User avatar
Gavinmc42
Posts: 3161
Joined: Wed Aug 28, 2013 3:31 am

Barebox

Thu May 16, 2019 6:12 am

I have used U-boot on Linux devices before but this one is new to me.
https://www.barebox.org/doc/latest/user ... anual.html

USB and framebuffer are interesting, this is a bit more than uart console.
There is stuff in there that I have seen in Busybox and Toybox, i2cprobe(i2cdetect?) etc

Has anyone tried it on Pi's?
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

epoch1970
Posts: 3049
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Barebox

Thu May 16, 2019 12:04 pm

I see that as the quarrel between germans brothers (Denx and Pengutronix)

If you read this old presentation the reasons for forking u-boot into barebox exposed back in the day are, I believe, not all still relevant today.
In the meantime I don't think Barebox has acquired a very large user base. I could be wrong.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

hippy
Posts: 5353
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Barebox

Thu May 16, 2019 9:14 pm

I hadn't heard of it either and it looked interesting to me. Managed to get it built on my Pi 3B but haven't had time to check it boots. Took about 5 minutes in total -

Code: Select all

sudo apt-get install bison
sudo apt-get install flex
sudo apt-get install lzop
cd ~
git clone https://github.com/avian2/barebox.git
cd barebox
export ARCH=arm
make rpi_defconfig
make -j1
sudo cp images/barebox-raspberry-pi-3.img /boot/barebox.img

Acknowledgements to : https://www.tablix.org/~avian/blog/arch ... om_barebox

User avatar
Gavinmc42
Posts: 3161
Joined: Wed Aug 28, 2013 3:31 am

Re: Barebox

Fri May 17, 2019 1:51 am

Thanks guys, interesting links.

Barebox is a mix of boot loader and Linux
I like the options of choosing OS's.
With the network stuff, picking and loading the OS from a server?

Wonder if I can expand the framebuffer stuff into an OpenVG GUI.
This could be fun, it looks like a mini OS with integrated shell and editor :o
Could I toss away Linux?
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

hippy
Posts: 5353
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Barebox

Fri May 17, 2019 9:53 am

Gavinmc42 wrote:
Fri May 17, 2019 1:51 am
This could be fun, it looks like a mini OS with integrated shell and editor :o
Could I toss away Linux?
Those were my exact thoughts. Looks like a reasonably comprehensive 'bootable bare metal C' implementation which could be leveraged for other things. I had some fun building Windows PE set-ups back in the day and this looks similar for Linux.

User avatar
Gavinmc42
Posts: 3161
Joined: Wed Aug 28, 2013 3:31 am

Re: Barebox

Fri May 17, 2019 11:29 am

Bit longer on a Pi3B ;)
I think it defaults to serial console only, I get the 4 colour screen.
Time to play with make menuconfig, same method as Buildroot?
Yep looks like it , need ncurses dependencies first.

This could take a while, where is the frame buffer hiding?
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

User avatar
Gavinmc42
Posts: 3161
Joined: Wed Aug 28, 2013 3:31 am

Re: Barebox

Fri May 17, 2019 11:52 am

Generates a 362KB kernel so nice and small.
So baremetal I need to dig out a serial console gadget to see if is working.
Yep Buildroot stuff, so much fun working through those menu configs, not.

But at least I now have a C baremetal toolset that I am happy to work with.
Been trying small Linux, none small/simple enough to suit me.
Yocto was not bad, my Go based PunkOS OpenVG Demo Desktop just worked but still 600MB :lol:
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

hippy
Posts: 5353
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Barebox

Fri May 17, 2019 4:43 pm

Gavinmc42 wrote:
Fri May 17, 2019 11:29 am
I think it defaults to serial console only
Needing the serial console is why I haven't tried booting it yet. There's some docs here which may help -

https://www.barebox.org/doc/latest/user ... anual.html
Gavinmc42 wrote:
Fri May 17, 2019 11:29 am
Bit longer on a Pi3B ;)
Odd. Under 3 minutes for me on my 3B (non-plus), with the previous deleted and starting over again with cloning from .git

I wanted to add an "export KBUILD_OUTPUT=./build" as recommended by the documentation.
Gavinmc42 wrote:
Fri May 17, 2019 11:29 am
Time to play with make menuconfig, same method as Buildroot? ... where is the frame buffer hiding?
"Sort of" was how it felt to me. Not sure if just enabling framebuffer / console framebuffer is enough to get a USB keyboard + HDMI console working.

Please do post a 'How To' update if you get that working, move on to doing interesting things.

User avatar
Gavinmc42
Posts: 3161
Joined: Wed Aug 28, 2013 3:31 am

Re: Barebox

Fri May 17, 2019 11:23 pm

make -j1
I just copied your instructions, hit return just as I realized I had 4 cores - make -j4 ;)

All my uart to FTDI USB serial dongles are at work, might have to use another Pi and some wires.
That means cleaning up the desk and another monitor etc.

Time to make that portable serial console with LCD?
Wonder what I can use to make that, I know - Barebox ;)
Time also to learn about that overlay stuff, perhaps the display stuff uses that?
Got some A+'s that don't have a home, Serial LCD consoles?

Pi's = non stop learning.
Sometimes I feel like i'm living Wack-a-mole life, learn this, no learn that, don't forgot to learn those, google what I forgot I learned 2 years ago.....
That last one is annoying...
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

hippy
Posts: 5353
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Barebox

Sat May 18, 2019 12:39 am

Gavinmc42 wrote:
Fri May 17, 2019 11:23 pm
make -j1
I just copied your instructions, hit return just as I realized I had 4 cores - make -j4 ;)
I have been bitten by "-j4" induced make failures in the past so have got into the habit of substituting with "-j1" which solved it back then. "make -j1" is the under 3 minute compilation I'm getting.

jahboater
Posts: 4439
Joined: Wed Feb 04, 2015 6:38 pm

Re: Barebox

Sat May 18, 2019 6:13 am

Or just "make", it defaults to one CPU.

I use

make -j `nproc`

User avatar
Gavinmc42
Posts: 3161
Joined: Wed Aug 28, 2013 3:31 am

Re: Barebox

Sat May 18, 2019 7:34 am

Barebox on Pi's goes back at least 2012 and is on noobs :o
Time to try Noobs and PINN and just see what is available these days.

Got so focused on my little world I don't notice other stuff, probably more it did not means anything to me at the time.

This does look like a way to play with a babyboot/Linux/shell which has devicetree support.
Because it complies much faster than the real Linux, it makes for quicker learning how Buildroot/devicetree work.

It has taken me years to learn enough to go back to things like this and AJ Starks OpenVG code that has just been sitting there for years.
Thanks to RPF having this forum that goes back to the start of Pi's, things are just siting there waiting for google to find them.

Wonder what other little gems are out there?
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

User avatar
Gavinmc42
Posts: 3161
Joined: Wed Aug 28, 2013 3:31 am

Re: Barebox

Sat May 18, 2019 8:11 am

Somethings are right in your face and you don't notice them :oops:
Noobs and PINN are mini boot OS's that let you pick OS's.
But they fire up with device tree stuff and HDMI console.

How do these two things work?
The Lite versions, not that small at 36 and 44MB.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

User avatar
procount
Posts: 1651
Joined: Thu Jun 27, 2013 12:32 pm
Location: UK

Re: Barebox

Sat May 18, 2019 11:07 am

If you add "rescueshell" to recovery.cmdline in noobs or pinn, it will dump you straight to a command shell (ash) to play about in.
Add "ssh" to pinn and you can remote into it as well.
PINN - NOOBS with the extras... https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=142574

User avatar
Gavinmc42
Posts: 3161
Joined: Wed Aug 28, 2013 3:31 am

Re: Barebox

Sat May 18, 2019 12:16 pm

If you add "rescueshell" to recovery.cmdline in noobs or pinn, it will dump you straight to a command shell (ash) to play about in.
Add "ssh" to pinn and you can remote into it as well.
Thanks, that's very interesting, more learning- tomorrow :D

I'm busy trying to figure out device overlays for 480x320 LCDs.
The 7"Pi LCD just worked, but the Waveshare and 4DSystems might need more than just a hour or two to sort out.
Drivers are older than the kernels I am using.
Gone back to PiCore 9.03 to try getting the LCDs working there first.

Might have to do hardware GPIO bitbanging,
Probably should spend some time learning device overlays, seems to be a trend.
HDMI is so much easier, Waveshare now have HDMI from 3.5", that configuration also reduce the thickness.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

hippy
Posts: 5353
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Barebox

Sun May 19, 2019 1:43 pm

jahboater wrote:
Sat May 18, 2019 6:13 am
Or just "make", it defaults to one CPU.
I'm no linux expert so it was mostly a case of 'if you don't know what you're doing; stick with what you know works'. When -j4 created problems I used -j1 to force single job and it worked so stuck with that. The document I read was not clear on what leaving -j out did. With hindsight, having read 'man make', I think it was a lack of clarity in that document over leaving -j out or just the number after -j out.

Thanks for the info and provoking me to go and properly read-up on make.

jahboater
Posts: 4439
Joined: Wed Feb 04, 2015 6:38 pm

Re: Barebox

Sun May 19, 2019 4:15 pm

