an experiment to see the kernel8.img, kernel7.img differences in action
This commit is contained in:
47
boards/pi3/imgtest/Makefile
Normal file
47
boards/pi3/imgtest/Makefile
Normal file
@@ -0,0 +1,47 @@
|
||||
|
||||
ARMGNU64 ?= aarch64-none-elf
|
||||
ARMGNU32 ?= arm-none-eabi
|
||||
|
||||
COPS = -Wall -O2 -nostdlib -nostartfiles -ffreestanding
|
||||
|
||||
gcc : kernel8.img kernel8-32.img kernel7.img kernel.img
|
||||
|
||||
all : gcc
|
||||
|
||||
clean :
|
||||
rm -f *.o
|
||||
rm -f *.bin
|
||||
rm -f *.hex
|
||||
rm -f *.elf
|
||||
rm -f *.list
|
||||
rm -f *.img
|
||||
|
||||
kernel8.img : memmap bs64.s notmain.c
|
||||
$(ARMGNU64)-as bs64.s -o bs64.o
|
||||
$(ARMGNU64)-gcc $(COPS) -c -DDEFINEME=0x800 notmain.c -o notmain.o
|
||||
$(ARMGNU64)-ld bs64.o notmain.o -T memmap -o kernel8.elf
|
||||
$(ARMGNU64)-objdump -D kernel8.elf > kernel8.list
|
||||
$(ARMGNU64)-objcopy kernel8.elf -O binary kernel8.img
|
||||
|
||||
kernel8-32.img : memmap bs32.s notmain.c
|
||||
$(ARMGNU32)-as bs32.s -o bs32.o
|
||||
$(ARMGNU32)-gcc $(COPS) -c -DDEFINEME=0x832 notmain.c -o notmain.o
|
||||
$(ARMGNU32)-ld bs32.o notmain.o -T memmap -o kernel8-32.elf
|
||||
$(ARMGNU32)-objdump -D kernel8-32.elf > kernel8-32.list
|
||||
$(ARMGNU32)-objcopy kernel8-32.elf -O binary kernel8-32.img
|
||||
|
||||
kernel7.img : memmap bs32.s notmain.c
|
||||
$(ARMGNU32)-as bs32.s -o bs32.o
|
||||
$(ARMGNU32)-gcc $(COPS) -c -DDEFINEME=0x700 notmain.c -o notmain.o
|
||||
$(ARMGNU32)-ld bs32.o notmain.o -T memmap -o kernel7.elf
|
||||
$(ARMGNU32)-objdump -D kernel7.elf > kernel7.list
|
||||
$(ARMGNU32)-objcopy kernel7.elf -O binary kernel7.img
|
||||
|
||||
kernel.img : memmap bs32.s notmain.c
|
||||
$(ARMGNU32)-as bs32.s -o bs32.o
|
||||
$(ARMGNU32)-gcc $(COPS) -c -DDEFINEME=0x000 notmain.c -o notmain.o
|
||||
$(ARMGNU32)-ld bs32.o notmain.o -T memmap -o kernel.elf
|
||||
$(ARMGNU32)-objdump -D kernel.elf > kernel.list
|
||||
$(ARMGNU32)-objcopy kernel.elf -O binary kernel.img
|
||||
|
||||
|
||||
62
boards/pi3/imgtest/README
Normal file
62
boards/pi3/imgtest/README
Normal file
@@ -0,0 +1,62 @@
|
||||
|
||||
See the top level README file for more information on documentation
|
||||
and how to run these programs.
|
||||
|
||||
Sounds like this happened a while ago now, months, so I am just catching
|
||||
up so they have provided a way to allow for 64 bit kernels without
|
||||
having to load from zero and manage the cores and switching modes.
|
||||
|
||||
So what they are saying is it looks for the file kernel8.img then
|
||||
kernel8-32.img then kernel7.img and last kernel.img and in that order
|
||||
whichever it finds is the one it uses. So with only a current
|
||||
bootcode.bin, start.elf and one or all of the files built here on
|
||||
the flash whichever it finds in that order it uses, so you can put
|
||||
all four .img files and it uses kernel8.img then delete that one and
|
||||
then it uses kernel8-32.img and so on.
|
||||
|
||||
Yes you have to do the sd card dance.
|
||||
|
||||
So the output is below, interesting that in 64 bit mode either my
|
||||
code to read the pc is wrong or they are starting at 0x80000 instead
|
||||
of 0x8000.
|
||||
|
||||
There are no doubt other registers I could dump (note as this time I
|
||||
didnt do the work to read the CPSR in 64 bit mode so it is just zero)
|
||||
to see if there are any actual differences between the kernel8-32.img
|
||||
and kernel7.img and kernel.img as far as how it loads, etc. I guess
|
||||
I (you, we) could just dump the 0x0000 code they place to see if it
|
||||
varies.
|
||||
|
||||
kernel8.img
|
||||
|
||||
12345678
|
||||
00000800
|
||||
00080264
|
||||
00000000
|
||||
12345678
|
||||
|
||||
kernel8-32.img
|
||||
|
||||
12345678
|
||||
00008320
|
||||
00008224
|
||||
200001DA
|
||||
12345678
|
||||
|
||||
kernel7.img
|
||||
|
||||
12345678
|
||||
00000700
|
||||
00008224
|
||||
200001DA
|
||||
12345678
|
||||
|
||||
kernel.img
|
||||
|
||||
12345678
|
||||
00000000
|
||||
00008224
|
||||
200001DA
|
||||
12345678
|
||||
|
||||
|
||||
59
boards/pi3/imgtest/bs32.s
Normal file
59
boards/pi3/imgtest/bs32.s
Normal file
@@ -0,0 +1,59 @@
|
||||
|
||||
;@-------------------------------------------------------------------
|
||||
;@-------------------------------------------------------------------
|
||||
|
||||
.globl _start
|
||||
_start:
|
||||
mov sp,#0x80000
|
||||
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 dummy
|
||||
dummy:
|
||||
bx lr
|
||||
|
||||
.globl GETCPSR
|
||||
GETCPSR:
|
||||
mrs r0,cpsr
|
||||
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.
|
||||
;@
|
||||
;@-------------------------------------------------------------------
|
||||
48
boards/pi3/imgtest/bs64.s
Normal file
48
boards/pi3/imgtest/bs64.s
Normal file
@@ -0,0 +1,48 @@
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
.globl _start
|
||||
_start:
|
||||
mov sp,#0x80000
|
||||
bl notmain
|
||||
hang: b hang
|
||||
|
||||
.globl PUT32
|
||||
PUT32:
|
||||
str w1,[x0]
|
||||
ret
|
||||
|
||||
.globl GET32
|
||||
GET32:
|
||||
ldr w0,[x0]
|
||||
ret
|
||||
|
||||
.globl GETPC
|
||||
GETPC:
|
||||
mov x0,x30
|
||||
ret
|
||||
|
||||
.globl GETCPSR
|
||||
GETCPSR:
|
||||
mov x0,#0
|
||||
ret
|
||||
|
||||
.globl dummy
|
||||
dummy:
|
||||
ret
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//-------------------------------------------------------------------
|
||||
12
boards/pi3/imgtest/memmap
Normal file
12
boards/pi3/imgtest/memmap
Normal file
@@ -0,0 +1,12 @@
|
||||
|
||||
MEMORY
|
||||
{
|
||||
ram : ORIGIN = 0x8000, LENGTH = 0x1000
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.text : { *(.text*) } > ram
|
||||
.bss : { *(.bss*) } > ram
|
||||
}
|
||||
|
||||
138
boards/pi3/imgtest/notmain.c
Normal file
138
boards/pi3/imgtest/notmain.c
Normal file
@@ -0,0 +1,138 @@
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
// 2 outer corner
|
||||
// 4
|
||||
// 6
|
||||
// 8 TX out
|
||||
// 10 RX in
|
||||
|
||||
extern void PUT32 ( unsigned int, unsigned int );
|
||||
extern unsigned int GET32 ( unsigned int );
|
||||
extern unsigned int GETPC ( void );
|
||||
extern void dummy ( unsigned int );
|
||||
extern unsigned int GETCPSR ( void );
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
#define PBASE 0x3F000000
|
||||
|
||||
extern void PUT32 ( unsigned int, unsigned int );
|
||||
extern unsigned int GET32 ( unsigned int );
|
||||
|
||||
#define ARM_TIMER_CTL (PBASE+0x0000B408)
|
||||
#define ARM_TIMER_CNT (PBASE+0x0000B420)
|
||||
|
||||
#define GPFSEL1 (PBASE+0x00200004)
|
||||
#define GPSET0 (PBASE+0x0020001C)
|
||||
#define GPCLR0 (PBASE+0x00200028)
|
||||
#define GPPUD (PBASE+0x00200094)
|
||||
#define GPPUDCLK0 (PBASE+0x00200098)
|
||||
|
||||
#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)
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
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);
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
int notmain ( void )
|
||||
{
|
||||
uart_init();
|
||||
hexstring(0x12345678);
|
||||
hexstring(DEFINEME);
|
||||
hexstring(GETPC());
|
||||
hexstring(GETCPSR());
|
||||
hexstring(0x12345678);
|
||||
return(0);
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2014 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