Hi,
has anyone tested if sleep/suspend & resume works ? Could not find /sys/power ( I am using default buildroot). Only info that exists is that 8051 is able to resume the main C906 core but again no any examples … And if I remember right I had read a comment that suspend/resume functionality would be available by the end of April; are there any news regarding that?
The board has low power consumption (~ 500mW idle) but without suspend support it’s use in mobile applications (eg wearables) would be very limited …
Found out that suspend/resume may be enabled in kernel (buildroot)
*> cat /proc/cvitek/power * suspend resume
but not sure how to enable it. There is no /sys/power/state or any similar file.
Have not checked if default buildroot has PM enabled & have not checked if distros for duo256 have PM enabled. If anyone knows please share !
I went through the datasheet for SG2000/SG2002, and looking at the RTC channel I tried directly setting register values, to check if suspend works, like :
devmem 0x050260F0 32 0x0 # set RTC_PG_REG to 0 (from 0xF)
devmem 0x050260E4 32 0x1 # set RTC_EN_SUSPEND_REQ to 1
devmem 0x05025004 32 0xAB18 # UNLOCK WRITING TO RTC_CTRL0
devmem 0x05025008 32 0x8C0 # set RTC_CTRL0, so that req_suspend = 1
Problem is in the 1st statement seems to FAIL (vs 3 others). Maybe a HW bug or bad documentation or I should do that from RTC domain (8051). Will try again …
I am very interested in this as well. Suspend/resume looks to be supported according to the datasheet:
I suspect you’d need to send the signal from the 8051 core and maybe a heads up to linux kernel that system is about to go down?
I’ve never worked with the 8051 or any embedded stuff really but I have devmem and sdcc set up. I’ll try writing a program to load into 8051 sram that sleeps the main core for a few seconds and then wakes it.
I’d be happy to work with someone over IRC/Matrix figuring out how to implement this.
I’ve been playing around with some of the registers for shutdown/reboot/suspend. RTC_CTRL0 is set to 0xAB18, can’t seem to trigger any of the desired outcomes.
It looks like that procfs entry is generated by the kernel module cv181x_base.ko. In the Buildroot repo, that is a binary middleware/v2/cv181x/ko/cv181x_base.ko, not a source file unfortunately.
Linux suspend-to-RAM is working on the MilkV Duo with CV1800B. It is not working with the MilkV Duo S SG2000. On Duo, suspend and resume are working, with normal idle around .08A and suspend-to-RAM at .013A. SG2000 should be similar.
Suspending the Duo with CV1800B:
[root@milkv-duo]~# insmod /mnt/system/ko/cv180x_rtc.ko
[root@milkv-duo]~# hwclock -w
[root@milkv-duo]~# cat /sys/power/state
freeze mem
[root@milkv-duo]~# echo +30 >/sys/class/rtc/rtc0/wakealarm
[root@milkv-duo]~# echo mem > /sys/power/state
# Resumes in 30 seconds
This will update the kernel defconfig linux_5.10/build/sg2000_milkv_duos_musl_riscv64_sd/.config.
Build the image:
./build.sh milkv-duos-musl-riscv64-sd
On-device:
[root@milkv-duo]~# insmod /mnt/system/ko/cv181x_rtc.ko
[root@milkv-duo]~# hwclock -w
[root@milkv-duo]~# echo +30 >/sys/class/rtc/rtc0/wakealarm
[root@milkv-duo]~# echo mem > /sys/power/state
[ 87.494847] PM: dpm_run_callback(): pm_generic_suspend+0x0/0x12 returns -22
[ 87.494856] PM: Device mmc1:390b:2 failed to suspend async: error -22
[ 87.494882] PM: Some devices failed to suspend, or early wake event detected
sh: write error: Invalid argument
The shared suspend implementation is at opensbi/platform/generic/cvitek_riscv.c. It sets sleep / resume settings, then loads a prebuilt binary into SRAM and jumps to it to perform the actual suspend. The binary is platform-specific. CV1800B uses opensbi/pm_default_cv180x.bin and SG2000 uses opensbi/pm_default_cv181x.bin. Its contents can be examined after building using /opt/toolchain/Xuantie-900-gcc-linux-6.6.0-glibc-x86_64-V2.10.1/bin/riscv64-unknown-linux-gnu-objdump -D opensbi/build/platform/generic/cvitek_riscv.o.