[File] [PATCH] Magdir/rpi for raspberry PI eeprom*.bin

Jörg Jenderek joerg.jen.der.ek at gmx.net
Fri Apr 1 16:34:43 UTC 2022


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,

some days ago i wanted to change the boot order on my old PI.
Therefore i installed package rpi-eeprom. Afterwards in sub
directory bootloader beneath /lib/firmware are files with names like
pieeprom*.bin.

When running file command version 5.41 on such examples i get an
output like:

pieeprom20-07-16.bin: BIOS (ia32) ROM Ext. (-16*512)
pieeprom22-03-10.bin: BIOS (ia32) ROM Ext. (-16*512)

By "bad" circumstances such eeprom start with same magic as for
BIOS (ia32) ROM Extension handled by Magdir/intel.

Luckily on Raspberry pi web site in Raspberry Pi Documentation
there is a section about "Raspberry Pi 4 Boot EEPROM". More details
can be found inside python script rpi-eeprom-config. That
informations are now expressed by additional comment lines
inside Magdir/rpi like:

# URL:		https://www.raspberrypi.com/documentation/computers/
#		raspberry-pi.html#raspberry-pi-4-boot-eeprom
# Reference:	https://github.com/raspberrypi/rpi-eepro/blob/master/
#		rpi-eeprom-config


At the end i add new lines that start like:
0	belong&0xFFffF00F	0x55aaF00F	Raspberry PI EEPROM
!:mime	application/x-raspberry-eeprom
!:ext	bin

Instead generic mime type application/octet-stream i display a user
defined one. In all my dozens samples the starting 4 bytes are always
0x55aaF00F, but according to python source there may exist variants
that look a little bit other. So the value must be masked with
value 0xFFffF00F (called MAGIC_MASK) before comparing value with
expected value 0x55aaF00F (called MAGIC in source).

Afterwards a 32 bit offset in big endian to the next section is
stored. This is shown by line like:
> 4	ubelong			x		\b, offset %8.8x

Afterwards length and optional filename of section follow. This
maybe is shown by lines like:
> 8	ubelong			!0		\b, length %x 12	string			>0		\b, "%s"

For the first section i got always length zero. If i understand
source right this means second section start immediately afterwards
with it own magic. If this magic is also zero then parsing of
sections is done. So this is now shown lines like:
> 8	ubelong			=0
>> 8	ubelong			!0		\b, 2nd MAGIC=%8.8x

After applying the above mentioned modifications by patch
file-5.41-rpi-bin.diff then the raspberry pi EEPROM now are
identified and described. This now with option -m Magdir/rpi
looks like:

pieeprom-2020-07-16.bin: Raspberry Pi EEPROM, offset 000184d4
pieeprom-2020-07-31.bin: Raspberry Pi EEPROM, offset 000184c8
pieeprom-2020-09-03.bin: Raspberry Pi EEPROM, offset 000184c8
pieeprom-2020-10-02.bin: Raspberry Pi EEPROM, offset 00018534
pieeprom-2020-10-28.bin: Raspberry Pi EEPROM, offset 000185a4
pieeprom-2020-11-24.bin: Raspberry Pi EEPROM, offset 0001a628
pieeprom-2020-12-11.bin: Raspberry Pi EEPROM, offset 0001a5f4
pieeprom-2021-01-05.bin: Raspberry Pi EEPROM, offset 0001a608
pieeprom-2021-01-11.bin: Raspberry Pi EEPROM, offset 0001a60c
pieeprom-2021-01-16.bin: Raspberry Pi EEPROM, offset 0001a614
pieeprom-2021-02-16.bin: Raspberry Pi EEPROM, offset 0001a62c
pieeprom-2021-03-04.bin: Raspberry Pi EEPROM, offset 0001ddcc
pieeprom-2021-03-17.bin: Raspberry Pi EEPROM, offset 0001ddb0
pieeprom-2021-05-19.bin: Raspberry Pi EEPROM, offset 0001de60
pieeprom-2021-06-11.bin: Raspberry Pi EEPROM, offset 0001de84
pieeprom-2021-06-17.bin: Raspberry Pi EEPROM, offset 0001de84
pieeprom-2021-06-25.bin: Raspberry Pi EEPROM, offset 0001de84
pieeprom-2021-07-06.bin: Raspberry Pi EEPROM, offset 0001de84
pieeprom-2021-09-23.bin: Raspberry Pi EEPROM, offset 0000ab2c
pieeprom-2021-09-27.bin: Raspberry Pi EEPROM, offset 0000ab28
pieeprom-2021-10-04.bin: Raspberry Pi EEPROM, offset 0000ab28
pieeprom-2021-10-05.bin: Raspberry Pi EEPROM, offset 0000ab28
pieeprom-2021-10-27.bin: Raspberry Pi EEPROM, offset 0000bb30
pieeprom-2021-11-22.bin: Raspberry Pi EEPROM, offset 0000bb30
pieeprom-2021-12-02.bin: Raspberry Pi EEPROM, offset 0000bb30
pieeprom-2022-01-20.bin: Raspberry Pi EEPROM, offset 0000bb30
pieeprom-2022-01-25.bin: Raspberry Pi EEPROM, offset 0000bb30
pieeprom-2022-02-04.bin: Raspberry Pi EEPROM, offset 0000bb84
pieeprom-2022-02-16.bin: Raspberry Pi EEPROM, offset 0000bb84
pieeprom-2022-02-28.bin: Raspberry Pi EEPROM, offset 0000bbd4
pieeprom-2022-03-10.bin: Raspberry Pi EEPROM, offset 0000bbd4

