Programming ATSAM4L on OpenOCD

1 post / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm trying to simply program an ATSAM4LC2A with a J-Link using OpenOCD. OpenOCD programs and verifies it, and reports that everything was ok. But the circuit will not give any sign of life.

Then, I made a very simple program that just toggles one IO pin (PA20) using direct memory access to be as simple as possible. This is the code: (sorry, the code wrapper wasn't working)

#include "sam.h"

int main(void)
{

    SystemInit();

    uint32_t* IO_SET = 0x400E1000U+(0x200*0)+0x054;
    uint32_t* IO_CLR = 0x400E1000U+(0x200*0)+0x058;
    uint32_t* IO_OUT = 0x400E1000U+(0x200*0)+0x044;
    uint32_t* IO_STC = 0x400E1000U+(0x200*0)+0x168;

    *IO_OUT = GPIO_PA20;
    *IO_STC = GPIO_PA20;

    while (1) 
   {
        *IO_SET = GPIO_PA20;
        *IO_CLR = GPIO_PA20;
    }

}

I program it, but nothing happens. PA20 shows no activity on the oscilloscope. I then read the MCU's FLASH using OpenOCD, and it matches the .BIN file perfectly.

And so, my questions are:

1) The .BIN file generated by Atmel Studio is supposed to be an exact image of the MCU's FLASH memory, starting from 0x00000000, right?
2) Are there any restrictions on the address that my application is written to? I assume that the compiler knows what its doing when using the memory, but I've seen some examples online where the address 0..8192 is used for the bootloader section, and the actual application code starts at 8192. I'll admit that I'm a noob on ARM. Been using AVR's forever and all I have to watch for on them regarding addresses is the IVT.
3) I'm simply using the "program" command on OpenOCD to program the FLASH memory. Should I be programming the MCU's fuses or anything else in order for it to work? I am doing a "reset run" after programming, and "targets" shows that the MCU is indeed running.

Thanks for your help!