From 1fee1784c12e9fa3d0dc7189433ce38bb65b640a Mon Sep 17 00:00:00 2001 From: dwelch67 Date: Wed, 23 Dec 2015 03:43:12 -0500 Subject: [PATCH] added a blinker01 example for the A+ and B+ --- blinker01/README | 5 ++- blinker01/blinker01.bin | Bin 148 -> 148 bytes blinker01/blinker01.elf | Bin 33639 -> 33624 bytes blinker01/blinker01.hex | 6 +-- blinker01/blinker01.list | 16 ++++---- blinker01/blinker01.o | Bin 1012 -> 1012 bytes blinker01/pi2/asm/blinker01.c | 7 +++- blinker01/plus/Makefile | 70 ++++++++++++++++++++++++++++++++++ blinker01/plus/README | 12 ++++++ blinker01/plus/blinker01.c | 55 ++++++++++++++++++++++++++ blinker01/plus/memmap | 11 ++++++ blinker01/plus/vectors.s | 39 +++++++++++++++++++ blinker01/vectors.o | Bin 800 -> 800 bytes 13 files changed, 207 insertions(+), 14 deletions(-) create mode 100644 blinker01/plus/Makefile create mode 100644 blinker01/plus/README create mode 100644 blinker01/plus/blinker01.c create mode 100644 blinker01/plus/memmap create mode 100644 blinker01/plus/vectors.s diff --git a/blinker01/README b/blinker01/README index ab00f63..28e6809 100644 --- a/blinker01/README +++ b/blinker01/README @@ -6,8 +6,9 @@ these programs. The code in this directory is for the old/original-ish raspberry pi which you can still get raspberry pi 1 if you will. The pi2 directory -is for the raspberry pi 2 the one with the quad core arm. You have to -match the right program to the right raspberry pi. +is for the raspberry pi 2 the one with the quad core arm. The plus +directory is for the raspberry pi B+ and A+. You have to match the +right program to the right raspberry pi. This simple example sets up a small stack, not much to this program so the stack doesnt need much room. It then enables gpio16 as diff --git a/blinker01/blinker01.bin b/blinker01/blinker01.bin index 76e0e8277411879d104c438f659aec02dc623740..1db6d1a5714e8a060d98567ac9c10bcf1826e9dd 100755 GIT binary patch delta 54 zcmbQjIE8V7jSi#4g2yfl^PhhB|Nk|E!-B^w3=1AII9PUkao~1*m3X Gh7JJ5x*FjC delta 54 zcmbQjIE8V7jgAMy{HKf(3m$*?|Nk|E!-B^w3=1AII9PUrGb2W@3g8 E0LOwF=>Px# diff --git a/blinker01/blinker01.elf b/blinker01/blinker01.elf index 2d52e8562eac93bbad27037ab10c4b869040c931..8af0133fac4d4b4af9778f6be9162f2ee3b66ffc 100755 GIT binary patch delta 172 zcmaFf#&n~NX@Y{WLlXl76B7fg34;OyBZCG5I|B=lMg>zE7#Kj96)eoSF>!wV!~(ua z4K_NA5(^%?FwB4Y;s5{F3=Rt(voI`p$mr1W2*hV(3wiwO|9>fv8Wo_L$r%kvtfqR# zdIpovHv~<#Z0eqTrD^iSB+bbtjT?A*8W|Wq0L^CuVy?*_8>LzQ07aZ97d8q50R7K5 A5dZ)H delta 215 zcmcc7#`L_6X@Y_gPa^{Z69WUQ34;OyBZCG5I|B=l27(3zo&scoFe?xin6 QRKWoY!^i)V*ECKB0P(psv;Y7A diff --git a/blinker01/blinker01.hex b/blinker01/blinker01.hex index 10841ed..dee7cff 100644 --- a/blinker01/blinker01.hex +++ b/blinker01/blinker01.hex @@ -1,10 +1,10 @@ :1080000002D9A0E3050000EBFEFFFFEA001080E5C7 :108010001EFF2FE1000090E51EFF2FE11EFF2FE164 :1080200010402DE95C009FE5F9FFFFEB0717C0E367 -:10803000011781E34C009FE5F3FFFFEB48009FE54C -:108040000118A0E3F0FFFFEB0040A0E30400A0E173 +:10803000011781E34C009FE5F3FFFFEB0118A0E37C +:1080400044009FE5F0FFFFEB0040A0E30400A0E147 :10805000014084E2F0FFFFEB010654E3FAFFFF1A50 -:1080600028009FE50118A0E3E7FFFFEB0040A0E335 +:108060000118A0E324009FE5E7FFFFEB0040A0E339 :108070000400A0E1014084E2E7FFFFEB010654E3C6 :10808000FAFFFF1AECFFFFEA040020201C0020206A :048090002800202084 diff --git a/blinker01/blinker01.list b/blinker01/blinker01.list index 3e7dcd8..f436ad6 100644 --- a/blinker01/blinker01.list +++ b/blinker01/blinker01.list @@ -30,8 +30,8 @@ Disassembly of section .text: 8030: e3811701 orr r1, r1, #262144 ; 0x40000 8034: e59f004c ldr r0, [pc, #76] ; 8088 8038: ebfffff3 bl 800c - 803c: e59f0048 ldr r0, [pc, #72] ; 808c - 8040: e3a01801 mov r1, #65536 ; 0x10000 + 803c: e3a01801 mov r1, #65536 ; 0x10000 + 8040: e59f0044 ldr r0, [pc, #68] ; 808c 8044: ebfffff0 bl 800c 8048: e3a04000 mov r4, #0 804c: e1a00004 mov r0, r4 @@ -39,8 +39,8 @@ Disassembly of section .text: 8054: ebfffff0 bl 801c 8058: e3540601 cmp r4, #1048576 ; 0x100000 805c: 1afffffa bne 804c - 8060: e59f0028 ldr r0, [pc, #40] ; 8090 - 8064: e3a01801 mov r1, #65536 ; 0x10000 + 8060: e3a01801 mov r1, #65536 ; 0x10000 + 8064: e59f0024 ldr r0, [pc, #36] ; 8090 8068: ebffffe7 bl 800c 806c: e3a04000 mov r4, #0 8070: e1a00004 mov r0, r4 @@ -61,10 +61,10 @@ Disassembly of section .ARM.attributes: 8: 01006962 tsteq r0, r2, ror #18 c: 00000020 andeq r0, r0, r0, lsr #32 10: 4d524105 ldfmie f4, [r2, #-20] ; 0xffffffec - 14: 54347620 ldrtpl r7, [r4], #-1568 ; 0x620 + 14: 54347620 ldrtpl r7, [r4], #-1568 ; 0xfffff9e0 18: 08020600 stmdaeq r2, {r9, sl} 1c: 12010901 andne r0, r1, #16384 ; 0x4000 - 20: 15011404 strne r1, [r1, #-1028] ; 0x404 + 20: 15011404 strne r1, [r1, #-1028] ; 0xfffffbfc 24: 18031701 stmdane r3, {r0, r8, r9, sl, ip} 28: Address 0x0000000000000028 is out of bounds. @@ -74,6 +74,6 @@ Disassembly of section .comment: 00000000 <.comment>: 0: 3a434347 bcc 10d0d24 4: 4e472820 cdpmi 8, 4, cr2, cr7, cr0, {1} - 8: 34202955 strtcc r2, [r0], #-2389 ; 0x955 - c: 322e382e eorcc r3, lr, #3014656 ; 0x2e0000 + 8: 35202955 strcc r2, [r0, #-2389]! ; 0xfffff6ab + c: 302e332e eorcc r3, lr, lr, lsr #6 ... diff --git a/blinker01/blinker01.o b/blinker01/blinker01.o index 45f37a4f2eabdb87b09a3c8f7c67f83d6fbc2d05..1be952ceb2283d627dd74c745fb35feeca80d8bc 100644 GIT binary patch delta 98 zcmeyu{)K&l0#gdpL?t~AMu`QFT^Qy+ome9SW~+eN7ObXv#(D-5cXm(S!^E@s0h0*h tWM@Xn$pMT!lOq|8xf~cEz=Ub?G{$#KCXAEYnABKVm>3vzCm&=K1^^BB8=C+C delta 98 zcmeyu{)K&l0+R{jL?t~A4~F?q86_4xo>(Kpp#f)Gu$t&u=owAi**&>|i3f;nxEP?| q2=nA)Oz)VEFiqaZtj0QpnSnuf@<%4&$rVfjlm9SrZ1!Q4U<3dSGaa}9 diff --git a/blinker01/pi2/asm/blinker01.c b/blinker01/pi2/asm/blinker01.c index deb1039..5f248be 100644 --- a/blinker01/pi2/asm/blinker01.c +++ b/blinker01/pi2/asm/blinker01.c @@ -7,6 +7,11 @@ extern unsigned int GET32 ( unsigned int ); extern void dummy ( unsigned int ); extern void HOP ( unsigned int ); +void put32(unsigned long int addr, unsigned long int val) { + volatile unsigned long int *a; + a = addr; + *a = val; +} //------------------------------------------------------------------------- int notmain ( void ) { @@ -25,7 +30,7 @@ int notmain ( void ) PUT32(ra,0xe3811902); ra+=4; PUT32(ra,0xe580100c); ra+=4; PUT32(ra,0xe3a02902); ra+=4; - PUT32(ra,0xe3a03008); ra+=4; + put32(ra,0xe3a03008); ra+=4; PUT32(ra,0xe5802020); ra+=4; PUT32(ra,0xe580302c); ra+=4; PUT32(ra,0xe3a04601); ra+=4; diff --git a/blinker01/plus/Makefile b/blinker01/plus/Makefile new file mode 100644 index 0000000..e5bdcbd --- /dev/null +++ b/blinker01/plus/Makefile @@ -0,0 +1,70 @@ + +ARMGNU ?= arm-none-eabi + +AOPS = --warn --fatal-warnings +COPS = -Wall -Werror -O2 -nostdlib -nostartfiles -ffreestanding + + + +gcc : blinker01.hex blinker01.bin + +all : gcc clang + +clean : + rm -f *.o + rm -f *.bin + rm -f *.hex + rm -f *.elf + rm -f *.list + rm -f *.img + rm -f *.bc + rm -f *.clang.opt.s + +vectors.o : vectors.s + $(ARMGNU)-as vectors.s -o vectors.o + +blinker01.o : blinker01.c + $(ARMGNU)-gcc $(COPS) -c blinker01.c -o blinker01.o + +blinker01.elf : memmap vectors.o blinker01.o + $(ARMGNU)-ld vectors.o blinker01.o -T memmap -o blinker01.elf + $(ARMGNU)-objdump -D blinker01.elf > blinker01.list + +blinker01.bin : blinker01.elf + $(ARMGNU)-objcopy blinker01.elf -O binary blinker01.bin + +blinker01.hex : blinker01.elf + $(ARMGNU)-objcopy blinker01.elf -O ihex blinker01.hex + + + + + + +LOPS = -Wall -m32 -emit-llvm +LLCOPS = -march=arm -mcpu=arm1176jzf-s +LLCOPS0 = -march=arm +LLCOPS1 = -march=arm -mcpu=arm1176jzf-s +COPS = -Wall -O2 -nostdlib -nostartfiles -ffreestanding +OOPS = -std-compile-opts + +clang : blinker01.clang.hex blinker01.clang.bin + + +blinker01.clang.bc : blinker01.c + clang $(LOPS) -c blinker01.c -o blinker01.clang.bc + +blinker01.clang.opt.elf : memmap vectors.o blinker01.clang.bc + opt $(OOPS) blinker01.clang.bc -o blinker01.clang.opt.bc + llc $(LLCOPS) blinker01.clang.opt.bc -o blinker01.clang.opt.s + $(ARMGNU)-as blinker01.clang.opt.s -o blinker01.clang.opt.o + $(ARMGNU)-ld -o blinker01.clang.opt.elf -T memmap vectors.o blinker01.clang.opt.o + $(ARMGNU)-objdump -D blinker01.clang.opt.elf > blinker01.clang.opt.list + +blinker01.clang.hex : blinker01.clang.opt.elf + $(ARMGNU)-objcopy blinker01.clang.opt.elf blinker01.clang.hex -O ihex + +blinker01.clang.bin : blinker01.clang.opt.elf + $(ARMGNU)-objcopy blinker01.clang.opt.elf blinker01.clang.bin -O binary + + diff --git a/blinker01/plus/README b/blinker01/plus/README new file mode 100644 index 0000000..5ae9c98 --- /dev/null +++ b/blinker01/plus/README @@ -0,0 +1,12 @@ + +See the top level README for information on where to find the +schematic and programmers reference manual for the ARM processor +on the raspberry pi. Also find information on how to load and run +these programs. + +Same as blinker01 in the directory above, except the raspberry pi 1 +A+ and B+ have two leds one on gpio47 the other gpio35. + +I tested this on an A+. I probably have a B+ around somewhere, but +not sure where. The A+ does appear to have two leds and they are both +blinking. diff --git a/blinker01/plus/blinker01.c b/blinker01/plus/blinker01.c new file mode 100644 index 0000000..e30a815 --- /dev/null +++ b/blinker01/plus/blinker01.c @@ -0,0 +1,55 @@ + +//------------------------------------------------------------------------- +//------------------------------------------------------------------------- + +extern void PUT32 ( unsigned int, unsigned int ); +extern unsigned int GET32 ( unsigned int ); +extern void dummy ( unsigned int ); + +#define GPFSEL3 0x2020000C +#define GPFSEL4 0x20200010 +#define GPSET1 0x20200020 +#define GPCLR1 0x2020002C + +//------------------------------------------------------------------------- +int notmain ( void ) +{ + unsigned int ra; + + ra=GET32(GPFSEL4); + ra&=~(7<<21); + ra|=1<<21; + PUT32(GPFSEL4,ra); + + ra=GET32(GPFSEL3); + ra&=~(7<<15); + ra|=1<<15; + PUT32(GPFSEL3,ra); + + while(1) + { + PUT32(GPSET1,1<<(47-32)); + PUT32(GPCLR1,1<<(35-32)); + for(ra=0;ra<0x100000;ra++) dummy(ra); + PUT32(GPCLR1,1<<(47-32)); + PUT32(GPSET1,1<<(35-32)); + for(ra=0;ra<0x100000;ra++) dummy(ra); + } + + return(0); +} +//------------------------------------------------------------------------- +//------------------------------------------------------------------------- + + +//------------------------------------------------------------------------- +// +// Copyright (c) 2015 David Welch dwelch@dwelch.com +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +//------------------------------------------------------------------------- diff --git a/blinker01/plus/memmap b/blinker01/plus/memmap new file mode 100644 index 0000000..afebc70 --- /dev/null +++ b/blinker01/plus/memmap @@ -0,0 +1,11 @@ + +MEMORY +{ + ram : ORIGIN = 0x8000, LENGTH = 0x10000 +} + +SECTIONS +{ + .text : { *(.text*) } > ram + .bss : { *(.bss*) } > ram +} diff --git a/blinker01/plus/vectors.s b/blinker01/plus/vectors.s new file mode 100644 index 0000000..9cdad8b --- /dev/null +++ b/blinker01/plus/vectors.s @@ -0,0 +1,39 @@ + +;@ ------------------------------------------------------------------ +;@ ------------------------------------------------------------------ + +.globl _start +_start: + mov sp,#0x8000 + bl notmain +hang: b hang + +.globl PUT32 +PUT32: + str r1,[r0] + bx lr + +.globl GET32 +GET32: + ldr r0,[r0] + bx lr + +.globl dummy +dummy: + bx lr + +;@------------------------------------------------------------------------- +;@------------------------------------------------------------------------- + + +;@------------------------------------------------------------------------- +;@ +;@ Copyright (c) 2012 David Welch dwelch@dwelch.com +;@ +;@ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +;@ +;@ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +;@ +;@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +;@ +;@------------------------------------------------------------------------- diff --git a/blinker01/vectors.o b/blinker01/vectors.o index 9f692bb1435d279542195478f59dd77a2362025b..0e8de30438719fc789002ec6f0faa95e3d1fb0b9 100644 GIT binary patch delta 57 zcmZ3$wt#Jd0@Du0iAu{R8!&yCxJ6;&0gj1R47eN^AYcaLWIo1YOlue>Ut?5b&0%C< K(3+gcC=37$h_CLUm!c;W*96Q>ar