adding pi2 blinker02 in svc mode
This commit is contained in:
67
boards/pi2/SVC/blinker02/Makefile
Normal file
67
boards/pi2/SVC/blinker02/Makefile
Normal file
@@ -0,0 +1,67 @@
|
||||
|
||||
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
|
||||
OOPS = -std-link-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
|
||||
|
||||
27
boards/pi2/SVC/blinker02/README
Normal file
27
boards/pi2/SVC/blinker02/README
Normal file
@@ -0,0 +1,27 @@
|
||||
|
||||
See the top level README for information on where to find documentation
|
||||
for the raspberry pi and the ARM processor inside. Also find information
|
||||
on how to load and run these programs.
|
||||
|
||||
This example is for the pi2, see other directories for other flavors
|
||||
of raspberry pi. This example switches back to SVC mode from HYP mode.
|
||||
|
||||
There is a free-running 64 bit timer, super easy to use, just read it.
|
||||
|
||||
//0x01000000 17 seconds
|
||||
//0x00400000 4 seconds
|
||||
//#define TIMER_BIT 0x01000000
|
||||
#define TIMER_BIT 0x00400000
|
||||
|
||||
I think what they are doing is using a 1GHz clock for the ARM core
|
||||
(and GPU?) That is divided by 4 to get the 250MHz system clock (and
|
||||
or there is a 250MHz reference clock that is multiplied by 4). Either
|
||||
way there is a 250MHz system clock, and my guess is this is divided by
|
||||
256 to get 977KHz. 0x01000000 ticks would be 17.18 seconds and I am
|
||||
using a watch with a second hand, so very plausible.
|
||||
|
||||
Can change the TIMER_BIT to a different one to change the blink rate
|
||||
of the LED for example try:
|
||||
|
||||
#define TIMER_BIT 0x00100000
|
||||
|
||||
68
boards/pi2/SVC/blinker02/blinker02.c
Normal file
68
boards/pi2/SVC/blinker02/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 0x01000000
|
||||
#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
boards/pi2/SVC/blinker02/memmap
Normal file
11
boards/pi2/SVC/blinker02/memmap
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
MEMORY
|
||||
{
|
||||
ram : ORIGIN = 0x8000, LENGTH = 0x1000
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.text : { *(.text*) } > ram
|
||||
.bss : { *(.bss*) } > ram
|
||||
}
|
||||
52
boards/pi2/SVC/blinker02/vectors.s
Normal file
52
boards/pi2/SVC/blinker02/vectors.s
Normal file
@@ -0,0 +1,52 @@
|
||||
|
||||
;@ ------------------------------------------------------------------
|
||||
;@ ------------------------------------------------------------------
|
||||
|
||||
|
||||
.globl _start
|
||||
_start:
|
||||
;@ b skip
|
||||
mrs r0,cpsr
|
||||
and r1,r0,#0x1F
|
||||
cmp r1,#0x1A
|
||||
bne skip
|
||||
bic r0,r0,#0x1F
|
||||
orr r0,r0,#0x13
|
||||
msr spsr_cxsf,r0
|
||||
add r0,pc,#4
|
||||
msr ELR_hyp,r0 ;@ .word 0xe12ef300
|
||||
eret ;@ .word 0xe160006e
|
||||
skip:
|
||||
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