Yocto minimal image with package management - linux

I am trying to build the smallest possible linux image using the Yocto project. I would also like to have package management on the target to be able to add to and update parts of the running system.
I can enable the package management by adding this to my conf/local.conf:
EXTRA_IMAGE_FEATURES = "package-management"
Using rpm, that pulls in the smartpm package manager which is based on python which in turn makes the image to large. So I tried to use ipk packages but that still depends on python.
Does anyone have a good idea how to include package management in Yocto with the least possible overhead?

I can suggest you few things, which may help you to optimize size of rootfs:
Optimize as much as possible linux kernel binary and removed unnecessary packages (filesystem,device driver,networking etc).
$ bitbake -c menuconfig virtual/kernel //configure as per your requirement
$ bitbake -c savedefconfig virtual/kernel //savedefconfig
$ bitbake -f virtual/kernel
Configure Busybox and removed unused things:
$ bitbake -c menuconfig busybox
Remove those Distro features if not in use (and check more also): graphics [x11], sound [alsa], touchscreen [touchscreen], Multimedia. Change apply in conf/local.conf file. Example: DISTRO_FEATURES_remove = "x11 alsa touchscreen bluetooth opengl wayland "
Choose proper system init manager: systemd or sysvinit
Removed Unused Packages from the image. Example PACKAGE_EXCLUDE = "perl5 sqlite3 udev-hwdb bluez3 bluez4"
For small embedded device preferred PACKAGE_CLASSES = "package_ipk" and it is well optimized for small systems.

Looks like this is the best I can do.
PACKAGE_CLASSES = "package_ipk"
Then edit the recipe for opkg-utils to not depend on python. Will of course break the python utils, though.

Related

Cannot get custom kernel to boot - mkinitpcio does not add any modules

1. What I am trying to achieve:
Build a custom kernel so I can install and run Anbox-git from AUR on my Arch laptop. Custom kernel is needed for the package to work.
2. What I did to achieve it:
Download Arch Linux kernel v5.8.5-arch1 from here
I followed the guidelines on tradional compilation Arch wiki to create the custom kernel
Via make nconfig I applied the changes mentioned in the Anbox Arch wiki page.
Via make nconfig I changed EFIVAR_FS option from "M" to "*" to resolve an error from earlier attemps.
Via make nconfig under Location: -> Device Drivers-> Multiple devices driver support (RAID and LVM) (MD [=y])-> Device mapper support (BLK_DEV_DM [=y]) I added a few more options (*) because on earlier builds mkinitpcio gave errors for missing modules for DM_CRYPT, and some more DM_ modules which I cannot easily reproduce (will do if necessary for the answer, but I hope it'll be irrelevant).
After creating the config this way I did:
sudo make modules_install
sudo cp -v arch/x86_64/boot/bzImage /boot/vmlinuz-linux58ac
sudo cp /etc/mkinitcpio.d/linux.preset /etc/mkinitcpio.d/linux58ac.preset
Adapted the preset file per Arch wiki instructions
sudo mkinitcpio -p linux58ac
Important: The mkinitpcio runs fine, but keeps giving me a warning:
WARNING: No modules were added to the image. This is probably not what
you want.
sudo grub-mkconfig -o /boot/grub/grub.cfg
3. Expected result:
I am able to reboot, select the new kernel from grub menu, get the usual LVM password prompt, and launch into it without problems.
4. Result I get:
I can reboot and select new kernel from grub but when I select it I get a
Warning: /lib/modules/5.8.5-arch1/modules.devname not found, ignoring.
Starting version 246.4-1-arch
ERROR device 'dev/mapper/vg0-root' not found. Skipping fsck.
mount /new_root: special device /dev/mapper/vg0-root does not exist.
You are being dropped into an emergy shell.
I checked and the /lib/modules/5.8.5-arch1/modules.devnamedoes indeed exist. But I think the actual problem is that mkinitcpio doesn't load the correct modules into the custom kernel, causing it to become unbootable.
Any help appreciated!

Yocto/Poky: How to remove hwclock from busybox?

I'm building a Poky-based embedded Linux distribution for a target which doesn't have a real-time clock. System time is only set by ntpd. Therefore I don't really need an init script which calls hwclock --hctosys during boot, and in fact I'm afraid that this might cause the system time which is set by ntpd to be
overwritten with an incorrect value.
So how do I get rid of the hwclock init script? It turns out that it comes from the busybox recipe. The default recipe for busybox in Poky contains the following lines:
PACKAGES =+ "${PN}-httpd ${PN}-udhcpd ${PN}-udhcpc ${PN}-syslog ${PN}-mdev ${PN}-hwclock"
...
FILES_${PN}-hwclock = "${sysconfdir}/init.d/hwclock.sh"
...
INITSCRIPT_PACKAGES = "${PN}-httpd ${PN}-syslog ${PN}-udhcpd ${PN}-mdev ${PN}-hwclock"
...
INITSCRIPT_NAME_${PN}-hwclock = "hwclock.sh"
I have no idea how to remove all the references to hwclock from within a *.bbappend file. Is there any straightforward solution, or is it not possible from a bbappend and I have to re-write the entire recipe?
You can disable it from its defconfig file by configuring CONFIG_HWCLOCK=n located at openembedded-core/meta/recipes-core/busybox/busybox/defconfig.
If you want to exclude packages from a build and don't want to resort to manipulating working recipes, just so a PACKAGE_EXCLUDE = "<package_name>" in your local.conf
This is an example of mine:
PACKAGE_EXCLUDE = "busybox-syslog busybox-hwclock"
But note that some packages may depend on hwclock. You'll get a bitbake dependency error at worst.

../util-linux-2.28.1/schedutils/chrt.c:88:17: error: ‘__NR_sched_setattr’ undeclared (first use in this function)

i am trying to build os-image using bitbake in yocto project. i got the following error.
../util-linux-2.28.1/schedutils/chrt.c:88:17: error: ‘__NR_sched_setattr’ undeclared (first use in this function)
i followed the instructions given in Mega Manual of yocto. how to resolve this build error?
This type of error messages appear when some user space program or library is being built for kernel that doesn't support some system call, sched_setattr in this case. Either you build on very old linux (appeared in 3.14) or which is most probable the arch you are building on doesn't support this system call (you haven't specified which arch you are building on, so I cannot check).
Either way, it's possible to disable this particular part of util-linux with configuration option --disable-schedutils. You won't get chrt, ionice, taskset (process manipulation) tools on your device in this case but they are probably not very useful for you.
In yocto build environment, you can first modify recipe for util-linux, well actually include file for recipe (meta/recipes-core/util-linux/util-linux.inc), by adding one line:
SHARED_EXTRA_OECONF = "--disable-use-tty-group \
--disable-makeinstall-chown \
...
--disable-schedutils \
"
and check if it works for you. Later you can add
EXTRA_OECONF_append_util-linux = " --disable-schedutils"
to your conf/local.conf or to util-linux bbappend file in your working meta layer (if you have it).
It's probably finding ncurses headers from your host machine when it should only be looking in the Yocto sysroot. There's a patch that fixes this, it will probably end up in master soon. Either use the patch locally for now or as a workaround remove libncurses6 and libncursesw6 development packages from your build host.

Yocto menuconfig not working

For some reason the menuconfig menu does not come up when I try launching it from my Yocto installation. I am using the Toradex Yocto 1.6 system as is described here http://developer.toradex.com/software-resources/arm-family/linux/board-support-package/openembedded-%28core%29, with my board set to "apalis-t30". When I run either bitbake virtual/kernal -c menuconfig or bitbake linux-toradex -c menuconfig, it executes fine but finishes (without erros) before actually showing anything. Running devshell also gives the same results.
If I just use the kernel sources on their own as is described here http://developer.toradex.com/software-resources/arm-family/linux/board-support-package/build-u-boot-and-linux-kernel-from-source-code, I can get menuconfig open using make nconfig. From the Yocto scripts it appears as if though the exact same kernel sources are being used. If I try adding adding make nconfig to the do_configure_prepend script in the linux-toradex_git.bb file then the commands get stuck stating that the process (I assume menuconfig) is running and then provides a PID for it, but no window or menu is displayed anywhere and the task does not seem to finish.
PS. I am on Fedora 21 64-bit.
EDIT:
I have now checked the default Yocto image and menuconfig comes up fine there. I am assuming that the Toradex BSP is not entirely compatible enough with Yocto for this to work out of the box. I have spoken to Toradex and they have told me that I should instead fork their kernel, modify it the normal way in my own repo and then tell the script to pull from my modified repo. I guess this could work but its a bit of a hassle and I would like to fix their Yocto system. I am assuming that this cannot be to hard as running make nconfig is usually enough, I just can't figure out how to get that command working with bitbake.
This should work fine with the meta-toradex layer. In the local.conf file, comment out the INHERIT += "rm_work" line:
#INHERIT += "rm_work"
Then do a full build of the kernel:
MACHINE=apalis-t30 bitbake virtual/kernel
Then try menuconfig now that all the sources are in place:
MACHINE=apalis-t30 bitbake -c menuconfig virtual/kernel
If you are using Ubuntu, try to reconfigure system shell to bash instead of dash(that is default for Ubuntu):
$ sudo dpkg-reconfigure dash
press "No" when prompted.
Actually I got the same problem few times. In one case shell reconfigure helped me.

IOMMU Emulation and install with QEMU

For now, I need to use some packages to do a emulation for IOMMU (it is similar to MMU), and I got some source about it, but I don't know how to use them.
http://www.spinics.net/lists/kvm/msg38514.html Here is a link of source for emulating IOMMU
http://repo.or.cz/w/qemu-kvm/amd-iommu.git Here is a link for downloading file for this emulation
My problem is how to use qemu to do this and there are so many file in the download list, I don't know how to use them...
Thanks for your help, really appreciate!!! If you know something detail, please tell me
you can use download option in the right side of the page ( Generally snapshot option is available in repositories )
or this
then simply use configure script to generate makefile
i.e.
use ccache if you want to recompile it again and again
$CC="ccache gcc"./configure --prefix=$PREFIX <br>
then make to build and install, use -j<no_of_cpu+1>
$make -j5 all install
if you have dependencies issue, solve them using synaptic manager or apt-get
P.S. AFAIK You should have iommu support available in hardware, if you have 64-bit machine then you might have. You can check flags in using cat /proc/cpuinfo

Resources