yocto_uboot_env - zivku/MPU GitHub Wiki

Yocto修改uboot-env教學

前言

在進行本教學前,請先確認您已建立自己的 Yocto Layer。
若尚未建立,建議先參考以下相關教學,以便順利進行後續整合與開發:

教學

  1. 進入建立的layer中建立打包uboot-env的.inc檔 :
cd ~/git/sam9x60_yocto/meta-mycustom/
gedit recipes-bsp/u-boot/u-boot-envs-mycustom.inc

貼上以下內容:

# U-Boot Environments for AT91 boards

SRC_URI:append = " file://envs/"

ENV_FILENAME = "uboot.env"
ENV_FILEPATH = "${WORKDIR}/envs"

do_compile:append() {
    if [ -e "${ENV_FILEPATH}/${MACHINE}.txt" ]; then
        bbnote "Compile U-Boot environment for ${MACHINE}"
        ${B}/tools/mkenvimage ${MKENVIMAGE_EXTRA_ARGS} -s ${UBOOT_ENV_SIZE} ${ENV_FILEPATH}/${MACHINE}.txt -o ${ENV_FILENAME}
    else
        bbnote "No custom environment available for ${MACHINE}."
    fi
}

do_deploy:append() {
    if [ -e  ${B}/${ENV_FILENAME} ]; then
        install -Dm 0644 ${B}/${ENV_FILENAME} ${DEPLOYDIR}
    fi
}
  1. 建立.bbappend將uboot-env打包至燒錄映像 :
gedit recipes-bsp/u-boot/u-boot-mchp_2024.07.bbappend 

貼上以下內容:

FILESEXTRAPATHS:prepend := "${THISDIR}/files:"
require u-boot-envs-mycustom.inc
  1. 複製原廠的uboot-env.txt來做修改 :
cd ~/git/sam9x60_yocto/meta-mycustom/recipes-bsp/u-boot
mkdir files/envs/
cd files/envs/
cp ~/git/sam9x60_yocto/meta-atmel/recipes-bsp/u-boot/files/envs/sam9x60-curiosity.txt .
gedit sam9x60-curiosity.txt .
  1. 重新建構uboot-env :
cd ~/git/sam9x60_yocto/poky
source oe-init-build-env build-microchip 
MACHINE=sam9x60-curiosity bitbake -c clean u-boot-mchp
MACHINE=sam9x60-curiosity bitbake u-boot-mchp