Mike
Mike

Reputation: 1871

Wrong image format for "source" command for U-boot

I'm trying to write a script to run commands automatically at U-boot.

I followed the instructions on the website [1].

Below is what I did.

I compiled the script on the NVIDIA Jetson board and put the compiled file into /boot/setenv.img

Now when I reboot the board, load the script image with the command:

ext2load mmc 0:1 100000 /boot/setenv.img

I got the following output:

1096 bytes read in 403 ms (2 KiB/s)

Note that when I run command imi, it reports "Command not found" on Jetson board.

I run the loaded image with the command:

source 100000

It gives me the following output (error message):

\## Executing script at 00100000

Wrong image format for "source" command

My question is:

Why is the image format incorrect for the source command?

Is there any method that I can debug the error?

Any help or advice about how to debug the error is really appreciated!

[1] http://www.denx.de/wiki/view/DULG/UBootScripts

Thank you very much!

Upvotes: 3

Views: 10726

Answers (2)

Drakes
Drakes

Reputation: 23660

For future readers, CONFIG_LEGACY_IMAGE_FORMAT=y is required to load the boot.scr script or else you will get following error message:

Wrong image format for "source" command

Also, when CONFIG_FIT_SIGNATURE is enabled, then the above flag is disabled. From the Kconfig:

WARNING: When relying on signed FIT images with a required signature check the legacy image format is disabled by default, so that unsigned images cannot be loaded. If a board needs the legacy image format support in this case, enable it using CONFIG_LEGACY_IMAGE_FORMAT.

Upvotes: 1

John Moon
John Moon

Reputation: 924

As sawdust noted, the iminfo would be helpful for debugging - so make sure that's compiled in to U-Boot. You can also manually check the header info using the md command. Keep in mind that mkimage doesn't compile anything - it simply prepends 64 bytes of metadata to the beginning of the file.

So, if you load the script into DDR at 0x100000, you can look at that location in memory by entering md 0x100000.

The first four lines of output are bytes 0x0 - 0x40 of the file (the 64-byte U-Boot header). If your header is there, you should see something like this:

00100000: 56190527 030b131f eb439a57 de0d0000    '..V....W.C.....
00100010: 00000000 00000000 fc6de331 00060205    ........1.m.....
00100020: 6f747541 616d492d 676e6967 72635320    Auto-Imaging Scr
00100030: 00747069 00000000 00000000 00000000    ipt.............

This header contains a magic number, CRC checksums (one for the file, one for the header itself), timestamp, filesize, name, and a few other things. All iminfo does is parse the header. Beyond those 64 bytes should just be your plaintext ASCII script.

The source command is looking for a header that was generated with the -t script flag in mkimage. The error message you're getting is printed when an image at that address has the wrong type.

Upvotes: 3

Related Questions