【u-boot-2016到s5pv210】1.1 自定义板卡ok210

由上一节,已经下载了u-boot-2016.09.01的源码,并知道了u-boot.bin和u-boot-spl.bin的生成过程,那么本章主要解决如下问题:

1 怎样为一个新板定义uboot

2 关键流程

3 验证移植是否成功

一、怎样定义一个新的板卡

最好的老师,就是源码中的doc文档,在/doc/README.kconfig文档中,有如下说明 :

When adding a new board, the following steps are generally needed:

 [1] Add a header file include/configs/<target>.h
 [2] Make sure to define necessary CONFIG_SYS_* in Kconfig:
       Define CONFIG_SYS_CPU="cpu" to compile arch/<arch>/cpu/<cpu>
       Define CONFIG_SYS_SOC="soc" to compile arch/<arch>/cpu/<cpu>/<soc>
       Define CONFIG_SYS_VENDOR="vendor" to compile board/<vendor>/common/*
         and board/<vendor>/<board>/*
       Define CONFIG_SYS_BOARD="board" to compile board/<board>/*
         (or board/<vendor>/<board>/* if CONFIG_SYS_VENDOR is defined)
       Define CONFIG_SYS_CONFIG_NAME="target" to include
         include/configs/<target>.h
 [3] Add a new entry to the board select menu in Kconfig.
     The board select menu is located in arch/<arch>/Kconfig or
     arch/<arch>/*/Kconfig.
 [4] Add a MAINTAINERS file
     It is generally placed at board/<board>/MAINTAINERS or
     board/<vendor>/<board>/MAINTAINERS
 [5] Add configs/<target>_defconfig

二 增加新板配置

1 增加板卡,在board/samsung目录下,增加smdkv210目录,即复制smdkc100目录,分别修改如下文件:

(1)Kconfig

if TARGET_SMDKV210

config SYS_BOARD
	default "smdkv210"
config SYS_VENDOR
	default "samsung"
config SYS_SOC
	default "s5pc1xx"
config SYS_CONFIG_NAME
	default "smdkv210"
endif


(1)这几个宏,在make ok210_defconfig的时候,会生成对应的CONFIG_对应项的宏,在.config文件中

(2)这几个宏,分别指定了编译时,选择的路径

SYS_ARCH指定编译路径为arch/<CONFIG_SYS_ARCH>

SYS_CPU指定编译路径为arch/<CONFIG_SYS_ARCH>/cpu/<CONFIG_SYS_CPU>

SYS_SOC指定编译路径为arch/<CONFIG_SYS_ARCH>/cpu/<CONFIG_SYS_CPU>/<CONFIG_SYS_SOC>.

SYS_VENDOR指定编译路径为 board/<CONFIG_SYS_VENDOR>/common//*或board/<CONFIG_SYS_VENDOR>/<CONFIG_SYS_BOARD>/*

SYS_BOARD指定编译路径为board/<CONFIG_SYS_BOARD>/*或如果指定SYS_VENDOR,则为board/<CONFIG_SYS_VENDOR>/<CONFIG_SYS_BOARD>//* 

SYS_CONFIG_NAME如果定义,include/config.h包含include/configs/<CONFIG_SYS_CONFIG_NAME>.h


(2)lowlevel_init

	.globl lowlevel_init
lowlevel_init:
	mov	r9, lr

	mov	lr, r9
	mov	pc, lr


	mov	pc, lr

(3)smdkv210.c文件


(4)MAINTAINERS

SMDKV210 BOARD
M:	Minkyu Kang <mk7.kang@samsung.com>
S:	Maintained
F:	board/samsung/smdkv210/
F:	include/configs/smdkv210.h
F:	configs/smdkv210_defconfig

2 增加配置文件 smdkc100_defconfig

CONFIG_ARM=y
CONFIG_ARCH_S5PC1XX=y
CONFIG_TARGET_SMDKV210=y
CONFIG_DEFAULT_DEVICE_TREE="s5pv210-smdkv210"
CONFIG_HUSH_PARSER=y
CONFIG_SYS_PROMPT="SMDKV210 # "
# CONFIG_CMD_IMLS is not set
# CONFIG_CMD_FLASH is not set
# CONFIG_CMD_SETEXPR is not set
CONFIG_CMD_CACHE=y
CONFIG_CMD_FAT=y

3 增加头文件

将C100修改成V210


4 增加

1 首先执行第3步,在arch/<arch>/Kconfig或arch/<arch>/*/Kconfig增加自己板卡menu,在此我们在/arch/arm/mach-s5pc1xx/Kconfig中,增加如下所示:

