Skip to content

Commit

Permalink
Merge pull request #348 from siemens/chao/add-examples-for-update-tool
Browse files Browse the repository at this point in the history
Chao/add examples for update tool
  • Loading branch information
BaochengSu authored Aug 10, 2022
2 parents f3b648d + c11a1b6 commit 5eb4980
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions recipes-app/iot2050-firmware-update/files/iot2050-firmware-update
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
# }
# ],
# "suggest_preserved_uboot_env": [
# "boot_targets",
# "boot_targets"
# ]
# }
#
Expand Down Expand Up @@ -105,6 +105,7 @@ import mmap
import argparse
import tarfile
import json
import textwrap
from types import SimpleNamespace as Namespace
import subprocess
import tempfile
Expand Down Expand Up @@ -425,9 +426,23 @@ class ManagedFirmwareUpdate(FirmwareUpdate):

return preserved_uboot_env_value

__version__ = "0.2"

def main(argv):
parser = argparse.ArgumentParser(description='Update OSPI firmware.')
description=textwrap.dedent('''\
Update OSPI firmware.
Examples:
1. %(prog)s -f file.bin
using binary format firmware
2. %(prog)s file.tar.xz
using tarball format firmware
3. %(prog)s -p "env1,env2" file.tar.xz
using tarball format firmware, preserve environment follow -p
4. %(prog)s -r file.tar.xz
using tarball format firmware, reset environment
''')
parser = argparse.ArgumentParser(description=description,
formatter_class=argparse.RawDescriptionHelpFormatter)
group = parser.add_mutually_exclusive_group()
parser.add_argument('firmware', metavar='FIRMWARE',
type=argparse.FileType('rb'),
Expand All @@ -437,10 +452,13 @@ def main(argv):
action='store_true')
group.add_argument('-p', '--preserve_list',
type=str,
help='env preserve list,using comma to separate env')
help='env preserve list, using comma to separate env')
group.add_argument('-r', '--reset',
help='reset env to default value',
action='store_true')
parser.add_argument('-v', '--version',
action='version',
version="%(prog)s version: " + __version__)

try:
args = parser.parse_args()
Expand Down Expand Up @@ -475,7 +493,7 @@ def main(argv):
for env in envlist:
print(env)
preserved_env_input = input(
"\nWarning: Preserve the above env variables. Confirm(n/Y)? ")
"\nWarning: Preserve the above env variables. Confirm(Y/n)? ")
if not preserved_env_input == "n":
updater.update_uboot_env(envlist)

Expand Down

0 comments on commit 5eb4980

Please sign in to comment.