boot-scripts
boot-scripts copied to clipboard
generic-board-startup.service takes a long time to run, contributing to slow boot time.
Hello,
I'm currently attempting to decrease the boot time of a Beaglebone Black for use in an industrial situation where boot times are important.
Running systemd-analyze plot shows that generic-board-startup service (which i believe runs eventually runs, am35xx_evm.sh) takes a significant time to run, around 4.5 seconds. Upon reducing the sleep statements in am335x_evm.sh and generic-startup.sh I've got this time down to 2.5 seconds but still wish to reduce this time further. Do you have any suggestions?
I have tried disabling this service from starting at all, but this appears to disable the serial console, meaning I am unable to login to the board.
Thanks.
@Samathy the am335x_evm.sh script goes thru a bunch of options based on how the image is setup. Since you are targeting one setup, you could remove some of that extra's.
For your application, are you using all 3 modes of the usb? serial gadget, network gadget, flash drive gadget?
For example, if your just using the serial gadget, you could remove the call from generic-board-startup and just have g_serial loaded via:
echo "g_serial" > /etc/modules-load.d/g_serial.conf
For the network gadget, hardcode the values we recover from teh at24 eeprom on the i2c bus..
Regards,
Thanks for the input, I'll look into your suggestions.
Regards,
I'm having the same issue, except my boot times are ridiculously excessive.
# systemd-analyze blame
38.438s generic-board-startup.service
36.895s dev-mmcblk1p1.device
12.458s apt-daily.service
3.143s loadcpufreq.service
3.109s systemd-udev-trigger.service
2.243s networking.service
1.731s ssh.service
1.336s pppd-dns.service
1.293s bb-wl18xx-wlan0.service
1.289s connman.service
1.215s systemd-journald.service
1.055s systemd-logind.service
1.015s avahi-daemon.service
927ms dnsmasq.service
793ms udhcpd.service
725ms systemd-timesyncd.service
573ms cpufrequtils.service
555ms rsyslog.service
524ms wpa_supplicant.service
502ms systemd-udevd.service
419ms systemd-fsck-root.service
398ms systemd-update-utmp.service
374ms systemd-user-sessions.service
371ms kmod-static-nodes.service
366ms sys-kernel-debug.mount
324ms systemd-modules-load.service
318ms sys-kernel-config.mount
276ms systemd-remount-fs.service
267ms sys-fs-fuse-connections.mount
267ms systemd-sysctl.service
238ms systemd-journal-flush.service
234ms systemd-tmpfiles-setup-dev.service
217ms systemd-tmpfiles-setup.service
203ms hostapd.service
202ms [email protected]
183ms systemd-update-utmp-runlevel.service
161ms systemd-random-seed.service
141ms bb-wl18xx-bluetooth.service
137ms dev-mqueue.mount
85ms systemd-tmpfiles-clean.service
It's the usb gadget modules...
I should also point out that my kernel takes 26 seconds to load even though its written on and running from the eMMC...
$ ssh [email protected] systemd-analyze
Startup finished in 26.334s (kernel) + 57.971s (userspace) = 1min 24.305s
How do I know which usb gadget modules I am and am not using so I can disable the ones I'm not using?
Also @RobertCNelson, just because it is interesting, here is the plot.zip which contains plot.svg
from systemd-analyze plot > plot.svg
It's time-consuming, but I'm contemplating starting from a fresh image and taking plot.svg
along the way as I set it up from scratch just to see if its something I did...
@troywweber7 so this is the slow path:
https://github.com/RobertCNelson/boot-scripts/blob/master/boot/am335x_evm.sh#L472-L550
This builds up and provides:
usb-serial
usb-network
usb-flash
Currently, usb-flash can be disabled easily in /etc/default/bb-boot
USB_IMAGE_FILE_DISABLED=yes
https://github.com/RobertCNelson/boot-scripts/blob/master/boot/default/bb-boot
i'd like to factor the other two at some point.
in v4.15.x/v4.16.x i've been trying to make it work when libcomposite is bulit-in to speed things up, but i haven't had any luck yet..
https://github.com/RobertCNelson/boot-scripts/commits/master/boot/am335x_evm.sh
Regards,
@RobertCNelson so am I correct in my understanding of those module's purposes? Here is my current understanding:
-
usb-serial
allows you to ssh log in over the usb? -
usb-network
allows the beaglebone to use your computer's internet to update? -
usb-flash
allows you to access a portion of flash storage when the board is plugged in via USB?
@RobertCNelson and if I don't need any one of those modules, how do I turn them off exactly?
By which I mean, disabling flash is easy as you pointed out, but how do I disable the other options? Do I simply comment out the call to am335xevm.sh
within the generic-startup.sh
script?
@RobertCNelson what I decided to do was to comment out the script="am334x-evm.sh"
line in the /opt/scripts/boot/generic-startup.sh
script and got much quicker boot times. Is there any danger to this other than losing those fancy usb features?
$ systemd-analyze && systemd-analyze blame
Startup finished in 21.062s (kernel) + 12.218s (userspace) = 33.281s
19.788s dev-mmcblk1p1.device
3.013s systemd-udev-trigger.service
2.564s loadcpufreq.service
2.511s apache2.service
2.094s networking.service
1.995s systemd-logind.service
1.743s ssh.service
1.733s udhcpd.service
1.542s bb-wl18xx-wlan0.service
1.455s pppd-dns.service
1.102s connman.service
1.041s systemd-journald.service
997ms generic-board-startup.service
782ms systemd-hostnamed.service
707ms cpufrequtils.service
613ms avahi-daemon.service
596ms wpa_supplicant.service
546ms [email protected]
507ms systemd-timesyncd.service
451ms systemd-update-utmp.service
450ms systemd-random-seed.service
402ms systemd-tmpfiles-setup-dev.service
395ms systemd-udevd.service
339ms rsyslog.service
328ms systemd-modules-load.service
322ms sys-kernel-config.mount
318ms kmod-static-nodes.service
317ms sys-kernel-debug.mount
279ms hostapd.service
270ms systemd-journal-flush.service
269ms sys-fs-fuse-connections.mount
256ms systemd-user-sessions.service
241ms systemd-sysctl.service
240ms systemd-update-utmp-runlevel.service
221ms systemd-tmpfiles-setup.service
220ms dev-mqueue.mount
188ms systemd-remount-fs.service
173ms bb-wl18xx-bluetooth.service
Further, is there anything else I should consider doing to cut back the boot time?
@troywweber7 What did you do to retain the ssh capabilities after just commenting out script="am334x-evm.sh"?