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

NXP LPC17xx USB Secondary Bootloader

Hi,

I'm using 'NXP LPC17xx USB Secondary Bootloader'.

I read the whole "AN10866.pdf" which commes together with the code on this link: ics.nxp.com/.../an10866.zip

I did everything as described in document and basically it works fine.
I can program my chip using this USB bootloader.

So where is the problem?
When I use more than 1572 bytes for global variables in my application then the program will not run normally. It halts. If I try then to program the chip over the JTAG with the same code (only I change the starting position from 0x2000->0x0000), then it runs normally.

Does anyone of you know the where could be the problem ?
Any hint what to change to make it work regardless to the number of global variables ?

Parents Reply Children
  • Yes, of course. The bin file size if 84.6 KB, and chip has 504KB free.

    I must say that I can add local variables, I can add as much as the code I want. Only global variables cause the problem. Therefore I think it is not related to the file size.

    Something is very weird here.

    Wait, now I will try to write a hello world program which fails, than we will know for sure what is it about...

  • Working code:

    int dummy2;
    int *dummy3;
    char Dummy_check[500];

    #include <LPC17xx.h>
    #include "system_LPC17xx.c"

    int main ()
    { // Init clock 96Mhz, 12 Mhz crystal SystemInit(); SystemCoreClockUpdate();

    //Init output pin for blinking led LPC_PINCON->PINSEL7&=~(3<<18); LPC_GPIO3->FIODIR=1<<25;

    while(1) { for (long i=0;i<2500000;i++); //delay for a fraction of a second LPC_GPIO3->FIOSET=1<<25; //LED ON for (long i=0;i<2500000;i++); //delay for a fraction of a second LPC_GPIO3->FIOCLR=1<<25; //LED OFF };
    }

    Not working code:

    //int dummy2;
    int *dummy3;
    char Dummy_check[500];

    #include <LPC17xx.h>
    #include "system_LPC17xx.c"

    int main ()
    { // Init clock 96Mhz, 12 Mhz crystal SystemInit(); SystemCoreClockUpdate();

    //Init output pin for blinking led LPC_PINCON->PINSEL7&=~(3<<18); LPC_GPIO3->FIODIR=1<<25;

    while(1) { for (long i=0;i<2500000;i++); //delay for a fraction of a second LPC_GPIO3->FIOSET=1<<25; //LED ON for (long i=0;i<2500000;i++); //delay for a fraction of a second LPC_GPIO3->FIOCLR=1<<25; //LED OFF };
    }

    If I comment the dummy3, the code also don't work. I can change the size of a field Dummy_check.

    In this case the problem occurs when removing a variable. Sometimes the problem occurs then adding them.

    Any ideas?

  • Might you have an issue with how you align the stack?

    By the way - it does not hurt if you look up the posting instructions for source code. It's described directly above the input message box.

  • It is probably something with stack.
    I have set on both: bootloader, and user aplication the adress for memory: 0x10000000, and size 0x8000.

    It was like that by default.

    If I select IRAM2 with a start at 0x2007C000 for user application, then it works normally.
    I know that IRAM2 is divided into two sections, so I rather would not use this area.

    My apologizes for the unformated source code.
    My first post here, lesson learned.