-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Sy1xx/otp bootloader runner #87394
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sy1xx/otp bootloader runner #87394
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # Copyright (c) 2025 sensry.io | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| board_set_flasher_ifnset(sy1xx) | ||
| board_finalize_runner_args(sy1xx) |
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,74 @@ | ||||
| # Copyright (c) 2025 sensry.io | ||||
| # SPDX-License-Identifier: Apache-2.0 | ||||
|
|
||||
| '''Runner for Sensry SY1xx Soc Flashing Tool.''' | ||||
|
|
||||
| import importlib.util | ||||
|
|
||||
| from runners.core import RunnerCaps, ZephyrBinaryRunner | ||||
|
|
||||
|
|
||||
| class Sy1xxBinaryRunner(ZephyrBinaryRunner): | ||||
| '''Runner front-end for Sensry SY1xx Soc''' | ||||
|
|
||||
| def __init__(self, cfg, dev_id=None): | ||||
| super().__init__(cfg) | ||||
| print(cfg) | ||||
| self.bin_file = cfg.bin_file | ||||
| self.dev_id = dev_id | ||||
|
|
||||
| @classmethod | ||||
| def name(cls): | ||||
| return 'sy1xx' | ||||
|
|
||||
| @classmethod | ||||
| def capabilities(cls): | ||||
| return RunnerCaps(commands={'flash'}, dev_id=True) | ||||
|
|
||||
| @classmethod | ||||
| def do_add_parser(cls, parser): | ||||
| parser.set_defaults(dev_id='/dev/ttyUSB0') | ||||
|
|
||||
| @classmethod | ||||
| def dev_id_help(cls) -> str: | ||||
| return 'Device identifier such as /dev/ttyUSB0' | ||||
|
|
||||
| @classmethod | ||||
| def do_create(cls, cfg, args): | ||||
| # make sure the ganymed tools are installed | ||||
| if importlib.util.find_spec('ganymed') is None: | ||||
| raise RuntimeError("ganymed not found; can be installed with 'pip install ganymed'") | ||||
|
|
||||
| if not hasattr(args, "dev_id") or args.dev_id is None: | ||||
| raise RuntimeError("missing --dev-id argument, such as /dev/ttyUSB0") | ||||
|
|
||||
| return Sy1xxBinaryRunner(cfg, args.dev_id) | ||||
|
|
||||
| def do_run(self, command, **kwargs): | ||||
| if command == 'flash': | ||||
| self.flash(**kwargs) | ||||
|
|
||||
| def flash(self, **kwargs): | ||||
| self.logger.info(f'Flashing file: {self.bin_file} to {self.dev_id}') | ||||
|
|
||||
| from ganymed.bootloader import Bootloader | ||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where does this come from and how does one install this? It doesn't seem to be documented anywhere?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it comes from here: https://pypi.org/project/ganymed/
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure but you can't expect users to just know that, and it will just fail when they west flash :)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Initially I had an auto installer via pip, when creating this runner. However this is maybe not the best version. for now it prompts: when flashing the first time. so it offers to install on demand.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh I missed that, sorry. I guess that works if @pdgendt and others are happy with the approach, although the error message can probably be more explicit IMO "ganymed Python package is required to use the sy1xx runner. etc"
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did recommend this, and the short concise message was copied from zephyr/scripts/west_commands/patch.py Line 481 in 4875978
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. actually, it cannt be missed: |
||||
|
|
||||
| # convert binary to application ganymed-image | ||||
| application_gnm = Bootloader.convert_zephyr_bin(self.bin_file) | ||||
|
|
||||
| # create the loader | ||||
| flash_loader = Bootloader() | ||||
|
|
||||
| # connect to serial | ||||
| flash_loader.connect(self.dev_id) | ||||
|
|
||||
| # set the controller into bootloader mode | ||||
| flash_loader.enter_loading_mode() | ||||
|
|
||||
| # clear the internal flash | ||||
| flash_loader.clear_mram() | ||||
|
|
||||
| # write the new binary | ||||
| flash_loader.write_image(application_gnm) | ||||
|
|
||||
| self.logger.info('Flashing SY1xx finished. You may reset the device.') | ||||
Uh oh!
There was an error while loading. Please reload this page.