Skip to content

Commit cf52cf7

Browse files
Update README.md
1 parent 23df6b6 commit cf52cf7

File tree

2 files changed

+113
-50
lines changed

2 files changed

+113
-50
lines changed

Diff for: README.md

+113-50
Original file line numberDiff line numberDiff line change
@@ -1,107 +1,170 @@
1-
# Arduino Core for Zephyr BETA
1+
> [!IMPORTANT]
2+
> This core is in **BETA**. 🧪
3+
> Features may change, and bugs may be present. Use for testing only and provide feedback to help us improve.
24
3-
This repository contains the official implementation of **Arduino Core** for Zephyr based board.
5+
# 🚧 Arduino Core for Zephyr
46

5-
Easily install the core and its toolchains via Board Manager using this URL: https://downloads.arduino.cc/packages/package_zephyr_index.json
7+
This repository contains the official implementation of **Arduino Core** for Zephyr RTOS based board.
68

7-
## Theory of operation
9+
## 🧐 What is Zephyr?
810

9-
Unlike every other Arduino implementation (where the final compilation step is a standalone binary, eventually loaded by a bootloader), this one creates a freestanding elf file that can be dynamically loaded by a static (precompiled) Zephyr firmware.
11+
[Zephyr RTOS](https://zephyrproject.org/) is an open-source, real-time operating system designed for low-power, resource-constrained devices. It's modular, scalable, and supports multiple architectures.
1012

11-
The most important parts of this project are:
13+
![Zephyr RTOS Logo](doc/zephyr_logo.jpg)
14+
15+
## ⚙️ Installation
16+
17+
Install the core and its toolchains via Board Manager:
18+
* Download and install the latest [Arduino IDE](https://www.arduino.cc/en/software)
19+
* Open the *'Settings / Preferences'* window
20+
* Open the *'Boards Manager'* from the side menu and search for *'Zephyr'*
21+
* If it does not show up - enter `https://downloads.arduino.cc/packages/package_zephyr_index.json` in the *'Additional Boards Manager URLs'* field (add a comma in between if you have multiple URLs)
22+
* Install the `Arduino Zephyr Boards` platform
23+
24+
## 🧢 Under the hood
25+
26+
Unlike traditional Arduino implementations, where the final output is a standalone binary loaded by a bootloader, this core generates a freestanding `elf` file. This file can be dynamically loaded by a precompiled Zephyr firmware, referred to as the `loader`.
27+
28+
For the end user, installing the `loader` is easy. Simply run `Burn Bootloader` option from the IDE/CLI while the board is in bootloader mode (by double-clicking the RESET button). Note that due to limitations in the Arduino IDE, you may need to select a `bogus` programmer from the `Programmers` menu.
29+
30+
To load the first sketch, the board must also be manually placed into bootloader mode. After this initial setup, the standard "autoload" method will take over for future sketches.
31+
32+
To ensure flexibility, the `loader` project is designed to be generic. Any necessary modifications for specific boards should be made in the corresponding `DTS overlay` or a special `fixup` file, using appropriate guards to maintain stability.
33+
34+
The behavior of the `loader` can be adjusted through the `Mode` menu:
35+
- `Standard`: The sketch is loaded automatically.
36+
- `Debug`: The user must type `sketch` in Zephyr's shell, which is accessible via the default Serial.
37+
38+
The most important components of this project are:
1239

1340
* [Zephyr based loader](/loader)
1441
* [LLEXT](https://docs.zephyrproject.org/latest/services/llext/index.html)
1542
* [Actual core](/cores/arduino) with [variants](/variants) and the usual `{platform,boards}.txt`
1643
* [ArduinoCore-API](https://github.com/arduino/ArduinoCore-API)
1744
* [post_build_tool](/extra/post_build_tool)
1845

19-
The `loader` project should be kept generic and any modification required for a given board should be added to its dts overlay or a special `fixup` file (with the proper guards).
20-
The loader changes its behaviour based on the `Mode` menu.
21-
`Standard` means that the sketch is loaded automatically, while `Debug` requires the user to type `sketch` in Zephyr's shell (exposed over the default UART).
22-
23-
For the end user, installing the `loader` only requires running `Burn Bootloader` while the board is in bootloader mode (double clicking the RESET button should be do the trick). Due to Arduino IDE limitiations, you must select a bogus programmer from `Programmers` menu.
46+
## 🛠️ Setup the environment
2447

25-
Loading the first sketch also requires the board to be placed forcefully in bootloader mode. From then on, the usual "autoload" method will kick in.
48+
In this section, we’ll guide you through setting up your environment to work with the core, making it easy to compile and upload your sketches to compatible boards.
2649

27-
## Setup the environment
50+
Shell scripts are available to simplify the installation process (Windows is not supported at the moment 😔).
2851

29-
We provide some shell scripts to ease installation (Windows not supported ATM)
30-
On a new terminal, run
31-
```
52+
### Clone the repository
53+
```bash
3254
mkdir my_new_zephyr_folder && cd my_new_zephyr_folder
3355
git clone https://github.com/arduino/ArduinoCore-zephyr
56+
```
57+
### Pre-requirements
58+
Before running the installation script, ensure that `python3` and `pip` are installed on your system. The script will automatically install `west` and manage the necessary dependencies.
59+
60+
### Run the ```bootstrap``` script
61+
```bash
3462
cd ArduinoCore-zephyr
3563
./extra/bootstrap.sh
3664
```
65+
### Install the Zephyr SDK
66+
Download and install the Zephyr SDK for your OS from [here](https://github.com/zephyrproject-rtos/sdk-ng/releases/tag/v0.16.8).
3767

38-
Then you need to download and install the Zephyr SDK for your OS from https://github.com/zephyrproject-rtos/sdk-ng/releases/tag/v0.16.8
68+
> [!NOTE]
69+
> This core is validated for version v0.16.8. Compatibility with later versions has not been tested yet.
3970
40-
To build a loader, run
41-
```
71+
### Build the Loader
72+
73+
To build a loader, run the following commands:
74+
```bash
4275
export ZEPHYR_SDK_INSTALL_DIR=$folder_where_you_installed_the_sdk
4376
./extra/build.sh $zephyr_board_name $arduino_variant_board_name
44-
# eg: ./extra/build.sh arduino_portenta_h7//m7 arduino_portenta_h7
4577
```
78+
Replace `$zephyr_board_name` and `$arduino_variant_board_name` with the appropriate names for your board.
79+
80+
Example for Arduino Portenta H7:
81+
```bash
82+
./extra/build.sh arduino_portenta_h7//m7 arduino_portenta_h7
83+
```
84+
4685
The firmwares will be copied to [firmwares](/firmwares) folder.
4786

48-
If the board is fully supported by Zephyr, they can also be directly falshed with `west flash`
87+
### Flash the Loader
88+
89+
If the board is fully supported by Zephyr, you can flash the firmware directly onto the board using the following command:
90+
```bash
91+
west flash
92+
```
4993

50-
## Use the core in Arduino environment
94+
## 🖥️ Using the Core in Arduino IDE/CLI
5195

52-
After runnign the `bootstrap` script, you should be able to symlink the core to `$sketchbook/hardware/arduino-git/zephyr` and it will appear in the IDE/CLI. Boards FQBN will then become `arduino-git:zephyr:name_from_boards_txt`
96+
After running the `bootstrap` script, you can symlink the core to `$sketchbook/hardware/arduino-git/zephyr`. Once linked, it will appear in the IDE/CLI, and the board's Fully Qualified Board Name (FQBN) will be formatted as `arduino-git:zephyr:name_from_boards_txt`.
5397

54-
## Toubleshooting
98+
## 🔧 Troubleshooting
5599

56-
**Q: My Sketch doesn't start (Serial doen't appear)**
100+
### Common Issues
57101

58-
**A:** Connect a USB-to-UART adapter to the default UART (eg. TX0/RX0 on Giga, TX,RX on Nano) and read the error message
102+
#### **Q: My Sketch doesn't start (Serial doesn't appear)**
103+
**A:** Connect a USB-to-UART adapter to the default UART (eg. TX0/RX0 on Giga, TX/RX on Nano) and read the error message (with the sketch compiled in `Default` mode). If you don't own a USB-to-UART adapter, compile the sketch in `Debug` mode; this will force the shell to wait until you open the Serial Monitor. Then, run `sketch` command and *probably* you'll be able to read the error (if generated by `llext`). For OS crashes, the USB-to-UART adapter is the only way to collect the crash.
59104

60-
**Q: I did it and I get a `<err> llext: Undefined symbol with no entry in symbol table ...`**
105+
---
61106

107+
#### **Q: I did it and I get the error: `<err> llext: Undefined symbol with no entry in symbol table ...`**
62108
**A:** This means you are trying to use a Zephyr function which has not yet been exported. Open `llext_exports.c`, add the function you need and recompile/upload the loader.
63109

64-
**Q: I want to use a Zephyr subsystem which is not compiled in**
110+
---
65111

112+
#### **Q: I want to use a Zephyr subsystem which is not compiled in**
66113
**A:** Open the `.conf` file for your board, add the required `CONFIG_`, recompile/upload the loader.
67114

68-
**Q: I get an OS crash**
115+
---
116+
117+
#### **Q: I get an OS crash, like `<err> os: ***** USAGE FAULT *****`**
118+
**A:** This is usually due to a buffer overflow or coding error in the user's own code. However, since the project is still in beta 🧪, a [good bug report](#bug-reporting) could help identify any issues in our code.
119+
120+
---
121+
122+
#### **Q: I get an out of memory error**
123+
**A:** Since collecting bug reports is very important at this time, we are keeping Zephyr's shell enabled to allow loading a full sketch (which requires a large stack). Adjust your board's `.conf` file to reduce the stack size if your platform doesn't have enough RAM.
69124

70-
**A:** This is usally do to some buffer overflow/coding error in the user's own code. However, since the project is still in Beta, a [good bug report](#bug-reporting) could help identifying an issue in our code.
125+
## 📚 Libraries
71126

72-
**Q: I get an out of memory error**
127+
### Included with the core: ###
73128

74-
**A:** Since at this point in time collecting bug reports is very important, we are keeping Zephyr's shell enabled and able to load a full sketch (so its stack is very big). Tune your board's `.conf` to reduce that size if your platform down't have enough RAM
129+
### Separately supplied: ###
130+
- **ArduinoBLE**: This library is enabled only for the Arduino Nano 33 BLE. Please use [this branch](https://github.com/facchinm/ArduinoBLE/tree/zephyr_hci) to test it.
75131

76-
## Bug Reporting
132+
## 🚀 Adding a new target
133+
134+
To add a new board that is already supported by mainline Zephyr, follow these steps:
135+
136+
* Create the `DTS overlay` and `.conf` files in the [loader](/loader/boards) directory.
137+
The overlay must include:
138+
* A flash partition called `user_sketch`, tipically located near the end of the flash.
139+
* A `zephyr,user` section containing the description for GPIOs, Analog, UART, SPI and I2C devices. Feel free to leave some fields empty in case Zephyr support is missing. This will result in some APIs not being available at runtime (eg. `analogWrite` if PWM section is empty).
140+
* Build the Loader: run `./extra.build.sh $your_board $your_board` and start debugging the errors. :grin:
141+
* Update the `boards.txt`: add an entry for your board, manually filling the required fields.
142+
* Implement touch support: if your board supports the `1200bps touch` method, implement `_on_1200_bps` in a file located inside the `variant/your_board` folder.
143+
* ⏳ Temporary steps
144+
* Create `includes.txt` based on `llext-edk/Makefile.cflags`, taking inspiration for other variants.
145+
* Amend `your_board.compiler.zephyr.*` with information from `llext-edk/Makefile.cflags`.
146+
147+
## 🐛 Bug Reporting
77148

78149
To report a bug, open the [issues](/issues) and follow the instructions. Any issue opened without the needed information will be discarded.
79150

80-
## TODO
151+
## 🙌 Contributions
152+
153+
Contributions are always welcome. The preferred way to receive code contribution is by submitting a [Pull Request](/pull).
154+
155+
## 📌 Upcoming features
81156

82157
- [ ] Unify overlay in [loader](/loader/boards) with the one provided in [variant](/variant) for interoperability with GSoC project
83158
- [ ] Autogenerate `defines.txt`, `includes.txt`, `cflags.txt` from `llext-edk` output
84159
- [ ] Network: support UDP and TLS
85160
- [ ] USB: switch to USB_DEVICE_STACK_NEXT to support PluggableUSB
86161
- [ ] Relocate RODATA in flash to accomodate sketches with large assets
87162
- [ ] Provide better error reporting for failed llext operations
88-
- [ ] Replace [llext_exports.c](/loader/llext_exports.c) with proper symbols generation (via inclues)
163+
- [ ] Replace [llext_exports.c](/loader/llext_exports.c) with proper symbols generation (via includes)
89164
- [ ] Provide better usability for `Debug` builds (eg. shell over USB)
90165
- [ ] Fix corner cases with `std::` includes (like `<iterator>`)
166+
- [ ] Get rid of all warnings
91167

92-
## ADVANCED: Add a new target board
93-
94-
* To add a new board (already supported by mainline Zephyr), you'll first need to create its `dts overlay` and `.conf` in [loader](/loader/boards).
95-
The overlay MUST contains:
96-
* A flash partition called `user_sketch`, usually near the end of the flash
97-
* A `zephyr,user` section containing the description for GPIOs, Analog, UART, SPI and I2C devices. Feel free to leave some fields empty in case Zephyr support is missing. This will result in some APIs not being available at runtime (eg. `analogWrite` if PWM section is empty)
98-
* Run `./extra.build.sh $your_board $your_board` and start debugging the errors :grin:
99-
* Add an entry in `boards.txt` for your board, manually filling the required fields
100-
* If your boards supports `1200pbs touch` method, implement `_on_1200_bps` in a file inside `variant/your_board` folder
101-
* Temporary: create `includes.txt` based on `llext-edk/Makefile.cflags`, taking inspiration for other variants
102-
* Temporary: amend `your_board.compiler.zephyr.*` with information from `llext-edk/Makefile.cflags`
103-
* Profit!
104-
105-
## Acknowledgments
168+
## 🌟 Acknowledgments
106169

107-
This effort would have been very hard without the [GSoC project](/README.gsoc.md) and in general the Zephyr community.
170+
This effort would have been very hard without the [GSoC project](/README.gsoc.md) and the Zephyr community.

Diff for: doc/zephyr_logo.jpg

32.8 KB
Loading

0 commit comments

Comments
 (0)