uboot2015.10 移植過程
Arch: arm
Soc: am3352
Board: 與Beaglebone Black相似,emmc替換爲Nand
目錄結構說明
├── api // 機器架構相關的用於應用編程的獨立API
├── arch // 架構相關的文件
├── board // 板級相關的文件
├── common // 獨立於架構的misc類文件
├── configs // 板級配置文件放置目錄
├── disk // 磁盤相關的驅動器分區處理代碼
├── doc // 文檔目錄
├── drivers // Uboot驅動文件目錄
├── dts // dts目錄,用於編譯Uboot fdt
├── examples // 獨立應用程序的示例代碼
├── fs // 文件系統相關代碼
├── include // 頭文件存放目錄
├── lib // 適用於所有架構
├── Licenses // License
├── net // 網絡相關的文件
├── post // Power on self test
├── scripts // 腳本目錄
├── spl // spl 相關
├── test // test相關
└── tools // 用於編譯生產Uboot的工具
從目錄結構分析,與移植相關的目錄有:arch、board、configs、include
移植
board
board目錄下的結構爲board/vendor/boardname
vendor: 供應商名(sluan)
boardname: 開發板名(ant)
創建目錄:mkdir -p board/sluan/ant
拷貝板級文件:cp board/ti/am335x/* board/sluan/ant/
修改u-boot.lds的text域中的built-in.o的路徑爲:board/sluan/ant/built-in.o (.text*)
修改Kconfig內容爲:
if TARGET_AM335X_ANT
config SYS_BOARD
default "ant"
config SYS_VENDOR
default "sluan"
config SYS_SOC
default "am33xx"
config SYS_CONFIG_NAME
default "am335x_ant"
config CONS_INDEX
int "UART used for console"
range 1 6
default 1
help
The AM335x SoC has a total of 6 UARTs (UART0 to UART5 as referenced
in documentation, etc) available to it. Depending on your specific
board you may want something other than UART0 as for example the IDK
uses UART3 so enter 4 here.
config NOR
bool "Support for NOR flash"
help
The AM335x SoC supports having a NOR flash connected to the GPMC.
In practice this is seen as a NOR flash module connected to the
"memory cape" for the BeagleBone family.
config NOR_BOOT
bool "Support for booting from NOR flash"
depends on NOR
help
Enabling this will make a U-Boot binary that is capable of being
booted via NOR. In this case we will enable certain pinmux early
as the ROM only partially sets up pinmux. We also default to using
NOR for environment.
endif
configs
拷貝板級配置文件:cp am335x_boneblack_defconfig am335x_ant_defconfig
修改板級配置文件內容爲:
CONFIG_SPL=y
CONFIG_SYS_EXTRA_OPTIONS="NAND"
CONFIG_CONS_INDEX=1
+S:CONFIG_ARM=y
+S:CONFIG_TARGET_AM335X_ANT=y
arch
修改arch/arm/Kconfig,在內容中添加ant
開發板的Kconfig支持和board路徑:
config TARGET_AM335X_ANT
bool "Support am335x_ant"
select CPU_V7
select SUPPORT_SPL
source "board/sluan/ant/Kconfig"
include
添加板級頭文件: cp include/configs/am335x_evm.h include/configs/am335x_ant.h
修改am335x_ant.h
中關於鏈接腳本的路徑爲:
#define CONFIG_SYS_LDSCRIPT "board/sluan/ant/u-boot.lds"
開發板相關代碼修改
TI的Beaglebone Black開發板上有EEPROM,其存儲了板級的信息用於用於根據板級信息選擇不同的參數初始化相關硬件,我們的ANT開發板沒有EEPROM,因此需要修改EEPROM相關代碼。
修改board/sluan/ant/board.c中的read_eeprom函數爲:
static int read_eeprom(struct am335x_baseboard_id *header)
{
header->magic = 0xEE3355AA; // 設置魔數
strcpy(header->name, "A335BNLT"); // 將板級信息中的名字設置爲Beaglebone Black
return 0;
}
ANT開發板使用Nand替換了Beaglebone Black的Emmc,因此需要配置Nand的相關引腳初始化
修改board/sluan/ant/mux.c中的enable_board_pin_mux函數爲:
void enable_board_pin_mux(struct am335x_baseboard_id *header)
{
/* Do board-specific muxes. */
if (board_is_bone(header)) {
/* Beaglebone pinmux */
configure_module_pin_mux(i2c1_pin_mux);
configure_module_pin_mux(mii1_pin_mux);
configure_module_pin_mux(mmc0_pin_mux);
#if defined(CONFIG_NAND)
configure_module_pin_mux(nand_pin_mux);
#elif defined(CONFIG_NOR)
configure_module_pin_mux(bone_norcape_pin_mux);
#else
configure_module_pin_mux(mmc1_pin_mux);
#endif
} else if (board_is_gp_evm(header)) {
/* General Purpose EVM */
unsigned short profile = detect_daughter_board_profile();
configure_module_pin_mux(rgmii1_pin_mux);
configure_module_pin_mux(mmc0_pin_mux);
/* In profile #2 i2c1 and spi0 conflict. */
if (profile & ~PROFILE_2)
configure_module_pin_mux(i2c1_pin_mux);
/* Profiles 2 & 3 don't have NAND */
#ifdef CONFIG_NAND
if (profile & ~(PROFILE_2 | PROFILE_3))
configure_module_pin_mux(nand_pin_mux);
#endif
else if (profile == PROFILE_2) {
configure_module_pin_mux(mmc1_pin_mux);
configure_module_pin_mux(spi0_pin_mux);
}
} else if (board_is_idk(header)) {
/* Industrial Motor Control (IDK) */
configure_module_pin_mux(mii1_pin_mux);
configure_module_pin_mux(mmc0_no_cd_pin_mux);
} else if (board_is_evm_sk(header)) {
/* Starter Kit EVM */
configure_module_pin_mux(i2c1_pin_mux);
configure_module_pin_mux(gpio0_7_pin_mux);
configure_module_pin_mux(rgmii1_pin_mux);
configure_module_pin_mux(mmc0_pin_mux_sk_evm);
} else if (board_is_bone_lt(header)) {
/* Beaglebone LT pinmux */
configure_module_pin_mux(i2c1_pin_mux);
configure_module_pin_mux(mii1_pin_mux);
configure_module_pin_mux(mmc0_pin_mux);
#if defined(CONFIG_NAND) && defined(CONFIG_EMMC_BOOT)
configure_module_pin_mux(nand_pin_mux);
#elif defined(CONFIG_NOR) && defined(CONFIG_EMMC_BOOT)
configure_module_pin_mux(bone_norcape_pin_mux);
#elif defined(CONFIG_NAND) // 增加的代碼
configure_module_pin_mux(nand_pin_mux); // 初始化Nand相關的引腳
#else
configure_module_pin_mux(mmc1_pin_mux);
#endif
} else {
puts("Unknown board, cannot configure pinmux.");
hang();
}
}
編譯、燒錄及運行
在uboot根目錄下編譯:make am335x_ant_defconfig && make -j8
燒錄至SD卡:
sudo dd iflag=dsync oflag=dsync if=MLO of=/dev/sdb seek=0
sudo dd iflag=dysnc oflag-dsync if=u-boot.img of=/dev/sdb seek=768
MLO的燒錄地址可以爲0x0\0x20000\0x40000\0x60000,seek大小爲0x200,因此燒錄MLO的seek可爲0\256\512\768
u-boot.img的燒錄地址在include/configs/ti_armv7_common.h中:
#define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR 0x300 /* address 0x60000 */
因此燒錄u-boot.img的seek爲768
運行結果: