Search code examples
raspberry-piembedded-linuxyoctobitbakeu-boot

Extra commands in raspberry pi u-boot using yocto


I want to add a custom command in raspberry pi u-boot using yocto I was able add custom in using make by following the answers provided here Implement custom u-boot command

Now I want add it using yocto in raspberry pi. But first I want to just add the timer command in u-boot which is present in misc.c in u-boot source where we just have to add the CONFIG_CMD_TIMER=y in the defconfig file

I tried the following setup till now

  1. cloned poky
  2. cloned meta-raspberrypi
  3. Enabled u-boot and uart in local.conf
  4. created a custom layer (custom layer added in bblayers.conf) to add the command config

Details of the recipe in the custom layer

  1. create the following directory structure
meta-custom-layer/recipes-bsp/u-boot/
  1. created a .bbappend file containing the following content
$ cat meta-custom-layer/recipes-bsp/u-boot/u-boot_%.bbappend
FILESEXTRAPATHS_prepend := "${THISDIR}:"
SRC_URI += " file://rpi_3_defconfig.patch;patchdir=${S}/configs "
  1. contents of the meta-custom-layer/recipes-bsp/u-boot/
$ ls -l meta-custom-layer/recipes-bsp/u-boot/
drwxr-xr-x 2 bhargav bhargav 4096 May 16 22:04 files
-rw-r--r-- 1 bhargav bhargav  107 May 16 22:04 u-boot_%.bbappend

$ cat meta-custom-layer/recipes-bsp/u-boot/files/rpi_3_defconfig.patch
CONFIG_CMD_TIMER=y
  1. while build u-boot getting the following error
$ bitbake u-boot
Loading cache: 100% |########################################################################################################################################################################| Time: 0:00:00
Loaded 2875 entries from dependency cache.
NOTE: Resolving any missing task queue dependencies

Build Configuration:
BB_VERSION           = "1.46.0"
BUILD_SYS            = "x86_64-linux"
NATIVELSBSTRING      = "universal"
TARGET_SYS           = "aarch64-poky-linux"
MACHINE              = "raspberrypi3-64"
DISTRO               = "poky"
DISTRO_VERSION       = "3.1"
TUNE_FEATURES        = "aarch64 cortexa53 crc"
TARGET_FPU           = ""
meta                 
meta-poky            
meta-yocto-bsp       = "master:2e11d97b6c95e89aa1f9d3603a966c94c442469e"
meta-raspberrypi     = "master:45ee64377bcc511380edf59191abc90c1ddb210e"
meta-shell           = "master:81fd3448f603a56409389247443439cad4fdaa67"
meta-oe              = "master:679bb4912613f3860e8527557602251e5e5f2c41"
meta-python2         = "master:2684086f91e7074324081196c8a5f9945d39650e"

