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

placing code at specific address

in main() I have two pieces of code - the first one needs to start at the beginning of main and it is very small the second one will be placed just after at the beginnig adddress + 200h
can you tell me the directive(s) to use to set this second piece of code to be placed at this specific address after the beginning of main()

Parents
  • Here is the way I start the main application from the bootloader:
    1) I write a magic cookie into a variable.
    2) I trigger a software reset.
    3) Early in the bootloader, I check if the magic cookie is present. If so, I jump to the main application starting address.

    This way the main application starts up alomost from the reset state. Very convenient.

Reply
  • Here is the way I start the main application from the bootloader:
    1) I write a magic cookie into a variable.
    2) I trigger a software reset.
    3) Early in the bootloader, I check if the magic cookie is present. If so, I jump to the main application starting address.

    This way the main application starts up alomost from the reset state. Very convenient.

Children
  • But who writes the magic cookie? Can't be the application because it hasn't been started until the boot loader runs.

    Would be meaningless for the boot loader to write a magic cookie and then test it.

    Magic cookies are good for having an application perform a forced reboot, and with the cookie tell the boot loader to _not_ boot into the application again, but to instead perform a transfer.

    For normal operation, it's better to have the application area covered by a CRC-32 or similar, and have the boot loader scan the area to verify if the computed CRC-32 is correct.