Allow flashing only the kernel without any app.

This commit is contained in:
Jean-Michel Picod
2020-03-11 18:29:31 +01:00
parent b22832e9c7
commit 4a3ccb48d7

View File

@@ -485,6 +485,7 @@ class OpenSKInstaller:
kern_hex.frombytes(kernel.read(), offset=board_props.kernel_address) kern_hex.frombytes(kernel.read(), offset=board_props.kernel_address)
final_hex.merge(kern_hex, overlap="error") final_hex.merge(kern_hex, overlap="error")
if self.args.application:
# Add padding # Add padding
if board_props.padding_address: if board_props.padding_address:
padding_hex = intelhex.IntelHex() padding_hex = intelhex.IntelHex()
@@ -546,9 +547,6 @@ class OpenSKInstaller:
self.check_prerequisites() self.check_prerequisites()
self.update_rustc_if_needed() self.update_rustc_if_needed()
if self.args.application is None:
fatal("Please specify an application to be flashed")
# Compile what needs to be compiled # Compile what needs to be compiled
if self.args.tockos: if self.args.tockos:
self.build_tockos() self.build_tockos()
@@ -556,6 +554,8 @@ class OpenSKInstaller:
if self.args.application == "ctap2": if self.args.application == "ctap2":
self.generate_crypto_materials(self.args.regenerate_keys) self.generate_crypto_materials(self.args.regenerate_keys)
self.build_opensk() self.build_opensk()
elif self.args.application is None:
info("No application selected.")
else: else:
self.build_example() self.build_example()
@@ -568,16 +568,19 @@ class OpenSKInstaller:
if self.args.tockos: if self.args.tockos:
# Install Tock OS # Install Tock OS
self.install_tock_os() self.install_tock_os()
# Install padding and application # Install padding and application if needed
if self.args.application:
self.install_padding() self.install_padding()
self.install_tab_file("target/tab/{}.tab".format(self.args.application)) self.install_tab_file("target/tab/{}.tab".format(self.args.application))
if self.verify_flashed_app(self.args.application): if self.verify_flashed_app(self.args.application):
info("You're all set!") info("You're all set!")
return 0 return 0
error(("It seems that something went wrong. App/example not found " error(
("It seems that something went wrong. App/example not found "
"on your board. Ensure the connections between the programmer and " "on your board. Ensure the connections between the programmer and "
"the board are correct.")) "the board are correct."))
return 1 return 1
return 0
if self.args.programmer in ("pyocd", "nordicdfu", "none"): if self.args.programmer in ("pyocd", "nordicdfu", "none"):
dest_file = "target/{}_merged.hex".format(self.args.board) dest_file = "target/{}_merged.hex".format(self.args.board)
@@ -734,7 +737,14 @@ if __name__ == "__main__":
"storage (i.e. unplugging the key will reset the key)."), "storage (i.e. unplugging the key will reset the key)."),
) )
apps_group = main_parser.add_mutually_exclusive_group() apps_group = main_parser.add_mutually_exclusive_group(required=True)
apps_group.add_argument(
"--no-app",
dest="application",
action="store_const",
const=None,
help=("Doesn't compile nor install any application. Useful when you only "
"want to update Tock OS kernel."))
apps_group.add_argument( apps_group.add_argument(
"--opensk", "--opensk",
dest="application", dest="application",