Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support for RaspberryPi4 mass storage boot #842

Open
jens-maus opened this issue May 22, 2020 · 6 comments
Open

Add Support for RaspberryPi4 mass storage boot #842

jens-maus opened this issue May 22, 2020 · 6 comments

Comments

@jens-maus
Copy link
Owner

@jens-maus jens-maus commented May 22, 2020

See here for a first beta bootloader for RaspberryPi4 which should support booting from USB/SDD storage:

https://www.raspberrypi.org/forums/viewtopic.php?t=274595

@Newbie-2
Copy link

@Newbie-2 Newbie-2 commented May 23, 2020

Hallo Jens, ich habe seit ca. 6 Monaten einen Pi4 mit einer SSD bei mir liegen, der auf den Einsatz Deiner RaspberryMatic wartet,. Der schon länger bekannte Workaround mit SDHC Karte als Bootdevice und dem Betriebssystem auf der SSD funktionierte mit der RaspberryMatic leider nicht.

Aktuell ist der offizielle Bootloader für die Besitzer des Pi4 freigegeben worden. Ich war schon voller Vorfreude, da sich sowohl Rasbian als auch LibreELEC mit dem Bootloader fehlrefrei auf dem Pi4 von der SSD starten lässt. Nur leider funktionierte auch mit dem offiziellen Bootloader die RaspberryMatic nicht. Ich würde mich sehr freuen, wenn Du das Startproblem der RaspberryMatic auf dem Pi4 von SSD beheben könntest. :-)

Aber jetzt zu meiner Anmerkung !!!
Wenn die RaspberryMatic ohne SDHC Karte nur von SSD läuft, wäre es aus meiner Sicht noch wichtig das Thema "Ausgelagerte Daten auf dem USB Stick" zu berücksichtigen. Die SSD hat ja viel mehr Platz als die RaspberryMatic braucht. Somit würde ich keinen USB Stick mehr für zB. CCU-Historian, Tages-Backup, oder andere ausgelagerte Daten benötigen.

Worauf müsste man noch achten und was muss in der RaspberryMatic umgestellt werden, um alle Daten auf die SSD auszulagern, die aktuell auf dem USB Stick gespeichert werden ?

1.) Könnte die RaspberryMatic automatisch erkennen, das die Software auf einer SSD läuft und das umrouten auf die SSD sebstständig durchführen
2.) Könnte die RaspberryMatic die SSD erkennen und den Benutzer fragen, oder auf einen Menüpunkt in der UI verweisen, mit dem jeder das Verzeichnis dann individuell auswählen kann. ?

Vorab schon einmal Danke für Deinen extrem guten Job der RaspberryMatic .
Viele Grüße Bernd

@jens-maus
Copy link
Owner Author

@jens-maus jens-maus commented Jun 6, 2020

FYI: After some own investigation on that matter, I do have unfortunately no good news yet. While the beta bootloader provided by the raspberrypi foundation seem to allow to boot via USB mass storage without the use of any SD card, the second level bootloader RaspberryMatic is using (U-Boot) doesn't seem to support the USB2/USB3 device of the RaspberryPi4 yet. The current debug output I could catch during a debug session ended up with memory initialization in U-Boot. See:

