【免费下载】am335x uboot移植
am335x_linux-3.14.43内核移植笔记

本文主要描述在EVB335X-II以Device Tree的方式移植新TI官网AM335X系列最新的linux-3.14.43版本内核以及移植Debian文件系统的过程及遇到的一些问题。
整个Device Tree牵涉面比较广,即增加了新的用于描述设备硬件信息的文本格式(即.dts文件),又增加了编译这一文本的工具,同时Bootloader也需要支持将编译后的Device Tree传递给Linux内核。
以下是修改步骤:一、修改uboot,支持Device TreeEVB335X-II在linux-3.2版本内核移植的时候已经有uboot,因此只需在该uboot上增加Device Tree支持即可,以下是修改步骤:1、修改include/configs/com335x.h文件,增加支持DT的宏定义:/* Flattened Device Tree */#define CONFIG_OF_LIBFDT2、修改uboot启动参数,增加dtb文件的加载和启动(由于目前只是移植EMMC版本的EVB335X-II,因此只需修改EMMC的启动参数即可,大概在405行),修改如下:#elif defined(CONFIG_EMMC_BOOT)#define CONFIG_BOOTCOMMAND \"run mmcboot;"#define CONFIG_EXTRA_ENV_SETTINGS \"lcdtype=AUO_AT070TN94\0" \"console=ttyO0,115200n8\0" \"mmcroot=/dev/mmcblk0p2 rw\0" \"mmcrootfstype=ext4 rootwait\0" \"mmcargs=setenv bootargs console=${console} noinitrd root=${mmcroot} rootfstype=${mmcrootfstype} lcdtype=${lcdtype} consoleblank=0\0" \"mmcdev=" MMCDEV "\0" \"loadaddr=0x81000000\0" \"dtbfile=evb335x-ii-emmc.dtb\0" \"bootenv=uEnv.txt\0" \"bootpart=" BOOTPART "\0" \"loadbootenv=load mmc ${mmcdev} ${loadaddr} ${bootenv}\0" \"importbootenv=echo Importing environment from mmc ...; " \"env import -t $loadaddr ${filesize}\0" \"loadaddr-dtb=0x82000000\0" \"loadimage=load mmc ${bootpart} ${loadaddr} uImage\0" \"loaddtb=load mmc ${bootpart} ${loadaddr-dtb} ${dtbfile}\0" \"mmcboot=mmc dev ${mmcdev}; " \"if mmc rescan; then " \"echo SD/MMC found on device ${mmcdev};" \"if run loadbootenv; then " \"echo Loaded environment from ${bootenv};" \"run importbootenv;" \"fi;" \"run mmcargs;" \"if run loadimage; then " \"run loaddtb;" \"bootm ${loadaddr} - ${loadaddr-dtb};" \"fi;" \"fi; \0"#endif以上,红色为修改部分。
AM335x 处理器 SDK RTOS 板库端口和启动说明书

