您尚未登录。

楼主 #1 2020-05-09 20:53:36

缥缈九哥
会员
注册时间: 2020-05-09
已发帖子: 93
积分: 96

测试基于linux-2.6.27的9G9260开发板MTD驱动 --缥缈九哥

测试基于linux-2.6.27的9G9260开发板MTD驱动

1,修改内核源码:
root@yuanxh-desktop:/home/yuanxh/sam9260/linux-2.6.27-9g9260# vi arch/arm/mach-at91/board-sam9260ek.c
在第174行修改成如下:

 /*
  * NAND flash
  */
 static struct mtd_partition __initdata ek_nand_partition[] = {
  {
   .name   = "Bootstrap",
   .offset = 0,
   .size   = 0x20000,
  },
  {
   .name   = "U-boot",
   .offset = 0x20000,
   .size   = 0xe0000,
  },
  {
   .name   = "uImage",
   .offset = 0x100000,
   .size   = 0x200000,
  },
  {
   .name   = "ramdisk",
   .offset = 0x300000,
   .size   = 0x400000,
  },
  {
   .name   = "rootfs",
   .offset = 0x700000,
   .size   = 0x900000,
  },
  {
   .name   = "data",
   .offset = 16 * 1024 * 1024,
   .size   = MTDPART_SIZ_FULL,
  },
 };

2,修改内核配置:

 root@yuanxh-desktop:/home/yuanxh/sam9260/linux-2.6.27-9g9260# make menuconfig

    Boot options  ---> 
  (mem=64M console=ttyS0,115200 root=/dev/mtdblock4 rootfstype=jffs2 init=/linuxrc)
  
 Device Drivers  --->
 <*> Memory Technology Device (MTD) support  --->
 <*>   MTD concatenating support
 [*]   MTD partitioning support
 [*]     Command line partition table parsing
 <*>   Direct char device access to MTD devices
 -*-   Common interface to block layer for MTD 'translation layers'
 <*>   Caching block device access to MTD devices 
 <*>   NAND Device Support  --->
 <*>   Support for NAND Flash / SmartMedia on AT91 and AVR32
         ECC management for NAND Flash / SmartMedia on AT91 / AVR32 (Software ECC)  --->

 File systems  --->
 <*> Second extended fs support
 Miscellaneous filesystems  --->
 <*> Journalling Flash File System v2 (JFFS2) support 
 (0)   JFFS2 debugging verbosity (0 = quiet, 2 = noisy) 
 [*]   JFFS2 write-buffering support
 [*]   JFFS2 summary support (EXPERIMENTAL)

默认就是如此,不作修改。

3,编译内核:
root@yuanxh-desktop:/home/yuanxh/sam9260/linux-2.6.27-9g9260# make uImage
root@yuanxh-desktop:/home/yuanxh/sam9260/linux-2.6.27-9g9260# cp arch/arm/boot/uImage uImage-2.6.27-9g9260.bin
root@yuanxh-desktop:/home/yuanxh/sam9260/linux-2.6.27-9g9260# sz  uImage-2.6.27-9g9260.bin

4,生成JFFS2文件系统:
root@yuanxh-desktop:/nfsboot# ./mkfs.jffs2 -d rootfs -o jffs2-2.6.27-9g9260.bin -n --pagesize=0x800 --eraseblock=0x20000 --pad=0x900000
root@yuanxh-desktop:/nfsboot# sz jffs2-2.6.27-9g9260.bin

5,测试MTD驱动
# cat /proc/mtd
# flash_eraseall /dev/mtd5
# mount -t jffs2 /dev/mtdblock5 /mnt
# cd /app
# touch yuanxihua
# vi yuanxhua
掉电后重新启动,看到文件及内容还存在。

离线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn