Starting to add support for the Raspberri Pi 2

This commit is contained in:
dwelch67
2015-03-22 22:06:52 -04:00
parent bb46e5358f
commit 10f5860952
22 changed files with 258541 additions and 58 deletions

14
bootloader07/BCM2835.h Normal file
View File

@@ -0,0 +1,14 @@
#define PBASE 0x20000000
//-------------------------------------------------------------------------
//
// 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.
//
//-------------------------------------------------------------------------

14
bootloader07/BCM2836.h Normal file
View File

@@ -0,0 +1,14 @@
#define PBASE 0x3F000000
//-------------------------------------------------------------------------
//
// 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.
//
//-------------------------------------------------------------------------

View File

@@ -3,7 +3,7 @@ ARMGNU ?= arm-none-eabi
COPS = -Wall -O2 -nostdlib -nostartfiles -ffreestanding
gcc : kernel.img blinker.hex
gcc : kernel.img kernel7.img blinker.hex blinker7.hex
all : gcc clang
@@ -24,17 +24,23 @@ vectors.o : vectors.s
bootloader07.o : bootloader07.c
$(ARMGNU)-gcc $(COPS) -c bootloader07.c -o bootloader07.o
periph.o : periph.c
periph.o : periph.c BCM2835.h
$(ARMGNU)-gcc $(COPS) -c periph.c -o periph.o
periph7.o : periph.c BCM2836.h
$(ARMGNU)-gcc $(COPS) -c periph.c -o periph7.o -DRPI2
kernel.img : loader vectors.o periph.o bootloader07.o
$(ARMGNU)-ld vectors.o periph.o bootloader07.o -T loader -o bootloader07.elf
$(ARMGNU)-objdump -D bootloader07.elf > bootloader07.list
$(ARMGNU)-objcopy bootloader07.elf -O ihex bootloader07.hex
$(ARMGNU)-objcopy bootloader07.elf -O binary kernel.img
$(ARMGNU)-ld vectors.o periph.o bootloader07.o -T loader -o bootloader07_rpi1.elf
$(ARMGNU)-objdump -D bootloader07_rpi1.elf > bootloader07_rpi1.list
$(ARMGNU)-objcopy bootloader07_rpi1.elf -O ihex bootloader07_rpi1.hex
$(ARMGNU)-objcopy bootloader07_rpi1.elf -O binary kernel.img
kernel7.img : loader vectors.o periph7.o bootloader07.o
$(ARMGNU)-ld vectors.o periph7.o bootloader07.o -T loader -o bootloader07_rpi2.elf
$(ARMGNU)-objdump -D bootloader07_rpi2.elf > bootloader07_rpi2.list
$(ARMGNU)-objcopy bootloader07_rpi2.elf -O ihex bootloader07_rpi2.hex
$(ARMGNU)-objcopy bootloader07_rpi2.elf -O binary kernel7.img
start.o : start.s
@@ -47,9 +53,16 @@ blinker.hex : memmap start.o blinker.o
$(ARMGNU)-ld start.o blinker.o -T memmap -o blinker.elf
$(ARMGNU)-objdump -D blinker.elf > blinker.list
$(ARMGNU)-objcopy blinker.elf -O ihex blinker.hex
#$(ARMGNU)-objcopy blinker.elf -O binary blinker.bin
blinker7.o : blinker7.c
$(ARMGNU)-gcc $(COPS) -c blinker7.c -o blinker7.o
blinker7.hex : memmap start.o blinker7.o
$(ARMGNU)-ld start.o blinker7.o -T memmap -o blinker7.elf
$(ARMGNU)-objdump -D blinker7.elf > blinker7.list
$(ARMGNU)-objcopy blinker7.elf -O ihex blinker7.hex
#$(ARMGNU)-objcopy blinker7.elf -O binary blinker7.bin
@@ -60,7 +73,7 @@ LLCOPS = $(LLCOPS1)
COPS = -Wall -O2 -nostdlib -nostartfiles -ffreestanding
OOPS = -std-compile-opts
clang : bootloader07.bin
clang : bootloader07.clang.bin
bootloader07.bc : bootloader07.c
clang $(LOPS) -c bootloader07.c -o bootloader07.bc
@@ -76,7 +89,7 @@ bootloader07.clang.elf : loader vectors.o bootloader07.bc periph.bc
$(ARMGNU)-ld -o bootloader07.clang.elf -T loader vectors.o bootloader07.clang.o
$(ARMGNU)-objdump -D bootloader07.clang.elf > bootloader07.clang.list
bootloader07.bin : bootloader07.clang.elf
bootloader07.clang.bin : bootloader07.clang.elf
$(ARMGNU)-objcopy bootloader07.clang.elf bootloader07.clang.bin -O binary