PM_RSTS: 0x00001000
RPi: BOOTLOADER release VERSION:b5de8c32 DATE: Jun  3 2020 TIME: 13:53:50 BOOTMODE: 0x00000006 part: 0 BUILD_TIMESTAMP=1591188827 0xd5423d97 0x00d03114
uSD voltage 3.3V
Initialising SDRAM 'Micron' 32Gb x2 total-size: 64 Gbit 3200
Boot mode: SD (01) order f4
SD HOST: 250000000 CTL0: 0x00000000 BUS: 100000 Hz actual: 100000 HZ div: 2500 (1250) status: 0x1fff0000 delay: 1080
SD HOST: 250000000 CTL0: 0x00000f00 BUS: 100000 Hz actual: 100000 HZ div: 2500 (1250) status: 0x1fff0000 delay: 1080
EMMC
SD HOST: 250000000 CTL0: 0x00000000 BUS: 100000 Hz actual: 100000 HZ div: 2500 (1250) status: 0x1fff0000 delay: 1080
SD HOST: 250000000 CTL0: 0x00000000 BUS: 100000 Hz actual: 100000 HZ div: 2500 (1250) status: 0x1fff0000 delay: 1080
SDV1
SD HOST: 250000000 CTL0: 0x00000000 BUS: 100000 Hz actual: 100000 HZ div: 2500 (1250) status: 0x1fff0000 delay: 1080
SD CMD: 0x371a0010 (55) 0x0 0x1fff0001
Failed to open device: 'sdcard' (cmd 371a0010 status 1fff0001)
Boot mode: USB-MSD (04) order f
VLI: HUB2: 0xfff00000 0x24e6 MCU: 0xfff20000 0x150d8
VL805 0xfff00000 0xfff20000
XHCI-STOP
xHC ver: 256 HCS: 05000420 fc000031 00e70004 HCC: 002841eb
xHC ports 5 slots 32 intrs 4
USB3 rport 2 status 00000000 -> 000002b1
USB3 rport 3 status 00000000 -> 000002a0
USB3 rport 4 status 00000000 -> 000002a0
USB3 rport 5 status 00000000 -> 000002a0
USB2 rport 1 status 00000000 -> 400002e1
USB2 rport 1 status 400002f1 -> 40200e03
root HUB port 1 init
DEV [01:00] 2.16 000000:01 class 9 VID 2109 PID 3431
HUB init [01:00] 2.16 000000:01
USB3 rport 2 status 000002b1 -> 00281203
root HUB port 2 init
DEV [02:00] 3.00 000000:02 class 0 VID 8564 PID 1000
MSD device [02:00] 3.00 000000:02 conf 0 iface 0 ep 82#1024 01#1024
MSD [02:00] 3.00 000000:02 register MSD
PM_RSTS: 0x00001000
MSD [02:00] 3.00 000000:02 LUN 0
MSD [02:00] 3.00 000000:02 lun 0 block-count 123404288 block-size 512
MBR: 0x00000001,  524288 type: 0x0c
MBR: 0x00080001, 2097152 type: 0x83
MBR: 0x00280001,    6000 type: 0x83
MBR: 0x00000000,       0 type: 0x00
lba: 1 oem: 'mkfs.fat' volume: '  V       ^ '
rsc 8 fat-sectors 256 c-count 65467 c-size 8 r-dir 1 r-sec 32
PM_RSTS: 0x00001000
Partition: 0
lba: 1 oem: 'mkfs.fat' volume: '  V       ^ '
rsc 8 fat-sectors 256 c-count 65467 c-size 8 r-dir 1 r-sec 32
Read config.txt bytes     1450 hnd 0x00002e8b hash '4c33513306bab35c'
recover4.elf not found (6)
recovery.elf not found (6)
Read start4.elf bytes  2274272 hnd 0x00000017 hash 'a71eea9d75519554'
Read fixup4.dat bytes     5407 hnd 0x00000015 hash 'e4ad9a0c1bb698cc'
0x00d03114 0x00000000 0x0000001f
MEM GPU: 76 ARM: 947 TOTAL: 1023
Starting start4.elf @ 0xfeb00200 partition 0

U-Boot 2020.04 (Jun 06 2020 - 23:02:29 +0200)

DRAM:  3.9 GiB
[no further output ending up with the standard rainbow color display on the HDMI]

Hence, it seems that U-Boot is not yet able to initialize/use any USB device and thus the USB boot capabilities of the latest RaspberryPi bootloader beta cannot be utilized by RaspberryMatic yet. Thus, we would need to wait until the U-Boot maintainers integrated USB support for the RaspberryPi4 in some future release.

