Featured image of post yocto 筆記

yocto 筆記

紀錄build-yocto

Yocto 使用紀錄

什麼是 Yocto

  • Yocto 是一個 用來建立客製化 Linux 發行版 的開源專案。它不是一個 Linux 發行版本身,而是一套 工具與框架,幫助開發者針對特定硬體平台(例如嵌入式系統)生成完整的 Linux 系統映像檔(image)。
  • Yocto是一個開源專案,它提供了一套工具和方法來為嵌入式系統建立客製化、輕量級的Linux發行版。 它包含核心元件如負責處理任務和建構的BitBake,以及為OpenEmbedded系統提供基礎的OpenEmbedded-Core層。 透過Yocto,開發者可以選擇軟體組件、調整配置,並建立出適合特定硬體(如物聯網設備、AI邊緣設備等)的Linux映像檔。

Yocot 歷史

  • Yocto計劃,一個自由軟體專案計劃,由Linux基金會於2010年宣布,這個計劃的目標在於創造出可以提供嵌入式linux發行版的軟體工具,以改善軟體發展流程。2011年3月,這個計劃與OpenEmbedded計劃結合,以OpenEmbedded-Core計劃作為計劃的另一個名稱。

安裝與構建最小映像步驟

1. 安裝依賴套件

  • Ubuntu / Debian requirement
1
sudo apt-get install build-essential chrpath cpio debianutils diffstat file gawk gcc git iputils-ping libacl1 liblz4-tool locales python3 python3-git python3-jinja2 python3-pexpect python3-pip python3-subunit socat texinfo unzip wget xz-utils zstd

2. Clone Poky

  • Use Git to Clone Poky
1
git clone git://git.yoctoproject.org/poky
  • 需要確保已啟用地區設定:en_US.UTF-8
1
2
locale --all-locales | grep en_US.utf8
sudo dpkg-reconfigure locales

3. 指定 branch,開始構建最小 image 並使用 qemu 模擬

1
2
3
4
5
6
7
8
cd poky
git branch -a
git checkout -t origin/walnascar -b my-walnascar
git pull
source oe-init-build-env x64

bitbake core-image-minimal
runqemu qemux86-64 nographic
  • 接著使用 root 登入,poweroff退出 qemu

為 image 增加實用的套件

  • meta-oe list 包含linux 常用的一些工具像是 iproute2 vim nano pciutils
1
2
3
4
cd poky
git clone git://git.openembedded.org/meta-openembedded
git checkout -t origin/walnascar -b my-walnascar
git pull
  • bblayers.conf增加
1
meta-openembedded/meta-oe
  • local.conf 增加
1
IMAGE_INSTALL:append = " htop iproute2 vim nano pciutils"

增加 coreutils

  • local.conf 增加
1
IMAGE_INSTALL:append = " coreutils"

增加 util-linux

  • local.conf 增加
1
IMAGE_INSTALL:append = " util-linux"

增加 man-db、man-page

  • local.conf 增加
1
IMAGE_INSTALL:append = " man-db man-page"

增加 C tool

  • packagegroup-core-buildessential類似於 Debian/Ubuntu 系統中的 build-essential 套件,包含 gcc, g++, make, cpp, libgcc, libstdc++, kernel-dev, pkgconfig
  • local.conf 增加
1
IMAGE_INSTALL:append = " packagegroup-core-buildessential gdb"

增加 lsb-release

  • local.conf 增加
1
IMAGE_INSTALL:append = " lsb-release"

Creat ISO

  • local.conf 增加
1
2
3
4
5
IMAGE_INSTALL:append = " grub-efi syslinux"
IMAGE_FSTYPES:append = " wic iso"
WIC_CREATE_ISO = "1"
IMAGE_BOOT_FILES += "efi/boot/*"
IMAGE_FSTYPES += "iso"
  • bblayers.conf增加
1
meta-yocto-bsp
  • 用 qemu 執行 iso
1
2
3
4
5
qemu-img create -f qcow2 ./HD.qcow2 4G

qemu-system-x86_64 -cpu EPYC -smp 2 -m 2048 -device virtio-scsi-pci,id=scsi0 -device scsi-hd,bus=scsi0.0,drive=main_disk -drive id=main_disk,file=./HD.qcow2,if=none,format=qcow2 -cdrom ./tmp/deploy/images/genericx86-64/boom-image-genericx86-64.rootfs.iso -net nic,model=virtio -net user -nographic

qemu-system-x86_64 -cpu EPYC -smp 2 -m 2048 -device virtio-scsi-pci,id=scsi0 -device scsi-hd,bus=scsi0.0,drive=main_disk -drive id=main_disk,file=./HD.qcow2,if=none,format=qcow2 -net nic,model=virtio -net user -nographic
  • 選擇 Serial console install
  • 出現 Please select an install target or press n to exit ( sda ): 時,輸入 sda 後按 Enter
網站穩定運行
使用 Hugo 建立 ,   主題 StackJimmy 設計