(一)拷贝模板
1、拷贝board/samsung/smdk2410为board/samsung/smdk2440
book@ubuntu:~$ cd u-boot-2016.11/board/samsung/
book@ubuntu:~/u-boot-2016.11/board/samsung$ ls
arndale espresso7420 odroid smdk2410 smdk5420 smdkv310 trats2
common goni origen smdk5250 smdkc100 trats universal_c210
book@ubuntu:~/u-boot-2016.11/board/samsung$ cp -R smdk2410 smdk2440
book@ubuntu:~/u-boot-2016.11/board/samsung$ cd smdk2440
book@ubuntu:~/u-boot-2016.11/board/samsung/smdk2440$ ls
Kconfig lowlevel_init.S MAINTAINERS Makefile smdk2410.c
book@ubuntu:~/u-boot-2016.11/board/samsung/smdk2440$ mv smdk2410.c smdk2440.c
book@ubuntu:~/u-boot-2016.11/board/samsung/smdk2440$ ls
Kconfig lowlevel_init.S MAINTAINERS Makefile smdk2440.c
2、拷贝configs/smdk2410_defconfig为configs/smdk2440_defconfig
book@ubuntu:~/u-boot-2016.11/board/samsung/smdk2440$ cd ~/u-boot-2016.11/configs
book@ubuntu:~/u-boot-2016.11/configs$ cp smdk2410_defconfig smdk2440_defconfig
3、拷贝include/configs/smdk2410.h为include/configs/smdk2440.h
book@ubuntu:~/u-boot-2016.11/configs$ cd ../include/configs/
book@ubuntu:~/u-boot-2016.11/include/configs$ cp smdk2410.h smdk2440.h
(二)初步编译u-boot
1、修改arch/arm/Kconfig
diff -urN u-boot-2016.11/arch/arm/Kconfig u-boot-2016.11_s3c2440/arch/arm/Kconfig
--- u-boot-2016.11/arch/arm/Kconfig 2016-11-15 00:27:11.000000000 +0800
+++ u-boot-2016.11_s3c2440/arch/arm/Kconfig 2018-06-14 19:59:43.532651155 +0800
@@ -145,6 +145,10 @@
bool "Support smdk2410"
select CPU_ARM920T
+config TARGET_SMDK2440
+ bool "Support smdk2440"
+ select CPU_ARM920T
+
config TARGET_ASPENITE
bool "Support aspenite"
select CPU_ARM926EJS
@@ -992,6 +996,7 @@
source "board/phytec/pcm052/Kconfig"
source "board/ppcag/bg0900/Kconfig"
source "board/samsung/smdk2410/Kconfig"
+source "board/samsung/smdk2440/Kconfig"
source "board/sandisk/sansa_fuze_plus/Kconfig"
source "board/schulercontrol/sc_sps_1/Kconfig"
source "board/siemens/draco/Kconfig"
2、修改board/samsung/smdk2440/Kconfig
diff -urN u-boot-2016.11/board/samsung/smdk2440/Kconfig u-boot-2016.11_s3c2440/board/samsung/smdk2440/Kconfig
--- u-boot-2016.11/board/samsung/smdk2440/Kconfig 2018-06-14 22:06:34.243660155 +0800
+++ u-boot-2016.11_s3c2440/board/samsung/smdk2440/Kconfig 2018-06-14 20:00:28.647197155 +0800
@@ -1,7 +1,7 @@
-if TARGET_SMDK2410
+if TARGET_SMDK2440
config SYS_BOARD
- default "smdk2410"
+ default "smdk2440"
config SYS_VENDOR
default "samsung"
@@ -10,6 +10,6 @@
default "s3c24x0"
config SYS_CONFIG_NAME
- default "smdk2410"
+ default "smdk2440"
endif
3、修改board/samsung/smdk2440/MAINTAINERS
diff -urN u-boot-2016.11/board/samsung/smdk2440/MAINTAINERS u-boot-2016.11_s3c2440/board/samsung/smdk2440/MAINTAINERS
--- u-boot-2016.11/board/samsung/smdk2440/MAINTAINERS 2018-06-14 22:06:34.243660155 +0800
+++ u-boot-2016.11_s3c2440/board/samsung/smdk2440/MAINTAINERS 2018-06-14 20:00:57.529631155 +0800
@@ -1,6 +1,6 @@
-SMDK2410 BOARD
+SMDK2440 BOARD
M: David Müller <[email protected]>
S: Maintained
-F: board/samsung/smdk2410/
-F: include/configs/smdk2410.h
-F: configs/smdk2410_defconfig
+F: board/samsung/smdk2440/
+F: include/configs/smdk2440.h
+F: configs/smdk2440_defconfig
4、修改board/samsung/smdk2440/Makefile
diff -urN u-boot-2016.11/board/samsung/smdk2440/Makefile u-boot-2016.11_s3c2440/board/samsung/smdk2440/Makefile
--- u-boot-2016.11/board/samsung/smdk2440/Makefile 2018-06-14 22:06:34.243660155 +0800
+++ u-boot-2016.11_s3c2440/board/samsung/smdk2440/Makefile 2018-06-14 20:01:27.408563155 +0800
@@ -5,5 +5,5 @@
# SPDX-License-Identifier: GPL-2.0+
#
-obj-y := smdk2410.o
+obj-y := smdk2440.o
obj-y += lowlevel_init.o
5、修改configs/smdk2440_defconfig
diff -urN u-boot-2016.11/configs/smdk2440_defconfig u-boot-2016.11_s3c2440/configs/smdk2440_defconfig
--- u-boot-2016.11/configs/smdk2440_defconfig 2018-06-14 22:06:53.467660155 +0800
+++ u-boot-2016.11_s3c2440/configs/smdk2440_defconfig 2018-06-14 20:11:33.999707154 +0800
@@ -1,10 +1,10 @@
CONFIG_ARM=y
-CONFIG_TARGET_SMDK2410=y
+CONFIG_TARGET_SMDK2440=y
CONFIG_BOOTDELAY=5
# CONFIG_SYS_STDIO_DEREGISTER is not set
# CONFIG_DISPLAY_BOARDINFO is not set
CONFIG_HUSH_PARSER=y
-CONFIG_SYS_PROMPT="SMDK2410 # "
+CONFIG_SYS_PROMPT="SMDK2440 # "
CONFIG_CMD_USB=y
# CONFIG_CMD_SETEXPR is not set
CONFIG_CMD_DHCP=y
6、修改scripts/config_whitelist.txt
diff -urN u-boot-2016.11/scripts/config_whitelist.txt u-boot-2016.11_s3c2440/scripts/config_whitelist.txt
--- u-boot-2016.11/scripts/config_whitelist.txt 2016-11-15 00:27:11.000000000 +0800
+++ u-boot-2016.11_s3c2440/scripts/config_whitelist.txt 2018-06-14 20:21:40.162637155 +0800
@@ -4107,6 +4107,7 @@
CONFIG_SMC_USE_32_BIT
CONFIG_SMC_USE_IOFUNCS
CONFIG_SMDK2410
+CONFIG_SMDK2440
CONFIG_SMDK5420
CONFIG_SMDKC100
CONFIG_SMDKV310
7、修改include/configs/smdk2440.h
diff -urN u-boot-2016.11/include/configs/smdk2440.h u-boot-2016.11_s3c2440/include/configs/smdk2440.h
--- u-boot-2016.11/include/configs/smdk2440.h 2018-06-14 22:07:11.595660155 +0800
+++ u-boot-2016.11_s3c2440/include/configs/smdk2440.h 2018-06-14 20:13:47.670509156 +0800
@@ -18,8 +18,8 @@
* (easy to change)
*/
#define CONFIG_S3C24X0 /* This is a SAMSUNG S3C24x0-type SoC */
-#define CONFIG_S3C2410 /* specifically a SAMSUNG S3C2410 SoC */
-#define CONFIG_SMDK2410 /* on a SAMSUNG SMDK2410 Board */
+#define CONFIG_S3C2440 /* specifically a SAMSUNG S3C2440 SoC */
+#define CONFIG_SMDK2440 /* on a SAMSUNG SMDK2440 Board */
#define CONFIG_SYS_TEXT_BASE 0x0
8、增加auto_run.sh
book@ubuntu:~/u-boot-2016.11$ gedit auto_run.sh
#!/bin/bash
echo "Clean Configuration File..."
make distclean
echo "Clean Obj..."
make clean
echo "Load Configuration File..."
make smdk2440_defconfig
echo "make..."
make CROSS_COMPILE=arm-linux-
9、编译u-boot
book@ubuntu:~/u-boot-2016.11$ chmod +x auto_run.sh
book@ubuntu:~/u-boot-2016.11$ ./auto_run.sh
book@ubuntu:~/u-boot-2016.11$ cd board/samsung/smdk2440/
book@ubuntu:~/u-boot-2016.11/board/samsung/smdk2440/$ ls
built-in.o lowlevel_init.o MAINTAINERS smdk2440.c
Kconfig lowlevel_init.S Makefile smdk2440.o
10、烧写u-boot.bin到Nor Flash启动看现象
可以看到,没有任何输出信息
(三)成功在Nor Flash上启动u-boot
1、修改 arch/arm/cpu/arm920t/start.S
diff -urN u-boot-2016.11/arch/arm/cpu/arm920t/start.S u-boot-2016.11_s3c2440/arch/arm/cpu/arm920t/start.S
--- u-boot-2016.11/arch/arm/cpu/arm920t/start.S 2016-11-15 00:27:11.000000000 +0800
+++ u-boot-2016.11_s3c2440/arch/arm/cpu/arm920t/start.S 2018-06-14 22:35:54.819660155 +0800
@@ -1,7 +1,7 @@
/*
* armboot - Startup Code for ARM920 CPU-core
*
- * Copyright (c) 2001 Marius Gröger <[email protected]>
+ * Copyright (c) 2001 Marius Gr?ger <[email protected]>
* Copyright (c) 2002 Alex Züpke <[email protected]>
* Copyright (c) 2002 Gary Jennejohn <[email protected]>
*
@@ -78,13 +78,37 @@
ldr r1, =0x3ff
ldr r0, =INTSUBMSK
str r1, [r0]
-# endif
-
/* FCLK:HCLK:PCLK = 1:2:4 */
/* default FCLK is 120 MHz ! */
ldr r0, =CLKDIVN
mov r1, #3
str r1, [r0]
+# endif
+# if defined(CONFIG_S3C2440)
+ #define S3C2440_MPLL_400MHZ ((0x5c<<12)|(0x01<<4)|(0x01))
+ /* FCLK:HCLK:PCLK = 1:4:8 */
+ /* default FCLK is 400 MHz ! */
+ /* 2. 设置时钟 */
+ ldr r0, =0x4c000014
+ mov r1, #0x05; // FCLK:HCLK:PCLK=1:4:8
+ str r1, [r0]
+
+ /* 如果HDIVN非0,CPU的总线模式应该从“fast bus mode”变为“asynchronous bus mode” */
+ mrc p15, 0, r1, c1, c0, 0 /* 读出控制寄存器 */
+ orr r1, r1, #0xc0000000 /* 设置为“asynchronous bus mode” */
+ mcr p15, 0, r1, c1, c0, 0 /* 写入控制寄存器 */
+
+ /* MPLLCON = S3C2440_MPLL_400MHZ */
+ ldr r0, =0x4c000004
+ ldr r1, =S3C2440_MPLL_400MHZ
+ str r1, [r0]
+
+ /* 启动ICACHE */
+ mrc p15, 0, r0, c1, c0, 0
+ orr r0, r0, #(1<<12)
+ mcr p15, 0, r0, c1, c0, 0
+# endif
+
#endif /* CONFIG_S3C24X0 */
/*
2、修改board/samsung/smdk2440/lowlevel_init.S
diff -urN u-boot-2016.11/board/samsung/smdk2440/lowlevel_init.S u-boot-2016.11_s3c2440/board/samsung/smdk2440/lowlevel_init.S
--- u-boot-2016.11/board/samsung/smdk2440/lowlevel_init.S 2018-06-14 22:06:34.243660155 +0800
+++ u-boot-2016.11_s3c2440/board/samsung/smdk2440/lowlevel_init.S 2018-06-14 22:36:29.351660155 +0800
@@ -131,16 +131,17 @@
/* the literal pools origin */
SMRDATA:
- .word (0+(B1_BWSCON<<4)+(B2_BWSCON<<8)+(B3_BWSCON<<12)+(B4_BWSCON<<16)+(B5_BWSCON<<20)+(B6_BWSCON<<24)+(B7_BWSCON<<28))
- .word ((B0_Tacs<<13)+(B0_Tcos<<11)+(B0_Tacc<<8)+(B0_Tcoh<<6)+(B0_Tah<<4)+(B0_Tacp<<2)+(B0_PMC))
- .word ((B1_Tacs<<13)+(B1_Tcos<<11)+(B1_Tacc<<8)+(B1_Tcoh<<6)+(B1_Tah<<4)+(B1_Tacp<<2)+(B1_PMC))
- .word ((B2_Tacs<<13)+(B2_Tcos<<11)+(B2_Tacc<<8)+(B2_Tcoh<<6)+(B2_Tah<<4)+(B2_Tacp<<2)+(B2_PMC))
- .word ((B3_Tacs<<13)+(B3_Tcos<<11)+(B3_Tacc<<8)+(B3_Tcoh<<6)+(B3_Tah<<4)+(B3_Tacp<<2)+(B3_PMC))
- .word ((B4_Tacs<<13)+(B4_Tcos<<11)+(B4_Tacc<<8)+(B4_Tcoh<<6)+(B4_Tah<<4)+(B4_Tacp<<2)+(B4_PMC))
- .word ((B5_Tacs<<13)+(B5_Tcos<<11)+(B5_Tacc<<8)+(B5_Tcoh<<6)+(B5_Tah<<4)+(B5_Tacp<<2)+(B5_PMC))
- .word ((B6_MT<<15)+(B6_Trcd<<2)+(B6_SCAN))
- .word ((B7_MT<<15)+(B7_Trcd<<2)+(B7_SCAN))
- .word ((REFEN<<23)+(TREFMD<<22)+(Trp<<20)+(Trc<<18)+(Tchr<<16)+REFCNT)
- .word 0x32
- .word 0x30
- .word 0x30
+ .long 0x22011110 //BWSCON
+ .long 0x00000700 //BANKCON0
+ .long 0x00000700 //BANKCON1
+ .long 0x00000700 //BANKCON2
+ .long 0x00000700 //BANKCON3
+ .long 0x00000740 //BANKCON4
+ .long 0x00000700 //BANKCON5
+ .long 0x00018005 //BANKCON6
+ .long 0x00018005 //BANKCON7
+ .long 0x008C04F4 // REFRESH
+ .long 0x000000B1 //BANKSIZE
+ .long 0x00000030 //MRSRB6
+ .long 0x00000030 //MRSRB7
+
(四)裁剪u-boot.bin大小
1、查看未裁剪前u-boot.bin的大小
book@ubuntu:~/u-boot-2016.11$ ./auto_run.sh
book@ubuntu:~/u-boot-2016.11$ ls -lh u-boot.bin
-rw-rw-r-- 1 david david 520K 6月 14 23:44 u-boot.bin
u-boot.bin太大不利于烧写,我们需要对u-boot进行裁剪
2、修改arch/arm/config.mk,删除pie
diff -urN u-boot-2016.11/arch/arm/config.mk u-boot-2016.11_s3c2440/arch/arm/config.mk
--- u-boot-2016.11/arch/arm/config.mk 2016-11-15 00:27:11.000000000 +0800
+++ u-boot-2016.11_s3c2440/arch/arm/config.mk 2018-06-14 22:49:20.435660155 +0800
@@ -86,7 +86,7 @@
endif
# needed for relocation
-LDFLAGS_u-boot += -pie
+#LDFLAGS_u-boot += -pie
#
# FIXME: binutils versions < 2.22 have a bug in the assembler where
@@ -108,7 +108,7 @@
ifneq ($(CONFIG_SPL_BUILD),y)
# Check that only R_ARM_RELATIVE relocations are generated.
-ALL-y += checkarmreloc
+#ALL-y += checkarmreloc
# The movt / movw can hardcode 16 bit parts of the addresses in the
# instruction. Relocation is not supported for that case, so disable
# such usage by requiring word relocations.
3、修改configs/smdk2440_defconfig
diff -urN u-boot-2016.11/configs/smdk2440_defconfig u-boot-2016.11_s3c2440/configs/smdk2440_defconfig
--- u-boot-2016.11/configs/smdk2440_defconfig 2018-06-14 22:37:01.047660155 +0800
+++ u-boot-2016.11_s3c2440/configs/smdk2440_defconfig 2018-06-14 22:47:45.395660155 +0800
@@ -5,14 +5,14 @@
# CONFIG_DISPLAY_BOARDINFO is not set
CONFIG_HUSH_PARSER=y
CONFIG_SYS_PROMPT="SMDK2440 # "
-CONFIG_CMD_USB=y
+#CONFIG_CMD_USB=y
# CONFIG_CMD_SETEXPR is not set
-CONFIG_CMD_DHCP=y
+#CONFIG_CMD_DHCP=y
CONFIG_CMD_PING=y
CONFIG_CMD_CACHE=y
-CONFIG_CMD_EXT2=y
-CONFIG_CMD_FAT=y
-CONFIG_CMD_UBI=y
-CONFIG_USB=y
-CONFIG_USB_STORAGE=y
-CONFIG_USB_KEYBOARD=y
+#CONFIG_CMD_EXT2=y
+#CONFIG_CMD_FAT=y
+#CONFIG_CMD_UBI=y
+#CONFIG_USB=y
+#CONFIG_USB_STORAGE=y
+#CONFIG_USB_KEYBOARD=y
4、修改include/configs/smdk2440.h
diff -urN u-boot-2016.11/include/configs/smdk2440.h u-boot-2016.11_s3c2440/include/configs/smdk2440.h
--- u-boot-2016.11/include/configs/smdk2440.h 2018-06-14 22:37:01.047660155 +0800
+++ u-boot-2016.11_s3c2440/include/configs/smdk2440.h 2018-06-14 22:45:30.747660155 +0800
@@ -45,6 +45,7 @@
#define CONFIG_S3C24X0_SERIAL
#define CONFIG_SERIAL1 1 /* we use SERIAL 1 on SMDK2410 */
+#if 0
/************************************************************
* USB support (currently only works with D-cache off)
************************************************************/
@@ -56,6 +57,7 @@
* RTC
************************************************************/
#define CONFIG_RTC_S3C24X0
+#endif
#define CONFIG_BAUDRATE 115200
@@ -71,7 +73,7 @@
* Command line configuration.
*/
#define CONFIG_CMD_BSP
-#define CONFIG_CMD_DATE
+/* #define CONFIG_CMD_DATE */
#define CONFIG_CMD_NAND
#define CONFIG_CMD_REGINFO
@@ -160,6 +162,7 @@
#define CONFIG_SYS_NAND_BASE 0x4E000000
#endif
+#if 0
/*
* File system
*/
@@ -169,6 +172,7 @@
#define CONFIG_MTD_PARTITIONS
#define CONFIG_YAFFS2
#define CONFIG_RBTREE
+#endif
/* additions for new relocation code, must be added to all boards */
#define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM_1
5、编译u-boot.bin并烧写到Nor Flash上
book@ubuntu:~/u-boot-2016.11$ ./auto_run.sh
book@ubuntu:~/u-boot-2016.11$ ls -lh u-boot.bin
-rwxrwxr-x 1 david david 230K 6月 14 23:53 u-boot.bin
裁剪后u-boot的大小明显比之前小了很多,我们将它烧写到Nor Flash上看会有什么现象?
到这里初步可以用Nor Flash启动u-boot了!