Just a standard... 2:00am post. Cause.. the best work is done when sleep deprived
So I have coded up majority of the flash erase and programming into the kernel, but have it currently skip the actual vital parts since going to need to trial run this first to make sure all addressing and things work correctly before pulling the trigger.
For the erasing part, Im going to get it to transmit back the success command plus the sector it has erased to verify sector address(7E8 06 74 QQ WW TT XX YY). Basically everything gets setup and ready to go, other then the single command run to erase that sector, if successful it should send back that message. Only part thats a bit hard to test... until its done... is the function I built to verify the block was infact erased which verifies by checking if the flash is FF.
For the programming/writing.. I currently have it dumping all the bytes to ram, and will validate its correct using a ram read command (mode 40). The actual programming of the bytes has been disabled, but that is a very simple loop which reads a word from ram, writes the word to flash then finally increases address by 4 to repeat until the block has been done (so damn simple).
Im feeling pretty confident on the writing part, but not so much on the erasing. GMs kernel doesnt really give an indication for how long it takes to erase a sector. The data sheet says 1 second per sector.. which would be over a minute in just erasing which seems extremely wrong. GM kernel does not sit around for 1 minute in erasing so I call bullshit on that one.
- e38erase.PNG (12.16 KiB) Viewed 7414 times
Even on the sectors with 16k words, doign 16000(ish) * 18 = 294912us = 294.912ms. Literally 1/3rd of the indicated time.. s
Next issue is I cant get the timer to be working correctly. Whenever I enable it, the whole kernel crashes. I assume its because of some sort of timer interrupt which fires but every interrupt is disabled for timers so I cant see how. I figured using a proper timer to count time would be smarter then trying to use a nop loop to waste time.. which is currently the only real way I have found to waste time, inspiration taken from that in the P01/P59 kernel.
*Edit
Page 63, Erase and programming performance.
Typical sector erase time is 0.5seconds. Up to 5secs in worse case conditions of 145degC and 1million cycles.
So.. ~30second for a full chip.. or.. calibration of 0x40000 would be about ~3.5seconds, that seems way more sensible. Now to get some sort of timer working.. or nail in the nop loop values for accurate delays.