Clear SRAM AT91SAM3X8E

Discussion around product based on ARM Cortex M3 core.
This forum will be discontinued soon.

Moderators: nferre, ncollot

tomshirvo
Posts: 11
Joined: Wed Oct 22, 2014 7:22 am

Clear SRAM AT91SAM3X8E

Thu Jan 15, 2015 8:35 am

I have finished making my bootloader but I am not sure if when it starts the uploaded firmware that the SRAM is cleared of all the global variables used in the bootloader.

I pass the location on the flash that the firmware was uploaded too. everything works but I am just wondering if things like the serial buffer that is a global variable is still allocated in the SRAM. All the variables from the bootloader can be wiped when the loaded firmware is started.

Below is the code that is run that starts the uploaded firmware.

Thanks

Code: Select all

/**
 * Jump to CM3 vector table
 */
void _binExec (void * l_code_addr)
{
    __asm__ ("mov   r1, r0        \n"
             "ldr   r0, [r1, #4]  \n"
             "ldr   sp, [r1]      \n"
             "blx   r0"
             );
}








/**
 * Name:      binary_exec
 * Purpose:   Execute the binary
 * Input:
 *  - Application starting address
 * Output:    If success, no return.
 *            1, address alignment error.
 *            2, address not executable.
 */
int binary_exec(void * vStart)
{
    int i;
    // -- Check parameters
    // Should be at least 32 words aligned
    if ((uint32_t)vStart & 0x7F)
        return 1;
    // Should in code or sram region
    if ((uint32_t)vStart > CM3_SRAM_END)
        return 2;
    // -- Disable interrupts
    // Disable IRQ
    __disable_irq();
    // Disable IRQs
    for (i = 0; i < 8; i ++) NVIC->ICER[i] = 0xFFFFFFFF;
    // Clear pending IRQs
    for (i = 0; i < 8; i ++) NVIC->ICPR[i] = 0xFFFFFFFF;
    // -- Modify vector table location
    // Barriars
    __DSB();
    __ISB();
    // Change the vector table
    SCB->VTOR = ((uint32_t)vStart & SCB_VTOR_TBLOFF_Msk);
    // Barriars
    __DSB();
    __ISB();
    // -- Enable interrupts
    __enable_irq();
    // -- Load Stack & PC
    _binExec(vStart);
    return 0;
}
amey11637
Posts: 1
Joined: Sun Nov 22, 2015 1:39 pm

Re: Clear SRAM AT91SAM3X8E

Sun Nov 22, 2015 1:52 pm

Can I see complete source code of bootloader?

Return to “SAM3 Cortex-M3 MCU”

Who is online

Users browsing this forum: No registered users and 1 guest