Hi,
We currently use a pc54s018j2m.
During development, our main firmware is located at default "program_flash" address 0x10000000 and it works fine.
During production, we create another firmware (a monitor) that become our boot firmware (also located at "program_flash" address 0x10000000).
We change "program_flash" address for the main firmware to be 0x10060000, and program the flash with generated code.
We now want to jump to this address from the monitor.
Here's my jump procedure:
__RAMFUNC(RAM2) void execute_code(unsigned addr)
{
__ISB();
__DSB();
__ASM volatile ("cpsid i");
__ASM volatile ("cpsid f");
SCB->VTOR = addr;
uint32_t *p;
p = (uint32_t*) addr;
__set_MSP(*p);
__set_PSP(*p);
p++;
void (*user_code_entry)(void) = NULL;
user_code_entry = (void (*)(void)) (*p);
user_code_entry();
}
And I call this function with following code:
execute_code(0x10060000);
And.. it crashes.
Is there any problem with my execute_code function (this functions works fine on lpc55s28, but maybe it's completely different).
Do you have any hints ? or link ?
regards
Is it possible to have a simple reply ?
On my lpc54s018
* I've a 1st firmware (called Boot) at address 0x10000000 (defined in IDE MCU settings)
* I've a 2nd firmware (called Firmware) at address 0x10060000 (defined in IDE MCU settings)
Both are programmed with segger jflash (data file, merge data file), and memory is checked.
Now how can I jump from my first Boot to my Firmware.
I explain in a previous post how I try to do this jump, but it don't work and any advice will be welcome.
I follow many application notes, check many example but don't find anything.
Is it possible ? And how ?
Regards
Not sure if this is relevant here ...
But wouldn't you need to have an "odd" target address as jump location ?
The LSB of the address serves as marker for the core mode in several instructions, with "0" meaning ARM mode, and "1" being Thumb mode.
Instructions are always word-aligned, so ARM reused the LSB here.
Hi,
For the LPC55S69, there is an example hello_world for trustzone, in the application, there is a part of code to do the almost same job, I copy it here.
typedef void (*funcptr_ns)(void) TZM_IS_NONSECURE_CALLED;
void TZM_JumpToNormalWorld(uint32_t nonsecVtorAddress)
{
funcptr_ns ResetHandler_ns;
/* Set non-secure main stack (MSP_NS) */
__TZ_set_MSP_NS(*((uint32_t *)(nonsecVtorAddress)));
/* Set non-secure vector table */
SCB_NS->VTOR = nonsecVtorAddress;
/* Get non-secure reset handler */
ResetHandler_ns = (funcptr_ns)(*((uint32_t *)((nonsecVtorAddress) + 4U)));
/* Call non-secure application - jump to normal world */
ResetHandler_ns();
}
#define DEMO_CODE_START_NS 0x00010000
#define NON_SECURE_START DEMO_CODE_START_NS
TZM_JumpToNormalWorld(NON_SECURE_START);
Hope it can help you
BR
XiangJun Rong
Hi, Pierre,
Yes, I see that you do not use trustzone. But the scenario is the same, pls refer to it.
BR
XiangJun Rong
Hi,
thank your for reply.
But what kind of address do I have to use.
My bootloader is in external flash (addresse 0x10000000)
My firmware is in external flash (address 0x10060000)
Do I have to try a jump to address 0x10060000 or to address 0x60000 ?
Is there special advice about spifi configuration ?
Is there special advice about timers, reset, ...
Regards
pierre
Hi,
For LPC540xx family, the SPIFI address space is from ox1000_0000 to 0x17FF_FFFF, so jumping to address 0x10060000 is correct.
Pls refer to the an12384.pdf, which can be downloaded from the web site:
https://www.nxp.com.cn/docs/en/application-note/AN12384.pdf
This is the jumping code from bootloader to application:
pls refer to the code
Hope it can help you
BR
XiangJun Rong
@xiangjun_rongDo you have any advice about my last post ?
We're completely stuck now ?
Is there any sample of a secondary bootloader on lpc54s18, with a jump to external flash (0x10000000 and more) ?
Regards
pierre
Hi,
Still not work, event by following what's inside AN12384. But I can give you more information about my tests. I reduce all to juste relevant part to have a minimal example of what's not working.
I've got 2 simple programs.
* TestBoot (MCU settings: PROGRAM_FLASH 0x10000000, SIZE 0x60000)
- Plain Load Image SRAMX
- Global Data Placement SRAM_0_1_2_3
* TestFirmware (MCU settings: PROGRAM_FLASH 0x10060000, SIZE 0x60000)
- Plain Load Image SRAMX
- Global Data Placement SRAM_0_1_2_3
Both are very simple:
* TestBoot configure some gpio and blink led.
* Then jump to TestFirmware (0x10060000)
* TestFirmware configure some gpio and blink led (other color)
I program both in my external flash with jflash (with data and merge data):
* TestBoot at 0x10000000
* TestFirmware at 0x10060000
I reset the device:
* I see expected led from TestBoot blink
* When the jump occurs, there's a reset on the device, and I fall back to the TestBoot blink
* And so on
I never saw the led from TestFirmware.
I try different code in firmware (with or without GPIO configuration), but I do think that the problem is the jump code that cannot reach my TestFirmware application.
Here's the jump function:
static void boot_tofwimage(unsigned addr) // depuis l'AN12384
{
void (*firmwareFunc)(void);
uint32_t fwStack = *((uint32_t*) (addr));
uint32_t fwEntry = *((uint32_t*) (addr + 4U));
firmwareFunc = (void (*)(void)) fwEntry;
SCB->VTOR = addr;
__set_MSP(fwStack);
__set_PSP(fwStack);
firmwareFunc();// let's go
}
What's seems weird to me: If I run my TestBoot app step by step, and the firmwareFunc() jumps to ResetISR() that restart the TestBoot !
The main difference between the LPC54s18 and the one in AN (LPC5460) is the fact that there's no flash inside.
So, do you have an AN that I can read for a device like the LPC54s18.
Do I have to ensure special features when I compile my firmware ? Options, relocation ?
Do I have to transfer something in RAM ? ...
My project is completely stuck without a valid bootloader, so any advice will be welcome.
I can perform some tests if needed.
Regards
Hi,
Maybe the spifi interface is not initialized or whatever.
Pls refer to an12352
https://www.nxp.com.cn/docs/en/nxp/application-notes/AN12352.pdf
Hope it can help you
BR
XiangJun Rong
Thank you,
seems similar to my code, but I'll readd whole doc and follow your advices.
Regards