【AT91SAM9261EK】使用U-Boot 2022.01的调试记录

开发环境

调试过程

  • 进入:u-boot-at91目录,切换到 u-boot-2022.01-at91分支,通过查看 configs目录,发现有开发板的【默认配置】,所以操作步骤如下:
  • ls configs,因为开发板的【默认配置】,放在这个目录下

在这里插入图片描述

  • 默认的编译过程
make mrproper
make at91sam9261ek_nandflash_defconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- all
  • 注意这里使用高版本的:arm-linux-gnueabi- 工具链,如:gcc version 9.4.0

下载烧写

  • AT91SAM9261EK开发板,使用JLink V8 + SAM-BA v2.18 下载,这里使用的是NandFlash启动,u-boo.bin 烧写在NandFlash中,注意NandFlash烧写的位置: 0x40000
  • 运行,发现无法引导Linux内核(烧写的:Linux version 3.10.0)
  • 不断的重启,错误信息如下:
Hit any key to stop autoboot:  0
NAND read: device 0 offset 0x200000, size 0x300000
3145728 bytes read: OK
Booting kernel from Legacy Image at 22000000 ...
Image Name:   Linux-3.10.0+
Image Type:   ARM Linux Kernel Image (uncompressed)
Data Size:    2125848 Bytes = 2 MiB
Load Address: 20008000
Entry Point:  20008000
Verifying Checksum ... OK
Loading Kernel Image
FDT and ATAGS support not compiled in
resetting ...

问题的排查

  • 根据这个提示,FDT and ATAGS support not compiled in,搜索u-boot的源码,定位到问题在:boot_prep_linux 这个函数,看了是条件没有满足,【BOOTM_ENABLE_TAGS】这个宏没有开启
/* Subcommand: PREP */
static void boot_prep_linux(bootm_headers_t *images)
{
	char *commandline = env_get("bootargs");

	if (CONFIG_IS_ENABLED(OF_LIBFDT) && images->ft_len) {
#ifdef CONFIG_OF_LIBFDT
		debug("using: FDT\n");
		if (image_setup_linux(images)) {
			panic("FDT creation failed!");
		}
#endif
	} else if (BOOTM_ENABLE_TAGS) {
		debug("using: ATAGS\n");
		setup_start_tag(gd->bd);
		if (BOOTM_ENABLE_SERIAL_TAG)
			setup_serial_tag(&params);
		if (BOOTM_ENABLE_CMDLINE_TAG)
			setup_commandline_tag(gd->bd, commandline);
		if (BOOTM_ENABLE_REVISION_TAG)
			setup_revision_tag(&params);
		if (BOOTM_ENABLE_MEMORY_TAGS)
			setup_memory_tags(gd->bd);
		if (BOOTM_ENABLE_INITRD_TAG) {
			/*
			 * In boot_ramdisk_high(), it may relocate ramdisk to
			 * a specified location. And set images->initrd_start &
			 * images->initrd_end to relocated ramdisk's start/end
			 * addresses. So use them instead of images->rd_start &
			 * images->rd_end when possible.
			 */
			if (images->initrd_start && images->initrd_end) {
				setup_initrd_tag(gd->bd, images->initrd_start,
						 images->initrd_end);
			} else if (images->rd_start && images->rd_end) {
				setup_initrd_tag(gd->bd, images->rd_start,
						 images->rd_end);
			}
		}
		setup_board_tags(&params);
		setup_end_tag(gd->bd);
	} else {
		panic("FDT and ATAGS support not compiled in\n");
	}

	board_prep_linux(images);
}
  • 开启【BOOTM_ENABLE_TAGS】,make menuconfig 进入图形化配置u-boot的界面
  • / 搜索关键的配置项,没有找到相关的Kconfig配置,通过查看代码,需要开启
    【CONFIG_SUPPORT_PASSING_ATAGS】
#ifdef CONFIG_SUPPORT_PASSING_ATAGS
# define BOOTM_ENABLE_TAGS		1
#else
# define BOOTM_ENABLE_TAGS		0
#endif
  • ARM architecture --->
    在这里插入图片描述

  • 勾选:[*] Support pre-devicetree ATAG-based booting
    在这里插入图片描述

  • 注意这里【需要】勾选:[*] Pass Linux kernel cmdline via ATAG,否则无法把参数传递给Linux。

  • 这里我浪费了一点时间,因为不勾选这个选项,造成传递给Linux的bootargs参数不对,会是Linux的默认值,如:
    Kernel command line: mem=64M console=ttyS0,115200 initrd=0x21100000,3145728 root=/dev/ram0 rw

在这里插入图片描述

