From 2e0f28149d46f128cf6851e76bf541f66b484fd5 Mon Sep 17 00:00:00 2001
From: oharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Date: Thu, 15 Jan 2009 13:22:04 +0000
Subject: [PATCH] Alan Carvalho de Assis <acassis@gmail.com> test app for imx27

git-svn-id: svn://svn.berlios.de/openocd/trunk@1323 b42882b7-edfa-0310-969c-e2dbd0fdcd60
---
 testing/examples/ledtest-imx27ads/Makefile    |  42 ++++++++++++
 testing/examples/ledtest-imx27ads/crt0.S      |  47 ++++++++++++++
 .../ledtest-imx27ads/gdbinit-imx27ads         |  36 +++++++++++
 testing/examples/ledtest-imx27ads/ldscript    |  18 ++++++
 testing/examples/ledtest-imx27ads/test.c      |  60 ++++++++++++++++++
 testing/examples/ledtest-imx27ads/test.elf    | Bin 0 -> 35762 bytes
 6 files changed, 203 insertions(+)
 create mode 100644 testing/examples/ledtest-imx27ads/Makefile
 create mode 100644 testing/examples/ledtest-imx27ads/crt0.S
 create mode 100644 testing/examples/ledtest-imx27ads/gdbinit-imx27ads
 create mode 100644 testing/examples/ledtest-imx27ads/ldscript
 create mode 100644 testing/examples/ledtest-imx27ads/test.c
 create mode 100644 testing/examples/ledtest-imx27ads/test.elf

