Skip to content

Commit a6f125d

Browse files
committed
Add sunxi_spl
1 parent acb5f2c commit a6f125d

File tree

210 files changed

+51366
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

210 files changed

+51366
-2
lines changed

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,5 +89,3 @@ GTAGS
8989
*.orig
9090
*~
9191
\#*#
92-
93-
sunxi_spl/

sunxi_spl/.gitignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#
2+
# NOTE! Don't add files that are generated in specific
3+
# subdirectories here. Add them in the ".gitignore" file
4+
# in that subdirectory instead.
5+
#
6+
# Normal rules
7+
#
8+
9+
*.rej
10+
*.axf
11+
*.map
12+
*.bin
13+
*.lds
14+
*.o
15+
*.depend
16+
*.cur
17+
cur.log
18+
include/generated/generic-asm-offsets.h
19+
#
20+
# Generated files
21+
#
22+
23+

sunxi_spl/boot0/Makefile

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
#
2+
# (C) Copyright 2000-2011
3+
# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4+
#
5+
# (C) Copyright 2011
6+
# Daniel Schwierzeck, daniel.schwierzeck@googlemail.com.
7+
#
8+
# (C) Copyright 2011
9+
# Texas Instruments Incorporated - http://www.ti.com/
10+
# Aneesh V <aneesh@ti.com>
11+
#
12+
# This file is released under the terms of GPL v2 and any later version.
13+
# See the file COPYING in the root directory of the source tree for details.
14+
#
15+
# Based on top-level Makefile.
16+
#
17+
18+
include $(SPLDIR)/config.mk
19+
include $(TOPDIR)/include/autoconf.mk
20+
include $(TOPDIR)/include/autoconf.mk.dep
21+
22+
CONFIG_SPL := y
23+
export CONFIG_SPL
24+
25+
TOOLS_DIR := $(TOPDIR)/tools
26+
27+
BOOT0_LDSCRIPT := $(SPLBASE)/sunxi_spl/boot0/main/boot0.lds
28+
29+
# We want the final binaries in this directory
30+
obj := $(SPLBASE)/sunxi_spl/boot0/
31+
32+
BOOT0_HEAD := sunxi_spl/boot0/boot0_head.o
33+
START := sunxi_spl/boot0/boot0_entry.o
34+
35+
LIBS-y += sunxi_spl/boot0/spl/libsource_spl.o
36+
LIBS-y += sunxi_spl/boot0/main/libmain.o
37+
LIBS-y += sunxi_spl/boot0/libs/libgeneric.o
38+
LIBS-y += sunxi_spl/spl/lib/libgeneric.o
39+
LIBS-y += sunxi_spl/dram/$(SOC)/dram/libdram.o
40+
LIBS-$(CONFIG_SUNXI_HDMI_IN_BOOT0) += sunxi_spl/display/hdmi/libdisplay.o
41+
42+
LIBS-$(CONFIG_SUNXI_CHIPID) += sunxi_spl/dram/$(SOC)/dram/libchipid.o
43+
LIBS := $(addprefix $(SPLBASE)/,$(sort $(LIBS-y)))
44+
45+
LIBNAND-$(CONFIG_STORAGE_MEDIA_NAND) += $(SPLBASE)/sunxi_spl/boot0/load_nand/libloadnand.o
46+
LIBNAND-$(CONFIG_STORAGE_MEDIA_NAND) += $(TOPDIR)/arch/$(ARCH)/cpu/$(CPU)/$(SOC)/nand/libnand.o
47+
LIBNAND-$(CONFIG_STORAGE_MEDIA_SPINAND) += $(TOPDIR)/arch/$(ARCH)/cpu/$(CPU)/$(SOC)/spinand/libspinand.o
48+
49+
LIBNAND := $(LIBNAND-y)
50+
51+
LIBMMC-$(CONFIG_STORAGE_MEDIA_MMC) += $(SPLBASE)/sunxi_spl/boot0/load_mmc/libloadmmc.o
52+
LIBMMC-$(CONFIG_STORAGE_MEDIA_MMC) += $(TOPDIR)/arch/$(ARCH)/cpu/$(CPU)/$(SOC)/mmc/libmmc.o
53+
54+
LIBMMC := $(LIBMMC-y)
55+
56+
57+
LIBSPINOR-$(CONFIG_STORAGE_MEDIA_SPINOR) += $(SPLBASE)/sunxi_spl/boot0/load_spinor/libloadspinor.o
58+
LIBSPINOR-$(CONFIG_STORAGE_MEDIA_SPINOR) += $(TOPDIR)/arch/$(ARCH)/cpu/$(CPU)/$(SOC)/spinor/libspinor.o
59+
60+
LIBSPINOR := $(LIBSPINOR-y)
61+
62+
ifndef CONFIG_BOOT0_SIZE_LIMIT
63+
BOOT0SIZE = $(CONFIG_SYS_INIT_RAM_SIZE)
64+
else
65+
BOOT0SIZE = $(CONFIG_BOOT0_SIZE_LIMIT)
66+
endif
67+
68+
__LIBS := $(subst $(obj),,$(LIBS))
69+
70+
71+
72+
# Special flags for CPP when processing the linker script.
73+
# Pass the version down so we can handle backwards compatibility
74+
# on the fly.
75+
LDPPFLAGS += \
76+
-include $(TOPDIR)/include/u-boot/u-boot.lds.h \
77+
-DBOOT0ADDR=$(CONFIG_BOOT0_RUN_ADDR) \
78+
-DBOOT0SIZE=$(BOOT0SIZE) \
79+
$(shell $(LD) --version | \
80+
sed -ne 's/GNU ld version \([0-9][0-9]*\)\.\([0-9][0-9]*\).*/-DLD_MAJOR=\1 -DLD_MINOR=\2/p')
81+
82+
ALL-$(CONFIG_STORAGE_MEDIA_NAND) += $(obj)boot0_nand.bin
83+
ALL-$(CONFIG_STORAGE_MEDIA_MMC) += $(obj)boot0_sdcard.bin
84+
ALL-$(CONFIG_STORAGE_MEDIA_SPINOR) += $(obj)boot0_spinor.bin
85+
86+
87+
all: $(ALL-y)
88+
89+
$(obj)boot0_nand.bin: $(obj)boot0_nand.axf $(obj)cur.log
90+
@echo bootaddr is $(CONFIG_BOOT0_RUN_ADDR)
91+
$(OBJCOPY) $(OBJCFLAGS) -O binary $< $@
92+
@$(SPLDIR)/../../tools/add_hash.sh -f $(SPLDIR)/boot0/boot0_nand.bin -m boot0
93+
94+
$(obj)boot0_nand.axf: $(LIBS) $(LIBNAND) $(obj)boot0.lds
95+
$(LD) $(LIBS) $(LIBNAND) $(PLATFORM_LIBGCC) $(LDFLAGS) $(LDFLAGS_boot0) -T$(obj)boot0.lds -o boot0_nand.axf -Map boot0_nand.map
96+
97+
$(obj)boot0_sdcard.bin: $(obj)boot0_sdcard.axf $(obj)cur.log
98+
$(OBJCOPY) $(OBJCFLAGS) -O binary $< $@
99+
@$(SPLDIR)/../../tools/add_hash.sh -f $(SPLDIR)/boot0/boot0_sdcard.bin -m boot0
100+
101+
$(obj)boot0_sdcard.axf: $(LIBS) $(LIBMMC) $(obj)boot0.lds
102+
$(LD) $(LIBS) $(LIBMMC) $(PLATFORM_LIBGCC) $(LDFLAGS) $(LDFLAGS_boot0) -T$(obj)boot0.lds -o boot0_sdcard.axf -Map boot0_sdcard.map
103+
104+
$(obj)boot0_spinor.bin: $(obj)boot0_spinor.axf $(obj)cur.log
105+
$(OBJCOPY) $(OBJCFLAGS) -O binary $< $@
106+
@$(SPLDIR)/../../tools/add_hash.sh -f $(SPLDIR)/boot0/boot0_spinor.bin -m boot0
107+
108+
$(obj)boot0_spinor.axf: $(LIBS) $(LIBSPINOR) $(obj)boot0.lds
109+
$(LD) $(LIBS) $(LIBSPINOR) $(PLATFORM_LIBGCC) $(LDFLAGS) $(LDFLAGS_boot0) -T$(obj)boot0.lds -o boot0_spinor.axf -Map boot0_spinor.map
110+
111+
$(LIBS): depend
112+
$(MAKE) -C $(SRCTREE)$(dir $(subst $(OBJTREE),,$@))
113+
114+
$(LIBNAND): depend
115+
$(MAKE) -C $(SRCTREE)$(dir $(subst $(OBJTREE),,$@))
116+
117+
$(LIBMMC): depend
118+
$(MAKE) -C $(SRCTREE)$(dir $(subst $(OBJTREE),,$@))
119+
120+
$(LIBSPINOR): depend
121+
$(MAKE) -C $(SRCTREE)$(dir $(subst $(OBJTREE),,$@))
122+
123+
$(obj)boot0.lds: $(BOOT0_LDSCRIPT)
124+
@$(CPP) $(ALL_CFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@
125+
126+
$(obj)cur.log:
127+
@git show HEAD --pretty=format:"%H" | head -n 1 > cur.log
128+
129+
depend: .depend
130+
#########################################################################
131+
132+
# defines $(obj).depend target
133+
include $(SRCTREE)/rules.mk
134+
135+
sinclude .depend
136+
137+
#########################################################################

sunxi_spl/boot0/libs/Makefile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
2+
##
3+
## Makefile for Sunxi Secure Boot
4+
##
5+
6+
7+
8+
include $(SPLDIR)/config.mk
9+
10+
LIB := $(lib)libgeneric.o
11+
12+
COBJS += check.o
13+
COBJS += nand_misc.o
14+
COBJS += mmu.o
15+
COBJS += eabi_compat.o
16+
#COBJS += jmp.o
17+
COBJS += common.o
18+
19+
SOBJS += jmpto64.o memcpy_align16.o
20+
21+
SOBJS := $(SOBJS)
22+
COBJS := $(COBJS)
23+
SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c)
24+
OBJS := $(addprefix $(obj),$(COBJS) $(SOBJS))
25+
26+
all: $(obj).depend $(LIB)
27+
28+
$(LIB): $(OBJS)
29+
$(call cmd_link_o_target, $(OBJS))
30+
31+
#########################################################################
32+
33+
# defines $(obj).depend target
34+
include $(SRCTREE)/rules.mk
35+
36+
sinclude $(obj).depend
37+
38+
#########################################################################

sunxi_spl/boot0/libs/check.c

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* (C) Copyright 2013-2020
3+
* Allwinner Technology Co., Ltd. <www.allwinnertech.com>
4+
* wangwei <wangflord@allwinnertech.com>
5+
*
6+
* See file CREDITS for list of people who contributed to this
7+
* project.
8+
*
9+
* This program is free software; you can redistribute it and/or
10+
* modify it under the terms of the GNU General Public License as
11+
* published by the Free Software Foundation; either version 2 of
12+
* the License, or (at your option) any later version.
13+
*
14+
* This program is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
* GNU General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU General Public License
20+
* along with this program; if not, write to the Free Software
21+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
22+
* MA 02111-1307 USA
23+
*/
24+
25+
#include "common.h"
26+
#include "private_toc.h"
27+
#include <private_uboot.h>
28+
29+
30+
int verify_addsum( void *mem_base, __u32 size )
31+
{
32+
__u32 *buf;
33+
__u32 count;
34+
__u32 src_sum;
35+
__u32 sum;
36+
sbrom_toc1_head_info_t *bfh;
37+
38+
bfh = (sbrom_toc1_head_info_t *)mem_base;
39+
/*generate checksum*/
40+
src_sum = bfh->add_sum;
41+
bfh->add_sum = STAMP_VALUE;
42+
count = size >> 2;
43+
sum = 0;
44+
buf = (__u32 *)mem_base;
45+
do
46+
{
47+
sum += *buf++;
48+
sum += *buf++;
49+
sum += *buf++;
50+
sum += *buf++;
51+
}while( ( count -= 4 ) > (4-1) );
52+
53+
while( count-- > 0 )
54+
sum += *buf++;
55+
56+
bfh->add_sum = src_sum;
57+
58+
// printf("sum=%x\n", sum);
59+
// printf("src_sum=%x\n", src_sum);
60+
61+
//check: 0-success -1:fail
62+
if( sum == src_sum )
63+
return 0;
64+
else
65+
return -1;
66+
}

