TeensyUser / doc

Teensy PJRC WIKI
76 stars 5 forks source link

Not all data in DMAMEM/RAM2 survives a warm reset/restart #14

Open Defragster opened 1 year ago

Defragster commented 1 year ago

In : https://github.com/TeensyUser/doc/wiki/The-Watchdog-timer

This is not entirely true. Some portion of lower (?) DMAMEM is used by the security HAB (?) code before startup and data stored there will be wiped and overwritten. There is a forum post somewhere - or it could be tested - some 32KB (???) area is disturbed as the processor wakes up and verifies chip security. Any area above that - that was flushed from cache - will be retained. The area used may be different between Locked and UnLocked as well???

// DMAMEM causes allocation in 'static' RAM2 on Teensy using 1062 processor // It is not initialized and will retain value while powered // BUT - it writes through a cache that must be flushed to assure it is current // This works for any DMAMEM allocation of any variable type or structure

Defragster commented 1 year ago

Wrote test sketch to MALLOC DMAMEM and test in 1KB blocks. 'X' are blocks before Malloc (USB Alloc and any other) '+' blocks retained the expected values on warm restart '-' blocks are those that did not have the pre-written and flushed values

Locked T_4.1 pollutes first 39-40KB, and also 1KB more at start +~64KB? Start Address 0x20203088 End at 0x2027fc88 XXXXXXXXXXXXX13+1-------------------------25+++++++++++50 ++++++++++++++25-1+++++++++++++++++++++++++++++++++++100

Unlocked 1062 startup pollutes the first ~34KB Start Address 0x20203088 End at 0x2027fc88 XXXXXXXXXXXXX13+1-------------------19+++++++++++++++++50 ++++++++++++++++++++++++++++++++++++++++++++++++++100

Cold start - no block matches of course Warm Start after Program Load or TyComm Reset {with loader not triggering programming} show above results.

Will update if the sketch cleans up nicely for posting and perhaps improve results display.

Defragster commented 1 year ago

shared this https://github.com/Defragster/TeensySketches/tree/main/RamPersistTest

DRAM Persist test ............._ Bytes 510976 is 499 KB

Start Address 0x20203088 End at 0x2027fc88 XXXXXXXXXXXXXAlready Allocated 20200000 - 16 03 55 00 53 00 42 00 20 00 53 00 65 00 72 00 : ..U.S.B. .S.e.r. 20200010 - 69 00 61 00 6C 00 6F 00 00 00 00 00 00 00 00 00 : i.a.l.o. ........ 13+ Overwritten 20203488 - 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 : ABCDEFGH IJKLMNOP ... 53 duplicate line(s) removed. 202037E8 - 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 : ABCDEFGH IJKLMNOP 202037F8 - 41 42 43 44 45 46 47 48 49 4A 40 48 4D 4E 4F 50 : ABCDEFGH IJ@HMNOP 20203808 - 01 00 00 00 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 : ....EFGH IJKLMNOP 20203818 - 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 : ABCDEFGH IJKLMNOP Max Count of Output Lines Reached 1-------------------19+++++++++++++++++50 ++++++++++++++++++++++++++++++++++++++++++++++++++100 ++++++++++++++++++++++++++++++++++++++++++++++++++150 ++++++++++++++++++++++++++++++++++++++++++++++++++200 ++++++++++++++++++++++++++++++++++++++++++++++++++250 ++++++++++++++++++++++++++++++++++++++++++++++++++300 ++++++++++++++++++++++++++++++++++++++++++++++++++350 ++++++++++++++++++++++++++++++++++++++++++++++++++400 ++++++++++++++++++++++++++++++++++++++++++++++++++450 ++++++++++++++++++++++++++++++++++++++++++++++++++500 ++++++++++++479 Start=20200000 Len KB=13 TYPE=Pre allocated X Start=20203088 Len KB=1 TYPE=Static maintained + Start=20203488 Len KB=19 TYPE=Overwritten/LOST - Start=20208088 Len KB=479 TYPE=Static maintained +