From c7a1e7920a5dd54a8f65b4c8b38cd770d991a93e Mon Sep 17 00:00:00 2001 From: "lion.chan" Date: Mon, 2 May 2022 10:49:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20Yocto=20for=20Raspberry=20?= =?UTF-8?q?pi=204=20B=2064=20bit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lion.chan --- Chapter8_SOC_与_Linux/8.21_Yocto.md | 0 .../8.22_使用_Yocto_构建树莓派_4B.md | 127 ++++++++++++++++++ 2 files changed, 127 insertions(+) create mode 100644 Chapter8_SOC_与_Linux/8.21_Yocto.md create mode 100644 Chapter8_SOC_与_Linux/8.22_使用_Yocto_构建树莓派_4B.md diff --git a/Chapter8_SOC_与_Linux/8.21_Yocto.md b/Chapter8_SOC_与_Linux/8.21_Yocto.md new file mode 100644 index 0000000..e69de29 diff --git a/Chapter8_SOC_与_Linux/8.22_使用_Yocto_构建树莓派_4B.md b/Chapter8_SOC_与_Linux/8.22_使用_Yocto_构建树莓派_4B.md new file mode 100644 index 0000000..e4c5ed7 --- /dev/null +++ b/Chapter8_SOC_与_Linux/8.22_使用_Yocto_构建树莓派_4B.md @@ -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 + +## 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** + +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 +```