bossac-wrapper 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bossac_wrapper-0.1.0/CHANGELOG.md +25 -0
- bossac_wrapper-0.1.0/CONTRIBUTING.md +74 -0
- bossac_wrapper-0.1.0/LICENSE +21 -0
- bossac_wrapper-0.1.0/PKG-INFO +125 -0
- bossac_wrapper-0.1.0/README.md +109 -0
- bossac_wrapper-0.1.0/bossac/__init__.py +919 -0
- bossac_wrapper-0.1.0/bossac/py.typed +0 -0
- bossac_wrapper-0.1.0/docs/Makefile +20 -0
- bossac_wrapper-0.1.0/docs/make.bat +35 -0
- bossac_wrapper-0.1.0/docs/source/api.rst +30 -0
- bossac_wrapper-0.1.0/docs/source/changelog.rst +5 -0
- bossac_wrapper-0.1.0/docs/source/conf.py +67 -0
- bossac_wrapper-0.1.0/docs/source/dev_guide.rst +9 -0
- bossac_wrapper-0.1.0/docs/source/index.rst +20 -0
- bossac_wrapper-0.1.0/pdm_build.py +182 -0
- bossac_wrapper-0.1.0/pyproject.toml +155 -0
- bossac_wrapper-0.1.0/tests/Blink.ino.bin +0 -0
- bossac_wrapper-0.1.0/tests/Blink.ino.hex +646 -0
- bossac_wrapper-0.1.0/tests/__init__.py +0 -0
- bossac_wrapper-0.1.0/tests/test_bossac.py +924 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## [Unreleased]
|
|
10
|
+
|
|
11
|
+
## [0.1.0]
|
|
12
|
+
|
|
13
|
+
_First release._
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
|
|
17
|
+
- `upload()`, `verify()`, `read()`, `erase()`, `reset()` and `info()` for programming devices
|
|
18
|
+
with bossac, including support for Intel HEX files and the Arduino 1200 baud touch
|
|
19
|
+
- `version()` for querying the version of the bundled bossac binary
|
|
20
|
+
- `BossacError`, raised whenever bossac fails
|
|
21
|
+
- bossac 1.9.1, built from source and bundled with the wheels for Linux, macOS and Windows
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
[Unreleased]: https://github.com/int-brain-lab/bossac-wrapper/compare/v0.1.0...HEAD
|
|
25
|
+
[0.1.0]: https://github.com/int-brain-lab/bossac-wrapper/releases/tag/v0.1.0
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
Contributing
|
|
2
|
+
============
|
|
3
|
+
|
|
4
|
+
uv
|
|
5
|
+
--
|
|
6
|
+
|
|
7
|
+
This project uses [uv](https://docs.astral.sh/uv/) as its package manager, for managing
|
|
8
|
+
dependencies and ensuring consistent, reproducible environments. See uv's
|
|
9
|
+
[installation instructions](https://docs.astral.sh/uv/getting-started/installation/) for
|
|
10
|
+
details on installing it.
|
|
11
|
+
|
|
12
|
+
Installing developer dependencies
|
|
13
|
+
----------------------------------
|
|
14
|
+
|
|
15
|
+
```shell
|
|
16
|
+
uv sync --group dev
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Building bossac
|
|
20
|
+
--------------
|
|
21
|
+
|
|
22
|
+
The bundled `bossac` binary isn't committed to this repository - it's built from source
|
|
23
|
+
automatically whenever it's needed (e.g. by `uv sync`, `uv build`, or `uv run tox`): the first
|
|
24
|
+
time, and again whenever the pinned version (`_BOSSAC_VERSION` in `bossac/__init__.py`) changes.
|
|
25
|
+
The build checks that BOSSA's release tag still points to the pinned commit (`_BOSSAC_COMMIT`) -
|
|
26
|
+
update both together. Building it requires `git`, `make` and a C++ compiler; on Windows, it
|
|
27
|
+
has to be built in an [MSYS2](https://www.msys2.org/) MINGW64 environment.
|
|
28
|
+
|
|
29
|
+
Running the test suite
|
|
30
|
+
-----------------------
|
|
31
|
+
|
|
32
|
+
Tests, linting, and type checking all run through [tox](https://tox.wiki/) (via the
|
|
33
|
+
[tox-uv](https://github.com/tox-dev/tox-uv) plugin), across every supported Python version -
|
|
34
|
+
uv provisions whichever interpreters are missing automatically:
|
|
35
|
+
|
|
36
|
+
```shell
|
|
37
|
+
uv run tox -p
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Coverage report
|
|
41
|
+
---------------
|
|
42
|
+
|
|
43
|
+
After running the test suite, a merged coverage report is available via:
|
|
44
|
+
|
|
45
|
+
```shell
|
|
46
|
+
uv run coverage report
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Checking and formatting code
|
|
50
|
+
-----------------------------
|
|
51
|
+
|
|
52
|
+
```shell
|
|
53
|
+
uv run ruff format
|
|
54
|
+
uv run ruff check --fix
|
|
55
|
+
uv run mypy
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Building the documentation
|
|
59
|
+
---------------------------
|
|
60
|
+
|
|
61
|
+
```shell
|
|
62
|
+
uv run sphinx-build -b dirhtml docs/source docs/build
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Building the package
|
|
66
|
+
---------------------
|
|
67
|
+
|
|
68
|
+
```shell
|
|
69
|
+
uv build --sdist
|
|
70
|
+
uv build --wheel
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Build the wheel separately: a plain `uv build` builds it from the sdist, which doesn't contain
|
|
74
|
+
the bossac binary - so bossac would be cloned and compiled again every time.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 International Brain Laboratory
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: bossac-wrapper
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A Python wrapper for bossac
|
|
5
|
+
Keywords: bossa,bossac,sam-ba,atmel,arduino,firmware
|
|
6
|
+
Author-Email: Florian Rau <bimac@users.noreply.github.com>
|
|
7
|
+
License: MIT
|
|
8
|
+
Project-URL: Homepage, https://github.com/int-brain-lab/bossac-wrapper/
|
|
9
|
+
Project-URL: Documentation, https://int-brain-lab.github.io/bossac-wrapper/
|
|
10
|
+
Project-URL: Repository, https://github.com/int-brain-lab/bossac-wrapper.git
|
|
11
|
+
Project-URL: Issues, https://github.com/int-brain-lab/bossac-wrapper/issues
|
|
12
|
+
Project-URL: Changelog, https://github.com/int-brain-lab/bossac-wrapper/blob/main/CHANGELOG.md
|
|
13
|
+
Requires-Python: >=3.10
|
|
14
|
+
Requires-Dist: pyserial>=3.5
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
|
|
17
|
+
bossac-wrapper
|
|
18
|
+
==============
|
|
19
|
+
|
|
20
|
+
A thin Python wrapper for [bossac](https://github.com/shumatech/BOSSA) by
|
|
21
|
+
[ShumaTech](http://www.shumatech.com) - a flash programmer for Atmel SAM microcontrollers with
|
|
22
|
+
a SAM-BA bootloader, such as the Arduino Due, Arduino Zero and MKR boards.
|
|
23
|
+
|
|
24
|
+
Installation
|
|
25
|
+
------------
|
|
26
|
+
|
|
27
|
+
```shell
|
|
28
|
+
pip install bossac-wrapper
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
This will install bossac-wrapper along with the necessary bossac binary for your system.
|
|
32
|
+
|
|
33
|
+
bossac-wrapper requires Python 3.10 or later. Supported platforms are:
|
|
34
|
+
|
|
35
|
+
- Linux (x86_64, arm64)
|
|
36
|
+
- macOS (Intel, Apple Silicon)
|
|
37
|
+
- Windows (x86_64)
|
|
38
|
+
|
|
39
|
+
Examples
|
|
40
|
+
--------
|
|
41
|
+
|
|
42
|
+
### Uploading a firmware file
|
|
43
|
+
|
|
44
|
+
To upload a firmware file to a device, use the `upload()` function. Both Intel HEX files (`.hex`)
|
|
45
|
+
and raw binaries (`.bin`) are supported.
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
import bossac
|
|
49
|
+
import logging
|
|
50
|
+
|
|
51
|
+
logging.basicConfig(level=logging.INFO)
|
|
52
|
+
bossac.upload('blink.hex', port='/dev/ttyACM0')
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
By default, the device is first put into its bootloader with a 1200 baud touch. Its flash is
|
|
56
|
+
then erased, written and verified, and the device is reset to start the new firmware. The
|
|
57
|
+
progress will be logged:
|
|
58
|
+
```
|
|
59
|
+
INFO:bossac:Erase flash
|
|
60
|
+
INFO:bossac:Done in 0.887 seconds
|
|
61
|
+
INFO:bossac:Write 10288 bytes to flash (161 pages)
|
|
62
|
+
INFO:bossac:Done in 0.067 seconds
|
|
63
|
+
INFO:bossac:Verify 10288 bytes of flash
|
|
64
|
+
INFO:bossac:Verify successful
|
|
65
|
+
INFO:bossac:Done in 0.276 seconds
|
|
66
|
+
INFO:bossac:Set boot flash true
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
An Intel HEX file carries its addresses, so it is flashed at the right offset on any board. A
|
|
70
|
+
binary file doesn't, so its offset has to be given - it depends on the board's bootloader, e.g.
|
|
71
|
+
`0x2000` on SAMD21 boards with an Arduino-style bootloader, or 0 on the Arduino Due, whose
|
|
72
|
+
bootloader is in ROM. On a board whose bootloader is in flash, an offset of 0 would overwrite it.
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
bossac.upload('blink.bin', port='/dev/ttyACM0', offset=0x2000) # SAMD21
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
When uploading via a USB-to-serial bridge, such as the programming port of the Arduino Due, pass
|
|
79
|
+
`usb=False`:
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
bossac.upload('blink.bin', port='/dev/ttyACM0', offset=0, usb=False)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Getting device information
|
|
86
|
+
|
|
87
|
+
To get the details of a device, use the `info()` function. The device must be in its bootloader,
|
|
88
|
+
e.g. after double-tapping its reset button. `touch=True` puts it there, too - but that usually
|
|
89
|
+
destroys the firmware, which then has to be uploaded again: the Arduino Due erases its flash, and
|
|
90
|
+
SAMD boards running Arduino firmware erase its first flash row.
|
|
91
|
+
|
|
92
|
+
```python
|
|
93
|
+
import bossac
|
|
94
|
+
|
|
95
|
+
bossac.info(port='/dev/ttyACM0')
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
For a SparkFun SAMD21 Mini, this returns:
|
|
99
|
+
```python
|
|
100
|
+
{
|
|
101
|
+
'device': 'ATSAMD21x18',
|
|
102
|
+
'version': 'v1.1 [Arduino:XYZ] Feb 20 2019 10:43:51',
|
|
103
|
+
'address': 0,
|
|
104
|
+
'pages': 4096,
|
|
105
|
+
'page_size': 64,
|
|
106
|
+
'total_size': 262144,
|
|
107
|
+
'planes': 1,
|
|
108
|
+
'lock_regions': 16,
|
|
109
|
+
'locked': [],
|
|
110
|
+
'security': False,
|
|
111
|
+
'boot_flash': None,
|
|
112
|
+
'brownout_detection': True,
|
|
113
|
+
'brownout_reset': True,
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Full Documentation
|
|
118
|
+
------------------
|
|
119
|
+
|
|
120
|
+
The full API documentation is available [here](https://int-brain-lab.github.io/bossac-wrapper).
|
|
121
|
+
|
|
122
|
+

|
|
123
|
+
[](https://coveralls.io/github/int-brain-lab/bossac-wrapper)
|
|
124
|
+
[](https://github.com/int-brain-lab/bossac-wrapper/actions)
|
|
125
|
+
[](https://pypi.org/project/bossac-wrapper/)
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
bossac-wrapper
|
|
2
|
+
==============
|
|
3
|
+
|
|
4
|
+
A thin Python wrapper for [bossac](https://github.com/shumatech/BOSSA) by
|
|
5
|
+
[ShumaTech](http://www.shumatech.com) - a flash programmer for Atmel SAM microcontrollers with
|
|
6
|
+
a SAM-BA bootloader, such as the Arduino Due, Arduino Zero and MKR boards.
|
|
7
|
+
|
|
8
|
+
Installation
|
|
9
|
+
------------
|
|
10
|
+
|
|
11
|
+
```shell
|
|
12
|
+
pip install bossac-wrapper
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
This will install bossac-wrapper along with the necessary bossac binary for your system.
|
|
16
|
+
|
|
17
|
+
bossac-wrapper requires Python 3.10 or later. Supported platforms are:
|
|
18
|
+
|
|
19
|
+
- Linux (x86_64, arm64)
|
|
20
|
+
- macOS (Intel, Apple Silicon)
|
|
21
|
+
- Windows (x86_64)
|
|
22
|
+
|
|
23
|
+
Examples
|
|
24
|
+
--------
|
|
25
|
+
|
|
26
|
+
### Uploading a firmware file
|
|
27
|
+
|
|
28
|
+
To upload a firmware file to a device, use the `upload()` function. Both Intel HEX files (`.hex`)
|
|
29
|
+
and raw binaries (`.bin`) are supported.
|
|
30
|
+
|
|
31
|
+
```python
|
|
32
|
+
import bossac
|
|
33
|
+
import logging
|
|
34
|
+
|
|
35
|
+
logging.basicConfig(level=logging.INFO)
|
|
36
|
+
bossac.upload('blink.hex', port='/dev/ttyACM0')
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
By default, the device is first put into its bootloader with a 1200 baud touch. Its flash is
|
|
40
|
+
then erased, written and verified, and the device is reset to start the new firmware. The
|
|
41
|
+
progress will be logged:
|
|
42
|
+
```
|
|
43
|
+
INFO:bossac:Erase flash
|
|
44
|
+
INFO:bossac:Done in 0.887 seconds
|
|
45
|
+
INFO:bossac:Write 10288 bytes to flash (161 pages)
|
|
46
|
+
INFO:bossac:Done in 0.067 seconds
|
|
47
|
+
INFO:bossac:Verify 10288 bytes of flash
|
|
48
|
+
INFO:bossac:Verify successful
|
|
49
|
+
INFO:bossac:Done in 0.276 seconds
|
|
50
|
+
INFO:bossac:Set boot flash true
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
An Intel HEX file carries its addresses, so it is flashed at the right offset on any board. A
|
|
54
|
+
binary file doesn't, so its offset has to be given - it depends on the board's bootloader, e.g.
|
|
55
|
+
`0x2000` on SAMD21 boards with an Arduino-style bootloader, or 0 on the Arduino Due, whose
|
|
56
|
+
bootloader is in ROM. On a board whose bootloader is in flash, an offset of 0 would overwrite it.
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
bossac.upload('blink.bin', port='/dev/ttyACM0', offset=0x2000) # SAMD21
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
When uploading via a USB-to-serial bridge, such as the programming port of the Arduino Due, pass
|
|
63
|
+
`usb=False`:
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
bossac.upload('blink.bin', port='/dev/ttyACM0', offset=0, usb=False)
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Getting device information
|
|
70
|
+
|
|
71
|
+
To get the details of a device, use the `info()` function. The device must be in its bootloader,
|
|
72
|
+
e.g. after double-tapping its reset button. `touch=True` puts it there, too - but that usually
|
|
73
|
+
destroys the firmware, which then has to be uploaded again: the Arduino Due erases its flash, and
|
|
74
|
+
SAMD boards running Arduino firmware erase its first flash row.
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
import bossac
|
|
78
|
+
|
|
79
|
+
bossac.info(port='/dev/ttyACM0')
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
For a SparkFun SAMD21 Mini, this returns:
|
|
83
|
+
```python
|
|
84
|
+
{
|
|
85
|
+
'device': 'ATSAMD21x18',
|
|
86
|
+
'version': 'v1.1 [Arduino:XYZ] Feb 20 2019 10:43:51',
|
|
87
|
+
'address': 0,
|
|
88
|
+
'pages': 4096,
|
|
89
|
+
'page_size': 64,
|
|
90
|
+
'total_size': 262144,
|
|
91
|
+
'planes': 1,
|
|
92
|
+
'lock_regions': 16,
|
|
93
|
+
'locked': [],
|
|
94
|
+
'security': False,
|
|
95
|
+
'boot_flash': None,
|
|
96
|
+
'brownout_detection': True,
|
|
97
|
+
'brownout_reset': True,
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Full Documentation
|
|
102
|
+
------------------
|
|
103
|
+
|
|
104
|
+
The full API documentation is available [here](https://int-brain-lab.github.io/bossac-wrapper).
|
|
105
|
+
|
|
106
|
+

|
|
107
|
+
[](https://coveralls.io/github/int-brain-lab/bossac-wrapper)
|
|
108
|
+
[](https://github.com/int-brain-lab/bossac-wrapper/actions)
|
|
109
|
+
[](https://pypi.org/project/bossac-wrapper/)
|