移植4412时,使用uboot的一些总结

1. 搭建已有的linux4.4.38环境
    a. 交叉编译工具链(arm-linux-gcc-4.9.4 eabi 硬浮点兼容版, arm-linux-gcc-4.9.4 eabihf 真硬浮点版)
    export PATH=${PATH}:/work/ov5640_camera/gcc-linaro-4.9.4-2017.01-i686_arm-linux-gnueabihf/bin
    b. uboot
    make tiny4412
    c. kernel
    cp tiny4412_linux_4_4_defconfig .config
    make LOADADDR=0x40008000 uImage
    make dtbs        (DTC工具会自动编译内核中所有的arm类的dts文件生成 dtb文件)
    make exynos4412-tiny4412.dtb    指定设备树文件(遇到编译错误见1.1节)


2. 烧写uboot到emmc中
    uboot源码: https://github.com/zczjx/uboot_tiny4412
    进入u-boot/sd_fuse/执行make,可以生成mkbl2工具,
    进入u-boot/sd_fuse/tiny4412目录下可以看到bl2.bin  E4412_N.bl1.bin  E4412_tzsw.bin三个bin,其中bl2.bin在制作SD启动卡时会生成,我们也需要此文件。(见2.1节)
    下载ubuntu下dnw工具
    制作SD启动卡,开发板SW2开关选择SD启动
    sd卡uboot的运行后的命令输入
        mmcinfo 0
        mmcinfo 1
        fdisk -p 0
        fdisk -p 1
        fdisk -c 1 320 2057 520
        fatformat mmc 1:1
        ext3format mmc 1:2
        ext3format mmc 1:3
        ext3format mmc 1:4
    从PC端下载固件到开发板Memory中
        emmc open 1
        dnw 0x40008000(这个地址如何确定)
            ubuntu:./dnw E4412_N.bl1.bin
        mmc write 1 0x40008000 0 0x10
        dnw 0x40008000
            ubuntu:./dnw bl2.bin
        mmc write 1 0x40008000 0x10 0x1C
        dnw 0x40008000
            ubuntu:./dnw u-boot.bin
        mmc write 1 0x40008000 0x30 0x21D
        dnw 0x40008000
            ubuntu:./dnw E4412_tzsw.bin
        mmc write 1 0x40008000 0x2c0 0xB8
        emmc close 1
    接下来我们可以把开发板的SW2拨动到NAND启动,同时u-boot中断输入reset(此时emmc里有uboot,从emmc启动uboot)
    还有一件非常重要的事情我们还有做,就是启动参数写入,我们bootargs写入到env分区,注意ENV分区在TZSW分区后面,内核分区之前。即 TZSW | ENV | KERNEL
        setenv bootargs console=ttySAC0,115200n8 androidboot.console=ttySAC0 uhost0=n ctp=2 skipcali=y vmalloc=512m lcd=S70
        saveenv
    烧写kernel, system, ramdisk(重点)
        fastboot
        ubuntu:fastboot flash kernel-4-4 arch/arm/boot/uImage
        ubuntu:fastboot flash dtb arch/arm/boot/dts/exynos4412-tiny4412.dtb
        

https://www.cnblogs.com/pengdonglin137/p/4495056.html


