From 038ca467d53fe522688fd64e9595b6b11b5abea6 Mon Sep 17 00:00:00 2001 From: Gunjan Gupta Date: Tue, 5 Dec 2023 17:19:13 +0530 Subject: [PATCH] Orange Pi Zero: Enable crust and fix suspend/resume (#6007) * Fix system doesnt come back from sleep because of xradio_wlan module Add workaround for getting suspend resume to work properly. This works by unloading xradio_wlan module on suspend and reloading the same on system resume. Tested by putting system to sleep for 20 seconds and bringing it back up via rtc wakealarm using the following command echo +20 > /sys/class/rtc/rtc0/wakealarm && systemctl suspend The rtcwake still causes the system to hang on resume, but atleast systemctl suspend works. * Enable crust for Orange Pi Zero --- config/boards/orangepizero.conf | 41 +++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/config/boards/orangepizero.conf b/config/boards/orangepizero.conf index 0e254ec283..ca9b21daae 100644 --- a/config/boards/orangepizero.conf +++ b/config/boards/orangepizero.conf @@ -11,3 +11,44 @@ HAS_VIDEO_OUTPUT="yes" SERIALCON="ttyS0,ttyGS0" KERNEL_TARGET="legacy,current,edge" KERNEL_TEST_TARGET="current" +CRUSTCONFIG="orangepi_zero_defconfig" + +function orange_pi_zero_enable_xradio_workarounds() { + /usr/bin/systemctl enable xradio_unload.service + /usr/bin/systemctl enable xradio_reload.service +} + +function post_family_tweaks_bsp__fix_resume_after_suspend() { + # Adding systemd services to remove and reload xradio module on suspend and resume + # respectively. It will fix suspend resume using systemctl suspend, but rtcwake is + # still be broken. + + run_host_command_logged cat <<- 'xradio_unload' > "${destination}"/etc/systemd/system/xradio_unload.service + [Unit] + Description=Unload xradio module on sleep + Before=sleep.target + + [Service] + Type=simple + ExecStart=-/usr/sbin/rmmod xradio_wlan + + [Install] + WantedBy=sleep.target + xradio_unload + + run_host_command_logged cat <<- 'xradio_reload' > "${destination}"/etc/systemd/system/xradio_reload.service + [Unit] + Description=Reload xradio module on resume + After=suspend.target + + [Service] + Type=simple + ExecStart=-/usr/sbin/modprobe xradio_wlan + + [Install] + WantedBy=suspend.target + xradio_reload + + # Enable workaround on apt upgrade of armbian-bsp-cli package + postinst_functions+=('orange_pi_zero_enable_xradio_workarounds') +}