Bytes to upload for reprogramming flash with a custom bootloader

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Bytes to upload for reprogramming flash with a custom bootloader

715 Views
greta_sasso
Contributor I

Hi everyone,

I am writing one secondary bootloader for lpc11u6x and i can't find any documentation that can help me.. 

I am trying to write an "hello world bootloader" wich is located at 0x0 address. this app will erase and prepare sectors and it will copied one array containing the new firmware ( in hex) to the flash, from address 0x00003000.

With "Chip_IAP_CopyRamToFlash(APP_VECTOR_TABLE, bin , size);" i continue obtained error 6 ( COUNT_ERROR Byte count is not multiple of 4 or is not a permitted value ) .. 

I don't understand from with kind of file I have to take the bytes for the new application. 

I am currently using the .bin file generated from the lpcxpresso ide with the post-build-step, including checksum...

thanks a lot..

Labels (1)
0 Kudos
3 Replies

562 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

HI Greta Sasso

I suggest you refer AN12037:  LPC11U6x USB DFU Secondary Bootloader

https://www.nxp.com/docs/en/application-note/AN12037_LPC11U6x.zip 


Have a great day,
Jun Zhang

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

562 Views
greta_sasso
Contributor I

Thanks a lot

I saw the source code for some inspiration.. but I can't solve my doubts..

I have my app running from 0x00 addres, and it's the secondary bootloader. 

I want to save directly one bin image ( saved into one array ) into flash at address 0x3000. So have write the bin hex ( saved directly into code in one array )  into the necessary sectors of flash, with success.

After that, i have tried to jump to the 0x3004 address, reloading vector table address to 0x3000 ( i have enable this function with cortex m0+).

But i have stiil problems with interrupts.. i obtained :  <signal handler called>() at 0xfffffff9  ( SIGINT interurpt) and no handler was called...

I don't know if I am wrong with the bin hex file saved into flash.. or with the interrupt vector table manaement..

--- I have generate the .bin file from my second application "blink"  without checksum ( i don't wont check in this moment), using lpcxpresso ide. I have take bytes from 0x00 to 0x2000 ( app'size = 6KB) and copied into one uint32_t array in the bootloader that i want to persist in flash ad address 0x000

--- I tried two different ways for interrupt vector table...  

 1) this will generate the interrupt after jump_to_app() 

cleanBoot();

SCB->VTOR = stackPointer; 

unsigned * p = (unsigned *) (applicationAddress  + 4);

void (*jump_to_app)(void);

jump_to_app = (void *) *p;

jump_to_app();

2) with common_handler in  cr_startup....c and the redirect common_handler function. this will generate the interrupt when enter in common_handler, after jump2app();

cleanBoot();
Chip_PMU_WriteGPREG(LPC_PMU, 3, APP_VECTOR_TABLE);
__set_MSP(*(volatile uint32_t*) (APP_VECTOR_TABLE));
__set_PSP(*(volatile uint32_t*) (APP_VECTOR_TABLE));
jump2app = (iapfun) *(uint32_t*) (APP_VECTOR_TABLE + 4);

jump2app();

void Common_Handler(void)
{
typedef void (*pFunction)(void);

pFunction Jump_To_Application;
volatile uint32_t JumpAddress;
volatile uint32_t i;
i = __get_IPSR();
JumpAddress = *(__IO uint32_t *)(Chip_PMU_ReadGPREG(LPC_PMU, 3) + (4 * i));
Jump_To_Application = (pFunction) JumpAddress;
Jump_To_Application();
}

0 Kudos

562 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

HI

I would suggest you refer this article I ever wrote

https://community.nxp.com/docs/DOC-103961 

It's for Kinetis but the jumping to bootloader method is exactly the same as LPC.

Have a nice day,

Jun Zhang

0 Kudos