订阅
纠错
加入自媒体

如何从0编译和移植uboot、增加串口?

2021-04-01 14:59
一口Linux
关注

添加

COBJS-$(CONFIG_S5P_MSHC) += s5p_mshc.o  
添加EMMC相关配置
$vim    include/configs/origen.h

添加

#define CONFIG_EVT1     1        EVT1
#ifdef CONFIG_EVT1
#define CONFIG_EMMC44_CH4 //eMMC44_CH4 (OMPIN[5:1] = 4)
#ifdef CONFIG_SDMMC_CH2
#define CONFIG_S3C_HSMMC
#undef DEBUG_S3C_HSMMC
#define USE_MMC2  
#endif
#ifdef CONFIG_EMMC44_CH4
#define CONFIG_S5P_MSHC
#define CONFIG_EMMC             1              
#define USE_MMC4  
#define CONFIG_EMMC_8Bit
#define CONFIG_EMMC_EMERGENCY
#define emmcdbg(fmt,args...) printf(fmt ,##args) //for emmc debug
#define emmcdbg(fmt,args...)
#endif
#endif end CONFIG_EVT1
#define CONFIG_CMD_MOVINAND
#define CONFIG_CLK_1000_400_200
#define CFG_PHY_UBOOT_BASE      CONFIG_SYS_SDRAM_BASE + 0x3e00000
#define CFG_PHY_KERNEL_BASE     CONFIG_SYS_SDRAM_BASE + 0x8000
#define BOOT_MMCSD      0x3
#define BOOT_EMMC43     0x6
#define BOOT_EMMC441    0x7
#define CONFIG_BOARD_LATE_INIT

7. 重新编译u-boot

修改顶层Makefile,注释掉spl的编译:

623 #$(obj)spl/u-boot-spl.bin:  $(SUBDIR_TOOLS) depend
624 #       $(MAKE) -C spl all

重新编译uboot:

$ ./build.sh

在根目录下会生成bin文件u-boot-origen.bin。

二、SD卡制作

1. 烧写脚本

三星公司已经给我们提供了制作SD卡启动的烧写的脚本:mkuboot.sh

#!/bin/bash

# This script will create a u-boot binary for movinand/mmc boot

echo "Fuse FS4412 trustzone uboot file into SD card"
if [ -z $1 ] #判断参数1的字符串是否为空,如果为空,则打印出帮助信息
then
./sd_fusing_exynos4x12.sh /dev/sdb u-boot-origen.bin
else
./sd_fusing_exynos4x12.sh $1 u-boot-origen.bin
fi

sd_fusing_exynos4x12.sh

1 #!/bin/sh  
 2 #
 3 # Copyright (C) 2010 Samsung Electronics Co., Ltd.
 4 #              http://www.samsung.com/
 5 #
 6 # This program is free software; you can redistribute it and/or modify
 7 # it under the terms of the GNU General Public License version 2 as
 8 # published by the Free Software Foundation.
 9 #
10 ####################################
11 reader_type1="/dev/sd"
12 reader_type2="/dev/mmcblk0"
13
14 if [ -z $2 ]  #判断参数2的字符串是否为空,如果为空,则打印出帮助信息
15 then
16     echo "usage: ./sd_fusing.sh <SD Reader's device file> <filename>"
17     exit 0
18 fi
19
20 param1=`echo "$1" | awk '{print substr($1,1,7)}'`
21
22 if [ "$param1" = "$reader_type1" ]
23 then
24     partition1=$1"1"
25     partition2=$1"2"
26     partition3=$1"3"
27     partition4=$1"4"
28
29 elif [ "$1" = "$reader_type2" ]
30 then
31     partition1=$1"p1"
32     partition2=$1"p2"
33     partition3=$1"p3"
34     partition4=$1"p4"
35
36 else
37     echo "Unsupported SD reader"
38     exit 0
39 fi
40
41 if [ -b $1 ] #判断参数1所指向的设备节点是否存在
42 then
43     echo "$1 reader is identified."
44 else
45     echo "$1 is NOT identified."
46     exit 0
47 fi
48
49 ####################################
50 # format
51 umount $partition1 2> /dev/null
52 umount $partition2 2> /dev/null
53 umount $partition3 2> /dev/null
54 umount $partition4 2> /dev/null
55
56 echo "$2 fusing..."
 # 烧写u-boot-origen.bin到SD卡(512+8K)字节处, 512+8K=17x512,即第17个block
