增加 Yocto for Raspberry pi 4 B 64 bit.

Signed-off-by: lion.chan <cy187lion@sina.com>
This commit is contained in:
lion.chan 2022-05-02 10:49:41 +08:00
parent cd3b7008e9
commit c7a1e7920a
2 changed files with 127 additions and 0 deletions

View File

View File

@ -0,0 +1,127 @@
# Yocto for Raspberry pi 4 B 64 bit
Using Yocto we can create custom Linux images for embedded devices. Here we are going to build a basic minimal image for raspberry pi 4b. With the small modification in the configuration file you can create the images for various versions of Raspberry pi.
[*Optional]
Full course on Yocto available @ Udemy
All the below commands are available as a shell script on <https://github.com/eclabs007/Yocto-Udemy.git>
## Prepare your Host Linux
Install the essential tools for your host PC.
```bash
sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat libsdl1.2-dev xterm python
```
## Setting up Yocto
1.Download Poky (reference implementation of yocto)
here we are downloading zeus version of Yocto.
```bash
git clone -b zeus git://git.yoctoproject.org/poky.git poky-zeus
```
navigate to poky folder
```bash
cd poky-zeus
```
Download meta-openembedded layer
```bash
git clone -b zeus git://git.openembedded.org/meta-openembedded
```
Download meta-Raspberry pi layer
```bash
git clone -b zeus git://git.yoctoproject.org/meta-raspberrypi
```
If you wish qt support download meta-qt5
```bash
git clone -b zeus https://github.com/meta-qt5/meta-qt5
```
Now you have all the necessary layers for building the Yocto
## Building your first image for Raspberry Pi
For Initializing Poky Variables You can use oe-init-build-env script
The script is responsible for the initialization of variables of the Poky build system, the script creates a directory structure in which it is very well divided:
build build directory
source assembly recipes source code
download directory for downloading program code (git databases, tar.gz archives)
```bash
source oe-init-build-env
```
It will take you to a build folder , optionally you can give build folder as an argument , **source oe-init-build-env** <build_folder_name>
In the build folder now you will be able to see one folder called conf which will be having the configuration files
```bash
conf/
├── bblayers.conf
├── local.conf
└── templateconf.cfg
```
Now edit conf/bblayers.conf with your favorite text editor as below
add layer meta-raspberrypi to your bblayer.cof
```bash
POKY_BBLAYERS_CONF_VERSION = "2"
BBPATH = "${TOPDIR}"
BBFILES ?= ""
BBLAYERS ?= " \
/home/eclabs/Yocto/poky-zeus/meta \
/home/eclabs/Yocto/poky-zeus/meta-poky \
/home/eclabs/Yocto/poky-zeus/meta-yocto-bsp \
/home/eclabs/Yocto/poky-zeus/meta-raspberrypi \
"
```
Modify conf/local.conf
```bash
MACHINE ??= “raspberrypi4-64”
```
you can build Yocto image for the different hardware versions of Raspberry pi by just changing this MACHINE variable.
```bash
raspberrypi0
raspberrypi0w
raspberrypi3
raspberrypi3-64
raspberrypi4
raspberrypi4-64 etc
```
For a building minimal image you can give the following command
bitbake core-image-minimal
it will create Kernel image ,RFS ,dtbs and boot codes for you. For the first time build will take some time( You are building a Linux from source).
After the build you can copy the images to SD card , Enjoy booting your Linux it will be available in tmp/deploy/images/raspberrypi4-64/ folder
```bash
sudo dd if=tmp/deploy/images/raspberrypi4-64/core-image-minimal-raspberrypi4-64.rpi-sdimg of=/dev/sdX bs=16M status=progress
```