I hope my diff file can be applied in future version of file
utility.

With best wishes
Jörg Jenderek
- --
Jörg Jenderek










-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iF0EARECAB0WIQS5/qNWKD4ASGOJGL+v8rHJQhrU1gUCYkcpogAKCRCv8rHJQhrU
1poeAJ9LLptm5lnxflAPVM48vz8rwqWwFwCgnEusJWndcfXVgSgwcT64nYlwT3Y=
=a+yN
-----END PGP SIGNATURE-----
-------------- next part --------------
-- 
File mailing list
File at astron.com
https://mailman.astron.com/mailman/listinfo/file

-------------- next part --------------
--- file-5.41/magic/Magdir/rpi.old	2019-10-02 04:07:30.000000000 +0200
+++ file-5.41/magic/Magdir/rpi	2022-04-01 18:31:36.935643000 +0200
@@ -28,2 +28,25 @@
 >>>>>>>>>>48	lelong	4
 >>>>>>>>>>>52	string	RPTL		Raspberry PI kernel image
+
+# From: 	Joerg Jenderek
+# URL:		https://www.raspberrypi.com/documentation/computers/raspberry-pi.html
+#		#raspberry-pi-4-boot-eeprom
+# Reference:	https://github.com/raspberrypi/rpi-eeprom/blob/master/rpi-eeprom-config
+# Note:		start with same magic as for BIOS (ia32) ROM Extension handled by ./intel
+# masked with MAGIC_MASK and then compared with MAGIC
+0	belong&0xFFffF00F	0x55aaF00F	Raspberry PI EEPROM
+#!:mime	application/octet-stream
+!:mime	application/x-raspberry-eeprom
+# like: pieeprom-2020-09-03.bin
+!:ext	bin
+# a 32 bit offset to the next section like: 000184d4 000184c8 00018534 ... 0000bb84 0000bbd4 0000bbd4
+>4	ubelong			x		\b, offset %8.8x
+#>(4.L)	ubelong			x		NEXT=%8.8x
+# self.length
+>8	ubelong			!0		\b, length %x
+# self.filename
+>12	string			>0		\b, "%s"
+# length is zero
+>8	ubelong			=0
+# if length is zero then 2nd section magic here can be zero; this means sections parsing done
+>>8	ubelong			!0		\b, 2nd MAGIC=%8.8x
-------------- next part --------------
A non-text attachment was scrubbed...
Name: file-5.41-rpi-bin.diff.sig
Type: application/octet-stream
Size: 834 bytes
Desc: not available
URL: <https://mailman.astron.com/pipermail/file/attachments/20220401/356ec868/attachment.obj>


More information about the File mailing list