Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions boards/sensry/ganymed_bob/board.cmake
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)
1 change: 1 addition & 0 deletions scripts/west_commands/runners/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def _import_runner_module(runner_name):
'spi_burn',
'stm32cubeprogrammer',
'stm32flash',
'sy1xx',
'teensy',
'trace32',
'uf2',
Expand Down
74 changes: 74 additions & 0 deletions scripts/west_commands/runners/sy1xx.py
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
Copy link
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it comes from here: https://pypi.org/project/ganymed/

Copy link
Contributor

Choose a reason for hiding this comment

The 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 :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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:

        if importlib.util.find_spec('ganymed') is None:
            raise RuntimeError("ganymed not found; can be installed with 'pip install ganymed'")

when flashing the first time. so it offers to install on demand.

Copy link
Contributor

Choose a reason for hiding this comment

The 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"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did recommend this, and the short concise message was copied from

self.die("PyGithub not found; can be installed with 'pip install PyGithub'")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, it cannt be missed:

[94/94] Linking C executable zephyr/zephyr.elf
Memory region         Used Size  Region Size  %age Used
        L2_START:           4 B        128 B      3.12%
     L2_VALIDITY:           4 B        128 B      3.12%
             ROM:       13972 B     391680 B      3.57%
             RAM:        4432 B         2 MB      0.21%
     L2_PRIV_CH0:          3 KB         8 KB     37.50%
        IDT_LIST:          0 GB         2 KB      0.00%
Generating files from /home/user/.local/zephyrproject-latest/zephyr/build/zephyr/zephyr.elf for board: ganymed_bob
-- west flash: using runner sy1xx
FATAL ERROR: ganymed not found; can be installed with 'pip install ganymed'
$ 


# 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.')
1 change: 1 addition & 0 deletions scripts/west_commands/tests/test_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def test_runner_imports():
'spi_burn',
'stm32cubeprogrammer',
'stm32flash',
'sy1xx',
'teensy',
'trace32',
'uf2',
Expand Down
Loading