config TARGET_SMDKV210
	bool "Support Samsung smdkv210"
	select SUPPORT_SPL
	select SPL
		help
		Support Samsung OK210 platform based on Samsung s5pv210.

同时指定自定义板卡路径

source "board/samsung/smdkv210/Kconfig"


三 完善配置

1 执行make smdkv210_defconfig没有出错


2 执行编译

make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi-

出错

arch/arm/cpu/armv7/built-in.o: In function `print_cpuinfo':
/home/rabbit/work/samba/xuboot/u-boot-2016.05/arch/arm/cpu/armv7/s5p-common/cpu_info.c:40: undefined reference to `fdt_getprop'
drivers/gpio/built-in.o: In function `gpio_exynos_bind':
/home/rabbit/work/samba/xuboot/u-boot-2016.05/drivers/gpio/s5p_gpio.c:331: undefined reference to `fdt_first_subnode'
/home/rabbit/work/samba/xuboot/u-boot-2016.05/drivers/gpio/s5p_gpio.c:339: undefined reference to `fdtdec_get_bool'
/home/rabbit/work/samba/xuboot/u-boot-2016.05/drivers/gpio/s5p_gpio.c:345: undefined reference to `fdt_get_name'
/home/rabbit/work/samba/xuboot/u-boot-2016.05/drivers/gpio/s5p_gpio.c:333: undefined reference to `fdt_next_subnode'
drivers/serial/built-in.o: In function `s5p_serial_ofdata_to_platdata':

和设备树操作有关,打开配置文件的设备树相关配置

CONFIG_OF_LIBFDT=y
CONFIG_OF_CONTROL=y
CONFIG_CMD_FDT=y

编译出错

Device Tree Source is not correctly specified.
Please define 'CONFIG_DEFAULT_DEVICE_TREE'
or build with 'DEVICE_TREE=<device_tree>' argument

dts/Makefile:27: recipe for target 'arch/arm/dts/s5pv210-smdkv210.dtb' failed
make[1]: *** [arch/arm/dts/s5pv210-smdkv210.dtb] Error 1
Makefile:821: recipe for target 'dts/dt.dtb' failed
make: *** [dts/dt.dtb] Error 2

配置设备树文件


dtb-$(CONFIG_TARGET_SMDKV210) += s5pv210-smdkv210.dtb

再次编译出错

arch/arm/lib/built-in.o: In function `_main':
/home/rabbit/work/samba/xuboot/u-boot-2016.05/arch/arm/lib/crt0.S:93: undefined reference to `board_init_f'
scripts/Makefile.spl:247: recipe for target 'spl/u-boot-spl' failed
make[1]: *** [spl/u-boot-spl] Error 1
Makefile:1334: recipe for target 'spl/u-boot-spl' f

定义spl中的函数

#ifdef CONFIG_SPL_BUILD

void board_init_f(ulong bootflag)
{
	
}

#endif

再次编译出错:

./tools/mkexynosspl  spl/u-boot-spl.bin spl/smdkv210-spl.bin
make[1]: ./tools/mkexynosspl: Command not found
scripts/Makefile.spl:213: recipe for target 'spl/smdkv210-spl.bin' failed
make[1]: *** [spl/smdkv210-spl.bin] Error 127
Makefile:1334: recipe for target 'spl/u-boot-spl' failed
make: *** [spl/u-boot-spl] Error 2

为SPL增加头文件

(1)在tools中的Makefile文件中加入


(2)在scripts中的Makefile.spl中加入


再次编译编译通过



总结:

1 在ok210.c中,增加board_init、dram_init、board_init_f函数的定义

2 在lowlevel.s中,增加lowlevel_init函数的定义

3 在script/Makefile.spl中,增加u-boot-spl.bin的头工具mksmdkv210spl


四 验证

 将上一节的led程序,加到arch/arm/cpu/armv7/start.s中,做如下修改版 




烧写后,查看是否点灯

sudo dd bs=512 if=spl/ok210-spl.bin of=/dev/sdb seek=1


©️2020 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页