移植的核心思想介紹
我們在實際項目開發過程中,更多的時候是用芯片做產品。IMX6ULL芯片在被設計出來的時候,NXP芯片廠家會根據芯片定制開發板EVK來測試芯片的功能。NXP的原廠工程師會為EVK開發板移植u-boot,我們開發的智能小車是用NXP的IMX6ULL芯片定制的開發板,在設計的時候是參照EVK開發板來定制的。所以在為智能小車的開發板移植u-boot的時候,可以參照NXP的EVK開發板的u-boot來進行移植。
硬件平臺信息
開發板 SmartCar開發板,根據NXP的EVK開發板來設計
SOC IMX6ULL
CPU ARM Cortex-A7 ,ARMV7架構
u-boot中添加自己的開發板
1.清空源碼目錄
uboot-imx-rel_imx_4.1.15_2.1.0_ga$ make distclean
2.添加開發板默認配置文件
在u-boot源碼下的configs目錄下添加mx6ull_smartcar_defconfig配置文件
uboot-imx-rel_imx_4.1.15_2.1.0_ga/configs$ cp mx6ull_14x14_evk_defconfig
mx6ull_smartcar_defconfig
將mx6ull_smartcar_defconfig修改如下內容:
CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/smartcar/imximage.cfg"
CONFIG_ARM=y
CONFIG_ARCH_MX6=y
CONFIG_TARGET_MX6ULL_SMARTCAR=y
CONFIG_CMD_GPIO=y
3.添加開發板目錄
在u-boot源碼下的board/freescale目錄下添加smartcar開發板
uboot-imx-rel_imx_4.1.15_2.1.0_ga/board/freescale$ cp mx6ullevk smartcar -a
進入smartcar目錄下,將mx6ullevk.c修改成smartcar.c。
修改smartcar目錄下的Makefile,修改如下:
# (C) Copyright 2015 Freescale Semiconductor, Inc.
#
# SPDX-License-Identifier: GPL-2.0+
#
obj-y := smartcar.o
extra-$(CONFIG_USE_PLUGIN) := plugin.bin
$(obj)/plugin.bin: $(obj)/plugin.o
$(OBJCOPY) -O binary --gap-fill 0xff $< $@
修改smartcar目錄下的imximage.cfg文件的第34行,修改如下:
4.添加開發板頭文件
在u-boot源碼目錄下的include/configs目錄下添加smartcar.h
uboot-imx-rel_imx_4.1.15_2.1.0_ga/include/configs$ cp mx6ullevk.h smartcar.h
修改頭部宏開關:
修改136行fdt_file內容如下:
5.修改Kconfig文件
進入u-boot源碼的arch/arm/cpu/armv7/mx6目錄下,修改Kconfig文件內容如下:
添加自己的開發板的配置選項:
添加包含自己開發板的Kconfig文件:
進入u-boot源碼的board/freescale/smartcar目錄下,修改Kconfig文件內容如下:
if TARGET_MX6ULL_SMARTCAR
config SYS_BOARD
default "smartcar"
config SYS_VENDOR
default "freescale"
config SYS_CONFIG_NAME
default "smartcar"
endif
三、配置編譯及測試
配置
uboot-imx-rel_imx_4.1.15_2.1.0_ga$ make mx6ull_smartcar_defconfig
2.編譯
uboot-imx-rel_imx_4.1.15_2.1.0_ga$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
3 測試
將源碼目錄下的u-boot.bin到tftpboot目錄下,然后通過開發板上的u-boot通過tftp下載測試:
=> tftp 878000000 u-boot.bin
Using FEC0 device
TFTP from server 192.168.1.100; our IP address is 192.168.1.200
Filename 'u-boot.bin'.
Load address: 0x78000000
Loading: #############################
2.7 MiB/s
done
Bytes transferred = 416472 (65ad8 hex)
=> go 87800000
更新板子里面的u-boot
A、切換到emmc 的第0分區
=> mmc dev 1 0
switch to partitions #0, OK
mmc1(part 0) is current device
=>
B、從tftp下載 u-boot.imx 到內存 80800000
=> tftp 80800000 u-boot.imx
Using FEC0 device
TFTP from server 192.168.3.25; our IP address is 192.168.3.22
Filename 'u-boot.imx'.
Load address: 0x80800000
Loading: #########################
1.7 MiB/s
done
Bytes transferred = 363520 (58c00 hex)
=>
C、將內存的數據寫到emmc的第0分區第2個塊
為什么是 2C6 ?上一步驟我們下載的u-boot.imx為 363520 個字節,353520/512=710塊,十六進制為2C6
(如果有小數需要+1)
=> mmc write 80800000 2 2C6
MMC write: dev # 1, block # 2, count 710... 710blocks written: OK
=>
4、分區設置
mmc partconf dev boot_ack boot_partition partition_access
- Change the bits of the PARTITION_CONFIG field of the specified device
=> mmc partconf 1 1 0 0
=>
5、重啟
=> reset
resetting ...
注意:
不要寫 SD 卡或者 EMMC 的前兩個塊(扇區),里面保存著分區表!