Hi,
I'm developing a secondary bootloader on LPC2368.
The bootloader at startup initialize stack pointer:
....
LDR R0, =Top_Stack
# Enter Undefined Instruction Mode and set its Stack Pointer
MSR CPSR_c, #Mode_UND|I_Bit|F_Bit
MOV SP, R0
SUB R0, R0, #UND_Stack_Size
# Enter Abort Mode and set its Stack Pointer
MSR CPSR_c, #Mode_ABT|I_Bit|F_Bit
MOV SP, R0
SUB R0, R0, #ABT_Stack_Size
# Enter FIQ Mode and set its Stack Pointer
MSR CPSR_c, #Mode_FIQ|I_Bit|F_Bit
MOV SP, R0
SUB R0, R0, #FIQ_Stack_Size
# Enter IRQ Mode and set its Stack Pointer
MSR CPSR_c, #Mode_IRQ|I_Bit|F_Bit
MOV SP, R0
SUB R0, R0, #IRQ_Stack_Size
# Enter Supervisor Mode and set its Stack Pointer
MSR CPSR_c, #Mode_SVC|I_Bit|F_Bit
MOV SP, R0
SUB R0, R0, #SVC_Stack_Size
# Enter User Mode and set its Stack Pointer
MSR CPSR_c, #Mode_USR/*|F_Bit /* |F_Bit disabilito fiq */
MOV SP, R0
# Setup a default Stack Limit (when compiled with "-mapcs-stack-check")
SUB SL, SP, #USR_Stack_Size
....
executes some code and then jump to the application code.
The application code also sets stack pointer accordings to its needs during initialization.
I noticed that the User Mode stack pointer is changed properly while the IRQ stack pointer is remained the one setted by the bootloader making the system crash.
The instructions used by the application are similar to the ones used by the bootloader, the only difference is that R0 holds different value.
There is the possibility of changing the IRQ stack pointer the second time?
Thank you
Hi Giovanni,
There are some considerations when developing a bootloader. For additional details, please refer to application note AN10835 “LPC2000 secondary bootloader for code update using IAP”, available on the link below:
http://www.nxp.com/documents/application_note/AN10835.pdf
Additionally, the following links may be also helpful:
https://www.lpcware.com/category/file-types/bootloader
https://www.lpcware.com/content/forum/changing-bootloader-content-through-user-applicationiap
Hope this will be useful for you.
Best regards!
/Carlos
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Thank you,
I solved my problem by resetting (using watchdog) bootloader and then jumping directly to application if bootloader found a magic value
in a specific location.
Best Regards
Giovanni Friolo
DAB PUMPS S.P.A.
Electronic Designer
Via Bonanno Pisano, 1
giovanni.friolo@dwtgroup.com<mailto:giovanni.friolo@dwtgroup.com>
56031 Bientina (Pisa)
+39 0587 753 840
Italy
Hi
I am currently facing the same issue. How did you managed to jump directly to the user application? Have you modified the Startup file?
Thanks in advance
Nils