View File

@@ -34,4 +34,11 @@ I normally do not deliver binaries. In this case I have included all
of the build files so that you can at least get started without having
to build the bootloader. Backup whatever kernel.img file you are using
and replace with the kernel.img file in this repo (on your sd card) to
use this program.
use this program. If on a Raspberry Pi 2 then use kernel7.img instead
of kernel.img.
blinker.hex is for older RPi boards the A and B whose activity led
is tied to GPIO16. The A+, B+, and RPi2 use GPIO47, also on these
latter boards the power led is on GPIO35. Last I checked they wouldnt
provide a schematic for these latter boards (so much for being "open")
so we have to just go on faith...

View File

@@ -2,20 +2,22 @@
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
#include "BCM2835.h" /* Original B,A,A+,B+ */
extern void PUT32 ( unsigned int, unsigned int );
extern unsigned int GET32 ( unsigned int );
extern void dummy ( unsigned int );
#define ARM_TIMER_LOD 0x2000B400
#define ARM_TIMER_VAL 0x2000B404
#define ARM_TIMER_CTL 0x2000B408
#define ARM_TIMER_DIV 0x2000B41C
#define ARM_TIMER_CNT 0x2000B420
#define ARM_TIMER_LOD (PBASE+0x0000B400)
#define ARM_TIMER_VAL (PBASE+0x0000B404)
#define ARM_TIMER_CTL (PBASE+0x0000B408)
#define ARM_TIMER_DIV (PBASE+0x0000B41C)
#define ARM_TIMER_CNT (PBASE+0x0000B420)
#define SYSTIMERCLO 0x20003004
#define GPFSEL1 0x20200004
#define GPSET0 0x2020001C
#define GPCLR0 0x20200028
#define SYSTIMERCLO (PBASE+0x00003004)
#define GPFSEL1 (PBASE+0x00200004)
#define GPSET0 (PBASE+0x0020001C)
#define GPCLR0 (PBASE+0x00200028)
#define TIMEOUT 1000000

Binary file not shown.

80
bootloader07/blinker7.c Normal file
View File