1.1节:解决dtb编译错误问题
解决编译dtb错误问题: (https://www.linuxquestions.org/questions/linux-kernel-70/kernel-compilation-terminated-4175620037/)
fatal error: dt-bindings/clock/exynos4.h: No such file or directory
cd arch/arm/boot/dts/include/
mv dt-bindings dt-bindings_bak
ln -s ../../../../../include/dt-bindings
make exynos4412-tiny4412.dtb


2.1节:将uboot烧写到sd卡 (http://www.voidcn.com/article/p-vjoeevph-bkp.html)
root@book-virtual-machine:/work/huo_ov5640_camera/uboot_tiny4412/sd_fuse/tiny4412# ./sd_fusing.sh /dev/sdd
/dev/sdd reader is identified.
Error: Block device size (62333952) is too large (原脚本会返回,这边做过修改,不让程序返回)
---------------------------------------
BL1 fusing
16+0 records in
16+0 records out
8192 bytes (8.2 kB) copied, 0.0592814 s, 138 kB/s
---------------------------------------
BL2 fusing
28+0 records in
28+0 records out
14336 bytes (14 kB) copied, 0.217092 s, 66.0 kB/s
---------------------------------------
u-boot fusing
548+1 records in
548+1 records out
280584 bytes (281 kB) copied, 1.92679 s, 146 kB/s
---------------------------------------
TrustZone S/W fusing
184+0 records in
184+0 records out
94208 bytes (94 kB) copied, 0.866241 s, 109 kB/s
---------------------------------------
U-boot image is fused successfully.
Eject SD card and insert it again.

3. 基于已有的4412示例系统
sdflash.exe制作sd卡supperboot
将images文件夹放到sd卡根目录下,将ini配置文件改为OS=Linux,后sd卡启动自动加载qt系统

SD 卡上的 images/FriendlyARM.ini改为 USB MODE
USB-Mode = yes,之后就不会像上面所说的自动安装,需要借助MiniTools工具

**************问题点:
BL1 version:  N/A (TrustZone Enabled BSP)--------什么意思?
dnw 0x40008000(这个地址如何确定)??????????????   ------- 根据芯片手册bank来确定
    4412的内存是1G(0x40000000)大小,内存控制器的片选地址得来的
    ./board/samsung/tiny4412/config.mk:13:CONFIG_SYS_TEXT_BASE = 0x43e00000
Kernel: arch/arm/boot/zImage is ready
Kernel: arch/arm/boot/Image is ready
Kernel: arch/arm/boot/zImage is ready
multiple (or no) load addresses: 
This is incompatible with uImages
Specify LOADADDR on the commandline to build an uImage
make[1]: *** [arch/arm/boot/uImage] Error 1
make: *** [uImage] Error 2

原因是没有指定 加载地址 --------------------- https://blog.csdn.net/u011011827/article/details/82995261
Load Address: 80008000        ?????? (内核在内存里储存的具体位置)
Entry Point:  80008000        ?????? (kernel_entry(0, machid, r2);的地址)
bootm 地址
    uImage = zImage + 头部信息
cmd_uimage 中 的 UIMAGE_LOADADDR 和 UIMAGE_ENTRYADDR
总结:
bootm与loadaddress不一致时,此种情况下,bootm会把uImage header后的zImage move到load address(见上方代码),然后go到entry point开始执行。 由此知道此时的load address必须等于entry point。
bootm与loadaddress一致时,此种情况下,bootm不会对uImage header后的zImage进行memory move的动作,而会直接go到entry point开始执行。因此此时的entry point必须设置为load address + 0x40。如果kernel boot过程没有到uncompressing the kernel,就可能是这里设置不对。
需要做测试:
    1. 编译时,不指定为40008000                make LOADADDR=0x40001000 uImage (可以运行)
    2. 40008000时,让bootm为40008000        make LOADADDR=0x40600000 uImage (此时不能运行,因为bootm地址和Loadaddress相同,都为0x40600000,停止在Starting kernel ...处)
    3. 40008000时,让bootm不为40008000
ERROR: image is not a fdt - must RESET the board to recover. (解决方法见下边)


**************困难点:
1. 如何在一个已有的uboot下下载新的uboot.bin,内核以及文件系统?dnw(不好用,传输地址失败),tftp(不知道具体命令以及貌似网卡没驱动)
网卡是usb转网卡,在uboot没有驱动,所以建议用fastboot,除非自己有能力移植usb网卡驱动
https://blog.csdn.net/morixinguan/article/details/70478650

dnw 0x40008000    //此句话的意思是将usb接收到的数据存储到0x40008000.所以此处当usb的dnw不好用时,可使用网络tftp或ftp来获得,不一定要usb
ubuntu:dnw sd_fuse/tiny4412/E4412_N.bl1.bin
mmc write 1 0x40008000 0 0x10

tftp命令:
tftp 0x60003000 uImage;  //将 uImage 下载到 0x60003000(下载到内存)
bootm 0x60003000;  // 从 0x60003000 开始解析 zImage 的要求,并按照要求行事. 注意: 此时不是从 0x60003000 启动.

//错误点:
TINY4412 # fastboot
Error: No MBR is found at SD/MMC.
Hint: use fdisk command to make partitions.
//以下是解决方法:
TINY4412 # fdisk -c 0
Count: 10000
fdisk is completed

total_block_count: 15269888 
sdInfo.C_start: 0 
sdInfo.H_start: 1 
sdInfo.S_start: 1 
sdInfo.C_end: 1022 
sdInfo.H_end: 253 
sdInfo.S_end: 59 
sdInfo.available_block: 15255394 
sdInfo.unit: 14927 
sdInfo.total_block_count: 15269888 
sdInfo.addr_mode: 0 

partion #    size(MB)     block start #    block count    partition_Id 
   1          6399          2015145        13105906          0x0C 
   2           306           134343          626934          0x83 
   3           306           761277          626934          0x83 
   4           306          1388211          626934          0x83 
TINY4412 # fastboot  
[Partition table on MoviNAND]


//miniusb不好用
用着就检测不到miniusb设备了
解决方法:
a. 插拔线不起作用
b. 只能重新刷一般sd卡,minitools工具使用的系统


sudo apt-get install android-tools-adb android-tools-fastboot
http://www.metsky.com/archives/740.html

常见问题:
//1. (loadaddress,entryaddress设置不正确)
Starting kernel ...

//以下情况可能性比较多,串口?uboot bootarg设置?或是其它
Starting kernel ...
Uncompressing Linux... done, booting the kernel

ERROR: image is not a fdt - must RESET the board to recover.
This seems like the memory at which fdt is getting corrupted (usually due to overwrite) when kernel image starts to un-compress. Try loading fdt at a higher address e.g. 0xe00000.
Flattened Device Tree blob at 42000000
Booting using the fdt blob at 0x42000000 (此地址应该就是设备树的地址了,所以内核地址loadaddress不应覆盖此地址。比如make LOADADDR=0x42000000 uImage就会出现上述错误)

问:编译内核时如何分别指定load address和entry address
答:修改目录下的Makefile


tiny4412                     arm         armv7       tiny4412            samsung        exynos
baudrate=115200
bootargs=console=ttySAC0,115200n8 androidboot.console=ttySAC0 uhost0=n ctp=2 skipcali=y vmalloc=512m lcd=S70
bootcmd=movi read kernel-4-4 0 40600000;movi read dtb 0 42000000;bootm 0x40600000 - 0x42000000

Loading Kernel Image ... OK    卡在此处,详细如下:
## Booting kernel from Legacy Image at 40600000 ...
   Image Name:   Linux-4.4.38-tiny4412
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    3615424 Bytes = 3530 KiB
   Load Address: 30008040 (难道是因为内存条基地址为0x40000000,30008040不在内存编码内??????)
   Entry Point:  30008040
   Verifying Checksum ... OK
## Flattened Device Tree blob at 42000000
   Booting using the fdt blob at 0x42000000
   Loading Kernel Image ... OK

还真是,是因为内存条基地址为0x40000000,30008040不在内存编码内。make LOADADDR=0x30008040 uImage会出现以上问题,改为make LOADADDR=0x40008000 uImage就能正常启动内核


记录:9:30开始 ----- 
1. 重新安装sd卡系统
    前面的usb用不了,后面的usb基本满,而且sd卡比较大,不能并排
2. 重新制作sd卡的开源uboot
    ubuntu下居然检测不到/dev/下的设备
    试了多次无果,2019年1月29日 09:52:14
    重启完 2019年1月29日 09:56:29,终于有/dev/sdc设备了
    开始重新刷uboot等 2019年1月29日 10:00:38
    接下来顺利完成 2019年1月29日 10:07:46


 

  • 3
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值