ejolson
Posts: 3555
Joined: Tue Mar 18, 2014 11:47 am

Re: Raspberry Pi 4 usb boot?

Sun Sep 08, 2019 9:13 pm

rpdom wrote:
Sun Sep 08, 2019 7:36 pm
ejolson wrote:
Sun Sep 08, 2019 7:15 pm
jdb wrote:
Sun Sep 08, 2019 5:29 pm
Then make a chainloader. USB boot is intentionally limited in scope to "find the first valid boot disk and boot from it".
I'm trying to make a chain loader. It will be called slug.

Do you have any idea how to make kexec work on the Raspberry Pi?

How does NOOBS do it?
NOOBS doesn't use kexec. It uses a flag in the SoC (somewhere under /sys) that specifies which partition to use for the next boot, then performs a reboot.
That is my understanding as well. Is there any documentation? What are the details?

trejan
Posts: 569
Joined: Tue Jul 02, 2019 2:28 pm

Re: Raspberry Pi 4 usb boot?

Sun Sep 08, 2019 9:58 pm

ejolson wrote:
Sun Sep 08, 2019 9:13 pm
rpdom wrote:
Sun Sep 08, 2019 7:36 pm
NOOBS doesn't use kexec. It uses a flag in the SoC (somewhere under /sys) that specifies which partition to use for the next boot, then performs a reboot.
That is my understanding as well. Is there any documentation? What are the details?
/sys/module/bcm270x/parameters/reboot_part is long gone and was removed with the change to preferring the upstream kernel drivers.

NOOBS now passes the partition using the reboot syscall with the magic number for LINUX_REBOOT_CMD_RESTART2 and the partition as the command. The watchdog driver picks up that value and sets the PM_RSTS register to indicate which partition to boot from.

The odd way it jams the value into the register is because PM_RSTS is meant to show the reset reason with bits for various types of software, watchdog and debugger resets but it is being (ab)used to pass the value to the firmware.

ejolson
Posts: 3555
Joined: Tue Mar 18, 2014 11:47 am

Re: Raspberry Pi 4 usb boot?

Mon Sep 09, 2019 2:09 am

trejan wrote:
Sun Sep 08, 2019 9:58 pm
ejolson wrote:
Sun Sep 08, 2019 9:13 pm
rpdom wrote:
Sun Sep 08, 2019 7:36 pm
NOOBS doesn't use kexec. It uses a flag in the SoC (somewhere under /sys) that specifies which partition to use for the next boot, then performs a reboot.
That is my understanding as well. Is there any documentation? What are the details?
/sys/module/bcm270x/parameters/reboot_part is long gone and was removed with the change to preferring the upstream kernel drivers.

NOOBS now passes the partition using the reboot syscall with the magic number for LINUX_REBOOT_CMD_RESTART2 and the partition as the command. The watchdog driver picks up that value and sets the PM_RSTS register to indicate which partition to boot from.

The odd way it jams the value into the register is because PM_RSTS is meant to show the reset reason with bits for various types of software, watchdog and debugger resets but it is being (ab)used to pass the value to the firmware.
These code references are very helpful. It looks like rebootp in PINN

https://github.com/procount/pinn/blob/m ... /rebootp.c

is using the same mechanism.

trejan
Posts: 569
Joined: Tue Jul 02, 2019 2:28 pm

Re: Raspberry Pi 4 usb boot?

Mon Sep 09, 2019 2:41 am

ejolson wrote:
Mon Sep 09, 2019 2:09 am
These code references are very helpful. It looks like rebootp in PINN

https://github.com/procount/pinn/blob/m ... /rebootp.c

is using the same mechanism.
Yeah. The rebootp utility is so you can manually change it from the recovery shell. The PINN boot menu uses the syscall directly like NOOBS

rtfmoz
Posts: 17
Joined: Wed Mar 27, 2013 8:39 pm

Re: Raspberry Pi 4 usb boot?

Tue Oct 08, 2019 11:06 pm

