源码分享 移植u-boot-2015.4到TQ2440 完美支持nand启动 tftp下载功能

为了给我的老伙计TQ2440升下级,经过几天的折腾,在这位大哥(https://www.cnblogs.com/pengdonglin137/p/4541705.html)的基础上,继续移植u-boot-2015.4使u-boot支持nand启动kernel-2.6.30和dm9000网口(tftp下载)功能.

测试环境

ubuntu 16.04

tq2440  (nandflash 256MB) 版

 

源码分享

废话不说直接发源代码

经过测试的u-boot源码,kernel源码,rootfs镜像,交叉编译工具下载地址:

 

链接: https://pan.baidu.com/s/1BhU0lUijG1i7VBCnliBS4Q

提取码: jivb

 

编译kernel

下载解压linux-2.6.30.4.tar.gz

修改build.sh, 变量PATH换成你的交叉工具链接路径。

#!/bin/sh      
                                                                                                                                                                                             
//PATH换成你的工具链路径                                                                                                                                                                           
export PATH=$PATH:/data/linux/s3c2440/tq2440/tools/cross_compile/opt/EmbedSky/4.3.3/bin/
export ARCH=arm
export CROSS_COMPILE=arm-linux-

make tq2440_defconfig
make -j16

执行编译命令:

./build.sh

最后会生成最终镜像 zImage.bin

 

烧写kernel和rootfs

下载rootfs镜像root.bin

使用天嵌自带的烧写工具

#####    Boot for Nor Flash Main Menu   #####
#####     EmbedSky USB download mode     #####

[1] Download u-boot or STEPLDR.nb1 or other bootloader to Nand Flash
[2] Download Eboot (eboot.nb0) to Nand Flash
[3] Download Linux Kernel (zImage.bin) to Nand Flash
[5] Download CRAMFS image to Nand Flash
[6] Download YAFFS image (root.bin) to Nand Flash
[7] Download Program (uCOS-II or TQ2440_Test) to SDRAM and Run it
[8] Boot the system
[9] Format the Nand Flash
[0] Set the boot parameters
[a] Download User Program (eg: uCOS-II or TQ2440_Test)
[b] Download LOGO Picture (.bin) to Nand  Flash 
[l] Set LCD Parameters 
[n] Enter TFTP download mode menu 
[o] Download u-boot to Nor Flash
[r] Reboot u-boot
[t] Test Linux Image (zImage)
[q] quit from menu
Enter your selection: 

将zImage.bin和root.bin下载至nand flash

 

编译u-boot

下载解压uboot-2015.tar.gz后,修改build.sh, 变量PATH换成你的交叉工具链接路径。

#!/bin/sh                                                                                                                                                                                                   

//PATH换成你的工具链路径
export PATH=$PATH:/data/linux/s3c2440/tq2440/tools/cross_compile/opt/EmbedSky/4.3.3/bin/
export ARCH=arm
export CROSS_COMPILE=arm-linux-

make -j16 tq2440_defconfig
make -j16
./mk.sh

执行编译命令:

./build.sh

最后会生成最终镜像 u-boot.out

 

烧写u-boot

经测试天嵌默认的烧写工具并不支持烧写我们的u-boot.out,原因可能是我们u-boot.out太大了。

#####    Boot for Nor Flash Main Menu   #####
#####     EmbedSky USB download mode     #####

[1] Download u-boot or STEPLDR.nb1 or other bootloader to Nand Flash
[2] Download Eboot (eboot.nb0) to Nand Flash
[3] Download Linux Kernel (zImage.bin) to Nand Flash
[5] Download CRAMFS image to Nand Flash
[6] Download YAFFS image (root.bin) to Nand Flash
[7] Download Program (uCOS-II or TQ2440_Test) to SDRAM and Run it
[8] Boot the system
[9] Format the Nand Flash
[0] Set the boot parameters
[a] Download User Program (eg: uCOS-II or TQ2440_Test)
[b] Download LOGO Picture (.bin) to Nand  Flash 
[l] Set LCD Parameters 
[n] Enter TFTP download mode menu 
[o] Download u-boot to Nor Flash
[r] Reboot u-boot
[t] Test Linux Image (zImage)
[q] quit from menu
Enter your selection: 

我们可以选择t先进入kernel,进入rootfs,然后执行以下命令,直接烧写u-boot.out到第一个分区

flash_eraseall /dev/mtd0
sync
dd if=u-boot.out of=/dev/mtdblock0
sync

 

值得注意的是,以上mtdblock0分区的大小需要在kernel中预先设定好

我们给u-boot分2M空间,使用我的kernel源码即可,以下修改已经默认完成。

--- a/arch/arm/plat-s3c24xx/common-EmbedSky.c
+++ b/arch/arm/plat-s3c24xx/common-EmbedSky.c
@@ -44,7 +44,7 @@ static struct mtd_partition EmbedSky_default_nand_part[] = {
        [0] = {
                .name   = "EmbedSky_Board_uboot",
                .offset = 0x00000000,
-               .size   = 0x00040000,
+               .size   = 0x00200000,
        },
 #if defined(CONFIG_FB_S3C24X0_TFT1024768)
        [1] = {

 

烧写完成后,重启就可以看到从nand-flash正常启动。

U-Boot 2015.04-gb2d425b-dirty (Jun 07 2019 - 12:26:41)

CPUID: 32440001
FCLK:      400 MHz
HCLK:      100 MHz
PCLK:       50 MHz
DRAM:  64 MiB
WARNING: Caches not enabled
Flash: 0 Bytes
NAND:  256 MiB
*** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Net:   dm9000
Hit any key to stop autoboot:  0 

NAND read: device 0 offset 0x200000, size 0x300000
s3c2440_nand_correct_data: 1 bit error detected at byte 1771. Correcting from 0xe9 to 0xeb...OK
 3145728 bytes read: OK
Kernel image @ 0x30008000 [ 0x000000 - 0x262424 ]

Starting kernel ...

Uncompressing Linux....................................................................................................................................................................... done, booting th.
Linux version 2.6.30.4-EmbedSky (jojo@jojo) (gcc version 4.3.3 (Sourcery G++ Lite 2009q1-176) ) #7 Thu Jun 6 20:54:21 CST 2019
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
CPU: VIVT data cache, VIVT instruction cache
Machine: TQ2440
Memory policy: ECC disabled, Data cache writeback
CPU S3C2440A (id 0x32440001)
S3C24XX Clocks, (c) 2004 Simtec Electronics
S3C244X: core 400.000 MHz, memory 100.000 MHz, peripheral 50.000 MHz
CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 16256
Kernel command line: noinitrd root=/dev/mtdblock2 init=/linuxrc console=ttySAC0,115200n8
NR_IRQS:85
irq: clearing pending ext status 00080000
irq: clearing subpending status 00000002
PID hash table entries: 256 (order: 8, 1024 bytes)
Console: colour dummy device 80x30
console [ttySAC0] enabled
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)

 

tftp 功能测试:

U-Boot 2015.04-gb2d425b-dirty (Jun 07 2019 - 12:26:41)

CPUID: 32440001
FCLK:      400 MHz
HCLK:      100 MHz
PCLK:       50 MHz
DRAM:  64 MiB
WARNING: Caches not enabled
Flash: 0 Bytes
NAND:  256 MiB
*** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Net:   dm9000
Hit any key to stop autoboot:  0 
TQ2440 # 
TQ2440 # setenv serverip 192.168.1.102
TQ2440 # tftp 0x30008000 zImage.bin
dm9000 i/o: 0x20000300, id: 0x90000a46 
DM9000: running in 16 bit mode
MAC: 00:0c:29:2a:5c:a5
could not establish link
Using dm9000 device
TFTP from server 192.168.1.102; our IP address is 192.168.1.6
Filename 'zImage.bin'.
Load address: 0x30008000
Loading: #################################################################
         #################################################################
         #########################################
         2.2 MiB/s
done
Bytes transferred = 2499516 (2623bc hex)
TQ2440 # 

 

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值