Board Porting\Bring up using Processor SDK RTOS for AM335xProcessor SDK RTOS component known as board library consolidates all the board-specific information so that all the modifications made when moving to a new custom platform using the SOC can be made in the source of this library.There are three different components in PRSDK that help in porting and bring up of a custom board:∙Board library updatesa.PLL Clocking and PRCMb.Pin mux Updatec.DDR Configurationd.Peripheral instances updates∙Diagnostics tests∙Boot loader updatesBoard Library Updates in Processor SDK RTOS:PLL ClockingThere are two places where the device PLL configurations are performed when using Processor SDK RTOS and CCS.Debug environment:Debug environment refers to development setup where code is debugged using JTAG emulator on the SOC. The PRSDK software relies on the GEL file that is part of the target configuration to setup the clocks and the DDR for the device. The CCS GEL file for AM335x platforms is located in the CCS package at the location ccsv7\ccs_base\emulation\boards\<boardName>For example for beagle bone black, the files can be found atccsv7\ccs_base\emulation\boards\beaglebone\gelThe GEL is the first piece of software that should be brought up on a custom board.Production environment:Production environment refers to the setup when the base application is booted from a boot media like a flash memory or host interface. In this environment, the bootloader sets performs all the SOC and board initialization and copies the application from flash memory to the device memory.The clock setup in the bootloader code can be located atpdk_am335x_x_x_x\packages\ti\starterware\bootloader\src\am335xUsers can choose to use the platform clocking similar to one of TI reference platforms or can modify them as per their application requirements. By default the PLL settings are setup for OPP_NOM settings (MPU= 600 MHz.)TI provides Clock Tree tool to allow users to simulate the clocking on the SOC. For quick reference of the multiplier and divider settings to change the PLL setting is provided in the spreadsheetAM335x_DPLL_CALCv3.xlsx.After modifying the clocking in the bootloader, users need to rebuild the bootloader using instructions provided in Processor_SDK_RTOS_BOOT_AM335x/AM437xPRCM Modules Enable:PRCM Module Enable is required to turn on the power domain and the clocking to each of the modules on the SOC. The PRCM Enable calls to enable each module are made from the functionBoard_moduleClockInit which is found in the location.pdk_am335x_1_0_9\packages\ti\board\src\bbbAM335x\bbbAM335x.cCheck every instance and peripheral required in the application platform and enable the module in the board library.For example to use three UARTs 0, 1 and 4, ensure that you have the following code as part of the board library setup:/* UART */status = PRCMModuleEnable(CHIPDB_MOD_ID_UART, 0U, 0U);status = PRCMModuleEnable(CHIPDB_MOD_ID_UART, 1U, 0U);status = PRCMModuleEnable(CHIPDB_MOD_ID_UART, 4U, 0U);Note: PRCMEnable function is defined in pdk_am335x_1_0_9\packages\ti\starterware\soc\am335x Pinmux updates in the Board library:Generating a New PinMux Configuration Using the PinMux Utility: This procedure uses the cloud-based pinmux utilityNavigate to ${PDK_INSTALL_DIR}\packages\ti\starterware\tools\pinmux_config\am335x and Load beaglebone_black_configAdd and remove peripheral instances and select the appropriate use cases required for development based on the application platform requirements and resolve all conflicts.Refer Pin_Mux_Utility_for_ARM_MPU_ProcessorsPost Processing steps:1.Change the Category filter to starterware and download the pinmux files am335x_pimnmux.hand am335x_pinmux_data.c2.At the bottom of am335x_pinmux.h change extern pinmuxBoardCfg_t gAM335xPinmuxData[];to extern pinmuxBoardCfg_t gBbbPinmuxData[];3.Change am335x_pinmux_data.c to am335x_beagleboneblack_pinmux_data.c.4.Change gAM335xPinmuxData to gBbbPinmuxData at the end of the file in file5.am335x_beagleboneblack_pinmux_data.c.Replace the existing files with the new files and rebuild the board library using the instructions in the section Rebuilding board Library in Processor SDK RTOS:Updating DDR settings:Similar to clock and PLL settings, DDR initialization is configured in the Debug environment through GEL files and in production environment using bootloader source files.TI provides AM335x_EMIF_Configuration_tips which contains a spreadsheet to enter the timing from the DDR datasheet to compute the EMIF timing number required to initialize DDR.We strongly recommend changing the value and testing using GEL files before using them in the bootloader software. For Sanity test, you can perform read/write tests using CCS Memory Browser or run the diagnostic memory read/write test that we provide in diagnostics package here:PDK_INSTALL_PATH\packages\ti\board\diag\memOnce the DDR timings have been confirmed, you can use the settings in the file:PDK_INSTALL_PATH \packages\ti\starterware\bootloader\src\am335x\sbl_am335x_platform_ddr.c Peripheral initialization:The board library is responsible for most of the SOC initialization but it also setup some board level components such as ethernet PHY and debug UART and I2C for reading board ID from EEPROM. All of the other peripheral instances and initialization needs to be done from the application level.For example for beagleboneblack, the peripheral initialization are performed from the source filepdk_am335x_1_0_9\packages\ti\board\src\bbbAM335x\bbbAM335x_lld_init.cThe debug UART instance, I2C Addresses are set using the file board_cfg.h found under:pdk_am335x_1_0_9\packages\ti\board\src\bbbAM335x\includeDefault UART instance is set to 0 in the board library. The Board initialization will configure the UART instance 0 to send binary log data to serial console using the Board_UARTInit function. If you wish to use more UART instances then we recommend linking in the UART driver in the application and using UART_open() and UART_stdioInit API calls from the application.Each peripheral driver in the Processor SDK RTOS has a SOC configuration that provides the interrupt numbers, base address, EDMA channels which can be updated using the file <peripheral>_soc.c file. This is used as default setup for initializing the driver instance. It can be overridden from the application using peripheral_getSOCInitCfg() and peripheral_setSOCInitCfg()For Example: All instances of UART for AM335x have been mapped in the filepdk_am335x_1_0_9\packages\ti\drv\uart\soc\am335x\UART_soc.cSystem integrators need to ensure that no interrupt numbers and EDMA resource conflicts exist in the SOC configuration for all drivers used in the system.To exercise three UARTs in the system, users can use the following code://Setup Debug UARTboardCfg = BOARD_INIT_PINMUX_CONFIG |BOARD_INIT_MODULE_CLOCK |BOARD_INIT_UART_STDIO;Board_init(boardCfg);// Open Additional UART Instances:/* UART SoC init configuration */UART_initConfig(false);/* Initialize the default configuration params. */UART_Params_init(&uartParams);// Open UART Instance 1uartTestInstance =1;uart1 = UART_open(uartTestInstance, &uartParams);//Open UART Instance 4uartTestInstance = 4;uart4 = UART_open(uartTestInstance, &uartParams);BoardID Detect:TI supports multiple evaluation and reference platforms for AM335x hence the hardware platforms are populated with an EEPROM which contains information that identifies the hardware and its revision. The board library and software components read the boardID and initialize the platform based on the boardID. The BoardID_detect function can be found in the source in the file bbbAM335x_info.c in the board library and board_am335x.c in the bootloader source at:<PDK_INSTALL_PATH>\packages\ti\starterware\board\am335xRebuilding board Library in Processor SDK RTOS:While Creating a new folder for the custom board is an option users can explore, TI recommends that users make there changes in existing board package using either bbbAM335x, evmAM335x oriceAM335x folder to avoid spending additional effort to modify the build files for including the customBord.Once all the update to the board library are completed, the board library can be updated using the following instructions.Instructions to rebuild board library:Setup Processor SDK build environment before following steps provided below.cd pdk_am335x_1_0_9\packagesgmake board_libFor a specific board users are required to provide the LIMIT_BOARDS argument.LIMIT_BOARDS : evmAM335x icev2AM335x iceAMIC110 bbbAM335x skAM335xFor Example for beagleboneblack, users can use the following build option:gmake board_lib LIMIT_BOARDS=bbbAM335xDiagnostics:After the board library is built, we highly recommend that you create a diagnostics package similar to one provided in board library to test different interfaces functionally during board bring up.The diagnostics package can be located at pdk_am335x_1_0_9\packages\ti\board\diag. These are simple bare-metal tests that use peripheral drivers to help functionally validate the pins and interfaces.Documentation for all available diagnostic tests is provided here:/index.php/Processor_SDK_RTOS_DIAGBootloader in Processor SDK RTOS:As part of the production flow, users are required to develop/port flashing and booting utilities so the application can be launched on the custom board with JTAG. TI provides a bootloader mechanism where the ROM bootloader loads a secondary bootloader on the onchip memory that initializes the SOC and DDR and then copies the application into DDR memory.The boot process and flashing tools have been described in detail in the following article that is part of processor SDK RTOS Software developer`s guide:/index.php/Processor_SDK_RTOS_BOOT_AM335x/AM437x#Building_the_B ootloader。
AM335xU-BootUsersGuide中文手册