asavah wrote:
Sun Sep 01, 2019 4:16 pm
bjtheone wrote:
Sun Sep 01, 2019 3:02 pm
If the EEPROM is writable and accessible it is hackable.
To make use of "hackable" EEPROM on the pi4 one would need to:
1a) hack the os remotely and gain root access.
or
1b) have local physical access

2) Have deep knowledge of VC4/6 hardware and software architecture and have knowledge of and access to all the needed tools to build their own bootloader code which is closed source and AFAIK is very peculiar architecture, I think the amount of people in the world capable of writing their own malicious vc4/6 bootloader is very small, like a dozen or two of persons.

Please stop spreading the FUD.
Hi, I have security concerns as well and its quite interesting that you call this FUD. I can guarantee you blackhats will be looking at how to exploit a writable boot EEPROM on Pi4. It's literally a treasure chest. Mind you the use case will be interesting as they need to reach the device to reprogram it. When they do they would probably see the Linux OS as a goldmine anyway and its raw capability to act the perfect launchpad for network forensics in preparation for a coming intrusion. Expect said tools coming to a security conference near you, if not already.

Anyway, this is off-topic. Thanks for the hard work bringing out the Pi4 and we look forward to new boot code with new features. If you have any blog posts regarding the security of the Pi4 can you point me to them, please?

pepeEL
Posts: 79
Joined: Thu Feb 26, 2015 11:23 am

Re: Raspberry Pi 4 usb boot?

Fri Oct 11, 2019 6:45 am

Hi
Any news about boot from USB on RPI4 ?

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 23647
Joined: Sat Jul 30, 2011 7:41 pm

Re: Raspberry Pi 4 usb boot?

Fri Oct 11, 2019 8:34 am

pepeEL wrote:
Fri Oct 11, 2019 6:45 am
Hi
Any news about boot from USB on RPI4 ?
No, which is why we haven't announced any news.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

pepeEL
Posts: 79
Joined: Thu Feb 26, 2015 11:23 am

Re: Raspberry Pi 4 usb boot?

Fri Oct 11, 2019 9:40 am

Because i see that network boot was added....

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 23647
Joined: Sat Jul 30, 2011 7:41 pm

Re: Raspberry Pi 4 usb boot?

Fri Oct 11, 2019 9:43 am

pepeEL wrote:
Fri Oct 11, 2019 9:40 am
Because i see that network boot was added....
Yes, network boot has been added. Nothing to do with USB boot though, which will be announced when it's ready. Still a few months away I suspect.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

pepeEL
Posts: 79
Joined: Thu Feb 26, 2015 11:23 am

Re: Raspberry Pi 4 usb boot?

Fri Oct 11, 2019 11:00 am

It's good if it would be done faster than a few months ... because a lot of people are waiting for it.

User avatar
clicky
Posts: 387
Joined: Thu Oct 25, 2012 7:34 am

Re: Raspberry Pi 4 usb boot?

Fri Oct 11, 2019 11:24 am

pepeEL wrote:
Fri Oct 11, 2019 11:00 am
It's good if it would be done faster than a few months ... because a lot of people are waiting for it.
Here we go again. :roll:
The people that are waiting on it could apply one of the simple workarounds and could go on with their life...

dickon
Posts: 471
Joined: Sun Dec 09, 2012 3:54 pm
Location: Home, just outside Reading

Re: Raspberry Pi 4 usb boot?

Fri Oct 11, 2019 11:25 am

It's quite a complicated thing. Much moreso than network, I would think. For network, you only need to write a driver for the hardware -- surprisingly simple in most cases; I did one for the DEC Tulip back in the day, and it wasn't much over about a 1000 lines of assembly, if that -- and enough of a UDP/IP stack (with trivial ARP, DHCP, and TFTP implementations; none of which is difficult) to load the next-stage.

For USB you've got to initialise the hardware, enumerate all the devices, handle hubs, ideally handle as many quirks as possible, and then you've got to have enough of a SCSI stack -- the USB mass-storage protocol is basically SCSI over USB -- to start probing the attached discs to read stuff from. After than you can hand it off to the partition and FAT parsers you've already got for the SD card mode, but there's still a lot of work to be done. All in, AIUI, about 32K of ROM space.

