mirror of
https://github.com/tillitis/tillitis-key1.git
synced 2025-03-26 00:28:15 -04:00
Add tool to create a flash image containing a preloaded app at slot 0
This commit is contained in:
parent
a8f2a8c30e
commit
478212f72f
28
hw/application_fpga/tools/create_flash_image.py
Executable file
28
hw/application_fpga/tools/create_flash_image.py
Executable file
@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
|
||||
FLASH_SIZE_BYTES = 1 * 1024 * 1024
|
||||
PRELOADED_APP_0_START = 0x30000
|
||||
|
||||
|
||||
def run(output_path, preloaded_app_0_path):
|
||||
with (
|
||||
open(output_path, "wb") as output_file,
|
||||
open(preloaded_app_0_path, "rb") as preloaded_app_0_file,
|
||||
):
|
||||
content = bytearray(b"\xFF") * FLASH_SIZE_BYTES
|
||||
preloaded_app = preloaded_app_0_file.read()
|
||||
content[
|
||||
PRELOADED_APP_0_START : PRELOADED_APP_0_START + len(preloaded_app)
|
||||
] = preloaded_app
|
||||
output_file.write(content)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
arg_parser = argparse.ArgumentParser()
|
||||
arg_parser.add_argument("OUTPUT_PATH")
|
||||
arg_parser.add_argument("PRELOADED_APP_0_PATH")
|
||||
args = arg_parser.parse_args()
|
||||
|
||||
run(args.OUTPUT_PATH, args.PRELOADED_APP_0_PATH)
|
Loading…
x
Reference in New Issue
Block a user