cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Contributor
Contributor
497 Views
Registered: ‎11-19-2018

Build Two Different Images Within The Same PetaLinux Build Tree

I have a need to build two separate images within petalinux where one image is SD card based and the other is RAMFS based. The main difference in the images is what user packages are included and what init scripts are run. It would be nice not to have to duplicate image recipes for my custom packages and have everything included in the same build tree.

I know that this is possible within Yocto. You can create two different image recipes and call them with the bitbake command.

Does the PetaLinux wrapper support the ability to do this? How would I be able to make PetaLinux support the ability of building two images in the same build tree?

 

-Doug Bailey 

 

0 Kudos
7 Replies
Highlighted
Visitor
Visitor
260 Views
Registered: ‎10-14-2020

I have been looking for a way to do this as well. I need to build 4 images which use some of the same application packages but require different kernel configurations and images types.

So you would normally create you own image recipes and select which packages you want etc and require your base image, but how do you have different kernel fragments for different images? this is another problem I have to resolve if I use multiple images in the same build directory.

The petalinux  config tool generates every thing including the bblayers.conf and local.conf in the generated folder but there is no support for multiple images.

So you could either have a separate build tree copy for each target image and use petalinux-config each one separately  or use the petalinux tools to generate the initial configuration layer and files then just create a pure yocto build tree build and add the generated files as the start point with a normal yocto folder structure and never use petalinux-config again because you can just manually make changes or add kernel fragments.

I am not a yocto beginner but I not an expert by any means. 

In my petalinux setup I am using 2019.1 but plan to move to the 2020.1 version later.

This seems a common question but there never is an answer or article  that explains all aspects of building multiple image from one source tree

I have also noticed that petalinux uses shared local state information and download which would reduce build times if using multiple build trees which is part of the reason why you would want to do it in a single.

So if there is a petalinux yocto person that knows how to do this it would great have some pointers or suggestion on the best methods to do this.

Things that need to be include in the solution

- kernel configuration and the use of different fragments for different image targets

- how to handle device tree differences

- configuration of  a custom image use petalinux-config if possible 

 

0 Kudos
Highlighted
Contributor
Contributor
250 Views
Registered: ‎11-19-2018

I ended up building multiple yocto layers that I pull into the petalinux configurations for each of the images.

meta-mylayer -+-- meta-image1 -- recipes-image1
              |
              +-- meta-image2 -- recipes-image2
              |
              +-- meta-image3 -- recipes-image3
              |
              +-recipes-common



The advantage of doing my own layers is that they are text so diff out nicely in my git repo. They take advantages of bbappends to prevent me from replicating items in my layers. They extract my code from the painful exercise of upgrading petalinux builds.

I do create 3 BSP files that store which yocto layers to use for each of the images. In this case, the petalinux configuration for the first image specifies the location of meta-mylayer as yocto user layer 0 and meta-image1 as yocto user layer 1. The second and third images are set similarly.

This does create 3 builds which is extremely wasteful and time consuming. Unfortunately, I did not see an easy way around this.

0 Kudos
Highlighted
Visitor
Visitor
231 Views
Registered: ‎10-14-2020

Thanks for your reply

When you say "I do create 3 BSP files that store which yocto layers to use for each of the images" 

Are these the 3 files used by petalinux-config as it generates the bblayers.conf file for each project tree?

I would like to have the files that are used to generate the configuration settings under version control so I can reproduce it all from scratch.

The only files that I can find that contains a reference to my layer is under project-spec/conf /conf  is that the file are you referring to?

In each your image layers do you have your image append files to modify your image content  by appending to the generated 

petalinux-user-image.bb image file ?

Thanks

0 Kudos
Highlighted
Contributor
Contributor
214 Views
Registered: ‎11-19-2018

Here is my yocto layers that are a little more fleshed out:  