hippy wrote:
Sun May 19, 2019 1:43 pm
jahboater wrote:
Sat May 18, 2019 6:13 am
Or just "make", it defaults to one CPU.
I'm no linux expert so it was mostly a case of 'if you don't know what you're doing; stick with what you know works'. When -j4 created problems I used -j1 to force single job and it worked so stuck with that. The document I read was not clear on what leaving -j out did. With hindsight, having read 'man make', I think it was a lack of clarity in that document over leaving -j out or just the number after -j out.
For interest, I think make was around for decades before multi-core CPU's and the -j option.

hippy
Posts: 5353
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Barebox

Tue Jul 02, 2019 3:31 pm

Finally got round to trying barebox and it works quite nicely. It does need a UART connection, only the rainbow screen shows on the display.

I tried creating my own command, but seem to have got trapped in a make clean, make menuconfig, make mrproper, make, loop. Not quite sure what I've done wrong or missed. Not really sure what I am meant to be doing to be honest.

Anyone have any HowTo for adding commands or a pointer to one ?

Has anyone got creating and using the frame buffer working ?

User avatar
Gavinmc42
Posts: 3161
Joined: Wed Aug 28, 2013 3:31 am

Re: Barebox

Wed Jul 03, 2019 2:22 am

I had forgotten this, I'm getting old.

Now that we have a Pi with lots of Uarts and two screens for development, time to get back to this.
Wonder how fast Buildroot is on Pi4's?

Could Barebox be used as a Pi4 OS selector on boot?
Nice big USB3 HDD with multiple partitions with different OS's in each partition.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

hippy
Posts: 5353
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Barebox

Wed Jul 03, 2019 1:45 pm

Gavinmc42 wrote:
Wed Jul 03, 2019 2:22 am
Wonder how fast Buildroot is on Pi4's?
Pass. The problem with buildroot seems more that it seems an awful lot of work to use it. I guess that's easier after the first time, and I'm going by Cristophe's guide rather than having actually done it -

https://www.blaess.fr/christophe/articl ... -buildroot

I may have done some buildroot stuff when playing with diskless booting of zeroes, but whatever that was it ended up with me using WSL under Windows 10 to cross-compile because my Pi 3B couldn't handle it.

Barebox is, or was before I broke things, compact, quick and easy to compile and get working using only my Pi 3B.
Gavinmc42 wrote:
Wed Jul 03, 2019 2:22 am
Could Barebox be used as a Pi4 OS selector on boot?
I would say so given that appears to be its intended purpose and one can boot stock Buster from within barebox. That's a more convoluted set of commands than I'd like but I am sure it could be turned into something more user friendly -

Code: Select all

global linux.bootargs.vc="$global.vc.bootargs"
bootm -o /vc.dtb /boot/kernel7.img
Use a different .img and it should boot to that.

User avatar
procount
Posts: 1651
Joined: Thu Jun 27, 2013 12:32 pm
Location: UK

Re: Barebox

Thu Jul 04, 2019 3:51 pm

Gavinmc42 wrote:
Wed Jul 03, 2019 2:22 am
Wonder how fast Buildroot is on Pi4's?
I assume you mean how fast is it to build a system from buildroot?
Well, buildroot is used to build NOOBS and PINN.
Here are some times for building PINN on various RPis:

Code: Select all

Model:          Pi4         Pi3B+      Pi3B       Pi2B
Time(h:m:s):    03:34:10    06:04:23   07:00:05   11:50:44
Of course, this is a complete build including the kernel, rootfs and all the cross compilation tools after having downloaded all the source files. This is only done once and thereafter only the main program and occasionally the kernels are built which takes a lot less time (a few minutes).
Gavinmc42 wrote:
Wed Jul 03, 2019 2:22 am
Could Barebox be used as a Pi4 OS selector on boot?
Nice big USB3 HDD with multiple partitions with different OS's in each partition.
Why re-invent the wheel when you can just use PINN which is already designed to do this? Including backup/restore of each OS, password recovery, fsck etc. PINN supports up to 63 partitions and already works on the Pi4.
PINN - NOOBS with the extras... https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=142574

User avatar
Gavinmc42
Posts: 3161
Joined: Wed Aug 28, 2013 3:31 am

Re: Barebox

Fri Jul 05, 2019 8:06 am

Nice compile times on the Pi4 :D .
Why re-invent the wheel when you can just use PINN which is already designed to do this? Including backup/restore of each OS, password recovery, fsck etc. PINN supports up to 63 partitions and already works on the Pi4.
Thank, I don't use Noobs or PINN so did not know how they work.

Can PINN handle 32 and 64bit OS's :oops: Scratch that, just remembered you can do Gentoo64 now.

I only reinvent the wheel so I learn how to make wheels ;)
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

Return to “Bare metal, Assembly language”