⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 linux_1_4_x_93xx_flash_file_system.txt

📁 英培特公司ARM开发板手册,包括地址说明,WINCE,LINUX安装
💻 TXT
字号:
*******************************************************************
Demo JFFS2 Flash File System under Atanasoff 1.4.x using EP93xx



This document describes how to setup and demonstrate JFFS2 Flash File System in Linux.


1. Please read the following section in cirrus-arm-linux-1.4.x/readme.txt.

FLASH - EDB7312, EDB9301, EDB9302, EDB9312, EDB9315

    Access to the NOR FLASH is provided through the /dev/mtd?, /dev/mtdr?, and
    /dev/mtdblock? device files.  The /dev/mtd? device files are character
    devices that provide read/write access, the /dev/mtdr? device files are
    also character devices but provide read-only access, and the /dev/mtdblock?
    device files are block devices.  The first MTD device (i.e. /dev/mtd0)
    always refers to the entire FLASH device; great care should be taken when
    using it.  The remaining devices refer to the various partitions that were
    created from within RedBoot (partitions can only be created from within
    RedBoot).  The available partitions and their names can be found by typing
    the following into a shell:

        cat /proc/mtd

    The "eraseall" command can be used to erase the contents of a partition.
    An empty partition can be used for a file system by enabling the JFFS or
    JFFS2 filesystem in the kernel and then using the "mount" command to mount the
    appropriate /dev/mtdblock device.  The following menu items in the kernel
    configuration must be enabled to support the JFFS or JFFS2 filesystems:

        File systems
          <*> Journalling Flash File System (JFFS) support
          <*> Journalling Flash File System v2 (JFFS2) support

    ..............
    ...............

   The following menu items in the kernel configuration must be enabled to
    support the NOR FLASH on the EDB9312:

        Memory Technology Devices (MTD)
          <*> Memory Technology Device (MTD) support
          <*>   MTD partitioning support
          <*>   RedBoot partition table parsing
          <*>   Direct char device access to MTD devices
          <*>   Caching block device access to MTD devices
          RAM/ROM/Flash chip drivers
            <*> Detect flash chips by Common Flash Interface (CFI) probe
            <*> Support for Intel/Sharp flash chips
          Mapping drivers for chip access
            <*> CFI Flash device mapped on EDB93xx (01,02,07,12,or 15)


2. Go to the root directory of Linux source code, 
   cirrus-arm-linux-1.4.x/linux-2.4.21.  Configure the Linux kernel 
   according to the instructions in the readme.txt file, and rebuild 
   the Linux kernel:

   make clean
   make menuconfig
   make dep
   make zImage

   zImage is in arch/arm/boot.
   copy zImage to /tftpboot.

3. Since the size of ramdisk.gz for EDB9301 is the smallest one, 
   we want to put it into the flash file system.

   cd cirrus-arm-linux-1.4.x/edb9301
   cp ramdisk.gz ramdisk.gz.org     
   gunzip ramdisk.gz
   mkdir /tmp/jffs2_dir
   mount -o loop ramdisk /tmp/jffs2_dir

4. The MTD utilities are in cirrus-arm-linux-1.4.x/mtd-20011217.
   Build the MTD utilities, and use it to create a JFFS2 file system.

   cd cirrus-arm-linux-1.4.x/mtd-20011217
   cd util
   make
   ls    (you should see mkfs.jffs2)

   ./mkfs.jffs2 -d /tmp/jffs2_dir -o jffs2fs.out
   cp jffs2fs.out /tftpboot
    
   

5. Program jffs2fs.out, ramdisk, and zImage to flash.
   From the RedBoot prompt of edb93xx, enter:
   
   load -r -v -b 0x1000000  jffs2fs.out 
   load -r -v -b 0x800000 ramdisk.gz 
   load -r -v -b 0x80000  zImage 

   fis init -f 
   fis create -b 0x800000 -l 0x?????? ramdisk
   fis create -b 0x80000 -l 0x?????? zImage
   fis create -b 0x1000000 -l 0x?????+1M jffs2fs 
    
   (Note: "-l ??????" The length depends on the size of the file. 
    Since jffs2 needs extra space for garbage collection, we suggest
    1M larger than the actual size of the file system image for
    garbage collection.)

      
   fis list    
   (You should see the newly-created flash partitions)

