1.. _bin-blobs:
2
3Binary Blobs
4############
5
6In the context of an operating system that supports multiple architectures and
7many different IC families, some functionality may be unavailable without the
8help of executable code distributed in binary form.  Binary blobs (or blobs for
9short) are files containing proprietary machine code or data in a binary format,
10e.g. without corresponding source code released under an OSI approved license.
11
12Zephyr supports downloading and using third-party binary blobs via its built-in
13mechanisms, with some important caveats, described in the following sections. It
14is important to note that all the information in this section applies only to
15`upstream (vanilla) Zephyr <https://github.com/zephyrproject-rtos/zephyr>`_.
16
17There are no limitations whatsoever (except perhaps license compatibility) in
18the support for binary blobs in forks or third-party distributions of Zephyr. In
19fact, Zephyr’s build system supports arbitrary use cases related to blobs. This
20includes linking against libraries, flashing images to targets, etc. Users are
21therefore free to create Zephyr-based downstream software which uses binary
22blobs if they cannot meet the requirements described in this page.
23
24Software license
25****************
26
27Most binary blobs are distributed under proprietary licenses which vary
28significantly in nature and conditions. It is up to the vendor to specify the
29license as part of the blob submission process. Blob vendors may impose a
30click-through or other EULA-like workflow when users fetch and install blobs.
31
32Hosting
33*******
34
35Blobs must be hosted on the Internet and managed by third-party infrastructure.
36Two potential examples are Git repositories and web servers managed by
37individual hardware vendors.
38
39The Zephyr Project does not host binary blobs in its Git repositories or
40anywhere else.
41
42Fetching blobs
43**************
44
45Blobs are fetched from official third-party sources by the :ref:`west blobs
46<west-blobs>` command.
47
48The blobs themselves must be specified in the :ref:`module.yml
49<modules-bin-blobs>` files included in separate Zephyr :ref:`module repositories
50<modules>` maintained by their respective vendors.  This means that in order to
51include a reference to a binary blob to the upstream Zephyr distribution, a
52module repository must exist first or be created as part of the submission
53process.
54
55Each blob which may be fetched must be individually identified in the
56corresponding :file:`module.yml` file. A specification for a blob must contain:
57
58- An abstract description of the blob itself
59- Version information
60- A reference to vendor-provided documentation
61- The blob’s :ref:`type <bin-blobs-types>`, which must be one of the allowed types
62- A checksum for the blob, which ``west blobs`` checks after downloading.
63  This is required for reproducibility and to allow bisecting issues as blobs
64  change using Git and west
65- License text applicable to the blob or a reference to such text, in SPDX
66  format
67
68See the :ref:`corresponding section <modules-bin-blobs>` for a more formal
69definition of the fields.
70
71The :ref:`west blobs <west-blobs>` command can be used to list metadata of
72available blobs and to fetch blobs from user-selected modules.
73
74The ``west blobs`` command only fetches and stores the binary blobs themselves.
75Any accompanying code, including interface header files for the blobs, must be
76present in the corresponding module repository.
77
78Tainting
79********
80
81Inclusion of binary blobs will taint the Zephyr build. The definition of
82tainting originates in the `Linux kernel
83<https://www.kernel.org/doc/html/latest/admin-guide/tainted-kernels.html>`_ and,
84in the context of Zephyr, a tainted image will be one that includes binary blobs
85in it.
86
87Tainting will be communicated to the user in the following manners:
88
89- One or more Kconfig options ``TAINT_BLOBS_*`` will be set to ``y``
90- The Zephyr build system, during its configuration phase, will issue a warning.
91  It will be possible to disable the warning using Kconfig
92- The ``west spdx`` command will include the tainted status in its output
93- The kernel's default fatal error handler will also explicitly print out the
94  kernel's tainted status
95
96.. _bin-blobs-types:
97
98Allowed types
99*************
100
101The following binary blob types are acceptable in Zephyr:
102
103* Precompiled libraries: Hardware enablement libraries, distributed in
104  precompiled binary form, typically for SoC peripherals. An example could be an
105  enablement library for a wireless peripheral
106* Firmware images: An image containing the executable code for a secondary
107  processor or CPU.  This can be full or partial (typically delta or patch data)
108  and is generally copied into RAM or flash memory by the main CPU. An example
109  could be the firmware for the core running a Bluetooth LE Controller
110* Miscellaneous binary data files. An example could be pre-trained neural
111  network model data
112
113Hardware agnostic features provided via a proprietary library are not
114acceptable. For example, a proprietary and hardware agnostic TCP/IP stack
115distributed as a static archive would be rejected.
116
117Note that just because a blob has an acceptable type does not imply that it will
118be unconditionally accepted by the project; any blob may be rejected for other
119reasons on a case by case basis (see library-specific requirements below).
120In case of disagreement, the TSC is the arbiter of whether a particular blob
121fits in one of the above types.
122
123Precompiled library-specific requirements
124*****************************************
125
126This section contains additional requirements specific to precompiled library
127blobs.
128
129Any person who wishes to submit a precompiled library must represent that it
130meets these requirements. The project may remove a blob from the upstream
131distribution if it is discovered that the blob fails to meet these requirements
132later on.
133
134Interface header files
135======================
136
137The precompiled library must be accompanied by one or more header files,
138distributed under a non-copyleft OSI approved license, that define the interface
139to the library.
140
141Allowed dependencies
142====================
143
144This section defines requirements related to external symbols that a library
145blob requires the build system to provide.
146
147* The blob must not depend on Zephyr APIs directly. In other words, it must have
148  been possible to build the binary without any Zephyr source code present at
149  all. This is required for loose coupling and maintainability, since Zephyr
150  APIs may change and such blobs cannot be modified by all project maintainers
151* Instead, if the code in the precompiled library requires functionality
152  provided by Zephyr (or an RTOS in general), an implementation of an OS
153  abstraction layer (aka porting layer) can be provided alongside the library.
154  The implementation of this OS abstraction layer must be in source code form,
155  released under an OSI approved license and documented using Doxygen
156
157Toolchain requirements
158======================
159
160Precompiled library blobs must be in a data format which is compatible with and
161can be linked by a toolchain supported by the Zephyr Project.  This is required
162for maintainability and usability. Use of such libraries may require special
163compiler and/or linker flags, however. For example, a porting layer may require
164special flags, or a static archive may require use of specific linker flags.
165
166Limited scope
167=============
168
169Allowing arbitrary library blobs carries a risk of degrading the degree to
170which the upstream Zephyr software distribution is open source. As an extreme
171example, a target with a zephyr kernel clock driver that is just a porting layer
172around a library blob would not be bootable with open source software.
173
174To mitigate this risk, the scope of upstream library blobs is limited. The
175project maintainers define an open source test suite that an upstream
176target must be able to pass using only open source software included in the
177mainline distribution and its modules. The open source test suite currently
178consists of:
179
180- :file:`samples/philosophers`
181- :file:`tests/kernel`
182
183The scope of this test suite may grow over time. The goal is to specify
184tests for a minimal feature set which must be supported via open source software
185for any target with upstream Zephyr support.
186
187At the discretion of the release team, the project may remove support for a
188hardware target if it cannot pass this test suite.
189
190Support and maintenance
191***********************
192
193The Zephyr Project is not expected to be responsible for the maintenance and
194support of contributed binary blobs. As a consequence, at the discretion of the
195Zephyr Project release team, and on a case-by-case basis:
196
197- GitHub issues reported on the zephyr repository tracker that require use of
198  blobs to reproduce may not be treated as bugs
199- Such issues may be closed as out of scope of the Zephyr project
200
201This does not imply that issues which require blobs to reproduce will be closed
202without investigation. For example, the issue may be exposing a bug in a Zephyr
203code path that is difficult or impossible to trigger without a blob. Project
204maintainers may accept and attempt to resolve such issues.
205
206However, some flexibility is required because project maintainers may not be
207able to determine if a given issue is due to a bug in Zephyr or the blob itself,
208may be unable to reproduce the bug due to lack of hardware, etc.
209
210Blobs must have designated maintainers that must be responsive to issue reports
211from users and provide updates to the blobs to address issues. At the discretion
212of the Zephyr Project release team, module revisions referencing blobs may be
213removed from :file:`zephyr/west.yml` at any time due to lack of responsiveness or
214support from their maintainers. This is required to maintain project control
215over bit-rot, security issues, etc.
216
217The submitter of the proposal to integrate a binary blob must commit to maintain
218the integration of such blob for the foreseeable future.
219
220Regarding Continuous Integration, binary blobs will **not** be fetched in the
221project's CI infrastructure that builds and optionally executes tests and samples
222to prevent regressions and issues from entering the codebase. This includes
223both CI ran when a new GitHub Pull Request is opened as well as any other
224regularly scheduled execution of the CI infrastructure.
225
226.. _blobs-process:
227
228Submission and review process
229*****************************
230
231For references to binary blobs to be included in the project, they must be
232reviewed and accepted by the Technical Steering Committee (TSC). This process is
233only required for new binary blobs, updates to binary blobs follow the
234:ref:`module update procedure <modules_changes>`.
235
236A request for integration with binary blobs must be made by creating a new
237issue in the Zephyr project issue tracking system on GitHub with details
238about the blobs and the functionality they provide to the project.
239
240Follow the steps below to begin the submission process:
241
242#. Make sure to read through the :ref:`bin-blobs` section in
243   detail, so that you are informed of the criteria used by the TSC in order to
244   approve or reject a request
245#. Use the :github:`New Binary Blobs Issue
246   <new?assignees=&labels=RFC&template=008_bin-blobs.md&title=>` to open an issue
247#. Fill out all required sections, making sure you provide enough detail for the
248   TSC to assess the merit of the request. Additionally you must also create a Pull
249   Request that demonstrates the integration of the binary blobs and then
250   link to it from the issue
251#. Wait for feedback from the TSC, respond to any additional questions added as
252   GitHub issue comments
253
254If, after consideration by the TSC, the submission of the binary blob(s) is
255approved, the submission process is complete and the binary blob(s) can be
256integrated.
257