meta-mylayer
├── bsps
│   ├── petalinux-image1-2018.3.bsp
│   ├── petalinux-image2-2018.3.bsp
│   └── petalinux-image3-2018.3.bsp
├── conf
│   └── layer.conf
├── hdf
│   └── MarsXU3_wrapper.hdf
├── meta-image1
│   ├── conf
│   │   └── layer.conf
│   ├── recipes-apps
│   │   └── recovery
│   │       ├── files
│   │       │   ├── recoveryinit.sh
│   │       │   └── recovery-rootfs
│   │       └── recovery_1.0.bb
│   └── recipes-core
│       └── images
│           └── petalinux-user-image.bbappend
├── meta-image2
│   ├── conf
│   │   └── layer.conf
│   ├── recipes-apps
│   └── recipes-core
│       └── images
│           └── petalinux-user-image.bbappend
├── meta-image3
│   ├── conf
│   │   └── layer.conf
│   ├── recipes-apps
│   │   └── nfspublish
│   │       ├── files
│   │       │   ├── exports
│   │       │   └── nfsmountpoint
│   │       │       └── nfsinfo.txt
│   │       └── nfspublish_1.0.bb
│   ├── recipes-bsp
│   │   └── u-boot
│   │       ├── files
│   │       │   └── platform-top.h
│   │       └── u-boot-xlnx_%.bbappend
│   ├── recipes-core
│   │   └── images
│   │       └── petalinux-user-image.bbappend
│   └── recipes-kernel
│       └── linux
│           ├── files
│           │   └── NFS-server.cfg
│           └── linux-xlnx_%.bbappend
├── README
├── recipes-apps
│   ├── emmc-prep
│   │   ├── emmc-prep_1.0.bb
│   │   ├── files
│   │   │   ├── emmcpartition
│   │   │   ├── emmcprep
│   │   │   ├── emmcprogram
│   │   │   ├── emmcumount
│   │   │   └── SDprogram
│   │   └── README
│   └── miscscripts
│       ├── files
│       │   └── gpio_manipulate.py
│       └── miscscripts_1.0.bb
├── recipes-bsp
│   └── device-tree
│       ├── device-tree.bbappend
│       └── files
│           └── system-user.dtsi
├── recipes-kernel
│   └── linux
│       ├── files
│       │   ├── PPP-serial.cfg
│       │   ├── SD-writeprotectdisable.patch
│       │   ├── unused-purge.cfg
│       │   └── USB-serial.cfg
│       └── linux-xlnx_%.bbappend
└── recipes-libs

 

The BSP files are generated with the petalinux-package command.  

petalinux-package --bsp --clean --output <BSP file Name> -p .   --force

 

The steps for reconstituting the projects is: 

petalinux-create -t project -s meta-mylayer/bsps/petalinux-image1-2018.3.bsp

Then I go into the resulting petalinux project directory and run petalinux-config and then petalinux-build. 

 

Repeat that for all 3 images. 

 

 

 

 

 

Highlighted
Visitor
Visitor
199 Views
Registered: ‎10-14-2020

Thanks that makes sense now. I did not understand the BSP packaging part so that feature is very useful.  

The second half of your meta-mylayer has some recipes in it. Are these common to all images?

So when you include meta-mylayer its layer.conf only includes folders that match something like /recipes-*

Therefore excluding the other image layers and recipes from being included as well which would be bad.

Thanks for sharing you have helped a lot 

0 Kudos
Highlighted
Moderator
Moderator
184 Views
Registered: ‎04-24-2017

Hi @tscbailey ,

In petalinux you can't build multiple image and its not a supported flow.

Yes in yocto you can do and below is the steps.

  1. I would suggest to create a common distribution image inclusion file (similar to https://github.com/Xilinx/meta-petalinux/blob/master/recipes-core/images/petalinux-image-common.inc)
  2. Then you can add distribution image recipes for SD and INITRAMFS(https://github.com/Xilinx/meta-petalinux/blob/master/recipes-core/images/petalinux-initramfs-image.bb ) build two image recipes using bitbake.
Thanks,
Sandeep
PetaLinux Yocto | Embedded SW Support

---------------------------------------------------------------------------
Don’t forget to Reply, Kudo, and Accept as Solution.
---------------------------------------------------------------------------
0 Kudos
Highlighted
Visitor
Visitor
163 Views
Registered: ‎10-14-2020

thanks that confirms it.

I have in the past built multiple images using separate image recipes as you suggest and that works ok  when you want to have different packages and images types but how would we build images with different kernel configurations or device trees. 

How would you suggest this could be achieved in yocto?

Would we create a kernel recipe with a unique name for each configuration which adds different fragment .cfg files and in that recipe require the linux-xlnx recipe for the base configuration and add this to the image install in our image recipe.  

0 Kudos