Author Topic: Quick boot on Raspberry for embedded application  (Read 1685 times)

0 Members and 1 Guest are viewing this topic.

Offline luiHS

  • Frequent Contributor
  • **
  • Posts: 459
  • Country: es
Quick boot on Raspberry for embedded application
« on: May 23, 2021, 09:12:16 am »
Hi
I need to noticeably reduce the boot time on a Raspberry for an embedded application.

Everything I have found seems to require compiling scaled-down linux versions, buildroot, yocto, void linux, OpenWRT, Poky.

Anyone with experience in the field?

I just need Wifi and the UART. If there was an .img file to create the SD, all the better, because it is complex for me to have to compile and it can take hours before it does not work.
 

Offline kripton2035

  • Super Contributor
  • ***
  • Posts: 2089
  • Country: fr
    • kripton2035 schematics repository
Re: Quick boot on Raspberry for embedded application
« Reply #1 on: May 23, 2021, 11:29:27 am »

 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 6948
  • Country: fr
Re: Quick boot on Raspberry for embedded application
« Reply #2 on: May 23, 2021, 11:42:02 pm »
I need to noticeably reduce the boot time on a Raspberry for an embedded application.

What would be the maximum boot time allowed?
 

Offline DiTBho

  • Frequent Contributor
  • **
  • Posts: 755
  • Country: gb
Re: Quick boot on Raspberry for embedded application
« Reply #3 on: May 24, 2021, 10:15:37 am »
I just need Wifi and the UART.

All you need is to edit the file which describes the services to be launched.
Less services, less time to boot. Easy job.
Wifi requires more stuff than the simple Ethernet.
 

Offline luiHS

  • Frequent Contributor
  • **
  • Posts: 459
  • Country: es
Re: Quick boot on Raspberry for embedded application
« Reply #4 on: May 25, 2021, 10:01:13 am »
What would be the maximum boot time allowed?

10 seconds.
 

Offline kripton2035

  • Super Contributor
  • ***
  • Posts: 2089
  • Country: fr
    • kripton2035 schematics repository
Re: Quick boot on Raspberry for embedded application
« Reply #5 on: May 25, 2021, 10:19:30 am »
out of curiosity, what does the Pi exactly between wifi and uart ?
 

Offline luiHS

  • Frequent Contributor
  • **
  • Posts: 459
  • Country: es
Re: Quick boot on Raspberry for embedded application
« Reply #6 on: May 25, 2021, 11:49:09 am »
out of curiosity, what does the Pi exactly between wifi and uart ?

WIFI, I use it to connect from PC with SmarTTY and WinSCP to configure and update files. I do not like to use wired Ethernet, I find it more comfortable to do it over WIFI. And in the future I also want to develop an Android App so that the user can configure the product and upload firmware updates from the mobile phone.

UART, to communicate with an RT1064 microcontroller that sends commands to the Raspberry to play videos.
 

Offline ralphrmartin

  • Frequent Contributor
  • **
  • Posts: 409
  • Country: gb
    • Me
Re: Quick boot on Raspberry for embedded application
« Reply #7 on: May 25, 2021, 03:57:14 pm »
Why not just boot directly from a USB 3 SSD? Wouldn't this be quick enough? It may not be the cheapest solution, but might be the easiest.

As noted above, you could also turn off unwanted services for extra speed: e.g.
systemctl disable bluetooth
systemctl stop bluetooth

 

Offline DiTBho

  • Frequent Contributor
  • **
  • Posts: 755
  • Country: gb
Re: Quick boot on Raspberry for embedded application
« Reply #8 on: May 25, 2021, 04:21:49 pm »
Even a USB-stick should be faster than an SD card.
Except those gold-ones used for digital video recording.

So
-1- turn off unwanted services for extra speed
-2- try USB-stick for other extra I/O speed

 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 6948
  • Country: fr
Re: Quick boot on Raspberry for embedded application
« Reply #9 on: May 25, 2021, 05:14:28 pm »
What would be the maximum boot time allowed?

10 seconds.