AM335xU-BootUsersGuide中⽂⼿册AM335x U-Boot User's Guide /****************************************************************** * author: 卢浩* time: 2012.09.12* environment: ubuntu10.04LTS +TI AM3359* kernel version: linux-3.2* Official Website:/doc/783206ed551810a6f5248646.html/doc/783206ed551810a6f5248646.html* QQ Group For Technology Exchange:122879839******************************************************************/ 风核科技出品—AM3359系列搭建uboot开发环境进⼊官⽅提供的SDK包的uboot⽬录$ cd ./AM335x-LINUX-PSP-MM.mm.pp.bb/src/u-boot/u-boot-MM.mm.pp.bb编译⼝令$ [ -d ./am335x ] && rm -rf ./am335x$ make O=am335x CROSS_COMPILE=arm-arago-linux-gnueabi- ARCH=arm am335x_evm编译完成将会⽣成可执⾏性⽂件MLO和u-boot.img。
主机配置:⽤串⼝线把主机和EVM板连接起来,设置超级终端参数如下:*Baud rate: 115,200*Data bits: 8*Parity: None*Stop bits: 1*Flow control: None开发板配置:设置启动⽅式:请注意,红⾊位置为off,绿⾊位置为on Nand启动,请设置拨码开关如下:SPI启动,请设置拨码开关如下:UART启动,请设置拨码开关如下:SD启动,请设置拨码开关如下:CPSW启动,请设置拨码开关如下:注意,从CPSW启动这样设置是因为EVM板⽤的是RGMII mode。
AM335x uboot spl分析

AM335x uboot spl分析芯片到uboot启动流程ROM → SPL→ uboot.img简介在335x 中ROM code是第一级的bootlader。
mpu上电后将会自动执行这里的代码,完成部分初始化和引导第二级的bootlader,第二级的bootlader引导第三级bootader,在ti官方上对于第二级和第三级的bootlader由uboot提供。
SPLTo unify all existing implementations for a secondary program loader (SPL) and to allow simply adding of new implementations this generic SPL framework has been created. With this framework almost all source files for a board can be reused. No code duplication or symlinking is necessary anymore.1> Basic ARM initialization2> UART console initialization3> Clocks and DPLL locking (minimal)4> SDRAM initialization5> Mux (minimal)6> BootDevice initialization(based on where we are bootingfrom.MMC1/MMC2/Nand/Onenand)7> Bootloading real u-boot from the BootDevice and passing control to it.uboot spl源代码分析一、makefile分析打开spl文件夹只有一个makefile 可见spl都是复用uboot原先的代码。
AM335x Flash Tool -- UniFlash 烧写工具使用简介及问题解决方案汇总

AM335x Flash Tool -- UniFlash 烧写工具使用简介及问题解决方案汇总大家好,目前很多人都在关注AM335x flash tool(UniFlash)的进展情况,这篇文章会对当前的进展情况进行汇总,并就客户使用过程中遇到的一些问题,给出了相应的解决方案。
目前的UniFlash官方发布的版本中,仅支持NAND FLASH的烧录,近期版本中将会更新对eMMC烧录功能的支持。
UniFlash的下载地址:/index.php/NowFlash%E2%84%A2_Programming_ToolUniFlash的主机端安装用户指南:/index.php/Sitara_Uniflash_Quick_Start_GuideUniFlash的image编译,脚本编译使用指南(Linux环境下):/index.php/Sitara_Linux_AM335x_Flash_Programming_Linux_Developmen t使用注意事项及问答:1.使用该Uniflash进行NAND FLASH烧写时,Uniflash会先将u-boot-spl-restore.bin和u-boot-restore.img下载到开发板中,启动开发板进入到UBOOT阶段,从而调用脚本文件进行FLASH的烧写,所以需要先对SDK6.0开发包进行UBOOT的移植。
移植时,一定要加入UBOOT 的patch:/index.php/Sitara_Linux_AM335x_Flash_Programming_Linux_Dev elopment#Build_SPL_.28MLO.29_and_U-Boot_for_Flashing2.请注意,制作用于NAND flash烧写的启动image时,确认使用的编译选项为:am335x_evm_restore_flash_usbspl3.在Uniflash进行u-boot-spl-restore.bin的下载时,如果出现usb网络反应超时,请确认是否已经安装我们的usb patch:0001-u-boot-Change-default-cdc_connect_timeout-to-15s.patch。
uboot——官网下载直接移植(一)

