This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Switching between two applications using nRF5 SDK

There is a previous similar question here:

https://devzone.nordicsemi.com/f/nordic-q-a/16382/switching-between-apps-with-dual-bank

I am using nRF5232, nRF5 SDK v16.0.0, and using the latest SEGGER Embedded Studio.  Both applications use SoftDevice.  (If it matters, both use FreeRTOS)

I'm wanting to do the same thing as stated in the previous questions, but I'm looking for two examples that can be built with SES.

My Application1 is located at 0x26000 and my Application2 is located at 0x40000.

According to my .hex files, my Applications are being placed at the correct addresses, however when I try to jump to them, I get some sort of fault.

I tried using code the following code I took from nrf_bootloader, and I'm getting stuck in the HardFault_Handler:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/**@brief Function that sets the stack pointer and link register, and starts executing a particular address.
*
* @param[in] new_msp The new value to set in the main stack pointer.
* @param[in] new_lr The new value to set in the link register.
* @param[in] addr The address to execute.
*/
#if defined ( __CC_ARM )
__ASM __STATIC_INLINE void jump_to_addr(uint32_t new_msp, uint32_t new_lr, uint32_t addr)
{
MSR MSP, R0;
MOV LR, R1;
BX R2;
}
#else
__STATIC_INLINE void jump_to_addr(uint32_t new_msp, uint32_t new_lr, uint32_t addr)
{
__ASM volatile ("MSR MSP, %[arg]" : : [arg] "r" (new_msp));
__ASM volatile ("MOV LR, %[arg]" : : [arg] "r" (new_lr) : "lr");
__ASM volatile ("BX %[arg]" : : [arg] "r" (addr));
}
#endif
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX