Edit online

存储配置

3 Mar 2025
Read time: 5 minute(s)

存储配置是编译的固件是否可刷机的关键步骤,但存储的更换要修改的地方较多,建议按照现有工程仿写需要 Bringup 的开发板。

SPI NAND 存储配置

SPI NAND 存储配置步骤如下:
  1. 配置 U-Boot 以支持特定的 SPI NAND 型号,确认开发板的型号被选中支持。
    注:

    kernel 分区比较大,默认打开了 SDK 支持的所有型号,不用选择。

    1. 查看 drivers/mtd/nand/spi/ 源码目录,确认 SPI NAND 器件的厂商是否在支持列表中。

      例如,查看源码目录中是否存在 winbond.c 。如果不存在,则需要添加新厂商支持,详情可查看 SPI NAND 移植

      SDK 默认支持了几种 SPI NAND,编译之前需要确认开发板的 SPI NAND 型号被选中支持,详情可查看 SPI NAND

    2. 执行下列命令进入 U-Boot 配置界面:
      make um
    3. 选择 Device Drivers > MTD Support,配置下列信息:
      (0x240000) Offset of bbt in nand
      (0x40000) Range of bbt in nand
      [*] Define U-boot binaries locations in SPI NAND
      (0x100000) Location in SPI NAND to read U-Boot from
      [ ] Support Micron SPI NAND
      [ ] Support Macronix SPI NAND
      [*] Support Winbond SPI NAND
      [ ] Support Winbond SPI NAND CONTINUOUS READ MODE
      [*] Support GigaDevice SPI NAND
      [ ] Support Toshiba SPI NAND
      [*] Support FudanMicro SPI NAND
      [*] Support Foresee SPI NAND
      [*] Support Zbit SPI NAND
      [ ] Support Elite SPI NAND
      [ ] Support ESMT SPI NAND
      [ ] Support UMTEK SPI NAND
      SPI Flash Support  --->
      UBI support  --->

      U-Boot 和 SPL 分区一般都比较小,如果开启的 SPI NAND 型号过多,存储容易越界,建议仅打开需要使用的型号。

  2. 配置文件系统。

  3. 调整固件大小。
    固件的大小要和分区大小相匹配,可以自动适配也可以手工调整:
    • 自动适配。
      1. Filesystem images 配置界面,按如下选择:
        RootFS images  --->
        [ ] UserFS 1  ----
        [ ] UserFS 2  ----
        [ ] UserFS 3  ----
        [ ] Generate burner format image
        [*] Auto calculate partition size to generate image                 //通过分区大小自动生成固件
    • 手工调整。
      1. Filesystem images > RootFS images 界面,配置下列信息:
        [ ] ext2/3/4 root filesystem
        [ ] cpio the root filesystem (for use as an initial RAM filesystem)
        [ ] initial RAM filesystem linked into linux kernel
        [ ] jffs2 root filesystem
        [ ] squashfs root filesystem
        [ ] tar the root filesystem
            ubi parameter select (spi-nand all type support)  --->
        [*] ubi image containing an ubifs root filesystem
        [ ]   Use custom config file
        ()    Additional ubinize options
        -*- ubifs root filesystem
        (0x2000000) ubifs size(Should be aligned to MB)                      //固件大小,32M
        ubifs runtime compression (lzo)  --->
        Compression method (no compression)  --->
        (-F)  Additional mkfs.ubifs options

SPI NOR 存储配置

SPI NOR 存储一般比较小,在 Linux 系统上进行分区调整比较麻烦,本节不详细描述。

EMMC 存储配置

EMMC 的接口协议固定,因此不需要进行新器件型号的移植。
注: 调整分区大小时,也需要同时调整固件的大小来和分区匹配。
EMMC 存储配置步骤如下:
  1. 分区
    分区信息在 target/d211/demo/image_cfg.json
    "mmc": { // Media type
        "size": "4G", // Size of SD/eMMC
        "partitions": { // Partition table apply to device
            "spl":    { "offset": "0x4400", "size": "495k" },
            "uboot":  { "size": "1m" },
            "env":    { "size": "256k" },
            "falcon": { "size": "256k" },
            "logo":   { "size": "512k" },
            "kernel": { "size": "16m" },
            "rootfs": { "size": "72m" },        //分区大小为 72M
            "user":   { "size": "-" },
        },
    },
  2. 固件

    执行 make menuconfig 命令,进入 menuconfig 界面,并选择 Filesystem images > RootFS images 调整。

    [*] ext2/3/4 root filesystem
    ext2/3/4 variant (ext4)  --->
    (rootfs) filesystem label
    (72M) exact size                                                 //固件大小为 72M
    (0)   exact number of inodes (leave at 0 for auto calculation)
    (5)   reserved blocks percentage
    (-O ^64bit) additional mke2fs options
    Compression method (no compression)  --->
    [ ] cpio the root filesystem (for use as an initial RAM filesystem)
    [ ] initial RAM filesystem linked into linux kernel

正确的存储配置应该能够成功支持固件烧录。