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

Problem with LPC1768 USB bootloader

Hi,

I have a problem with USB bootloader. I downloaded sample code from NXP site. I followed instructions AN10866.
Bootloader works fine if I load small program into LPC.
This small program uses interrupts.
But If I load large program then interrupts do not work.
Is this a problem with Vector Table? How to check it? Please help.

Parents
  • Without a real fix one thing that worked for me is switching from optimization level 0 to level 1.

    I am not sure if I understand the mentioned problem, but if [switching from optimization level 0 to level 1] solves the mentioned problem; then maybe you can increase the size of STACK and HEAP, to see if this increasing solves the mentioned problem.

Reply
  • Without a real fix one thing that worked for me is switching from optimization level 0 to level 1.

    I am not sure if I understand the mentioned problem, but if [switching from optimization level 0 to level 1] solves the mentioned problem; then maybe you can increase the size of STACK and HEAP, to see if this increasing solves the mentioned problem.

Children
  • Hi All,

    in the example from NXP is an error. SP register must be set correctly before jump to the user application. I have changed execute_user_code() function:

    void execute_user_code(void)
    {
            void (*user_code_entry)(void);
    
            /* Change the Vector Table to the USER_FLASH_START
            in case the user application uses interrupts */
    
            volatile const DWORD *stack_adr = 0x00002000;
            volatile const DWORD *start_adr = 0x00002004;
    
            __MSR_MSP(*stack_adr);
    
            NVIC_SetVectorTable(NVIC_VectTab_FLASH, USER_FLASH_START);
    
            user_code_entry = (void (*)(void))(*start_adr);
            user_code_entry();
    
    }
    


    Regards

  • Increasing the stack size helped if I commented out one of my ISRs but no matter how much I increase the stack it's not enough for this one.

    In the LPC2368 I had to setup stack sizes for all of the ARM modes like IRQ, System, Supervisor, etc. Without doing it I had a similar problem. Do these modes still exist in the 1768? I couldn't find any documentation on it for the 1768 but then again I can barely find any reference of it for the 2368 either. All I could dig up is this one forum post:
    www.embeddedrelated.com/.../23503.php

  • In the LPC1768 (Cortex-M3) there are only two modes:
    - Thread mode - TM
    - Handler mode – HM.
    In addition, there are two levels with different rights of access to key areas in the address space:
    - Privileged Level – PL
    - Unprivileged/User Level – UL.

  • That was a huge help thanks! All I had to do was add

    mov R0, #0x00
    msr CONTROL, R0
    


    into my bootloader startup and everything works! I needed my code to be in Priveleged mode. I was looking for the modes in the NXP User's Manual instead of in the Cortex M3 core manual.

  • Hi all,

    I have the same problem with NXP Ethernet bootloader.

    The bootloader works fine with a small program but with bigger program, the user application doesn't start at all. It seems to be stuck at the same address in start_up (command STR Rd, [Rn, Offset]).

    The same application works fine, if I compile it to start at address 0x00.

    Vector table has been changed to the a new address and it works fine with the smaller application.

    I have tried to switch optimization level, it doesn't help at all.
    I have tried to set SP register before jumping to the user application. No help.
    Both applications are in privileged mode.

    Please help me out...

    Thanks in advance
    Piritta