uboot——官⽹下载直接移植(⼀)1:uboot下载地址:ftp://ftp.denx.de/pub/u-boot/我们下载的版本是:u-boot-2013.10.tar.bz2;2:下载好以后,删除⾥⾯的相关⽂件因为三星是的s5pv1XX这个cpu做了很多个板⼦,我们在移植的时候虽然与三星的开发板不同但是⽤的cpu是相同的,所以我们再选择cpu相关⽂件的时候,要确定好哪个cpu与我们⽤的cpu是相同的,u-boot-2013.10\arch\arm\cpu\armv7\s5pc1xx 在⽬录下有s5pc1xx相关的配置⽂件;这就是我们要选⽤的cpu⽂件;3:相较与我们直接移植三星移植好的uboot,新版的uboot编译配置时有所不同;把主Makefile与board有关的配置信息⽂件分开了;我们可以根据board.cfg⽂件中的配置信息来确定我们⽤的是哪个开发板;打开board.cfg⽂件搜索s5pc1xx我们可以看到两个相关的开发板,goni、smdk100,我们先⽤goni开发板来进⾏移植;⾸先删除其它的⽆关⽂件:arch⽬录下:只保留arm⽂件夹;arm/cpu⽬录下的出armv7⽂件夹以外其他删除;arm/cpu/armv7⽬录下保留s5pc1xx 以及s5p_common这两个⽂件夹,其他的删除;board⽬录下:board⽬录下只保留samsung⽂件夹samsung⽬录下只保留goni、common⽂件夹之后⽤sourceinsight创建项⽬4:对主Makefile进⾏分析,之前我们make的时候⾸先要进⾏配置:make x210_sd_config,⽽在新uboot中的配置依赖于下⾯这个规则:我们进⾏配置的时候make s5p_goni_config 然后执⾏下⾯这段脚本相当于执⾏ ./mkcofig -A s5p_goniMKCONFIG变量还是mkconfig脚本,下⾯我们看⼀下mkconfig脚本如何⼯作:下⾯这段代码的作⽤:1if [ \( $# -eq 2 \) -a \( "$1" = "-A" \) ] ; then2 # Automatic mode3 line=`awk '($0 !~ /^#/ && $7 ~ /^'"$2"'$/) { print $1, $2, $3, $4, $5, $6, $7, $8 }' boards.cfg`4if [ -z "$line" ] ; then5 echo "make: *** No rule to make target \`$2_config'. Stop." >&26 exit 17 fi89set ${line}10 # add default board name if needed11 [ $# = 3 ] && set ${line} ${1}12 fi判断传参是否两个且第⼀个参数为 -A,如果是则对line赋值,line的值是通过在boards.cfg⽂件中查找第⼆个参数$2,并把这⼀⾏赋值给line,从前⾯内容我们可以看出line = Active arm armv7 s5pc1xx samsung goni s5p_goni -并且把这些由空格分开的字符赋值给$1-$8所以这段代码执⾏完以后的结果是:$1 = Active$2 = arm$3 = armv7$4 = s5pv1xx$5 = samsung$6 = goni$7 = s5p_goni$8 = -继续分析下⾯代码:这段代码实际中没有起到什么作⽤可忽略1while [ $# -gt 0 ] ; do2case"$1"in3 --) shift ; break ;;4 -a) shift ; APPEND=yes ;;5 -n) shift ; BOARD_NAME="${7%_config}" ; shift ;;6 -t) shift ; TARGETS="`echo $1 | sed 's:_: :g'` ${TARGETS}" ; shift ;;7 *) break ;;8 esac9 done1011 [ $# -lt 7 ] && exit 112 [ $# -gt 8 ] && exit 1下⾯代码:CONFIG_NAME="${7%_config}"[ "${BOARD_NAME}" ] || BOARD_NAME="${7%_config}"arch="$2"cpu=`echo $3 | awk 'BEGIN {FS = ":"} ; {print $1}'`spl_cpu=`echo $3 | awk 'BEGIN {FS = ":"} ; {print $2}'`if [ "$6" = "-" ] ; thenboard=${BOARD_NAME}elseboard="$6"fi[ "$5" != "-" ] && vendor="$5"[ "$4" != "-" ] && soc="$4"[ $# -gt 7 ] && [ "$8" != "-" ] && {# check if we have a board config name in the options field# the options field mave have a board config name and a list# of options, both separated by a colon (':'); the options are# separated by commas (',').## Check for board nametmp="${8%:*}"if [ "$tmp" ] ; thenCONFIG_NAME="$tmp"fi# Check if we only have a colon...if [ "${tmp}" != "$8" ] ; thenoptions=${8#*:}TARGETS="`echo ${options} | sed 's:,: :g'` ${TARGETS}"fi}config_name = s5p_goni_configBOARD_NAME = s5p_goni_configarch = armcpu = armv7spl_cpu = " "board = gonivendor = samsungsoc = s5pc1xx看下⾯信息:在这⾥第⼀打印出信息:Configuring for s5p_goni_config board...if [ "${ARCH}" -a "${ARCH}" != "${arch}" ]; thenecho "Failed: \$ARCH=${ARCH}, should be '${arch}' for ${BOARD_NAME}"1>&2exit 1fiif [ "$options" ] ; thenecho "Configuring for ${BOARD_NAME} - Board: ${CONFIG_NAME}, Options: ${options}" elseecho "Configuring for ${BOARD_NAME} board..."fi创建头⽂件的符号连接:if [ "$SRCTREE" != "$OBJTREE" ] ; thenmkdir -p ${OBJTREE}/includemkdir -p ${OBJTREE}/include2cd ${OBJTREE}/include2rm -f asmln -s ${SRCTREE}/arch/${arch}/include/asm asmLNPREFIX=${SRCTREE}/arch/${arch}/include/asm/cd ../includemkdir -p asmelsecd ./includerm -f asmln -s ../arch/${arch}/include/asm asmfirm -f asm/archif [ -z "${soc}" ] ; thenln -s ${LNPREFIX}arch-${cpu} asm/archelseln -s ${LNPREFIX}arch-${soc} asm/archfiif [ "${arch}" = "arm" ] ; thenrm -f asm/procln -s ${LNPREFIX}proc-armv asm/procfi符号连接1:/include/asm 连接到 /arch/arm/include/asm符号连接2: /include/asm/arch链接到 /arch/arm/include/asm/arch-s5pc1xx 符号链接3: /include/asm/proc链接到/arch/arm/include/asm/proc-armv看⼀下下⾯的代码:## Create include file for Make#( echo "ARCH = ${arch}"if [ ! -z "$spl_cpu" ] ; thenecho 'ifeq ($(CONFIG_SPL_BUILD),y)'echo "CPU = ${spl_cpu}"echo "else"echo "CPU = ${cpu}"echo "endif"elseecho "CPU = ${cpu}"fiecho "BOARD = ${board}"[ "${vendor}" ] && echo "VENDOR = ${vendor}"[ "${soc}" ] && echo "SOC = ${soc}"exit 0 ) > config.mk这段代码的作⽤是把ARCH = armCPU = armv7BOARD = gonivendor = samsungsoc = s5pc1xx 输出config.mk⽂件中看下⾯代码:# Assign board directory to BOARDIR variableif [ -z "${vendor}" ] ; thenBOARDDIR=${board}elseBOARDDIR=${vendor}/${board}fiBOARDDIR = samsung/goni再看最后⼀段代码:# Create board specific header file#if [ "$APPEND" = "yes" ] # Append to existing config file thenecho >> config.helse> config.h # Create new config filefiecho "/* Automatically generated - do not edit */" >>config.hfor i in ${TARGETS} ; doi="`echo ${i} | sed '/=/ {s/=/ /;q; } ; { s/$/ 1/; }'`"echo "#define CONFIG_${i}" >>config.h ;doneecho "#define CONFIG_SYS_ARCH \"${arch}\"" >> config.hecho "#define CONFIG_SYS_CPU \"${cpu}\"" >> config.hecho "#define CONFIG_SYS_BOARD \"${board}\"" >> config.h [ "${vendor}" ] && echo "#define CONFIG_SYS_VENDOR \"${vendor}\"" >> config.h [ "${soc}" ] && echo "#define CONFIG_SYS_SOC \"${soc}\"" >> config.hcat << EOF >> config.h#define CONFIG_BOARDDIR board/$BOARDDIR#include <config_cmd_defaults.h>#include <config_defaults.h>#include <configs/${CONFIG_NAME}.h>#include <asm/config.h>#include <config_fallbacks.h>#include <config_uncmd_spl.h>EOFexit 0上⾯这段代码的作⽤就是添加⼀些宏定义到config.h⽂件中:/* Automatically generated - do not edit */TARGETS为空所以不执⾏#define CONFIG_SYS_ARCH arm#define CONFIG_SYS_CPU armv7#define CONFIG_SYS_BOARD goni#define CONFIG_SYS_SOC s5pc1xxcat << EOF >> config.h 这句代码的作⽤是把下⾯内容写⼊config.h中,直到EOF;。
AM335X UBIFS NandFlash Programming Guide v1.1

