adding bootloader06, made it more lean and mean than bootloader05
This commit is contained in:
83
bootloader06/Makefile
Normal file
83
bootloader06/Makefile
Normal file
@@ -0,0 +1,83 @@
|
||||
|
||||
ARMGNU ?= arm-none-eabi
|
||||
|
||||
COPS = -Wall -O2 -nostdlib -nostartfiles -ffreestanding
|
||||
|
||||
gcc : kernel.img blinker.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.s
|
||||
|
||||
|
||||
vectors.o : vectors.s
|
||||
$(ARMGNU)-as vectors.s -o vectors.o
|
||||
|
||||
bootloader06.o : bootloader06.c
|
||||
$(ARMGNU)-gcc $(COPS) -c bootloader06.c -o bootloader06.o
|
||||
|
||||
periph.o : periph.c
|
||||
$(ARMGNU)-gcc $(COPS) -c periph.c -o periph.o
|
||||
|
||||
kernel.img : loader vectors.o periph.o bootloader06.o
|
||||
$(ARMGNU)-ld vectors.o periph.o bootloader06.o -T loader -o bootloader06.elf
|
||||
$(ARMGNU)-objdump -D bootloader06.elf > bootloader06.list
|
||||
$(ARMGNU)-objcopy bootloader06.elf -O ihex bootloader06.hex
|
||||
$(ARMGNU)-objcopy bootloader06.elf -O binary kernel.img
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
start.o : start.s
|
||||
$(ARMGNU)-as start.s -o start.o
|
||||
|
||||
blinker.o : blinker.c
|
||||
$(ARMGNU)-gcc $(COPS) -c blinker.c -o blinker.o
|
||||
|
||||
blinker.bin : 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
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
LOPS = -Wall -m32 -emit-llvm
|
||||
LLCOPS0 = -march=arm
|
||||
LLCOPS1 = -march=arm -mcpu=arm1176jzf-s
|
||||
LLCOPS = $(LLCOPS1)
|
||||
COPS = -Wall -O2 -nostdlib -nostartfiles -ffreestanding
|
||||
OOPS = -std-compile-opts
|
||||
|
||||
clang : bootloader06.bin
|
||||
|
||||
bootloader06.bc : bootloader06.c
|
||||
clang $(LOPS) -c bootloader06.c -o bootloader06.bc
|
||||
|
||||
periph.bc : periph.c
|
||||
clang $(LOPS) -c periph.c -o periph.bc
|
||||
|
||||
bootloader06.clang.elf : loader vectors.o bootloader06.bc periph.bc
|
||||
llvm-link periph.bc bootloader06.bc -o bootloader06.nopt.bc
|
||||
opt $(OOPS) bootloader06.nopt.bc -o bootloader06.opt.bc
|
||||
llc $(LLCOPS) bootloader06.opt.bc -o bootloader06.clang.s
|
||||
$(ARMGNU)-as bootloader06.clang.s -o bootloader06.clang.o
|
||||
$(ARMGNU)-ld -o bootloader06.clang.elf -T loader vectors.o bootloader06.clang.o
|
||||
$(ARMGNU)-objdump -D bootloader06.clang.elf > bootloader06.clang.list
|
||||
|
||||
bootloader06.bin : bootloader06.clang.elf
|
||||
$(ARMGNU)-objcopy bootloader06.clang.elf bootloader06.clang.bin -O binary
|
||||
|
||||
|
||||
47
bootloader06/README
Normal file
47
bootloader06/README
Normal file
@@ -0,0 +1,47 @@
|
||||
|
||||
See the top level README file for more information on documentation
|
||||
and how to run these programs.
|
||||
|
||||
Derived from bootloader05, this is a very simple bootloader. Instead
|
||||
of the sd dance (see toplevel README), this makes life a bit simpler
|
||||
and greatly reduces physical wear and tear on the sd card socket. Do
|
||||
the sd card dance one more time with kernel.img. Get some sort of
|
||||
serial solution to connect a dumb termial program with xmodem
|
||||
capabilities to the uart on the raspberry pi. (see the toplevel
|
||||
README for more information).
|
||||
|
||||
The difference between bootloader05 and bootloader06 is that I made
|
||||
it more lean and mean either it works perfect or it bails out, I dont
|
||||
know or think the NAK stuff was working anyway. The whole xmodem
|
||||
receiver is in a loop so you should be able to try again without
|
||||
power cycling the board.
|
||||
|
||||
I use minicom and it uses lrzsz to do the xmodem transfer and there
|
||||
is a delay after the transfer before minicom gets control again so
|
||||
I added a delay at the end before branching to the application so
|
||||
that no uart output is lost, in theory...Your favorite tools may give
|
||||
you a different experience.
|
||||
|
||||
You take the .bin file of your test program, assumed to be built based
|
||||
on address 0x8000 and less than 0x200000-0x8000 bytes in size.
|
||||
|
||||
With uart connected to a terminal
|
||||
1) power off raspberry pi
|
||||
2) power on raspberry pi
|
||||
3) use xmodem to transfer binary file
|
||||
Repeat for each new program to test
|
||||
|
||||
This bootloader sits at 0x200000 so that you have 0x200000 bytes to
|
||||
develop with. And that way if you like your program you can just
|
||||
copy a .bin version to kernel.img on the sd card and use it. It
|
||||
is easy to change this starting address, see the source for more.
|
||||
|
||||
bootloader01 uses .hex files, bootloader02 through bootloader06 use .bin
|
||||
files, .hex files wont work. Consider bootloader01 and 02 to be
|
||||
obsolete.
|
||||
|
||||
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).
|
||||
|
||||
BIN
bootloader06/blinker.bin
Executable file
BIN
bootloader06/blinker.bin
Executable file
Binary file not shown.
70
bootloader06/blinker.c
Normal file
70
bootloader06/blinker.c
Normal file
@@ -0,0 +1,70 @@
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
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 SYSTIMERCLO 0x20003004
|
||||
#define GPFSEL1 0x20200004
|
||||
#define GPSET0 0x2020001C
|
||||
#define GPCLR0 0x20200028
|
||||
|
||||
#define TIMEOUT 1000000
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
int notmain ( void )
|
||||
{
|
||||
unsigned int ra;
|
||||
unsigned int rb;
|
||||
|
||||
ra=GET32(GPFSEL1);
|
||||
ra&=~(7<<18);
|
||||
ra|=1<<18;
|
||||
PUT32(GPFSEL1,ra);
|
||||
|
||||
PUT32(ARM_TIMER_CTL,0x00F90000);
|
||||
PUT32(ARM_TIMER_CTL,0x00F90200);
|
||||
|
||||
rb=GET32(ARM_TIMER_CNT);
|
||||
while(1)
|
||||
{
|
||||
PUT32(GPSET0,1<<16);
|
||||
while(1)
|
||||
{
|
||||
ra=GET32(ARM_TIMER_CNT);
|
||||
if((ra-rb)>=TIMEOUT) break;
|
||||
}
|
||||
rb+=TIMEOUT;
|
||||
PUT32(GPCLR0,1<<16);
|
||||
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
bootloader06/blinker.elf
Executable file
BIN
bootloader06/blinker.elf
Executable file
Binary file not shown.
16
bootloader06/blinker.hex
Normal file
16
bootloader06/blinker.hex
Normal file
@@ -0,0 +1,16 @@
|
||||
:1080000002D9A0E3050000EBFEFFFFEA001080E5C7
|
||||
:108010001EFF2FE1000090E51EFF2FE11EFF2FE164
|
||||
:1080200070402DE98C009FE5F9FFFFEB0717C0E3D7
|
||||
:10803000011781E37C009FE5F3FFFFEB78009FE5EC
|
||||
:10804000F918A0E3F0FFFFEB6C009FE56C109FE5D3
|
||||
:10805000EDFFFFEB68009FE5EDFFFFEB64409FE560
|
||||
:108060000050A0E160009FE50118A0E3E6FFFFEBF0
|
||||
:108070004C009FE5E6FFFFEB000065E0040050E1E7
|
||||
:10808000FAFFFF9A3D6985E240009FE50118A0E3F1
|
||||
:10809000096D86E2DCFFFFEB24009FE5DCFFFFEBD0
|
||||
:1080A000000066E0040050E1FAFFFF9A7A5985E289
|
||||
:1080B000125D85E2EAFFFFEA0400202008B40020F8
|
||||
:1080C0000002F90020B400203F420F001C002020D5
|
||||
:0480D0002800202044
|
||||
:040000030000800079
|
||||
:00000001FF
|
||||
95
bootloader06/blinker.list
Normal file
95
bootloader06/blinker.list
Normal file
@@ -0,0 +1,95 @@
|
||||
|
||||
blinker.elf: file format elf32-littlearm
|
||||
|
||||
|
||||
Disassembly of section .text:
|
||||
|
||||
00008000 <_start>:
|
||||
8000: e3a0d902 mov sp, #32768 ; 0x8000
|
||||
8004: eb000005 bl 8020 <notmain>
|
||||
|
||||
00008008 <hang>:
|
||||
8008: eafffffe b 8008 <hang>
|
||||
|
||||
0000800c <PUT32>:
|
||||
800c: e5801000 str r1, [r0]
|
||||
8010: e12fff1e bx lr
|
||||
|
||||
00008014 <GET32>:
|
||||
8014: e5900000 ldr r0, [r0]
|
||||
8018: e12fff1e bx lr
|
||||
|
||||
0000801c <dummy>:
|
||||
801c: e12fff1e bx lr
|
||||
|
||||
00008020 <notmain>:
|
||||
8020: e92d4070 push {r4, r5, r6, lr}
|
||||
8024: e59f008c ldr r0, [pc, #140] ; 80b8 <notmain+0x98>
|
||||
8028: ebfffff9 bl 8014 <GET32>
|
||||
802c: e3c01707 bic r1, r0, #1835008 ; 0x1c0000
|
||||
8030: e3811701 orr r1, r1, #262144 ; 0x40000
|
||||
8034: e59f007c ldr r0, [pc, #124] ; 80b8 <notmain+0x98>
|
||||
8038: ebfffff3 bl 800c <PUT32>
|
||||
803c: e59f0078 ldr r0, [pc, #120] ; 80bc <notmain+0x9c>
|
||||
8040: e3a018f9 mov r1, #16318464 ; 0xf90000
|
||||
8044: ebfffff0 bl 800c <PUT32>
|
||||
8048: e59f006c ldr r0, [pc, #108] ; 80bc <notmain+0x9c>
|
||||
804c: e59f106c ldr r1, [pc, #108] ; 80c0 <notmain+0xa0>
|
||||
8050: ebffffed bl 800c <PUT32>
|
||||
8054: e59f0068 ldr r0, [pc, #104] ; 80c4 <notmain+0xa4>
|
||||
8058: ebffffed bl 8014 <GET32>
|
||||
805c: e59f4064 ldr r4, [pc, #100] ; 80c8 <notmain+0xa8>
|
||||
8060: e1a05000 mov r5, r0
|
||||
8064: e59f0060 ldr r0, [pc, #96] ; 80cc <notmain+0xac>
|
||||
8068: e3a01801 mov r1, #65536 ; 0x10000
|
||||
806c: ebffffe6 bl 800c <PUT32>
|
||||
8070: e59f004c ldr r0, [pc, #76] ; 80c4 <notmain+0xa4>
|
||||
8074: ebffffe6 bl 8014 <GET32>
|
||||
8078: e0650000 rsb r0, r5, r0
|
||||
807c: e1500004 cmp r0, r4
|
||||
8080: 9afffffa bls 8070 <notmain+0x50>
|
||||
8084: e285693d add r6, r5, #999424 ; 0xf4000
|
||||
8088: e59f0040 ldr r0, [pc, #64] ; 80d0 <notmain+0xb0>
|
||||
808c: e3a01801 mov r1, #65536 ; 0x10000
|
||||
8090: e2866d09 add r6, r6, #576 ; 0x240
|
||||
8094: ebffffdc bl 800c <PUT32>
|
||||
8098: e59f0024 ldr r0, [pc, #36] ; 80c4 <notmain+0xa4>
|
||||
809c: ebffffdc bl 8014 <GET32>
|
||||
80a0: e0660000 rsb r0, r6, r0
|
||||
80a4: e1500004 cmp r0, r4
|
||||
80a8: 9afffffa bls 8098 <notmain+0x78>
|
||||
80ac: e285597a add r5, r5, #1998848 ; 0x1e8000
|
||||
80b0: e2855d12 add r5, r5, #1152 ; 0x480
|
||||
80b4: eaffffea b 8064 <notmain+0x44>
|
||||
80b8: 20200004 eorcs r0, r0, r4
|
||||
80bc: 2000b408 andcs fp, r0, r8, lsl #8
|
||||
80c0: 00f90200 rscseq r0, r9, r0, lsl #4
|
||||
80c4: 2000b420 andcs fp, r0, r0, lsr #8
|
||||
80c8: 000f423f andeq r4, pc, pc, lsr r2 ; <UNPREDICTABLE>
|
||||
80cc: 2020001c eorcs r0, r0, ip, lsl r0
|
||||
80d0: 20200028 eorcs r0, r0, r8, lsr #32
|
||||
|
||||
Disassembly of section .ARM.attributes:
|
||||
|
||||
00000000 <.ARM.attributes>:
|
||||
0: 00002a41 andeq r2, r0, r1, asr #20
|
||||
4: 61656100 cmnvs r5, r0, lsl #2
|
||||
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
|
||||
18: 08020600 stmdaeq r2, {r9, sl}
|
||||
1c: 12010901 andne r0, r1, #16384 ; 0x4000
|
||||
20: 15011404 strne r1, [r1, #-1028] ; 0x404
|
||||
24: 18031701 stmdane r3, {r0, r8, r9, sl, ip}
|
||||
28: Address 0x0000000000000028 is out of bounds.
|
||||
|
||||
|
||||
Disassembly of section .comment:
|
||||
|
||||
00000000 <.comment>:
|
||||
0: 3a434347 bcc 10d0d24 <notmain+0x10c8d04>
|
||||
4: 4e472820 cdpmi 8, 4, cr2, cr7, cr0, {1}
|
||||
8: 34202955 strtcc r2, [r0], #-2389 ; 0x955
|
||||
c: 322e382e eorcc r3, lr, #3014656 ; 0x2e0000
|
||||
...
|
||||
241
bootloader06/bootloader06.c
Normal file
241
bootloader06/bootloader06.c
Normal file
@@ -0,0 +1,241 @@
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
// 2 outer corner
|
||||
// 4
|
||||
// 6
|
||||
// 8 TX out
|
||||
// 10 RX in
|
||||
|
||||
// The raspberry pi firmware at the time this was written defaults
|
||||
// loading at address 0x8000. Although this bootloader could easily
|
||||
// load at 0x0000, it loads at 0x8000 so that the same binaries built
|
||||
// for the SD card work with this bootloader. Change the ARMBASE
|
||||
// below to use a different location.
|
||||
|
||||
#define ARMBASE 0x8000
|
||||
|
||||
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 unsigned int GETPC ( void );
|
||||
extern void BRANCHTO ( unsigned int );
|
||||
extern void dummy ( unsigned int );
|
||||
|
||||
extern void uart_init ( void );
|
||||
extern unsigned int uart_lcr ( void );
|
||||
extern void uart_flush ( void );
|
||||
extern void uart_send ( unsigned int );
|
||||
extern unsigned int uart_recv ( void );
|
||||
extern unsigned int uart_check ( void );
|
||||
extern void hexstring ( unsigned int );
|
||||
extern void hexstrings ( unsigned int );
|
||||
extern void timer_init ( void );
|
||||
extern unsigned int timer_tick ( void );
|
||||
|
||||
extern void timer_init ( void );
|
||||
extern unsigned int timer_tick ( void );
|
||||
|
||||
#define SOH 0x01
|
||||
#define ACK 0x06
|
||||
#define NAK 0x15
|
||||
#define EOT 0x04
|
||||
#define CAN 0x18
|
||||
|
||||
//timer set at 1 million ticks per second
|
||||
#define NAKSOH_TIMEOUT 4000000
|
||||
#define WAIT_AFTER_EOT_TIMEOUT 2000000
|
||||
#define WAIT_AFTER_CAN_TIMEOUT 2000000
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
int notmain ( void )
|
||||
{
|
||||
unsigned int ra;
|
||||
unsigned int rb;
|
||||
unsigned int rx;
|
||||
unsigned int block;
|
||||
unsigned int state;
|
||||
unsigned int csum;
|
||||
unsigned char *xstring;
|
||||
|
||||
uart_init();
|
||||
hexstring(0x12345678);
|
||||
hexstring(GETPC());
|
||||
hexstring(ARMBASE);
|
||||
timer_init();
|
||||
|
||||
// block numbers start with 1
|
||||
|
||||
// 132 byte packet
|
||||
// starts with SOH
|
||||
// block number byte
|
||||
// 255-block number
|
||||
// 128 bytes of data
|
||||
// checksum byte (whole packet)
|
||||
// a single EOT instead of SOH when done, send an ACK on it too
|
||||
|
||||
while(1)
|
||||
{
|
||||
block=1;
|
||||
state=192;
|
||||
csum=0;
|
||||
xstring=(unsigned char *)ARMBASE;
|
||||
|
||||
//only going to do the nak wait for soh dance once.
|
||||
//not going to deal with timeouts other than here
|
||||
uart_send(NAK);
|
||||
rx=timer_tick();
|
||||
while(1)
|
||||
{
|
||||
ra=timer_tick();
|
||||
if((ra-rx)>=NAKSOH_TIMEOUT)
|
||||
{
|
||||
uart_send(NAK);
|
||||
rx+=NAKSOH_TIMEOUT;
|
||||
}
|
||||
if(uart_check()) break;
|
||||
}
|
||||
while(state!=255)
|
||||
{
|
||||
rb=uart_recv();
|
||||
switch(state)
|
||||
{
|
||||
//wait for SOH or EOT
|
||||
case 192:
|
||||
{
|
||||
switch(rb)
|
||||
{
|
||||
case SOH:
|
||||
{
|
||||
csum=rb;
|
||||
state++;
|
||||
break;
|
||||
}
|
||||
case EOT:
|
||||
{
|
||||
uart_send(ACK);
|
||||
rx=timer_tick();
|
||||
while(1)
|
||||
{
|
||||
ra=timer_tick();
|
||||
if((ra-rx)>=WAIT_AFTER_EOT_TIMEOUT) break;
|
||||
}
|
||||
uart_send(0x0D);
|
||||
uart_send(0x0A);
|
||||
uart_send(0x0A);
|
||||
hexstring(0xDADADADA);
|
||||
uart_flush();
|
||||
BRANCHTO(ARMBASE);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
state=255;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
//uninverted block number
|
||||
case 193:
|
||||
{
|
||||
if(rb==block)
|
||||
{
|
||||
csum+=rb;
|
||||
state++;
|
||||
}
|
||||
else
|
||||
{
|
||||
state=255;
|
||||
}
|
||||
break;
|
||||
}
|
||||
//inverted block number
|
||||
case 194:
|
||||
{
|
||||
if(rb==(0xFF-block))
|
||||
{
|
||||
csum+=rb;
|
||||
state=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
state=255;
|
||||
}
|
||||
break;
|
||||
}
|
||||
//checksum
|
||||
case 128:
|
||||
{
|
||||
csum&=0xFF;
|
||||
if(rb==csum)
|
||||
{
|
||||
uart_send(ACK);
|
||||
block=(block+1)&0xFF;
|
||||
xstring+=128;
|
||||
state=192;
|
||||
}
|
||||
else
|
||||
{
|
||||
state=255;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
csum+=rb;
|
||||
xstring[state]=rb&0xFF;
|
||||
state++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
//just bail out.
|
||||
uart_send(CAN);
|
||||
uart_send(CAN);
|
||||
uart_send(CAN);
|
||||
uart_send(CAN);
|
||||
uart_send(CAN);
|
||||
rx=timer_tick();
|
||||
while(1)
|
||||
{
|
||||
ra=timer_tick();
|
||||
if((ra-rx)>=WAIT_AFTER_CAN_TIMEOUT) break;
|
||||
}
|
||||
uart_send(0x0D);
|
||||
uart_send(0x0A);
|
||||
uart_send(0x0A);
|
||||
hexstring(0xBADBAD);
|
||||
uart_flush();
|
||||
//try to flush some out so we hit this timeout fewer times
|
||||
while(1)
|
||||
{
|
||||
if(uart_check())
|
||||
{
|
||||
uart_recv();
|
||||
}
|
||||
else
|
||||
{
|
||||
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.
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
BIN
bootloader06/bootloader06.elf
Executable file
BIN
bootloader06/bootloader06.elf
Executable file
Binary file not shown.
129136
bootloader06/bootloader06.hex
Normal file
129136
bootloader06/bootloader06.hex
Normal file
File diff suppressed because it is too large
Load Diff
382
bootloader06/bootloader06.list
Normal file
382
bootloader06/bootloader06.list
Normal file
@@ -0,0 +1,382 @@
|
||||
|
||||
bootloader06.elf: file format elf32-littlearm
|
||||
|
||||
|
||||
Disassembly of section .text:
|
||||
|
||||
00008000 <_start>:
|
||||
8000: ea07dffe b 200000 <skip>
|
||||
...
|
||||
|
||||
00200000 <skip>:
|
||||
200000: e3a0d302 mov sp, #134217728 ; 0x8000000
|
||||
200004: eb0000a6 bl 2002a4 <notmain>
|
||||
|
||||
00200008 <hang>:
|
||||
200008: eafffffe b 200008 <hang>
|
||||
|
||||
0020000c <PUT32>:
|
||||
20000c: e5801000 str r1, [r0]
|
||||
200010: e12fff1e bx lr
|
||||
|
||||
00200014 <PUT16>:
|
||||
200014: e1c010b0 strh r1, [r0]
|
||||
200018: e12fff1e bx lr
|
||||
|
||||
0020001c <PUT8>:
|
||||
20001c: e5c01000 strb r1, [r0]
|
||||
200020: e12fff1e bx lr
|
||||
|
||||
00200024 <GET32>:
|
||||
200024: e5900000 ldr r0, [r0]
|
||||
200028: e12fff1e bx lr
|
||||
|
||||
0020002c <GETPC>:
|
||||
20002c: e1a0000e mov r0, lr
|
||||
200030: e12fff1e bx lr
|
||||
|
||||
00200034 <BRANCHTO>:
|
||||
200034: e12fff10 bx r0
|
||||
|
||||
00200038 <dummy>:
|
||||
200038: e12fff1e bx lr
|
||||
|
||||
0020003c <uart_lcr>:
|
||||
20003c: e92d4008 push {r3, lr}
|
||||
200040: e59f0008 ldr r0, [pc, #8] ; 200050 <uart_lcr+0x14>
|
||||
200044: ebfffff6 bl 200024 <GET32>
|
||||
200048: e8bd4008 pop {r3, lr}
|
||||
20004c: e12fff1e bx lr
|
||||
200050: 20215054 eorcs r5, r1, r4, asr r0
|
||||
|
||||
00200054 <uart_recv>:
|
||||
200054: e92d4008 push {r3, lr}
|
||||
200058: e59f001c ldr r0, [pc, #28] ; 20007c <uart_recv+0x28>
|
||||
20005c: ebfffff0 bl 200024 <GET32>
|
||||
200060: e3100001 tst r0, #1
|
||||
200064: 0afffffb beq 200058 <uart_recv+0x4>
|
||||
200068: e59f0010 ldr r0, [pc, #16] ; 200080 <uart_recv+0x2c>
|
||||
20006c: ebffffec bl 200024 <GET32>
|
||||
200070: e8bd4008 pop {r3, lr}
|
||||
200074: e20000ff and r0, r0, #255 ; 0xff
|
||||
200078: e12fff1e bx lr
|
||||
20007c: 20215054 eorcs r5, r1, r4, asr r0
|
||||
200080: 20215040 eorcs r5, r1, r0, asr #32
|
||||
|
||||
00200084 <uart_check>:
|
||||
200084: e92d4008 push {r3, lr}
|
||||
200088: e59f000c ldr r0, [pc, #12] ; 20009c <uart_check+0x18>
|
||||
20008c: ebffffe4 bl 200024 <GET32>
|
||||
200090: e8bd4008 pop {r3, lr}
|
||||
200094: e2000001 and r0, r0, #1
|
||||
200098: e12fff1e bx lr
|
||||
20009c: 20215054 eorcs r5, r1, r4, asr r0
|
||||
|
||||
002000a0 <uart_send>:
|
||||
2000a0: e92d4010 push {r4, lr}
|
||||
2000a4: e1a04000 mov r4, r0
|
||||
2000a8: e59f001c ldr r0, [pc, #28] ; 2000cc <uart_send+0x2c>
|
||||
2000ac: ebffffdc bl 200024 <GET32>
|
||||
2000b0: e3100020 tst r0, #32
|
||||
2000b4: 0afffffb beq 2000a8 <uart_send+0x8>
|
||||
2000b8: e1a01004 mov r1, r4
|
||||
2000bc: e59f000c ldr r0, [pc, #12] ; 2000d0 <uart_send+0x30>
|
||||
2000c0: ebffffd1 bl 20000c <PUT32>
|
||||
2000c4: e8bd4010 pop {r4, lr}
|
||||
2000c8: e12fff1e bx lr
|
||||
2000cc: 20215054 eorcs r5, r1, r4, asr r0
|
||||
2000d0: 20215040 eorcs r5, r1, r0, asr #32
|
||||
|
||||
002000d4 <uart_flush>:
|
||||
2000d4: e92d4008 push {r3, lr}
|
||||
2000d8: e59f0010 ldr r0, [pc, #16] ; 2000f0 <uart_flush+0x1c>
|
||||
2000dc: ebffffd0 bl 200024 <GET32>
|
||||
2000e0: e3100c01 tst r0, #256 ; 0x100
|
||||
2000e4: 1afffffb bne 2000d8 <uart_flush+0x4>
|
||||
2000e8: e8bd4008 pop {r3, lr}
|
||||
2000ec: e12fff1e bx lr
|
||||
2000f0: 20215054 eorcs r5, r1, r4, asr r0
|
||||
|
||||
002000f4 <hexstrings>:
|
||||
2000f4: e92d4038 push {r3, r4, r5, lr}
|
||||
2000f8: e1a05000 mov r5, r0
|
||||
2000fc: e3a04020 mov r4, #32
|
||||
200100: e2444004 sub r4, r4, #4
|
||||
200104: e1a03435 lsr r3, r5, r4
|
||||
200108: e203300f and r3, r3, #15
|
||||
20010c: e3530009 cmp r3, #9
|
||||
200110: 82830037 addhi r0, r3, #55 ; 0x37
|
||||
200114: 92830030 addls r0, r3, #48 ; 0x30
|
||||
200118: ebffffe0 bl 2000a0 <uart_send>
|
||||
20011c: e3540000 cmp r4, #0
|
||||
200120: 1afffff6 bne 200100 <hexstrings+0xc>
|
||||
200124: e3a00020 mov r0, #32
|
||||
200128: e8bd4038 pop {r3, r4, r5, lr}
|
||||
20012c: eaffffdb b 2000a0 <uart_send>
|
||||
|
||||
00200130 <hexstring>:
|
||||
200130: e92d4008 push {r3, lr}
|
||||
200134: ebffffee bl 2000f4 <hexstrings>
|
||||
200138: e3a0000d mov r0, #13
|
||||
20013c: ebffffd7 bl 2000a0 <uart_send>
|
||||
200140: e3a0000a mov r0, #10
|
||||
200144: e8bd4008 pop {r3, lr}
|
||||
200148: eaffffd4 b 2000a0 <uart_send>
|
||||
|
||||
0020014c <uart_init>:
|
||||
20014c: e92d4010 push {r4, lr}
|
||||
200150: e59f00d8 ldr r0, [pc, #216] ; 200230 <uart_init+0xe4>
|
||||
200154: e3a01001 mov r1, #1
|
||||
200158: ebffffab bl 20000c <PUT32>
|
||||
20015c: e59f00d0 ldr r0, [pc, #208] ; 200234 <uart_init+0xe8>
|
||||
200160: e3a01000 mov r1, #0
|
||||
200164: ebffffa8 bl 20000c <PUT32>
|
||||
200168: e59f00c8 ldr r0, [pc, #200] ; 200238 <uart_init+0xec>
|
||||
20016c: e3a01000 mov r1, #0
|
||||
200170: ebffffa5 bl 20000c <PUT32>
|
||||
200174: e59f00c0 ldr r0, [pc, #192] ; 20023c <uart_init+0xf0>
|
||||
200178: e3a01003 mov r1, #3
|
||||
20017c: ebffffa2 bl 20000c <PUT32>
|
||||
200180: e59f00b8 ldr r0, [pc, #184] ; 200240 <uart_init+0xf4>
|
||||
200184: e3a01000 mov r1, #0
|
||||
200188: ebffff9f bl 20000c <PUT32>
|
||||
20018c: e59f00a0 ldr r0, [pc, #160] ; 200234 <uart_init+0xe8>
|
||||
200190: e3a01000 mov r1, #0
|
||||
200194: ebffff9c bl 20000c <PUT32>
|
||||
200198: e59f00a4 ldr r0, [pc, #164] ; 200244 <uart_init+0xf8>
|
||||
20019c: e3a010c6 mov r1, #198 ; 0xc6
|
||||
2001a0: ebffff99 bl 20000c <PUT32>
|
||||
2001a4: e59f109c ldr r1, [pc, #156] ; 200248 <uart_init+0xfc>
|
||||
2001a8: e59f009c ldr r0, [pc, #156] ; 20024c <uart_init+0x100>
|
||||
2001ac: ebffff96 bl 20000c <PUT32>
|
||||
2001b0: e59f0098 ldr r0, [pc, #152] ; 200250 <uart_init+0x104>
|
||||
2001b4: ebffff9a bl 200024 <GET32>
|
||||
2001b8: e3c01a3f bic r1, r0, #258048 ; 0x3f000
|
||||
2001bc: e3811a12 orr r1, r1, #73728 ; 0x12000
|
||||
2001c0: e59f0088 ldr r0, [pc, #136] ; 200250 <uart_init+0x104>
|
||||
2001c4: ebffff90 bl 20000c <PUT32>
|
||||
2001c8: e59f0084 ldr r0, [pc, #132] ; 200254 <uart_init+0x108>
|
||||
2001cc: e3a01000 mov r1, #0
|
||||
2001d0: ebffff8d bl 20000c <PUT32>
|
||||
2001d4: e3a04000 mov r4, #0
|
||||
2001d8: e1a00004 mov r0, r4
|
||||
2001dc: e2844001 add r4, r4, #1
|
||||
2001e0: ebffff94 bl 200038 <dummy>
|
||||
2001e4: e3540096 cmp r4, #150 ; 0x96
|
||||
2001e8: 1afffffa bne 2001d8 <uart_init+0x8c>
|
||||
2001ec: e59f0064 ldr r0, [pc, #100] ; 200258 <uart_init+0x10c>
|
||||
2001f0: e3a01903 mov r1, #49152 ; 0xc000
|
||||
2001f4: ebffff84 bl 20000c <PUT32>
|
||||
2001f8: e3a04000 mov r4, #0
|
||||
2001fc: e1a00004 mov r0, r4
|
||||
200200: e2844001 add r4, r4, #1
|
||||
200204: ebffff8b bl 200038 <dummy>
|
||||
200208: e3540096 cmp r4, #150 ; 0x96
|
||||
20020c: 1afffffa bne 2001fc <uart_init+0xb0>
|
||||
200210: e59f0040 ldr r0, [pc, #64] ; 200258 <uart_init+0x10c>
|
||||
200214: e3a01000 mov r1, #0
|
||||
200218: ebffff7b bl 20000c <PUT32>
|
||||
20021c: e59f0014 ldr r0, [pc, #20] ; 200238 <uart_init+0xec>
|
||||
200220: e3a01003 mov r1, #3
|
||||
200224: ebffff78 bl 20000c <PUT32>
|
||||
200228: e8bd4010 pop {r4, lr}
|
||||
20022c: e12fff1e bx lr
|
||||
200230: 20215004 eorcs r5, r1, r4
|
||||
200234: 20215044 eorcs r5, r1, r4, asr #32
|
||||
200238: 20215060 eorcs r5, r1, r0, rrx
|
||||
20023c: 2021504c eorcs r5, r1, ip, asr #32
|
||||
200240: 20215050 eorcs r5, r1, r0, asr r0
|
||||
200244: 20215048 eorcs r5, r1, r8, asr #32
|
||||
200248: 0000010e andeq r0, r0, lr, lsl #2
|
||||
20024c: 20215068 eorcs r5, r1, r8, rrx
|
||||
200250: 20200004 eorcs r0, r0, r4
|
||||
200254: 20200094 mlacs r0, r4, r0, r0
|
||||
200258: 20200098 mlacs r0, r8, r0, r0
|
||||
|
||||
0020025c <timer_init>:
|
||||
20025c: e92d4010 push {r4, lr}
|
||||
200260: e59f401c ldr r4, [pc, #28] ; 200284 <timer_init+0x28>
|
||||
200264: e3a018f9 mov r1, #16318464 ; 0xf90000
|
||||
200268: e1a00004 mov r0, r4
|
||||
20026c: ebffff66 bl 20000c <PUT32>
|
||||
200270: e1a00004 mov r0, r4
|
||||
200274: e59f100c ldr r1, [pc, #12] ; 200288 <timer_init+0x2c>
|
||||
200278: ebffff63 bl 20000c <PUT32>
|
||||
20027c: e8bd4010 pop {r4, lr}
|
||||
200280: e12fff1e bx lr
|
||||
200284: 2000b408 andcs fp, r0, r8, lsl #8
|
||||
200288: 00f90200 rscseq r0, r9, r0, lsl #4
|
||||
|
||||
0020028c <timer_tick>:
|
||||
20028c: e92d4008 push {r3, lr}
|
||||
200290: e59f0008 ldr r0, [pc, #8] ; 2002a0 <timer_tick+0x14>
|
||||
200294: ebffff62 bl 200024 <GET32>
|
||||
200298: e8bd4008 pop {r3, lr}
|
||||
20029c: e12fff1e bx lr
|
||||
2002a0: 2000b420 andcs fp, r0, r0, lsr #8
|
||||
|
||||
002002a4 <notmain>:
|
||||
2002a4: e92d47f0 push {r4, r5, r6, r7, r8, r9, sl, lr}
|
||||
2002a8: ebffffa7 bl 20014c <uart_init>
|
||||
2002ac: e59f0208 ldr r0, [pc, #520] ; 2004bc <notmain+0x218>
|
||||
2002b0: ebffff9e bl 200130 <hexstring>
|
||||
2002b4: ebffff5c bl 20002c <GETPC>
|
||||
2002b8: ebffff9c bl 200130 <hexstring>
|
||||
2002bc: e3a00902 mov r0, #32768 ; 0x8000
|
||||
2002c0: ebffff9a bl 200130 <hexstring>
|
||||
2002c4: ebffffe4 bl 20025c <timer_init>
|
||||
2002c8: e59f71f0 ldr r7, [pc, #496] ; 2004c0 <notmain+0x21c>
|
||||
2002cc: e59f61f0 ldr r6, [pc, #496] ; 2004c4 <notmain+0x220>
|
||||
2002d0: e3a00015 mov r0, #21
|
||||
2002d4: ebffff71 bl 2000a0 <uart_send>
|
||||
2002d8: ebffffeb bl 20028c <timer_tick>
|
||||
2002dc: e1a04000 mov r4, r0
|
||||
2002e0: ea000002 b 2002f0 <notmain+0x4c>
|
||||
2002e4: ebffff66 bl 200084 <uart_check>
|
||||
2002e8: e3500000 cmp r0, #0
|
||||
2002ec: 1a00000a bne 20031c <notmain+0x78>
|
||||
2002f0: ebffffe5 bl 20028c <timer_tick>
|
||||
2002f4: e0640000 rsb r0, r4, r0
|
||||
2002f8: e1500007 cmp r0, r7
|
||||
2002fc: 9afffff8 bls 2002e4 <notmain+0x40>
|
||||
200300: e3a00015 mov r0, #21
|
||||
200304: ebffff65 bl 2000a0 <uart_send>
|
||||
200308: ebffff5d bl 200084 <uart_check>
|
||||
20030c: e284483d add r4, r4, #3997696 ; 0x3d0000
|
||||
200310: e3500000 cmp r0, #0
|
||||
200314: e2844c09 add r4, r4, #2304 ; 0x900
|
||||
200318: 0afffff4 beq 2002f0 <notmain+0x4c>
|
||||
20031c: e3a0a902 mov sl, #32768 ; 0x8000
|
||||
200320: e3a08000 mov r8, #0
|
||||
200324: e3a040c0 mov r4, #192 ; 0xc0
|
||||
200328: e3a09001 mov r9, #1
|
||||
20032c: ebffff48 bl 200054 <uart_recv>
|
||||
200330: e35400c0 cmp r4, #192 ; 0xc0
|
||||
200334: e1a05000 mov r5, r0
|
||||
200338: 0a000036 beq 200418 <notmain+0x174>
|
||||
20033c: 9a000025 bls 2003d8 <notmain+0x134>
|
||||
200340: e35400c1 cmp r4, #193 ; 0xc1
|
||||
200344: 0a000051 beq 200490 <notmain+0x1ec>
|
||||
200348: e35400c2 cmp r4, #194 ; 0xc2
|
||||
20034c: 1a000049 bne 200478 <notmain+0x1d4>
|
||||
200350: e26930ff rsb r3, r9, #255 ; 0xff
|
||||
200354: e1530000 cmp r3, r0
|
||||
200358: 0a000054 beq 2004b0 <notmain+0x20c>
|
||||
20035c: e3a00018 mov r0, #24
|
||||
200360: ebffff4e bl 2000a0 <uart_send>
|
||||
200364: e3a00018 mov r0, #24
|
||||
200368: ebffff4c bl 2000a0 <uart_send>
|
||||
20036c: e3a00018 mov r0, #24
|
||||
200370: ebffff4a bl 2000a0 <uart_send>
|
||||
200374: e3a00018 mov r0, #24
|
||||
200378: ebffff48 bl 2000a0 <uart_send>
|
||||
20037c: e3a00018 mov r0, #24
|
||||
200380: ebffff46 bl 2000a0 <uart_send>
|
||||
200384: ebffffc0 bl 20028c <timer_tick>
|
||||
200388: e1a04000 mov r4, r0
|
||||
20038c: ebffffbe bl 20028c <timer_tick>
|
||||
200390: e0640000 rsb r0, r4, r0
|
||||
200394: e1500006 cmp r0, r6
|
||||
200398: 9afffffb bls 20038c <notmain+0xe8>
|
||||
20039c: e3a0000d mov r0, #13
|
||||
2003a0: ebffff3e bl 2000a0 <uart_send>
|
||||
2003a4: e3a0000a mov r0, #10
|
||||
2003a8: ebffff3c bl 2000a0 <uart_send>
|
||||
2003ac: e3a0000a mov r0, #10
|
||||
2003b0: ebffff3a bl 2000a0 <uart_send>
|
||||
2003b4: e59f010c ldr r0, [pc, #268] ; 2004c8 <notmain+0x224>
|
||||
2003b8: ebffff5c bl 200130 <hexstring>
|
||||
2003bc: ebffff44 bl 2000d4 <uart_flush>
|
||||
2003c0: ea000000 b 2003c8 <notmain+0x124>
|
||||
2003c4: ebffff22 bl 200054 <uart_recv>
|
||||
2003c8: ebffff2d bl 200084 <uart_check>
|
||||
2003cc: e3500000 cmp r0, #0
|
||||
2003d0: 1afffffb bne 2003c4 <notmain+0x120>
|
||||
2003d4: eaffffbd b 2002d0 <notmain+0x2c>
|
||||
2003d8: e3540080 cmp r4, #128 ; 0x80
|
||||
2003dc: 1a000025 bne 200478 <notmain+0x1d4>
|
||||
2003e0: e20880ff and r8, r8, #255 ; 0xff
|
||||
2003e4: e1500008 cmp r0, r8
|
||||
2003e8: 1affffdb bne 20035c <notmain+0xb8>
|
||||
2003ec: e3a00006 mov r0, #6
|
||||
2003f0: ebffff2a bl 2000a0 <uart_send>
|
||||
2003f4: ebffff16 bl 200054 <uart_recv>
|
||||
2003f8: e3a040c0 mov r4, #192 ; 0xc0
|
||||
2003fc: e2899001 add r9, r9, #1
|
||||
200400: e35400c0 cmp r4, #192 ; 0xc0
|
||||
200404: e1a08005 mov r8, r5
|
||||
200408: e28aa080 add sl, sl, #128 ; 0x80
|
||||
20040c: e20990ff and r9, r9, #255 ; 0xff
|
||||
200410: e1a05000 mov r5, r0
|
||||
200414: 1affffc8 bne 20033c <notmain+0x98>
|
||||
200418: e3500001 cmp r0, #1
|
||||
20041c: 0a000020 beq 2004a4 <notmain+0x200>
|
||||
200420: e3500004 cmp r0, #4
|
||||
200424: 1affffcc bne 20035c <notmain+0xb8>
|
||||
200428: e3a00006 mov r0, #6
|
||||
20042c: ebffff1b bl 2000a0 <uart_send>
|
||||
200430: ebffff95 bl 20028c <timer_tick>
|
||||
200434: e1a05000 mov r5, r0
|
||||
200438: ebffff93 bl 20028c <timer_tick>
|
||||
20043c: e0650000 rsb r0, r5, r0
|
||||
200440: e1500006 cmp r0, r6
|
||||
200444: 9afffffb bls 200438 <notmain+0x194>
|
||||
200448: e3a0000d mov r0, #13
|
||||
20044c: ebffff13 bl 2000a0 <uart_send>
|
||||
200450: e3a0000a mov r0, #10
|
||||
200454: ebffff11 bl 2000a0 <uart_send>
|
||||
200458: e3a0000a mov r0, #10
|
||||
20045c: ebffff0f bl 2000a0 <uart_send>
|
||||
200460: e59f0064 ldr r0, [pc, #100] ; 2004cc <notmain+0x228>
|
||||
200464: ebffff31 bl 200130 <hexstring>
|
||||
200468: ebffff19 bl 2000d4 <uart_flush>
|
||||
20046c: e3a00902 mov r0, #32768 ; 0x8000
|
||||
200470: ebfffeef bl 200034 <BRANCHTO>
|
||||
200474: eaffffac b 20032c <notmain+0x88>
|
||||
200478: e7ca5004 strb r5, [sl, r4]
|
||||
20047c: e2844001 add r4, r4, #1
|
||||
200480: e35400ff cmp r4, #255 ; 0xff
|
||||
200484: e0888005 add r8, r8, r5
|
||||
200488: 1affffa7 bne 20032c <notmain+0x88>
|
||||
20048c: eaffffb2 b 20035c <notmain+0xb8>
|
||||
200490: e1500009 cmp r0, r9
|
||||
200494: 1affffb0 bne 20035c <notmain+0xb8>
|
||||
200498: e0888009 add r8, r8, r9
|
||||
20049c: e3a040c2 mov r4, #194 ; 0xc2
|
||||
2004a0: eaffffa1 b 20032c <notmain+0x88>
|
||||
2004a4: e1a08000 mov r8, r0
|
||||
2004a8: e3a040c1 mov r4, #193 ; 0xc1
|
||||
2004ac: eaffff9e b 20032c <notmain+0x88>
|
||||
2004b0: e0888003 add r8, r8, r3
|
||||
2004b4: e3a04000 mov r4, #0
|
||||
2004b8: eaffff9b b 20032c <notmain+0x88>
|
||||
2004bc: 12345678 eorsne r5, r4, #120, 12 ; 0x7800000
|
||||
2004c0: 003d08ff ldrshteq r0, [sp], -pc
|
||||
2004c4: 001e847f andseq r8, lr, pc, ror r4
|
||||
2004c8: 00badbad adcseq sp, sl, sp, lsr #23
|
||||
2004cc: dadadada ble ff8b703c <notmain+0xff6b6d98>
|
||||
|
||||
Disassembly of section .ARM.attributes:
|
||||
|
||||
00000000 <.ARM.attributes>:
|
||||
0: 00002a41 andeq r2, r0, r1, asr #20
|
||||
4: 61656100 cmnvs r5, r0, lsl #2
|
||||
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
|
||||
18: 08020600 stmdaeq r2, {r9, sl}
|
||||
1c: 12010901 andne r0, r1, #16384 ; 0x4000
|
||||
20: 15011404 strne r1, [r1, #-1028] ; 0x404
|
||||
24: 18031701 stmdane r3, {r0, r8, r9, sl, ip}
|
||||
28: Address 0x0000000000000028 is out of bounds.
|
||||
|
||||
|
||||
Disassembly of section .comment:
|
||||
|
||||
00000000 <.comment>:
|
||||
0: 3a434347 bcc 10d0d24 <notmain+0xed0a80>
|
||||
4: 4e472820 cdpmi 8, 4, cr2, cr7, cr0, {1}
|
||||
8: 34202955 strtcc r2, [r0], #-2389 ; 0x955
|
||||
c: 322e382e eorcc r3, lr, #3014656 ; 0x2e0000
|
||||
...
|
||||
BIN
bootloader06/kernel.img
Executable file
BIN
bootloader06/kernel.img
Executable file
Binary file not shown.
12
bootloader06/loader
Normal file
12
bootloader06/loader
Normal file
@@ -0,0 +1,12 @@
|
||||
|
||||
MEMORY
|
||||
{
|
||||
ram : ORIGIN = 0x8000, LENGTH = 0x1000000
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.text : { *(.text*) } > ram
|
||||
.bss : { *(.bss*) } > ram
|
||||
}
|
||||
|
||||
12
bootloader06/memmap
Normal file
12
bootloader06/memmap
Normal file
@@ -0,0 +1,12 @@
|
||||
|
||||
MEMORY
|
||||
{
|
||||
ram : ORIGIN = 0x8000, LENGTH = 0x1000
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.text : { *(.text*) } > ram
|
||||
.bss : { *(.bss*) } > ram
|
||||
}
|
||||
|
||||
151
bootloader06/periph.c
Normal file
151
bootloader06/periph.c
Normal file
@@ -0,0 +1,151 @@
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
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 GPFSEL1 0x20200004
|
||||
#define GPSET0 0x2020001C
|
||||
#define GPCLR0 0x20200028
|
||||
#define GPPUD 0x20200094
|
||||
#define GPPUDCLK0 0x20200098
|
||||
|
||||
#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
|
||||
|
||||
//GPIO14 TXD0 and TXD1
|
||||
//GPIO15 RXD0 and RXD1
|
||||
//------------------------------------------------------------------------
|
||||
unsigned int uart_lcr ( void )
|
||||
{
|
||||
return(GET32(AUX_MU_LSR_REG));
|
||||
}
|
||||
//------------------------------------------------------------------------
|
||||
unsigned int uart_recv ( void )
|
||||
{
|
||||
while(1)
|
||||
{
|
||||
if(GET32(AUX_MU_LSR_REG)&0x01) break;
|
||||
}
|
||||
return(GET32(AUX_MU_IO_REG)&0xFF);
|
||||
}
|
||||
//------------------------------------------------------------------------
|
||||
unsigned int uart_check ( void )
|
||||
{
|
||||
if(GET32(AUX_MU_LSR_REG)&0x01) return(1);
|
||||
return(0);
|
||||
}
|
||||
//------------------------------------------------------------------------
|
||||
void uart_send ( unsigned int c )
|
||||
{
|
||||
while(1)
|
||||
{
|
||||
if(GET32(AUX_MU_LSR_REG)&0x20) break;
|
||||
}
|
||||
PUT32(AUX_MU_IO_REG,c);
|
||||
}
|
||||
//------------------------------------------------------------------------
|
||||
void uart_flush ( void )
|
||||
{
|
||||
while(1)
|
||||
{
|
||||
if((GET32(AUX_MU_LSR_REG)&0x100)==0) break;
|
||||
}
|
||||
}
|
||||
//------------------------------------------------------------------------
|
||||
void hexstrings ( unsigned int d )
|
||||
{
|
||||
//unsigned int ra;
|
||||
unsigned int rb;
|
||||
unsigned int rc;
|
||||
|
||||
rb=32;
|
||||
while(1)
|
||||
{
|
||||
rb-=4;
|
||||
rc=(d>>rb)&0xF;
|
||||
if(rc>9) rc+=0x37; else rc+=0x30;
|
||||
uart_send(rc);
|
||||
if(rb==0) break;
|
||||
}
|
||||
uart_send(0x20);
|
||||
}
|
||||
//------------------------------------------------------------------------
|
||||
void hexstring ( unsigned int d )
|
||||
{
|
||||
hexstrings(d);
|
||||
uart_send(0x0D);
|
||||
uart_send(0x0A);
|
||||
}
|
||||
//------------------------------------------------------------------------
|
||||
void uart_init ( void )
|
||||
{
|
||||
unsigned int ra;
|
||||
|
||||
PUT32(AUX_ENABLES,1);
|
||||
PUT32(AUX_MU_IER_REG,0);
|
||||
PUT32(AUX_MU_CNTL_REG,0);
|
||||
PUT32(AUX_MU_LCR_REG,3);
|
||||
PUT32(AUX_MU_MCR_REG,0);
|
||||
PUT32(AUX_MU_IER_REG,0);
|
||||
PUT32(AUX_MU_IIR_REG,0xC6);
|
||||
PUT32(AUX_MU_BAUD_REG,270);
|
||||
ra=GET32(GPFSEL1);
|
||||
ra&=~(7<<12); //gpio14
|
||||
ra|=2<<12; //alt5
|
||||
ra&=~(7<<15); //gpio15
|
||||
ra|=2<<15; //alt5
|
||||
PUT32(GPFSEL1,ra);
|
||||
PUT32(GPPUD,0);
|
||||
for(ra=0;ra<150;ra++) dummy(ra);
|
||||
PUT32(GPPUDCLK0,(1<<14)|(1<<15));
|
||||
for(ra=0;ra<150;ra++) dummy(ra);
|
||||
PUT32(GPPUDCLK0,0);
|
||||
PUT32(AUX_MU_CNTL_REG,3);
|
||||
}
|
||||
//------------------------------------------------------------------------
|
||||
void timer_init ( void )
|
||||
{
|
||||
//0xF9+1 = 250
|
||||
//250MHz/250 = 1MHz
|
||||
PUT32(ARM_TIMER_CTL,0x00F90000);
|
||||
PUT32(ARM_TIMER_CTL,0x00F90200);
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
unsigned int timer_tick ( void )
|
||||
{
|
||||
return(GET32(ARM_TIMER_CNT));
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
39
bootloader06/start.s
Normal file
39
bootloader06/start.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.
|
||||
;@
|
||||
;@-------------------------------------------------------------------------
|
||||
64
bootloader06/vectors.s
Normal file
64
bootloader06/vectors.s
Normal file
@@ -0,0 +1,64 @@
|
||||
|
||||
;@-------------------------------------------------------------------------
|
||||
;@-------------------------------------------------------------------------
|
||||
|
||||
.globl _start
|
||||
_start:
|
||||
b skip
|
||||
|
||||
.space 0x200000-0x8004,0
|
||||
|
||||
skip:
|
||||
mov sp,#0x08000000
|
||||
bl notmain
|
||||
hang: b hang
|
||||
|
||||
.globl PUT32
|
||||
PUT32:
|
||||
str r1,[r0]
|
||||
bx lr
|
||||
|
||||
.globl PUT16
|
||||
PUT16:
|
||||
strh r1,[r0]
|
||||
bx lr
|
||||
|
||||
.globl PUT8
|
||||
PUT8:
|
||||
strb r1,[r0]
|
||||
bx lr
|
||||
|
||||
.globl GET32
|
||||
GET32:
|
||||
ldr r0,[r0]
|
||||
bx lr
|
||||
|
||||
.globl GETPC
|
||||
GETPC:
|
||||
mov r0,lr
|
||||
bx lr
|
||||
|
||||
.globl BRANCHTO
|
||||
BRANCHTO:
|
||||
bx r0
|
||||
|
||||
.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