6. The demo how to mount jffs2fs after Linux has been brought up.

   Turn off power on the EDB93xx.

   fis load ramdisk
   fis load zImage
   exec -r 0x800000  -s 0x600000 

   Upon Linux prompt:
   / #
   / # cat /proc/mtd
       dev:    size   erasesize  name
       mtd0: 02000000 00040000 "NOR flash on EDB9312"
       mtd1: 00040000 00040000 "RedBoot"
       mtd2: 00600000 00040000 "ramdisk"
       mtd3: 00100000 00040000 "zImage"
       mtd4: 00300000 00040000 "jffs2fs"
       mtd5: 019c0000 00040000 "unallocated space"
       mtd6: 00001000 00040000 "RedBoot config"
       mtd7: 00040000 00040000 "FIS directory"
   / # cd mnt
   /mnt # mkdir jffs2_dir
   /mnt # mount -t jffs2 /dev/mtdblock4 jffs2_dir


   (If you see the following message,

   jffs2_scan_empty(): Empty block at 0x00380708 ends at 0x003807c0 (with 0xfffffff
e)! Marking dirty
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x003807c0: 0xfffe in
stead ...............................
 
    It is normal because the jffs2 partition created in Redboot doesn't clean up 
    the space used for garbage collection. The problem can be avoided by using 
    mkfs.jffs2 to pad output with 0xFF, which is beyond Cirrus' support)


   /mnt # cd  jffs2_dir
   /mnt/jffs2_dir # ls
    bin        etc        home       mnt        sbin       usr
    dev        funky.mp3  lib        proc       tmp        var
    /mnt/jffs2_dir # do_someting_you_want
    .......
   /mnt/jffs2_dir # cd ..
   /mnt # umount jffs2_dir
 

7. Demo how to bring up Linux with Root File System on Flash.

   Power off, then power on the EDB93xx.

   fis load zImage
   exec -c "root=/dev/mtdblock4 console=ttyAM0"

   where "root=/dev/mtdblock4" tells Linux to get the root file system from /dev/mtdblock4.
   and "console=ttyAM0" sets the console to UART1 so you can capture all messages.

   Be patient. It takes several minutes to mount the flash file system.



For Linux 1.4.3 and before:
===========================

   In RedBoot, the flash is configured as buffered and cached in the MMU table. 
   Always un-mount the jffs2 file system before power off EDB93xx so JFFS2 data can
   be flushed back to flash. 

   /mnt/jffs2_dir # cd ..
   /mnt # umount jffs2_dir

   Even un-mount the jffs2 file system every time, you may still experience 
   the data lost. The best way to fix the problem is to configure the flash as 
   unbuffered and uncached in the MMU table. The MMU table is set in redboot.bin.  

   For the Linux_1-4-3, 

   1. please revise the file
      cirrus-arm-linux-1.4.3/ecos-2.0/packages/hal/arm/arm9/ep93xx/v2_0/include/hal_platform_setup.h 
      as follow,

    //
    // Create a read-only mapping of FLASH at virtual address 0x6000_0000.
    //
    add     r1, r0, #0x00001800
#if defined(HAL_PLATFORM_EP9301) || defined(HAL_PLATFORM_EP9302)
    mov     r2, #0x00000040
#else
    mov     r2, #0x00000080
#endif
-    orr     r3, r12, #0x0000001e    ( delete the line)
+    orr     r3, r12, #0x00000012    (add the line)
map_flash_6:
        str     r3, [r1], #4
        add     r3, r3, #0x00100000
        subs    r2, r2, #4
        bne     map_flash_6

   2. Rebuild redboot.bin

      Go to cirrus-arm-linux-1.4.3/edb93xx.

      cp redboot.bin redboot.bin.org  (save the old image)

      Remove the old building directory. Otherwise, the build script won't
      compile the new source code.

      rm -rf .do_not_edit

      make redboot

      You must see "Building redboot.....". 
      Otherwsie the new source code is not built.
      The newly-built redboot.bin will be in the directory.



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -