mirror of
https://github.com/raspberrypi/rpi-eeprom.git
synced 2026-01-20 21:13:36 +08:00
rpi-eeprom-config: Add -x option to extract files
For test/debug add an option to extract all of the modifiable files.
This commit is contained in:
@@ -360,8 +360,15 @@ class BootloaderImage(object):
|
|||||||
def get_file(self, filename):
|
def get_file(self, filename):
|
||||||
hdr_offset, length, is_last = self.find_file(filename)
|
hdr_offset, length, is_last = self.find_file(filename)
|
||||||
offset = hdr_offset + 4 + FILE_HDR_LEN
|
offset = hdr_offset + 4 + FILE_HDR_LEN
|
||||||
config_bytes = self._bytes[offset:offset+length-FILENAME_LEN-4]
|
file_bytes = self._bytes[offset:offset+length-FILENAME_LEN-4]
|
||||||
return config_bytes
|
return file_bytes
|
||||||
|
|
||||||
|
def extract_files(self):
|
||||||
|
for i in range(0, len(self._sections)):
|
||||||
|
s = self._sections[i]
|
||||||
|
if s.magic == FILE_MAGIC:
|
||||||
|
file_bytes = self.get_file(s.filename)
|
||||||
|
open(s.filename, 'wb').write(file_bytes)
|
||||||
|
|
||||||
def read(self):
|
def read(self):
|
||||||
config_bytes = self.get_file('bootconf.txt')
|
config_bytes = self.get_file('bootconf.txt')
|
||||||
@@ -457,6 +464,7 @@ See 'rpi-eeprom-update -h' for more information about the available EEPROM image
|
|||||||
parser.add_argument('-o', '--out', help='Name of output file', required=False)
|
parser.add_argument('-o', '--out', help='Name of output file', required=False)
|
||||||
parser.add_argument('-d', '--digest', help='Signed boot only. The name of the .sig file generated by rpi-eeprom-dgst for config.txt ', required=False)
|
parser.add_argument('-d', '--digest', help='Signed boot only. The name of the .sig file generated by rpi-eeprom-dgst for config.txt ', required=False)
|
||||||
parser.add_argument('-p', '--pubkey', help='Signed boot only. The name of the RSA public key file to store in the EEPROM', required=False)
|
parser.add_argument('-p', '--pubkey', help='Signed boot only. The name of the RSA public key file to store in the EEPROM', required=False)
|
||||||
|
parser.add_argument('-x', '--extract', action='store_true', default=False, help='Extract the modifiable files (boot.conf, pubkey, signature)', required=False)
|
||||||
parser.add_argument('eeprom', nargs='?', help='Name of EEPROM file to use as input')
|
parser.add_argument('eeprom', nargs='?', help='Name of EEPROM file to use as input')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
@@ -468,6 +476,9 @@ See 'rpi-eeprom-update -h' for more information about the available EEPROM image
|
|||||||
|
|
||||||
if args.edit:
|
if args.edit:
|
||||||
edit_config(args.eeprom)
|
edit_config(args.eeprom)
|
||||||
|
elif args.eeprom is not None and args.extract:
|
||||||
|
image = BootloaderImage(args.eeprom, args.out)
|
||||||
|
image.extract_files()
|
||||||
elif args.apply is not None:
|
elif args.apply is not None:
|
||||||
if not os.path.exists(args.apply):
|
if not os.path.exists(args.apply):
|
||||||
exit_error("config file '%s' not found" % args.apply)
|
exit_error("config file '%s' not found" % args.apply)
|
||||||
|
|||||||
Reference in New Issue
Block a user