再次编译下载

  • menuconfig 保存配置后,编译下载到开发板,发现开发板成功的引导了
  • u-boot 2022.01,正常引导Linux内核了,这里是较老的版本Linux内核,默认没有使用Device Tree。
  • 同时了解了u-boot 的启动流程:boot_prep_linux cmdline 传参的流程

启动信息

U-Boot 2022.01-linux4sam-2022.04-rc3-00001-g4754b701e5-dirty (May 04 2022 - 11:29:16 +0800)

CPU: AT91SAM9261
Crystal frequency:   18.432 MHz
CPU clock        :  198.656 MHz
Master clock     :   99.328 MHz
DRAM:  64 MiB
NAND:  128 MiB
Loading Environment from NAND... OK
In:    serial
Out:   serial
Err:   serial
Net:   dm9000
dm9000 i/o: 0x30000000, id: 0x90000a46 
DM9000: running in 16 bit mode
MAC: a8:53:3e:26:6a:5b
operating at 100M full duplex mode
Hit any key to stop autoboot:  0 

NAND read: device 0 offset 0x200000, size 0x300000
 3145728 bytes read: OK
## Booting kernel from Legacy Image at 22000000 ...
   Image Name:   Linux-3.10.0+
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    2125848 Bytes = 2 MiB
   Load Address: 20008000
   Entry Point:  20008000
   Verifying Checksum ... OK
   Loading Kernel Image
boot_prep_linux : commandline = console=ttyS0,115200 earlyprintk mtdparts=atmel_nand:256k(bootstrap)ro,512k(uboot)ro,256k(env),256k(env_redundant),256k(spare),512k(dtb),6M(kernel)ro,-(rootfs) root=/dev/mtdblock7 rw rootfstype=cramfs init=/linuxrc
boot_prep_linux : BOOTM_ENABLE_TAGS
boot_prep_linux : setup_board_tags

Starting kernel ...

Uncompressing Linux... done, booting the kernel.
Booting Linux on physical CPU 0x0
Linux version 3.10.0+ (root@pluto-os) (gcc version 4.4.1 (Sourcery G++ Lite 2010q1-202) ) #2 Mon May 2 23:56:17 CST 2022
CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=00053177
CPU: VIVT data cache, VIVT instruction cache
Machine: Atmel AT91SAM9261-EK
Memory policy: ECC disabled, Data cache writeback
AT91: Detected soc type: at91sam9261
AT91: sram at 0x300000 of 0x28000 mapped at 0xfef50000
Clocks: CPU 198 MHz, master 99 MHz, main 18.432 MHz
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 16256
Kernel command line: console=ttyS0,115200 earlyprintk mtdparts=atmel_nand:256k(bootstrap)ro,512k(uboot)ro,256k(env),256k(env_redundant),256k(spare),512k(dtb),6M(kernel)ro,-(rootfs) root=/dev/mtdblock7 rw rootfstype=cramfs init=/linuxrc
PID hash table entries: 256 (order: -2, 1024 bytes)
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory: 64MB = 64MB total
Memory: 59696k/59696k available, 5840k reserved, 0K highmem
Virtual kernel memory layout:
    vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)
    vmalloc : 0xc4800000 - 0xff000000   ( 936 MB)
    lowmem  : 0xc0000000 - 0xc4000000   (  64 MB)
    modules : 0xbf000000 - 0xc0000000   (  16 MB)
      .text : 0xc0008000 - 0xc04ae348   (4761 kB)
      .init : 0xc04af000 - 0xc04d1a50   ( 139 kB)
      .data : 0xc04d2000 - 0xc04fbca0   ( 168 kB)
       .bss : 0xc04fbca0 - 0xc051b240   ( 126 kB)
