Network boot the Raspberry Pi from a PXE server or similar

From being powerer-on the Pi has, AIUI, to find bootloader code on an SD card. But there is nothing to stop that bootloader code fetching further executable code from across a network.

Have any of you guys already tried booting the Pi from an image which is stored on a server? What Pi bootloader did you use? Is there one that you would recommend? I don't need or want any flexibility or complexity such as command line operation or menus or the ability to boot from multiple sources. A bootloader that does the minimum to carry out a network boot (with adequate diagnostics if things went wrong) would be good.

I have seen forum posts which suggest loading a minimal Linux and a ramdisk just to run a network boot but that should not be necessary. All that should be required is:

  1. GPU loads bootloader file from SD card and starts CPU running it
  2. Bootloader does DHCP and TFTP to get and vet a file from the network.

After that the bootloader can just start executing the file that it has loaded. That file will do the rest.

Anyone already tried this?

James

Reply to
James Harris
Loading thread data ...

There are several threads in the Net. The trick is using U-Boot for network booting.

Google for 'raspberry pi u-boot'.

--

Tauno Voipio
Reply to
Tauno Voipio

Thanks but that's fairly horrible. It is *far* from small. I tried following

formatting link
but the u-boot directory structure I have just downloaded via git is over 100Mbytes. Its Makefile alone is over 1400 lines. I'm not sure I want to trust that it will not harm my system even if I work out how to configure it from the README file which is over 6000 lines long.......

A much more lightweight TFTP boot option would be a lot better.

James

Reply to
James Harris

It seems to me that you need to create your own bare-metal code if U-Boot does not fit the bill.

The main difference from the other Linux system is that you need to do most of the SD card booting, replacing the ARM kernel image with the bootloader code. There must be the GPU boot files in the first partition (formatted as FAT32) of the SD card.

The U-Boot size comes from the countless options and hosts for the code. The generated run image is not so large. Anyway, you need suitable drivers for the network interface in the boot loader image in addition to the IP, UDP, TFTP and maybe BOOTP/DHCP code for network booting.

--

-TV
Reply to
Tauno Voipio

I'd like to do the opposite, use the Pi as the PXE server.

--

They who can give up essential liberty to obtain a little temporary safety, 
 deserve neither liberty nor safety. - Ben Franklin
Reply to
G. Morgan

That is no problem, just install and configure DHCP server and TFTP server packages.

Reply to
Rob

easy enough I suppose if your bootloader contains a USB stack.

--
umop apisdn
Reply to
Jasen Betts

It's not going to happen - unless you write the TFTP bootloader then put it on the SD card.

Basically, the SD card is crucial to the Pi booting - it won't boot without it.

One option might be to put the kernel on the SD card then NFS mount the rest of it from a server. Myself and others are doing this.

Gordon

Reply to
Gordon Henderson

...

...

...

...

Interesting that you should say that. It is not relevant to the query but what I want the bootloader for is bring in my own bare-metal code from a server.

Because the program that I want to load across the network won't run under an operating system it will have no debugging facilities or even console IO facilities so any debugging will have to be by making changes to the code, rebooting, and seeing the effects. It is because that will happen so often that moving each new version across via SD card would quickly become onerous.

"The other Linux system"?

Yes, all that would be needed and enough USB support because, AIUI, the Pi's NIC sits behind the USB subsystem. Not practical.

It's good to know that the final uboot image is not so large. I may come back to uboot if I don't find a better option.

I am surprised that there isn't a prebuilt binary network bootloader for the Pi. For network booting all settings can be on a server so the network bootloader would need no customisation for each site. One PXE bootloader could boot them all....

James

Reply to
James Harris

If you just want to avoid the sd-card swapping then raspbootin might fit your needs. But it runs via a serial line, not ethernet. We used that in a project.

formatting link

greez

Reply to
Stefan Enzinger

You may want to look at the industrial version of the Pi then. That can boot via the USB OTG port (not present on the Pi). My understanding is that you can plug it into a PC emulating a USB storage device, then get the Pi to boot off it.

formatting link

Gordon

Reply to
Gordon Henderson

The Compute Module will try to boot from USB-OTG if there is no boot image available on the onboard flash storage - exactly the same as the Model A Pi can do via its USB port and SD card.

The main use for this is to load a USB Mass Storage Driver which allows the CM/PI-A's storage to be available as USB mass-storage to load a boot image on it.

Reply to
Dom

Ah, it's the other way round - that probably makes more sense. Didn't realise it could be done on the A either. Will get one on Monday while waiting on my CM to arrive to make sure I can boot it!

Cheers,

Gordon

Reply to
Gordon Henderson

Thanks

--

They who can give up essential liberty to obtain a little temporary safety, 
 deserve neither liberty nor safety. - Ben Franklin
Reply to
G. Morgan

That looks good. Since my code will be small, loading via serial port would be plenty fast enough.

I take it the above programs should work with something like one of these:

formatting link
formatting link

One problem is that serial cables have to be relatively short and I don't have a Unix host near where I want the Pi to be. (It looks like the raspbootcom component needs to run on Unix.) So network boot would still be better but I guess I can set something up. I might even be able to run a Unix in a VM and serve the Pi from there.

Incidentally, if anyone else is interested in bare-metal programming on the Pi I found some potentially useful links

formatting link
formatting link
formatting link
formatting link

James

Reply to
James Harris

Yes, I know. I had in mind the SD card having something like a PXE client on it. Then the Pi would effectively boot across the network; the PXE client would take the place of a PXE ROM.

James

Reply to
James Harris

For what value of Short? OK, slow old modem but I once ran one on the end of several metres of ribbon cable.

--
Regards 
Dave Saville
Reply to
Dave Saville

Im my experience serial works over distances at least as great as the upper limit for ethernet (90m). If that isn't enough, put RS485 drivers at each end and go up to a couple of kilometres.

--
Alan Adams, from Northamptonshire 
alan@adamshome.org.uk 
http://www.nckc.org.uk/
Reply to
Alan Adams

Good point that serial cables can be long - for some value of long - especially with low data rates but the GPIO voltage is much lower than normal so doesn't have the same drive ability.

James

Reply to
James Harris

With a small external PSU you could use a pair of simple line-driver chips which will handle the distance. Something like a current-loop RS-422 setup will work over much distance at lowish speeds.

I have worked with plain RS-232 on up to 19,200 bps over 20+ meters of shielded cable, and 9,600 bps (can't remember the format of that one) with a several hundreds of meters of shielded cable.

Reply to
Dom

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.