Search code examples
armcross-compilingbootloaderu-boot

How to check for which architecure U-boot image was built?


I'm working on adding certain feature to Uboot. I have accidentally bricked my device and am trying to determine what went wrong. My guess is that cross compilation went wrong, and the image produced was for some reason built for other than expected architecture (i.e. host architecture, instead of ARMv7). I tried to verify that by examining u-boot.bin:

  1. file u-boot.bin but the only result I got was : 'data'. Not very useful.

  2. After viewing 'u-boot.lds' for the architecture, I've got a hint:

    (..) OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") (..)

  3. Knowing that it should be ELF, I tried both readelf and objdump:

    readelf -h u-boot.bin readelf: Error: Not an ELF file - it has the wrong magic bytes at the start

    objdump -f u-boot.bin objdump: u-boot.bin: File format not recognized

I would appreciate any clues.


Solution

  • U-Boot has a version command which cannot be disabled in the configuration. It writes a message like

    => version
    U-Boot 2024.01-rc4 (Dec 06 2023 - 10:02:02 +0100)
    
    riscv64-linux-gnu-gcc (Ubuntu 13.2.0-6ubuntu1) 13.2.0
    GNU ld (GNU Binutils for Ubuntu) 2.41
    
    

    These strings are in your u-boot.bin binary. You can find them with a hexadecimal editor like hexedit.