return omap_bootmode[0]; } } /* End */
修改完后重新编译。
Linux Kernel:
由于 SDK 是 3.2 的内核,需要打以下补丁,关于该补丁的描述参见 https:///patch/1245721/,并且该补丁已融入 3.4.7 内核中 /pub/linux/kernel/v3.x/ChangeLog-3.4.7:
至此,mtd-utils 编译完成。
制作 UBI Filesystem
打开终端,输入: cd [your base dirctory]/mtd-utils-1.5.0 mkfs.ubifs/mkfs.ubifs -r [your filesystem directory]/ -F -o ubifs.img -m 2048 -e 126976 -c 1580
编译 mtd-utils..........................................................................................................................3 制作 UBI Filesystem.................................................................................................................4
或通过 Git 获取源码: git:///mtd-utils.git
推荐使用 mtd-utils 1.4.8 以上
AM335x UBOOT移植记录

board_init_r 第 2 阶段的初始化,在 board.c 文件中
enable_caches 这个函数没有做什么内容
board_init
第 2 次初始化平台,这里可以初始化其他内容了,和平台相关
mem_malloc_init 初始化 malloc 内存
nanபைடு நூலகம்_init
初始化 NAND(CONFIG_CMD_NAND 需要定义)
uboot 的代码运行流程 u-boot-2011.09-psp04.06.00.08/arch/arm/cpu/armv7 start.s 入口运行文件
bl save_boot_params 跳转到 lowlevel_init.S 该 文 件 在 (arch\arm\cpu\armv7\omap-common) , 如 果 是 MLO 则 会 定 义
1、.boards.depend 2、include/config.h
/* Automatically generated - do not edit */ #define CONFIG_BOARDDIR board/ti/am335x #include <config_cmd_defaults.h> #include <config_defaults.h> #include <configs/am335x_evm.h> #include <asm/config.h> 3、include/config.mk ARCH = arm CPU = armv7 BOARD = am335x VENDOR = ti SOC = ti81xx
这个目录下的几个文件,start.s 这个是程序的入口执行文件 u-boot-2011.09-psp04.06.00.08/arch/arm/cpu/armv7/omap-common u-boot-2011.09-psp04.06.00.08/arch/arm/cpu/armv7/ti81xx
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
AM335x uboot 移植2013-06-11 22:36:39| 分类:am335x-艾默生 | 标签:uboot am335x 移植|举报|字号订阅uBOOT的编译命令直接一次性编译make O=am335x CROSS_COMPILE=arm-arago-linux-gnueabi ARCH=armam335x_evm配置make ARCH=arm CROSS_COMPILE=arm-arago-linux-gnueabi- am335x_evm_config编译make ARCH=arm CROSS_COMPILE=arm-arago-linux-gnueabi-清理make clean ARCH=arm CROSS_COMPILE=arm-arago-linux-gnueabi-make distclean ARCH=arm CROSS_COMPILE=arm-arago-linux-gnueabi-编译器环境变量的设置这个环境变量是TI的SDK包里面带的编译器,不是之前的arm-gcc-export PATH=$PATH:/mnt/disk1/ti-sdk-am335x-evm-05.05.00.00/linux-devkit/bin/UBOOT里面的MLO(u-boot-spl)如果使用NAND启动,那么这个文件就是相当于NBOOT,进行第一次的引导这个MLO实际上就是u-boot-spl.bin生成的,在编译完uboot后,SPL的目录里面会产生了许多的.o文件,这里文件就是uboot的文件,可以打开Makefile,有一些对应的宏定义,可以取消,减少MLO文件的大小UBOOT的链接脚本ldsUBOOT\arch\arm\cpu\armv7\u-boot.lds正常运行UBOOT的ldsUBOOT\arch\arm\cpu\armv7\omap-common\u-boot.lds这个是nboot,加载uboot用有2个lds,不同的作用,注意要区别开增加新的单板支持在boards.cfg文件中,找到加入,例如单板名字 arm armv7 对应board的目录 ti ti81xx以后就可以执行make 单板名字来生成uboot,这里被ti改写了,所以不是原版的uboot生成方法一些代码的定位u-boot-2011.09-psp04.06.00.08/arch/arm/cpu/armv7这个目录下的几个文件,start.s这个是程序的入口执行文件u-boot-2011.09-psp04.06.00.08/arch/arm/cpu/armv7/omap-commonu-boot-2011.09-psp04.06.00.08/arch/arm/cpu/armv7/ti81xx这2个目录是和平台板子相关,AM335X是ti81xx的版本以上都是和CPU有关u-boot-2011.09-psp04.06.00.08/arch/libARM平台的公用代码u-boot-2011.09-psp04.06.00.08/lib通用的库代码,无论什么平台都编译board/ti/xxx 这个目录就是单板的配置Makefile文件分析在终端中输入后make ARCH=arm CROSS_COMPILE=arm-arago-linux-gnueabi- am335x_evm_config 命令后,会生成3个文件1、.boards.depend2、include/config.h/* Automatically generated - do not edit */#define CONFIG_BOARDDIR board/ti/am335x#include <config_cmd_defaults.h>#include <config_defaults.h>#include <configs/am335x_evm.h>#include <asm/config.h>3、include/config.mkARCH = armCPU = armv7BOARD = am335xVENDOR = tiSOC = ti81xx终端中会输出awk '(NF && $1 !~ /^#/) { print $1 ": " $1 "_config; $(MAKE)" }'boards.cfg > .boards.dependConfiguring for am335x_evm board...支持的配置am335x配置有am335x_evmam335x_evm_restore_flasham335x_evm_spiboot解析Makefile文件,sinclude $(obj).boards.depend$(obj).boards.depend: boards.cfgawk '(NF && $$1 !~ /^#/) { print $$1 ": " $$1 "_config; $$(MAKE)" }' $< > $@我们搜索am335x_evm并没有在makefile文件中找到对应的关键字,但是发现boards.cfg 中有此关键词,可能am335x_evm_config输入后,是到boards.cfg中寻找的通过TI CCS调试uboot通过makefile文件建立ccs工程1、打开CCS,选择File->New->Project2、打开新建窗口后,选择c/c++下的Makefile Project with Existing Code3、点击下一步,选择uboot的存放的目录,然后点击完成4、等待右下角的进度,一直到达100%后,在继续操作5、最后在属性设置里,取消C的自动编译调试的时候,如果目标代码是汇编,则不会现实源码,只有C才会现实出uboot的代码运行流程u-boot-2011.09-psp04.06.00.08/arch/arm/cpu/armv7start.s 入口运行文件bl save_boot_params跳转到lowlevel_init.S该文件在(arch\arm\cpu\armv7\omap-common) ,如果是MLO则会定义CONFIG_SPL_BUILD宏,uboot没有定义,保存CPU ROM的参数到一个地方中bl cpu_init_crit SPL里面调用,初始化底层相关的(函数就在本文件中最下面)bl lowlevel_init 保存旧的堆栈指针,设置新的堆栈指针在lowlevel_init.S (arch\arm\cpu\armv7\omap-common)文件中bl s_init 此函数在Evm.c (board\ti\am335xwecon)文件中,不同的平台初始化不同的内容初始化堆栈指针跳转到C语言,board_init_f,C 言从个函数开始行语这执board_init_f 在Board.c (arch\arm\lib)文件中init_sequence数,行初始化组继续进relocate_code 函数,重新回到汇编start.s文件中relocate_code:在start.s文件中主要了实现uboot的重新定位代,和码bss段的清零ldr r0, _board_init_r_ofs 通个方式取过这获board_init_r函数入口adr r1, _startadd lr, r0, r1mov pc, lr 最后里个到这C函数,board_init_r里面board_init_r 第2 段的初始化,在阶board.c文件中enable_caches 个函数没有做什么内容这board_init 第2次初始化平台,里可以初始化其他内容了,和平台相关这mem_malloc_init 初始化malloc内存nand_init 初始化NAND(CONFIG_CMD_NAND需要定)义mmc_initialize 初始化SD(CONFIG_GENERIC_MMC需要定)义/drivers/mmc/mmc.c文件中board_mmc_init 平台相关omap_mmc_init(ID)/drivers/mmc/omap_hsmmc.c文件中env_relocate 初始化境量环变/common/env_common.c文件中stdio_initjumptable_initconsole_init_rmisc_init_r 平台相关,目前不知道什么用interrupt_initenable_interruptseth_initialize(gd->bd); 初始化以太网/net/eth.c文件中board_eth_init 平台相关的代中码cpsw_register /driver/net/cpsw.c 注册一个以太网设备main_loop(); 入控制台进init_sequence数里的内容组#if defined(CONFIG_ARCH_CPU_INIT)arch_cpu_init, /* basic arch cpu dependent setup */#endif#if defined(CONFIG_BOARD_EARLY_INIT_F)board_early_init_f,#endiftimer_init, Timer.c (arch\arm\cpu\armv7\omap-common)默的定器,开始运行认时刚uboot ,那个倒多少后按空格入时计时时间进uboot#ifdef CONFIG_FSL_ESDHCget_clocks,#endifenv_init, Env_nand.c (common) uboot默的参数,都在里初始化认这init_baudrate, 本文件中,初始化uboot使用的默的串口波特率认serial_init, Serial.c (drivers\serial)初始化串口,在UBOOT中,使用的默串口名认字是叫NS16550,可能是因原来就存在此代的故,然后用了为码缘继续调ns16550.c里面的函数初始化串口console_init_f, Console.c (common)初始化控制台display_banner, 本文件中,出一些信息,代表运行到了里输这#if defined(CONFIG_DISPLAY_CPUINFO)print_cpuinfo, /* display cpu info (and speed) */#endif#if defined(CONFIG_DISPLAY_BOARDINFO)checkboard, /* display board info */#endif#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)init_func_i2c, 本文件中,初始化IIC,然后用继续调Omap24xx_i2c.c (drivers\i2c),具体的CPU IIC初始化的实现#endifdram_init, /* configure available RAM banks */UBOOT用到的结构体register volatile gd_t *gd asm ("r8")此结构体记录了UBOOT所有的参数内容typedef struct global_data {bd_t *bd; 个是一个构体这还结unsigned long flags;unsigned long baudrate; UBOOT串口端所使用的串口波特率终unsigned long have_console; 串口控制台是否初始化?过=1初始化过//UBOOT 境量相关的量环变变unsigned long env_addr; 个是地址,存放了这uboot使用的境量参数存放在内环变存中的地址,例如了对应记录uboot的ip地址,入进uboot默的延等,和认时时间default_environment 起来对应unsigned long env_valid; 默的境量是否有效,认环变=1代表有效unsigned long fb_base;/* base address of frame buffer */#ifdef CONFIG_FSL_ESDHCunsigned long sdhc_clk;#endif#ifdef CONFIG_AT91FAMILY/* "static data" needed by at91's clock.c */unsigned long cpu_clk_rate_hz;unsigned long main_clk_rate_hz;unsigned long mck_rate_hz;unsigned long plla_rate_hz;unsigned long pllb_rate_hz;unsigned long at91_pllb_usb_init;#endif#ifdef CONFIG_ARM/* "static data" needed by most of timer.c on ARM platforms */unsigned long timer_rate_hz;unsigned long tbl;unsigned long tbu;unsigned long long timer_reset_value;unsigned long lastinc;#endif#ifdef CONFIG_IXP425unsigned long timestamp;#endifunsigned long relocaddr; /* Start address of U-Boot in RAM */phys_size_t ram_size; 内存的大小unsigned long mon_len; uboot整个bin文件的大小代码段+bss段unsigned long irq_sp; IRQ中断堆指栈针unsigned long start_addr_sp; /* start_addr_stackpointer */unsigned long reloc_off;#if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF)) unsigned long tlb_addr;#endifvoid **jt; /* jump table */char env_buf[32];/* buffer for getenv() before reloc. */} gd_t;typedef struct bd_info {int bi_baudrate; 串口控制台波特率unsigned long bi_ip_addr; IP地址ulong bi_arch_number; 传递给LINUX内核,告诉当前是板子的IDulong bi_boot_params; 传递给linux 内核,告诉其参数存放的位置struct /* RAM configuration */{ulong start;ulong size;}bi_dram[CONFIG_NR_DRAM_BANKS];这个用于给LINUX传递启动信息的,内存大小和起始地址,如果有多块内存,则这个变量是一个数组} bd_t;SPL的代码/arch/arm/cpu/armv7/start.s 入口/arch/arm/cpu/armv7/omap-common C文件,Uboot的重定位relocate_code: 要有pie选项(arm-linux-ld命令中)movr4, r0 /* save addr_sp */ 新的堆栈地址movr5, r1 /* save addr of gd */ gd_t变量的内容地址,因为重定位后,这个地址会改变movr6, r2 /* save addr of destination */ 目标地址/* Set up the stack */stack_setup:movsp, r4 设置堆栈adr r0, _start uboot的起始运行地址cmpr0, r6moveq r9, #0 /* no relocation. relocation offset(r9) = 0 */ 如果代码段已经是目标了,那么不要复制了直接跳转到clear_bssbeqclear_bss /* skip relocation */movr1, r6 /* r1 <- scratch for copy_loop */ 代码段的目标地址ldr r3, _image_copy_end_ofs 要复制的长度addr2, r0, r3 /* r2 <- source end address */ 代码段的结束地址开始循环复制代码段copy_loop:ldmia r0!, {r9-r10} /* copy from source address [r0] */stmia r1!, {r9-r10} /* copy to target address [r1] */cmpr0, r2 /* until source end address [r2] */blo copy_loop重定位代码,修改代码为新的地址#ifndef CONFIG_SPL_BUILDR0是目标内存,修改后放入目标的内存中ldr r0, _TEXT_BASE /* r0 <- Text base */ 代码段的基地址sub r9, r6, r0 /* r9 <- relocation offset */ 重定位的偏移值 r9=代码段目标地址–代码段的基地址ldr r10, _dynsym_start_ofs /* r10 <- sym table ofs */ r10=动态起始地址addr10, r10, r0 /* r10 <- sym table in FLASH */ r10 = 动态符号表的目标存放地址r2是rel_dyn段的内容,这个段就是代表要修改的数据.这个段都是放一个要修改的值,然后放一个标记.偏移值分为两种:相对位移和绝对位移ldr r2, _rel_dyn_start_ofs /* r2 <- rel dyn start ofs */ 要修改地址的信息的一些变量都放在这里addr2, r2, r0 /* r2 <- rel dyn start in FLASH */r3是放结束的地址,用来判断是否结束ldr r3, _rel_dyn_end_ofs /* r3 <- rel dyn end ofs */addr3, r3, r0 /* r3 <- rel dyn end in FLASH */fixloop:从R2取出要修改的值,ldr r0, [r2] /* r0 <- location to fix up, IN FLASH! */addr0, r0, r9 /* r0 <- location to fix up in RAM */从R2的下一个位置读取一个值,这个值是用来判断是运行fixrel还是fixabs用ldr r1, [r2, #4]andr7, r1, #0xff这里判断是相对位移还是绝对位移,然后修改cmpr7, #23 /* relative fixup? */beqfixrelcmpr7, #2 /* absolute fixup? */beqfixabs/* ignore unknown type of fixup */b fixnextfixabs: 修改绝对位移,就是运行前才可以确定的/* absolute fix: set location to (offset) symbol value */movr1, r1, LSR #4 /* r1 <- symbol index in .dynsym */addr1, r10, r1 /* r1 <- address of symbol in table */ldr r1, [r1, #4] /* r1 <- symbol value */addr1, r1, r9 /* r1 <- relocated sym addr */b fixnextfixrel: 修改相对位移,编译时就确定了地址/* relative fix: increase location by offset */ldr r1, [r0]addr1, r1, r9fixnext: 写入本次修改的内容,判断是否运行完成,str r1, [r0] 将r1写入目标内存addr2, r2, #8 /* each rel.dyn entry is 8 bytes */cmpr2, r3 判断是否结束,blo fixloop 没有结束,继续循环b clear_bss 结束了#endif /* #ifndef CONFIG_SPL_BUILD */uboot命令环境变量printenv 打印当前的环境变量运行gobootm 0x82000000boot - boot default, i.e., run 'bootcmd'根据bootcmd环境变量运行命令bootd - boot default, i.e., run 'bootcmd' 根据bootcmd环境变量运行命令nand flash以太网ping 192.168.1.2 tftp。