JZ2440 v3.0 linux-3.4.2 busybox1.20.0内核 和 文件系统移植 修改分区大小 yaffs2文件系统补丁 开源资源查找

零、平台 + 软件版本 + 烧写

平台 和 版本

  1. JZ2440v3.0
  2. u-boot-1.1.6 + u-boot-1.1.6_jz2440.patch ftp://ftp.denx.de/pub/u-boot/
  3. linux-3.4.2 https://mirrors.edge.kernel.org/pub/linux/kernel/v3.x/
    内核编译选的mini2440 ,机器id设置 set machid (mini2440 7cf ; smdk2440 16a)
  4. busybox1.20.0 https://busybox.net/downloads/
    内核yaffs2补丁 https://github.com/lifeyx/yaffs2.git
  5. arm-linux-gcc-4.3.2 https://sourceforge.net/projects/sunsea1026/files/work/arm-linux-gcc-4.3.2.tgz/download(这个资源真tm难找)

查找开源资源https://osdn.net

烧写

u-boot用oflash工具烧写 ,windows下。(裸机,board – openJTAG – win)
内核和文件系统用DNW,windows下。(uboot cmd,boardUSB – win)

一、编译系统的一堆命令

1. 编译uboot

tar xjf u-boot-1.1.6.tar.bz2    			解压
cd u-boot-1.1.6/                			到目录下
patch -p1 < ../u-boot-1.1.6_jz2440.patch  	打补丁 
make 100ask24x0_config                    	配置make
make                                      	make

2. 编译内核

tar -xjf linux-3.4.2.tar.bz2
cd linux-3.4.2
make mini2440_defconfig
./patch-ker.sh c m ../linux-3.4.2 # yaffs2文件补丁,按照下面错误2步骤下载 打补丁 编译
make menuconfig
make uImage -j8

3. 文件系统 yaffs2

# 解压编译安装到fsroot
tar -xjf busybox-1.20.0.tar.bz2
make menuconfig
	Busybox Settings  ---> 
	Build Options  --->
	Cross Compiler prefix (输入 arm-linux- 或 在中)
make
mkdir fsroot1.20.0
make CONFIG_PREFIX=~/Desktop/uboot-kernel/fsroot1.20.0 install

