4.1 The first step of migration
The process of .config has been analyzed before, and you can know the files needed for porting:
- .config file
- Files under arch/arm/cpu
- board directory
The .config file is generated based on the last two files, so we need to configure the last two directories.
4.1.2 Migrating the board directory
JZ2440 is based on S3C2440, which is Samsung architecture, we can port from other uboot versions that support 2440.
u-boot has introduced the KBuild system since the v2014.10 version, so we query the version in the version shortly after 2014.10, so as to minimize the differences when porting
Download u-boot 2015.01 version code: git clone git://git.denx.de/u-boot.git u-boot
Switch version:
git status
git day
git checkout v2015.01
git diff v2018.03 (compare the source code, you can do it)
Copy board/samsung/smdk2410 to the following directory
1 cp -R smdk2410 / ../../../../../uboot/u-boot- 2018.03 / board / samsung / jz2440
Modify the file:
cd u-boot-2018.03/board/samsung/jz2440
mv smdk2410.c jz2440.c
Modify the makefile:
1 obj-y := jz2440.o 2 obj-y += lowlevel_init.o
jz2440.c file modification:
1 /* arch number of JZ2440-Board */ 2 gd->bd->bi_arch_number = MACH_TYPE_JZ2440;
Note: Modifying the type here must also add this module in another place:
Just change SMDK2440 to JZ2440 directly
1 #define MACH_TYPE_SMDK2460 1007 2 #define MACH_TYPE_JZ2440 1008 3 #define MACH_TYPE_SMDK2412 1009
Kconfig modification:
1 if TARGET_JZ2440 2 3 config SYS_BOARD 4 default "jz2440" 5 6 config SYS_VENDOR 7 default "samsung" 8 9 config SYS_SOC 10 default "s3c24x0" 11 12 config SYS_CONFIG_NAME 13 default "jz2440" 14 15 endif
The current directory has been modified
4.1.3 Arch/arm/cpu/arm920t directory modification
uboot2015.01/u-boot$ cd arch/arm/cpu/arm920t/
u-boot/arch/arm/cpu/arm920t$ cp -R s3c24x0/ ../../../../../../../uboot/u-boot-2018.03/arch/arm/cpu/arm920t/
(1)u-boot-2018.03/arch/arm/cpu/arm920t/Makefile 修改
1 extra-y = start.o 2 3 obj-y += cpu.o 4 5 obj-$(CONFIG_EP93XX) += ep93xx/ 6 obj-$(CONFIG_IMX) += imx/ 7 obj-$(CONFIG_S3C24X0) += s3c24x0/ 8 9 # some files can only build in ARM mode 10 11 ifdef CONFIG_$(SPL_)SYS_THUMB_BUILD 12 CFLAGS_cpu.o := -marm 13 endif
(2) Add header file
Check the s3c24x0.h file and find that it contains a header file: asm/arch/s3c24x0_cpu.h , add this header file.
Find this file in the root directory of uboot2015.01: find . -name s3c24x0_cpu.h
./arch/arm/include/asm/arch-s3c24x0/s3c24x0_cpu.h
From the results found, we need to add the arch-s3c24x0 directory
cp -R arch/arm/include/asm/arch-s3c24x0/ ../../u-boot-2018.03/arch/arm/include/asm/
Just add it in, no need to do other settings
(3) Add in arch/arm/Kconfig
Add on line 1323
1 source "board/samsung/jz2440/Kconfig"
In line 339, it is the option of the target board in menuconfig. In this option, we can add our own board and make it visible in menuconfig
Lines 569~573 add:
1 config TARGET_JZ2440 2 bool "Samsung S3C24X0" 3 select CPU_ARM920T 4 help 5 The S3C24X0 is deperated,but I want to use it.
4.2 Generate .config file
We configure our board with make menuconfig. Or you can use the smdk2410_defconfig in the uboot 2015 version for configuration, you can copy it in.
cp configs/smdk2410_defconfig ../../u-boot-2018.03/configs/jz2440_defconfig
Execute the command make jz2440_defconfig
Then execute make menuconfig to view the configuration. With the appropriate amount of modification, the compilation will definitely go wrong, and then modify it after the error.
4.3 Compiling
4.3.1 .config:138:warning: symbol value '' invalid for SYS_TEXT_BASE
In .config we do not configure the base address of the snippet. First find where this is configured in the original uboot. in include/configs/smdk2410.h
Copy this file into our project: cp include/configs/smdk2410.h ../../u-boot-2018.03/include/configs/jz2440.h
Find the include file, modify it, then check the include/configs/jz2440.h file, and configure make menuconfig
Modify CONFIG_SYS_TEXT_BASE to 0x0 in menuconfig
4.3.2 include/configs/jz2440.h:78:32: fatal error: config_cmd_default.h: No such file or directory
This file does not exist anymore. comment out compile
4.3.3 Duplicate Definitions
(1)include/configs/jz2440.h:84:0: warning: "CONFIG_CMD_ELF" redefined
(2)include/configs/jz2440.h:91:0: warning: "CONFIG_CMDLINE_EDITING" redefined
(3)include/configs/jz2440.h:110:0: warning: "CONFIG_SYS_LONGHELP" redefined
(4)include/configs/jz2440.h:111:0: warning: "CONFIG_SYS_PROMPT" redefined
(5)include/configs/jz2440.h:119:0: warning: "CONFIG_DISPLAY_CPUINFO" redefined
(6)include/configs/jz2440.h:129:0: warning: "CONFIG_LZMA" redefined
Just comment out the lines in the code
4.3.4 Clock function not found
(1)arch/arm/cpu/arm920t/s3c24x0/cpu_info.c:15:2: error: ‘get_FCLK’ undeclared here (not in a function); did you mean ‘get_dacr’?
(2)arch/arm/cpu/arm920t/s3c24x0/cpu_info.c:16:2: error: ‘get_HCLK’ undeclared here (not in a function); did you mean ‘get_FCLK’?
(3)arch/arm/cpu/arm920t/s3c24x0/cpu_info.c:17:2: error: ‘get_PCLK’ undeclared here (not in a function); did you mean ‘get_HCLK’?
It can be known from the file comparison that these three functions are defined in arch/arm/cpu/arm920t/s3c24x0/speed.c, but these functions are not included in the current project version, and they are declared and added in the header file.
Lines 505-510 join
1 /* $(CPU)/speed.c */ 2 int get_clocks (void); 3 ulong get_bus_freq (ulong); 4 int get_serial_clock(void); 5 #if defined(CONFIG_S3C24X0) 6 ulong get_FCLK(void); 7 ulong get_HCLK(void); 8 ulong get_PCLK(void); 9 ulong get_UCLK(void); 10 #endif
4.3.5 Board adaptation problem
board/samsung/jz2440/jz2440.c:100:27: error: ‘MACH_TYPE_JZ2440’ undeclared (first use in this function)
Comparing the code of the 2015 version, you can know that this variable is defined in arch/arm/include/asm/mach-types.h because machine_arch_type is not defined
Add the following code to the file header:
1 #ifndef __ASSEMBLY__ 2 extern unsigned int __machine_arch_type; 3 #endif
Add the following code to the end of the file:
1 #ifdef CONFIG_ARCH_JZ2440 2 # ifdef machine_arch_type 3 # undef machine_arch_type 4 # define machine_arch_type __machine_arch_type 5 # else 6 # define machine_arch_type MACH_TYPE_JZ2440 7 # endif 8 # define machine_is_jz2440() (machine_arch_type == MACH_TYPE_JZ2440) 9 #else 10 # define machine_is_jz2440() (0) 11 #endif
board/samsung/jz2440/jz2440.c plus header file:
#include <asm/mach-types.h>
4.3.6 No such file and directory
(1)cmd/reginfo.c:10:10: fatal error: asm/ppc.h: No such file or directory
#include <asm/ppc.h>
reginfo.c is a command file that prints register information, which can be modified in the common line option in menuconfig
Look for CONFIG_CMD_REGINFO in the source code:
In menuconfig CMD_REGINFO depends on PPC=y, comment out this definition.
(2)cmd/ubi.c: In function ‘display_ubi_info’:
cmd/ubi.c:79:44: error: ‘CONFIG_MTD_UBI_WL_THRESHOLD’ undeclared (first use in this function)
cmd/ubi.c:28:54: note: in definition of macro ‘ubi_msg’
cmd/ubi.c:79:44: note: each undeclared identifier is reported only once for each function it appears in ubi_msg("wear-leveling threshold: %d", CONFIG_MTD_UBI_WL_THRESHOLD);
cmd/ubi.c:28:54: note: in definition of macro ‘ubi_msg’ #define ubi_msg(fmt, ...) printf("UBI: " fmt "\n", ##__VA_ARGS__)
The explanation in the README, the default value is 4096
If MTD_UBI is not enabled in menuconfig, this module can be commented out.
include/configs/jz2440.h 中
(3)cmd/built-in.o: In function `do_fat_fsinfo':
cmd/fat.c:85: undefined reference to `fat_set_blk_dev'
cmd/fat.c:90: undefined reference to `file_fat_detectfs'
The trace code can know that fat_set_blk_dev and file_fat_detectfs are defined in Fat.c (fs\fat), we do not support the fat file system. Turn off this command macro in include/configs/jz2440.h.
Code line 185 comment
(4)drivers/mtd/nand/built-in.o: In function `nand_init_chip':
drivers/mtd/nand/nand.c:94: undefined reference to `board_nand_init'
Comparing the code, you can know that the driver/mtd/nand/s3c2410_nand.c file is not available in the 2018.03 version and is copied into the project.
drivers/mtd/nand$ cp s3c2410_nand.c ../../../../../u-boot-2018.03/drivers/mtd/nand/s3c2440_nand.c
Change the 2410 string in s3c2440_nand.c to 2440
Line 59 in drivers/mtd/nand/Makefile adds:
1 obj-$(CONFIG_NAND_S3C2440) += s3c2440_nand.o
Add in drivers/mtd/nand/Kconfig:
1 config NAND_S3C2440 2 bool "Support for S3c2440 Nand Controller" 3 depends on TARGET_JZ2440 4 imply CMD_NAND 5 help 6 This enables Nand driver support for Nand flash contoller 7 found on S3C2440 Soc.
After the modification is completed, you need to enter the menuconfig to add the configuration.
(5)env/built-in.o: In function `env_flash_save':
env/flash.c:268: undefined reference to `flash_sect_protect'
env/flash.c:276: undefined reference to `flash_sect_erase'
env/flash.c:280: undefined reference to `flash_write'
env/flash.c:303: undefined reference to `flash_sect_protect'
env/flash.c:298: undefined reference to `flash_perror'
The tracking code can know that the CONFIG_MTD_NOR_FLASH macro is not defined, just open the macro
4.3.7 Rules issues
(1)make[1]: *** No rule to make target 'arch/arm/dts/unset.dts', needed by 'arch/arm/dts/unset.dtb'.
Makefile:879: recipe for target 'dts/dt.dtb' failed
Take a look at the top-level Makefile:
Compiled into dts here, we don't support dts and we have to kill it
make menuconfig 中,
Device Tree Control kill
The value of Path to dtc binary for use within mkimage is set to empty
4.3.8 Macro definition problem
Error: You must add new CONFIG options using Kconfig
The following new ad-hoc CONFIG options were detected:
CONFIG_JZ2440
CONFIG_NAND_S3C2410
CONFIG_RTC_S3C24X0
CONFIG_S3C2410
CONFIG_S3C24X0
CONFIG_S3C24X0_SERIAL
CONFIG_SMDK2410
CONFIG_SYS_HUSH_PARSER
CONFIG_SYS_S3C2410_NAND_HWECC
CONFIG_USB_OHCI_S3C24XX
CONFIG_ZERO_BOOTDELAY_CHECK
Comment out the following lines in the top-level Makefile:
Compile after clean.
Compilation is complete and u-boot.bin is generated.
4.3.8 Driver problem
(1)cmd/date.c:52:12: warning: implicit declaration of function ‘I2C_GET_BUS’;
(2)cmd/date.c:53:2: warning: implicit declaration of function ‘I2C_SET_BUS’;
(3)cmd/date.c:53:14: error: ‘CONFIG_SYS_RTC_BUS_NUM’ undeclared
The function problem is because CONFIG_DM_I2C_COMPAT is not defined, that is, the I2C module is not turned on. If CONFIG_SYS_I2C or CONFIG_DM_RTC is turned on, it will not take that branch.
We directly turn off the CONFIG_DM_I2C module
(4)drivers/spi/built-in.o: In function `dev_read_u32_default'
DM module problem, turn off the DM module.
(5)rivers/serial/serial.c:379: undefined reference to `default_serial_console'
Comparing the code, you can know that the serial_s3c24x0.c file is missing, copy it in, and modify the Makefile
drivers/serial$ cp serial_s3c24x0.c ../../../../u-boot-2018.03/drivers/serial/
The modification is completed, and the complete u-boot.bin file can be compiled. When doing code analysis and porting later, some things still need to be modified
The current .bin file is too large, close to 350K