Open mcerveny opened 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
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.
Updated charger+battery+powerswitch https://github.com/mcerveny/rockchip-linux/commit/2147595873e0c7a8ccc92e70e748eeaca3575618. Due to HW design faults it is not perfect.
Open questions:
GPIO 93
over /sys/class/gpio/* ?
#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
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 ...
Open questions:
- Is it OK/tested ? If yes I will merge this sub-branch to https://github.com/mcerveny/rockchip-linux/tree/wx8.
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:
codec_hp_det
) . There's no suck an event here.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:
panel@0
and disaply-timings
to match those of the display, but it basically stays off. I can see the backlight turning on and off depending on whether a graphical application is being launched, but there's nothing in the display. I can provide some traces and extracted DTS if you believe you can help us finding out more about that.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.
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):
SPK
is not used (GPIO 35
== GPIO1-3), test it with LRMonoPhase4.wav
# ### "lo" means that amplifier is disabled (shutdown)
# grep spk-ctl /sys/kernel/debug/gpio
gpio-35 ( |spk-ctl ) out lo
UDEV
and programmed in /etc/udev/...
# udevadm monitor
monitor will print the received events for:
UDEV - the event which udev sends out after rule processing
KERNEL - the kernel uevent
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/...`
/sys/devices/virtual/switch/h2w/name:Headset /sys/devices/virtual/switch/h2w/state:2
/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)
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'
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 ?
- 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.
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.
* 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
* 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 showninnohdmi-rockchip 20034000.hdmi: failed to get edid
but EDID is already cached. So do not setdisconnected
but set DSI connector to DPMSoff
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.
* 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 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:
@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?
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).
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.
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
.
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
orps7000-rk3128_defconfig
. KERNEL is updated in ps7000 branch https://github.com/mcerveny/rockchip-linux/tree/ps7000 - patch mcerveny/rockchip-linux@75be5fa. Configuration remainswx8_defconfig
but there are specific dtb for boards -rk3128-ps5000.dtb
orrk3128-ps7000.dtb
.
Very nice progress!!! I can wait to promote to alpha and test something!!! There are so many folks that will appreciate that :)
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
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 :-)
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:
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:
retroarch
config ?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.
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:
gpio-keys-polled
. Using gpio-keys
didn't work because some release events were
lost (don't know why) causing drifting.rk30_adc_battery
that I remembered @mcerveny mentioned before as unknown driver. I looked for it and found the following repos, it says it's GPL, not sure where this kernel sources actually comes from. I didn't try to add it to the caesar version because of its dependencies and because I don't have the knowledge to decide whether that driver is worth to be added as it is or re-implemented.
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 :)
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 ...
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.
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.
Happy new year @mcerveny ! :)
@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.
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 !