Does anyone know what type of memory the RTC memory is? Seems to me it should be eeprom to survive some erase/write cycles.
When inspecting the assembly for system_rtc_mem_write it seems the memory size is 768 bytes and valid start address for write is word-aligned addresses 0-190. My assembly skillz are a bit rusty but I think I've got it fairly correct...
401007cc <system_rtc_mem_write>:
401007cc: bfa052 movi a5, 191
401007cf: 123527 bltu a5, a2, 401007e5 <system_rtc_mem_write+0x19>
401007d2: 370c movi.n a7, 3
401007d4: 146030 extui a6, a3, 0, 2
401007d7: a6cc bnez.n a6, 401007e5 <system_rtc_mem_write+0x19>
401007d9: 1192e0 slli a9, a2, 2
401007dc: 00a382 movi a8, 0x300
401007df: c08890 sub a8, a8, a9
401007e2: 03a847 bge a8, a4, 401007e9 <system_rtc_mem_write+0x1d>
401007e5: 020c movi.n a2, 0
401007e7: f00d ret.n
A little further down I think we have the actual RTC start address 0x40100128, just above the memory write loop:
40100850: fe3671 l32r a7, 40100128 <wdt_feed+0x7c>
40100853: 040c movi.n a4, 0
40100855: a05420 addx4 a5, a4, a2
40100858: a06430 addx4 a6, a4, a3
4010085b: 557a add.n a5, a5, a7
4010085d: 0020c0 memw
40100860: c02552 l32i a5, a5, 0x300
40100863: 0020c0 memw
40100866: 0659 s32i.n a5, a6, 0
40100868: 441b addi.n a4, a4, 1
4010086a: 744040 extui a4, a4, 0, 8
4010086d: e43487 bltu a4, a8, 40100855 <system_rtc_mem_read+0x35>
If the RTC start address above is correct, it points into the instruction ram? Or am I being fooled by the l32r instruction somehow?
I did some testing and indeed it is possible to write to address < 191. And it stays there over restart, or least I found 12 bytes starting at addr 144 that was usable without causing any side effects.
Anyone know more on this topic? It would be good to know if the RTC memory is indeed eeprom. That way it could be possible to use to store a counter in RTC mem instead of wearing out the flash.
Cheers!