@@ -0,0 +1,80 @@
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
#include "BCM2836.h" /* Raspberriy Pi 2 */
extern void PUT32 ( unsigned int, unsigned int );
extern unsigned int GET32 ( unsigned int );
extern void dummy ( unsigned int );
#define ARM_TIMER_LOD (PBASE+0x0000B400)
#define ARM_TIMER_VAL (PBASE+0x0000B404)
#define ARM_TIMER_CTL (PBASE+0x0000B408)
#define ARM_TIMER_DIV (PBASE+0x0000B41C)
#define ARM_TIMER_CNT (PBASE+0x0000B420)
#define SYSTIMERCLO (PBASE+0x00003004)
#define GPFSEL3 (PBASE+0x0020000C)
#define GPFSEL4 (PBASE+0x00200010)
#define GPSET1 (PBASE+0x00200020)
#define GPCLR1 (PBASE+0x0020002C)
#define TIMEOUT 1000000
//-------------------------------------------------------------------------
int notmain ( void )
{
unsigned int ra;
unsigned int rb;
ra=GET32(GPFSEL4);
ra&=~(7<<21);
ra|=1<<21;
PUT32(GPFSEL4,ra);
ra=GET32(GPFSEL3);
ra&=~(7<<15);
ra|=1<<15;
PUT32(GPFSEL3,ra);
PUT32(ARM_TIMER_CTL,0x00F90000);
PUT32(ARM_TIMER_CTL,0x00F90200);
rb=GET32(ARM_TIMER_CNT);
while(1)
{
PUT32(GPSET1,1<<(47-32));
PUT32(GPCLR1,1<<(35-32));
while(1)
{
ra=GET32(ARM_TIMER_CNT);
if((ra-rb)>=TIMEOUT) break;
}
rb+=TIMEOUT;
PUT32(GPCLR1,1<<(47-32));
PUT32(GPSET1,1<<(35-32));
while(1)
{
ra=GET32(ARM_TIMER_CNT);
if((ra-rb)>=TIMEOUT) break;
}
rb+=TIMEOUT;
}
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.
//
//-------------------------------------------------------------------------

BIN
bootloader07/blinker7.elf Executable file

Binary file not shown.

19
bootloader07/blinker7.hex Normal file
View File

@@ -0,0 +1,19 @@
:1080000002D9A0E3050000EBFEFFFFEA001080E5C7
:108010001EFF2FE1000090E51EFF2FE11EFF2FE164
:1080200070402DE9BC009FE5F9FFFFEB0E16C0E3A1
:10803000021681E3AC009FE5F3FFFFEBA8009FE58C
:10804000F3FFFFEB0E19C0E3021981E398009FE5EF
:10805000EDFFFFEB94009FE5F918A0E3EAFFFFEBCB
:1080600088009FE588109FE5E7FFFFEB84009FE510
:10807000E7FFFFEB80409FE50050A0E17C009FE51B
:108080000219A0E3E0FFFFEB74009FE50810A0E3F6
:10809000DDFFFFEB5C009FE5DDFFFFEB000065E02F
:1080A000040050E1FAFFFF9A54009FE50219A0E393
:1080B000D5FFFFEB3D6985E240009FE50810A0E396
:1080C000096D86E2D0FFFFEB28009FE5D0FFFFEBB4
:1080D000000066E0040050E1FAFFFF9A7A5985E259
:1080E000125D85E2E4FFFFEA1000203F0C00203F14
:1080F00008B4003F0002F90020B4003F3F420F00E7
:088100002000203F2C00203F6D
:040000030000800079
:00000001FF

View File

@@ -59,6 +59,7 @@ int notmain ( void )
data=0;
record_type=0;
address=0;
byte_count=0;
while(1)
{
ra=uart_recv();

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,6 @@
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
#include <stdio.h>
#include <stdlib.h>
@@ -191,4 +193,16 @@ int main ( void )
//-------------------------------------------------------------------------
//
// 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.
//
//-------------------------------------------------------------------------

View File

@@ -2,34 +2,39 @@
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
#ifdef RPI2
#include "BCM2836.h" /* Raspberriy Pi 2 */
#else
#include "BCM2835.h" /* Original B,A,A+,B+ */
#endif
extern void PUT32 ( unsigned int, unsigned int );
extern void PUT16 ( unsigned int, unsigned int );
extern void PUT8 ( unsigned int, unsigned int );
extern unsigned int GET32 ( unsigned int );
extern void BRANCHTO ( unsigned int );
extern void dummy ( unsigned int );
#define ARM_TIMER_CTL 0x2000B408
#define ARM_TIMER_CNT 0x2000B420
#define ARM_TIMER_CTL (PBASE+0x0000B408)
#define ARM_TIMER_CNT (PBASE+0x0000B420)
#define GPFSEL1 0x20200004
#define GPSET0 0x2020001C
#define GPCLR0 0x20200028
#define GPPUD 0x20200094
#define GPPUDCLK0 0x20200098
#define GPFSEL1 (PBASE+0x00200004)
#define GPSET0 (PBASE+0x0020001C)
#define GPCLR0 (PBASE+0x00200028)
#define GPPUD (PBASE+0x00200094)
#define GPPUDCLK0 (PBASE+0x00200098)
#define AUX_ENABLES 0x20215004
#define AUX_MU_IO_REG 0x20215040
#define AUX_MU_IER_REG 0x20215044
#define AUX_MU_IIR_REG 0x20215048
#define AUX_MU_LCR_REG 0x2021504C
#define AUX_MU_MCR_REG 0x20215050
#define AUX_MU_LSR_REG 0x20215054
#define AUX_MU_MSR_REG 0x20215058
#define AUX_MU_SCRATCH 0x2021505C
#define AUX_MU_CNTL_REG 0x20215060
#define AUX_MU_STAT_REG 0x20215064
#define AUX_MU_BAUD_REG 0x20215068
#define AUX_ENABLES (PBASE+0x00215004)
#define AUX_MU_IO_REG (PBASE+0x00215040)
#define AUX_MU_IER_REG (PBASE+0x00215044)
#define AUX_MU_IIR_REG (PBASE+0x00215048)
#define AUX_MU_LCR_REG (PBASE+0x0021504C)
#define AUX_MU_MCR_REG (PBASE+0x00215050)
#define AUX_MU_LSR_REG (PBASE+0x00215054)
#define AUX_MU_MSR_REG (PBASE+0x00215058)
#define AUX_MU_SCRATCH (PBASE+0x0021505C)
#define AUX_MU_CNTL_REG (PBASE+0x00215060)
#define AUX_MU_STAT_REG (PBASE+0x00215064)
#define AUX_MU_BAUD_REG (PBASE+0x00215068)
//GPIO14 TXD0 and TXD1
//GPIO15 RXD0 and RXD1

14
uart03/BCM2835.h Normal file
View File

@@ -0,0 +1,14 @@
#define PBASE 0x20000000
//-------------------------------------------------------------------------
//
// 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.
//
//-------------------------------------------------------------------------

14
uart03/BCM2836.h Normal file
View File

@@ -0,0 +1,14 @@
#define PBASE 0x3F000000
//-------------------------------------------------------------------------
//
// 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.
//
//-------------------------------------------------------------------------

View File

@@ -11,5 +11,9 @@ subset. Thumb2 has confused/blurred those definitions though.
(thumb2 is a mostly 32 bit extension to the thumb instruction set using
formerly undefined instructions to create variable word length instructions).
From the top level readme we see that the RPi2 uses a different base
address for the peripherals. Uncomment the correct line at the
top of the uart03.c file depending on the Raspberry Pi you are using.
See the top level README for information on how to connect the raspi
uart to your host computer.

View File

@@ -2,28 +2,32 @@
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
//Uncomment one of these
//#include "BCM2835.h" /* Original B,A,A+,B+ */
#include "BCM2836.h" /* Raspberriy Pi 2 */
extern void PUT32 ( unsigned int, unsigned int );
extern unsigned int GET32 ( unsigned int );
extern void dummy ( unsigned int );
#define GPFSEL1 0x20200004
#define GPSET0 0x2020001C
#define GPCLR0 0x20200028
#define GPPUD 0x20200094
#define GPPUDCLK0 0x20200098
#define GPFSEL1 (PBASE+0x00200004)
#define GPSET0 (PBASE+0x0020001C)
#define GPCLR0 (PBASE+0x00200028)
#define GPPUD (PBASE+0x00200094)
#define GPPUDCLK0 (PBASE+0x00200098)
#define AUX_ENABLES 0x20215004
#define AUX_MU_IO_REG 0x20215040
#define AUX_MU_IER_REG 0x20215044
#define AUX_MU_IIR_REG 0x20215048
#define AUX_MU_LCR_REG 0x2021504C
#define AUX_MU_MCR_REG 0x20215050
#define AUX_MU_LSR_REG 0x20215054
#define AUX_MU_MSR_REG 0x20215058
#define AUX_MU_SCRATCH 0x2021505C
#define AUX_MU_CNTL_REG 0x20215060
#define AUX_MU_STAT_REG 0x20215064
#define AUX_MU_BAUD_REG 0x20215068
#define AUX_ENABLES (PBASE+0x00215004)
#define AUX_MU_IO_REG (PBASE+0x00215040)
#define AUX_MU_IER_REG (PBASE+0x00215044)
#define AUX_MU_IIR_REG (PBASE+0x00215048)
#define AUX_MU_LCR_REG (PBASE+0x0021504C)
#define AUX_MU_MCR_REG (PBASE+0x00215050)
#define AUX_MU_LSR_REG (PBASE+0x00215054)
#define AUX_MU_MSR_REG (PBASE+0x00215058)
#define AUX_MU_SCRATCH (PBASE+0x0021505C)
#define AUX_MU_CNTL_REG (PBASE+0x00215060)
#define AUX_MU_STAT_REG (PBASE+0x00215064)
#define AUX_MU_BAUD_REG (PBASE+0x00215068)
//GPIO14 TXD0 and TXD1
//GPIO15 RXD0 and RXD1