0
votes

I'm a newly graduated electronics engineer and one of my first tasks in my new job is to import a code to Mbed compiler. I'm trying to run the Mbed Blinky example on my custom hardware with LPC1769 chip. I've exported the Blinky app to GNU Eclipse from the Online MBED compiler and imported it to the IDE.

The Mbed blinky code runs fine when I set the appropriate led pin(changing LED1 in the PinNames.h from 1.10 to 2.13 for my hardware) and flash it directly. So MBed and my custom HW isn't problematic. However, my firm has a custom bootloader and it's required to use it with any application. The custom bootloader requires that I start the program beginning from 0x4000. For this my firm was previously adding this line to their code, flashing the bootloader and uploading the IDE's output .bin file to the board with a custom FW loading program.

    SCB->VTOR = (0x4000) & 0x1FFFFF80;

When I try to follow the same steps, compiler builds without any complaints, but I see no blinks when I upload the program to my bootloader.

I'm suspecting I have to make some changes to the built-in CMSIS library, and/or the startup_LPC17XX.o and system_LPC17xx.o files come with the MBED export, but I'm confused. Any help would be much appreciated. Also, I'm using the automatically built make file, in case there's any wonders.

1

1 Answers

0
votes

Most importantly, you need to adjust the code location in the linker script, for example:

MEMORY {
    FLASH   : ORIGIN = 0x4000,  LENGTH = 0x7C000
}

Check the startup code and linker script for any further absolute addresses in flash memory.

Adjusting the VTOR is required for interrupts, if the bootloader doesn't already do that. The & operation looks weird; it should be sufficient to simply write 0x4000, or, even better, something like:

SCB->VTOR = (uint32_t) &_IsrVector;

Assuming you have defined _IsrVector in your linker script or startup code to refer to the very first byte in the vector table, i.e. the definition of the initial stack pointer. This way you don't have to adjust the code if the memory layout is changed in the linker script, and you avoid magic numbers.