OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 7377|回复: 2

u-boot(2015.01)在AM335X上移植 第三天

[复制链接]

27

主题

30

帖子

0

精华

初级会员

Rank: 2

积分
194
金钱
194
注册时间
2012-4-4
在线时间
46 小时
发表于 2016-1-7 15:18:26 | 显示全部楼层 |阅读模式
本帖最后由 fuqiye 于 2016-1-7 15:36 编辑

u-boot(2015.01)在AM335X上移植 第三天


一、在程序中添加“个性代码”

  1、点亮板上的LED指示灯

  在arch/arm/cpu/armv7/arm33xx/board.c文件中

  在void s_init(void)函数中添加如下代码

void s_init(void)
{
        /*
         * The ROM will only have set up sufficient pinmux to allow for the
         * first 4KiB NOR to be read, we must finish doing what we know of
         * the NOR mux in this space in order to continue.
         */
#ifdef CONFIG_NOR_BOOT
        enable_norboot_pin_mux();
#endif
        /*
         * Save the boot parameters passed from romcode.
         * We cannot delay the saving further than this,
         * to prevent overwrites.
         */
#ifdef CONFIG_SPL_BUILD
        save_omap_boot_params();
#endif
        watchdog_disable();
        set_uart_mux_conf();
        setup_clocks_for_console();
        uart_soft_reset();
#if defined(CONFIG_NOR_BOOT) || defined(CONFIG_QSPI_BOOT)
        gd->baudrate = CONFIG_BAUDRATE;
        serial_init();
        gd->have_console = 1;
#elif defined(CONFIG_SPL_BUILD)
        gd = &gdata;
        preloader_console_init();
#endif
#if defined(CONFIG_SPL_AM33XX_ENABLE_RTC32K_OSC)
        /* Enable RTC32K clock */
        rtc32k_enable();
#endif
#ifdef CONFIG_SPL_BUILD
        board_early_init_f();
        /*
        *打开指示灯
        */
        gpio_request((32*3+18), "LED");//GPIO3_18
        gpio_direction_output((32*3+18), 1);
        /*end打开指示灯*/
        sdram_init();
#endif
}

#endif
   2、加入自己的一此打印信息
   在common/spl/Spl.c文件中
   在void preloader_console_init(void)函数中添加如下代码
void preloader_console_init(void)
{
        gd->bd = &bdata;
        gd->baudrate = CONFIG_BAUDRATE;

        serial_init();                /* serial communications setup */

        gd->have_console = 1;

        puts("\nU-Boot SPL " PLAIN_VERSION " (" U_BOOT_DATE " - " U_BOOT_TIME ")\n");
        printf("**********voip server V0.0.1 SPL**********\n");
#ifdef CONFIG_SPL_DISPLAY_PRINT
        spl_display_print();
#endif
}
   在lib/Display_options.c文件中
   在int display_options (void)函数中添加如下代码
int display_options (void)
{
#if defined(BUILD_TAG)
        printf ("\n\n%s, Build: %s\n", version_string, BUILD_TAG);
#else
        printf ("\n\n%s\n", version_string);
        printf("*******voip server V0.0.1 uboot*******\n");
#endif
        return 0;
}
修改完成后编译运行。。。。。。
二、查看打印信息修改代码
此时串口的打印信息如下
QQ截图20160107143614.jpg
在打印信息中看到如下信息
reading args
spl_load_image_fat_os: error reading image args, err - -1
因为我们只是想让SPL引导u-boot的,所以去掉spl_load_image_fat_os读取。
只要在include/configs/ti_armv7_common.h文件中修改如下代码(添加红色部分)
#if defined(CONFIG_SPL_OS_BOOT_ENABLE)
#define CONFIG_SPL_OS_BOOT
#endif
还有       Watchdog enabled这句话前面有空格,我看起来有点不舒服。(可能楼主有点强迫症^_^)
只要在common/board_f.c文件static int init_func_watchdog_init(void)函数中去了打印信息中的空格
修改如下
puts("Watchdog enabled\n");
三、修改UBOOT引导命令
我们现在还在调试阶段所以要一直用SD卡起动所以这在要从SD引导。
修改u-boot的CONFIG_BOOTCOMMAND命令如下
#define CONFIG_BOOTCOMMAND \
        "echo Please manually select the command ... ;"\
        "echo run mmcboot, download2nand, debugkernel, nandboot ... ;"
