README: update build guide with bitbake-setup

update build guide to use bitbake-setup.

also drop the reference to poky

Signed-off-by: Lee Chee Yang <chee.yang.lee@intel.com>
This commit is contained in:
cheeyanglee
2025-12-24 14:46:35 +08:00
committed by Lee Chee Yang
parent 3097b198fe
commit 95f464af4a

125
README.md
View File

@@ -6,75 +6,110 @@ This layer enables building Zephyr using Yocto Project.
This layer depends on: This layer depends on:
URI: https://git.yoctoproject.org/poky URI: https://git.openembedded.org/bitbake
layers: meta branch: master
branch: master
URI: https://git.openembedded.org/meta-openembedded URI: https://git.openembedded.org/openembedded-core
layers: meta-oe, meta-python layers: meta
branch: master branch: master
URI: https://git.openembedded.org/meta-openembedded
layers: meta-oe, meta-python
branch: master
## Building Zephyr Images via bitbake recipes ## Building Zephyr Images via bitbake recipes
More detailed and up-to-date information can be found here: ### Quick Build
https://wiki.yoctoproject.org/wiki/TipsAndTricks/BuildingZephyrImages Ensure your build host meets the
[Yocto Project system requirements](https://docs.yoctoproject.org/ref-manual/system-requirements.html)
and follow the
[Quick Build setup guide](https://docs.yoctoproject.org/brief-yoctoprojectqs/index.html#yocto-project-quick-build)
to setup the host enviroment.
> **Pre-requisites:** Clone the following repos:
1. Refer [Yocto Project Quick Build]( https://docs.yoctoproject.org/dev/singleindex.html#yocto-project-quick-build) documentation.
2. Clone and add following layers to BBLAYERS - bitbake
* meta-openembedded/meta-oe - meta-zephyr
* meta-openembedded/meta-python
* meta-zephyr-core ```console
* meta-zephyr-bsp git clone https://git.openembedded.org/bitbake
``` git clone https://git.yoctoproject.org/meta-zephyr
$ mkdir sources
$ git clone -b <release-branch> https://git.yoctoproject.org/poky
$ git clone -b <branch-name> https://git.openembedded.org/meta-openembedded
$ git clone -b <branch-name> https://git.yoctoproject.org/meta-zephyr
$ source poky/oe-init-build-env
$ bitbake-layers add-layer ../meta-openembedded/meta-oe
$ bitbake-layers add-layer ../meta-openembedded/meta-python
$ bitbake-layers add-layer ../meta-zephyr/meta-zephyr-core
$ bitbake-layers add-layer ../meta-zephyr/meta-zephyr-bsp
``` ```
### Building and Running Zephyr Samples Initialize default build configuration with bitbake-setup:
You can build Zephyr samples. There are several sample recipes. ```console
./bitbake/bin/bitbake-setup init --non-interactive \
To use the Yocto toolchain, modify local conf by adding: ./meta-zephyr/zephyr-master.conf.json \
``` zephyr-default distro/zephy machine/qemu-x86
DISTRO = "zephyr"
``` ```
To use the Zephyr pre-built toolchain, modify local conf by adding: Alternatively, run bitbake-setup with interactive mode to choose for
``` different configuration:
ZEPHYR_TOOLCHAIN_VARIANT = "zephyr"
```console
./bitbake/bin/bitbake-setup init ./meta-zephyr/zephyr-master.conf.json
``` ```
For example, to build the Zephyr "philosophers" sample: Initialize build environment
```console
source ./bitbake-builds/zephyr-master/build/init-build-env
``` ```
$ MACHINE=qemu-x86 bitbake zephyr-philosophers
build the Zephyr "helloworld" sample:
```console
bitbake zephyr-helloworld
```
### Building and Running other Zephyr Samples
You can build other Zephyr samples. There are several sample recipes
[available here](https://git.yoctoproject.org/meta-zephyr/tree/meta-zephyr-core/recipes-kernel/zephyr-kernel).
For example, to build the
[Zephyr "philosophers" sample](https://git.yoctoproject.org/meta-zephyr/tree/meta-zephyr-core/recipes-kernel/zephyr-kernel/zephyr-philosophers.bb):
```console
bitbake zephyr-philosophers
``` ```
You can then run the created "philosophers" image in qemu: You can then run the created "philosophers" image in qemu:
```
$ runqemu qemu-x86 ```console
runqemu
``` ```
The same sample, for ARM image: The same sample can be built for other machines/boards, for example ARM Cortex-M3:
```
$ MACHINE=qemu-cortex-m3 bitbake zephyr-philosophers ```console
$ runqemu qemu-cortex-m3 bitbake-config-build enable-fragment machine/qemu-cortex-m3
bitbake zephyr-philosophers
runqemu
``` ```
The same sample, for Nios2 image: Alternatively, you can use the MACHINE variable to define the target machine,
you will need to disable the machine fragment to prevent conflict:
```console
bitbake-config-build disable-fragment machine/qemu-x86
MACHINE=qemu-cortex-m3 bitbake zephyr-philosophers
runqemu qemu-cortex-m3
``` ```
$ MACHINE=qemu-nios2 bitbake zephyr-philosophers
$ runqemu qemu-nios2 The default configuration (with `zephyr` DISTRO) uses the Yocto Project toolchain
to compile Zephyr applications. To use the Zephyr pre-built toolchain instead,
modify `local.conf` by adding:
``` ```
ZEPHYR_TOOLCHAIN_VARIANT = "zephyr"
```
Other Tips and Tricks for building zephyr image can be found
[here](https://wiki.yoctoproject.org/wiki/TipsAndTricks/BuildingZephyrImages).
### Flashing ### Flashing