# 在fsroot中创建文件
mkdir etc
mkdir lib usr/lib
cp -pd /usr/local/arm/arm-linux-gcc-4.3.2/arm-none-linux-gnueabi/libc/armv4t/lib/*.so* lib/
cp -pd /usr/local/arm/arm-linux-gcc-4.3.2/arm-none-linux-gnueabi/libc/armv4t/usr/lib/*.so* usr/lib/
 注意安装库的时候:加-pd选项(把链接文件cp后也作为链接文件,否则会cp链接后的实际文件,导致fs异常庞大,p是保留源文件属性。)

cd etc
vim inittab
-----------------------------
# /etc/inittab
::sysinit:/etc/init.d/rcS
console::askfirst:-/bin/sh
::ctrlaltdel:/sbin/reboot
::shutdown:/bin/umount -a -r
-----------------------------
mkdir init.d
vim init.d/rcS
------------------------------------------
#!/bin/sh
mount -a
mkdir /dev/pts
mount -t devpts devpts /dev/pts
echo /sbin/mdev > /proc/sys/kernel/hotplug
mdev -s
------------------------------------------
chmod a+x init.d/rcS
vim fstab
------------------------------------------------------------------
# device     mount-point    type   options        dump  fsck order
proc           /proc        proc   defaults        0     0
tmpfs          /tmp         tmpfs  defaults        0     0
sysfs          /sys         sysfs  defaults        0     0
tmpfs          /dev         tmpfs  defaults        0     0
------------------------------------------------------------------
mkdir dev
cd dev
sudo mknod console c 5 1
sudo mknod null c 1 3

mkdir proc tmp mnt sys root

# 制作yaffs2文件
mkyaffs2image fsroot1.20.0 fsroot.yaffs2  # 需要安装mkyaffs2image工具

在这里插入图片描述

额外的,自启动脚本配置 + 自动配置网卡

自启动脚本配置 + 自动配置网卡
vi etc/init.d/rcS
------------------------------------------
#!/bin/sh
mount -a
mkdir /dev/pts
mount -t devpts devpts /dev/pts
echo /sbin/mdev > /proc/sys/kernel/hotplug
mdev -s
exec /etc/rc.local # 添加这一行
------------------------------------------
vi etc/rc.local
----------------------------------------------------------
ifconfig eth0 192.168.1.100
mount -t nfs -o tcp,nolock 192.168.1.103:/nfs/fs_root /mnt
----------------------------------------------------------
chmod +x rc.local

二、修改默认分区大小

需要修改uboot的宏(或者直接在uboot cmd中修改) 和 内核代码的mtd分区和偏移,使得两者保持一致。

注意:如果进入uboot后print命令出现了mtdparts参数,那么需要去掉它才是我们在uboot中指定的默认参数(我们在uboot源码中修改的宏),否则会使用print出来的参数,就算uboot源码改过也不起作用。
uboot命令中去掉mtdparts参数方法:
set mtdparts
save

1. 修改uboot的宏

uboot中在include/configs/100ask24x0.h,中修改,

// 只修改这里不一定起作用,还要去掉uboot参数mtdparts。
#define MTDPARTS_DEFAULT "mtdparts=nandflash0:256k@0(bootloader)," \
                            "128k(params)," \
                            "4m(kernel)," \ // 2m -> 4m
                            "-(root)"

2. 修改内核的mtd分区大小和偏移

在文件arch/arm/mach-s3c24xx/mach-mini2440.c中,
原来nand为2MB用于存储内核镜像,现在修改为4M,偏移对应修改即可。

/* NAND Flash on MINI2440 board */
static struct mtd_partition mini2440_default_nand_part[] __initdata = {
	[0] = {
		.name	= "bootloader",
		.size	= SZ_256K,
		.offset	= 0,
	},
	[1] = {
		.name	= "params",
		.size	= SZ_128K,
		.offset	= SZ_256K,
	},
	[2] = {
		.name	= "kernel",
		/* 5 megabytes, for a kernel with no modules
		 * or a uImage with a ramdisk attached */
		.size	= 0x00400000,						// 这里修改内核分区大小
		.offset	= SZ_256K + SZ_128K,
	},
	[3] = {
		.name	= "root",
		.offset	= SZ_256K + SZ_128K + 0x00400000,	// 这里修改root分区的offset
		.size	= MTDPART_SIZ_FULL,
	},
};

三、在源码中修改uboot的tftp ip

在uboot的include/configs/100ask24x0.h中,

#define CONFIG_IPADDR		192.168.1.100
#define CONFIG_SERVERIP		192.168.1.103

四、报错

1. 读出内核但是 内核校验出错

NAND read: device 0 offset 0x60000, size 0x200000

Reading data from 0x25f800 -- 100% complete.
 2097152 bytes read: OK
## Booting image at 30007fc0 ...
   Image Name:   Linux-3.4.2
   Created:      2020-06-26   7:42:00 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    2472992 Bytes =  2.4 MB
   Load Address: 30008000
   Entry Point:  30008000
   Verifying Checksum ... Bad Data CRC

在这里插入图片描述

1. 解决办法

如错误提示所示,内核大小为2.4MB,但是只从NAND中读出了2MB,当然校验出错。
需要修改内核分区的大小,保证uboot中的mtd分区大小和内核mtd分区大小和偏移保持一致即可。

2. 版本3.4.2内核无法识别yaffs2文件系统