So sorry, but I think one has to wait some more time until someone from the u-boot community (see https://github.com/u-boot/u-boot) has picked up the task to integrated USB support for the RaspberryPi4 hardware target in their bootloader.

Please note the following discussion link where the missing USB support in U-Boot for the RaspberryPi4 was already confirmed last year: https://www.raspberrypi.org/forums/viewtopic.php?t=244785#p1522518

UPDATE:
Please note that the U-Boot community already seem to have a working XHCI driver für the USB ports fo the RaspberryPi4. Here are some appropriate links to discussions about that:

https://lists.denx.de/pipermail/u-boot/2020-April/405216.html
https://lists.denx.de/pipermail/u-boot/2020-April/407895.html
https://lists.denx.de/pipermail/u-boot/2020-June/414411.html

And here are the links to patchsets to get XHCI support integrated.
https://patchwork.ozlabs.org/project/uboot/list/?series=179078
https://patchwork.ozlabs.org/project/uboot/list/?series=181081
https://patchwork.ozlabs.org/project/uboot/list/?submitter=75131

I also already applied these patches and USB2/USB3 seem to work with that in principle. Nevertheless, I am unfortunately still not able to get plain USB boot without any SD card involved running even with these patches applied. U-Boot then still stops hard after the DRAM init without any further (serial) debug output that would help me to get things solved.

So this still needs some more attention to get it finally done. But we are already on a good path IMHO because of the U-Boot community having ported the XHCI driver quite successfully.

jens-maus added a commit that referenced this issue Jun 7, 2020
working within U-Boot so that we hopefully get closer in getting
usb-mass-storage boot working on a rpi4 with latest beta bootloader.
This refs #842.
jens-maus added a commit that referenced this issue Jun 7, 2020
integrated. Note, however, that pure USB boot still does not work even
thought XHCI/USB3 support should work now with a rpi4. Thus, this still
needs some more investigation by the uboot people. This refs #842.
@Newbie-2
Copy link

@Newbie-2 Newbie-2 commented Jul 1, 2020

Hallo, da es aktuell wieder einige Post´s in den Raspberry Foren zum Thema Pi4 Bootloader gibt, wollte ich mal fragen, ob es schon positive Auswirkungen auf den Start der RaspberryMatic gibt, oder ob das Problem seitens des U-Boot noch nicht gelöst werden konnte ?

@Baxxy13
Copy link

@Baxxy13 Baxxy13 commented Jul 6, 2020

Ich bin diesbezüglich auch in Wartestellung. Musste aber feststellen das die Möglichkeit RaspberryMatic von USB zu booten weitere Probleme mit sich bringt.

  1. (siehe deine Anmerkung oben) es werden "Out of the Box" keine Backups sowie Diagrammdaten gespeichert da kein USB1 vorhanden ist.
  2. steckt man einen zusätzlichen USB-Stick ein fährt RaspberryMatic nicht mehr hoch weil der Bootloader nicht unterscheiden kann von wo er nun booten soll. Bei meinen Tests wurde immer nur der "nicht bootfähige" Stick erkannt
  3. eher ein Schönheitsproblem... die rote Raspi-LED wird nicht richtig angesprochen und blinkt daher im Sekundentakt auf.

Ich habe meine USB-Boot Erfahrungen (noch mit Pi3B+) hier festgehalten. Anregungen und Ideen zum Thema sind da willkommen.

@Newbie-2
Copy link

@Newbie-2 Newbie-2 commented Jul 6, 2020

Eigentlich möchte ich nur das die RasperyMatic von der SSD des Pi4 bootet.

Selbst die kleinste SSD ist groß genug, um alle Diagramme, Historian, Red Matic usw abzuspeichern. Somit wäre die Nutzung eines weiteren Hardware Datenträgers wie USB Stick aus meiner Sicht nicht erforderlich ! Es müsste nur möglich sein, den nicht von RasperryMatic formatierten bzw. genutzten Bereich der SSD zu formatieren und somit zu nutzen.

  • Also entweder die RaspberryMatic Partition auf den ungenutzte Bereich der SSD vergrößern
  • Oder den ungenutzten Bereich als eigene Partition formatieren, wenn die RaspberryMatic diese Partition verwalten und nutzen kann.
@Baxxy13
Copy link

@Baxxy13 Baxxy13 commented Jul 6, 2020

  • Also entweder die RaspberryMatic Partition auf den ungenutzte Bereich der SSD vergrößern

Das passiert automatisch wenn du das RaspberryMatic Image auf die SSD "brennst" und von dort den ersten Start durchführst.
Dann wird die gesamte Kapazität genutzt. Beim klonen der SD-Karte auf die SSD sind die Partitionen natürlich erstmal so groß wie auf der SD-Karte, lassen sich aber mit einem Partitionsprogramm wie GParted nachträglich vergrößern.

  • Oder den ungenutzten Bereich als eigene Partition formatieren, wenn die RaspberryMatic diese Partition verwalten und nutzen kann.

Hatte ich getestet. Habe es aber nicht geschafft diese Partition vernünftig nutzbar ins System zu mounten.

Somit wäre die Nutzung eines weiteren Hardware Datenträgers wie USB Stick aus meiner Sicht nicht erforderlich !

Sehe ich grundsätzlich auch so. Somit müsste das System so gestartet werden wie die ova-Version. Dort sind alle Pfade auf die /usr/local Partition ausgerichtet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.