Skip to content

Commit

Permalink
Fix dependency on tockloader 1.4
Browse files Browse the repository at this point in the history
Now that it has been released and pushed to pypi, make sure that
tockloader is at least 1.4 version
  • Loading branch information
jmichelp committed Apr 28, 2020
1 parent dc12e10 commit c9773e0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
pip install tockloader pylint
pip install 'tockloader~=1.4' pylint
- name: Register matcher
run: echo ::add-matcher::./.github/python_matcher.json
- name: Test code with pylint
Expand Down
23 changes: 18 additions & 5 deletions deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

import colorama
from six.moves import input
import tockloader
from tockloader import tab
from tockloader import tbfh
from tockloader import tockloader as loader
Expand Down Expand Up @@ -252,12 +253,16 @@ def __init__(self, args):
board=self.args.board,
debug=False,
force=False,
jlink_cmd="JLinkExe",
jlink=self.args.programmer == "jlink",
jlink_device=board.jlink_device,
jlink_if=board.jlink_if,
jlink_speed=1200,
openocd=self.args.programmer == "openocd",
openocd_board=board.openocd_board,
openocd_cmd="openocd",
openocd_commands=copy.copy(board.openocd_commands),
openocd_options=copy.copy(board.openocd_options),
jtag=False,
no_bootloader_entry=False,
page_size=board.page_size,
Expand Down Expand Up @@ -399,7 +404,7 @@ def install_tab_file(self, tab_filename):
setattr(args, "make", False)
setattr(args, "no_replace", False)
tock = loader.TockLoader(args)
tock.open(args)
tock.open()
tabs = [tab.TAB(tab_filename)]
try:
tock.install(tabs, replace="yes", erase=args.erase)
Expand Down Expand Up @@ -428,7 +433,7 @@ def install_tock_os(self):
args = copy.copy(self.tockloader_default_args)
setattr(args, "address", board_props.app_address)
tock = loader.TockLoader(args)
tock.open(args)
tock.open()
try:
tock.flash_binary(kernel, board_props.kernel_address)
except TockLoaderException as e:
Expand All @@ -441,7 +446,7 @@ def install_padding(self):
args = copy.copy(self.tockloader_default_args)
setattr(args, "address", board_props.padding_address)
tock = loader.TockLoader(args)
tock.open(args)
tock.open()
try:
tock.flash_binary(padding, args.address)
except TockLoaderException as e:
Expand All @@ -451,11 +456,14 @@ def clear_apps(self):
args = copy.copy(self.tockloader_default_args)
board_props = SUPPORTED_BOARDS[self.args.board]
setattr(args, "app_address", board_props.app_address)
# Ensure we don't force erase all apps but only the apps starting
# at `board.app_address`. This makes sure we don't erase the padding.
setattr(args, "force", False)
info("Erasing all installed applications")
tock = loader.TockLoader(args)
tock.open(args)
tock.open()
try:
tock.erase_apps(False)
tock.erase_apps()
except TockLoaderException as e:
# Erasing apps is not critical
info(("A non-critical error occurred while erasing "
Expand All @@ -467,6 +475,7 @@ def verify_flashed_app(self, expected_app):
return False
args = copy.copy(self.tockloader_default_args)
tock = loader.TockLoader(args)
tock.open()
app_found = False
with tock._start_communication_with_board():
apps = [app.name for app in tock._extract_all_app_headers()]
Expand Down Expand Up @@ -515,6 +524,10 @@ def create_hex_file(self, dest_file):
final_hex.tofile(dest_file, format="hex")

def check_prerequisites(self):
if not tockloader.__version__.startswith("1.4"):
fatal(("Your version of tockloader is too old: found {}, expected "
"1.4.0.".format(tockloader.__version__)))

if self.args.programmer == "jlink":
assert_mandatory_binary("JLinkExe")

Expand Down
2 changes: 1 addition & 1 deletion setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ source tools/gen_key_materials.sh
generate_crypto_materials N

rustup install $(head -n 1 rust-toolchain)
pip3 install --user --upgrade tockloader six intelhex
pip3 install --user --upgrade 'tockloader~=1.4' six intelhex
rustup target add thumbv7em-none-eabi

# Install dependency to create applications.
Expand Down

0 comments on commit c9773e0

Please sign in to comment.