Ethernet Bootlader from flash magic

Hi all ,
I’ve got a problem with Flash Magic Ethernet BootLoader .
The original sample for LPC1768 works fine but with a little change I made in the source code of the bootloader program . Here’s the line I added :
SCB->VTOR = 0x00002000; in the code below:

void execute_user_code(void)
{
    void (*user_code_entry)(void);
     SCB->VTOR = 0x00002000;
        user_code_entry = (void (*)(void))(USER_START_SECTOR_ADDRESS | 0x00000001);
    user_code_entry();
}


I can load some of my own programs into the microcontroller through ethernet (Via Flash Magic) , But when I load Some others , they don’t work at all .
Thanks in advanced

Bootloader Settings :

IROM1 = 0 , SIZE = 0x80000
IROM2 Not Used

IRAM1 Not Used
IRAM2 = 0x20082000 , Size = 0x1000

/////////////

Program Settings :

IROM1 = 0x2000 , SIZE = 0x80000
IROM2 Not Used

IRAM1 =0x10000000,size=0x8000
IRAM2 = 0x2007C000 , Size = 0x6000

It seems the problem lies on IRAM1 & IRAM2 Settings or lies on the different initialization settings between the bootloader program and my own programs which are loaded into the microcontroller or lies on SCB->VTOR.
I don’t exactly know how to set IRAM1 & IRAM2 in different programs . I just use different places in RAM and don’t know if some places are allocated to something or not or am I free to choose wherever interested or not ?

Isn’t the programs loaded supposed not to dependent on the bootloader program initialization ?
For example PLL ,TIMER, UART,… settings are set for some programs and they work perfectly when not using a bootloader . Now the bootloader has some settings for PLL and timer and uart .
For uart the first initialization is executed(BootLoader) and now the second is executed(The program loaded) with some changes . If I don’t have the exact same settings as bootloader settings on my program , the uart doesn’t work on the program !

The strange point is why there wasn’t the line I added to the bootloader program
(SCB->VTOR = 0x00002000;) ?

any help ?

Thanks in advanced

Parents
  • Note that code has to be written with care to be able to ignore the existence of a boot loader.

    A PLL normally has to be deactivated, before it can be reconfigured to a different speed. So if the boot loader sets up the PLL, then the application must notice that and deactivate it before it sets a different configuration.

    AN application that don't start from a boot loader don't need to care - it already knows that the PLL is deactivated.

    Same thing with lots of other things. Interrupt handlers needs to be configured in the correct order - if the boot loader have already installed an ISR to handle UART0, then incorrect sequences in the application can manage to trig interrupts into the bootloader before the application code have had time to replace the original interrupt handler vector to point at the application ISR instead of the boot loader ISR.

Reply
  • Note that code has to be written with care to be able to ignore the existence of a boot loader.

    A PLL normally has to be deactivated, before it can be reconfigured to a different speed. So if the boot loader sets up the PLL, then the application must notice that and deactivate it before it sets a different configuration.

    AN application that don't start from a boot loader don't need to care - it already knows that the PLL is deactivated.

    Same thing with lots of other things. Interrupt handlers needs to be configured in the correct order - if the boot loader have already installed an ISR to handle UART0, then incorrect sequences in the application can manage to trig interrupts into the bootloader before the application code have had time to replace the original interrupt handler vector to point at the application ISR instead of the boot loader ISR.

Children
More questions in this forum