10 seconds is definitely no problem.
I managed about 5 seconds with a RPi3 (and 4). For that to happen, you need to install a very minimal Linux distro with no desktop environment and the minimum amount of services enabled. (Also of course, use a decent fast SD card.)
I personally use ArchLinuxARM for this. The base install is pretty minimal and comes with no desktop env. After installing it, you can fine-tune by disabling services you don't need, but under 10s with the base install should be no problem already.

RPi3: https://archlinuxarm.org/platforms/armv8/broadcom/raspberry-pi-3
RPi4: https://archlinuxarm.org/platforms/armv8/broadcom/raspberry-pi-4

Works a treat for me.
« Last Edit: May 25, 2021, 05:16:32 pm by SiliconWizard »
 
The following users thanked this post: luiHS

Offline kripton2035

  • Super Contributor
  • ***
  • Posts: 2089
  • Country: fr
    • kripton2035 schematics repository
Re: Quick boot on Raspberry for embedded application
« Reply #10 on: May 25, 2021, 05:40:14 pm »
not sure you can play videos on the Pi with this minimal linux distro ?
 

Offline luiHS

  • Frequent Contributor
  • **
  • Posts: 459
  • Country: es
Re: Quick boot on Raspberry for embedded application
« Reply #11 on: May 25, 2021, 06:50:04 pm »
10 seconds is definitely no problem.
I managed about 5 seconds with a RPi3 (and 4). For that to happen, you need to install a very minimal Linux distro with no desktop environment and the minimum amount of services enabled. (Also of course, use a decent fast SD card.)
I personally use ArchLinuxARM for this. The base install is pretty minimal and comes with no desktop env. After installing it, you can fine-tune by disabling services you don't need, but under 10s with the base install should be no problem already.

RPi3: https://archlinuxarm.org/platforms/armv8/broadcom/raspberry-pi-3
RPi4: https://archlinuxarm.org/platforms/armv8/broadcom/raspberry-pi-4

Works a treat for me.

To install ArchLinux it can only be done from a Linux computer, it cannot be done from Widows, there is no .img file already ready to create the SD ??.
Where can I get information on how and what services can I disable?

I only use WIFI and the UART. I already have Bluetooth disabled to be able to use the serial port. I could do without keyboard and mouse, although for the near future I will need USB for a data pendrive.

« Last Edit: May 25, 2021, 06:55:27 pm by luiHS »
 
The following users thanked this post: WattsThat

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 6948
  • Country: fr
Re: Quick boot on Raspberry for embedded application
« Reply #12 on: May 25, 2021, 11:03:39 pm »
Well you have a number of ways of doing that. A small virtual machine with Linux (you only need the command line), or just do it from a RPi with Raspbian or similar!
That said, if you don't want to use ArchLinux ARM, you should be able to tailor Raspbian for the same thing. You just need to disable the desktop environment and a few services. I haven't tested, but a minimal Raspbian config should boot in only a couple seconds as well.
 

Offline luiHS

  • Frequent Contributor
  • **
  • Posts: 459
  • Country: es
Re: Quick boot on Raspberry for embedded application
« Reply #13 on: May 25, 2021, 11:38:57 pm »
I have a CM4 with 8Gb flash, I will try to do it with it, although if I have to compile I suppose it will be very slow.

I have already checked how to see running services with service --status-all and how to disable them with systemctl disable <service>. I don't know yet which services to disable, I have tried disabling avahi-daemon and triggerhappy. I need ssh to connect by WIFI, I do not know if need networking

I have also run the systemd-analyze blame and systemd-analyze critical-chain command, but RPY always responds with "Bootup not finished yet."

« Last Edit: May 25, 2021, 11:42:57 pm by luiHS »
 

Offline dunkemhigh

  • Super Contributor
  • ***
  • Posts: 2879
Re: Quick boot on Raspberry for embedded application
« Reply #14 on: May 26, 2021, 12:01:40 am »
Quote
To install ArchLinux it can only be done from a Linux computer

