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

How to load and execute from RAM

As I understand we must define both RAM_MODE and REMAP in ASM settings, but what about the linker settings ?

Parents
  • Here is what I have gotten to work, but it is a bit different from your question.

    I load the code as normal (not from RAM).

    I then use something like what was posted on Keil's site as a "MAP" problem someone was having.

    My first call in main is to copy_vectors.

    unsigned char vectors[64] __at 0x40000000; // reserve space for IRQ vectors

    void copy_vectors (void) {
    memcpy (vectors, 0, 64); // copy original IRQ vectors to RAM
    MEMMAP = 2; // fetch vectors from RAM
    }

    You can do this in your startup file as well, but I don't bother.

    Basically copy the bytes representing your handlers into RAM and then tell the code to run in RAM.

    Note: I am unclear how you get all your code to run in RAM, but this handles the exception vectors.

    You should change your linker to not use RAM from at least up to 0x4000003F possibly more if you use ISP stuff.

    Hope some of that helps.

Reply
  • Here is what I have gotten to work, but it is a bit different from your question.

    I load the code as normal (not from RAM).

    I then use something like what was posted on Keil's site as a "MAP" problem someone was having.

    My first call in main is to copy_vectors.

    unsigned char vectors[64] __at 0x40000000; // reserve space for IRQ vectors

    void copy_vectors (void) {
    memcpy (vectors, 0, 64); // copy original IRQ vectors to RAM
    MEMMAP = 2; // fetch vectors from RAM
    }

    You can do this in your startup file as well, but I don't bother.

    Basically copy the bytes representing your handlers into RAM and then tell the code to run in RAM.

    Note: I am unclear how you get all your code to run in RAM, but this handles the exception vectors.

    You should change your linker to not use RAM from at least up to 0x4000003F possibly more if you use ISP stuff.

    Hope some of that helps.

Children