1. 程式人生 > >[31]_tftp下載kernel、rootfs並設定啟動引數

[31]_tftp下載kernel、rootfs並設定啟動引數

3、燒寫映像檔案到SPI Flash
    以16M SPI Flash為例。
    1)地址空間說明
        |      1M       |      4M       |      11M      |
        |---------------|---------------|---------------|
        |     boot      |     kernel    |     rootfs    |

以下的操作均基於圖示的地址空間分配,您也可以根據實際情況進行調整。
   2)燒寫u-boot
        sf probe 0
        mw.b 82000000 ff 100000
        tftp 0x82000000 u-boot-hi3520D.bin
        sf probe 0
        sf erase 0 100000
        sf write 82000000 0 100000
        reset   

  3)燒寫核心
        mw.b 82000000 ff 400000
        tftp 82000000 uImage_hi3520d
        sf probe 0
        sf erase 100000 400000
        sf write 82000000 100000 400000

4) 燒寫檔案系統
        mw.b 82000000 ff b00000
        tftp 0x82000000 rootfs_uclibc_256k.jffs2
        sf erase 500000 b00000
        sf write 82000000 500000 b00000

5)設定啟動引數

setenv bootargs 'mem=64M console=ttyAMA0,115200 root=/dev/mtdblock2 rootfstype=jffs2 mtdparts=hi_sfc:1M(boot),4M(kernel),11M(rootfs)'

setenv bootcmd 'sf probe 0;sf read 0x82000000 0x100000 0x400000;bootm 0x82000000'
        saveenv

我的虛擬機器伺服器上的系統映象:

root@ubuntu:/tftpboot# ls
rootfs_uclibc_256k.jffs2  u-boot_hi3520d.bin  uImage_hi3520d_full

hisilicon # mw.b 82000000 ff 400000

hisilicon # tftp 82000000 uImage_hi3520d_full
Hisilicon ETH net controler
miiphy_register: non unique device name '0:3'
miiphy_register: non unique device name '0:2'
MAC:   00-00-23-34-45-66

UP_PORT : phy status change : LINK=DOWN : DUPLEX=FULL : SPEED=100M
UP_PORT : phy status change : LINK=UP : DUPLEX=FULL : SPEED=100M
TFTP from server 192.168.15.1xx; our IP address is 192.168.15.1xx
Download Filename 'uImage_hi3520d_full'.

Download to address: 0x82000000
Downloading: #################################################
done

Bytes transferred = 3196076 (30c4ac hex)
hisilicon # sf probe 0

16384 KiB hi_sfc at 0:0 is now current device
hisilicon #         sf eras        sf write 82000000 100000 400000
sf - SPI flash sub-system

hisilicon # sf probe 0
16384 KiB hi_sfc at 0:0 is now current device
hisilicon # sf erase 100000 400000
Erasing at 0x500000 -- 100% complete.

hisilicon # sf write 82000000 100000 400000

Writing at 0x500000 -- 100% complete.
hisilicon # mw.b 82000000 ff b00000

hisilicon # tftp 0x82000000 rootfs_uclibc_256k.jffs2
Hisilicon ETH net controler
miiphy_register: non unique device name '0:3'
miiphy_register: non unique device name '0:2'
MAC:   00-00-23-34-45-66

UP_PORT : phy status change : LINK=DOWN : DUPLEX=FULL : SPEED=100M
UP_PORT : phy status change : LINK=UP : DUPLEX=FULL : SPEED=100M
TFTP from server 192.168.15.1xx; our IP address is 192.168.15.1xx
Download Filename 'rootfs_uclibc_256k.jffs2'.

Download to address: 0x82000000
Downloading: #################################################
done

Bytes transferred = 6976840 (6a7548 hex)
hisilicon # sf erase 500000 b00000
Erasing at 0x1000000 -- 100% complete.

hisilicon # setenv bootargs 'mem=64M console=ttyAMA0,115200 root=/dev/mtdblock2 rootfstype=jffs2 mtdparts=hi_sfc:1M(boot),4M(kernel),11M(rootfs)

hisilicon # setenv bootcmd 'sf probe 0;sf read 0x82000000 0x100000 0x400000;bootm 0x82000000'
hisilicon # saveenv

Saving Environment to SPI Flash...
Erasing SPI flash, offset 0x00080000 size 256K ...done
Writing to SPI flash, offset 0x00080000 size 256K ...done

hisilicon # reset

執行後出現:

VFS: Mounted root (jffs2 filesystem) on device 31:2.
Freeing init memory: 140K
Kernel panic - not syncing: No init found.  Try passing init= option to kernel. See Linux Documentation/init.txt for guidance.

很明顯是根檔案系統上的linuxrc沒有被執行,官方給的需要引數還是存在問題的,於是我在傳參中指定了init程序的位置。

hisilicon # setenv bootargs 'mem=64M console=ttyAMA0,115200 root=/dev/mtdblock2 rootfstype=jffs2 mtdparts=hi_sfc:1M(boot),4M(kernel),11M(rootfs),init=/linuxrc

出現了下面的這種情況:

Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(2,0)

參考網路的一些說法,rootfs_uclibc_256k.jffs2可能沒有被燒寫到正確的位置,不過我看了核心啟動列印的資訊,地址是正確的,也有可能是我沒真正把rootfs燒寫了spi flash 上,於是我用tftp重新燒寫了rootfs,啟動後果然是: 

VFS: Mounted root (jffs2 filesystem) on device 31:2.
Freeing init memory: 140K
Kernel panic - not syncing: Attempted to kill init!