NR_IRQS:16 nr_irqs:16 16
AT91: 96 gpio irqs in 3 banks
sched_clock: 32 bits at 100 Hz, resolution 10000000ns, wraps every 4294967286ms
Console: colour dummy device 80x30
Calibrating delay loop... 98.71 BogoMIPS (lpj=493568)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
Setting up static identity map for 0xc03a71c0 - 0xc03a7218
devtmpfs: initialized
pinctrl core: initialized pinctrl subsystem
NET: Registered protocol family 16
DMA: preallocated 256 KiB pool for atomic coherent allocations
AT91: Power Management
AT91: Starting after user reset
bio: create slab <bio-0> at 0
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
i2c-gpio i2c-gpio.0: using pins 7 (SDA) and 8 (SCL)
Advanced Linux Sound Architecture Driver Initialized.
cfg80211: Calling CRDA to update world regulatory domain
Switching to clocksource tcb_clksrc
NET: Registered protocol family 2
TCP established hash table entries: 512 (order: 0, 4096 bytes)
TCP bind hash table entries: 512 (order: -1, 2048 bytes)
TCP: Hash tables configured (established 512 bind 512)
TCP: reno registered
UDP hash table entries: 256 (order: 0, 4096 bytes)
UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
NET: Registered protocol family 1
RPC: Registered named UNIX socket transport module.
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
squashfs: version 4.0 (2009/01/31) Phillip Lougher
jffs2: version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
msgmni has been set to 116
io scheduler noop registered (default)
atmel_usart.0: ttyS0 at MMIO 0xfffff200 (irq = 17) is a ATMEL_SERIAL
console [ttyS0] enabled
brd: module loaded
ssc at91rm9200_ssc.1: Atmel SSC device at 0xc48a8000 (irq 31)
atmel_nand: Use On Flash BBT
atmel_nand atmel_nand: No DMA support for NAND access.
NAND device: Manufacturer ID: 0xec, Chip ID: 0xf1 (Samsung NAND 128MiB 3,3V 8-bit), 128MiB, page size: 2048, OOB size: 64
Bad block table found at page 65472, version 0x01
Bad block table found at page 65408, version 0x01
nand_read_bbt: bad block at 0x0000037c0000
nand_read_bbt: bad block at 0x000007c40000
8 cmdlinepart partitions found on MTD device atmel_nand
Creating 8 MTD partitions on "atmel_nand":
0x000000000000-0x000000040000 : "bootstrap"
0x000000040000-0x0000000c0000 : "uboot"
0x0000000c0000-0x000000100000 : "env"
0x000000100000-0x000000140000 : "env_redundant"
0x000000140000-0x000000180000 : "spare"
0x000000180000-0x000000200000 : "dtb"
0x000000200000-0x000000800000 : "kernel"
0x000000800000-0x000008000000 : "rootfs"
atmel_spi atmel_spi.0: version: 0x150
atmel_spi atmel_spi.0: Atmel SPI Controller at 0xfffc8000 (irq 28)
atmel_spi atmel_spi.0: master is unqueued, this is deprecated
dm9000 dm9000.0: read wrong id 0x09090909
eth0: dm9000a at c48d6000,c48d8044 IRQ 123 MAC: a8:53:3e:26:6a:5b (chip)
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
at91_ohci at91_ohci: AT91 OHCI
at91_ohci at91_ohci: new USB bus registered, assigned bus number 1
at91_ohci at91_ohci: irq 36, io mem 0x00500000
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
usbcore: registered new interface driver usb-storage
udc: at91_udc version 3 May 2006
mousedev: PS/2 mouse device common for all mice
ads7846 spi0.2: touchscreen, irq 45
input: ADS7843 Touchscreen as /devices/platform/atmel_spi.0/spi_master/spi0/spi0.2/input/input0
rtc-at91sam9 rtc-at91sam9.0: rtc core: registered rtc-at91sam9 as rtc0
rtc-at91sam9 rtc-at91sam9.0: rtc0: SET TIME!
i2c /dev entries driver
at91sam9_wdt: sorry, watchdog is disabled
at91_wdt: probe of at91_wdt failed with error -5
at73c213 spi0.3: at73c213: supported bitrate is 48500 (64 divider)
TCP: cubic registered
NET: Registered protocol family 17
VFP support v0.3: not present
input: gpio-keys as /devices/platform/gpio-keys/input/input1
rtc-at91sam9 rtc-at91sam9.0: hctosys: unable to read the hardware clock
ALSA device list:
  #0: AT91SAM9261/9G10-EK external DACAT91SAM9 on irq 31
VFS: Mounted root (cramfs filesystem) readonly on device 31:7.
devtmpfs: mounted
Freeing unused kernel memory: 136K (c04af000 - c04d1000)

Please press Enter to activate this console. 
/ # ls
bin      dev      home     linuxrc  proc     sbin     tmp      var
boot     etc      lib      mnt      root     sys      usr
/ # ls
bin      dev      home     linuxrc  proc     sbin     tmp      var
boot     etc      lib      mnt      root     sys      usr
/ # 
  • 这里使用的是cramfs文件系统,为了快速验证Linux内核的启动

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

小结

  • 新的u-boot,不再建议使用老的cmdline 传参方式了,改为 Device Tree 了,这个后面继续研究如何操作
  • 目前【AT91SAM9261EK】开发板,u-boot 已经更新到当前的最新版本了,后面研究u-boot 2022.01 的Linux 启动流程
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

zhangsz_sh

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值