can't update MCUboot, flash protected?

I'm trying to update MCUboot from the application. As a first test, I enabled the flash shell commands. I can erase somewhere within the flash without problems:

uart:~$ flash erase e0000 1000                                                                                                                                
Erase success.                                                                                                                                                

but when I try to erase the bootloader, I get a bus fault:

uart:~$ flash erase 0 1000                                                                                                                                    
[00:00:28.689,117] <err> os: ***** BUS FAULT *****                                                                                                            
[00:00:28.689,147] <err> os:   Precise data bus error                                                                                                         
[00:00:28.689,178] <err> os:   BFAR Address: 0x0                                                                                                              
[00:00:28.689,239] <err> os: r0/a1:  0x00000000  r1/a2:  0x00000000  r2/a3:  0xffffffff                                                                       
[00:00:28.689,239] <err> os: r3/a4:  0x50039000 r12/ip:  0x2000ffc8 r14/lr:  0x0001e5f5                                                                       
[00:00:28.689,270] <err> os:  xpsr:  0x21000000                                                                                                               
[00:00:28.689,300] <err> os: Faulting instruction address (r15/pc): 0x000206d4                                                                                
[00:00:28.689,331] <err> os: >>> ZEPHYR FATAL ERROR 0: CPU exception on CPU 0                                                                                 
[00:00:28.689,392] <err> os: Current thread: 0x2000eeb8 (shell_uart)

Do I need to unprotect the flash somehow? Problem is I need this without the JTAG interface, all from the application, because the board is already at the customer, and they can only update it OTA, and I need to change the signing key. So my idea is to add MCUboot to my application, and then on start to update the flash and overwrite the old MCUboot.

Related