57 dd iflag=dsync oflag=dsync if=$2 of=$1 seek=1 &&
58     echo "$2 image has been fused successfully."
59
60 #echo "zImage fusing..."
61 #dd iflag=dsync oflag=dsync if=../../TC4_Kernel_3.0/arch/arm/boot/zImage of=$1 seek=1024 &&
62 #   echo "zImage has been fused successfully."
63
64 #echo "ramdisk-uboot.img fusing..."
65 #dd iflag=dsync oflag=dsync if=../../TC4_GB_2.3.4/out/target/product/smdk4212/ramdisk-uboot.img of=$1 seek=9216 &&
66 #   echo "ramdisk-uboot.img has been fused successfully."
67
68 ####################################
69 #<Message Display>
70 echo "Eject SD card"
71
2. 制作步骤

a) 创建文件mkuboot.sh、sd_fusing_exynos4x12.shb) 将SD卡插入电脑并被ubuntu识别c) 拷贝编译好u-boot-origen.bin拷贝到当前目录下

root@ubuntu:/home/peng/uboot/sdfuse_q# ls
mkuboot.sh  sd_fusing_exynos4x12.sh  u-boot-origen.bin

d) 进入sdfuse_q执行如下操作

root@ubuntu:/home/peng/uboot/sdfuse_q#./mkuboot.sh  /dev/sdb

d) 在SD卡中创建目录sdupdate,并把编译好的uboot镜像文件u-boot-origen.bin拷贝到这个目录。

3. 通过sd卡启动烧写uboot

a) 连接串口和板子,运行串口通信程序putty

选择右上角的”Serial”,然后点击左下角的”Serial”

按照自己的主机的情况选择COM口其他必须一直,然后点击open打开串口

b) 关闭开发板电源,将拨码开关SW1调至(1000)(SD启动模式)后打开电源c)    将刚才做好的SD启动盘插入SD卡插槽d) 重新打开开发板能够看到如下界面

在这里插入图片描述

在读秒倒计时时按任意键。由上图所示,已经支持EMMC和dm9000网卡。

e) 烧写在终端上执行

sdfuse  flashall

注意:上面的命令把SD卡 sdupdate目录下的u-boot-origen.bin烧写到emmc起始位置等待终端无输出是表示烧写结束

f) 关闭开发板电源,将拨码开关SW1调至0110(EMMC启动模式)后打开电源即可以从emmc启动

4. 网络烧写uboot

如果板子已经可以启动uboot,我们也可以通过网络烧写uboot。

步骤如下:

把编译好的u-boot-origen.bin拷贝到/tftpboot下启动开发板,在u-boot下先下载u-boot-origen.bin到41000000;再运行movi  write  u-boot  41000000

若编译后的u-boot-origen.bin 无法运行,可参考上一节,重新从SD卡引导烧写。

文中资料后台回复:uboot

·················· END ··················

<上一页  1  2  3  
声明: 本文由入驻维科号的作者撰写,观点仅代表作者本人,不代表OFweek立场。如有侵权或其他问题,请联系举报。

发表评论

0条评论,0人参与

请输入评论内容...

请输入评论/评论长度6~500个字

您提交的评论过于频繁,请输入验证码继续

暂无评论

暂无评论

人工智能 猎头职位 更多
扫码关注公众号
OFweek人工智能网
获取更多精彩内容
文章纠错
x
*文字标题:
*纠错内容:
联系邮箱:
*验 证 码:

粤公网安备 44030502002758号