Ruka-CFW / rk3128-cfw

*** DEPRECATED - DON'T USE *** Rockchip RK3128 Custom Firmware for Powkiddy A12/A13 & AIWO retro-consoles
Other
44 stars 14 forks source link

PS5000 factory updated -> rockchip uboot + 4.4 rockchip kernel opensource rebuild #51

Open mcerveny opened 3 years ago

mcerveny commented 3 years ago

Hello.

Update script ruka_install_ps5000.sh (ruka_cfw_3.0_beta_1_20210806.tgz) partition table does not match for userdata_ps5000_20210806.img partition (offset 0x00028800). I received updated version with different LBA offset 0x0002b000 !

$ ### different partition start (userdata) from "upgrade_tool"
$ sudo ./upgrade_tool 

...

Rockusb>pl
Partition Info(gpt):
NO  LBA        Size       Name
01  0x00002000 0x00000800 uboot
02  0x00002800 0x00001000 trust
03  0x00003800 0x00004800 boot
04  0x00008000 0x00023000 rootfs
05  0x0002b000 0x0000addf userdata

$ ### different verified from boot (serial console), factory build "Jul 8 10:53:53 CST 2021" !
$ cu -l /dev/ttyUSB0 -s 115200 -f

...

U-Boot 2017.09-gf468676-dirty (Jul 08 2021 - 10:53:40 +0800)

...

[root@root:/]# echo p | fdisk /dev/rkflash0 
Found valid GPT with protective MBR; using GPT

Command (m for help): Disk /dev/rkflash0: 220672 sectors,  107M
Logical sector size: 512
Disk identifier (GUID): 9c220000-0000-4e3b-8000-557800002e7b
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 220638

Number  Start (sector)    End (sector)  Size Name
     1            8192           10239 1024K uboot
     2           10240           14335 2048K trust
     3           14336           32767 9216K boot
     4           32768          176127 70.0M rootfs
     5          176128          220638 21.7M userdata

Command (m for help): [root@root:/]# 
[root@root:/]# uname -a
Linux root 4.4.159 #1047 SMP Thu Jul 8 10:53:53 CST 2021 armv7l GNU/Linux
[root@root:/]# cat /etc/os-release 
NAME=Buildroot
VERSION=2018.02-rc3-00808-gc9c3b18-dirty
ID=buildroot
VERSION_ID=2018.02-rc3
PRETTY_NAME="Buildroot 2018.02-rc3"
mcerveny commented 3 years ago

