zephyr-installer 1.0.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.
- zephyr_installer-1.0.0/LICENSE +201 -0
- zephyr_installer-1.0.0/PKG-INFO +354 -0
- zephyr_installer-1.0.0/README.md +336 -0
- zephyr_installer-1.0.0/pyproject.toml +46 -0
- zephyr_installer-1.0.0/setup.cfg +4 -0
- zephyr_installer-1.0.0/src/__init__.py +42 -0
- zephyr_installer-1.0.0/src/__main__.py +8 -0
- zephyr_installer-1.0.0/src/app.py +332 -0
- zephyr_installer-1.0.0/src/cli.py +15 -0
- zephyr_installer-1.0.0/src/core/__init__.py +12 -0
- zephyr_installer-1.0.0/src/core/cli.py +889 -0
- zephyr_installer-1.0.0/src/core/console.py +132 -0
- zephyr_installer-1.0.0/src/core/download.py +483 -0
- zephyr_installer-1.0.0/src/core/files.py +35 -0
- zephyr_installer-1.0.0/src/core/installer.py +661 -0
- zephyr_installer-1.0.0/src/core/manifest.py +804 -0
- zephyr_installer-1.0.0/src/core/target.py +133 -0
- zephyr_installer-1.0.0/src/core/usercode.py +193 -0
- zephyr_installer-1.0.0/src/core/yamlreader.py +301 -0
- zephyr_installer-1.0.0/src/module.py +215 -0
- zephyr_installer-1.0.0/src/zephyr.py +373 -0
- zephyr_installer-1.0.0/test/test_app.py +301 -0
- zephyr_installer-1.0.0/test/test_cli.py +175 -0
- zephyr_installer-1.0.0/test/test_manifest.py +171 -0
- zephyr_installer-1.0.0/test/test_module.py +149 -0
- zephyr_installer-1.0.0/test/test_packaging.py +31 -0
- zephyr_installer-1.0.0/zephyr_installer.egg-info/PKG-INFO +354 -0
- zephyr_installer-1.0.0/zephyr_installer.egg-info/SOURCES.txt +29 -0
- zephyr_installer-1.0.0/zephyr_installer.egg-info/dependency_links.txt +1 -0
- zephyr_installer-1.0.0/zephyr_installer.egg-info/entry_points.txt +2 -0
- zephyr_installer-1.0.0/zephyr_installer.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: zephyr-installer
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Install embedded C libraries into a Zephyr application, as Zephyr modules
|
|
5
|
+
Author-email: "Nima Askari (NimaLTD)" <nima.askari@gmail.com>
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/nimaltd/zephyr-installer
|
|
8
|
+
Project-URL: Issues, https://github.com/nimaltd/zephyr-installer/issues
|
|
9
|
+
Keywords: zephyr,zephyr-rtos,nrf-connect-sdk,embedded,installer,kconfig,nimaltd
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Topic :: Software Development :: Embedded Systems
|
|
14
|
+
Requires-Python: >=3.8
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
Dynamic: license-file
|
|
18
|
+
|
|
19
|
+
# zephyr-installer
|
|
20
|
+
|
|
21
|
+
Installs embedded C libraries into a Zephyr application, nRF Connect SDK ones included.
|
|
22
|
+
|
|
23
|
+
A library written for any project has no idea what a Zephyr module is. This copies it into your application, makes it a module, adds it to the build, and switches it on in `prj.conf`, so `west build` picks it up and its settings live in Kconfig like everything else in Zephyr.
|
|
24
|
+
|
|
25
|
+
It works with any library that has an `installer.yml` at the root of its repository. I wrote it for my own [NimaLTD](https://github.com/nimaltd) libraries, and they all have one, but nothing in it is tied to them: add an `installer.yml` to yours, as shown [below](#for-someone-writing-a-library), and it installs the same way. The same file serves [stm32-installer](https://github.com/nimaltd/stm32-installer), so one library can be installed into an STM32 project and a Zephyr application alike.
|
|
26
|
+
|
|
27
|
+
Every command below uses `owner/example`, the library's GitHub owner and name, such as `nimaltd/ee24`. Put the real ones in its place.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Installing a library
|
|
32
|
+
|
|
33
|
+
Install the installer once. This needs internet:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pip install zephyr-installer
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Then, from your application's folder, the one holding `CMakeLists.txt` and `prj.conf`:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
zephyr-installer owner/example
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Then build as always:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
west build -b nrf52840dk/nrf52840
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
To update it later, `pip install --upgrade zephyr-installer`. To remove it, `pip uninstall zephyr-installer`.
|
|
52
|
+
|
|
53
|
+
On Windows, if `zephyr-installer` is not found after installing, pip put it in a folder that is not on your PATH. `python -m zephyr_installer owner/example` runs the same thing.
|
|
54
|
+
|
|
55
|
+
### What happens
|
|
56
|
+
|
|
57
|
+
Take `example`, installed into an application called `app`:
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
app/
|
|
61
|
+
CMakeLists.txt one block added, above find_package(Zephyr)
|
|
62
|
+
prj.conf one block added, CONFIG_EXAMPLE=y and what it needs
|
|
63
|
+
modules/example/
|
|
64
|
+
example.h the library's files, as its installer.yml lists them
|
|
65
|
+
example.c
|
|
66
|
+
zephyr/
|
|
67
|
+
module.yml written by the installer: the library as a Zephyr module
|
|
68
|
+
CMakeLists.txt its files, built when CONFIG_EXAMPLE is set
|
|
69
|
+
Kconfig CONFIG_EXAMPLE and the library's settings
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
The block in your `CMakeLists.txt` adds the library's folder to `ZEPHYR_EXTRA_MODULES`. That is how Zephyr is told about a module outside the west workspace, and it has to come before `find_package(Zephyr)`, which is when Zephyr looks:
|
|
73
|
+
|
|
74
|
+
```cmake
|
|
75
|
+
cmake_minimum_required(VERSION 3.20.0)
|
|
76
|
+
|
|
77
|
+
# >>> zephyr-installer: example >>>
|
|
78
|
+
# Added by zephyr-installer. Delete this block, and example's block in
|
|
79
|
+
# the Kconfig file, to drop the library from the build.
|
|
80
|
+
list(APPEND ZEPHYR_EXTRA_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/modules/example")
|
|
81
|
+
# <<< zephyr-installer: example <<<
|
|
82
|
+
|
|
83
|
+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
The block in `prj.conf` switches the library on, with the symbols it needs and a list of its settings:
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
# >>> zephyr-installer: example >>>
|
|
90
|
+
# Added by zephyr-installer, and written again on every install, so set
|
|
91
|
+
# example's settings below this block rather than in it.
|
|
92
|
+
# Its settings, as they are unless you set them:
|
|
93
|
+
# CONFIG_EXAMPLE_POLL_CHUNK=32
|
|
94
|
+
CONFIG_I2C=y
|
|
95
|
+
CONFIG_EXAMPLE=y
|
|
96
|
+
# <<< zephyr-installer: example <<<
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
A symbol you already set yourself is not set again in the block, whatever value you gave it. `CONFIG_I2C=n` of yours stays `n`, and the installer says so before it writes anything, rather than quietly undoing your choice with a later line.
|
|
100
|
+
|
|
101
|
+
Both files are copied aside before they change, as `CMakeLists.txt.20261013-170013.bak` and the like, and the files keep their own line endings. Installing twice changes nothing the second time.
|
|
102
|
+
|
|
103
|
+
The module is called `example_lib`, not `example`. Zephyr keeps one module per name, and one added by the application quietly takes the place of a module of the same name in the workspace: a library called `littlefs` would otherwise replace Zephyr's own littlefs.
|
|
104
|
+
|
|
105
|
+
### Settings
|
|
106
|
+
|
|
107
|
+
A library's settings are Kconfig symbols, set in `prj.conf` like any other, below the installer's block:
|
|
108
|
+
|
|
109
|
+
```
|
|
110
|
+
CONFIG_EXAMPLE_POLL_CHUNK=64
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
`west build -t menuconfig` shows them too, under the library's name. The C code reads them as `CONFIG_EXAMPLE_POLL_CHUNK`, which Zephyr gives every file of the build.
|
|
114
|
+
|
|
115
|
+
### Which Kconfig file
|
|
116
|
+
|
|
117
|
+
`prj.conf` is the one most applications have. When yours has more, such as a board's own file in `boards/`, the installer asks once which one gets the libraries:
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
This application has more than one Kconfig file: prj.conf, boards/nrf52840dk_nrf52840.conf
|
|
121
|
+
Kconfig file for the libraries [prj.conf]:
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Press Enter for `prj.conf`. `--conf boards/nrf52840dk_nrf52840.conf` answers it on the command line, and a file that does not exist yet is created. One answer covers every library of that run, a library it needs included. On an update, a library stays in the file that already has its block, without a question. In a script, where nobody can answer, `prj.conf` is taken.
|
|
125
|
+
|
|
126
|
+
### What you see
|
|
127
|
+
|
|
128
|
+
A first install from GitHub, into an application whose `prj.conf` turned printk off:
|
|
129
|
+
|
|
130
|
+
```
|
|
131
|
+
Fetching owner/example ...
|
|
132
|
+
|
|
133
|
+
example 1.2.0
|
|
134
|
+
Driver for the X chip
|
|
135
|
+
driver / storage
|
|
136
|
+
|
|
137
|
+
Requirements
|
|
138
|
+
note CONFIG_I2C=y goes into prj.conf
|
|
139
|
+
check prj.conf sets CONFIG_PRINTK=n, and example needs y
|
|
140
|
+
Your line is kept. Change it if the library is to work.
|
|
141
|
+
note Needs I2C, 400 kHz
|
|
142
|
+
Enable it in your board's devicetree, or in an overlay of the application.
|
|
143
|
+
|
|
144
|
+
Folder to install example into [modules/example]:
|
|
145
|
+
|
|
146
|
+
Files
|
|
147
|
+
written modules/example/example.h
|
|
148
|
+
written modules/example/example.c
|
|
149
|
+
|
|
150
|
+
Project
|
|
151
|
+
updated Zephyr module Wrote example_lib: zephyr/module.yml, zephyr/CMakeLists.txt, zephyr/Kconfig.
|
|
152
|
+
updated CMakeLists.txt Added example to CMakeLists.txt.
|
|
153
|
+
backup: CMakeLists.txt.20261013-170013.bak
|
|
154
|
+
updated prj.conf Added example to prj.conf.
|
|
155
|
+
backup: prj.conf.20261013-170014.bak
|
|
156
|
+
|
|
157
|
+
Done. #include "example.h" and you are away.
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
The hardware a library uses is yours to give it in the devicetree, which the installer names but does not change.
|
|
161
|
+
|
|
162
|
+
### What to install
|
|
163
|
+
|
|
164
|
+
The argument can be any of these, and you can give several at once:
|
|
165
|
+
|
|
166
|
+
| You have | You type |
|
|
167
|
+
|---|---|
|
|
168
|
+
| Nothing yet, and internet | `zephyr-installer owner/example` |
|
|
169
|
+
| The library's GitHub address | `zephyr-installer https://github.com/owner/example` |
|
|
170
|
+
| The zip from GitHub's **Download ZIP** | `zephyr-installer D:/Downloads/example-main.zip` |
|
|
171
|
+
| That zip unpacked, anywhere on disk | `zephyr-installer D:/Downloads/example-main` |
|
|
172
|
+
| The library's folder, already inside your application | `zephyr-installer modules/example` |
|
|
173
|
+
|
|
174
|
+
A bare name with no owner, like `example`, is a NimaLTD library, `nimaltd/example` on GitHub, unless a folder of that name exists where you run it, in which case the folder is used. A path that does not exist is reported as missing rather than looked up on GitHub.
|
|
175
|
+
|
|
176
|
+
### Options
|
|
177
|
+
|
|
178
|
+
| Option | What it does |
|
|
179
|
+
|---|---|
|
|
180
|
+
| `--conf boards/x.conf` | The Kconfig file that switches the libraries on. Asked when the application has more than one, `prj.conf` otherwise. See [Which Kconfig file](#which-kconfig-file) |
|
|
181
|
+
| `--dir libs/example` | The folder of your application to install into, for one library. Asked for when not given, with `modules/<name>` as the answer if you just press Enter, or the folder it is already in |
|
|
182
|
+
| `--project D:/work/app` | Your application's folder, when you are not running from it |
|
|
183
|
+
| `--ref v2.0.0` | A tag, a branch or a commit to take from GitHub. When not given, `main`, or `master` for a repository that has no `main` |
|
|
184
|
+
| `--with littlefs` | Take this part of the library without being asked. Give it once for each part |
|
|
185
|
+
| `--without littlefs` | Leave this part out, or take it out of a library already installed |
|
|
186
|
+
| `--version` | Show which version of the installer you have, and do nothing else |
|
|
187
|
+
|
|
188
|
+
### Updating a library
|
|
189
|
+
|
|
190
|
+
Run the same command again. Every file of the library is replaced, so an update updates, and the module's three files are written again from the new `installer.yml`, so a source file the new version adds is built without you editing anything. A file that did not change is left alone, so the build does not configure again for nothing.
|
|
191
|
+
|
|
192
|
+
What you wrote between `USER CODE BEGIN` and `USER CODE END` in a library's file is kept. Outside those lines, the next install replaces it, and when that would lose something of yours the file is saved beside it first, as a `.bak`.
|
|
193
|
+
|
|
194
|
+
The record of what is installed, and where, is `.zephyr-installer.json` in your application's folder. Keep it in version control with the rest.
|
|
195
|
+
|
|
196
|
+
### A library that needs another
|
|
197
|
+
|
|
198
|
+
You install only the one you want, and what it needs goes in first, each as a module of its own with its own blocks. One already in the application at a version that will do is left alone. Everything is fetched before anything is installed, so when a library cannot be had, your application is left as it was.
|
|
199
|
+
|
|
200
|
+
### Without internet
|
|
201
|
+
|
|
202
|
+
On a machine that has internet, `pip download zephyr-installer` saves one file, the installer, which needs nothing else. Download the library too, from the green **Code** button, **Download ZIP**. Then, on the machine with no internet:
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
pip install zephyr_installer-1.0.0-py3-none-any.whl
|
|
206
|
+
zephyr-installer D:/Downloads/example-main.zip
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
If the library needs another, give that zip on the same line. A private repository installs by name with a GitHub token that can read it in `GITHUB_TOKEN`, and a proxy is taken from `HTTPS_PROXY`.
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
## For someone writing a library
|
|
214
|
+
|
|
215
|
+
Put an `installer.yml` at the root of the repository. Any library can have one, whoever wrote it, and the one file serves both zephyr-installer and stm32-installer: each reads its own keys and leaves the other's alone.
|
|
216
|
+
|
|
217
|
+
Every key zephyr-installer reads is below, each with what it does. Only `name` and `files` are required; leave out what your library does not need.
|
|
218
|
+
|
|
219
|
+
```yaml
|
|
220
|
+
name: example # the library's name, its folder and its Kconfig symbol
|
|
221
|
+
description: Driver for the X chip # one line, shown while installing and in menuconfig
|
|
222
|
+
repository: https://github.com/owner/example # where it comes from
|
|
223
|
+
license: Apache-2.0 # the licence's SPDX name
|
|
224
|
+
version: 1.0.0 # only when the first header has no @version tag
|
|
225
|
+
|
|
226
|
+
kind: driver # driver, middleware, rtos, protocol, filesystem,
|
|
227
|
+
# utility or bsp
|
|
228
|
+
category: storage # sensor, storage, display, communication, wireless,
|
|
229
|
+
# rtos, timing, power, input, math or system
|
|
230
|
+
provides: [] # what it gives other libraries: [rtos] for an RTOS
|
|
231
|
+
|
|
232
|
+
requires:
|
|
233
|
+
zephyr_installer: 1.0.0 # the oldest zephyr-installer that reads this file
|
|
234
|
+
libraries: # other libraries, installed first when missing
|
|
235
|
+
- osal >= 1.0.0 # no owner means nimaltd; >= the oldest that will do
|
|
236
|
+
- owner/lib # anyone else's, as owner/name
|
|
237
|
+
kconfig: # symbols it needs, set in the Kconfig file
|
|
238
|
+
- I2C # a symbol alone is set to y
|
|
239
|
+
- MAIN_STACK_SIZE=2048 # or SYMBOL=value: y, n, a number, 0x.. or "text"
|
|
240
|
+
peripherals: # hardware it uses, named to the user
|
|
241
|
+
- type: i2c # what it is
|
|
242
|
+
count: 1 # how many
|
|
243
|
+
note: 400 kHz # how to set it up
|
|
244
|
+
|
|
245
|
+
install:
|
|
246
|
+
layout: mirror # mirror keeps the repository's folders,
|
|
247
|
+
# flat (the default) puts every file at the top
|
|
248
|
+
include_dirs: [src] # include folders, only when the guess is wrong
|
|
249
|
+
defines: # given to the whole build, NAME or NAME=value
|
|
250
|
+
- EXAMPLE_FAST
|
|
251
|
+
|
|
252
|
+
files:
|
|
253
|
+
headers: # .h files; the first is the one to #include
|
|
254
|
+
- src/example.h
|
|
255
|
+
- src/port/*.h # a wildcard, matched the way a shell would
|
|
256
|
+
sources: # .c files, built when the library is switched on
|
|
257
|
+
- src/example.c
|
|
258
|
+
- from: src/port/spi.c # a file that goes somewhere of its own,
|
|
259
|
+
to: port/spi.c # whatever the layout says
|
|
260
|
+
|
|
261
|
+
options: # parts the user chooses at install
|
|
262
|
+
littlefs: # the name typed after --with
|
|
263
|
+
description: LittleFS file system on the flash # the question asked
|
|
264
|
+
libraries: # libraries this part needs, installed first
|
|
265
|
+
- littlefs >= 2.11.0
|
|
266
|
+
files: # its files, written like files above
|
|
267
|
+
sources:
|
|
268
|
+
- src/example_lfs.c
|
|
269
|
+
|
|
270
|
+
extras: # copied as they are, never compiled
|
|
271
|
+
- LICENSE.md # LICENSE.md and NOTICE are the default,
|
|
272
|
+
- NOTICE # so leave this out if that is all
|
|
273
|
+
- README.md
|
|
274
|
+
|
|
275
|
+
zephyr: # read by zephyr-installer only
|
|
276
|
+
kconfig: EXAMPLE # the library's symbol; the name in capitals when left out
|
|
277
|
+
settings: # Kconfig symbols the user sets, CONFIG_<name> in the code
|
|
278
|
+
- name: EXAMPLE_POLL_CHUNK # the symbol, best started with the library's own
|
|
279
|
+
type: int # bool, int, hex or string
|
|
280
|
+
default: 32 # required: true or false, a number, 0x.. or text
|
|
281
|
+
range: [1, 32768] # int and hex only: [smallest, largest]
|
|
282
|
+
prompt: Bytes read per call # one line, shown in menuconfig
|
|
283
|
+
help: | # as many lines as it takes, shown in menuconfig
|
|
284
|
+
A read by polling moves at most this many bytes per call.
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
Keys only stm32-installer reads, such as `requires.installer`, `requires.hal_modules` and `requires.rtos`, can stay in the same file. This installer skips them.
|
|
288
|
+
|
|
289
|
+
Leave `version` out. The installer reads the version from the `@version` tag in the file comment of the first header listed, so it is written in the code and nowhere else.
|
|
290
|
+
|
|
291
|
+
`requires.zephyr_installer` is the oldest zephyr-installer that reads the file correctly. It is checked before anything else in the file is read, so an older installer stops with a message saying to update, rather than read the file wrongly. Write it as three numbers, `1.0.0`: unquoted, YAML reads `1.10` as the decimal number `1.1`, and that is refused.
|
|
292
|
+
|
|
293
|
+
### Settings in the code
|
|
294
|
+
|
|
295
|
+
Zephyr hands every file of the build its configuration, so the library's code reads a setting as a macro. One header can serve Zephyr and any other project, taking the setting from Kconfig when it is there:
|
|
296
|
+
|
|
297
|
+
```c
|
|
298
|
+
#ifdef CONFIG_EXAMPLE_POLL_CHUNK
|
|
299
|
+
#define EXAMPLE_POLL_CHUNK CONFIG_EXAMPLE_POLL_CHUNK
|
|
300
|
+
#endif
|
|
301
|
+
|
|
302
|
+
#ifndef EXAMPLE_POLL_CHUNK
|
|
303
|
+
#define EXAMPLE_POLL_CHUNK 32U
|
|
304
|
+
#endif
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
A `bool` setting that is off is not defined at all, which is how Kconfig does it, so test it with `#ifdef` or `IS_ENABLED()`. A `string` arrives in quotes, ready for C.
|
|
308
|
+
|
|
309
|
+
Each setting is checked at install, since all of it is written into a Kconfig file: a default of the wrong type, one outside its range, or a name Kconfig would refuse stops the install with the reason, before anything is written.
|
|
310
|
+
|
|
311
|
+
### A library with its own module
|
|
312
|
+
|
|
313
|
+
A library that ships a `zephyr/module.yml` of its own, listed under `extras` or `files` so it is installed, knows its build better than the installer does. Its module is used as it is: nothing is written into its `zephyr` folder, and only the two blocks in the application are added. `zephyr.kconfig` then names the symbol its Kconfig defines, for the block in `prj.conf` to set.
|
|
314
|
+
|
|
315
|
+
---
|
|
316
|
+
|
|
317
|
+
## Running the tests
|
|
318
|
+
|
|
319
|
+
The shared core, [core-installer](https://github.com/nimaltd/core-installer), is a git submodule in `src/core`, so clone with it:
|
|
320
|
+
|
|
321
|
+
```bash
|
|
322
|
+
git clone --recursive https://github.com/nimaltd/zephyr-installer.git
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
In a clone made without `--recursive`, `git submodule update --init` fetches it. Then:
|
|
326
|
+
|
|
327
|
+
```bash
|
|
328
|
+
python test/run_tests.py
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
CI also installs a small library from `test/e2e/` into an application, builds it with Zephyr for `native_sim`, runs it, and checks what it prints, so every release is known to build with real Zephyr.
|
|
332
|
+
|
|
333
|
+
---
|
|
334
|
+
|
|
335
|
+
## Support
|
|
336
|
+
|
|
337
|
+
I write these tools and libraries in my own time and give them away, because good tools should be easy to get. If this one saved you an afternoon, there are two things that genuinely help:
|
|
338
|
+
|
|
339
|
+
**Star the repo.** It costs you one click, it helps other engineers find the tool, and it is the main reason I keep going.
|
|
340
|
+
|
|
341
|
+
**[Buy me a coffee on Ko-fi](https://ko-fi.com/nimaltd).** Any amount is a real motivation to keep writing, documenting and maintaining this work.
|
|
342
|
+
|
|
343
|
+
[](https://github.com/NimaLTD)
|
|
344
|
+
[](https://youtube.com/@nimaltd)
|
|
345
|
+
[](https://instagram.com/github.nimaltd)
|
|
346
|
+
[](https://linkedin.com/in/nimaltd)
|
|
347
|
+
[](mailto:nima.askari@gmail.com)
|
|
348
|
+
[](https://ko-fi.com/nimaltd)
|
|
349
|
+
|
|
350
|
+
---
|
|
351
|
+
|
|
352
|
+
## License
|
|
353
|
+
|
|
354
|
+
Apache License 2.0. See [LICENSE](https://github.com/nimaltd/zephyr-installer/blob/main/LICENSE).
|