uboot對jffs2檔案系統的支援

來源:互聯網
上載者:User
從uboot代碼中知道,uboot支援linux下幾種熱門檔案系統,如cramfs, ext2, jffs2。由於我的linux系統用的根檔案系統是jffs2, 就想能不能讓uboot支援jffs2檔案系統,然後將linux核心直接放到根檔案系統中,由uboot來讀出核心再啟動,就可以減少一個flash分區,並且linux系統起來後,更新核心並不需要重新燒寫核心分區,只需要wget一個核心檔案就可以了,少掉很多事。
答案是肯定的,並且更改也非常簡單,但一切的前提是flash讀寫操作正常,這可以從本論壇中“RM9200的uboot中調試flash的經曆”中找到調試flash的方法。
在include/configs/at91rm9200dk.h設定檔中定義:
#undef CONFIG_JFFS2_CMDLINE
#define CONFIG_JFFS2_DEV "nor0"
#define CONFIG_JFFS2_PART_SIZE 0x1C0000
#define CONFIG_JFFS2_PART_OFFSET 0x40000

uboot支援多個jffs2分區,可以通過命令設定分區,及啟用不同的工作分區。但由於我們並不需要在uboot中有太多操作(一個關鍵問題是uboot中不能寫檔案,只能讀檔案,做不了太多有意義的事),所以不支援命令對jffs2分區,只支援一個jffs2分區。上面參數分別定義的分區大小與分區起始位移地址,比較好理解。實際上,我的flash只分三個區,分別是uboot, rootfs, userfs,rootfs分區起始地址是0x40000, 大小是0x1c0000, 正是上面設定的參數值。

設定uboot的啟動參數為:#define CONFIG_BOOTCOMMAND "fsload uImage; bootm"
將linux核心檔案uImage放到根檔案系統中,啟動後如下:
U-Boot code: 21F00000 -> 21F21F48   BSS: -> 21F3FA88
RAM Configuration:
Bank #0: 20000000 32 MB
SST 39VF3201 flash
Flash:   4 MB
NAND:   64 MB
In: serial
Out: serial
Err: serial
Hit any key to stop autoboot:   0
uboot> ls
Scanning JFFS2 FS: .. done.
drwxr-xr-x        0 Wed May 02 06:36:59 2007 dev
drwxr-xr-x        0 Sun Apr 01 08:23:29 2007 home
drwxr-xr-x        0 Sat Jun 02 12:23:10 2007 bin
drwxr-xr-x        0 Sat May 12 03:21:46 2007 opt
drwxr-xr-x        0 Sat Jun 02 12:23:10 2007 sbin
drwxr-xr-x        0 Wed May 09 13:33:23 2007 mnt
drwxr-xr-x        0 Sun Apr 01 08:23:51 2007 usr
drwxr-xr-x        0 Tue Jun 19 13:09:31 2007 lib
drwxr-xr-x        0 Wed May 30 12:36:11 2007 etc
drwxr-xr-x        0 Sun Apr 01 08:23:29 2007 root
lrwxrwxrwx    11 Sat Jun 02 12:23:10 2007 linuxrc -> bin/busybox
lrwxrwxrwx    12 Sun May 27 01:08:47 2007 var -> /mnt/ram/var
lrwxrwxrwx        9 Sun May 27 01:07:02 2007 proc -> /tmp/proc
lrwxrwxrwx    16 Sun May 27 01:07:50 2007 tmp -> /mnt/ram/var/tmp
-rw-r--r--   1071560 Thu Jan 01 00:01:42 1970 uImage
uboot>

linux核心啟動如下,顯然jffs2檔案系統從uboot中啟動成功:
U-Boot 1.1.4 (Jun 26 2007 - 17:39:49)
U-Boot code: 21F00000 -> 21F21F48   BSS: -> 21F3FA88
RAM Configuration:
Bank #0: 20000000 32 MB
SST 39VF3201 flash
Flash:   4 MB
NAND:   64 MB
In: serial
Out: serial
Err: serial
Hit any key to stop autoboot:   0
### JFFS2 loading 'uImage' to 0x20008000
Scanning JFFS2 FS: .. done.
### JFFS2 load complete: 1071560 bytes loaded to 0x20008000
## Booting image at 20008000 ...
Image Name: Linux-2.6.14
Created:    2007-06-27   13:04:05 UTC
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 1071496 Bytes =   1 MB
Load Address: 20008000
Entry Point:   20008040
Verifying Checksum ... OK
XIP Kernel Image ... OK

Starting kernel ...

Uncompressing Linux.............................................................Linux version 2.6.14 (root@localhost.localdomain) (gcc version 3.4.1) #74 Wed J7CPU: ARM920Tid(wb)
[41129200] revision 0 (ARMv4T)
Machine: Atmel AT91RM9200-DK
Memory policy: ECC disabled, Data cache writeback
Clocks: CPU 179 MHz, master 59 MHz, main 18.432 MHz
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
Kernel command line: mem=32M noinitrd console=ttyS0,115200 init=/linuxrc root=/2AT91: 128 gpio irqs in 4 banks
PID hash table entries: 256 (order: 8, 4096 bytes)
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: 32MB = 32MB total
Memory: 30116KB available (1795K code, 344K data, 96K init)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
softlockup thread 0 started up.
NET: Registered protocol family 16
NetWinder Floating Point Emulator V0.97 (double precision)
devfs: 2004-01-31 Richard Gooch (rgooch@atnf.csiro.au)
devfs: boot_options: 0x1
JFFS2 version 2.2. (NAND) (C) 2001-2003 Red Hat, Inc.
JFFS2: default compression mode: priority
yaffs Jun 27 2007 21:03:42 Installing.
。。。。。。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.