Not a simple job.

pepeEL
Posts: 79
Joined: Thu Feb 26, 2015 11:23 am

Re: Raspberry Pi 4 usb boot?

Fri Oct 11, 2019 11:36 am

clicky wrote:
Fri Oct 11, 2019 11:24 am
pepeEL wrote:
Fri Oct 11, 2019 11:00 am
It's good if it would be done faster than a few months ... because a lot of people are waiting for it.
Here we go again. :roll:
The people that are waiting on it could apply one of the simple workarounds and could go on with their life...
Please write manual if it is very simple....

User avatar
clicky
Posts: 387
Joined: Thu Oct 25, 2012 7:34 am

Re: Raspberry Pi 4 usb boot?

Fri Oct 11, 2019 11:43 am

pepeEL wrote:
Fri Oct 11, 2019 11:36 am
Please write manual if it is very simple....
It was already mentioned many times in this particular thread (and a few different approaches to it). Here is what I've done:
https://www.maketecheasier.com/boot-up- ... hard-disk/

It did take 2 minutes of my time and another I can't-remember-how-long for rsync to finish and it just worked. No big deal. And it is still working and I am using that RPi4 to write it from. :)

User avatar
B.Goode
Posts: 8514
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Raspberry Pi 4 usb boot?

Fri Oct 11, 2019 11:47 am

pepeEL wrote:
Fri Oct 11, 2019 11:36 am
clicky wrote:
Fri Oct 11, 2019 11:24 am
pepeEL wrote:
Fri Oct 11, 2019 11:00 am
It's good if it would be done faster than a few months ... because a lot of people are waiting for it.
Here we go again. :roll:
The people that are waiting on it could apply one of the simple workarounds and could go on with their life...
Please write manual if it is very simple....

It can be done trivially with the NOOBS Installer https://github.com/raspberrypi/noobs/bl ... /README.md, and equally easily with the better supported PINN https://www.raspberrypi.org/forums/view ... 3&t=142574

Or forum user @RonR has a utility to assist you. https://www.raspberrypi.org/forums/view ... 1#p1547589

pepeEL
Posts: 79
Joined: Thu Feb 26, 2015 11:23 am

Re: Raspberry Pi 4 usb boot?

Fri Oct 11, 2019 11:51 am

I want use Hassos system with Home Assistant.... it is other system.

dickon
Posts: 471
Joined: Sun Dec 09, 2012 3:54 pm
Location: Home, just outside Reading

Re: Raspberry Pi 4 usb boot?

Fri Oct 11, 2019 11:53 am

clicky wrote:
Fri Oct 11, 2019 11:43 am
It was already mentioned many times in this particular thread (and a few different approaches to it). Here is what I've done:
https://www.maketecheasier.com/boot-up- ... hard-disk/
Interesting (and accurate) set of instructions. I always

Code: Select all

sudo su -
to get a full login shell, where PATH is setup correctly, and I'd recommend removing the 'noatime' from the root stanza in /etc/fstab as it's quite useful and doesn't have the same issues on a proper HD that it does on an SD card (basically, the extra write duty won't be an issue on a proper device, which it is on an SD card).

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 23647
Joined: Sat Jul 30, 2011 7:41 pm

Re: Raspberry Pi 4 usb boot?

Fri Oct 11, 2019 12:04 pm

pepeEL wrote:
Fri Oct 11, 2019 11:00 am
It's good if it would be done faster than a few months ... because a lot of people are waiting for it.
It'll be done when it's done. Constant pestering will not make it appear any faster. And in the general scheme of things, no, a lot of people are not waiting for it. We are making 100 of thousands of Pi4's a WEEK. Compare that with the number of people asking for USB boot......
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

OneMore
Posts: 1
Joined: Thu Oct 10, 2019 2:30 pm

Re: Raspberry Pi 4 usb boot?

Fri Oct 11, 2019 12:08 pm

jamesh wrote:
Fri Oct 11, 2019 12:04 pm
... Compare that with the number of people asking for USB boot......
Other people are not asking... We just wait... :) By the way for hassio as well.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 23647
Joined: Sat Jul 30, 2011 7:41 pm

