Posts by offbeat

    jernej !

    I have a problem with my Orange pi 3 and Pine H64. All my 1080P contents (movies and episodes) are jerky (not smooth). The only workaround I found is to put devices to 2160p and whitelist only 2160p resolution. That way all my contents play well.

    Do you have this problem on your side ? This problem doesn't exist on my raspberry pi 4, orange pi PC and Orange pi PC2.

    Yup, playing content at native 24/25/30 Hz is still broken on Kodi+H6, very jerky.

    I even bothered to compile and test in mpv, using same drmprime path on H6, play silky smooth there.

    Playback is also OK on H3 board, using both Kodi and mpv.

    Its somehow related to the combination of Kodi stopping rendering GUI/OSD during playback and panfrost on H6.

    Workaround is to force Kodi to render GUI even when hidden, set algorithmdirtyregions to 0 in advancedsettings.xml. Of course power consumption/temperature rises a bit.

    However, maybe default frequency can be raised same way it is done for A64 (via DT)?

    Thank you for suggestions!

    I've upped Beelink GS1 GPU to 756MHz and 980mV.

    950mV had a few panfrost freezes/errors, 980mV runs Kodi and glmark2 without any problems.

    This board has 800MHz LPDDR3 module (AWL3A1632), at least my revision does.
    So I've also upped RAM frequency, pll-ddr0 is now reported to be running at 1.584GHz

    With these changes and performance governor Kodi GUI is now able to reach 60FPS, except in some graphics heavy screens.

    Thermal wise, thats 50C to 60C while idle, this box has suprisingly adequate heatsink.
    Power consumption difference between schedutil and performance is 0.3 Watts or so, insignificant.

    Reason why OSD helps is probably because EGL provides vsync... I don't know. Maybe windowing/gbm: Add display clock by popcornmix · Pull Request #19601 · xbmc/xbmc · GitHub will help. IDK.

    I've rebuild LE with patches from this PR and enabled "Sync playback to display", no visible changes at all.
    23.976 FPS on 23.976 Hz is still stuttering, drawing something with EGL still fixes it.

    Did some further tests on Beelink GS1: configured Kodi to always draw (algorithmdirtyregions=0), enabled GALLIUM_HUD, launched Kodi mainscreen and tried switching CPU governors.

    Basicly lowering CPU clock frequency affects Kodi GUI rendering speed, quite visibly.
    Panfrost performance is inadequate enough already, 30 FPS only, but default schedutil clocks down CPU (as it should, since load is low) and it pushes rendering speed even lower, to 20FPS. Frametime on schedutil is bouncy and erratic as well.
    Loading even one CPU core to 100% with something like 'openssl speed' instantly improves Kodi GUI rendering 20->30FPS


    Also, locking CPU frequency to max also gives like +20% performance to hardware video decoding.
    P.S. Testing it was a pain, the way ffmpeg is packaged in LibreElec is sooo confusing, binary programs aren't included in base build at all and ffmpeg-tools addon uses completely different build options, without any hardware decoding patches...

    Perhaps there are some issues with hardware clocks, lowering CPU frequency also downclocks some other parts of H6, no idea if it's memory controller or GPU/VE/GE whatever else.

    IMHO for now the only sane workaround is to use performance governor instead of default schedutil, forcing CPU to max 1.8GHz.

    Strange problem, playing 23.976 FPS video outputing to 23.976 Hz TV on Beelink GS1 is rather jerky, micro stutters twice a second or so.

    Switching CPU governor from default schedutil to ondemand makes things even worse. Changing governor to fixed frequency like performance or powersave helps, most of stutters are gone, but not all. Tested on two different TVs, same result.

    Making Kodi draw any OSD during playback completely solves this issue, no matter what governor is active.

    Can send a short video sample with pan movement, if needed.

    A few more things about GS1 suspend.

    Now that RTC is working, suspend/resume tests can be scripted using "rtcwake"... which isn't included in Libreelec, so had to to edit util-linux config, build and copy in binary.

    Code
    for i in $(seq 100); do
    echo "Suspend #$i"
    ./rtcwake -m mem -u -s 3
    sleep 10
    done

    100 iterations of rtcwake worked just fine, panfrost refused to suspend every now and then, but system stayed alive.
    Which got me thinking, why the hell suspending from Kodi is getting box to unwakeable state on panfrost failure?

    It turns out, systemd suspend is trying to enter deep sleep first (echo mem > /sys/power/state), and if it fails, enters lighter software-only sleep mode (echo freeze > /sys/power/state). Can't really wake up from "freeze" on GS1: no physical button, no wake-on-lan, control isn't transferred to Crust. Not sure if kernel is still processing IR in "freeze" mode, in case it does, some key remap may help.

    Anyway, for now solution is to force systemd to suspend using "mem" method only. OS won't go to unwakeable state then, even if GPU fails to suspend.

    Code
    /storage/.config/sleep.conf.d/sleep.conf
    [Sleep]
    SuspendState=mem

    jernej , perhaps it can be added to global /etc/systemd/sleep.conf for Crust supported boards?

    BTW, Crust/Linux fixes were just merged for GS1.

    Superb, thanks!

    Another issue I see is that GS1 doesn't seem to be running GPU at full speed.
    I've enabled debug OSD in Kodi, held remote right button to keep Kodi scrolling/redrawing, and tested in both stock Android (latest Kodi 19 APK) and Libreelec.

    Android animations are fluid, easily capping at screens 60FPS rate. Libreelec animations are rather jerky, FPS counter only goes to ~20FPS.

    Kernel log says GPU is running at 432Mhz, if I'm intepreting things right. Google sources say Mali T720 in H6 can be run at 600.. 650 up until 700 Mhz.
    There doesn't seem to be any way to control GPU frequency/voltage dynamicaly, devfreq API is missing.

    Code
    [    0.281057] vdd-gpu: supplied by vcc-5v
    [    7.221561] panfrost 1800000.gpu: clock rate = 432000000
    [    7.221586] panfrost 1800000.gpu: bus_clock rate = 200000000
    [    7.314868] panfrost 1800000.gpu: mali-t720 id 0x720 major 0x1 minor 0x1 status 0x0
    [    7.314880] panfrost 1800000.gpu: features: 00000000,10309e40, issues: 00000000,21054400
    [    7.314885] panfrost 1800000.gpu: Features: L2:0x07110206 Shader:0x00000000 Tiler:0x00000809 Mem:0x1 MMU:0x00002821 AS:0xf JS:0x7
    [    7.314889] panfrost 1800000.gpu: shader_present=0x3 l2_present=0x1
    [    7.425222] [drm] Initialized panfrost 1.1.0 20180908 for 1800000.gpu on minor 1

    Also, did some quick unscientific power usage checks on Beelink GS1, tested consumption at 230V wall socket using Voltcraft Energy Logger 4000.

    1) ~0.0W in shutdown state (with Crust running on co-processor).

    2) ~0.0W in suspended state (with Crust running, yey).

    3) 2.4W running, idle on Kodi homescreen. Kodi IS wasting too much CPU in idle mode though, shouldn't be more than a single digit percent of a low frequency state CPU core, not ~35-40% like at the moment.

    4) 2.7W playing 1080p60 H264 video from the SD card.

    5) 5.3W playing video + 100% load on all quad cores using 'openssl speed'

    I'd say, as soon as GPU driver and suspend/resume process is stable enough for a particular Alwinner board, default remote power button could be remapped from poweroff to suspend. That would result so much smoother and pleasant user experience, since suspend/resume is almost instant and power usage is insignificant as well.

    Preferred way to check CEC on mainline Linux is to stop Kodi (systemctl stop kodi) and run cec-ctl --playback -S.

    Tested Beelink GS1 CEC with a capable TV, command line scan and power on / standby are working just fine.

    Kodi CEC plugin integration isn't yet stable though:

    1) Bootup always brings up TV, shutdown mostly puts TV to standby, but sometimes Kodi crashes on shutdown and fails to send standby CEC command to TV. Didn't have time to check crash logs yet, only saw gdb core process before shutdown in htop.

    2) When it comes to suspend, there is like 50%/50% chance to standby TV as well. Perhaps suspend is too fast and doesn't wait for the result of CEC command?

    Here is another test image: LibreELEC-H6.arm-10.0-devel-20210330172558-ba292b4-beelink-gs1-pm-and-int-32k-osc.img.gz (burn it, don't update). At least RTC should be quiet now and maybe CEC and suspend/resume will work too. Let me know.

    1) RTC is fixed, time is saved between warm startups/reboots, nice!

    Code
    # cold 
    Feb 02 15:29:47 LibreELEC kernel: sun6i-rtc 7000000.rtc: registered as rtc0
    Feb 02 15:29:47 LibreELEC kernel: sun6i-rtc 7000000.rtc: setting system clock to 1970-01-01T00:00:03 UTC (3)
    Feb 02 15:29:47 LibreELEC kernel: sun6i-rtc 7000000.rtc: RTC enabled
    
    # warm
    Mar 30 17:20:41 LibreELEC kernel: sun6i-rtc 7000000.rtc: registered as rtc0
    Mar 30 17:20:41 LibreELEC kernel: sun6i-rtc 7000000.rtc: setting system clock to 2021-03-30T17:20:37 UTC (1617124837)
    Mar 30 17:20:41 LibreELEC kernel: sun6i-rtc 7000000.rtc: RTC enabled

    2) No more CEC errors in dmesg and cec-client. I will test ir further later, no access to capable TV at the moment.

    3) Suspend/resume and poweroff/poweron worked perfectly while connected to TV. In headless mode though suspend rarely works, mostly fails due to GPU driver error, resulting either instant wakeup, or suspend/crash/smthelse without ability to wake using remote.
    Headless poweroff/poweron using remote worked 100% during my tests

    Code
    Mar 30 17:12:22 LibreELEC kernel: OOM killer disabled.
    Mar 30 17:12:22 LibreELEC kernel: Freezing remaining freezable tasks ... (elapsed 0.001 seconds) done.
    Mar 30 17:12:22 LibreELEC kernel: printk: Suspending console(s) (use no_console_suspend to debug)
    Mar 30 17:12:22 LibreELEC kernel: PM: dpm_run_callback(): platform_pm_suspend+0x0/0x70 returns -16
    Mar 30 17:12:22 LibreELEC kernel: PM: Device 1800000.gpu failed to suspend: error -16
    Mar 30 17:12:22 LibreELEC kernel: PM: Some devices failed to suspend, or early wake event detected
    Mar 30 17:12:22 LibreELEC kernel: OOM killer enabled.
    Mar 30 17:12:22 LibreELEC kernel: Restarting tasks ... done.

    Thank you!

    Regarding RTC - it would be helpful, if you could read address 0x07000004 from Android.

    Here goes, Beelink GS1 last stock Android, firmware 106N0, kernel 3.10.65

    Code
    # busybox devmem 0x07000004
    0x00000004
    # echo "0x07000004,0x07000008" > /sys/class/sunxi_dump/dump
    # cat /sys/class/sunxi_dump/dump
    0x0000000007000000:            0x00000004 0x0000000f

    I see you had some relevant discussions when merging RTC support for H6. Re: [linux-sunxi] [PATCH v2 0/3] Add basic support for RTC on Allwinner H6 SoC - Jernej Škrabec

    Also, other user had this problem on GS1 Beelink GS1 Allwinner H6 - General Chat - Armbian forum

    So even if it is a hardware problem, whole batch has it then.

    Please test this image: LibreELEC-H6.arm-10.0-devel-20210328122614-ba292b4-beelink-gs1-pm-test.img.gz Note that you should not try to update but burn it freshly. Most types of update don't update bootloader which is responsible for loading suspend/resume firmware (this firmware is embedded in bootloader).

    Burned test image to SD card, booted, burned to eMMC. Had a rather limited access to TV during this weekend, so enabled SSH and tested using shell and remote.
    1) Cold boot via power toggle and issuing 'systemctl suspend' = box reboots in a few seconds. Subsequent 'systemctl suspend' seems to suspend the box, remote power button doesn't wake it up.

    2) Cold boot and 'systemctl poweroff' (or remote power button) = box reboots in a few seconds. Subsequent 'systemctl poweroff' (or remote power button) shutdowns the box, remote power button doesn't wake it up.

    BTW, poweroff take quite some time, ~15-20 seconds on cold boot, all the shutdown jobs run instantly and then its sitting there, waiting for something.. Wonder if its related to sun6i-rtc/cec-dw_hdmi oscillator problems. Here is a journalctl log captured on poweroff:

    Strange. I don't have this box but other developers do. Nobody reported such issues. This would suggest that external 32 kHz oscillator is missing. I'm pretty sure at least some GS1 boxes have it. Can you open your box and make high quality image (so all markings are readable and all components distinguishable)? It's possible that this is another revision and they changed few things.

    Here is a photo of my PCB, revision 2.0 Imgur: The magic of the Internet

    Almost the same as the one published in Beelink GS1 - linux-sunxi.org , although some chips are diferent.

    Sadly Beelink GS1 is the only H6 board without proper suspend/resume support. One of our developers couldn't make it work.

    I understand GitHub - crust-firmware/crust: SCP firmware for sunxi SoCs is used to suspend/resume main CPU. Should I open bugreport there, or can I help in any other way?