Initialising tasks: 100% |###################################################################################################################################################################| Time: 0:00:00
Sstate summary: Wanted 16 Found 8 Missed 8 Current 135 (50% match, 94% complete)
NOTE: Executing Tasks
WARNING: u-boot-1_2020.04-r0 do_fetch: Failed to fetch URL file://rpi_3_defconfig.patch;patchdir=/home/bhargav/RPI3/Build/poky/build/tmp/work/raspberrypi3_64-poky-linux/u-boot/1_2020.04-r0/git/configs, attempting MIRRORS if available
ERROR: u-boot-1_2020.04-r0 do_fetch: Fetcher failure: Unable to find file file://rpi_3_defconfig.patch;patchdir=/home/bhargav/RPI3/Build/poky/build/tmp/work/raspberrypi3_64-poky-linux/u-boot/1_2020.04-r0/git/configs anywhere. The paths that were searched were:
    /home/bhargav/RPI3/Build/meta-shell/recipes-bsp/u-boot/poky
    /home/bhargav/RPI3/Build/poky/meta/recipes-bsp/u-boot/u-boot-2020.04/poky
    /home/bhargav/RPI3/Build/poky/meta/recipes-bsp/u-boot/u-boot/poky
    /home/bhargav/RPI3/Build/poky/meta/recipes-bsp/u-boot/files/poky
    /home/bhargav/RPI3/Build/meta-shell/recipes-bsp/u-boot/raspberrypi3-64
    /home/bhargav/RPI3/Build/poky/meta/recipes-bsp/u-boot/u-boot-2020.04/raspberrypi3-64
    /home/bhargav/RPI3/Build/poky/meta/recipes-bsp/u-boot/u-boot/raspberrypi3-64
    /home/bhargav/RPI3/Build/poky/meta/recipes-bsp/u-boot/files/raspberrypi3-64
    /home/bhargav/RPI3/Build/meta-shell/recipes-bsp/u-boot/raspberrypi3
    /home/bhargav/RPI3/Build/poky/meta/recipes-bsp/u-boot/u-boot-2020.04/raspberrypi3
    /home/bhargav/RPI3/Build/poky/meta/recipes-bsp/u-boot/u-boot/raspberrypi3
    /home/bhargav/RPI3/Build/poky/meta/recipes-bsp/u-boot/files/raspberrypi3
    /home/bhargav/RPI3/Build/meta-shell/recipes-bsp/u-boot/aarch64
    /home/bhargav/RPI3/Build/poky/meta/recipes-bsp/u-boot/u-boot-2020.04/aarch64
    /home/bhargav/RPI3/Build/poky/meta/recipes-bsp/u-boot/u-boot/aarch64
    /home/bhargav/RPI3/Build/poky/meta/recipes-bsp/u-boot/files/aarch64
    /home/bhargav/RPI3/Build/meta-shell/recipes-bsp/u-boot/rpi
    /home/bhargav/RPI3/Build/poky/meta/recipes-bsp/u-boot/u-boot-2020.04/rpi
    /home/bhargav/RPI3/Build/poky/meta/recipes-bsp/u-boot/u-boot/rpi
    /home/bhargav/RPI3/Build/poky/meta/recipes-bsp/u-boot/files/rpi
    /home/bhargav/RPI3/Build/meta-shell/recipes-bsp/u-boot/aarch64
    /home/bhargav/RPI3/Build/poky/meta/recipes-bsp/u-boot/u-boot-2020.04/aarch64
    /home/bhargav/RPI3/Build/poky/meta/recipes-bsp/u-boot/u-boot/aarch64
    /home/bhargav/RPI3/Build/poky/meta/recipes-bsp/u-boot/files/aarch64
    /home/bhargav/RPI3/Build/meta-shell/recipes-bsp/u-boot/
    /home/bhargav/RPI3/Build/poky/meta/recipes-bsp/u-boot/u-boot-2020.04/
    /home/bhargav/RPI3/Build/poky/meta/recipes-bsp/u-boot/u-boot/
    /home/bhargav/RPI3/Build/poky/meta/recipes-bsp/u-boot/files/
    /home/bhargav/RPI3/Build/poky/build/downloads
ERROR: u-boot-1_2020.04-r0 do_fetch: Fetcher failure for URL: 'file://rpi_3_defconfig.patch;patchdir=/home/bhargav/RPI3/Build/poky/build/tmp/work/raspberrypi3_64-poky-linux/u-boot/1_2020.04-r0/git/configs'. Unable to fetch URL from any source.
ERROR: Logfile of failure stored in: /home/bhargav/RPI3/Build/poky/build/tmp/work/raspberrypi3_64-poky-linux/u-boot/1_2020.04-r0/temp/log.do_fetch.13694
ERROR: Task (/home/bhargav/RPI3/Build/poky/meta/recipes-bsp/u-boot/u-boot_2020.04.bb:do_fetch) failed with exit code '1'
NOTE: Tasks Summary: Attempted 592 tasks of which 591 didn't need to be rerun and 1 failed.

Summary: 1 task failed:
  /home/bhargav/RPI3/Build/poky/meta/recipes-bsp/u-boot/u-boot_2020.04.bb:do_fetch
Summary: There was 1 WARNING message shown.
Summary: There were 2 ERROR messages shown, returning a non-zero exit code.

So what am I missing here ? I'm using a raspberry pi 3B+ .


Solution

  • After going through different rpi3 defconfig files found the correct file and created a patch for that file. The looks like this rpi-timer.patch

    diff --git a/configs/rpi_3_defconfig b/configs/rpi_3_defconfig
    index 9b281a4f15..053d36e244 100644
    --- a/configs/rpi_3_defconfig
    +++ b/configs/rpi_3_defconfig
    @@ -45,3 +45,4 @@ CONFIG_SYS_WHITE_ON_BLACK=y
     CONFIG_CONSOLE_SCROLL_LINES=10
     CONFIG_PHYS_TO_BUS=y
     CONFIG_OF_LIBFDT_OVERLAY=y
    +CONFIG_CMD_TIMER=y
    
    

    Now needed to apply the patch to the fetched source in yocto. Here is the .bbappend file recipes-bsp/u-boot/u-boot_%.bbappend for applying the patch

    FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
    SRC_URI += " file://rpi-timer.patch "