marinauterion opened a new pull request, #18988:
URL: https://github.com/apache/nuttx/pull/18988
## Summary
On some boards, the PCF85263 RTC does not count between reboots. After
inspecting the registers
at boot, `STOP_ENABLE` (register `0x2E`) had bit 0 set (`STOP=1`), which
freezes the RTC counter.
The exact trigger is unknown - not all boards exhibit the issue. The bit is
battery-backed and
persists across reboots, so once set (e.g. by a power glitch or undefined
hardware state) the
RTC stays frozen until explicitly cleared. The old driver never did this.
Fix: write `0x00` to `STOP_ENABLE` on init, which is the correct reset value
per the datasheet.
Fix: set time properly:
Due to datasheet the set_time should be as follow:
1. set stop_enable
2. clear prescaler
3. set time
4. clear stop_enable
## Impact
On affected boards, system time resets to the last value written via
`system_time set` after
every reboot, regardless of how much time has passed:
1. Set time to 10:00am
2. Turn off device, wait 2 minutes
3. Turn on device → time is 10:00am again
## Testing
Tested on PixHawk v6x (STM32H753IIK6)
Boot logs before and after the fix:
### Before Fix
```
Boot 1:
> pcf85263: STOP_ENABLE before init: 0xc1 <-- STOP=1 (bit 0 set)
> board: RTC time: 1970-01-01 00:00:05
wait 1 min
Boot 2:
> pcf85263: STOP_ENABLE before init: 0xc1 <-- STOP=1 (persistent)
> board: RTC time: 1970-01-01 00:00:06 <-- RTC did not count while
powered off
```
### After Fix
```
Boot 3 (first boot after fix - STOP still set from before, now cleared by
driver):
> pcf85263: STOP_ENABLE before init: 0xc1 <-- STOP=1, driver clears it
> board: RTC time: 1970-01-01 00:00:05
> system_time set 1779897071 <-- Wed May 27 2026 15:51:11 GMT+0000
wait 1 min
Boot 4 (STOP was cleared on Boot 3, RTC counted during power-off):
> pcf85263: STOP_ENABLE before init: 0x00 <-- STOP=0
> board: RTC time: 2026-05-27 15:52:11 <-- correct time, RTC counted
```
### Automated Power Cycle Test
41 iterations: power on → set time → power off → power on → compare RTC vs
PC time.
`STOP` was `0` on every boot after the fix. The remaining ~1s diff is a
measurement artifact
from integer truncation in the test script, not an RTC error.
```
run=0 diff=1s uC=1779952089 laptop=1779952090
run=1 diff=1s uC=1779952165 laptop=1779952166
run=2 diff=0s uC=1779952241 laptop=1779952241
run=3 diff=0s uC=1779952317 laptop=1779952317
run=39 diff=0s uC=1779955049 laptop=1779955049
run=40 diff=0s uC=1779955125 laptop=1779955125
run=41 diff=1s uC=1779955201 laptop=1779955202
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]