sunxi_spl/boot0/libs/common.c

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
* (C) Copyright 2007-2013
3+
* Allwinner Technology Co., Ltd. <www.allwinnertech.com>
4+
* Young <guoyingyang@allwinnertech.com>
5+
*
6+
* See file CREDITS for list of people who contributed to this
7+
* project.
8+
*
9+
* This program is free software; you can redistribute it and/or
10+
* modify it under the terms of the GNU General Public License as
11+
* published by the Free Software Foundation; either version 2 of
12+
* the License, or (at your option) any later version.
13+
*
14+
* This program is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
* GNU General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU General Public License
20+
* along with this program; if not, write to the Free Software
21+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
22+
* MA 02111-1307 USA
23+
*/
24+
25+
#include "common.h"
26+
#include "asm/armv7.h"
27+
#include <private_boot0.h>
28+
#include <asm/arch/uart.h>
29+
#include <boot0_helper.h>
30+
31+
extern const boot0_file_head_t BT0_head;
32+
extern int debug_enable;
33+
/*
34+
************************************************************************************************************
35+
*
36+
* function
37+
*
38+
* name :set_debugmode_flag
39+
*
40+
* parmeters :void
41+
*
42+
* return :
43+
*
44+
* note :if BT0_head.prvt_head.debug_mode_off = 1,do not print any message to uart
45+
*
46+
*
47+
************************************************************************************************************
48+
*/
49+
50+
int set_debugmode_flag(void)
51+
{
52+
char c = 0;
53+
54+
c = get_uart_input();
55+
if(c == 'd')
56+
{
57+
debug_enable = LOG_LEVEL_INFO;
58+
return c;
59+
}
60+
61+
if(BT0_head.prvt_head.debug_mode)
62+
debug_enable = BT0_head.prvt_head.debug_mode;
63+
else
64+
debug_enable = 0;
65+
66+
return c;
67+
}
68+

sunxi_spl/boot0/libs/eabi_compat.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Utility functions needed for (some) EABI conformant tool chains.
3+
*
4+
* (C) Copyright 2009 Wolfgang Denk <wd@denx.de>
5+
*
6+
* This program is Free Software; you can redistribute it and/or
7+
* modify it under the terms of the GNU General Public License as
8+
* published by the Free Software Foundation; either version 2 of the
9+
* License, or (at your option) any later version.
10+
*/
11+
12+
#include <common.h>
13+
14+
int raise (int signum)
15+
{
16+
return 0;
17+
}
18+
19+
/* Dummy function to avoid linker complaints */
20+
void __aeabi_unwind_cpp_pr0(void)
21+
{
22+
};

sunxi_spl/boot0/libs/jmpto64.S

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
3+
4+
5+
.globl RMR_TO64
6+
7+
RMR_TO64:
8+
MRC p15,0,r1,c12,c0,2
9+
ORR r1,r1,#(0x3<<0)
10+
DSB
11+
MCR p15,0,r1,c12,c0,2
12+
ISB
13+
14+
Loop1:
15+
WFI
16+
B Loop1
17+
BX lr
18+
19+
20+

0 commit comments

Comments
 (0)