在Mini2440开发板上烧写与调试uboot与kernel

发布于:2024-05-17 ⋅ 阅读:(66) ⋅ 点赞:(0)

以下内容源于学习过程中的相关记录,欢迎互相交流与共同进步。

参考博客

(1)https://www.cnblogs.com/qiaoqiao2003/p/3737045.html

(2)JZ2440采用nfs挂载根文件系统_查看nfs根文件系统(rootfs)-CSDN博客

 

一、uboot的烧写与调试

1.1 使用提供的uboot镜像文件

这里我使用的uboot镜像文件,是“mini2440光盘\images\u-boot.bin文件”。

首先利用NorFlash中的Supperboot2440.bin,配合Minitools软件,将上面提到的u-boot.bin文件烧写到NandFlash中;然后以NandFlash方式启动。发现uboot可以正常运行,即这个uboot是针对mini2440开发板移植好的uboot文件,可以正确地初始化开发板硬件以及引导内核启动。

1.2 使用编译得到的uboot镜像文件

上面是烧写现成的u-boot.bin文件,但这会我想编译移植好的源码以得到u-boot.bin文件。但不知为何(源码有问题?交叉编译工具链版本不合适?待解决),我对 “mini2440光盘\linux\bootloader\u-boot” 目录中的源码进行编译,并将生成的u-boot.bin文件烧写到mini2440开发板的NandFlash或者NorFlash中,启动开发板时,开发板一直在蜂鸣,且串口无输出。

1.3 板子的烧写情况

简而言之,此时NandFlash中烧写有u-boot.bin,NorFlash中烧写有Superboot2440.bin。

二、kernel的烧写与调试

2.1 烧写与调试过程 

2.2.1 uboot尝试启动Minitools软件烧写的zImage_TD35文件时报错

当采用uboot进行引导时,如果不打断其启动过程,如果要引导的内核是使用Minitools软件烧录到NandFlash中的zImage_TD35文件,那么启动结果如下所示(卡在 “Startting kernel…” 处): 

U-Boot 2010.03 (Jul 03 2012 - 10:18:03)

 modified by tekkamanninja (tekkamanninja@163.com)
 Love Linux forever!!

I2C:   ready
DRAM:  64 MB
Flash:  2 MB
NAND:  256 MiB
In:    serial
Out:   serial
Err:   serial
USB slave is enable!
Net:   dm9000
Hit any key to stop autoboot:  0 

NAND read: device 0 offset 0x60000, size 0x500000
NAND read from offset 6000033fbb914 failed 0
 5242880 bytes read: ERROR

Starting kernel ... #卡死在这个地方

2.2.2 利用uboot将zImage烧写到NandFlash中时可以启动内核 

如果打断uboot的启动,在uboot的shell界面中,通过 “tftp 30008000 zImage” 将zImage文件下载到30008000中,然后先后使用 “nand erase 60000 500000”、“nand write 30008000 60000 500000”命令把zImage从内存中烧写到NandFlash中,方便下次直接从NandFlash启动内核。

[u-boot@MINI2440]# tftp 30008000 zImage
dm9000 i/o: 0x20000300, id: 0x90000a46 
DM9000: running in 16 bit mode
MAC: 08:08:11:18:12:27
operating at 100M full duplex mode
Using dm9000 device
TFTP from server 192.168.1.141; our IP address is 192.168.1.88
Filename 'zImage'.
Load address: 0x30008000
Loading: T #################################################################
         #################################################################
         ##############
done
Bytes transferred = 2109444 (203004 hex)
[u-boot@MINI2440]# nand erase 60000 500000

NAND erase: device 0 offset 0x60000, size 0x500000
Erasing at 0x54000002800000 --   0% complete.
OK
[u-boot@MINI2440]# nand write 30008000 60000 500000

NAND write: device 0 offset 0x60000, size 0x500000
Writing at 0x54000000020000 -- 100% is complete. 5242880 bytes written: OK
[u-boot@MINI2440]# 

最后再执行“bootm 30008000”来启动内核,根据tftp时选择的zImage不同,会有两种情况:

(1)使用我自己编译源码得到的zImage(首先编译mini2440光盘\linux\linux-2.6.32.2-mini2440-20120606目录下的源码,即先后执行make mini2440_defconfig、make zImage,在内核源码/arch/arm/boot/目录下会生成zImage文件),则此时启动过程中Mini2440屏幕会显示两个企鹅头,且内核在尝试挂载文件系统时出错:

[u-boot@MINI2440]# bootm 30008000

Starting kernel ...

Uncompressing Linux................................................................................................................................... done, booting the kernel.
Linux version 2.6.32.2 (root@ubuntu) (gcc version 4.4.1 (Sourcery G++ Lite 2009q3-67) ) #4 Wed May 15 15:41:27 CST 2024
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
CPU: VIVT data cache, VIVT instruction cache
Machine: FriendlyARM Mini2440 development board
Memory policy: ECC disabled, Data cache writeback
CPU S3C2440A (id 0x32440001)
S3C24XX Clocks, (c) 2004 Simtec Electronics
S3C244X: core 405.000 MHz, memory 101.250 MHz, peripheral 50.625 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/mtdblock3 console=ttySAC0 init=/linuxrc
PID hash table entries: 256 (order: -2, 1024 bytes)
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory: 64MB = 64MB total
Memory: 60524KB available (3648K code, 419K data, 168K init, 0K highmem)
SLUB: Genslabs=11, HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
Hierarchical RCU implementation.
NR_IRQS:85
irq: clearing pending status 02000000
irq: clearing subpending status 00000003
irq: clearing subpending status 00000002
Console: colour dummy device 80x30
console [ttySAC0] enabled
Calibrating delay loop... 201.93 BogoMIPS (lpj=504832)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
NET: Registered protocol family 16
S3C Power Management, Copyright 2004 Simtec Electronics
S3C2440: Initialising architecture
S3C2440: IRQ Support
S3C24XX DMA Driver, (c) 2003-2004,2006 Simtec Electronics
DMA channel 0 at c4808000, irq 33
DMA channel 1 at c4808040, irq 34
DMA channel 2 at c4808080, irq 35
DMA channel 3 at c48080c0, irq 36
S3C244X: Clock Support, DVS off
bio: create slab <bio-0> at 0
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
s3c-i2c s3c2440-i2c: slave address 0x10
s3c-i2c s3c2440-i2c: bus frequency set to 98 KHz
s3c-i2c s3c2440-i2c: i2c-0: S3C I2C adapter
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 2048 (order: 2, 16384 bytes)
TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 2048 bind 2048)
TCP reno registered
NET: Registered protocol family 1
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
yaffs May 15 2024 00:02:03 Installing. 
JFFS2 version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
ROMFS MTD (C) 2007 Red Hat, Inc.
msgmni has been set to 118
alg: No test for stdrng (krng)
io scheduler noop registered
io scheduler anticipatory registered (default)
io scheduler deadline registered
io scheduler cfq registered
Console: switching to colour frame buffer device 80x40
fb0: s3c2410fb frame buffer device
leds    initialized
buttons initialized
pwm     initialized
adc     initialized
s3c2440-uart.0: s3c2410_serial0 at MMIO 0x50000000 (irq = 70) is a S3C2440
s3c2440-uart.1: s3c2410_serial1 at MMIO 0x50004000 (irq = 73) is a S3C2440
s3c2440-uart.2: s3c2410_serial2 at MMIO 0x50008000 (irq = 76) is a S3C2440
brd: module loaded
S3C24XX NAND Driver, (c) 2004 Simtec Electronics
s3c24xx-nand s3c2440-nand: Tacls=3, 29ns Twrph0=7 69ns, Twrph1=3 29ns
s3c24xx-nand s3c2440-nand: NAND soft ECC
NAND device: Manufacturer ID: 0xec, Chip ID: 0xda (Samsung NAND 256MiB 3,3V 8-bit)
Scanning device for bad blocks
Bad eraseblock 199 at 0x0000018e0000
Bad eraseblock 457 at 0x000003920000
Bad eraseblock 928 at 0x000007400000
Bad eraseblock 1363 at 0x00000aa60000
Bad eraseblock 1417 at 0x00000b120000
Bad eraseblock 1524 at 0x00000be80000
Bad eraseblock 1591 at 0x00000c6e0000
Bad eraseblock 1805 at 0x00000e1a0000
Bad eraseblock 2018 at 0x00000fc40000
Creating 5 MTD partitions on "NAND 256MiB 3,3V 8-bit":
0x000000000000-0x000000040000 : "supervivi"
0x000000040000-0x000000060000 : "param"
0x000000060000-0x000000560000 : "Kernel"
0x000000560000-0x000040560000 : "root"
mtd: partition "root" extends beyond the end of device "NAND 256MiB 3,3V 8-bit" -- size truncated to 0xfaa0000
0x000000000000-0x000040000000 : "nand"
mtd: partition "nand" extends beyond the end of device "NAND 256MiB 3,3V 8-bit" -- size truncated to 0x10000000
dm9000 Ethernet Driver, V1.31
eth0: dm9000e at c4872300,c4876304 IRQ 51 MAC: 08:90:90:90:90:90 (chip)
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
s3c2410-ohci s3c2410-ohci: S3C24XX OHCI
s3c2410-ohci s3c2410-ohci: new USB bus registered, assigned bus number 1
s3c2410-ohci s3c2410-ohci: irq 42, io mem 0x49000000
usb usb1: configuration #1 chosen from 1 choice
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
usbcore: registered new interface driver libusual
s3c2440-usbgadget s3c2440-usbgadget: S3C2440: increasing FIFO to 128 bytes
mice: PS/2 mouse device common for all mice
S3C24XX RTC, (c) 2004,2006 Simtec Electronics
s3c2410-rtc s3c2410-rtc: rtc disabled, re-enabling
s3c2410-rtc s3c2410-rtc: rtc core: registered s3c as rtc0
i2c /dev entries driver
S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics
s3c2410-wdt s3c2410-wdt: watchdog inactive, reset disabled, irq enabled
cpuidle: using governor ladder
sdhci: Secure Digital Host Controller Interface driver
sdhci: Copyright(c) Pierre Ossman
s3c-sdi s3c2440-sdi: powered down.
s3c-sdi s3c2440-sdi: mmc0 - using pio, sw SDIO IRQ
usbcore: registered new interface driver hiddev
usbcore: registered new interface driver usbhid
usbhid: v2.6:USB HID core driver
Advanced Linux Sound Architecture Driver Version 1.0.21.
No device for DAI UDA134X
No device for DAI s3c24xx-i2s
S3C24XX_UDA134X SoC Audio driver
UDA134X SoC Audio Codec
asoc: UDA134X <-> s3c24xx-i2s mapping ok
ALSA device list:
  #0: S3C24XX_UDA134X (UDA134X)
TCP cubic registered
NET: Registered protocol family 17
s3c2410-rtc s3c2410-rtc: hctosys: invalid date/time
yaffs: dev is 32505859 name is "mtdblock3"
yaffs: passed flags ""
yaffs: Attempting MTD mount on 31.3, "mtdblock3"
yaffs: auto selecting yaffs2
block 157 is bad
block 415 is bad
block 886 is bad
block 1321 is bad
block 1375 is bad
block 1482 is bad
block 1549 is bad
block 1763 is bad
block 1976 is bad
yaffs_read_super: isCheckpointed 0
VFS: Mounted root (yaffs filesystem) on device 31:3.
Freeing init memory: 168K
Warning: unable to open an initial console.
Failed to execute /linuxrc.  Attempting defaults...
Kernel panic - not syncing: No init found.  Try passing init= option to kernel.
[<c0037978>] (unwind_backtrace+0x0/0xd4) from [<c02e3ce4>] (panic+0x40/0x11c)
[<c02e3ce4>] (panic+0x40/0x11c) from [<c00325b8>] (init_post+0xcc/0xf4)
[<c00325b8>] (init_post+0xcc/0xf4) from [<c0008438>] (kernel_init+0xdc/0x10c)
[<c0008438>] (kernel_init+0xdc/0x10c) from [<c0033868>] (kernel_thread_exit+0x0/0x8)

(2)直接使用mini2440光盘\images\linux\zImage_TD35这个文件,则此时屏幕只显示一只企鹅。另外尝试挂载文件系统时依然出错。接下来都用这个zImage_TD35这个文件。

#省略内核启动的部分输出
s3c2410-rtc s3c2410-rtc: hctosys: invalid date/time
yaffs: dev is 32505859 name is "mtdblock3"
yaffs: passed flags ""
yaffs: Attempting MTD mount on 31.3, "mtdblock3"
yaffs: auto selecting yaffs2
block 157 is bad
block 415 is bad
block 886 is bad
block 1321 is bad
block 1375 is bad
block 1482 is bad
block 1549 is bad
block 1763 is bad
block 1976 is bad
yaffs_read_super: isCheckpointed 0
VFS: Mounted root (yaffs filesystem) on device 31:3.
Freeing init memory: 156K
Warning: unable to open an initial console.
Failed to execute /linuxrc.  Attempting defaults...
Kernel panic - not syncing: No init found.  Try passing init= option to kernel.
Backtrace: 
[<c00341cc>] (dump_backtrace+0x0/0x10c) from [<c03419d0>] (dump_stack+0x18/0x1c)
 r7:00000000 r6:00000000 r5:c001f930 r4:c049e2b0
[<c03419b8>] (dump_stack+0x0/0x1c) from [<c0341a20>] (panic+0x4c/0x114)
one_wire_status: 2
[<c03419d4>] (panic+0x0/0x114) from [<c002f598>] (init_post+0xa8/0x10c)
 r3:00000000 r2:c384ef00 r1:00000000 r0:c03f5d3c
[<c002f4f0>] (init_post+0x0/0x10c) from [<c00084b4>] (kernel_init+0xe4/0x114)
 r5:c001f930one_wire_status: 4
 r4:c049da40
[<c00083d0>] (kernel_init+0x0/0x114) from [<c004bbbc>] (do_exit+0x0/0x620)
 r5:00000000 r4:00000000

2.2 解决文件系统挂载失败的问题

由上面可知,uboot已经可以引导内核的启动,而且内核已经启动了,但在试图挂载文件系统时出现错误。现在我们来解决这个错误。首先解决启动过程中的一些小问题与小警告。

(1)解决问题“No filesystem could mount root”

启动过程中有以下提示(上面2.2.2(1)中之所以没有这个提示,是因为我已经修正过来了):

No filesystem could mount root, tried:  ext3 cramfs vfat msdos romfs
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(31,3)

这个错误是因为我在配置内核make menuconfig时没有配置支持yaffs选项。在配置内核时,添加yaffs2选项支持即可(https://blog.51cto.com/286520810/781377)。

File systems-->[*]Miscellaneous filesystems--><*>YAFFS2 file system support

(2)解决问题“ftl_cs: FTL header not found.”

 启动过程中有以下提示(上面2.2.2(1)中之所以没有这个提示,是因为我已经修正过来了):

Creating 5 MTD partitions on "NAND 256MiB 3,3V 8-bit":
0x000000000000-0x000000040000 : "supervivi"
0x000000040000-0x000000060000 : "param"
ftl_cs: FTL header not found.
0x000000060000-0x000000560000 : "Kernel"
ftl_cs: FTL header not found.
0x000000560000-0x000040560000 : "root"
mtd: partition "root" extends beyond the end of device "NAND 256MiB 3,3V 8-bit" -- size truncated to 0xfaa0000
ftl_cs: FTL header not found.
0x000000000000-0x000040000000 : "nand"
mtd: partition "nand" extends beyond the end of device "NAND 256MiB 3,3V 8-bit" -- size truncated to 0x10000000

在配置内核 make menuconfig时,进到Device Drivers -> Memory Technology Devices (MTD) ,取消下面这三个选项的选择,然后保存配置并重新编译即可。

<> FTL (Flash Translation Layer) support
<> NFTL (NAND Flash Translation Layer) support
<> INFTL (Inverse NAND Flash Translation Layer) support

(3)解决问题“Failed to execute /linuxrc”

由于2.1中提到uboot引导使用Minitools软件烧写的zImage_TD35时报错,而文件系统也是用该软件烧写的,我怀疑这软件烧写出错,于是参考以NFS方式挂载rootfs的步骤 ,将文件系统改为NFS文件系统的格式,挂载之前为X210开发板涉及的根文件系统。

其中设置bootargs为:

root=/dev/nfs nfsroot=192.168.1.141:/home/xjh/iot/embedded_basic/rootfs/rootfs_xjh ip=192.168.1.88:192.168.1.141:192.168.1.1:255.255.255.0::eth0:off init=/linuxrc console=ttySAC0,115200

原来的bootargs为:

noinitrd root=/dev/mtdblock3 console=ttySAC0 init=/linuxrc

此时启动流程最后为:

eth0: link down
IP-Config: Complete:
     device=eth0, addr=192.168.1.88, mask=255.255.255.0, gw=192.168.1.1,
     host=192.168.1.88, domain=, nis-domain=(none),
     bootserver=192.168.1.141, rootserver=192.168.1.141, rootpath=
Looking up port of RPC 100003/2 on 192.168.1.141
eth0: link up, 100Mbps, full-duplex, lpa 0xCDE1
Looking up port of RPC 100005/1 on 192.168.1.141
VFS: Mounted root (nfs filesystem) on device 0:11.
Freeing init memory: 156K
Warning: unable to open an initial console.
Kernel panic - not syncing: Attempted to kill init!
Backtrace: 
[<c00341cc>] (dump_backtrace+0x0/0x10c) from [<c03419d0>] (dump_stack+0x18/0x1c)
 r7:c3823ec8 r6:c381d000 r5:00000004 r4:c049e2b0
[<c03419b8>] (dump_stack+0x0/0x1c) from [<c0341a20>] (panic+0x4c/0x114)
[<c03419d4>] (panic+0x0/0x114) from [<c004c1ac>] (do_exit+0x5f0/0x620)
 r3:c0468ba4 r2:c3823cd4 r1:00002710 r0:c03f917c
[<c004bbbc>] (do_exit+0x0/0x620) from [<c004c220>] (do_group_exit+0x44/0xc4)
one_wire_status: 2
[<c004c1dc>] (do_group_exit+0x0/0xc4) from [<c0055f1c>] (get_signal_to_deliver+0x194/0x32c)
 r5:c3822000 r4:0830009f
[<c0055d88>] (get_signal_to_deliver+0x0/0x32c) from [<c0032938>] (do_signal+0x5c/0x544)
one_wire_status: 2
[<c00328dc>] (do_signal+0x0/0x544) from [<c0032e74>] (do_notify_resume+0x54/0x60)
[<c0032e20>] (do_notify_resume+0x0/0x60) from [<c002ff28>] (work_pending+0x1c/0x20)
 r5:00000007one_wire_status: 4
 r4:000e625c

上面的警告“Warning: unable to open an initial console.”,可以通过在虚拟机中的根文件系统/dev目录下执行“mknod console c 5 1”命令进行消除。

但是NFS文件系统方式也启动不了。那问题出现在哪里呢?猜想如下:

(1)用于编译内核源码的交叉编译工具链不对

linux启动时显示kernel panic- not syncing: Attempted to kill init!的第3点。我使用的交叉编译工具链的版本是4.4.1的(通过arm-linux-gcc -v的显示可知),在内核配置时也增加了EABI的支持。但是问题依然没有解决。

Kernel Features  --->
            [*] Use the ARM EABI to compile the kernel                   
            [*]   Allow old ABI binaries to run with this kernel (EXPERIMENTA)

(2)内核没有配置支持NFS文件系统

在内核配置时已经勾选NFS文件系统的支持。

(3)根文件系统没有制作好

但是在X210却是可以挂载的,应该制作好的?

ARM下Kernel panic - not syncing: Attempted to kill init!错误分析-CSDN博客

Kernel panic - not syncing: Attempted to kill init-CSDN博客

(4)配置阶段没有做好

问题是应该配置哪些,没有经验啊!先暂时搁置吧……


2.3 暂时的做法

最后是这样的:我把1.1中提到的uboot利用Minitools软件烧写到NandFlash中,把mini2440光盘\images\linux目录下的rootfs_qtopia_qt4文件利用Minitools软件烧写到NandFlash中,唯独zImage_TD35是通过uboot下载到NandFlash中的(自己编译得到的zImage文件也可以启动,只是屏幕有两个企鹅头,启动起来后画面也类似,而且触屏时不能进入系统),这样居然就可以完全启动起来了。

问题是,这个过程好像2.2.2就是这样的,那会为何挂载不上文件系统呢?我猜想,是不是我不小心把NandFlahs格式化了,从而删除了NandFlash中的文件系统而不自知?毕竟之前经常不小心在uboot启动是按“f”(表示格式化NandFlash)。

这说明,一切问题,出现在不能通过用Minitools软件将zImage_TD35下载到NandFlash中?毕竟2.1.1中之前我这样操作时uboot就无法引导zImage_TD35启动。

下一步计划,是探明为何自己编译得到的uboot文件会一直蜂鸣且串口无输出,以及如何移植内核源码,使得zImage的效果与zImage_TD35一致。


网站公告

今日签到

点亮在社区的每一天
去签到