I have recently used yocto to compile a custom OS and it resulted in the constituent parts of the ext4 file structure, the hardware dtb and the uboot image.
The device I am trying to replace the firmware on is android based and has its own windows based application to replace the firmware. The software needs a singular img file.
Is it possible to compile one from the 3 files listed above?
I have been looking at mkimage but to no joy. I don't know how to use the -d script possibly. Yocto produces a file that looks like it would work with -d argument but doesn't seem to.
I come from OpenWRT where it produced a single bin image which could be mtd'd (the verb to use mtd).
Thoughts?
My build configuration is:
Build Configuration:
BB_VERSION = "1.37.0"
BUILD_SYS = "x86_64-linux"
NATIVELSBSTRING = "universal"
TARGET_SYS = "aarch64-poky-linux"
MACHINE = "nexbox-a95x-s905x"
DISTRO = "poky"
DISTRO_VERSION = "2.5"
TUNE_FEATURES = "aarch64"
TARGET_FPU = ""
meta
meta-poky
meta-yocto-bsp = "sumo:b369e613a1d3af6439905724031aa2b75423aeee"
meta-meson = "sumo:9a060d8cb106fd86ed7ac93b66675a639bfc6045"
meta-oe
meta-python
meta-networking = "master:bb57bac845f3cd1634862fa9868bc8e294ba74a9"
meta-openwrt = "master:3f94c4f5aa965aa5d65419d6691b40a3870e84a8"
No other changes made to config files.
Resultant files are:
aml_autoscript
amlogic-image-headless-sd-nexbox-a95x-s905x-20180608105022.testdata.json
amlogic-image-headless-sd-nexbox-a95x-s905x-20180609220030.rootfs.ext4
amlogic-image-headless-sd-nexbox-a95x-s905x-20180609220030.rootfs.manifest
amlogic-image-headless-sd-nexbox-a95x-s905x-20180609220030.rootfs.tar.bz2
amlogic-image-headless-sd-nexbox-a95x-s905x-20180609220030.testdata.json
amlogic-image-headless-sd-nexbox-a95x-s905x.ext4
amlogic-image-headless-sd-nexbox-a95x-s905x.manifest
amlogic-image-headless-sd-nexbox-a95x-s905x.tar.bz2
amlogic-image-headless-sd-nexbox-a95x-s905x.testdata.json
Image--4.16.5+git0+e5ce9f6879-r0-meson-gxl-s905x-nexbox-a95x-20180608105022.dtb
Image-meson-gxl-s905x-nexbox-a95x.dtb
meson-gxl-s905x-nexbox-a95x.dtb
modules--4.16.5+git0+e5ce9f6879-r0-nexbox-a95x-s905x-20180608105022.tgz
modules-nexbox-a95x-s905x.tgz
uImage
uImage--4.16.5+git0+e5ce9f6879-r0-nexbox-a95x-s905x-20180608105022.bin
uImage-nexbox-a95x-s905x.bin
Try using skales-tools
dtbTool -o dt.img arch/arm/dts/
mkbootimg --kernel=uboot.bin --dt=dt.img --cmdline="" --pagesize 2048 --base --output=u-boot.img --ramdisk=
Are you sure the img you want to generate is using mkimage tool? mkimage is used to make u-boot image. What you are looking for is probably the genimage tool to combine all the generated output in one single image.
Related
I'm trying to add the tmux package to the image that I build with BitBake.
The recipe for tmux is known to bitbake:
user#ubuntu:/opt/user/build$ bitbake-layers show-recipes | grep -A 1 tmux
tmux:
meta-oe 2.1
Added this line to my conf/local.conf:
IMAGE_INSTALL_append = " tmux"
Clean & build the image:
bitbake -c cleansstate phytec-headless-image
bitbake -c clean phytec-headless-image
bitbake phytec-headless-image
Output of the build:
Build Configuration:
BB_VERSION = "1.36.0"
BUILD_SYS = "x86_64-linux"
NATIVELSBSTRING = "universal-4.8"
TARGET_SYS = "arm-phytec-linux-gnueabi"
MACHINE = "phyboard-mira-imx6-9"
DISTRO = "yogurt"
DISTRO_VERSION = "BSP-Yocto-i.MX6-PD18.1.2"
TUNE_FEATURES = "arm armv7a vfp thumb neon callconvention-hard cortexa9"
TARGET_FPU = "hard"
meta
meta-poky = "HEAD:5f660914cd7eec8117efccdf1eb29c466b4e74f7"
meta-oe
meta-networking
meta-python
meta-multimedia = "HEAD:eae996301d9c097bcbeb8046f08041dc82bb62f8"
meta-gstreamer1.0 = "HEAD:802a5db727edf0ec1d142122241c857bffab8667"
meta-phytec = "HEAD:fcc5c4c755fd273b951ac4726b795ca5a9e9a5ed"
meta-rauc = "HEAD:e9c3928d6c24bd58c613bd8334066021946d6347"
meta-qt5 = "HEAD:e6fb3850d43f857e87f7c53fc7df5933fef98cbd"
meta-yogurt = "HEAD:608387f14f29509af5d029347ab2049764b453d2"
Copy the image to sdcard, it boots fine. But there is no tmux:
root#phyboard-mira-imx6-3:~# tmux
-sh: tmux: command not found
root#phyboard-mira-imx6-3:~# find / -name tmux
root#phyboard-mira-imx6-3:~#
Guidance or hints as to why tmux isn't added to the image are appreciated.
The issue was that the board I thought I was flashing was booting from NAND instead of the SD card that I was using. It has a small hardware-switch to chose where to boot from so I never actually booted the Image that I presumed included tmux.
As described by Parthiban you can verify that the binaries included with IMAGE_INSTALL_append are actually included, have a look at image/*/rootfs.
Check if certain package is present on current Yocto Setup
bitbake -s | grep
see https://community.nxp.com/docs/DOC-94953
I'm creating a small Yocto distro that should work in RAM on tmpfs. I use the WIC configuration in the following way:
part /boot --source bootimg-efi --sourceparams="loader=grub-efi,initrd=${PN}-${MACHINE}.cpio.gz,file=${PN}-${MACHINE}.cpio.gz" --ondisk sda --label msdos --active --align 1024
bootloader --ptable gpt --timeout=0 --append="rootfstype=tmpfs rootflags=size=2G console=ttyS0,115200 console=tty0"
I also add IMAGE_FSTYPES_append = " cpio.gz " to my local.conf, so it builds the cpio.gz archive from my rootfs.
My problem is very straightforward - when WIC runs, it tries to create the wic file before it is done with creating the rootfs cpio.gz, and therefore the build fails. What I need is to create a dependency, something that will hold WIC scripts until the cpio.gz is ready. Does anyone know how to achieve it? Can, for instance, WKS_FILE_DEPENDS be used?
Here is the failure:
| ERROR: _exec_cmd: cp .../poky/build/tmp/deploy/images/genericx86-64/core-image-minimal-genericx86-64.cpio.gz .../poky/build/tmp/work/genericx86_64-poky-linux/core-image-minimal/1.0-r0/deploy-core-image-minimal-image-complete/core-image-minimal-genericx86-64-20191121151711/tmp.wic.k00ckxmk/hdd/boot returned '1' instead of 0
| output: cp: cannot stat '.../poky/build/tmp/deploy/images/genericx86-64/core-image-minimal-genericx86-64.cpio.gz': No such file or directory
Currently I bypass the problem by running the wic tool manually after the build. I had to use IMAGE_FSTYPES_remove = " wic wic.bmap hddimg " in my local.conf for that. The command for running wic then is:
wic create ../meta-mylayer/wic/myimage.wks -e core-image-minimal
Thanks!
EDIT:
Maybe the problem is not in creating the required dependency, but in the way I create the image? I just want a UEFI boot, a kernel, and a cpio.gz file with a complete rootfs which will gets mounted on boot. This is not an initramfs, but a complete rootfs that I need there. Except the problematic dependency the resulting image does exactly what I need.
You can specify the dependency with WIC in 2 ways.
Using do_image_wic: The final task to create the WIC is do_image_wic. So you can add dependency for creating your initrd/initramfs image to this task as below,
do_image_wic[depends] += "image-base-initramfs:do_image_complete"
You need to specify this in your WIC image creation recipe. For this example,
DESCRIPTION = "My image"
inherit core-image
export IMAGE_BASENAME = "image-base"
IMAGE_FSTYPES = "wic.xz"
DEPENDS += "image-base-initramfs"
do_image_wic[depends] += "image-base-initramfs:do_image_complete"
WKS_FILES = "my.wks"
Here image-base is used for creating the WIC using my.wks. It waits for the initramfs to complete the building. In image-base-initramfs you will create the initramfs image.
To add, you can also do this with INITRAMFS_IMAGE when using kernel fitImage.
Using WKS_FILE_DEPENDS: You can add any bitbake recipe to dependency before creating the WIC image. Adding image-base-initramfs to this variable will wait for it to complete the initramfs image. We also have WKS_FILE_DEPENDS_BOOTLOADERS when depending on bootloader to complete in WIC creation.
I'm trying to add auditd to Yocto linux.
I added the selinux layer and it's dependent layers: openembedded-core and meta-virtualization.
I added the layers to bblayers.conf.
I added DISTRO_FEATURES_append = " acl xattr pam selinux"
and PREFERRED_PROVIDER_virtual/refpolicy ?= "refpolicy-mls" to the local.conf file.
After building (by using bitbake core-image-base) and running the qemu, the kauditd process is running, but all user-space tools are not.
The /etc/audit folder is not exist ,non of the audit's config files exists (audit.rules) and no user-space audit process is running.
In the layer's info it is declared - "User space tools for kernel auditing".
What I am missing?
Thanks.
I think I found something that will answer your question: If you know what an example binary or library you expect to be in the target image, you can find what recipe the executable is in, and then add that package to the image.
Start with the name of a binary or library you expect to be in the image and run the following. For me, I am using a CAN bus executable called candump. I wonder what recipe it's in? To find out, I issue:
devtool search candump
Which returns:
can-utils
If nothing is returned, I'd double check your conf/bblayers.conf so that the layer you think it may be in is actually being seen by your build system. If you are unsure, take a look at the link below which points to OpenEmbedded which has a handy search utility for packages.
After you find the recipe, you can then include that recipe into your build.
Here is a good reference in doing what I think you're asking on the OpenEmbedded website:
https://wiki.yoctoproject.org/wiki/Cookbook:Example:Adding_packages_to_your_OS_image
I just added auditd to my system. This is what I did.
First I got the repository checked out.
cd /path/to/yocto
git clone git://git.yoctoproject.org/meta-selinux
cd meta-selinux
# checkout the branch matching the Yocto release you are on
git checkout thud
Then I added auditd to my build.
cd /path/to/build
bitbake-layers add-layer /path/to/yocto/meta-selinux
cat >> conf/local.conf <<'END'
IMAGE_INSTALL_append = " auditd"
END
bitbake my_normal_image_target
Even though the Yocto recipe is called audit, the package name is auditd.
Of course, auditd without selinux is useless but it did attempt to run (journalctl -u auditd) and /etc/audit exists.
FWIW: To get auditd to a point where it reports say, login success/failure, I had to do a few more things. I'm not just adding it to a standard Yocto image, but to a custom image and custom machine. I'm already using systemd so I didn't have to change that (the layer seems to indicate it's required?). My local.conf looked like this.
# enable selinux
DISTRO_FEATURES_append = " acl xattr pam selinux"
# set the policy
PREFERRED_PROVIDER_virtual/refpolicy ?= "refpolicy-mls"
# install selinux packages and auditd
IMAGE_INSTALL_append = " packagegroup-core-selinux auditd"
# tell the kernel to enable selinux (non-enforcing) and audting
APPEND_append = " selinux=1 enforcing=0 audit=1"
I also had to change linux-yocto_selinux.inc to load selinux.cfg later. Probably layer/recipe ordering could have solved this too?
-SRC_URI += "${#bb.utils.contains('DISTRO_FEATURES', 'selinux', 'file://selinux.cfg', '', d)}"
+SRC_URI_append = "${#bb.utils.contains('DISTRO_FEATURES', 'selinux', 'file://selinux.cfg', '', d)}"
With all that in place, I see audit logs in my journal.
Question: What output should I expect from core-image-minimal the U-boot platform, running on i.MX6 quad core Sabre devkit?
I can see a splash screen with the Freescale logo, but then the display goes blank. I was expecting some kind of boot-sequence and a U-Boot> command interface.
I also see from uboot_mx6x.pdf the following:
By default, U-Boot is configured to display the command prompt and receive serial keyboard input on certain UART ports with 115,200-8-N-1 settings.
Question: Where is this defined? How do I change it? How do I listen to this?
I followed a guide on NXP forums to start understanding Yocto and u-boot.
I have installed and followed the procedures from here.
I have used the command:
$ bitbake core-image-minimal
Loading cache: 100% |#######################################| Time: 0:00:00
Loaded 2274 entries from dependency cache.
NOTE: Resolving any missing task queue dependencies
Build Configuration:
BB_VERSION = "1.36.0"
BUILD_SYS = "x86_64-linux"
NATIVELSBSTRING = "universal"
TARGET_SYS = "arm-fslc-linux-gnueabi"
MACHINE = "imx6qdlsabresd"
DISTRO = "fslc-framebuffer"
DISTRO_VERSION = "2.4"
TUNE_FEATURES = "arm armv7a vfp thumb neon callconvention-hard"
TARGET_FPU = "hard"
meta
meta-poky = "HEAD:fdeecc901196bbccd7c5b1ea4268a2cf56764a62"
meta-oe
meta-multimedia = "HEAD:dacfa2b1920e285531bec55cd2f08743390aaf57"
meta-freescale = "HEAD:d6141ea291a1ac9ab8fb1dd1110d408f840fda57"
meta-freescale-3rdparty = "HEAD:62de01743c9233ea718de22991c47b73a78b4857"
meta-freescale-distro = "HEAD:0ec6d7e206705702b5b534611754de0787f92b72"
Initialising tasks: 100% |###################################| Time: 0:00:04
NOTE: Executing SetScene Tasks
NOTE: Executing RunQueue Tasks
NOTE: Tasks Summary: Attempted 3032 tasks of which 2366 didn't need to be rerun and all succeeded.
NOTE: Writing buildhistory
$ wic create imx-uboot-spl-bootpart -e core-image-minimal
INFO: Building wic-tools...
Previous bitbake instance shutting down?, waiting to retry...
Loading cache: 100% |###################################| Time: 0:00:00
Loaded 2274 entries from dependency cache.
NOTE: Resolving any missing task queue dependencies
Build Configuration:
BB_VERSION = "1.36.0"
BUILD_SYS = "x86_64-linux"
NATIVELSBSTRING = "universal"
TARGET_SYS = "arm-fslc-linux-gnueabi"
MACHINE = "imx6qdlsabresd"
DISTRO = "fslc-framebuffer"
DISTRO_VERSION = "2.4"
TUNE_FEATURES = "arm armv7a vfp thumb neon callconvention-hard"
TARGET_FPU = "hard"
meta
meta-poky = "HEAD:fdeecc901196bbccd7c5b1ea4268a2cf56764a62"
meta-oe
meta-multimedia = "HEAD:dacfa2b1920e285531bec55cd2f08743390aaf57"
meta-freescale = "HEAD:d6141ea291a1ac9ab8fb1dd1110d408f840fda57"
meta-freescale-3rdparty = "HEAD:62de01743c9233ea718de22991c47b73a78b4857"
meta-freescale-distro = "HEAD:0ec6d7e206705702b5b534611754de0787f92b72"
Initialising tasks: 100% |#####################################| Time: 0:00:00
NOTE: Executing SetScene Tasks
NOTE: Executing RunQueue Tasks
NOTE: Tasks Summary: Attempted 380 tasks of which 380 didn't need to be rerun and all succeeded.
NOTE: Writing buildhistory
INFO: Creating image(s)...
INFO: The new image(s) can be found here:
./imx-uboot-spl-bootpart-201804091703-mmcblk.direct
The following build artifacts were used to create the image(s):
ROOTFS_DIR: /media/mattis/7228221d-c3f3-424e-8443-8e97176c6a6d/sandbox/fsl-community-bsp/tmp.wic.yc_b166n/rootfs_copy
BOOTIMG_DIR: /media/mattis/7228221d-c3f3-424e-8443-8e97176c6a6d/sandbox/fsl-community-bsp/build/tmp/work/imx6qdlsabresd-fslc-linux-gnueabi/core-image-base/1.0-r0/recipe-sysroot/usr/share
KERNEL_DIR: /media/mattis/7228221d-c3f3-424e-8443-8e97176c6a6d/sandbox/fsl-community-bsp/build/tmp/deploy/images/imx6qdlsabresd
NATIVE_SYSROOT: /media/mattis/7228221d-c3f3-424e-8443-8e97176c6a6d/sandbox/fsl-community-bsp/build/tmp/work/armv7at2hf-neon-fslc-linux-gnueabi/wic-tools/1.0-r0/recipe-sysroot-native
INFO: The image(s) were created using OE kickstart file:
/media/mattis/7228221d-c3f3-424e-8443-8e97176c6a6d/sandbox/fsl-community-bsp/sources/meta-freescale/wic/imx-uboot-spl-bootpart.wks
Lastly I use the command:
dd if=imx-uboot-spl-bootpart-201804091703-mmcblk.direct of=/dev/sdb
After this process, I take the SDCard, and plug it into my sabre development kit, this then boots up the splash screen, after which nothing happens.
To answer your questions:
You should expect to see u-boots output, followed by the kernel's console output, and finally a login prompt.
The console is defined by the SERIAL_CONSOLES variable. You would listen to this by connecting a serial cable to the board and using a program like minicom.
Reading into your questions a bit, I believe the image you are putting on the SD card is not going to work. I do not know much about imx-uboot-spl-bootpart other than how it is described in the kickstart file, and can't say for sure which boards it is compatible with.
You should be able to use the default wic image that is generated once the build is complete. It looks like you are building from Yocto 2.4 Rocko, so once your build is finished you will have two files located here:
$BUILD_DIR/tmp/deploy/images/imx6qdlsabresd/...
core-image-minimal-imx6qdlsabresd.wic
core-image-minimal-imx6qdlsabresd.wic.bmap
If these files do not exist you can create them by adding this line to your local.conf file:
IMAGE_FSTYPES += "wic wic.bmap"
I would recommend using bmap-tools instead of dd as it will save you a lot of time.
In your example the command should look like this:
bmaptool copy /path/to/core-image-minimal-imx6qdlsabresd.wic /dev/sdb
That image should boot and you will be given the chance to stop u-boot and land at the u-boot prompt.
It looks like the default Freescale image is currently wic.gz, which bmap-tools should handle as well.
I would like to create a new target based on core-image-minimal and I would like to change the init system with systemd over SysV init. I would like my change to be permanent (nothing based on local.conf). How can I do this?
Edit: As Anders pointed out in the comments, i was wrong:
The available init systems are set in the local.conf, but you can indeed change the init system on a per image basis. In your case you want to change it in core-image-minimal. This image installs packagegroup-core-boot which sets
VIRTUAL-RUNTIME_init_manager ?= "sysvinit"
VIRTUAL-RUNTIME_initscripts ?= "initscripts"
You could create your own packagegroup-core-boot-systemd where those variables are set to
VIRTUAL-RUNTIME_init_manager = "systemd"
VIRTUAL-RUNTIME_initscripts = ""
and install it to your target.
The configuration of the init system is a Distro Feature. That means it is not in the image recipe, but in the local.conf.
If you don't want to put the configuration in the local.conf, you could create a custom distro configuration with the settings in it. The only thing you have to change in the local.conf is the line
# DISTRO = poky
DISTRO = <custom-distro>
The reference manual has also a chapter on creating your own distro