List of all partitions:
1f00             256 mtdblock0  (driver?)
1f01             128 mtdblock1  (driver?)
1f02            4096 mtdblock2  (driver?)
1f03          257664 mtdblock3  (driver?)
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)
[<c000dc1c>] (unwind_backtrace+0x0/0xf8) from [<c0340dac>] (panic+0x74/0x1d0)
[<c0340dac>] (panic+0x74/0x1d0) from [<c0441e70>] (mount_block_root+0x1d0/0x22c)
[<c0441e70>] (mount_block_root+0x1d0/0x22c) from [<c0441f4c>] (mount_root+0x80/0

2. 解决办法

内核默认没有yaffs2文件系统格式,需要下载补丁,重新配置内核,再make umage。
这篇文章详细介绍了如何打yaffs2的补丁和修改编译的错误。
主要步骤:

  1. 下载yaffs源码 git clone git@github.com:lifeyx/yaffs2.git
  2. 打补丁到内核
    cd yaffs2/
    ./patch-ker.sh  c m linux-3.4.2 //c 将yffs2文件夹copy到linux-3.4.2/fs   m 指定多版本
    
  3. 配置内核
    make menuconfig
    
    -> File systems
          -> Miscellaneous filesystems (MISC_FILESYSTEMS [=y])
                 <*>   yaffs2 file system support 
    
    在这里插入图片描述

3. 文件系统挂上了 后面出错

s3c-rtc s3c2410-rtc: setting system clock to 2000-01-01 03:24:11 UTC (946697051)
ALSA device list:
  No soundcards found.
yaffs: dev is 32505859 name is "mtdblock3" rw
yaffs: passed flags ""
VFS: Mounted root (yaffs filesystem) on device 31:3.
Freeing init memory: 148K
Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000200

[<c000dc1c>] (unwind_backtrace+0x0/0xf8) from [<c0352d2c>] (panic+0x74/0x1d0)
[<c0352d2c>] (panic+0x74/0x1d0) from [<c001aabc>] (do_exit+0x628/0x74c)
[<c001aabc>] (do_exit+0x628/0x74c) from [<c001acbc>] (sys_exit+0x10/0x14)
[<c001acbc>] (sys_exit+0x10/0x14) from [<c0009220>] (ret_fast_syscall+0x0/0x2c)

3. 解决办法

内核配置选项中勾选下面两个选项,重新编译uImage:

[*] Use the ARM EABI to compile the kernel.
[*]  Allow old ABI binaries to run with this kernel (EXPERIMENTAL) (NEW)

在这里插入图片描述

五、打印信息

u-boot打印信息

1. u-boot启动打印

U-Boot 1.1.6 enable Ethernet alltime(May 15 2018 - 19:44:59)

DRAM:  64 MB
JEDEC PROBE: ID 90 0 0
Flash:  0 kB
NAND:  256 MiB
In:    serial
Out:   serial
Err:   serial
UPLLVal [M:38h,P:2h,S:2h]
MPLLVal [M:5ch,P:1h,S:1h]
CLKDIVN:5h


+---------------------------------------------+
| S3C2440A USB Downloader ver R0.03 2004 Jan  |
+---------------------------------------------+
USB: IN_ENDPOINT:1 OUT_ENDPOINT:3
FORMAT: <ADDR(DATA):4>+<SIZE(n+10):4>+<DATA:n>+<CS:2>
NOTE: Power off/on or press the reset button for 1 sec
      in order to get a valid USB device address.

Hit any key to stop autoboot:  0
ERROR: resetting DM9000 -> not responding
dm9000 i/o: 0x20000000, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 08:00:3e:26:0a:5b
could not establish link

##### 100ask Bootloader for OpenJTAG #####
[n] Download u-boot to Nand Flash
[c] Re-scan Nor Flash
[u] Copy bootloader from nand to nor
[v] Copy bootloader from nor to nand
[k] Download Linux kernel uImage
[j] Download root_jffs2 image
[y] Download root_yaffs image
[d] Download to SDRAM & Run
[z] Download zImage into RAM
[g] Boot linux from RAM
[f] Format the Nand Flash
[s] Set the boot parameters
[b] Boot the system
[r] Reboot u-boot
[q] Quit from menu
Enter your selection:

2. u-boot的print

1.8M的内核镜像文件,这里分配2M够用,
在这里插入图片描述

OpenJTAG> print
bootargs=noinitrd root=/dev/mtdblock3 init=/linuxrc console=ttySAC0,115200
bootcmd=nand read.jffs2 0x30007FC0 kernel; bootm 0x30007FC0
bootdelay=2
baudrate=115200
ethaddr=08:00:3e:26:0a:5b
netmask=255.255.255.0
mtdids=nand0=nandflash0
mtdparts=mtdparts=nandflash0:256k@0(bootloader),128k(params),2m(kernel),-(root)
serverip=192.168.1.103
ipaddr=192.168.1.100
stdin=serial
stdout=serial
stderr=serial
partition=nand0,0
mtddevnum=0
mtddevname=bootloader

Environment size: 452/131068 bytes
OpenJTAG> b
Unknown command 'b' - try 'help'

3. uboot mtd分区情况

在这里插入图片描述

OpenJTAG> mtd
device nand0 <nandflash0>, # parts = 4
 #: name                        size            offset          mask_flags
 0: bootloader          0x00040000      0x00000000      0
 1: params              0x00020000      0x00040000      0
 2: kernel              0x00200000      0x00060000      0
 3: root                0x0fda0000      0x00260000      0
active partition: nand0,0 - (bootloader) 0x00040000 @ 0x00000000
defaults:
mtdids  : nand0=nandflash0
mtdparts: mtdparts=nandflash0:256k@0(bootloader),128k(params),4m(kernel),-(root)

内核启动过程的打印信息

在这里插入图片描述

NAND read: device 0 offset 0x60000, size 0x200000

Reading data from 0x25f800 -- 100% complete.
 2097152 bytes read: OK
## Booting image at 30007fc0 ...
   Image Name:   Linux-2.6.22.6
   Created:      2018-05-15  11:57:26 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    1848728 Bytes =  1.8 MB
   Load Address: 30008000
   Entry Point:  30008000
   Verifying Checksum ... OK
   XIP Kernel Image ... OK

Starting kernel ...

Uncompressing Linux...................................................................................................................... done, booting the kernel.
Linux version 2.6.22.6 (root@book-virtual-machine) (gcc version 3.4.5) #1 Tue May 15 19:57:22 CST 2018
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
Machine: SMDK2440
Memory policy: ECC disabled, Data cache writeback
CPU S3C2440A (id 0x32440001)
S3C244X: core 400.000 MHz, memory 100.000 MHz, peripheral 50.000 MHz
S3C24XX Clocks, (c) 2004 Simtec Electronics
CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
CPU0: D VIVT write-back cache
CPU0: I cache: 16384 bytes, associativity 64, 32 byte lines, 8 sets
CPU0: D cache: 16384 bytes, associativity 64, 32 byte lines, 8 sets
Built 1 zonelists.  Total pages: 16256
Kernel command line: noinitrd root=/dev/mtdblock3 init=/linuxrc console=ttySAC0,115200
irq: clearing subpending status 00000003
irq: clearing subpending status 00000002
PID hash table entries: 256 (order: 8, 1024 bytes)
timer tcon=00500000, tcnt a2c1, tcfg 00000200,00000000, usec 00001eb8
Console: colour dummy device 80x30
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: 60976KB available (3264K code, 458K data, 140K init)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
NET: Registered protocol family 16
S3C2410 Power Management, (c) 2004 Simtec Electronics
S3C2440: Initialising architecture
S3C2440: IRQ Support
S3C2440: Clock Support, DVS off
S3C24XX DMA Driver, (c) 2003-2004,2006 Simtec Electronics
DMA channel 0 at c4800000, irq 33
DMA channel 1 at c4800040, irq 34
DMA channel 2 at c4800080, irq 35
DMA channel 3 at c48000c0, irq 36
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
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
NetWinder Floating Point Emulator V0.97 (double precision)
Registering GDB sysrq handler
JFFS2 version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
yaffs May 15 2018 19:56:07 Installing.
io scheduler noop registered
io scheduler anticipatory registered (default)
io scheduler deadline registered
io scheduler cfq registered
Console: switching to colour frame buffer device 60x34
fb0: s3c2410fb frame buffer device
lp: driver loaded but no devices found
ppdev: user-space parallel port driver
S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics
Serial: 8250/16550 driver $Revision: 1.90 $ 4 ports, IRQ sharing enabled
s3c2440-uart.0: s3c2410_serial0 at MMIO map 0x50000000 mem 0xf0400000 (irq = 70) is a S3C2440
s3c2440-uart.1: s3c2410_serial1 at MMIO map 0x50004000 mem 0xf0404000 (irq = 73) is a S3C2440
s3c2440-uart.2: s3c2410_serial2 at MMIO map 0x50008000 mem 0xf0408000 (irq = 76) is a S3C2440
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
loop: module loaded
line 400 <DM9KS> I/O: c486a000, VID: 90000a46
line 408 <DM9KS> I/O: c486a000, VID: 90000a46
<DM9KS> error version, chip_revision = 0x1a, chip_info = 0x3
id_val=0
S3C24XX NAND Driver, (c) 2004 Simtec Electronics
s3c2440-nand s3c2440-nand: Tacls=3, 30ns Twrph0=7 70ns, Twrph1=3 30ns
NAND device: Manufacturer ID: 0xec, Chip ID: 0xda (Samsung NAND 256MiB 3,3V 8-bit)
Scanning device for bad blocks
Bad eraseblock 46 at 0x005c0000
Bad eraseblock 785 at 0x06220000
Bad eraseblock 789 at 0x062a0000
Bad eraseblock 1622 at 0x0cac0000
Bad eraseblock 1698 at 0x0d440000
Creating 4 MTD partitions on "NAND 256MiB 3,3V 8-bit":
0x00000000-0x00040000 : "bootloader"
0x00040000-0x00060000 : "params"
0x00060000-0x00260000 : "kernel"
0x00260000-0x10000000 : "root"
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
Initializing USB Mass Storage driver...
usbcore: registered new interface driver usb-storage
USB Mass Storage support registered.
mice: PS/2 mouse device common for all mice
s3c2410 TouchScreen successfully loaded
input: s3c2410 TouchScreen as /class/input/input0
S3C24XX RTC, (c) 2004,2006 Simtec Electronics
s3c2440-i2c s3c2440-i2c: slave address 0x10
s3c2440-i2c s3c2440-i2c: bus frequency set to 390 KHz
s3c2440-i2c s3c2440-i2c: i2c-0: S3C I2C adapter
mapped channel 0 to 0
s3c2440-sdi s3c2440-sdi: powered down.
s3c2440-sdi s3c2440-sdi: initialisation done.
s3c2440-sdi s3c2440-sdi: running at 0kHz (requested: 0kHz).
s3c2440-sdi s3c2440-sdi: running at 196kHz (requested: 195kHz).
s3c2440-sdi s3c2440-sdi: running at 196kHz (requested: 195kHz).
s3c2440-sdi s3c2440-sdi: running at 196kHz (requested: 195kHz).
usbcore: registered new interface driver hiddev
s3c2440-sdi s3c2440-sdi: CMD[TIMEOUT] #2 op:UNKNOWN(8) arg:0x000001aa flags:0x0875 retries:0 Status:nothing to complete
s3c2440-sdi s3c2440-sdi: CMD[TIMEOUT] #3 op:APP_CMD(55) arg:0x00000000 flags:0x0875 retries:0 Status:nothing to complete
usbcore: registered new interface driver usbhid
drivers/hid/usbhid/hid-core.c: v2.6:USB HID core driver
Advanced Linux Sound Architecture Driver Version 1.0.14 (Thu May 31 09:03:25 2007 UTC).
ASoC version 0.13.1
s3c2440-sdi s3c2440-sdi: CMD[TIMEOUT] #4 op:APP_CMD(55) arg:0x00000000 flags:0x0875 retries:0 Status:nothing to complete
s3c2440-sdi s3c2440-sdi: CMD[TIMEOUT] #5 op:APP_CMD(55) arg:0x00000000 flags:0x0875 retries:0 Status:nothing to complete
s3c2410iis_probe...
s3c2440-sdi s3c2440-sdi: CMD[TIMEOUT] #6 op:APP_CMD(55) arg:0x00000000 flags:0x0875 retries:0 Status:nothing to complete
s3c2440-sdi s3c2440-sdi: CMD[TIMEOUT] #7 op:ALL_SEND_OCR(1) arg:0x00000000 flags:0x0861 retries:0 Status:nothing to complete
s3c2440-sdi s3c2440-sdi: powered down.
UDA1341 audio driver initialized
ALSA device list:
  No soundcards found.
TCP cubic registered
NET: Registered protocol family 1
drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
UDF-fs: No VRS found
yaffs: dev is 32505859 name is "mtdblock3"
yaffs: passed flags ""
yaffs: Attempting MTD mount on 31.3, "mtdblock3"
yaffs: auto selecting yaffs2
block 28 is bad
block 767 is bad
block 771 is bad
block 1604 is bad
block 1680 is bad
VFS: Mounted root (yaffs filesystem).
Freeing init memory: 140K
init started: BusyBox v1.7.0 (2008-01-22 10:04:09 EST)
starting pid 764, tty '': '/etc/init.d/rcS'

Please press Enter to activate this console.
starting pid 767, tty '/dev/ttySAC0': '/bin/sh'
#

参考内容

  1. https://www.cnblogs.com/multimicro/p/9872722.html
  2. https://www.cnblogs.com/zzb-Dream-90Time/p/9726900.html
  3. https://blog.csdn.net/Carl_0/article/details/87856439
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值