Problem in migration IAP flash project from GNU GCC to MCUXpresso

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

Problem in migration IAP flash project from GNU GCC to MCUXpresso

787 Views
geertsteyaert
Contributor I

Hi,

I'm building a OSHW Sensornode FluksoKube (github here : https://github.com/flukso/kube) . I've built all HW, compiled the software under the latest MCUXpresso but I'm having issues erasing flash+writing my remotely fetched code segments in Flash. Already during the IAP-ERASE the MCU locks up and I need to remove power + go into ISP to get the control back over the MCU. I'm rather new to the MCU game, learned a lot along the way. great fun. Made lots of mistakes and fixed them all. But on this one I'm stuck.

To me, it looks like my memory configuration (default one in MCUxpresso for the LPC812) is maybe incorrect, maybe I'm overwriting my own program space. I do think I have set up the correct memory configuration as far as I could find out: I  have set up the proper end/begin of the Flash/RAM as per the original linker file and I've set the Stack offset of 32 bytes for iap usage.

I managed to get the periph_flashiap LPCOpen example file working fine without any problem, so it's not a system problem.

In the meantime, I also got the original .BIN file from the developer. That one is working fine, meaning the flashing seems to work fine but in the IAP'd code I can see via the serial monitor some other bad messages. Maybe I2C hardware related. Not sure, anyway I would like to be able to use MCUXpresso to debug the MCU all the way based on my own setup.

I'll give the relevant details here: The main memory descriptor file in the original GNU GCC project is the linker file LPC812_boot.ld:

MEMORY
{
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 16k
RAM (rwx) : ORIGIN = 0x10000000+0x280, LENGTH = 4k-0x280 /* 0x270 for IAP */
}

INCLUDE rules.ld

And also there the rules.ld file is this:

ENTRY(ResetISR)

SECTIONS
{
.text :
{
KEEP(*(.isr_vector))
*(.after_vectors*)
*(.text*)
*(.rodata .rodata.*)
. = ALIGN(4);
_etext = .;
} > FLASH

.data :
{
_data = .;
*(vtable)
*(.data*)
. = ALIGN(4) ;
_edata = .;
} > RAM AT > FLASH

.bss :
{
_bss = .;
*(.bss*)
*(COMMON)
. = ALIGN(4) ;
_ebss = .;
PROVIDE(end = .);
} > RAM

PROVIDE(_pvHeapStart = .);
PROVIDE(_vStackTop = ORIGIN(RAM) + LENGTH(RAM));
}

Ultimately the MCU should try to start the IAP'd code like this, but it never even gets there :

static void launchApp() {
printf("launchApp\n");
SCB->VTOR = (uint32_t) BASE_ADDR;
// __asm("LDR SP, [R0] ;Load new stack pointer address")
void (*fun)() = (void (*)()) ((uint32_t*) BASE_ADDR)[1];
printf("go!\n");
fun();
printf("launchApp failed\n");
}

and BASE_ADDR is in boot.h defined as 

#define PAGE_SIZE 64
#define SECTOR_SIZE (PAGE_SIZE * 16)
#define BASE_ADDR ((uint8_t*) 0x1000)
#define TOP_OF_BOOT BASE_ADDR
#define CONFIG_ADDR (TOP_OF_BOOT - PAGE_SIZE)

I've included a full export of my project for all details, I'm open for all suggestions as to what I might be doing wrong.

I'm also suspecting IRQ handling or something to do with VTOR relocation. But not sure where to look for clues or solutions.


Thanks,

Geert

Labels (1)
Tags (3)
2 Replies

617 Views
victorjimenez
NXP TechSupport
NXP TechSupport

Hello Geert Steyaert, 

Which version of MCUXpresso are you using? Please be sure that you are using the newest version available (10.2) you can download this version from the following page: 

https://www.nxp.com/support/developer-resources/software-development-tools/mcuxpresso-software-and-t... 

Also, I recommend you to take a look into the following application note: 

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

This application note explains step by step everything you need to know about the IAP in the LPC812. 

Hope it helps!

Victor.

-----------------------------------------------------------------------------------------------------------------------

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

----------------------------------------------------------------------------------------------------------------------- 

0 Kudos

617 Views
geertsteyaert
Contributor I

Hi, thanks for the feedback.

I examined the demo/example code and I could get some 'funny' things out of my code, made sure my systick interrupt was disabled before / enabled after every IAP flash operation. Maybe not needed due to the relocation of the systick code but did it anyway, to make sure. The Application Note was very good as well.

Now, without having the remote hub in range (so without end-to-end testing possibilities) at least the test code I've put in my debug version seems to pass fine, also the IAP compare looks ok so the content was properly written and compared.

When I'm back home, on Friday evening, I'll test it completely.

I'll update when having extra news. For sure my code will not will any beauty contest ... 

Cheers,

Geert