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 own bootloader / its application startup

Hi all

I am having problems with application startup. My USB based bootloader needs to start the "real" application if no USB is present. So I got two separate programs in flash residing on different locations. Bootloader starting at 0 (with flash vectors) and the application at say 0x4000, using relocated rambased vectors.

Both applications work fine, if started from within the debugger (PC set to either 0 or 0x4000, then command "go").

USB Bootloder is in Thumb mode, but I issue the BX R0 with R0 set to 4000h from supervisor mode. The application starts, but then ends up in an exception shortly. Any ideas what might be wrong? Does the CPU need some more setup? Or causes the duplicate clock stuff in the startup code some problems?

Funny thing is I checked NXP's app note 10711, which is about an USB bootloader too and they start the application simply that way:

void execute_user_code(void)
{ void (*user_code_entry)(void); user_code_entry = (void (*)(void))USER_FLASH_START; user_code_entry();
}

The bootloader is in Thumb and User mode I guess. Can that generally be a workiing solution? I tried it that way at first, but failed too.

Many thanks in advance
U.B.

Parents Reply Children
  • COOL - I finally got it.

    Decided to go the hard way and walk the entire startup (assembler ad my own 'C' stuff) along with the debugger

    1) USB Bootcode sets all PINSELS to 0 except for the few needed for USB

    2) Target application resets all PINSELS to 0 to start with "a clean CPU" and then adjusts all values as needed. (USB is only used for firmware upgrades, so appliations doesn't need it)

    the bad statement is

    PINSEL1 = 0; (this would reset some USB/port pins)

    replaced it by

    PINSEL = 0x14000000; (thus keeping the USB fxns of the pins) and the app runs as expected.

    damn crazy !

    is that "feature" documented somewhere ?

  • Forgot: this "effect" does NOT happen if in debugger;)