I added first try of battery mgmt driver (branch https://github.com/mcerveny/rockchip-linux/tree/wip-chgr, commit https://github.com/mcerveny/rockchip-linux/commit/db0a5e5cc926dc3c316912d3edd7d71191f5d035). Because I lost my TP4056 during HW measurement I must replace chip to continue. So the driver is incomplete for now. To test driver, charging:

# grep '' /sys/class/power_supply/*/*
/sys/class/power_supply/battery/capacity:60
/sys/class/power_supply/battery/charge_full:3000000
/sys/class/power_supply/battery/health:Good
/sys/class/power_supply/battery/present:1
/sys/class/power_supply/battery/status:Not charging               # <------ should be charging with TP4056
/sys/class/power_supply/battery/technology:Li-ion
/sys/class/power_supply/battery/type:Battery
/sys/class/power_supply/battery/uevent:POWER_SUPPLY_NAME=battery
/sys/class/power_supply/battery/uevent:POWER_SUPPLY_STATUS=Not charging
/sys/class/power_supply/battery/uevent:POWER_SUPPLY_VOLTAGE_NOW=3860000
/sys/class/power_supply/battery/uevent:POWER_SUPPLY_TECHNOLOGY=Li-ion
/sys/class/power_supply/battery/uevent:POWER_SUPPLY_PRESENT=1
/sys/class/power_supply/battery/uevent:POWER_SUPPLY_HEALTH=Good
/sys/class/power_supply/battery/uevent:POWER_SUPPLY_CAPACITY=60
/sys/class/power_supply/battery/uevent:POWER_SUPPLY_CHARGE_FULL=3000000
/sys/class/power_supply/battery/uevent:POWER_SUPPLY_VOLTAGE_MAX_DESIGN=4205000
/sys/class/power_supply/battery/uevent:POWER_SUPPLY_VOLTAGE_MIN_DESIGN=3400000
/sys/class/power_supply/battery/voltage_max_design:4205000
/sys/class/power_supply/battery/voltage_min_design:3400000
/sys/class/power_supply/battery/voltage_now:3860000
/sys/class/power_supply/usb/online:1
/sys/class/power_supply/usb/type:USB
/sys/class/power_supply/usb/uevent:POWER_SUPPLY_NAME=usb
/sys/class/power_supply/usb/uevent:POWER_SUPPLY_ONLINE=1

Discharging:

/sys/class/power_supply/battery/capacity:51
/sys/class/power_supply/battery/charge_full:3000000
/sys/class/power_supply/battery/health:Good
/sys/class/power_supply/battery/present:1
/sys/class/power_supply/battery/status:Discharging
/sys/class/power_supply/battery/technology:Li-ion
/sys/class/power_supply/battery/type:Battery
/sys/class/power_supply/battery/uevent:POWER_SUPPLY_NAME=battery
/sys/class/power_supply/battery/uevent:POWER_SUPPLY_STATUS=Discharging
/sys/class/power_supply/battery/uevent:POWER_SUPPLY_VOLTAGE_NOW=3796000
/sys/class/power_supply/battery/uevent:POWER_SUPPLY_TECHNOLOGY=Li-ion
/sys/class/power_supply/battery/uevent:POWER_SUPPLY_PRESENT=1
/sys/class/power_supply/battery/uevent:POWER_SUPPLY_HEALTH=Good
/sys/class/power_supply/battery/uevent:POWER_SUPPLY_CAPACITY=51
/sys/class/power_supply/battery/uevent:POWER_SUPPLY_CHARGE_FULL=3000000
/sys/class/power_supply/battery/uevent:POWER_SUPPLY_VOLTAGE_MAX_DESIGN=4205000
/sys/class/power_supply/battery/uevent:POWER_SUPPLY_VOLTAGE_MIN_DESIGN=3400000
/sys/class/power_supply/battery/voltage_max_design:4205000
/sys/class/power_supply/battery/voltage_min_design:3400000
/sys/class/power_supply/battery/voltage_now:3796000
/sys/class/power_supply/usb/online:0
/sys/class/power_supply/usb/type:USB
/sys/class/power_supply/usb/uevent:POWER_SUPPLY_NAME=usb
/sys/class/power_supply/usb/uevent:POWER_SUPPLY_ONLINE=0
acmeplus commented 3 years ago

To test driver, charging:

Very good, battery status is now displayed on supporting apps (e.g. EmulationStation and Retroarch).

Battery status charging shows 64 out of a total CAPACITY of 64, but applications show the actual value instead of the percentage (e.g. 64% instead of 100%). Removed power supply and status shows 99% (as opposed to 100%). I assume that's consistent since you indicate the driver is incomplete.

Let me know if you need me to test anything else.

mcerveny commented 3 years ago

Updated charger+battery+powerswitch https://github.com/mcerveny/rockchip-linux/commit/2147595873e0c7a8ccc92e70e748eeaca3575618. Due to HW design faults it is not perfect.

Open questions:

define BTN_DPAD_UP 0x220

define BTN_DPAD_DOWN 0x221

define BTN_DPAD_LEFT 0x222

define BTN_DPAD_RIGHT 0x223


PS: Drivers "wx8joy" and "wx8-charger" and DTB "rk3128-wx8.dtb" (kernel and uboot) are tested with WX8  board only. I do not own Powkiddy A12/A13 or other similar rk3128 based handhelds.
WX8 board is in **PS5000/Q500, LINTIAN LT-8203, [Powkiddy X20](https://www.youtube.com/watch?v=sDqQAObfrQM), PS7000/Q900 ([some versions (2021?)](https://www.alibaba.com/product-detail/Handheld-game-console-big-screen-PS7000_1600146097956.html) with 7" display)** and any other similar handhelds ...
acmeplus commented 3 years ago

Open questions:

I've done some tests and it looks good. I've not seen any regressions compared with wx8, and the additional fixes you have included improve the system.

One thing we have noticed is that there is no headphone plug event. It's probably something that can be added to the DTS but I'm not sure if that's one of those things that are missing/not available.

  • Is "low-battery" handled in RetroArch or EmulationStation ... ?

Need to leave the system running to get to a low battery state. I believe ES has a low battery warning, not sure about RetroArch.

  • Can anyone "calibrate" battery charge/discharge values (volts to percent) ?

We will try to find someone to do this task.

  • Can powersave be hooked in RetroArch or EmulationStation ... ?

Need to check that. I believe RetroPie has a power save method but it's handled at the board level, not at the Frontend/Emulator level.

  • shutdown/startup "DCDC boosters" with GPIO 93 over /sys/class/gpio/* ?
  • or can I try to extend this driver to hook FB events (blank/unblank) ?

You are the expert there. Either method seems logical, but I'm not sure about the implications in terms of performance.

  • wx8-joysticks default to analog or to key emulation (echo 1 > /sys/devices/platform/20072000.i2c/i2c-0/0-004c/key_type) ?

Default analogue mode is preferred. RA passes that configuration directly to some emulators like flycast or ppsspp that can use analogue controls directly.

  • keys mapping as-is or should be used "GAMEPAD" buttons ?
#define BTN_GAMEPAD       0x130
#define BTN_SOUTH     0x130
#define BTN_A         BTN_SOUTH
#define BTN_EAST      0x131
#define BTN_B         BTN_EAST
#define BTN_C         0x132
#define BTN_NORTH     0x133
#define BTN_X         BTN_NORTH
#define BTN_WEST      0x134
#define BTN_Y         BTN_WEST
#define BTN_Z         0x135
#define BTN_TL            0x136
#define BTN_TR            0x137
#define BTN_TL2           0x138
#define BTN_TR2           0x139
#define BTN_SELECT        0x13a
#define BTN_START     0x13b
#define BTN_MODE      0x13c
#define BTN_THUMBL        0x13d
#define BTN_THUMBR        0x13e

#define BTN_DPAD_UP       0x220
#define BTN_DPAD_DOWN     0x221
#define BTN_DPAD_LEFT     0x222
#define BTN_DPAD_RIGHT        0x223

Those make sense to me. Some observations about the mappings:

acmeplus commented 3 years ago

PS: Drivers "wx8joy" and "wx8-charger" and DTB "rk3128-wx8.dtb" (kernel and uboot) are tested with WX8 board only. I do not own Powkiddy A12/A13 or other similar rk3128 based handhelds. WX8 board is in PS5000/Q500, LINTIAN LT-8203, Powkiddy X20, PS7000/Q900 (some versions (2021?) with 7" display) and any other similar handhelds ...

I've tried to modify the DTS to get the A12 to boot. Some comments in case you may give us some hints:

For the PS7000, we don't have that board but we have backups of the firmware. Probably the same as X20 and X2. There's also the Q400 that seems to be similar too.

mcerveny commented 3 years ago

One thing we have noticed is that there is no headphone plug event. It's probably something that can be added to the DTS but I'm not sure if that's one of those things that are missing/not available.

Headphone event is working in "rockchip,rk3128-codec" (see sound/soc/codecs/rk312x_codec.c):

KERNEL[1021.534397] change /devices/virtual/switch/h2w (switch) UDEV [1021.592263] change /devices/virtual/switch/h2w (switch) KERNEL[1024.800785] change /devices/virtual/switch/h2w (switch) UDEV [1024.846588] change /devices/virtual/switch/h2w (switch)

- status can be also monitored by `/sys/...`

state:2 -> headtset plugged - BIT_HEADSET_NO_MIC

grep '' /sys/devices/virtual/switch/h2w/*

/sys/devices/virtual/switch/h2w/name:Headset /sys/devices/virtual/switch/h2w/state:2

grep '' /sys/devices/virtual/switch/h2w/*

/sys/devices/virtual/switch/h2w/name:Headset /sys/devices/virtual/switch/h2w/state:0

- automatically switch ALSA subsystem to "SPK", "HP", "SPK_HP" (actual code does not mute "SPK" if "HP" is present - "SPK_HP" is used)

amixer

Simple mixer control 'Playback Path',0 Capabilities: enum Items: 'OFF' 'RCV' 'SPK' 'HP' 'HP_NO_MIC' 'BT' 'SPK_HP' 'RING_SPK' 'RING_HP' 'RING_HP_NO_MIC' 'RING_SPK_HP' Item0: 'SPK' Simple mixer control 'Capture MIC Path',0 Capabilities: enum Items: 'MIC OFF' 'Main Mic' 'Hands Free Mic' 'BT Sco Mic' Item0: 'MIC OFF' Simple mixer control 'Voice Call Path',0 Capabilities: enum Items: 'OFF' 'RCV' 'SPK' 'HP' 'HP_NO_MIC' 'BT' Item0: 'OFF'

after plug headphone ... -> HP

amixer

Simple mixer control 'Playback Path',0 Capabilities: enum Items: 'OFF' 'RCV' 'SPK' 'HP' 'HP_NO_MIC' 'BT' 'SPK_HP' 'RING_SPK' 'RING_HP' 'RING_HP_NO_MIC' 'RING_SPK_HP' Item0: 'HP' Simple mixer control 'Capture MIC Path',0 Capabilities: enum Items: 'MIC OFF' 'Main Mic' 'Hands Free Mic' 'BT Sco Mic' Item0: 'MIC OFF' Simple mixer control 'Voice Call Path',0 Capabilities: enum Items: 'OFF' 'RCV' 'SPK' 'HP' 'HP_NO_MIC' 'BT' Item0: 'OFF'



So what are you missing ?
mcerveny commented 3 years ago
  • wx8-joysticks default to analog or to key emulation (echo 1 > /sys/devices/platform/20072000.i2c/i2c-0/0-004c/key_type) ?

Default analogue mode is preferred. RA passes that configuration directly to some emulators like flycast or ppsspp that can use analogue controls directly.

  • keys mapping as-is or should be used "GAMEPAD" buttons ?

Those make sense to me.

~~Done, new branch https://github.com/mcerveny/rockchip-linux/tree/wip-wx8-keys (also updated base kernel from mirror) with commit https://github.com/mcerveny/rockchip-linux/commit/569fa28baafba0d5e93a876c66823882df8dcb52. All mappings to emulators must be redefined, also "BTN_EAST" is "BTN_B" on "original gamepad" but "BTN_A" on "cloned gamepad". Default names are east/west/north/south. Swapped button A-B-X-Y colors and positions probably due to "copyright" reason.~~ I will merge this to wx8 (and wx8-updates) branch after update emulators mappings. Is it even possible ? I did not decode this possibility in code only "std keyboard mapping" (like https://docs.libretro.com/guides/input-and-controls/).

Update: New configurable version of keys/joystick/keys-emulation is in new branch https://github.com/mcerveny/rockchip-linux/tree/ps7000 commit https://github.com/mcerveny/rockchip-linux/commit/5d6c51020581cfb4d965302e59a4c874fc6bee8d.

acmeplus commented 3 years ago

So what are you missing ?

Nevermind @mcerveny. It's just an issue with missing udev rules as well as the other arm-headphone scripts that were present in the modified ruka but not on the batocera rootfs. Sorry to waste your time.

I'll add the missing pieces to the batocera fsoverlay and it should work as it used to do on the OFW or ruka FW.

mcerveny commented 3 years ago
* hdmi EDID problem tracing

EDID is generally OK. EEPROM and HPD is powered (~5V) from USB or from DCDC booster (no additional GPIO switches needed). The problem is only in one situation if DSI connector is set to disconnected then HDMI lost IRQ/timeout (including I2C EDID) (HDMI works normally) and error is shown innohdmi-rockchip 20034000.hdmi: failed to get edid but EDID is already cached. So do not set disconnected but set DSI connector to DPMS off state. Problem is somewhere in rk3128 chip or in some settings (maybe dclk_vop clock). I checked HDMI code path and corresponds to datasheet steps to get EDID, Example to generate error:

# ### off -> disable connecor
# echo off > /sys/class/drm/card0-DSI-1/status
# echo off > /sys/class/drm/card0-HDMI-A-1/status
# echo on > /sys/class/drm/card0-HDMI-A-1/status
# dmesg | grep edid 
[ 2540.495405] innohdmi-rockchip 20034000.hdmi: failed to get edid
# modetest -c | grep ^6
62  0   disconnected    DSI-1           0x0     0   61
64  63  connected   HDMI-A-1        340x190     13  63

HDMI audio works OK.

# cat /sys/class/drm/card0-HDMI-A-1/audioformat 
LPCM,
# ### play to HDMI
# aplay --device plughw:CARD=0,DEV=1 /sdcard/LRMonoPhase4.wav 
# ### play to internal
# aplay --device plughw:CARD=0,DEV=0 /sdcard/LRMonoPhase4.wav 
acmeplus commented 3 years ago
* hdmi EDID problem tracing

EDID is generally OK. EEPROM and HPD is powered (~5V) from USB or from DCDC booster (no additional GPIO switches needed). The problem is only in one situation if DSI connector is set to disconnected then HDMI lost IRQ/timeout (including I2C EDID) (HDMI works normally) and error is shown innohdmi-rockchip 20034000.hdmi: failed to get edid but EDID is already cached. So do not set disconnected but set DSI connector to DPMS off state. Problem is somewhere in rk3128 chip or in some settings (maybe dclk_vop clock). I checked HDMI code path and corresponds to datasheet steps to get EDID, Example to generate error:

# ### off -> disable connecor
# echo off > /sys/class/drm/card0-DSI-1/status
# echo off > /sys/class/drm/card0-HDMI-A-1/status
# echo on > /sys/class/drm/card0-HDMI-A-1/status
# dmesg | grep edid 
[ 2540.495405] innohdmi-rockchip 20034000.hdmi: failed to get edid
# modetest -c | grep ^6
62    0   disconnected    DSI-1           0x0     0   61
64    63  connected   HDMI-A-1        340x190     13  63

I did some experiments with the batocera build with HDMI and I can confirm that behavior. HDMI behavior seems consistent and the method of turning off DSI, turning off HDMI, turning on HDMI enables the HDMI display correctly.

mcerveny commented 2 years ago
* Can anyone "calibrate" battery charge/discharge values (volts to percent) ?

I done time-based battery calibration. Updated to "wx8" and "wx8-updates" branches https://github.com/mcerveny/rockchip-linux/commit/026c5f3ef73c2d76c12ccb4d7e44d8e69cda7262 + https://github.com/mcerveny/rockchip-linux/commit/95eae0f3791875cbdf577ae139ee6277f90bc120. Maximum power draw (to empty battery):

Discharge: discharge Discharge script:

echo performance > /sys/devices/platform/10091000.gpu/devfreq/10091000.gpu/governor 
echo performance > /sys/devices/platform/dmc/devfreq/dmc/governor
echo performance > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor

while true; do
    weston-simple-egl > /dev/null &

    sleep 30

    date

    grep '' \
     /sys/devices/platform/10091000.gpu/devfreq/10091000.gpu/cur_freq \
     /sys/devices/platform/10091000.gpu/devfreq/10091000.gpu/load \
     /sys/devices/platform/dmc/devfreq/dmc/cur_freq \
     /sys/devices/system/cpu/cpufreq/policy0/cpuinfo_cur_freq \
     /sys/class/thermal/thermal_zone0/temp \
     /sys/class/power_supply/battery/voltage_now \
     /sys/class/power_supply/battery/capacity \
     /proc/loadavg

     sleep 30

     killall weston-simple-egl
done

echo simple_ondemand > /sys/devices/platform/10091000.gpu/devfreq/10091000.gpu/governor 
echo dmc_ondemand > /sys/devices/platform/dmc/devfreq/dmc/governor
echo ondemand > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor

One measure like:

Thu Jan  1 01:15:14 UTC 1970
/sys/devices/platform/10091000.gpu/devfreq/10091000.gpu/cur_freq:480000000
/sys/devices/platform/10091000.gpu/devfreq/10091000.gpu/load:0@480000000Hz
/sys/devices/platform/dmc/devfreq/dmc/cur_freq:456000000
/sys/devices/system/cpu/cpufreq/policy0/cpuinfo_cur_freq:1200000
/sys/class/thermal/thermal_zone0/temp:65076
/sys/class/power_supply/battery/voltage_now:4144000
/sys/class/power_supply/battery/capacity:96
/proc/loadavg:2.06 1.99 1.38 3/105 382

Charge: charge

alpgarcia commented 2 years ago

@mcerveny, @acmeplus, one thing I noticed is now the sound always outputs both by the speaker and the headphones, no matter the playback path you set (either manually or via udev change event).

With the closed source kernel + uboot it works as expected. Any idea on where the problem could be?

mcerveny commented 2 years ago

Expected - see my test https://github.com/Ruka-CFW/rk3128-cfw/issues/51#issuecomment-932687725. ALSA and Rockchip driver is total chaos but there is possible solution (probably in udev script (https://github.com/rockchip-linux/kernel/blob/82c9666cb6fe999eb61f23c2c9d0d5dad7332fb6/sound/soc/codecs/rk312x_codec.c#L2023)):

# ### 1) test state:2 -> headtset plugged - BIT_HEADSET_NO_MIC 
# grep '' /sys/devices/virtual/switch/h2w/*
/sys/devices/virtual/switch/h2w/name:Headset
/sys/devices/virtual/switch/h2w/state:2`
# ### 2 - yes) disable speaker amplifier manually
# echo d > /sys/codec-spk-ctl/spk-ctl
# ### 2 - no) enable speaker amplifier manually
# echo e >  /sys/codec-spk-ctl/spk-ctl

Maybe another solution - rk312x_for_mid = <1>; in DTS but it does not work for me (https://github.com/rockchip-linux/kernel/blob/82c9666cb6fe999eb61f23c2c9d0d5dad7332fb6/sound/soc/codecs/rk312x_codec.c#L1561).

PS: I received PS7000 with wx8 board (manufactured >=12/2020) and begin to modify DTS, Display is RGB (24bit, mode clock 51200 kHz,H: 1024 1184 1204 1344, V: 0600 0612 0615 0635). ps7000

acmeplus commented 2 years ago

PS: I received PS7000 with wx8 board (manufactured >=12/2020) and begin to modify DTS, Display is RGB (24bit, mode clock 51200 kHz,H: 1024 1184 1204 1344, V: 0600 0612 0615 0635).

Very nice @mcerveny. That will help us to figure out the display issues on the A12/A13. Everything else on the A12/A13 seems to be working with the same firmware.

mcerveny commented 2 years ago

PS7000 & PS5000 are now supported. UBOOT is updated in ps7000 branch https://github.com/mcerveny/caesar-u-boot/tree/ps7000 - patch https://github.com/mcerveny/caesar-u-boot/commit/e20e9d85d326345fb2e80105a79263c95757414f. There are two configurations - ps5000-rk3128_defconfig or ps7000-rk3128_defconfig. KERNEL is updated in ps7000 branch https://github.com/mcerveny/rockchip-linux/tree/ps7000 - patch https://github.com/mcerveny/rockchip-linux/commit/75be5fa2d065d5605350749e1a4c2c5dc7f04bab. Configuration remains wx8_defconfig but there are specific dtb for boards - rk3128-ps5000.dtb or rk3128-ps7000.dtb.

ftirador commented 2 years ago

PS7000 & PS5000 are now supported. UBOOT is updated in ps7000 branch https://github.com/mcerveny/caesar-u-boot/tree/ps7000 - patch mcerveny/caesar-u-boot@e20e9d8. There are two configurations - ps5000-rk3128_defconfig or ps7000-rk3128_defconfig. KERNEL is updated in ps7000 branch https://github.com/mcerveny/rockchip-linux/tree/ps7000 - patch mcerveny/rockchip-linux@75be5fa. Configuration remains wx8_defconfig but there are specific dtb for boards - rk3128-ps5000.dtb or rk3128-ps7000.dtb.

Very nice progress!!! I can wait to promote to alpha and test something!!! There are so many folks that will appreciate that :)

mcerveny commented 2 years ago

Backlight PWM0 does not have any impact (probably totally irrelevant for DSI/MIPI display (probably running at maximum backlight power) but maybe relevant for unconnected/unpopulated RGB display).

PS7000 (parallel RGB display) backlight PWM is supported ! The default brightness is 200 - https://github.com/mcerveny/rockchip-linux/blob/ps7000/arch/arm/boot/dts/rk3128-ps7000.dts#L15

# cat /sys/devices/platform/backlight/backlight/backlight/brightness
200
# ### turn off
# echo 0 >  /sys/devices/platform/backlight/backlight/backlight/brightness
# ### full brightness (full backlight LED power)
# echo 255 > /sys/devices/platform/backlight/backlight/backlight/brightness
mcerveny commented 2 years ago

wx7 board (used in PS7000/Q900 <12/2020, ...) seems to be nearly same to wx8 (used in PS7000 >=12/2020, PS5000...):

Did someone try to replace tragic non IPS display in PS7000 with IPS display ? One year passed expecting wx9 variant :-)

ps7000_wx7 ps7000_wx7_1

acmeplus commented 2 years ago

Did someone try to replace tragic non IPS display in PS7000 with IPS display ?

@mcerveny according to @fakemaria a user in one of the forums replaced that screen with this IPS one:

https://a.aliexpress.com/_uQ8lOi

mcerveny commented 2 years ago

PS7000 & PS5000 are now supported.

I corrected keys, analog joysticks and joystick key emulation (echo 1 > /sys/devices/platform/20072000.i2c/i2c-0/0-004c/key_emulation) for different side PCBs in PS5000/PS7000. All keys/joysticks/emulated keys configurations are in DTB now. Driver was renamed to wx8-joysticks. See commit https://github.com/mcerveny/rockchip-linux/commit/5d6c51020581cfb4d965302e59a4c874fc6bee8d in branch https://github.com/mcerveny/rockchip-linux/tree/ps7000. There is also updated kernel (from jeffycn) for testing https://github.com/mcerveny/rockchip-linux/tree/ps7000-updates.

Not feedback for joystick driver:

alpgarcia commented 2 years ago

Not feedback for joystick driver:

  • need to normalize values to 0-255 (raw ADC values are ~95-~225 middle ~165, uncertainty +-5)?
  • need to assign minimum to left (or right) and top (or bottom) or it is configurable somewhere in retroarch config ?

In Retroarch you can set a deadzone vía Settings -> Input -> Analog deadzone. Not sure if that's what you're looking for.

alpgarcia commented 2 years ago

I've been adding support for the Powkiddy A13 console. It is worth noting a12 and a13 has different hardware revisions, including different displays with different resolutions. Mine for instance is what we called rev B (1024x600). I guess we should add a section in the wiki to describe what we know is different on each model.

Said that, this is my first time touching the device tree, so big disclaimer here, help and advice more than welcome. I forked @mcerveny's repos and added some changes to uboot on https://github.com/alpgarcia/caesar-u-boot/tree/powkiddy-a13 (https://github.com/alpgarcia/caesar-u-boot/commit/9724e7aac8f99c2b9cb225b8cb12590153440cb4) and to the kernel on https://github.com/alpgarcia/rockchip-linux/tree/powkiddy-a13 (https://github.com/alpgarcia/rockchip-linux/commit/fcacd11580639c4d47caa4b0a31c5cd0deb7f0a4). Of course my intention is sending PRs to the original repos when ready and use my forks for development purposes only.

I tried to not touch the dts hierarchy to keep my changes isolated for the moment. I created separate configs and dts files with the changes. In the case of the kernel I overwrote those definitions where I found some pins that were different from the already supported boards. I don't know what is the best way to add these changes, just tried to touch the minimum number of files possible at this point.

Some things I noticed:

The boot log still needs to be reviewed to find other errors in the definitions. Nevertheless, the screen and controls are working on my Powkiddy a13 without the drifting problems I mentioned above.

Please @mcerveny and @acmeplus let me know your thoughts and advices :)

mcerveny commented 2 years ago

Said that, this is my first time touching the device tree...

First you must get original DTB for u-boot (usually attached at the end of u-boot.bin) and kernel blobs (usually in android resource partition) and decompile with dts command to compare with yours (some hits dtc with -s (sort), decompile also new one and compare with meld or something like that). The board https://www.aliexpress.com/item/1005002674824010.html may use different PINs to charger circuit, PINs for usb power, PINs for audio power but also different PWMs for CPU, GPU and backlight power... It may be dangerous to use different DTB for different board.

gpio-keys didn't work

Weird. All pins are mapable via PIN bank virtual IRQ https://elixir.bootlin.com/linux/v4.4.293/source/drivers/pinctrl/pinctrl-rockchip.c#L1440

Battery driver

I was aware of this code but this code is incompatible (old). There is no DTS configs ...

alpgarcia commented 2 years ago

It may be dangerous to use different DTB for different board.

I was comparing stuff manually (grep and friends) from the sources, I hadn't thought of decompiling the final dtb instead, thanks a lot for the hint!

Weird. All pins are mapable via PIN bank virtual IRQ https://elixir.bootlin.com/linux/v4.4.293/source/drivers/pinctrl/pinctrl-rockchip.c#L1440

They are, and the events work, but sometimes the release event is not detected. The log of evtest is like the following:

Event: time 1129.110245, type 1 (EV_KEY), code 545 (BTN_DPAD_DOWN), value 1
Event: time 1129.110245, -------------- SYN_REPORT ------------
Event: time 1139.990214, type 1 (EV_KEY), code 545 (BTN_DPAD_DOWN), value 0
Event: time 1139.990214, -------------- SYN_REPORT ------------

The second event (0) in this log happens after a second joystick movement, not after the initial one (it is an arcade stick with push buttons). The first movement only seems to generate the press event. And of course, this occurs "randomly", sometimes the release event is there, sometimes not, causing the drifting effect. I thought I might have missed some other wrong definition of those pins somewhere, but I guess there would be a message in the logs and the controller definition would be rolled back during boot.

mcerveny commented 2 years ago
linux,code = <BTN_DPAD_DOWN>;
gpios = <&gpio2 0x17 GPIO_ACTIVE_LOW>;
    arcade_stick: arcade-stick {
      rockchip,pins = <
...
           RK_GPIO2 0x17 0x00 &pcfg_pull_default

There is fixed pull up/down problem in RK3128 - see https://rockchip.fr/RK312X%20TRM/chapter-01-introduction.pdf

I suppose that GPIO2_C7 (and GPIO2_C6, GPIO2_D0, GPIO2_D1) is pull down but on board is explicit pull up resistor. So pulled in both direction and due to some parasitic capacity the result does not work as expected (check original kernel DTB). Try to set "&pcfg_pull_none" to this pin. I had the same problem with R3.

acmeplus commented 2 years ago

Happy new year @mcerveny ! :)

acmeplus commented 2 years ago

@mcerveny hope you are doing well. We have been updating the build and is now getting ready to get it to merge into the main batocera repo, the main branch is here and you can follow the conversation in this issue.

However, there are few issues that I don't understand:

Anyway, let me know if you have some ideas. You can find releases for ps5000, ps7000, etc. in the releases page.