开发环境

  • Win10 64位
  • ubuntu 20.04
  • 虚拟机 VMware® Workstation 16 Pro
  • 开发板:NK-980IOT(NUC980DK61Y)
  • gcc 交叉编译工具链: ARM 官方 gcc version 11.2.1 20220111
  • NUC980 uboot 版本 :尝试移植到 u-boot-2017.11,官方当前 u-boot 版本为 2016.11

问题描述

  • NK-980IOT 开发板的 Flash 是 SPI Nand Flash,在 u-boot 2017.11 这个版本上,需要做简单的移植才能识别
  • 识别了 SPI Nand Flash 后,发现 没有 saveenv 等命令,并且 系统无法跳转,也就是烧写到 SPI Nand Flash 中的 env.txt 没有生效,是默认的 env 环境变量
NUC980 IBR 20180813
Boot from SPI-NAND
DDR-OK
finish SPI dow▒load

 SPL load main U-Boot from SPI NAND Flash! (May 14 2023 18:07:33)


U-Boot 2017.11-ga356251-dirty (May 14 2023 - 18:07:33 +0800)

CPU: NUC980
Board: NUC980
DRAM:  64 MiB
NAND:  SF: unrecognized JEDEC id bytes: ff, ef, aa
spi_nand: Id could not be mapped
0 MiB
MMC:
Using default environment

In:    serial
Out:   serial
Err:   serial
Net:   Net Initialization Skipped
No ethernet found.
=>
  • 跟正常的 u-boot 启动信息对比,这里有个 Using default environment 的提示

解决方法

  • 因为正常移植了 u-boot 2017.05,env 正常,所以对比 默认配置文件:这里是 nuc980_iot_defconfig,发现一致
  • 在代码里面搜索 Using default environment 的提示,发现有个宏没有定义,obj-$(CONFIG_ENV_IS_IN_SPI_FLASH) += env_sf.o,也就是 SPI nand flash env 的操作没有使能编译
  • 【解决方法】:开启 CONFIG_ENV_IS_IN_SPI_FLASH,通过 搜索 ENV_IS_IN_SPI_FLASH,很快找到了配置选项,选择后,重新编译,烧写到板子上,发现 env 变量正常了

nuc980 uboot 2017.11 移植:env 保存位置选择问题_env保存

nuc980 uboot 2017.11 移植:env 保存位置选择问题_env保存_02

env 正确启动信息

NUC980 IBR 20180813
Boot from SPI-NAND
DDR-OK
finish SPI dow▒load

 SPL load main U-Boot from SPI NAND Flash! (May 14 2023 18:49:24)


U-Boot 2017.11-gec2249d (May 14 2023 - 18:49:24 +0800)

CPU: NUC980
Board: NUC980
DRAM:  64 MiB
NAND:  info->id[0x21aaef], id[0x2121aaef], info->id_len[3]
spi nand jedec : 0xaa21
SF: Detected W25N01GV with page size 2 KiB, erase size 128 KiB, total 128 MiB
128 MiB
MMC:
info->id[0x21aaef], id[0x2121aaef], info->id_len[3]
spi nand jedec : 0xaa21
SF: Detected W25N01GV with page size 2 KiB, erase size 128 KiB, total 128 MiB
In:    serial
Out:   serial
Err:   serial
Net:   Net Initialization Skipped
No ethernet found.
Hit any key to stop autoboot:  0

NAND read: device 0 offset 0x200000, size 0x100000
 1048576 bytes read: OK
## Starting application at 0x00000000 ...

 \ | /
- RT -     Thread Operating System
 / | \     5.0.1 build May  6 2023 22:17:14
 2006 - 2022 Copyright by RT-Thread team
lwIP-2.1.2 initialized!
[I/I2C] I2C bus [i2c0] registered
[I/I2C] I2C bus [i2c2] registered
[I/spinand_flash] Found: [00EFAA21] Winbond 128MB: 2048+64@64@1024.
[I/spinand_flash] Enabled BUF, HWECC. Unprotected.
[I/sal.skt] Socket Abstraction Layer initialize success.
[I/utest] utest is initialize success.
[I/utest] total utest testcase num: (0)
MAC address: 82:06:21:53:94:53
nu_igmp_mac_filter add 224.0.0.1 01:00:5E:00:00:01

小结

  • u-boot 的每个版本,都有一定的变更,所以移植的时候需要注意,尤其是一些【宏定义】的配置问题
  • 当前 nuc980 可以正常的移植到 u-boot 2017.11 版本(前进了一年),后面继续移植到更新的版本