Boot time speedup

That did it, I can now ssh in via usb. Wahoo I 'm now a Linux kernel developer, fame and fortune awaits.

Thank you very much!

I have taken a couple of seconds off the kernel boot time now. Also removed about 10 services by stop, disable and removing their file from /etc/systemd/system and /usr/lib/systemd/system also used apt remove where needed. according to the svg plot the rest of the services take minimal time to execute.
Now I need to reduce the userspace boot time. Userspace is taking 25.6 seconds.

  1. How is the userspace booting up, where the file controlling that process.
  2. What can be removed to make userspace boot faster?
  3. when does user code start to be executed, when is /etc/init.d at the end of userspace boot time?

I had boot time issues with 11.8 kernel 5.10.168-ti-r71. Not sure which kernel is in image you are using.

I found this patch to kernel saved 6 seconds in booting.
https://patchwork.kernel.org/project/linux-acpi/cover/20201121020232.908850-1-saravanak@google.com/#23791353

Thank you for that link. I have no idea how to get it though. Is that for buildroot or guys who are compiling their own Linux from source? Looks to me like they are compiling their own.

Yes I had to rebuild the kernel from source with that patch. I have an image here if you want to see if it does anything for you.

http://www.pdp8online.com/mfm/revb/software.shtml

I cross compiled on Fedora. I can give you the build tree also if useful.

Thank you again, it is very helpful. I would like to see your build tree too. I am new at this and I very much want to learn how to build my own Linux kernel for the BBB. Learning from others is great, maybe someday I can contribute back some knowledge.

Looks like I started with kernel 5.10.168-ti-rt-r74.tar.gz

My cryptic notes on building the kernel
https://www.pdp8online.com/misc/kernel-build. I donā€™t do this often so this was looking at web pages until I found something that worked.

Tree here
https://www.pdp8online.com/misc/patched-linux-5.10.168-ti-r74.tgz

Sorry for slow response but life is busy right now.

1 Like

Iā€™ve managed to significantly reduce the boot time on my BeagleBone Black, following the steps from the discussion in this forum, but Iā€™m still looking to optimize it further. Currently, my boot time is 23.655s, and here are the changes Iā€™ve made:

  1. Installed kernel 5.15.148-bone42.
  2. Used the command ls /boot/initrd.img-* to list and then removed unnecessary kernel images with rm from the /boot directoryā€¦
  3. Disabled services like avahi-daemon, bb-symlinks, wpa_supplicant, systemd-timesyncd, systemd-resolved, and e2scrub_reap.
  4. Disabled audio, video and wireless by modifying the uEnv.txt file to prevent the drivers from loading and added the line dtb=am335x-bonegreen.dtb to configure the device tree.

Iā€™m using the BeagleBoard.org Debian Bullseye Minimal Image 2023-10-07.

My current setup shows 2.739s (kernel) and 20.915s (userspace) boot times. However, what else can I tweak to further reduce this boot time? Are there any additional services I could disable or configurations I should review to optimize further?

Thanks in advance for any suggestions or recommendations.

How fast do you want to boot and what do you really need ?

If the kernel is booing in 2.74s your software could be running then.
On the kernel boot args you can do init=/path_to_your_exe and run that rather than the default init

But if you are depending on services running that is probably not a good idea.

Depending on the work you want to put in, you could try going down the buildroot path.
If you build a minimal busybox image with nothing running you can get some idea how fast it is possible to boot.

You can use SYSV init rather than systemd (it is pretty easy to specify different init systems). You might find you can shave of some time doing that. It can also be easier to modify and as you seem to be disabling a lot of stuff might give you a quicker boot.

To be honest, I would like it to be as fast as possible; if itā€™s under 10 seconds, thatā€™s already acceptable. Essentially, the system automatically runs a PyQt file at startup, so the boot time needs to be as short as possible without compromising that functionality.

I was able to get boot time down to about 25 seconds with services needed for communication, display and running the custom software. I never got a Buildroot image to run as the 25s was fast enough for my customer. Buildroot requires a lot of time to learn to get an image to boot and run, at least for me. I got a Yacto build to complete but it did not run either. I can see a market for fast boot time for a BBB in an embedded application.

Have a Blessed day and new year!
Don

