Author Topic: Serial bootloader application configuration  (Read 8235 times)

Offline skyguy

  • Newbie
  • *
  • Posts: 7
    • View Profile
Serial bootloader application configuration
« on: September 07, 2009, 05:56:20 AM »
Hi,

I'm adding the serial bootloader to my non-uTasker application (MCF52223, CodeWarrior + Processor Expert).  Everything appears to be set up right.  I can load the serial bootloader into flash, and I can load the application into flash using the bootloader.  If I inspect memory, I see the application is in flash.  If I single step into the bootloader, I can see it call start_application and find the vector to the right starting address in my application.  It appears to start the application.  I can step through, some of the start up code. but then I get an address error exception.  It appears to be trying to run code at 0x00000000.  The application link map looks OK.  What could this be?

Thanks,

Rick

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: Serial bootloader application configuration
« Reply #1 on: September 07, 2009, 10:50:11 AM »
Hi Rick

Check how the interrupts are being used in the non-uTasker project.
They may not be fixed in FLASH but rather must be entered into a vector table in SRAM. Some projects have the vector table directly in FLASH starting at 0x00000000 and so, when the start address is moved, the vectors move to an invalid area.
Could this be the problem? (I would expect an interrupt to fail but not necessarily the PC go to 0 (?))

Regards

Mark

Offline skyguy

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Serial bootloader application configuration
« Reply #2 on: September 07, 2009, 03:39:47 PM »
I should know this, but... if I put the vector table in SRAM, does CodeWarrior & Processor Expert initialize it or do I have to manage that?  I see 'copy ROM to RAM' code, but my SRAM vector table doesn't seem right.

Thanks,

Rick

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: Serial bootloader application configuration
« Reply #3 on: September 07, 2009, 04:47:14 PM »
Hi Rick

This depends on how the SRAM area is defined and how the code initialises it.
If you have an area defines in your linker script and the code is initialising it as a static variable array (with some pragma or similar informing the linker that it should place it in the correct memory area) then I would expect the startup code to perform a copy. There could however be various reasons why it doesn't work (eg. the startup code only initialises the main memory area, etc.).

Assuming you have a fixed list of vectors I would declare them as const and then add a memcpy(START_OF_RAM, vectors, sizeof(vectors)); immediately after basic initialisation and then it should be OK. [START_OF_RAM is 0x20000000 and vectors is a const array of the required interrupt vectors].

If you compare with the uTasker project code you will see that it is leaving the vector area in RAM uninitialised but then adding each interrupt vector as required using the call fnSetIntHandler().

Regards

Mark


Offline skyguy

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Serial bootloader application configuration
« Reply #4 on: September 08, 2009, 02:09:54 PM »
Mark,

Thanks.  I'm very close to getting this to work.  I can see with the CodeWarrior debugger than I'm initializing the interrupt vectors in SRAM at the start of my application.  The application crashes when I first enable interrupts.  Even though I set VBR to 0x20000000 in code, its value stays at 0x200001B4 according to the register view.  I can't force it through the debugger, either.  Maybe the debugger is interferring?

Thanks,

Rick

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: Serial bootloader application configuration
« Reply #5 on: September 08, 2009, 02:14:36 PM »
Hi Rick

The VBR has only 12 bits that are valid (the 12 MSB) - the others should read as 0 since they are not implemented.
I would suggest that the debugger is displaying something incorrectly and that it is basically correct. also the VBR can only be written using a special instruction - perhaps the debugger doesn't use this so can also not change it(?)

regards

Mark