unofficial mirror of help-guix@gnu.org 
 help / color / mirror / Atom feed
* Re: U-Boot for Raspberry Pi
@ 2021-10-31 23:09 Stefan
  2021-11-02 11:00 ` phodina
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan @ 2021-10-31 23:09 UTC (permalink / raw)
  To: phodina; +Cc: Vagrant Cascadian, help-guix

Hi!

There is already a patch series available since May – patiently awaiting a review –, which brings support for the Raspberry Pi. It even supports booting via NFS, which helps to avoid all the common troubles with microSD cards. 

For the usual mircoSD card installation just partition and format it as usual, and put the well known bootloader blob on the FAT partition. Then do a ‘guix system init config.scm /mnt/microsd’. The patch series contains an example configuration at ‘gnu/system/examples/raspberry-pi-64.tmpl’.   

Take a look here: <http://issues.guix.gnu.org/48314#10>


In hope to get more attention and interest for a review, allow me to add two side notes.

Ever in need for a Guix System on an USB thump drive? Give the new ‘grub-efi-netboot-removable-bootloader’ a try instead of ‘grub-efi-bootloader’. It is not only usable for booting over network.

Ever in need to quickly modify the kernel Linux? Give the new function ‘modify-linux’ a try. For the Raspberry this is needed to get the kernel linux-libre working. (By the way, would Guix System be the first distribution using a libre kernel on the Raspberry?)

For example to enable NFS root functionality for virtual machines, use a kernel definition like this in your operating-system definition:

(kernel (modify-linux #:configs '("CONFIG_E1000=y"
                                  "CONFIG_ROOT_NFS=y"
                                  "CONFIG_NFS_FS=y"
                                  "CONFIG_NFS_V4=y")))

Bye

Stefan



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: U-Boot for Raspberry Pi
  2021-10-31 23:09 U-Boot for Raspberry Pi Stefan
@ 2021-11-02 11:00 ` phodina
  2021-11-02 13:24   ` Stefan
  0 siblings, 1 reply; 6+ messages in thread
From: phodina @ 2021-11-02 11:00 UTC (permalink / raw)
  To: Stefan; +Cc: help-guix, Vagrant Cascadian

Hi Stefan,

On Monday, November 1st, 2021 at 12:09 AM, Stefan <stefan-guix@vodafonemail.de> wrote:

> Hi!
>
> There is already a patch series available since May – patiently awaiting a review –, which brings support for the Raspberry Pi. It even supports booting via NFS, which helps to avoid all the common troubles with microSD cards.

Thanks for your amazing work! I've applied the patches and it builds the system.

>
> For the usual mircoSD card installation just partition and format it as usual, and put the well known bootloader blob on the FAT partition. Then do a ‘guix system init config.scm /mnt/microsd’. The patch series contains an example configuration at ‘gnu/system/examples/raspberry-pi-64.tmpl’.


However, I ran into several issues.

Firstly it's hard to run the init command as it requires root.
What I did is the following:

sudo guix environment --pure guix --ad-hoc coreutils findutils which

This gives me pure environment with the patches and root access.

Do you have different suggestion on how to invoke the guix system init command?

Secondly I have to run the command to init the system on the microSD card with the following flag --skip-checks:

[env]# ./pre-inst-env guix system init -s aarch64-linux gnu/system/examples/raspberry-pi-64.tmpl /mnt  --skip-checks

Otherwise I have to build with the following initrd config:

(initrd-modules (append (list "mmc_block" "rtsx_pci_sdmmc" "rtsx_pci")
   ;;                             %base-initrd-modules))

But adding these the build fails. Thought they might be needed as the kernel needs to access the blocks on microSD.

Another issue were certificates:

...
initializing operating system under '/mnt'...
copying to '/mnt'...  [#########################################################                                                    ]i/o error: /gnu/store/j76446v1asknzjl5lvzp9mnrg8gxl24d-nss-certs-3.59/etc/ssl/certs/NetLock_Arany_=Class_Gold=_F??tan??s??tv??ny:2.6.73.65.44.228.0.16.pem: No such file or directory
copying to '/mnt'...  [##################################################################                                           ]i/o error: /gnu/store/db3kp42msgw9f53jk5hvp2bgsaq6jdyv-profile/etc/ssl/certs/NetLock_Arany_=Class_Gold=_F??tan??s??tv??ny:2.6.73.65.44.228.0.16.pem: No such file or directory
copying to '/mnt'...
populating '/mnt'...

Lastly the init fails as the FAT file system not supporting symlinks.

guix system: error: symlink: Operation not permitted: "/boot/efi/gnu/store"

I formatted the microSD card with FAT32 and Ext4 partitions.
The FAT32 partition is mounted to /boot.

Could you please help me as I've might done something incorrectly?

>
> Take a look here: http://issues.guix.gnu.org/48314#10
>
> In hope to get more attention and interest for a review, allow me to add two side notes.
>
> Ever in need for a Guix System on an USB thump drive? Give the new ‘grub-efi-netboot-removable-bootloader’ a try instead of ‘grub-efi-bootloader’. It is not only usable for booting over network.
>
> Ever in need to quickly modify the kernel Linux? Give the new function ‘modify-linux’ a try. For the Raspberry this is needed to get the kernel linux-libre working. (By the way, would Guix System be the first distribution using a libre kernel on the Raspberry?)
>
> For example to enable NFS root functionality for virtual machines, use a kernel definition like this in your operating-system definition:
>
> (kernel (modify-linux #:configs '("CONFIG_E1000=y"
>
> "CONFIG_ROOT_NFS=y"
>
> "CONFIG_NFS_FS=y"
>
> "CONFIG_NFS_V4=y")))
>
> Bye
>
> Stefan


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: U-Boot for Raspberry Pi
  2021-11-02 11:00 ` phodina
@ 2021-11-02 13:24   ` Stefan
  0 siblings, 0 replies; 6+ messages in thread
From: Stefan @ 2021-11-02 13:24 UTC (permalink / raw)
  To: phodina; +Cc: Vagrant Cascadian, help-guix

Hi!

> Thanks for your amazing work! I've applied the patches and it builds the system.

Welcome, and thanks for the feedback.

> However, I ran into several issues.

Your troubles might indicate that you didn’t properly mount the ext4 and FAT file systems below /mnt. You should follow the manual regarding an EFI system¹: Mount the ext4 partition of the microSD card at /mnt and the FAT partition of the microSD card at /mnt/boot/efi – you will have to call ‘mkdir -p /mnt/boot/efi’ after mounting the ext4 partition and before mounting the FAT partition.

> Do you have different suggestion on how to invoke the guix system init command?

Please separate build and installation. First build guix as described in the manual² without any sudo but inside its build environment with the amount of cores you like to use:

$ guix environment --pure guix
$ ./bootstrap
$ ./configure --localstatedir=/var
$ make -j 4
$ exit

Then use the new guix outside its build environment to initialize the system with sudo:

$ sudo -E ./pre-inst-env guix system init --system=aarch64-linux gnu/system/examples/raspberry-pi-64.tmpl /mnt

The --system flag is needed in your case executing the command on a host PC. However, I built and installed my system directly on the Raspberry, so I didn’t use it. Also --skip-checks was not necessary in my case. But building guix with only 1 GB is meanwhile close to impossible.

Is there possibly an issue with checks when installing for another system? It could also be that these checks got “improved” but fail in this case. At least additional initrd modules are not needed. So just add the --skip-checks option, if guix complains otherwise.

I hope this will solve your issues.

The certificate issues could have been due to your unconventional use of sudo. The symlink issue must have been due to the wrong mount point of the FAT partition.


Bye

Stefan


¹ <https://guix.gnu.org/devel/devel/manual/en/guix.html#Bootloader>
² <https://guix.gnu.org/devel/devel/manual/en/guix.html#Building-from-Git>



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: U-Boot for Raspberry Pi
  2021-10-30 22:05 ` Vagrant Cascadian
@ 2021-10-31  6:47   ` phodina
  0 siblings, 0 replies; 6+ messages in thread
From: phodina @ 2021-10-31  6:47 UTC (permalink / raw)
  To: Vagrant Cascadian; +Cc: help-guix

Hi vagrant,

On Sunday, October 31st, 2021 at 12:05 AM, Vagrant Cascadian <vagrant@debian.org> wrote:

> On 2021-10-30, phodina via wrote:
>
> > I'm trying to run Guix System on Raspberry Pi. In order to do that we
> >
> > need a way to boot it up.
> >
> > There is the nonfree Broadcom bootloader, which does the job and it's
> >
> > used by many distributions.
> >
> > However, there is also an open source alternative as U-Boot supports
> >
> > the BCM SoCs.
>
> Well, you still need to load u-boot from the broadcom
>
> firmware/bootloader...

Yes, unfortunately you are right. The VC4 GPU core is started first and requires
the closed source binaries (bootcode.bin, start.elf and fixup.dat).

Also no disrespect was meant to the Guix help mailing list. I thought the closed source code could
be avoided.

>
> > If I inherit from the u-boot itself and specify the name, it's then in the list and I can build it.
> >
> > But the I can't use the package for the bootloader record.
> >
> > There must be something trivial I had overlooked.
> >
> > Could you please guide me on the procedure for porting the u-boot to new board as a new Guix package?
>
> There are install targets defined in gnu/bootloader/u-boot.scm, though
>
> most (all?) of those targets install to a raw device offset, whereas
>
> u-boot for the rpi needs u-boot.bin to be copied to your firmware
>
> partition and needs to be specified as a "kernel" in config.txt, if I
>
> recall correctly.

As you correctly pointed out that you can specify in the config.txt the next executable
to be loaded which in this case is the u-boot.

Also with U-boot it's the usually the case that you place it at specific flash location.

However, Raspberry Pi has BootRom which is able to access FAT file system
and load files from there. Therefore the SD card has to be formatted with
MBR layout, FAT boot partition and then let's say Linux root partition.

>
> > (define-public u-boot-raspberry-pi-4
> >
> > (make-u-boot-package "rpi_4" "aarch64-linux-gnu"))
>
> I would also try to keep the u-boot-BOARD matching the defconfig,
>
> e.g. u-boot-rpi-4 instead of u-boot-raspberry-pi-4. Not for any
>
> technical reason, per se, just keeping the u-boot target naming
>
> consistent.

Good idea. Though the longer version would be more readable.

>
> You might want to just build the u-boot package, and then manually copy
>
> it to your firmware partition and configure that appropriately once, and
>
> then just use guix to generate and update the extlinux.conf... I forget

That's the point of my original question as I created this package definition.
It builds fine and all the files are there. But as stated above can't be passed
to the bootloader record in the operating-system.

(define-public u-boot-rpi-2
  (let ((base (make-u-boot-package "rpi_2" "arm-linux-gnueabihf")))
  (package
  (inherit base)
  (name "uboot-rpi-2"))))

The contents of the package are here:

tree /gnu/store/77syxs86n0c52pslnzfsn9xzv1dzmxhc-uboot-rpi-2-2021.10/libexec
/gnu/store/77syxs86n0c52pslnzfsn9xzv1dzmxhc-uboot-rpi-2-2021.10/libexec
├── arch
│   └── arm
│       └── dts
│           ├── bcm2835-rpi-a.dtb
│           ├── bcm2835-rpi-a-plus.dtb
│           ├── bcm2835-rpi-b.dtb
│           ├── bcm2835-rpi-b-plus.dtb
│           ├── bcm2835-rpi-b-rev2.dtb
│           ├── bcm2835-rpi-cm1-io1.dtb
│           ├── bcm2835-rpi-zero.dtb
│           ├── bcm2835-rpi-zero-w.dtb
│           ├── bcm2836-rpi-2-b.dtb
│           ├── bcm2837-rpi-3-a-plus.dtb
│           ├── bcm2837-rpi-3-b.dtb
│           ├── bcm2837-rpi-3-b-plus.dtb
│           └── bcm2837-rpi-cm3-io3.dtb
├── doc
│   └── README.commands.spl
├── dts
│   └── dt.dtb
├── lib
│   └── efi_loader
│       └── helloworld.efi
├── scripts
│   └── Makefile.spl
├── tools
│   └── binman
│       └── test
│           └── descriptor.bin
├── u-boot
├── u-boot.bin
└── u-boot-nodtb.bin

>
> the exact syntax to generate extlinux.conf without actually installing
>
> u-boot, but I've done it in the past.

So do I now need to define a new bootloader target in gnu/bootloader/u-boot.scm,
where instead of writing directly to the image follow more the pattern of function
install-grub-efi, where based on the UEFI you also need to have EFI FAT partition
and just copy the files over to their correct location?

>
> Another option would be to build the raspberry pi UEFI (not 100% sure of
>
> the licensing, but reasonably free) instead of u-boot, and then use
>
> guix's standard UEFI configuration with grub-efi and such.

Then I can treat the closed source firmware to boot as UEFI and
just package the u-boot, right?

>
> live well,
>
> vagrant


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: U-Boot for Raspberry Pi
  2021-10-30 21:39 phodina via
@ 2021-10-30 22:05 ` Vagrant Cascadian
  2021-10-31  6:47   ` phodina
  0 siblings, 1 reply; 6+ messages in thread
From: Vagrant Cascadian @ 2021-10-30 22:05 UTC (permalink / raw)
  To: phodina, help-guix

[-- Attachment #1: Type: text/plain, Size: 1877 bytes --]

On 2021-10-30, phodina via wrote:
> I'm trying to run Guix System on Raspberry Pi. In order to do that we
> need a way to boot it up.
>
> There is the nonfree Broadcom bootloader, which does the job and it's
> used by many distributions.
>
> However, there is also an open source alternative as U-Boot supports
> the BCM SoCs.

Well, you still need to load u-boot from the broadcom
firmware/bootloader...


> If I inherit from the u-boot itself and specify the name, it's then in the list and I can build it.
> But the I can't use the package for the bootloader record.
>
> There must be something trivial I had overlooked.
>
> Could you please guide me on the procedure for porting the u-boot to new board as a new Guix package?

There are install targets defined in gnu/bootloader/u-boot.scm, though
most (all?) of those targets install to a raw device offset, whereas
u-boot for the rpi needs u-boot.bin to be copied to your firmware
partition and needs to be specified as a "kernel" in config.txt, if I
recall correctly.


> (define-public u-boot-raspberry-pi-4
> (make-u-boot-package "rpi_4" "aarch64-linux-gnu"))

I would also try to keep the u-boot-BOARD matching the defconfig,
e.g. u-boot-rpi-4 instead of u-boot-raspberry-pi-4. Not for any
technical reason, per se, just keeping the u-boot target naming
consistent.

You might want to just build the u-boot package, and then manually copy
it to your firmware partition and configure that appropriately once, and
then just use guix to generate and update the extlinux.conf... I forget
the exact syntax to generate extlinux.conf without actually installing
u-boot, but I've done it in the past.

Another option would be to build the raspberry pi UEFI (not 100% sure of
the licensing, but reasonably free) instead of u-boot, and then use
guix's standard UEFI configuration with grub-efi and such.


live well,
  vagrant

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 227 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* U-Boot for Raspberry Pi
@ 2021-10-30 21:39 phodina via
  2021-10-30 22:05 ` Vagrant Cascadian
  0 siblings, 1 reply; 6+ messages in thread
From: phodina via @ 2021-10-30 21:39 UTC (permalink / raw)
  To: help-guix

Hi,

I'm trying to run Guix System on Raspberry Pi. In order to do that we need a way to boot it up.

There is the nonfree Broadcom bootloader, which does the job and it's used by many distributions.

However, there is also an open source alternative as U-Boot supports the BCM SoCs.

I had look at different u-boot definitions under gnu/packages/bootloaders.scm and gnu/bootloader.scm.

From my understanding the way how to define a new board is find the defconfig name in the configs directory in U-Boot.
Then use the make-u-boot-package with the config name and target triplet to define the package.

Unfortunately, the definitions below are not found by Guix if I run guix search -L. raspberry

If I inherit from the u-boot itself and specify the name, it's then in the list and I can build it.
But the I can't use the package for the bootloader record.

There must be something trivial I had overlooked.

Could you please guide me on the procedure for porting the u-boot to new board as a new Guix package?

--8<---------------cut here---------------start------------->8---
(define-module (raspberry-pi)
#:use-module (guix packages)
#:use-module (gnu packages bootloaders)
#:use-module (guix download)
#:use-module (guix git-download)
#:use-module (guix build-system gnu)
#:use-module ((guix licenses) #:prefix license:))

(define-public u-boot-raspberry-pi-2
(make-u-boot-package "rpi_2" "arm-linux-gnueabihf"))

(define-public u-boot-raspberry-pi-3
(make-u-boot-package "rpi_3" "aarch64-linux-gnu"))

(define-public u-boot-raspberry-pi-4
(make-u-boot-package "rpi_4" "aarch64-linux-gnu"))

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-11-02 13:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-31 23:09 U-Boot for Raspberry Pi Stefan
2021-11-02 11:00 ` phodina
2021-11-02 13:24   ` Stefan
  -- strict thread matches above, loose matches on Subject: below --
2021-10-30 21:39 phodina via
2021-10-30 22:05 ` Vagrant Cascadian
2021-10-31  6:47   ` phodina

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).