Core image minimal in Yocto is a very fast boot.

1 Like

What do you recommend, Yocto or Buildroot? I donā€™t have much experience with either. It seems that the images provided by the manufacturers, even though minimal, include packages to support basic use. Also, Iā€™m looking for pre-made minimal images in Buildroot, but there doesnā€™t seem to be much available from what Iā€™ve searched so far.

personally I prefer buildroot because it is what I am used to. Think the learning curve for Yocto is much steeper.

For buildroot to start is as simple as downloading the tar file to a linux machine, unpack it
cd into the directory and then if you have ever built the linux kernel it is pretty similar

you can do make beaglebone_defconfig follwed by make

then go and make a cup of coffee because it will take a while

That should build a minimal image approx 50MB I think.
In the output/images directory you should have an image file that you can copy to an sd-card.

To add/change stuff run make menuconfig. Take a while and browse through all of the various menus.
It is all menu driven to select packages. Be aware that some stuff can be hidden if it depends on items you are not including.

@Martin_Rosso
Yes, it is.
We use it because the same packages can be used across multiple systems, from bbb to intel I7 boards. However, if you donā€™t have a need for that the time involved with finding all the little things that trip you up is not worth the effort. As for buildroot, we donā€™t use it so I cannot comment on it. As @benedict.hewson states, it might be a simpler solution.

If you remove systemd and everything that is not needed you will have done as much as possible. Not using systemd is not a good idea. Also, booting from SD is very slow.

root@beaglebone:~# systemd-analyze
Startup finished in 4.377s (kernel) + 13.162s (userspace) = 17.539s 
multi-user.target reached after 11.884s in userspace

root@beaglebone:~# systemd-analyze blame
12.115s dev-mmcblk0p2.device
 5.183s systemd-udev-trigger.service
 2.947s systemd-timesyncd.service
 2.508s systemd-resolved.service
 1.915s systemd-networkd.service
 1.793s systemd-logind.service
 1.565s systemd-journald.service
 1.226s systemd-udevd.service
 1.149s user@0.service
 1.135s sync-clocks.service
 1.035s ldconfig.service
  955ms modprobe@fuse.service
  943ms modprobe@drm.service
  923ms modprobe@configfs.service
  882ms systemd-modules-load.service
  864ms sys-kernel-debug.mount
  860ms sys-kernel-tracing.mount
  858ms tmp.mount
  857ms dev-mqueue.mount
  850ms systemd-network-generator.service
  795ms systemd-remount-fs.service
  755ms systemd-journal-catalog-update.service
  563ms systemd-tmpfiles-setup.service
  502ms sys-fs-fuse-connections.mount
  486ms systemd-update-utmp.service
  480ms systemd-userdbd.service
  409ms sys-kernel-config.mount
  367ms dbus.service
  279ms systemd-sysctl.service
  262ms systemd-random-seed.service
  243ms systemd-sysusers.service
  231ms media-ram.mount
  220ms systemd-update-utmp-runlevel.service
  206ms systemd-update-done.service
  203ms systemd-tmpfiles-setup-dev.service
  200ms var-volatile.mount

This is Tiā€™s arago build, based on core-image-minimal yocto. That is even on SD card, when I get closer to where it needs to be I will plant it in emmc.

2 Likes

Thatā€™s not bad timing. Could you point me to where I can find or download the minimal Arago image?

You will have to build it in Tiā€™s Yocto. As typical TI the current SDK instructions have not been tested to see if they are correct. If you decide to go that direction I will look for my notes and what had to be fixed. Once you get it set up it works very well.

FYI, you will need 400Gb of NVMe space, and set your swap on NVMe to 60Gb and if you have less than 32Gb of ram you will have to bump that up to possibly 100Gb.

root@beaglebone-ai64:~# systemd-analyze
Startup finished in 5.762s (kernel) + 5.394s (userspace) = 11.157s 
multi-user.target reached after 4.161s in userspace.
root@beaglebone-ai64:~# 

You can even take 2 more seconds off of that, grub hangs for 2 seconds so that is about 9s boot.
ai-64 on arago.

Do you recommend this SDK ā€˜PROCESSOR-SDK-AM335X Software development kit (SDK) | TI.comā€™ for creating my minimal image with Arago?