Im writing a serial bootloader for the NRF51822 128kB. Im not using much of the SDK and its a custom protocol i.e. no bluetooth. The boot loader can be squeezed into 16kB (.text, .bss, .data) and the main image is 60kB.
I have partitioned FLASH into: first 32 pages (32kB) for bootloader any paramters required. next 96 pages (96kB) for the main image.
Ive written the client in C++ and a bootloader code so that hex images select on the PC app are processed, sent as messages and sent down to the NRF51822 where a small bootloader calls my FLASH functions with the correct addresses and data.
But I want to check a coupe of aspects:
1 - From the text in the manual, '5.1.5 Erasing a page in code region 1' am I correct in thinking that if there is code running in region 0 i.e. like my bootloader runnig in the first 32 pages, I can erase and write to both region 0 and region 1 pages (pages 33-127). Presumbly as long as the bootloader isnt running from those locations.
Or, do I need to locate the bootloader into RAM?
2 - My erase page routine switches between ERASEPCR1 and ERASEPCR0 depending on the page address but these dont exist in nrf51.h
How can I erase pages in region 0? The manual reads as though ERASEPAGE is for code region 1 only. Or can ERASEPAGE be used for all pages in the device?
3 - If you have any advice WRT loading the bootloader into RAM, it would be much appreciated. I have edited the linked file so that the VMA is in RAM and then I presume I just need to write some assembler to run from FLASH address 0 to copy the program into RAM and jump to it; unless there is a better way?
4 - I read the MPU is off by default so I shouldnt have any problems with that inteferring?