From: Adrian Freihofer Date: Fri, 19 Jun 2026 11:17:09 +0000 (+0200) Subject: oe-selftest: fitimage: replace _gen_random_file with _gen_elf64_dummy X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0344e652a405b6a2e94d20560873e6945248dc15;p=thirdparty%2Fopenembedded%2Fopenembedded-core.git oe-selftest: fitimage: replace _gen_random_file with _gen_elf64_dummy Some boards (e.g. RK3399 with evb-rk3399_defconfig) use binman to build U-Boot and require BL31 to be a structurally valid ELF file so binman can parse the load/entry addresses. A plain random-byte file fails with "Magic number does not match". Add _gen_atf_tee_dummy_images(bb_vars) which generates both the ATF and TEE dummy binaries when the corresponding bb_vars keys are set. Tests will call this helper instead of duplicating the generate-and-path logic. So far this is a refactoring without functional changes, but it will be used in a follow-up commit when we are going to replace the beaglebone MACHINE by other MACHINEs which require a structurally valid ELF for BL31. Signed-off-by: Adrian Freihofer Signed-off-by: Mathieu Dubois-Briand Signed-off-by: Ross Burton Signed-off-by: Richard Purdie --- diff --git a/meta/lib/oeqa/selftest/cases/fitimage.py b/meta/lib/oeqa/selftest/cases/fitimage.py index 34b248ee0b..2d3337aabd 100644 --- a/meta/lib/oeqa/selftest/cases/fitimage.py +++ b/meta/lib/oeqa/selftest/cases/fitimage.py @@ -110,9 +110,67 @@ class FitImageTestCase(OESelftestTestCase): )) @staticmethod - def _gen_random_file(file_path, num_bytes=65536): - with open(file_path, 'wb') as file_out: - file_out.write(os.urandom(num_bytes)) + def _gen_elf64_dummy(file_path, load_addr=0x80000000): + """Generate a minimal valid ELF64 (ARM64, little-endian) file. + + Some boards (e.g. RK3399) let binman parse BL31 as an ELF to extract + load/entry addresses. A plain random binary fails ELF magic checks, so + we need a structurally valid ELF even for a dummy/fake binary. + """ + import struct + payload = b'\x00' * 4 + phoff = 64 # program header immediately after ELF header + payload_off = phoff + 56 # after one ELF64 program header entry + elf_ident = ( + b'\x7fELF' # magic + + b'\x02' # ELFCLASS64 + + b'\x01' # ELFDATA2LSB + + b'\x01' # EV_CURRENT + + b'\x00' * 9 # OS/ABI + padding + ) + elf_header = struct.pack( + '