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

Understanding Operation Lacking

All,

I am playing around with implementing a custom bootloader application on an ARM7 (NXP LPC213x) device and I am seeing some operations which I do not yet understand.

The bootloader is to remain resident in the Flash and either detect a new code update via SPI (UART not available) or jump to the main application and begin its execution (if validated). This is for in-the-field upgrade capability.

Now, as a test, when I override the linker memory and use the scatterfile I expect ALL the code to link at the address I specified (0x1000). When I load the code via the debugger I notice that the code is at 0x1000 but at offset 0 an unknown block of code is also written:

0x00000000  E59F4034  LDR       R4,[PC,#0x0034]
0x00000004  E3A05002  MOV       R5,#0x00000002
0x00000008  E5845000  STR       R5,[R4]
0x0000000C  E3A05003  MOV       R5,#0x00000003
0x00000010  E5845004  STR       R5,[R4,#0x0004]
0x00000014  E59F201C  LDR       R2,[PC,#0x001C]
0x00000018  E3A03000  MOV       R3,#VicBit(0x00000000)
0x0000001C  E1020093  SWP       R0,R3,[R2]
0x00000020  E2822028  ADD       R2,R2,#0x00000028
0x00000024  E1021093  SWP       R1,R3,[R2]
0x00000028  E3C03007  BIC       R3,R0,#0x00000007
0x0000002C  E5023028  STR       R3,[R2,#-0x0028]
0x00000030  E51FF004  LDR       PC,[PC,#-0x0004]
0x00000034  7FFFD1C4  SWIVC     0x00FFD1C4
0x00000038  E002C014  AND       R12,R2,R4,LSL R0
0x0000003C  E01FC000  ANDS      R12,PC,R0

BTW: The hex file shows correct offset:

:1010000018F09FE518F09FE518F09FE518F09FE5B0
:1010100018F09FE50000A0E1F0FF1FE518F09FE544
:1010200048100000781200006C35000080120000AB

This code does NOTHING as the program will not run. However, if I force the startup code to reside at 0x0000 and the rest of the application to reside at 0x1000 the application runs fine.

So, a couple of questions:

(1) The code placed at 0x0000 when I force a link all at 0x1000 - what is the purpose of this code? (I assume it is probably debugger related).

(2) Along these lines....If I want to jump from the resident bootloader application into the main application am I to be correct in assuming that I must reserve sector 0 soley for the purpose of erasing and copying the individual startup codes from the bootloader and the main application into this space in order to execute the main application code? Or can I just jump to the memory map 'Image Entry Point' address?

Since not just the vector table resides at offset 0 it makes this type of undertaking a little more complicated than just setting the PC to the next applications reset code entrypoint.

Thanks.

Parents
  • Read up on the interrupt vector table stored at the bottom of the memory.

    Then scan through the documentation about possibilities to remap the interrupt vector table into RAM, so that the boot loader can have the original interrupt vector table and the started application can install a new interrupt vector table in RAM and remap this memory to make the processor use the RAM-based vector copy.

Reply
  • Read up on the interrupt vector table stored at the bottom of the memory.

    Then scan through the documentation about possibilities to remap the interrupt vector table into RAM, so that the boot loader can have the original interrupt vector table and the started application can install a new interrupt vector table in RAM and remap this memory to make the processor use the RAM-based vector copy.

Children
No data