AnsweredAssumed Answered

Problem in migration IAP flash project from GNU GCC to MCUXpresso

Question asked by Geert Steyaert on Aug 7, 2018
Latest reply on Aug 13, 2018 by Geert Steyaert

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

Attachments

Outcomes