[嵌入式] 重温Mini2440(四)移植Yaffs2文件系统 (Yet Another Flash File System)

一. 获取Yaffs2源码

根据Yaffs官网可知,通过git clone来获取最新的源码:

git clone git://www.aleph1.co.uk/yaffs2

在这里插入图片描述

二. 给内核打yaffs2补丁

./patch-ker.sh c m /home/lps/linux-4.9.270

三. 配置内核

1.回到Linux内核源码目录,配置yaffs2

make menuconfig

File systems-Miscellaneous filesystems

在这里插入图片描述
2.重新编译内核

#多任务编译内核
make -j4
#制作uImage
./mkuImage.sh  

四. 生成根文件系统镜像

1.使用友善之臂的配套工具将根文件系统打包成二进制文件

./mkyaffs2image-128M rootfs rootfs.img

2.赋予rootfs.img可读权限

chmod a+r rootfs.img

3.将根文件系统镜像拷贝到tftp共享目录备用

cp rootfs.img tftpboot/

文件系统的制作方法参考:
[嵌入式] 重温Mini2440(三)使用BusyBox制作根文件系统

五. 烧写镜像

这里使用u-boot的网络命令来烧写,进入u-boot命令行
1.通过tftp命令下载rootfs.img

[u-boot@MINI2440]# tftp 0x30008000 rootfs.img
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.15.230; our IP address is 192.168.15.233
Filename 'rootfs.img'.
Load address: 0x30008000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         ###################################################
done
Bytes transferred = 7417344 (712e00 hex)

2.擦除Nand Flash根文件系统的分区,擦除的大小略大于镜像的大小

[u-boot@MINI2440]# nand erase 0x580000 0x720000

NAND erase: device 0 offset 0x580000, size 0x720000
Erasing at 0xc8000003900000 --   0% complete.
OK

要根据之前配置内核时的分区来确定根文件系统的起始位置:

0x000000000000-0x000000060000 : "u-boot"
0x000000060000-0x000000080000 : "u-boot-env"
0x000000080000-0x000000580000 : "kernel"
0x000000580000-0x00000cd80000 : "root"

3.烧写rootfs.img至Nand Flash的root分区

[u-boot@MINI2440]# nand write.yaffs 0x30008000 0x580000 $filesize

NAND write: device 0 offset 0x580000, size 0x712e00
Skip the first good block 58000000000000
Writing at 0xc6000000020000 -- 100% is complete. 7192576 bytes written: OK

4.配置启动参数

[u-boot@MINI2440]# setenv bootargs noinitrd root=/dev/mtdblock3 init=/linuxrc console=ttySAC0,115200
[u-boot@MINI2440]# save
Saving Environment to NAND...
Erasing Nand...
Erasing at 0x6000000000002 --   0% complete.
Writing to Nand... done

六. 启动内核挂载根文件系统

利用NFS方式加载内核并启动,最后成功挂载yaffs2根文件系统

[u-boot@MINI2440]# boot
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
File transfer via NFS from server 192.168.15.230; our IP address is 192.168.15.233
Filename '/home/lps/rootfs/uImage'.
Load address: 0x30008000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         ##########################
done
Bytes transferred = 3123360 (2fa8a0 hex)
## Booting kernel from Legacy Image at 30008000 ...
   Image Name:   mini2440
   Created:      2021-06-03   5:44:41 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    3123296 Bytes =  3 MB
   Load Address: 30008000
   Entry Point:  30008040
   Verifying Checksum ... OK
   XIP Kernel Image ... OK
OK
Using machid 0x7cf from environment

Starting kernel ...

Booting Linux on physical CPU 0x0
Linux version 4.9.270 (lps@lps-ubuntu) (gcc version 4.4.3 (ctng-1.6.1) ) #5 Thu Jun 3 13:44:05 CST 2021
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c000717f
CPU: VIVT data cache, VIVT instruction cache
Machine: MINI2440
Memory policy: Data cache writeback
CPU S3C2440A (id 0x32440001)

【省略一万字】

yaffs: dev is 32505859 name is "mtdblock3" rw
yaffs: passed flags ""
VFS: Mounted root (yaffs filesystem) on device 31:3.
Freeing unused kernel memory: 184K
This architecture does not have kernel memory protection.

Please press Enter to activate this console.

在这里插入图片描述

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值