Merge branch 'v6.6-gateware-scripts' into 'main'
rootfs: Update gateware scripts to support kernel 6.6 and later. See merge request beaglev-fire/BeagleV-Fire-ubuntu!9main
commit
0be36b84b4
@ -0,0 +1,49 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
echo "================================================================================"
|
||||||
|
echo "| FPGA Gateware Update |"
|
||||||
|
echo "| |"
|
||||||
|
echo "| Please ensure that the mpfs_bitstream.spi file containing the gateware |"
|
||||||
|
echo "| update has been copied to directory /lib/firmware. |"
|
||||||
|
echo "| |"
|
||||||
|
echo "| !!! This will take a couple of minutes. !!! |"
|
||||||
|
echo "| |"
|
||||||
|
echo "| Give the system a few minutes to reboot itself |"
|
||||||
|
echo "| after Linux has shutdown. |"
|
||||||
|
echo "| |"
|
||||||
|
echo "================================================================================"
|
||||||
|
|
||||||
|
if [ ! -f /usr/sbin/mtd_debug ] ; then
|
||||||
|
echo "Install mtd-utils package"
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f /lib/firmware/mpfs_bitstream.spi ] ; then
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
#read -rsp $'Press any key to continue...\n' -n1 key
|
||||||
|
|
||||||
|
if [ ! -f /sys/kernel/debug/fpga/microchip_exec_update ] ; then
|
||||||
|
/usr/bin/mount -t debugfs none /sys/kernel/debug
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Trash exisitng device tree overlay in case the rest of the process fails:
|
||||||
|
/usr/sbin/mtd_debug erase /dev/mtd0 0x0 0x10000
|
||||||
|
|
||||||
|
# Write device tree overlay
|
||||||
|
dtbo_ls=$(ls -l /lib/firmware/mpfs_dtbo.spi)
|
||||||
|
dtbo_size=$(echo $dtbo_ls | cut -d " " -f 5)
|
||||||
|
|
||||||
|
echo "Writing mpfs_dtbo.spi to /dev/mtd0"
|
||||||
|
/usr/sbin/mtd_debug write /dev/mtd0 0x400 $dtbo_size /lib/firmware/mpfs_dtbo.spi > /dev/zero
|
||||||
|
|
||||||
|
# Fake the presence of a golden image for now.
|
||||||
|
/usr/sbin/mtd_debug write /dev/mtd0 0 4 /dev/zero > /dev/zero
|
||||||
|
|
||||||
|
# Initiate FPGA update.
|
||||||
|
echo "Triggering FPGA Gateware Update (/sys/kernel/debug/fpga/microchip_exec_update)"
|
||||||
|
echo 1 > /sys/kernel/debug/fpga/microchip_exec_update
|
||||||
|
|
||||||
|
# Reboot Linux for the gateware update to take effect.
|
||||||
|
# FPGA reprogramming takes places between Linux shut-down and HSS restarting the board.
|
||||||
|
/usr/sbin/reboot
|
@ -1,49 +1,66 @@
|
|||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
echo "================================================================================"
|
|
||||||
echo "| FPGA Gateware Update |"
|
|
||||||
echo "| |"
|
|
||||||
echo "| Please ensure that the mpfs_bitstream.spi file containing the gateware |"
|
|
||||||
echo "| update has been copied to directory /lib/firmware. |"
|
|
||||||
echo "| |"
|
|
||||||
echo "| !!! This will take a couple of minutes. !!! |"
|
|
||||||
echo "| |"
|
|
||||||
echo "| Give the system a few minutes to reboot itself |"
|
|
||||||
echo "| after Linux has shutdown. |"
|
|
||||||
echo "| |"
|
|
||||||
echo "================================================================================"
|
|
||||||
|
|
||||||
if [ ! -f /usr/sbin/mtd_debug ] ; then
|
|
||||||
echo "Install mtd-utils package"
|
|
||||||
exit 2
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -f /lib/firmware/mpfs_bitstream.spi ] ; then
|
if [ $# -eq 0 ]; then
|
||||||
exit 2
|
echo "No gateware location provided. Checking default location."
|
||||||
|
if [ ! -e /lib/firmware/mpfs_bitstream.spi ]; then
|
||||||
|
echo "No gateware file found."
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
#read -rsp $'Press any key to continue...\n' -n1 key
|
echo "Gateware location provided: $1"
|
||||||
|
if [ ! -e "$1"/mpfs_bitstream.spi ]; then
|
||||||
if [ ! -f /sys/kernel/debug/fpga/microchip_exec_update ] ; then
|
echo "No gateware file found."
|
||||||
/usr/bin/mount -t debugfs none /sys/kernel/debug
|
exit 1
|
||||||
|
else
|
||||||
|
if [ ! -d /lib/firmware ]; then
|
||||||
|
mkdir /lib/firmware
|
||||||
fi
|
fi
|
||||||
|
cp "$1"/mpfs_dtbo.spi /lib/firmware/mpfs_dtbo.spi
|
||||||
|
cp "$1"/mpfs_bitstream.spi /lib/firmware/mpfs_bitstream.spi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Trash existing device tree overlay in case the rest of the process fails:
|
||||||
|
flash_erase /dev/mtd0 0 16
|
||||||
|
|
||||||
# Trash exisitng device tree overlay in case the rest of the process fails:
|
# Initiate FPGA update for dtbo
|
||||||
/usr/sbin/mtd_debug erase /dev/mtd0 0x0 0x10000
|
echo 1 > /sys/class/firmware/mpfs-auto-update/loading
|
||||||
|
|
||||||
# Write device tree overlay
|
# Write device tree overlay
|
||||||
dtbo_ls=$(ls -l /lib/firmware/mpfs_dtbo.spi)
|
cat /lib/firmware/mpfs_dtbo.spi > /sys/class/firmware/mpfs-auto-update/data
|
||||||
dtbo_size=$(echo $dtbo_ls | cut -d " " -f 5)
|
|
||||||
|
|
||||||
echo "Writing mpfs_dtbo.spi to /dev/mtd0"
|
# Signal completion for dtbo load
|
||||||
/usr/sbin/mtd_debug write /dev/mtd0 0x400 $dtbo_size /lib/firmware/mpfs_dtbo.spi > /dev/zero
|
echo 0 > /sys/class/firmware/mpfs-auto-update/loading
|
||||||
|
|
||||||
|
while [ "$(cat /sys/class/firmware/mpfs-auto-update/status)" != "idle" ]; do
|
||||||
|
# Do nothing, just keep checking
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
|
||||||
# Fake the presence of a golden image for now.
|
# Fake the presence of a golden image for now.
|
||||||
/usr/sbin/mtd_debug write /dev/mtd0 0 4 /dev/zero > /dev/zero
|
dd if=/dev/zero of=/dev/mtd0 count=1 bs=4
|
||||||
|
|
||||||
|
# Initiate FPGA update for bitstream
|
||||||
|
echo 1 > /sys/class/firmware/mpfs-auto-update/loading
|
||||||
|
|
||||||
|
# Write the firmware image to the data sysfs file
|
||||||
|
cat /lib/firmware/mpfs_bitstream.spi > /sys/class/firmware/mpfs-auto-update/data
|
||||||
|
|
||||||
# Initiate FPGA update.
|
# Signal completion for bitstream load
|
||||||
echo "Triggering FPGA Gateware Update (/sys/kernel/debug/fpga/microchip_exec_update)"
|
echo 0 > /sys/class/firmware/mpfs-auto-update/loading
|
||||||
echo 1 > /sys/kernel/debug/fpga/microchip_exec_update
|
|
||||||
|
|
||||||
# Reboot Linux for the gateware update to take effect.
|
while [ "$(cat /sys/class/firmware/mpfs-auto-update/status)" != "idle" ]; do
|
||||||
# FPGA reprogramming takes places between Linux shut-down and HSS restarting the board.
|
# Do nothing, just keep checking
|
||||||
/usr/sbin/reboot
|
sleep 1
|
||||||
|
done
|
||||||
|
|
||||||
|
# When the status is 'idle' and no error has occured, reboot the system for
|
||||||
|
# the gateware update to take effect. FPGA reprogramming takes places between
|
||||||
|
# Linux shut-down and HSS restarting the board.
|
||||||
|
if [ "$(cat /sys/class/firmware/mpfs-auto-update/error)" = "" ]; then
|
||||||
|
echo "FPGA update ready. Rebooting."
|
||||||
|
reboot
|
||||||
|
else
|
||||||
|
echo "FPGA update failed with status: $(cat /sys/class/firmware/mpfs-auto-update/error)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
Loading…
Reference in New Issue