If you're  building from sources you can compile and do whatever is needed on Windows. Takes a bit of effort to set up the cross-compiler and environment, but it's doable (and you'll end up knowing exactly how the thing gets built and from what).

But if you just want to get going quickly, as SiliconWizard suggests: install Linux in a VM to do the biz. VirtualBox is free and easy to set up.
 

Offline luiHS

  • Frequent Contributor
  • **
  • Posts: 459
  • Country: es
Re: Quick boot on Raspberry for embedded application
« Reply #15 on: May 26, 2021, 05:19:18 am »

I have already installed VirtualBox on my Windows computer.
What is the best version of Linux to install and work with this issue in VirtualBox? I am going to create Buildroot for Raspberry 3 and 4.
 

Offline luiHS

  • Frequent Contributor
  • **
  • Posts: 459
  • Country: es
Re: Quick boot on Raspberry for embedded application
« Reply #16 on: May 26, 2021, 07:54:25 am »
 
Thank you all for the information and advice.

Finally I have decided to create a custom linux with buildroot, but I am doing it from a Raspberry pi 4 with a 64Gb SD card.

I have followed the instructions that I found in this tutorial.
https://ubanov.wordpress.com/2020/04/21/sistema-embebido-sobre-raspberry-pi-con-buildroot/

If the system boots in less than 10 seconds for a Raspberry pi 1, as indicated in that tutorial, which will be even less for an RPY 3 or 4, and WIFI and UART work, I'm already happy.

What I have seen is that there are a lot of parameters. Buildroot has some configurations ready for Raspberry pi 3 and 4, even so I have reviewed them all and I have remembered that wpa_supplicant may be necessary for the WIFI, the rest or they were already selected or indicated in that tutorial as open_ssh. I have also activated and configured the password for root.

iptables I do not need it, I understand that it is a firewall and in my application it is not necessary.

Now I have left it processing in my Raspberry pi4 with the make so that the .img file for the SD card is created. I suppose it will take a long time, and that if I had process it from Virtualbox on my PC, it would compile much faster, but there's no rush. If I see that it takes more than 5 hours, I will cancel it and do it on the PC.

« Last Edit: May 26, 2021, 07:59:39 am by luiHS »
 

Offline luiHS

  • Frequent Contributor
  • **
  • Posts: 459
  • Country: es
Re: Quick boot on Raspberry for embedded application
« Reply #17 on: May 26, 2021, 08:11:05 am »
 
Compilation failed, and no idea why. Here it gives five ERROR messages, for the selected processor it does not support mls, r1, r2, r8, r11 in ARM mode. Luckily it failed soon and not after hours of compiling.



 

Offline dunkemhigh

  • Super Contributor
  • ***
  • Posts: 2879
Re: Quick boot on Raspberry for embedded application
« Reply #18 on: May 26, 2021, 11:51:47 am »
Quote
What is the best version of Linux to install and work with this issue in VirtualBox? I am going to create Buildroot for Raspberry 3 and 4.

Sorry, I can't help with buildroot - when I did this I wrote a custom build script, partly because with the likes of buildroot (and, especially, crosstool) if you hit a strange problem it can often take more effort to sort it out than to have done your own from the start.

Having said that, a quick google suggests that this page may be of use:

https://jenda.hrach.eu/w/rpi-gcc
 

Offline luiHS

  • Frequent Contributor
  • **
  • Posts: 459
  • Country: es
Re: Quick boot on Raspberry for embedded application
« Reply #19 on: May 26, 2021, 04:41:46 pm »
Quote
What is the best version of Linux to install and work with this issue in VirtualBox? I am going to create Buildroot for Raspberry 3 and 4.

Sorry, I can't help with buildroot - when I did this I wrote a custom build script, partly because with the likes of buildroot (and, especially, crosstool) if you hit a strange problem it can often take more effort to sort it out than to have done your own from the start.

Having said that, a quick google suggests that this page may be of use:

https://jenda.hrach.eu/w/rpi-gcc


I had already read about the compiler, an old version is kept in Raspbian for compatibility with Raspberry pi 1, but I was not convinced by the solution.

So I tried again with VirtualBox, and again problems, it installed well, also without problems to configure everything, but when trying to Start it gave me an error, I tried to solve it, but it could not be. I already activated virtualization in the BIOS because before it did not allow me to install 64bit versions, only 32bit and with problems.

So I looked for a Debian version for ARM, not Raspbian, there is a Debian ARM that does have the GCC compiler updated to the latest version. It has also been somewhat complicated because there are enough differences with Raspbian to configure the IP, SSH and WIFI, but finally I managed to start it, and again I started to compile buildroot in the Raspberry pi4.

And there is now the Raspberry pi 4 with Debian compiling buildroot, to see if there is luck and it does not give errors.

The truth is that it is a nightmare, I found three options, and two of them gave me an error, and the third was being very complicated:
1.- PC with Virtualbox and Linux Debian
2.- Raspberry pi 4 with Raspbian
3.- Raspberry pi 4 with Debian 10.

If all fail, then I will order a new SSD disk for my PC to install a Linux version.
« Last Edit: May 26, 2021, 04:49:43 pm by luiHS »
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 6948
  • Country: fr
Re: Quick boot on Raspberry for embedded application
« Reply #20 on: May 27, 2021, 12:01:09 am »
I have a CM4 with 8Gb flash, I will try to do it with it, although if I have to compile I suppose it will be very slow.

Compile what?
 

Offline artag

  • Frequent Contributor
  • **
  • Posts: 659
  • Country: gb
Re: Quick boot on Raspberry for embedded application
« Reply #21 on: May 27, 2021, 01:09:25 am »
There are a couple of Pi distributions intended specifically for a media player.
Wouldn't they be a good starting point ?
 

Offline luiHS

  • Frequent Contributor
  • **
  • Posts: 459
  • Country: es
Re: Quick boot on Raspberry for embedded application
« Reply #22 on: May 27, 2021, 05:48:23 am »

Three tries and I had to cancel it because it was stuck during the compilation process.

Now I am following these instructions, they are similar but downloading the latest stable version of buildroot, and the compilation process is launched before configuring to add wifi, ssh and others.

https://armphibian.wordpress.com/2019/10/01/how-to-build-raspberry-pi-zero-w-buildroot-image/

If it fails me too, I'll buy an SSD for the PC, install Linux and do it again.

 

Offline luiHS

  • Frequent Contributor
  • **
  • Posts: 459
  • Country: es
Re: Quick boot on Raspberry for embedded application
« Reply #23 on: May 27, 2021, 05:49:17 am »
There are a couple of Pi distributions intended specifically for a media player.
Wouldn't they be a good starting point ?

Problem is only the boot time. I prefer build a custom version with only the essential for fast boot.
 

Offline luiHS

  • Frequent Contributor
  • **
  • Posts: 459
  • Country: es
Re: Quick boot on Raspberry for embedded application
« Reply #24 on: May 27, 2021, 05:50:24 am »
I have a CM4 with 8Gb flash, I will try to do it with it, although if I have to compile I suppose it will be very slow.

Compile what?

buildroot

 

Offline luiHS

  • Frequent Contributor
  • **
  • Posts: 459
  • Country: es
Re: Quick boot on Raspberry for embedded application
« Reply #25 on: May 27, 2021, 06:57:13 am »
 
Fourth and last attempt, and the same thing happens again, there comes a time that it becomes locked and no longer continues. In htop I  see four compilation processes (I suppose) in state D. All this on a Raspberry pi4 with Debian 10 (not Raspbian).

I have ordered an SSD to install a Linux on my PC and try again.

« Last Edit: May 27, 2021, 06:58:51 am by luiHS »
 

Offline dunkemhigh

  • Super Contributor
  • ***
  • Posts: 2879
Re: Quick boot on Raspberry for embedded application
« Reply #26 on: May 27, 2021, 08:28:41 am »
Quote
All this on a Raspberry pi4 with Debian 10 (not Raspbian)

I'm a bit confused with this - I thought you were building in a VM on a PC, but this suggests you're running it on an actual Pi?
 

Offline paf

  • Regular Contributor
  • *
  • Posts: 65
Re: Quick boot on Raspberry for embedded application
« Reply #27 on: May 27, 2021, 11:06:09 am »
A good light Linux distribution for Raspberry is Diet Pi:
https://dietpi.com

You want fast boot times and WifI?
Wifi takes some time to connect. 
 

Offline dunkemhigh

  • Super Contributor
  • ***
  • Posts: 2879
Re: Quick boot on Raspberry for embedded application
« Reply #28 on: May 27, 2021, 11:35:36 am »
Quote
Wifi takes some time to connect.

But booting doesn't have to wait for that to complete. Or even start.
 

Offline paf

  • Regular Contributor
  • *
  • Posts: 65
Re: Quick boot on Raspberry for embedded application
« Reply #29 on: May 27, 2021, 03:00:32 pm »
Quote
Wifi takes some time to connect.

But booting doesn't have to wait for that to complete. Or even start.

Yes, you are right.  But he wants to use the system through the Wifi network, so while Wifi is connecting the system has already booted, but he cannot use it...   
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 6948
  • Country: fr
Re: Quick boot on Raspberry for embedded application
« Reply #30 on: May 27, 2021, 05:52:13 pm »
As I've said and others have said, just use an existing, ready-to-use distro, and uninstall whatever you don't need. As I already said, the thing that will matter most is X and the desktop environment. By disabling both just to have a command line when it boots should get you boot times within a few seconds.

I don't know exactly what you're going to do with this, but even if you need a GUI, you don't need a desktop environment. You may not even need X.

You can take a look at this for instance: https://jmeosbn.github.io/blog/minimal-raspbian-pi/
 

Offline luiHS

  • Frequent Contributor
  • **
  • Posts: 459
  • Country: es
Re: Quick boot on Raspberry for embedded application
« Reply #31 on: May 28, 2021, 04:02:17 pm »
 
Today I received the Samsung EVO 870 SSD hard disk that I ordered, and on Monday I will receive a Windows 10 that I ordered from the Microsoft Store.

I will take the opportunity to change my current Windows 7, for a Windows 10, and install both Linux Ubuntu and Windows 10 on the same SSD. I don't have the Windows 10 yet, so I'll install Ubuntu now and rerun the whole buildroot compilation process for Raspberry pi3 and 4.

All of the above (VirtualBox in W7 with Linux, buildroot compiled in Raspberry pi4) I already tried it and it did not work, also when I enabled virtualization in the BIOS to be able to create a 64bit Linux in VirtualBox it disabled the Windows7 license, and it did not work either VirtualBox, it gave me an error. I no longer waste time with those things, now I will work directly on Linux.

I have insisted on working with buildroot, because I have read of people who have achieved versions that boots even in less than 2 seconds, perfect for embedded applications. And from what I was seeing in the buildroot configuration menu there are a lot of options that allow you to create a custom linux only with what you need for the Raspberry. There are preconfigured configuration files for Raspberry 3 and 4, 32 and 64 bit, pretty much the only thing I modified was to include ssh and wifi then run the compilation with make, very easy.

« Last Edit: May 28, 2021, 04:05:27 pm by luiHS »
 

Offline luiHS

  • Frequent Contributor
  • **
  • Posts: 459
  • Country: es
Re: Quick boot on Raspberry for embedded application
« Reply #32 on: May 28, 2021, 06:51:36 pm »
 
With system-analyze I have been looking at the time it takes to start each service, and I see that dhcpcd takes a long time in relation to the others, just over 17 seconds.

Does anyone know if I can remove that service or optimize it so it doesn't take that long?. I have a static IP configured in /etc/dhcpcd.conf

Another thing I do not know is if my application does not start until all services have started. My application is for auto start in /etc/rc.local and does not need WIFI to work, I only put WIFI to access the system to upload files instead of doing it with an Ethernet cable.


« Last Edit: May 28, 2021, 06:54:47 pm by luiHS »
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 6948
  • Country: fr
Re: Quick boot on Raspberry for embedded application
« Reply #33 on: May 28, 2021, 09:38:54 pm »
I have insisted on working with buildroot, because I have read of people who have achieved versions that boots even in less than 2 seconds,

I see, and I admit I don't know what buildroot does exactly on RPi's.

On stock RPi's, the initial "boot" process is handled by the Video Core, and it is closed source. It does what is required to initialize the hardware, load a boot sequence from the SD card and hand it over to the main processor. That part itself takes about 2 seconds on average, even before any OS starts to boot. Does buildroot replace that? Is it even possible on RPi to replace the original bootloader executed on the Video Core?
 

Offline luiHS

  • Frequent Contributor
  • **
  • Posts: 459
  • Country: es
Re: Quick boot on Raspberry for embedded application
« Reply #34 on: May 29, 2021, 04:14:06 pm »
Does buildroot replace that? Is it even possible on RPi to replace the original bootloader executed on the Video Core?


I do not know it, my knowledge about Linux is quite scarce, a few commands from when I managed a dedicated server that I had years ago, and some basic things in Raspberry.

I just googled the way to boot a Raspberry as fast as possible, and the buildroot seems to be the fastest of all.

On the other hand, the configuration is simple and very complete, select one of the presets that are already defined (raspberrry, 3, 4, zero, 32 or 64 bit), run the menuconfig program, select what we want to add and compile with make, I just added ssh and wifi.
« Last Edit: May 29, 2021, 04:48:09 pm by luiHS »
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 6948
  • Country: fr
Re: Quick boot on Raspberry for embedded application
« Reply #35 on: May 29, 2021, 08:59:54 pm »
OK, I think the bootloader on RPis can't be bypassed, and as I said, it lasts about 2 seconds from power on to the OS booting. You'll see that if a display is connected - it displays some kind of rainbow image, and the OS then starts to boot when the image disappears.

So, the overall boot time (from power on) will always be over 2 seconds. In my experience 3 to 5 is achievable. Less than this, I don't think so. Just so you know what to expect.
 

Offline eti

  • Frequent Contributor
  • **
  • Posts: 500
  • Country: gb
Re: Quick boot on Raspberry for embedded application
« Reply #36 on: June 03, 2021, 03:45:00 am »
Why not just boot directly from a USB 3 SSD? Wouldn't this be quick enough? It may not be the cheapest solution, but might be the easiest.

As noted above, you could also turn off unwanted services for extra speed: e.g.
systemctl disable bluetooth
systemctl stop bluetooth

Yep. I timed my Pi 400 booting from a "Leven" JS-600 SSD in a USB 3 caddy, to be around 15 seconds from cold.
 

Offline eti

  • Frequent Contributor
  • **
  • Posts: 500
  • Country: gb
Re: Quick boot on Raspberry for embedded application
« Reply #37 on: June 03, 2021, 03:47:51 am »
not sure you can play videos on the Pi with this minimal linux distro ?

"omxplayer" can play videos without a window a window manager, that's if you can stop it crashing.
 

Offline Monkeh

  • Super Contributor
  • ***
  • Posts: 7145
  • Country: gb
Re: Quick boot on Raspberry for embedded application
« Reply #38 on: June 03, 2021, 03:56:00 am »
I see, and I admit I don't know what buildroot does exactly on RPi's.

The same thing it does on everything else. It's a suite of tools for (cross)compiling a kernel and userspace for embedded applications. It has nothing to do with the bootloader or the hardware of a Pi.


Fourth and last attempt, and the same thing happens again, there comes a time that it becomes locked and no longer continues. In htop I  see four compilation processes (I suppose) in state D. All this on a Raspberry pi4 with Debian 10 (not Raspbian).

You appear to have essentially deadlocked it by running catastrophically out of RAM.

This is what happens when you try and use an embedded system as a workstation.
 

Offline girishv

  • Regular Contributor
  • *
  • Posts: 91
  • Country: in
Re: Quick boot on Raspberry for embedded application
« Reply #39 on: June 05, 2021, 06:44:43 am »
Anyone with experience in the field?

I just need Wifi and the UART. If there was an .img file to create the SD, all the better, because it is complex for me to have to compile and it can take hours before it does not work.
The OpenWRT build system is pretty straight forward. But, you need a working linux system with development libraries installed. As you pointed out it takes few hours to get the build system up and running.

Send a personal message if you want an image.
 

Offline DiTBho

  • Frequent Contributor
  • **
  • Posts: 755
  • Country: gb
Re: Quick boot on Raspberry for embedded application
« Reply #40 on: June 05, 2021, 09:31:38 am »
the bootloader on RPis can't be bypassed

There are some experimental attempts. Guys trying to crack the binary code.
It still doesn't work and I think it won't be added to any official repository for a long time.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf