cancel
Showing results for 
Search instead for 
Did you mean: 

Writing my own Bootloader

Scott Dev
Senior
Posted on April 23, 2018 at 17:38

Hi

  I have looked on the forum, and see there is a lot of info regarding this topic. I am coming from a 68S09 processor where I designed my own bootloader that done the following: 

1. User first downloaded new firmware remotely , which was saved onto extarnal flash memory.

2. The processor restarted

3. Bootloader runs, and the first thing it does is check for new firmware in the external flash. If no firmware exists then simply jumps to current application.

4. If exists, then current firmware is erased, then reprograms the internal flash (thus overwriting the current code). Then erases the external flash to prevent further firmware updates. 

5. restart the processor, and No. 3 jumps to the newly added firmware.

This works well, and I want to do something similar on the STM32L4 chip. Looking at the forum, it looks like I should use the MPU to protect the bootloader from being overwritten . With the 68S09 chip I have to write to a couple of memory location to protect the memory (write once , and the chip has to be erased to use again) , which isnt done within the firmware code itself, but with a basic external application and programmer. After doing this, no one can copy the bootloader, and the first 4K (the bootloader), is write protected.

If my bootloader on the STM32L4 runs first when the processor is powered up, am I write in thinking that it is my bootloader that programs the MPU everytime it starts, which will protect its memory from being overwritten?  

Thanks

Scott

1 REPLY 1
Posted on April 24, 2018 at 02:12

Looking at the forum, it looks like I should use the MPU to protect the bootloader from being overwritten .

No. MPU is there to optionally allow an OS to prevent unpriviledged code from accessing address space where it has nothing to do.

You want to read the FLASH memory protection chapter in the Reference Manual to your chip.

JW