Skip to content

Commit

Permalink
Merge pull request #220 from erlingrj/zephyr
Browse files Browse the repository at this point in the history
Improved Zephyr docs
  • Loading branch information
lhstrh authored Jan 31, 2024
2 parents 378e542 + d436159 commit 874b88b
Showing 1 changed file with 43 additions and 1 deletion.
44 changes: 43 additions & 1 deletion docs/embedded/zephyr.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,21 @@ hi-resolution timing. These required configurations are stored in a file called
`prj_lf.conf` which `lfc` generates into the `src-gen` folder. You can provide
your own configurations through the following three files that `west lfc`
expects to find at the root of each app:
1. `prj.conf`, see [Seeting symbols in configuration files](https://docs.zephyrproject.org/latest/build/kconfig/setting.html#setting-symbols-in-configuration-files)
1. `prj.conf`, see [Seeting symbols in Configuration systems (Kconfig)](https://docs.zephyrproject.org/latest/build/kconfig/setting.html#setting-symbols-in-configuration-files)
2. `Kconfig`, see [Configuration system (Kconfig)](https://docs.zephyrproject.org/latest/build/kconfig/index.html)
3. `app.overlay`, see [Devicetree](https://docs.zephyrproject.org/latest/build/dts/index.html#devicetree)

The config options provided by you will be merged with those provided by `lfc`
and default settings for the board. It is very useful to inspect the final
version of the Kconfig and devicetree. After compilation, these are found in
`build/zephyr/.config` and `build/zephyr/zephyr.dts`. You can also inspect the
Kconfig options and devicetree by calling:
```
west build -t menuconfig
west build -t guiconfig
```
These are very powerful tools that give you a lot of insight into the application
you have just built.

# The `west lfc` command
The custom `lfc` west command has already been used in previous sections. It can
Expand Down Expand Up @@ -203,6 +214,31 @@ cd src-gen/LfcCentricZephyr
west build -t run
```

# C libraries
Zephyr has support for three C library implementations.
- Newlib (Default library used by LF)
- Picolibc (Supported by LF)
- Minimal libc (Not supported yet by LF)

For LF programs targeting Zephyr, Newlib is the default C library. You can
inspect the file `lf_prj.conf` which will be copied into the `src-gen` by `lfc`
when compiling a LF program with Zephyr as the target platform. Here you will find:"
```
CONFIG_NEWLIB_LIBC=y
CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y
```

This setting can be overridden in the user-written `prj.conf` file. If you wish
to use Picolibc instead put the following in your `prj.conf` file:
```
CONFIG_NEWLIB_LIBC=n
CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=n
CONFIG_PICOLIBC=y
```

With some additional work we could also get the LF runtime working with Minimal
libc. It should reduce the code size considerably.

# Debugging LF Zephyr programs using QEMU and GDB
In this section we will see how a LF program can be debugged while running in
QEMU emulation.
Expand Down Expand Up @@ -249,6 +285,12 @@ appear as if the `fast` target property was set to `true`.

## Troubleshooting

### ESP32
Several users have reported problems with using ESP32 and Newlib, which is the
default C library used by LF programs targeting Zephyr. A workaround is to use
Picolibc instead. See the chapter on "C libraries" for a description of how to
change C library implementation.

### Multiple Zephyr installations
If the following warning is shown when invoking `west lfc` or any other `west`
command:
Expand Down

0 comments on commit 874b88b

Please sign in to comment.