summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-10-13 09:48:46 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-10-13 09:48:46 -0600
commit50e10d42c8e3c485b74d999506a3eba3b1a7d3e1 (patch)
tree1344a78d7352fa01b8a2086dc0bd0810b3e3d10b
parenta9ffbd4c5a5a952c8f51edf1f53604b8b9d78e39 (diff)
downloadnuttx-50e10d42c8e3c485b74d999506a3eba3b1a7d3e1.tar.gz
nuttx-50e10d42c8e3c485b74d999506a3eba3b1a7d3e1.tar.bz2
nuttx-50e10d42c8e3c485b74d999506a3eba3b1a7d3e1.zip
Add SAM4E OpenOCD scripts
-rw-r--r--nuttx/configs/sam4e-ek/README.txt43
-rwxr-xr-xnuttx/configs/sam4e-ek/tools/gdb.ini7
-rwxr-xr-xnuttx/configs/sam4e-ek/tools/openocd.cfg64
3 files changed, 112 insertions, 2 deletions
diff --git a/nuttx/configs/sam4e-ek/README.txt b/nuttx/configs/sam4e-ek/README.txt
index edde6027c..65430455c 100644
--- a/nuttx/configs/sam4e-ek/README.txt
+++ b/nuttx/configs/sam4e-ek/README.txt
@@ -16,6 +16,7 @@ Contents
- NXFLAT Toolchain
- Atmel Studio 6.1
- Loading Code with J-Link
+ - Loading Code OpenOCD
- Writing to FLASH using SAM-BA
- LEDs
- Serial Console
@@ -251,8 +252,8 @@ Atmel Studio 6.1
STATUS: At this point, Atmel Studio 6.1 claims that my object files are
not readable. A little more needs to be done to wring out this procedure.
-Loading Code into SRAM with J-Link
-==================================
+Loading Code with J-Link
+========================
Loading code with the Segger tools and GDB
------------------------------------------
@@ -282,6 +283,44 @@ Loading Code into SRAM with J-Link
GPNVM1 settings and flash lock bits? In any event, the GDB server works
great for debugging after writing the program to FLASH using SAM-BA.
+Loading Code OpenOCD
+====================
+
+ OpenOCD scripts are available in the configs/sam4e-ek/tools directory.
+ These scripts were used with OpenOCD 0.8.0. If you use a version after
+ OpenOCD 0.8.0, then you should comment out the following lines in the
+ openocd.cfg file:
+
+ # set CHIPNAME SAM4E16E
+ # source [find target/at91sam4sXX.cfg]
+
+ And uncomment this line:
+
+ source [find board/atmel_sam4e_ek.cfg]
+
+ This have been reported to work under Linux, but I have not been
+ successful using it under Windows OpenOCD 0.8.0 iwht libUSB. I get
+
+ Open On-Chip Debugger 0.8.0 (2014-04-28-08:42)
+ ...
+ Error: libusb_open() failed with LIBUSB_ERROR_NOT_SUPPORTED
+ Error: Cannot find jlink Interface! Please check connection and permissions.
+ ...
+
+ This is telling me that the Segger J-Link USB driver is incompatible
+ with libUSB. It may be necessary to replace the Segger J-Link driver
+ with the driver from libusb-win32-device-bin on sourceforge.
+
+ - Go into Control Panel/System/Device Manager and update the J-Link
+ driver to point at the new jlink.inf file made with the
+ libusb-win32/bin inf-wizard. Browse to the unsigned driver
+ pointed to by the inf, libusb0.dll from the libusb-win32-device-bin
+ distribution to complete the installation.
+
+ - The Segger driver appeared under "Universal Serial Bus Controllers"
+ in Device Manager (winXP) while the libusb-win32 driver appears as
+ new top level Dev Mgr category "LibUSB-Win32 Devices".
+
Writing to FLASH using SAM-BA
=============================
diff --git a/nuttx/configs/sam4e-ek/tools/gdb.ini b/nuttx/configs/sam4e-ek/tools/gdb.ini
new file mode 100755
index 000000000..374051fac
--- /dev/null
+++ b/nuttx/configs/sam4e-ek/tools/gdb.ini
@@ -0,0 +1,7 @@
+target remote localhost:3333
+file nuttx
+b os_start
+mon at91sam4 gpnvm set 1
+load
+mon reset init
+continue
diff --git a/nuttx/configs/sam4e-ek/tools/openocd.cfg b/nuttx/configs/sam4e-ek/tools/openocd.cfg
new file mode 100755
index 000000000..19d372eb5
--- /dev/null
+++ b/nuttx/configs/sam4e-ek/tools/openocd.cfg
@@ -0,0 +1,64 @@
+# This is an SAM4E-EK board with a single SAM4E16 chip.
+# http://www.atmel.com/tools/sam4e-ek.aspx
+#
+# Tested with OpenOCD 0.8.0
+
+source [find interface/jlink.cfg]
+
+# chip name
+set CHIPNAME SAM4E16E
+
+# Versions of OpenOCD after have atmel_sam4e_ek.cfg
+# source [find board/atmel_sam4e_ek.cfg]
+source [find target/at91sam4sXX.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
+}