Cannot boot from FIT image

9.2k views Asked by At

I'm working with the Xilinx Zynq-7000 SoC, and I'm trying to transition from a "legacy" (uImage + DTB + initramfs image) to "modern" (FIT image) boot flow. This is the current sequence of commands I'm using to boot my board (output omitted):

setenv bootargs "console=ttyPS0,115200 root=/dev/ram rw ramdisk_size=0x1600000 earlyprintk init=/sbin/init"
tftpboot 0x2000000 devicetree.dtb
tftpboot 0x2080000 uImage
tftpboot 0x4000000 initramfs.img
bootm 0x2080000 0x4000000 0x2000000

I'm working on an existing project, and as far as I know, the TFTP load addresses (0x2080000 etc.) are arbitrary. I don't think they matter, aside from the fact that they are mapped to RAM and don't overlap with the load addresses. Correct me if I'm wrong here.

Executing the bootm command generates the following output:

Zynq> bootm 0x2080000 0x4000000 0x2000000
## Booting kernel from Legacy Image at 02080000 ...
   Image Name:   Linux-4.0.0-00011-gcfd1f62
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    3297728 Bytes = 3.1 MiB
   Load Address: 00008000
   Entry Point:  00008000
   Verifying Checksum ... OK
## Loading init Ramdisk from Legacy Image at 04000000 ...
   Image Name:   Ramdisk Image
   Image Type:   ARM Linux RAMDisk Image (gzip compressed)
   Data Size:    22569621 Bytes = 21.5 MiB
   Load Address: 00000000
   Entry Point:  00000000
   Verifying Checksum ... OK
## Flattened Device Tree blob at 02000000
   Booting using the fdt blob at 0x2000000
   Loading Kernel Image ... OK
   Loading Ramdisk to 1ea79000, end 1ffff295 ... OK
   Loading Device Tree to 1ea73000, end 1ea78ba1 ... OK

Starting kernel ...

Uncompressing Linux... done, booting the kernel.
Booting Linux on physical CPU 0x0
[Omitted]

In other words, bootm correctly boots the kernel.

Now, rather than loading each image and passing their addresses into bootm, I want to create a single FIT image with all three images. I can provide the .its source if necessary, but I specified all three images (uImage, DTB and initramfs) and this is the mkimage output:

FIT description: Test FIT Image
Created:         Mon Dec 19 13:13:06 2016
 Image 0 (kernel@1)
  Description:  Linux Kernel
  Created:      Mon Dec 19 13:13:06 2016
  Type:         Kernel Image
  Compression:  uncompressed
  Data Size:    3297792 Bytes = 3220.50 kB = 3.15 MB
  Architecture: ARM
  OS:           Linux
  Load Address: 0x00008000
  Entry Point:  0x00008000
 Image 1 (fdt@1)
  Description:  Device Tree Blob
  Created:      Mon Dec 19 13:13:06 2016
  Type:         Flat Device Tree
  Compression:  uncompressed
  Data Size:    11170 Bytes = 10.91 kB = 0.01 MB
  Architecture: ARM
 Image 2 (ramdisk@1)
  Description:  initramfs
  Created:      Mon Dec 19 13:13:06 2016
  Type:         RAMDisk Image
  Compression:  gzip compressed
  Data Size:    22569685 Bytes = 22040.71 kB = 21.52 MB
  Architecture: ARM
  OS:           Linux
  Load Address: 0x00000000
  Entry Point:  0x00000000
 Default Configuration: 'conf@1'
 Configuration 0 (conf@1)
  Description:  Boot Linux kernel with FDT blob
  Kernel:       kernel@1
  Init Ramdisk: ramdisk@1
  FDT:          fdt@1

The load addresses and entry points line up with the bootm output from my previous boot procedure. This is how I'm trying to boot using my new .itb file (output omitted):

setenv bootargs "console=ttyPS0,115200 root=/dev/ram rw ramdisk_size=0x1600000 earlyprintk init=/sbin/init"
tftpboot 0x2000000 image.itb
bootm 0x2000000

Here's the output from bootm:

Zynq> bootm 0x2000000
## Loading kernel from FIT Image at 02000000 ...
   Using 'conf@1' configuration
   Verifying Hash Integrity ... OK
   Trying 'kernel@1' kernel subimage
     Description:  Linux Kernel
     Type:         Kernel Image
     Compression:  uncompressed
     Data Start:   0x020000c4
     Data Size:    3297792 Bytes = 3.1 MiB
     Architecture: ARM
     OS:           Linux
     Load Address: 0x00008000
     Entry Point:  0x00008000
   Verifying Hash Integrity ... OK
## Loading ramdisk from FIT Image at 02000000 ...
   Using 'conf@1' configuration
   Trying 'ramdisk@1' ramdisk subimage
     Description:  initramfs
     Type:         RAMDisk Image
     Compression:  gzip compressed
     Data Start:   0x02327f88
     Data Size:    22569685 Bytes = 21.5 MiB
     Architecture: ARM
     OS:           Linux
     Load Address: 0x00000000
     Entry Point:  0x00000000
   Verifying Hash Integrity ... OK
## Loading fdt from FIT Image at 02000000 ...
   Using 'conf@1' configuration
   Trying 'fdt@1' fdt subimage
     Description:  Device Tree Blob
     Type:         Flat Device Tree
     Compression:  uncompressed
     Data Start:   0x02325370
     Data Size:    11170 Bytes = 10.9 KiB
     Architecture: ARM
   Verifying Hash Integrity ... OK
   Booting using the fdt blob at 0x2325370
   Loading Kernel Image ... OK
   Loading Ramdisk to 1ea79000, end 1ffff2d5 ... OK
   Loading Device Tree to 1ea73000, end 1ea78ba1 ... OK

