adding raspberry pi 2 and A+ and B+ variations on blinker02
This commit is contained in:
@@ -13,5 +13,6 @@ per second.
|
||||
Hmm, there are comments in the manual about the system clock coming up
|
||||
at 250MHz. I wonder if this system timer is 250MHz/256 = 0.976MHz.
|
||||
|
||||
|
||||
|
||||
This directory contains an example for the ARM11 raspberry pi, for the
|
||||
ARM11 based A+ and B+ see the plus directory and for the Cortex A7 based
|
||||
raspberry pi 2 see the pi2 directory.
|
||||
|
||||
66
blinker02/pi2/Makefile
Normal file
66
blinker02/pi2/Makefile
Normal file
@@ -0,0 +1,66 @@
|
||||
|
||||
ARMGNU ?= arm-none-eabi
|
||||
|
||||
COPS = -Wall -O2 -nostdlib -nostartfiles -ffreestanding
|
||||
|
||||
gcc : blinker02.hex blinker02.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
|
||||
|
||||
blinker02.o : blinker02.c
|
||||
$(ARMGNU)-gcc $(COPS) -c blinker02.c -o blinker02.o
|
||||
|
||||
blinker02.elf : memmap vectors.o blinker02.o
|
||||
$(ARMGNU)-ld vectors.o blinker02.o -T memmap -o blinker02.elf
|
||||
$(ARMGNU)-objdump -D blinker02.elf > blinker02.list
|
||||
|
||||
blinker02.bin : blinker02.elf
|
||||
$(ARMGNU)-objcopy blinker02.elf -O binary blinker02.bin
|
||||
|
||||
blinker02.hex : blinker02.elf
|
||||
$(ARMGNU)-objcopy blinker02.elf -O ihex blinker02.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 : blinker02.clang.hex blinker02.clang.bin
|
||||
|
||||
|
||||
blinker02.clang.bc : blinker02.c
|
||||
clang $(LOPS) -c blinker02.c -o blinker02.clang.bc
|
||||
|
||||
blinker02.clang.opt.elf : memmap vectors.o blinker02.clang.bc
|
||||
opt $(OOPS) blinker02.clang.bc -o blinker02.clang.opt.bc
|
||||
llc $(LLCOPS) blinker02.clang.opt.bc -o blinker02.clang.opt.s
|
||||
$(ARMGNU)-as blinker02.clang.opt.s -o blinker02.clang.opt.o
|
||||
$(ARMGNU)-ld -o blinker02.clang.opt.elf -T memmap vectors.o blinker02.clang.opt.o
|
||||
$(ARMGNU)-objdump -D blinker02.clang.opt.elf > blinker02.clang.opt.list
|
||||
|
||||
blinker02.clang.hex : blinker02.clang.opt.elf
|
||||
$(ARMGNU)-objcopy blinker02.clang.opt.elf blinker02.clang.hex -O ihex
|
||||
|
||||
blinker02.clang.bin : blinker02.clang.opt.elf
|
||||
$(ARMGNU)-objcopy blinker02.clang.opt.elf blinker02.clang.bin -O binary
|
||||
|
||||
9
blinker02/pi2/README
Normal file
9
blinker02/pi2/README
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
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 blinker02 in the plus directory except the raspberry pi 2
|
||||
uses a different base address (0x3F000000) than the raspberry pi 1
|
||||
(0x20000000) likely to make room for more ram but who knows.
|
||||
68
blinker02/pi2/blinker02.c
Normal file
68
blinker02/pi2/blinker02.c
Normal file
@@ -0,0 +1,68 @@
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
extern void PUT32 ( unsigned int, unsigned int );
|
||||
extern unsigned int GET32 ( unsigned int );
|
||||
extern void dummy ( unsigned int );
|
||||
|
||||
#define SYSTIMERCLO 0x3F003004
|
||||
#define GPFSEL3 0x3F20000C
|
||||
#define GPFSEL4 0x3F200010
|
||||
#define GPSET1 0x3F200020
|
||||
#define GPCLR1 0x3F20002C
|
||||
|
||||
//0x01000000 17 seconds
|
||||
//0x00400000 4 seconds
|
||||
#define TIMER_BIT 0x00400000
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
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));
|
||||
while(1)
|
||||
{
|
||||
ra=GET32(SYSTIMERCLO);
|
||||
if((ra&=TIMER_BIT)==TIMER_BIT) break;
|
||||
}
|
||||
PUT32(GPCLR1,1<<(47-32));
|
||||
PUT32(GPSET1,1<<(35-32));
|
||||
while(1)
|
||||
{
|
||||
ra=GET32(SYSTIMERCLO);
|
||||
if((ra&=TIMER_BIT)==0) break;
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
11
blinker02/pi2/memmap
Normal file
11
blinker02/pi2/memmap
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
MEMORY
|
||||
{
|
||||
ram : ORIGIN = 0x8000, LENGTH = 0x1000
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.text : { *(.text*) } > ram
|
||||
.bss : { *(.bss*) } > ram
|
||||
}
|
||||
39
blinker02/pi2/vectors.s
Normal file
39
blinker02/pi2/vectors.s
Normal file
@@ -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.
|
||||
;@
|
||||
;@-------------------------------------------------------------------------
|
||||
66
blinker02/plus/Makefile
Normal file
66
blinker02/plus/Makefile
Normal file
@@ -0,0 +1,66 @@
|
||||
|
||||
ARMGNU ?= arm-none-eabi
|
||||
|
||||
COPS = -Wall -O2 -nostdlib -nostartfiles -ffreestanding
|
||||
|
||||
gcc : blinker02.hex blinker02.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
|
||||
|
||||
blinker02.o : blinker02.c
|
||||
$(ARMGNU)-gcc $(COPS) -c blinker02.c -o blinker02.o
|
||||
|
||||
blinker02.elf : memmap vectors.o blinker02.o
|
||||
$(ARMGNU)-ld vectors.o blinker02.o -T memmap -o blinker02.elf
|
||||
$(ARMGNU)-objdump -D blinker02.elf > blinker02.list
|
||||
|
||||
blinker02.bin : blinker02.elf
|
||||
$(ARMGNU)-objcopy blinker02.elf -O binary blinker02.bin
|
||||
|
||||
blinker02.hex : blinker02.elf
|
||||
$(ARMGNU)-objcopy blinker02.elf -O ihex blinker02.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 : blinker02.clang.hex blinker02.clang.bin
|
||||
|
||||
|
||||
blinker02.clang.bc : blinker02.c
|
||||
clang $(LOPS) -c blinker02.c -o blinker02.clang.bc
|
||||
|
||||
blinker02.clang.opt.elf : memmap vectors.o blinker02.clang.bc
|
||||
opt $(OOPS) blinker02.clang.bc -o blinker02.clang.opt.bc
|
||||
llc $(LLCOPS) blinker02.clang.opt.bc -o blinker02.clang.opt.s
|
||||
$(ARMGNU)-as blinker02.clang.opt.s -o blinker02.clang.opt.o
|
||||
$(ARMGNU)-ld -o blinker02.clang.opt.elf -T memmap vectors.o blinker02.clang.opt.o
|
||||
$(ARMGNU)-objdump -D blinker02.clang.opt.elf > blinker02.clang.opt.list
|
||||
|
||||
blinker02.clang.hex : blinker02.clang.opt.elf
|
||||
$(ARMGNU)-objcopy blinker02.clang.opt.elf blinker02.clang.hex -O ihex
|
||||
|
||||
blinker02.clang.bin : blinker02.clang.opt.elf
|
||||
$(ARMGNU)-objcopy blinker02.clang.opt.elf blinker02.clang.bin -O binary
|
||||
|
||||
11
blinker02/plus/README
Normal file
11
blinker02/plus/README
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
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 blinker02 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+.
|
||||
|
||||
68
blinker02/plus/blinker02.c
Normal file
68
blinker02/plus/blinker02.c
Normal file
@@ -0,0 +1,68 @@
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
extern void PUT32 ( unsigned int, unsigned int );
|
||||
extern unsigned int GET32 ( unsigned int );
|
||||
extern void dummy ( unsigned int );
|
||||
|
||||
#define SYSTIMERCLO 0x20003004
|
||||
#define GPFSEL3 0x2020000C
|
||||
#define GPFSEL4 0x20200010
|
||||
#define GPSET1 0x20200020
|
||||
#define GPCLR1 0x2020002C
|
||||
|
||||
//0x01000000 17 seconds
|
||||
//0x00400000 4 seconds
|
||||
#define TIMER_BIT 0x00400000
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
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));
|
||||
while(1)
|
||||
{
|
||||
ra=GET32(SYSTIMERCLO);
|
||||
if((ra&=TIMER_BIT)==TIMER_BIT) break;
|
||||
}
|
||||
PUT32(GPCLR1,1<<(47-32));
|
||||
PUT32(GPSET1,1<<(35-32));
|
||||
while(1)
|
||||
{
|
||||
ra=GET32(SYSTIMERCLO);
|
||||
if((ra&=TIMER_BIT)==0) break;
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
11
blinker02/plus/memmap
Normal file
11
blinker02/plus/memmap
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
MEMORY
|
||||
{
|
||||
ram : ORIGIN = 0x8000, LENGTH = 0x1000
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.text : { *(.text*) } > ram
|
||||
.bss : { *(.bss*) } > ram
|
||||
}
|
||||
39
blinker02/plus/vectors.s
Normal file
39
blinker02/plus/vectors.s
Normal file
@@ -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.
|
||||
;@
|
||||
;@-------------------------------------------------------------------------
|
||||
Reference in New Issue
Block a user