[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

扫描二维码关注公众号,回复: 1635497 查看本文章

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!





猜你喜欢

转载自blog.csdn.net/qhzm72/article/details/79202739