Starting kernel ...

undefined instruction
pc : [<0000800c>]          lr : [<3ff2b834>]
reloc pc : [<c40dd00c>]    lr : [<04000834>]
sp : 3f30acb0  ip : 0000000c     fp : 3ff2b8c0
r10: 00000000  r9 : 3f30aee0     r8 : 020000c4
r7 : 00000000  r6 : 00008000     r5 : 3ff9c868  r4 : 00000000
r3 : 00002ba2  r2 : 1ea73000     r1 : 00000000  r0 : 3f30afb0
Flags: nZCv  IRQs off  FIQs off  Mode SVC_32
Resetting CPU ...

resetting ...

This is my first time using a FIT image, but everything up until the crash looks fine to me. The load and entry point addresses line up, and the output up until Starting kernel... lines up with my old boot, more or less.

Am I misunderstanding how to create/use FIT images?

I'm pretty sure that, with the FIT image, U-Boot is loading the uImage to the load address, 0x8000. I tested with md in U-Boot:

Before loading FIT image

Zynq> md 0x8000
00008000: dfdc3ffc dd5ffbfe ff7fbabe ffffd7fe    .?...._.........
00008010: 777fccfb fbbfeefb dde9f8cf ffffeee7    ...w............
00008020: ffcefebc f76ffffb ffadf2ed f5f776ff    ......o......v..
00008030: eb31fdd9 fff28fff df5fb77f ffdbeeeb    ..1......._.....
00008040: dedfef7f ebeffebe fddfbbbf f7f7d4ff    ................
00008050: ddcfaed7 e7fe33ee ff8eb89f fedd3df7    .....3.......=..
00008060: ffdffd7f 75bff5ad f2dff52b ffb7f03f    .......u+...?...
00008070: f7fffef3 ff9fbffb bf7fabfe ff96db5f    ............_...
00008080: f777feff f6b7bf5b fb27dffb e5beb98f    ..w.[.....'.....
00008090: ffbdf8f7 f3fefce7 e8fefdf6 ffc639ef    .............9..
000080a0: f6ef8bfe f6bffcfd ffffd4cf defffdff    ................
000080b0: edbf46bf ffdfbdbf 7edff6b7 fde5afbf    .F.........~....
000080c0: b7cdf9bf fffefdbb ffbdfa7f eeffffb7    ................
000080d0: c5affdef ffcffbaf e73f6fef fdeff37f    .........o?.....
000080e0: f3ffeffb 76af599b ffff7dff 6dafbd8f    .....Y.v.}.....m
000080f0: efffaafd fdfff7fe effffbff bebf6cbe    .............l..

After loading FIT image

00008000: 56190527 3328f51d dc265858 c0513200    '..V..(3XX&..2Q.
00008010: 00800000 00800000 368dbc5f 00020205    ........_..6....
00008020: 756e694c 2e342d78 2d302e30 31303030    Linux-4.0.0-0001
00008030: 63672d31 66316466 00003236 00000000    1-gcfd1f62......
00008040: e1a00000 e1a00000 e1a00000 e1a00000    ................
00008050: e1a00000 e1a00000 e1a00000 e1a00000    ................
00008060: ea000003 016f2818 00000000 003251c0    .....(o......Q2.
00008070: 04030201 e10f9000 eb000bf8 e1a07001    .............p..
00008080: e1a08002 e10f2000 e3120003 1a000001    ..... ..........
00008090: e3a00017 ef123456 e10f0000 e220001a    ....V4........ .
000080a0: e310001f e3c0001f e38000d3 1a000004    ................
000080b0: e3800c01 e28fe00c e16ff000 e12ef30e    ..........o.....
000080c0: e160006e e121f000 e16ff009 00000000    n.`...!...o.....
000080d0: 00000000 00000000 00000000 00000000    ................
000080e0: e1a0400f e204433e e2844902 e1a0000f    .@..>C...I......
000080f0: e1500004 359f01ac 3080000f 31540000    ..P....5...0..T1

U-Boot reported that the kernel image data started at an offset of 0xc4 from where I loaded the FIT image. If I read at that address (0x20000c4), the data is identical to what's at 0x8000 after trying to boot. So U-Boot is definitely loading the kernel.

Here's the output of my kernel build when creating the uImage:

/bin/sh ./scripts/mkuboot.sh -A arm -O linux -C none  -T kernel -a 0x8000 -e 0x8000 -n 'Linux-4.0.0-00011-gcfd1f62' -d arch/arm/boot/zImage arch/arm/boot/uImage
Image Name:   Linux-4.0.0-00011-gcfd1f62
Created:      Mon Dec 19 13:32:30 2016
Image Type:   ARM Linux Kernel Image (uncompressed)
Data Size:    3297728 Bytes = 3220.44 kB = 3.14 MB
Load Address: 00008000
Entry Point:  00008000

Again, everything seems kosher here.

Any ideas?

1

There are 1 answers

1
Notlikethat On BEST ANSWER

Seeing your FIT source might confirm it, but it would appear you're packing a uImage into the FIT, whilst claiming it's a regular kernel image. The kernel text which is supposed to be at 0x8000 is at 0x8040 in your dump, and the preceding 64 bytes looks an awful lot like a uImage header.

For a FIT kernel, either use plain arch/arm/boot/Image or the self-extracting arch/arm/boot/zImage, or one of the various compressed arch/arm/boot/Image.* with "compression" set as appropriate. Otherwise it all gets a bit "Yo dawg, I heard you like U-boot image formats..."