Raspberry Pi4 et UEFI

Submitted by hacyran on Wed, 09/08/2021 - 09:02

Pour booter le Raspberry en UEFI, il faut que le périphérique utilisé (carte micro-SD, clef, USB, ...) contienne une partition FAT32 d'environ 200MiB pour héberger les futurs fichiers.

On peut alors utiliser le script suivant:

#!/bin/bash

MASTER_URL=https://github.com/raspberrypi/firmware/archive/master.zip
MASTER_FILE=master.zip
UEFI_URL=https://github.com/pftf/RPi4/releases/download/v1.29/RPi4_UEFI_Firmware_v1.29.zip
UEFI_FILE=uefi.zip
TOPLEVEL=/tmp/UEFI
DOWNLOADS=${TOPLEVEL}/downloads
WORKSPACE=${TOPLEVEL}/workspace

s_directory() {
    rm -R "$1" 2>/dev/null
    mkdir -p "$1"
}

s_download() {
    DEST="${DOWNLOADS}/$2"
    if (wget -O ${DEST} $1); then
        echo "Got $2 with WGET"
    elif (curl -o ${DEST} $1); then
        echo "Got $2 with CURL"
    else
        echo "Cant retrieve file \"$2\" from URL \"$1\""
        echo Aborting
        exit 2
    fi
}


### Let's do it !
echo TOPLEVEL  directory: $TOPLEVEL
s_directory "$DOWNLOADS" && echo "DOWNLOADS directory: $DOWNLOADS"
s_directory "$WORKSPACE" && echo "WORKSPACE directory: $WORKSPACE"

# Download files
s_download "$MASTER_URL" $MASTER_FILE
s_download "$UEFI_URL" $UEFI_FILE

# Recipe
# fill workspace with files from master.zip/boot/ directory
echo "UNZIP file $MASTER_FILE"
unzip ${DOWNLOADS}/${MASTER_FILE} 'firmware-master/boot/*' -d "$WORKSPACE"

echo "MOVING files from /boot to toplevel"
mv ${WORKSPACE}/firmware-master/boot/* ${WORKSPACE}

echo "CLEANUP things"
rmdir ${WORKSPACE}/firmware-master/boot
rmdir ${WORKSPACE}/firmware-master

# Remove kernel* files
echo "REMOVE kernel* files"
rm -f ${WORKSPACE}/kernel*

# Then unzip uefi on top of that, overwriting master's files
echo "UNZIP uefi.zip on top of that"
unzip -o ${DOWNLOADS}/${UEFI_FILE} -d "$WORKSPACE"

echo
echo "Finished. Now you can copy all those files to a UEFI FAT32 partition"

On peut alors copier tous les fichiers de TOPLEVEL/workspace sur la partition UEFI FAT32 du disque USB.