Search code examples
linuxembedded-linuxyoctobsp

Overwriting Yocto Classes through meta-layer


Thanks for your time and support

I am planning to use swupdate for updates. So, I need to create an additional partition in which I need to store the recovery partition.

poky/meta/classes/image-live.bbclass

is the class which creates partitions and flashes the root file system. I have updated the above file to create one more partition and store the swupdate root filesystem.

How can I override this class in my own BSP layer, I don't want to touch poky source code..


Solution

  • Generally in Yocto there is no way to override .bbclass files like with .bb files (using .bbappend), to archive that it is needed to copy whole class file and move to another layer, I was able to manage that with this configuration:

    layer structure:

    $ tree ../meta-test/
    ../meta-test/
    ├── classes
    │   └── image-live.bbclass
    ├── conf
    │   └── layer.conf
    ├── COPYING.MIT
    ├── README
    └── recipes-example
        └── example.bb
    
    3 directories, 5 files
    

    content of example.bb recipe:

    $ cat ../meta-test/recipes-example/example/example.bb 
    LICENSE = "CLOSED"
    inherit image-live
    

    and finally really important thing*, the configuration file conf/bblayers.conf needs to be configured with this order meta-test/ above meta/ layer:

    $ tail -n6 conf/bblayers.conf 
    BBLAYERS ?= " \
      /home/user/poky/meta-test \
      /home/user/poky/meta \
      /home/user/poky/meta-poky \
      /home/user/poky/meta-yocto-bsp \
      "
    
    $ bitbake -e example -D | grep ^DEBUG:\\sInheriting\\s.*image-live.bbclass\\s\(from
    DEBUG: Inheriting /home/user/poky/meta-test/classes/image-live.bbclass (from /home/user/poky/meta-test/recipes-example/example/example.bb:3)
    

    *I don't know why bitbake layer priority doesn't work here, only modifying layers order in conf/bblayers.conf allows me to achieve the main goal:

    $ bitbake-layers show-layers
    NOTE: Starting bitbake server...
    layer                 path                                      priority
    ==========================================================================
    meta                  /home/user/poky/meta        5
    meta-test             /home/user/poky/meta-test   10
    meta-poky             /home/user/poky/meta-poky   5
    meta-yocto-bsp        /home/user/poky/meta-yocto-bsp  5
    

    layer meta-test/ below meta/ in conf/bblayers.conf:

    $ tail -n6 conf/bblayers.conf 
    BBLAYERS ?= " \
      /home/user/poky/meta \
      /home/user/poky/meta-test \
      /home/user/poky/meta-poky \
      /home/user/poky/meta-yocto-bsp \
      "    
    
    $ bitbake -e example -D | grep ^DEBUG:\\sInheriting\\s.*image-live.bbclass\\s\(from
    DEBUG: Inheriting /home/user/poky/meta/classes/image-live.bbclass (from /home/user/poky/meta-test/recipes-example/example/example.bb:3)