引言

  • 权当做个记录,因为最新的代码无法运行,所以【回归】验证定位问题的所在
  • 前面验证了旧版本: ​​linux-3.10-at91​​​ Linux内核可以被成功的引导,此次使用:​​linux-4.9-at91​​ 验证
  • 前面验证Linux 3.x 版本,可以直接成功运行,那么Linux 4.x 的版本是否可以直接编译运行呢?

开发环境

  • arm gcc 的交叉编译器:gcc version 4.4.1 (Sourcery G++ Lite 2010q1-202)
  • AT91Bootstrap 3.10.4
  • U-Boot 2015.01
  • linux-4.9-at91
  • 编译主机:Ubuntu 20.04.4 LTS

测试过程

  • git 仓库是Atmel的 ​​https://github.com/linux4sam/linux-at91.git​
  • 使用git 切换到这个分支:linux-4.9-at91,最好先切换到master,在切换到指定的分支,否则切换分支可能会冲突
  • 编译过程:此次的编译很顺利,命令如下
make mrproper
make ARCH=arm at91_dt_defconfig /* 配置名字改掉了,好像at91系列的都使用一个默认配置 */
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- LOADADDR=0x20008000 uImage /* 需要: LOADADDR=0x20008000 */

LOADADDR

  • 编译时,需要增加:LOADADDR,这个参数的计算与配置,后面深入研究
  • 不增加:LOADADDR,编译uImage 会报错
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- uImage

multiple (or no) load addresses:
This is incompatible with uImages
Specify LOADADDR on the commandline to build an uImage
make[1]: *** [arch/arm/boot/Makefile:79: arch/arm/boot/uImage] Error 1
make: *** [arch/arm/Makefile:329: uImage] Error 2
  • 【解决方法】编译命令改为:
    ​make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- LOADADDR=0x20008000 uImage​
  • 注意这里生成​​uImage​

uImage 文件较大

  • 对比:Linux 3.x 版本,Linux 4.x 的版本,Linux内核的生成的uImage大小,突破了4M

【AT91SAM9261EK】 编译 linux-4.9-at91:引导Linux 内核失败_at91

  • 固件后面Linux 的内核会越来越【臃肿】,当然功能可能会越来越多,配置越来越【复杂】

烧写验证

  • 使用 ​​SAM-BA v2.18​​,因为之前少写过其他的内核,建议烧写前,全部擦除,重新烧写 bootstrap、uboot、uImage,这样【防止出现NandFlash校验出错问题】

【AT91SAM9261EK】 编译 linux-4.9-at91:引导Linux 内核失败_4s_02


【AT91SAM9261EK】 编译 linux-4.9-at91:引导Linux 内核失败_4s_03

  • 接下来一次烧写: bootstrap、u-boot.bin、uImage,注意烧写的地址,这个跟之前版本一致
  • bootstrap : 0x0
  • u-boot.bin : 0x40000
  • uImage : 0x20 0000

运行

  • 【uImage 过大】,造成nand read 的内核大小需要调整
NAND read: device 0 offset 0x200000, size 0x300000
3145728 bytes read: OK

## Booting kernel from Legacy Image at 22000000 ...
Image Name: Linux-4.9.151-linux4sam_5.8+-048
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 4276400 Bytes = 4.1 MiB
Load Address: 20008000
Entry Point: 20008000
Verifying Checksum ... Bad Data CRC
ERROR: can't get kernel image!
  • 这里uboot 默认 nand read 3M,而此时的uImage 超过了 4M,这里可以改下uboot 的 env,也可以在u-boot的代码了改掉,如改为 读取 6M
U-Boot> nand read 0x22000000 0x200000 0x600000; bootm

NAND read: device 0 offset 0x200000, size 0x600000
6291456 bytes read: OK
## Booting kernel from Legacy Image at 22000000 ...
Image Name: Linux-4.9.151-linux4sam_5.8+-048
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 4276400 Bytes = 4.1 MiB
Load Address: 20008000
Entry Point: 20008000
Verifying Checksum ... OK
Loading Kernel Image ... OK

Starting kernel ...
  • 这个版本的内核无法引导,卡在了​​Starting kernel ...​

【AT91SAM9261EK】 编译 linux-4.9-at91:引导Linux 内核失败_at91_04

小结

  • 在 linux-4.9-at91 这个分支上,基于AT91SAM9261EK的开发板,已经不能引导Linux启动了,看了Linux 3.x 到 Linux4.x,中间改动较大,具体什么原因造成uImage 较大,无法正常引导Linux内核,接下来细细的验证与分析
  • 深入学习了解Linux 的整套开发方法,动手实践+持续学习