mirror of
https://github.com/raspberrypi/rpi-eeprom.git
synced 2026-01-20 21:13:36 +08:00
Merge pull request #12 from timg236/rpi-eeprom-config-magic
Rpi eeprom config magic
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
*.swp
|
||||||
@@ -15,7 +15,8 @@ IMAGE_SIZE = 512 * 1024
|
|||||||
# The number, order and size of the sections depends on the bootloader version
|
# The number, order and size of the sections depends on the bootloader version
|
||||||
# but the following mask can be used to test for section headers and skip
|
# but the following mask can be used to test for section headers and skip
|
||||||
# unknown data.
|
# unknown data.
|
||||||
MAGIC_MASK = 0x55aaf00f
|
MAGIC = 0x55aaf00f
|
||||||
|
MAGIC_MASK = 0xfffff00f
|
||||||
FILE_MAGIC = 0x55aaf11f # id for modifiable file, currently only bootconf.txt
|
FILE_MAGIC = 0x55aaf11f # id for modifiable file, currently only bootconf.txt
|
||||||
FILE_HDR_LEN = 20
|
FILE_HDR_LEN = 20
|
||||||
FILENAME_LEN = 12
|
FILENAME_LEN = 12
|
||||||
@@ -37,7 +38,7 @@ class BootloaderImage(object):
|
|||||||
magic = 0
|
magic = 0
|
||||||
while offset < IMAGE_SIZE:
|
while offset < IMAGE_SIZE:
|
||||||
magic, length = struct.unpack_from('>LL', self._bytes, offset)
|
magic, length = struct.unpack_from('>LL', self._bytes, offset)
|
||||||
if (magic & MAGIC_MASK) != MAGIC_MASK:
|
if (magic & MAGIC_MASK) != MAGIC:
|
||||||
raise Exception('EEPROM is corrupted')
|
raise Exception('EEPROM is corrupted')
|
||||||
|
|
||||||
if magic == FILE_MAGIC: # Found a file
|
if magic == FILE_MAGIC: # Found a file
|
||||||
|
|||||||
Reference in New Issue
Block a user