This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

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
  • Thanks ,

    I found out when jumping to the program (0x00002000), the reset handler of the program doesn’t resume . Apparently 0x00002000 is the place of Main and isn’t the place of LPC17XX_Startup.S of the program . So I added the SystemInit() function which was originally called from the LPC17XX_Startup of the program , to the first of main . Now some of my programs which didn’t work , work perfectly . But still some others don’t work perfectly .

    Even though using SystemInit() at the first of main would fix some problems but some other settings in LPC17XX_Startup aren’t set yet . So I think jumping to the reset handler of the program instead of jumping to the main of the program(0x0002000) would fix everything.

    How could I jump from the bootloader to the reset handler of the program ?

Reply
  • Thanks ,

    I found out when jumping to the program (0x00002000), the reset handler of the program doesn’t resume . Apparently 0x00002000 is the place of Main and isn’t the place of LPC17XX_Startup.S of the program . So I added the SystemInit() function which was originally called from the LPC17XX_Startup of the program , to the first of main . Now some of my programs which didn’t work , work perfectly . But still some others don’t work perfectly .

    Even though using SystemInit() at the first of main would fix some problems but some other settings in LPC17XX_Startup aren’t set yet . So I think jumping to the reset handler of the program instead of jumping to the main of the program(0x0002000) would fix everything.

    How could I jump from the bootloader to the reset handler of the program ?

Children
  • What does the map file tell you?

    Don't you have an vector table at start of the application binary?

    That table should contain a pointer to the reset handler.

  • Thanks ,

    I got fed up ……!!!!!!
    At the end of SystemInit from CMSIS , the SCB->VTOR is configured ,

    So the steps are :
    1- Before jumping to the user application , I set the SCB->VTOR to 0x00002000
    2- At the start of user application(At the start of main) I call SystemInit but with SCB->VTOR set to 0x00002000 (Commented previous settings)
    Bootloader Settings :
    IROM1 = 0 , SIZE = 0x2000
    IROM2 Not Used
    IRAM1 0x10007000 , Size = 0x1000
    IRAM2 Not Used
    Program Settings :
    IROM1 = 0x2000 , SIZE = 0x2000
    IROM2 Not Used
    IRAM1 = 0x10000000 , Size = 0x7000
    IRAM2 = 0x2007C000 , Size = 0x8000

    Now 99% of the programs are working correctly but still some problems persist
    In application program when I
    1-change Heap Size from 0 to 0x400 , the program doesn’t work
    2-check the PLL1 tick at System_LPC17xx , the program doesn’t work
    3-comment 1 unimportant line of the function called Calc_Checksum , the program doesn’t work
    (for test purposes I had added this line to increase or decrease size of the function
    This is the line : “for (Cnt=0; Cnt<100; Cnt++);”)

    I’m nearly sure the problem lies on IRAM1 & IRAM2 settings
    I tested a USB Bootloader and it’s working perfectly and the strange point is unlike the Ethernet Bootloader , both bootloader and the application have got the same IRAM1 & IRAM2 settings (both IRAM1’s settings is “0x10000000 , 0x8000” and both IRAM2’s setting is “unchecked” )

    What could be the problem where 80k code is working and with commenting just 1 line , it’s not working ?

  • Sorry , above in program settings :
    IROM1 = 0x2000 , SIZE = 0x7E000