Re: Raspberry Pi 4 usb boot?

Fri Oct 11, 2019 12:09 pm

dickon wrote:
Fri Oct 11, 2019 11:25 am
It's quite a complicated thing. Much moreso than network, I would think. For network, you only need to write a driver for the hardware -- surprisingly simple in most cases; I did one for the DEC Tulip back in the day, and it wasn't much over about a 1000 lines of assembly, if that -- and enough of a UDP/IP stack (with trivial ARP, DHCP, and TFTP implementations; none of which is difficult) to load the next-stage.

For USB you've got to initialise the hardware, enumerate all the devices, handle hubs, ideally handle as many quirks as possible, and then you've got to have enough of a SCSI stack -- the USB mass-storage protocol is basically SCSI over USB -- to start probing the attached discs to read stuff from. After than you can hand it off to the partition and FAT parsers you've already got for the SD card mode, but there's still a lot of work to be done. All in, AIUI, about 32K of ROM space.

Not a simple job.
Spot on.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 23647
Joined: Sat Jul 30, 2011 7:41 pm

Re: Raspberry Pi 4 usb boot?

Fri Oct 11, 2019 12:10 pm

OneMore wrote:
Fri Oct 11, 2019 12:08 pm
jamesh wrote:
Fri Oct 11, 2019 12:04 pm
... Compare that with the number of people asking for USB boot......
Other people are not asking... We just wait... :) By the way for hassio as well.
I have no problem with people waiting, quietly.

Had to look up Hassio. No idea what it was.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

User avatar
clicky
Posts: 387
Joined: Thu Oct 25, 2012 7:34 am

Re: Raspberry Pi 4 usb boot?

Fri Oct 11, 2019 12:12 pm

dickon wrote:
Fri Oct 11, 2019 11:53 am
Interesting (and accurate) set of instructions. I always

Code: Select all

sudo su -
to get a full login shell, where PATH is setup correctly, and I'd recommend removing the 'noatime' from the root stanza in /etc/fstab as it's quite useful and doesn't have the same issues on a proper HD that it does on an SD card (basically, the extra write duty won't be an issue on a proper device, which it is on an SD card).
Would 'noatime' help with SSD and controller I have no idea if it implemented trim and such ("ostrich head in sand" is first association that came to me to describe my approach in this case)?

User avatar
clicky
Posts: 387
Joined: Thu Oct 25, 2012 7:34 am

Re: Raspberry Pi 4 usb boot?

Fri Oct 11, 2019 12:15 pm

pepeEL wrote:
Fri Oct 11, 2019 11:51 am
I want use Hassos system with Home Assistant.... it is other system.
If you don't need to copy root to your image (on HD) - even better - you just need to update `/boot/cmdline.txt` and that's all!

dickon
Posts: 471
Joined: Sun Dec 09, 2012 3:54 pm
Location: Home, just outside Reading

Re: Raspberry Pi 4 usb boot?

Fri Oct 11, 2019 12:27 pm

clicky wrote:
Fri Oct 11, 2019 12:12 pm
Would 'noatime' help with SSD and controller I have no idea if it implemented trim and such ("ostrich head in sand" is first association that came to me to describe my approach in this case)?
All noatime does is stop the kernel writing atime datestamps when files are read from. These are mostly delayed until things are written to anyway, but they're worth disabling on something as limited as an SD card. Personally I find atimes quite useful and I wouldn't disable them on a proper disc.

Code: Select all

ls -lu
is handy once in a while.

royhenderson
Posts: 55
Joined: Sat Apr 09, 2016 1:56 pm
Location: Scotland

Re: Raspberry Pi 4 usb boot?

Fri Oct 11, 2019 3:47 pm

jamesh wrote:
Fri Oct 11, 2019 9:43 am

Yes, network boot has been added.
Is there any documentation available regarding network boot on RPi-4? I've trawled the board but most of what I've found looks to be a series of solutions to encountered problems …

TIA

Return to “General discussion”