diff --git a/testing/examples/ledtest-imx27ads/Makefile b/testing/examples/ledtest-imx27ads/Makefile
new file mode 100644
index 000000000..425164923
--- /dev/null
+++ b/testing/examples/ledtest-imx27ads/Makefile
@@ -0,0 +1,42 @@
+# This will make the test program for a Freescale iMX27 ADS Board with a 
+# FreeScale iMX27 CPU 
+
+PROC=arm
+TYPE=926ejs-linux
+LDSCRIPT=ldscript
+
+PATH:=/opt/freescale/usr/local/gcc-4.1.1-glibc-2.4-nptl-sf-1/arm-926ejs-linux/bin/:$(PATH)
+CC=$(PROC)-$(TYPE)-gcc
+AS=$(PROC)-$(TYPE)-as
+AR=$(PROC)-$(TYPE)-ar
+LD=$(PROC)-$(TYPE)-ld
+NM=$(PROC)-$(TYPE)-nm
+OBJDUMP=$(PROC)-$(TYPE)-objdump
+CFLAGS= -g -c -mcpu=arm920t
+
+all: test.elf
+
+# Make a little endian image:
+# In Eclipse, add the line :
+#    source gdbinit 
+# to : Run -> Debug... (menu) -> Commands (tab): Commands (listbox)
+# To start gdb from a window use : arm-elf-gdb --command=gdbinit
+test.elf: test.c Makefile ldscript crt0.S
+	$(CC) $(CFLAGS) -o crt0.o crt0.S
+	$(CC) $(CFLAGS) -o test.o test.c
+	$(LD) -g -v -T$(LDSCRIPT) -o test.elf crt0.o test.o 
+	$(NM) test.elf
+
+
+dump:
+	$(OBJDUMP) --all-headers test.elf
+
+dump_test:
+	$(OBJDUMP) --disassemble test.elf
+
+dump_full:
+	$(OBJDUMP) --full-contents test.elf
+
+clean:
+	-/bin/rm -f *.o *~ test.elf
+
diff --git a/testing/examples/ledtest-imx27ads/crt0.S b/testing/examples/ledtest-imx27ads/crt0.S
new file mode 100644
index 000000000..6c15be213
--- /dev/null
+++ b/testing/examples/ledtest-imx27ads/crt0.S
@@ -0,0 +1,47 @@
+/* Sample initialization file */
+	
+	.extern	main
+	.extern	exit
+	
+/* .text is used instead of .section .text so it works with arm-aout too.  */
+	.text
+	.code 32
+	.align 	0
+
+	.global	_mainCRTStartup
+	.global	_start
+	.global	start
+start:
+_start:
+_mainCRTStartup:
+
+/* Start by setting up a stack */
+	/*  Set up the stack pointer to end of bss */
+	ldr	r3, .LC2
+	mov 	sp, r3
+
+	sub	sl, sp, #512	/* Still assumes 512 bytes below sl */
+
+	mov 	a2, #0		/* Second arg: fill value */
+	mov	fp, a2		/* Null frame pointer */
+	mov	r7, a2		/* Null frame pointer for Thumb */
+	
+	ldr	a1, .LC1	/* First arg: start of memory block */
+	ldr	a3, .LC2	/* Second arg: end of memory block */
+	sub	a3, a3, a1	/* Third arg: length of block */
+	
+	mov	r0, #0		/*  no arguments  */
+	mov	r1, #0		/*  no argv either */
+
+	bl	main
+	bl	exit		/* Should not return */
+
+	/* For Thumb, constants must be after the code since only 
+	positive offsets are supported for PC relative addresses. */
+	
+	.align 0
+.LC1:
+	.word	__bss_start__
+.LC2:
+	.word	__bss_end__
+
diff --git a/testing/examples/ledtest-imx27ads/gdbinit-imx27ads b/testing/examples/ledtest-imx27ads/gdbinit-imx27ads
new file mode 100644
index 000000000..44758cf15
--- /dev/null
+++ b/testing/examples/ledtest-imx27ads/gdbinit-imx27ads
@@ -0,0 +1,36 @@
+echo Script to load ledtest on iMX27ADS.\n
+
+# Note: you need to startup openocd with "-f board/imx27ads.cfg"
+# in order to it initialize RAM memory.
+
+# SETUP GDB :
+#
+# Common gdb setup for ARM CPUs
+set complaints 1
+set output-radix 10
+set input-radix 10
+set prompt (arm-gdb)
+set endian little
+dir .
+
+# CONNECT TO TARGET :
+target remote 127.0.0.1:3333
+
+#  LOAD IMAGE :
+#
+
+# Load the program executable called "u-boot"
+load test.elf
+
+# Load the symbols for the program.
+symbol-file test.elf
+
+# RUN TO MAIN :
+#
+# Set a breakpoint at main().
+#b reset
+b main
+
+# Run to the breakpoint.
+c
+
diff --git a/testing/examples/ledtest-imx27ads/ldscript b/testing/examples/ledtest-imx27ads/ldscript
new file mode 100644
index 000000000..39cf76845
--- /dev/null
+++ b/testing/examples/ledtest-imx27ads/ldscript
@@ -0,0 +1,18 @@
+SECTIONS
+{
+    . = 0xA0000000;
+	.text : { *(.text) }
+	.data ALIGN(0x10): { *(.data) }
+	.bss ALIGN(0x10): {
+	    __bss_start__ = ABSOLUTE(.);
+	    *(.bss)
+	    . += 0x100;
+        }
+	__bss_end__ = .;
+PROVIDE (__stack = .);
+	_end = .;
+	.debug_info     0 : { *(.debug_info) }
+   	.debug_abbrev   0 : { *(.debug_abbrev) }
+   	.debug_line     0 : { *(.debug_line) }
+   	.debug_frame    0 : { *(.debug_frame) }
+}
diff --git a/testing/examples/ledtest-imx27ads/test.c b/testing/examples/ledtest-imx27ads/test.c
new file mode 100644
index 000000000..945778df8
--- /dev/null
+++ b/testing/examples/ledtest-imx27ads/test.c
@@ -0,0 +1,60 @@
+/***************************************************************************
+ *   Copyright (C) 2009 by Alan Carvalho de Assis       		   *
+ *   acassis@gmail.com                                                     *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ ***************************************************************************/
+
+void delay()
+{
+	int i;
+	for (i = 0; i < 500000; i++);
+}
+
+/* MAIN ARM FUNTION */
+int main (void)  
+{
+	int i;	
+        volatile unsigned char *ledoff = ((volatile unsigned char *)0xD4000008);
+        volatile unsigned char *ledon = ((volatile unsigned char *)0xD400000C);
+	
+	for (i = 0; i < 10000; i++)
+    	{
+		*ledon = 0x30;
+		delay();
+		*ledoff = 0x30;
+		delay();
+    	} /* FOR */
+
+} /* MAIN */
+
+__gccmain()
+{
+} /* GCCMAIN */
+
+
+void exit(int exit_code)
+{
+  while(1);
+} /* EXIT */
+
+
+atexit()
+{
+  while(1);
+} /* ATEXIT */
+
+
diff --git a/testing/examples/ledtest-imx27ads/test.elf b/testing/examples/ledtest-imx27ads/test.elf
new file mode 100644
index 0000000000000000000000000000000000000000..f65dcd63160ce8d64815bba49996cf890d62e4b5
GIT binary patch
literal 35762
zcmeH}U1%It6vxk<*(BTSrrmth2GZIUs%?erPGY2`+8UeG8XAlC0~Ax1$?jycvL9i0
zBPkY*v=*c)_Q@y7^vwq!`mRFp$p;^T_)tWoNeuKuqy--Wg6sdx%-u|aErL(NIqbdX
zoO{mw`pum?``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