修改添加命令列表
#define CONFIG_EXTRA_ENV_SETTINGS \
        DEFAULT_LINUX_BOOT_ENV \
        "boot_fdt=try\0" \
        "bootpart=0:2\0" \
        "bootdir=/boot\0" \
        "bootfile=uImage\0" \
        "fdtfile=undefined\0" \
        "console=ttyO0,115200n8\0" \
        "partitions=" \
                "uuid_disk=${uuid_gpt_disk};" \
                "name=rootfs,start=2MiB,size=-,uuid=${uuid_gpt_rootfs}\0" \
        "optargs=\0" \
        "mmcdev=0\0" \
        "mmcroot=/dev/mmcblk0p2 rw\0" \
        "mmcrootfstype=ext4 rootwait\0" \
        "rootpath=/export/rootfs\0" \
        "ipmethod=none\0" \
        "nfsopts=nolock\0" \
        "static_ip=${ipaddr}{serverip}{gatewayip}{netmask}{hostname}" \
                ":ff\0" \
        "ramroot=/dev/ram0 rw\0" \
        "ramrootfstype=ext2\0" \
        "bootargs_defaults=setenv bootargs " \
                "console=${console} " \
                "${optargs}\0" \
        "mmcargs=run bootargs_defaults;" \
                "setenv bootargs ${bootargs} " \
                "root=${mmcroot} " \
                "rootfstype=${mmcrootfstype} ip=${ipmethod}\0" \
        "spiroot=/dev/mtdblock4 rw\0" \
        "spirootfstype=jffs2\0" \
        "spisrcaddr=0xe0000\0" \
        "spiimgsize=0x362000\0" \
        "spibusno=0\0" \
        "spiargs=setenv bootargs console=${console} " \
                "${optargs} " \
                "root=${spiroot} " \
                "rootfstype=${spirootfstype}\0" \
        "netargs=setenv bootargs console=${console} " \
                "${optargs} " \
                "root=/dev/nfs " \
                "nfsroot=${serverip}{rootpath},${nfsopts} rw " \
                "ip=dhcp\0" \
        "bootenv=uEnv.txt\0" \
        "loadbootscript=load mmc ${mmcdev} ${loadaddr} boot.scr\0" \
        "bootscript=echo Running bootscript from mmc${mmcdev} ...; " \
                "source ${loadaddr}\0" \
        "loadbootenv=load mmc ${mmcdev} ${loadaddr} ${bootenv}\0" \
        "importbootenv=echo Importing environment from mmc ...; " \
                "env import -t -r $loadaddr $filesize\0" \
        "ramargs=setenv bootargs console=${console} " \
                "${optargs} " \
                "root=${ramroot} " \
                "rootfstype=${ramrootfstype}\0" \
        "loadramdisk=load mmc ${mmcdev} ${rdaddr} ramdisk.gz\0" \
        "loadimage=load mmc ${mmcdev} ${loadaddr} ${bootfile}\0" \
        "loadfdt=load mmc ${bootpart} ${fdtaddr} ${fdtfile}\0" \
        "mmcloados=run mmcargs; " \
                "if test ${boot_fdt} = yes || test ${boot_fdt} = try; then " \
                        "if run loadfdt; then " \
                                "bootz ${loadaddr} - ${fdtaddr}; " \
                        "else " \
                                "if test ${boot_fdt} = try; then " \
                                        "bootz; " \
                                "else " \
                                        "echo WARN: Cannot load the DT; " \
                                "fi; " \
                        "fi; " \
                "else " \
                        "bootz; " \
                "fi;\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};" \
                        "fi;" \
                "fi;\0" \
        "spiboot=echo Booting from spi ...; " \
                "run spiargs; " \
                "sf probe ${spibusno}:0; " \
                "sf read ${loadaddr} ${spisrcaddr} ${spiimgsize}; " \
                "bootz ${loadaddr}\0" \
        "netboot=echo Booting from network ...; " \
                "setenv autoload no; " \
                "dhcp; " \
                "tftp ${loadaddr} ${bootfile}; " \
                "tftp ${fdtaddr} ${fdtfile}; " \
                "run netargs; " \
                "bootz ${loadaddr} - ${fdtaddr}\0" \
        "ramboot=echo Booting from ramdisk ...; " \
                "run ramargs; " \
                "bootz ${loadaddr} ${rdaddr} ${fdtaddr}\0" \
        "findfdt="\
                "if test $board_name = A335BONE; then " \
                        "setenv fdtfile am335x-bone.dtb; fi; " \
                "if test $board_name = A335BNLT; then " \
                        "setenv fdtfile am335x-boneblack.dtb; fi; " \
                "if test $board_name = A33515BB; then " \
                        "setenv fdtfile am335x-evm.dtb; fi; " \
                "if test $board_name = A335X_SK; then " \
                        "setenv fdtfile am335x-evmsk.dtb; fi; " \
                "if test $fdtfile = undefined; then " \
                        "echo WARNING: Could not determine device tree to use; fi; \0" \
        "download2nand=echo sd download file to nand ...;"        \
                "echo sd download file to nand ...;" \
                "echo SD/MMC found on device ${mmcdev};" \
                "nand erase.chip; "\
                "fatload mmc 0 0x81000000 MLO; "\
                "nand write 0x81000000 NAND.SPL ${filesize}; "\
                "nand write 0x81000000 NAND.SPL.backup1 ${filesize}; "\
                "nand write 0x81000000 NAND.SPL.backup2 ${filesize}; "\
                "nand write 0x81000000 NAND.SPL.backup3 ${filesize}; "\
                "fatload mmc 0 0x81000000 u-boot.img; "\
                "nand write 0x81000000 NAND.u-boot ${filesize}; "\
                "fatload mmc 0 0x81000000 uImage; "\
                "nand write 0x81000000 NAND.kernel ${filesize}; "\
                "fatload mmc 0 0x81000000 root.bin; "\
                "nand write 0x81000000 NAND.rootfs ${filesize}; \0"\
        "debugkernel=echo debug linux kernel 3.18.24 Author:fuqiye...;"        \
                "load mmc 0 0x88000000 /am335x-wsdv.dtb ; "\
                "load mmc 0 0x82000000 /zImage ; "\
                "bootz 0x82000000 - 0x88000000 ; \0"\
        "nandboot=echo nand flash linux booting...;"        \
                "run nandargs ; ; "\
                "nand read 0x82000000 NAND.kernel 0x400000; "\
                "bootm 0x82000000 ; \0"\
        NANDARGS \
        DFUARGS
说明:此修改只是调试阶段的应用的一此命令,到最后会重新整理。
四、编译运行代码
运行代码情况如下串口打印信息
QQ截图20160107151713.jpg
到此u-boot成功在此板子上运行了。
u-boot调试到此已告一段落。







正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

530

主题

11万

帖子

34

精华

管理员

Rank: 12Rank: 12Rank: 12

积分
165540
金钱
165540
注册时间
2010-12-1
在线时间
2117 小时
发表于 2016-1-7 22:57:17 | 显示全部楼层
回复 支持 反对

使用道具 举报

2

主题

4

帖子

0

精华

新手入门

积分
20
金钱
20
注册时间
2016-4-13
在线时间
3 小时
发表于 2016-4-13 15:15:14 | 显示全部楼层
刚接触uboot,大神能指导下吗
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2025-6-19 17:19

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

快速回复 返回顶部 返回列表