ATMEL SAM4E script

Hi there.

I want to share my openocd script to ATMEL SAM4E / SAM4E-EK.

It is working very well and configures the PLL to 240 MHz and MCK to 120 MHz.

I’ve got a Transfer rate of 22 KB/sec instead 12 KB/sec from original config.

With SAM-ICE and a 700KB binary I had 24" with AtmelStudio (VM Windows 7 x64) and 27" with OpenOCD (Fedora 20 x64)

Regard

Marco

=============

— openocd.cfg —

source [find interface/jlink.cfg]

source [find board/atmel_sam4e_ek.cfg]

SAM4E chip has only NRST signal

SAM4E-EK board has only nSRST. nTRST is connected to +3V3 by pull-up.

reset_config srst_only

$_TARGETNAME configure -event gdb-attach {

reset init

}

$_TARGETNAME configure -event reset-init {

sam4e_pll_init

}

$_TARGETNAME configure -event reset-start {

adapter_khz 500

}

$_TARGETNAME configure -event reset-end {

adapter_khz 10000

flash probe 0

}

proc sam4e_pll_init {} {

Same sequence from ASF/pmc.c

mww 0x400E0A00 0x04000500 ;# FLASH 6 WS

Initialize main oscillator

mww 0x400E0420 0x00373E09 ;# CKGR_MOR

sleep 10

Switch to 3-20MHz Xtal oscillator

mww 0x400E0420 0x01373E09 ;# CKGR_MOR

sleep 10

Disable PLL first

mww 0x400E0428 0x20000000 ;# CKGR_PLLAR

sleep 10

PLLA 240 MHz

mww 0x400E0428 0x20133F01 ;# CKGR_PLLAR

sleep 10

PRES CLK_2, MAINCK → MCK = 120 MHz

mww 0x400E0430 0x00000011 ;# PMC_MCKR

sleep 10

PRES CLK_2, PLLACK

mww 0x400E0430 0x00000012 ;# PMC_MCKR

sleep 10

}

=======================

— gdb.ini —

target remote localhost:3333

file foo.elf

b main

mon at91sam4 gpnvm set 1

load

mon reset init

continue