Repository navigation
hi3516cv300: give hwclock the SoC RTC as /dev/rtc0 - #2643
Conversation
PR Summary by QodoEnable the SoC RTC for hi3516cv300 and hi3516ev100
AI Description
Diagram
High-Level Assessment
Files changed (2)
|
Code Review by Qodo
1.
|
The cv300 kernel was built without the RTC class, so the board had no /dev/rtc0: hwclock failed with "can't open '/dev/misc/rtc'", hctosys never ran, and fake-hwclock had no RTC to keep. The SDK's hi3516cv300_rtc.ko, which the image ships but nothing loads, cannot stand in: it offers only private HI_RTC_* ioctls, so hwclock's RTC_RD_TIME on it fails with EPERM (#191). Turn on the RTC class with hctosys, systohc, the dev, sysfs and proc interfaces, and rtc-hibvt. It binds once the device tree names the RTC "hisilicon,hi35xx-rtc" (OpenIPC/linux#125); until then this costs about 8 KB of kernel and changes nothing else. hi3516ev100 shares the kernel family but is left as it is: there is no ev100 board to run it on.
e7b3bca to
c607f54
Compare
|
/review |
|
Code review by qodo was updated up to the latest commit c607f54 |
Fixes #191.
Problem
On hi3516cv300,
hwclockcannot use the SoC's RTC. Lab hi3516cv300 onhi3516cv300_lite, master+6f03cc4:The kernel config has
# CONFIG_RTC_CLASS is not set, so there is no/dev/rtc0. hctosys never runs, andfake-hwclockhas no RTC to keep.The image ships the SDK's
hi3516cv300_rtc.ko, which nothing loads. It can't stand in for a real driver: it is a character device with privateHI_RTC_*ioctls, sohwclock'sRTC_RD_TIMEon it fails withOperation not permitted, exactly as reported in #191.The RTC itself works. With no driver loaded, its counter reads day 14, 01:08, which matches the board's 14 days of uptime: it ticks from power-on.
Change
hi3516cv300.generic.configturns on:RTC_CLASS, with hctosys and systohc;RTC_DRV_HIBVT.Depends on OpenIPC/linux#125. The cv300 device tree names the RTC
"hisilicon,hi_rtc", whichrtc-hibvtdoesn't match, and #125 fixes that. #125 also brings in the driver fixes from OpenIPC/linux#81: no 1970 from a counter that lost power, and no read failure from the low-voltage flag. Until #125 is merged, this change costs about 8 KB of kernel and changes nothing else: the driver is built but never binds.Left alone:
hi3516ev100.generic.config. It shares the kernel family, but there is no ev100 board to test it on, so it is not part of this change (Qodo's review point).hi3516cv300.neo.config. It is a minimal config that never mentions the RTC.Kernel size: the same tree, toolchain and global patches, built both ways. zImage grows from 1,680,160 to 1,688,608 bytes (+8,448), and the DTB by +4. That makes the uImage about 1667 KB of the 2048 KB cap.
Hardware tested on
hi3516cv300, lab board
hi3516cv300-imx291(hi3516cv300_lite), no backup battery.I built the kernel with Buildroot from this branch, with OpenIPC/linux#125's two commits applied to its source. U-Boot loaded it over TFTP. The NOR kernel was never written, and afterwards the board went back to its own kernel and its original environment.
The kernel was rebuilt and re-run on this board after OpenIPC/linux#125's
set_time()fix: setting the time returns0, 1999 is refused, and the time reads back.Evidence
Before (shipped kernel):
After. First boot from power-on: the counter restarted with no battery, so it is refused, and userspace restores the time:
hwclockand sysfs work once the time is set:Warm reboot. The RTC kept counting, and hctosys applies it:
30 s PoE cut, with no battery. The counter restarts, and it is refused rather than set to 1970:
Scope
general/package/all-patches/linux/(those go to OpenIPC/linux)general/overlay/or in a sharedload_<vendor>script hardcodes a value specific to my boardLD_PRELOAD, and no binaries that cannot be rebuilt from source