Skip to contentSkip to conversation

Fixup Update Gateware Feature

PATCH Superseded Jamie Gibbons via buildroot 1 participant 8 messages Oct 22, 2024 – Jan 7, 2025

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover Fixup Update Gateware Feature

Hi all,

The following patchset fixes the gateware update feature following the addition of the firmware upload API in linux v6.6. Using debugfs for firmware updating has now been removed. The update-gateware script now makes use of the firmware upload API with sysfs and enables applying overlays during boot. The README steps for updating the firmware have also been optimised, making it easier for the user.
Three configs have been added:
1. When applying overlays at boot time all dtbs need to be compiled with the -@ flag.
2. The updated update-gateware script uses stat on the target to get the size of firmware files - add coreutils and it's dependency (busybox_show_others) for this.

Thanks,
Jamie.

Jamie Gibbons (3):
board/beagleboard/beaglev_fire: fix update gateware feature configs/beaglev_fire: add support for overlays and update script board/beagleboard/beaglev_fire: cleanup gatewate update

 board/beagleboard/beaglev_fire/README.txt     | 13 +---
 board/beagleboard/beaglev_fire/boot.cmd       |  1 +
 .../usr/share/microchip/update-gateware.sh    | 65 +++++++++++++------
 configs/beaglev_fire_defconfig                |  3 +
 4 files changed, 53 insertions(+), 29 deletions(-)
 mode change 100644 => 100755 board/beagleboard/beaglev_fire/rootfs-overlay/usr/share/microchip/update-gateware.sh
Signature · 6 lines
2.43.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

PATCH 1/3 board/beagleboard/beaglev_fire: fix update gateware feature

Following the addition of the firmware upload API in linux v6.6, using debugfs for firmware updating has been removed. Update the update-gateware script to use the firmware upload API with sysfs and enable applying the overlays during boot.

---
 board/beagleboard/beaglev_fire/boot.cmd       |  1 +
 .../usr/share/microchip/update-gateware.sh    | 41 ++++++++++++++-----
 2 files changed, 31 insertions(+), 11 deletions(-)
 mode change 100644 => 100755 board/beagleboard/beaglev_fire/rootfs-overlay/usr/share/microchip/update-gateware.sh
board/beagleboard/beaglev_fire/boot.cmd +1 -0
index 05f4858bac..1402458d8b 100644
@@ -12,4 +12,5 @@ bootm loados ${scriptaddr};
 bootm ramdisk;
 bootm prep;
 fdt set /soc/ethernet@20110000 mac-address ${beaglevfire_mac_addr0};
+run design_overlays;
 bootm go;
board/beagleboard/beaglev_fire/rootfs-overlay/usr/share/microchip/update-gateware.sh +30 -11

50 lines not on this page · raw message

Signature · 6 lines
2.43.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#5 lore raw

PATCH 3/3 board/beagleboard/beaglev_fire: cleanup gatewate update

In reply to Jamie Gibbons via buildroot

Update the README following the update gateware fix and optimise the script, making it easier for the user to use.

---
 board/beagleboard/beaglev_fire/README.txt     | 13 +++-------
 .../usr/share/microchip/update-gateware.sh    | 24 ++++++++++++-------
 2 files changed, 19 insertions(+), 18 deletions(-)
board/beagleboard/beaglev_fire/README.txt +3 -10
index c9a824b67f..6484cca8e1 100644
@@ -113,7 +113,7 @@ https://docs.beagleboard.org/latest/boards/beaglev/fire/demos-and-tutorials/gate
   On your Linux host development computer, copy the bitstream to BeagleV-Fire
   board, replacing </path/to/your/> with the path to your BeagleV-Fire root file
   system.
-    'cp -r ./LinuxProgramming /path/to/your/buildroot/board/beagleboard/beaglev_fire/rootfs-overlay/etc/'
+    'cp -r ./LinuxProgramming /path/to/your/buildroot/board/beagleboard/beaglev_fire/rootfs-overlay/lib/firmware/'
 
   To apply these changes to your image, make sure to re-build it with:
     `make`
@@ -121,14 +121,7 @@ https://docs.beagleboard.org/latest/boards/beaglev/fire/demos-and-tutorials/gate
   Then, re-flash your image - to ensure you have the necessary firmware files - by
   following the above section "Flashing the image to your eMMC".
 
-  On BeagleV-Fire,
-    1. Make your update gateware script executable
-      'chmod +x /usr/share/microchip/update-gateware.sh'
-    2. Create a firmware directory
-      'mkdir /lib/firmware'
-    3. Change to the directory of your gateware script
-      `cd /usr/share/microchip/`
-    3. initiate the reprogramming of the FPGA with your gateware bitstream:
-      './update-gateware.sh /etc/LinuxProgramming/'
+  On BeagleV-Fire initiate the reprogramming of the FPGA with your gateware bitstream:
+    `/usr/share/microchip/update-gateware.sh`
 
   Wait for a couple of minutes for the BeagleV-Fire to reprogram itself.
board/beagleboard/beaglev_fire/rootfs-overlay/usr/share/microchip/update-gateware.sh +16 -8
index ce55394343..b4344bb804 100755
@@ -1,17 +1,25 @@
 #!/bin/sh
 
-if [ ! -e "$1"/mpfs_bitstream.spi ]; then
+if [ $# -eq 0 ]; then
+    echo "No gateware location provided. Checking default location."
+    if [ ! -e /lib/firmware/mpfs_bitstream.spi ]; then
         echo "No gateware file found."
         exit 1
+    fi
+else
+    echo "Gateware location provided: $1"
+    if [ ! -e "$1"/mpfs_bitstream.spi ]; then
+        echo "No gateware file found."
+        exit 1
+    else
+        if [ ! -d /lib/firmware ]; then
+            mkdir /lib/firmware
+        fi
+        cp "$1"/mpfs_dtbo.spi /lib/firmware/mpfs_dtbo.spi
+        cp "$1"/mpfs_bitstream.spi /lib/firmware/mpfs_bitstream.spi
+    fi
 fi
 
-if [ ! -d /lib/firmware ]
-then
-    mkdir /lib/firmware
-fi
-
-cp "$1"/mpfs_dtbo.spi /lib/firmware/mpfs_dtbo.spi
-cp "$1"/mpfs_bitstream.spi /lib/firmware/mpfs_bitstream.spi
 
 # Trash existing device tree overlay in case the rest of the process fails:
 flash_erase /dev/mtd0 0 16
Signature · 6 lines
2.43.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#4 lore raw

PATCH 2/3 configs/beaglev_fire: add support for overlays and update script

In reply to Jamie Gibbons via buildroot

When applying overlays at boot time all dtbs need to be compiled with the -@ flag. Set the appropriate config to do this.
The updated update-gateware script uses stat on the target to get the size of firmware files, enable coreutils and it's dependency to make use of this package on the target when this script is used.

---
 configs/beaglev_fire_defconfig | 3 +++
 1 file changed, 3 insertions(+)
configs/beaglev_fire_defconfig +3 -0
index 5e1faf41b9..5d7115b914 100644
@@ -12,7 +12,10 @@ BR2_LINUX_KERNEL_CUSTOM_TARBALL_LOCATION="$(call github,linux4microchip,linux,li
 BR2_LINUX_KERNEL_DEFCONFIG="mpfs"
 BR2_LINUX_KERNEL_DTS_SUPPORT=y
 BR2_LINUX_KERNEL_INTREE_DTS_NAME="microchip/mpfs-beaglev-fire"
+BR2_LINUX_KERNEL_DTB_OVERLAY_SUPPORT=y
+BR2_PACKAGE_BUSYBOX_SHOW_OTHERS=y
 BR2_PACKAGE_MTD=y
+BR2_PACKAGE_COREUTILS=y
 BR2_TARGET_ROOTFS_EXT2=y
 BR2_TARGET_ROOTFS_EXT2_4=y
 BR2_TARGET_UBOOT=y
Signature · 6 lines
2.43.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
author Reviewed-by Conor Dooley on the v1 series
#6 lore raw
In reply to Jamie Gibbons via buildroot
Quoted 16 lines · Jamie Gibbons

Hi all,

The following patchset fixes the gateware update feature following the
addition of the firmware upload API in linux v6.6. Using debugfs for firmware
updating has now been removed. The update-gateware script now makes use of the
firmware upload API with sysfs and enables applying overlays during boot.
The README steps for updating the firmware have also been optimised, making it
easier for the user.
Three configs have been added:
1. When applying overlays at boot time all dtbs need to be
compiled with

Quoted 6 lines
	the `-@` flag.
	2. The updated update-gateware script uses `stat` on the

target to get the
size of firmware files - add coreutils and it's dependency (busybox_show_others) for this.

Hi all,

Anything holding this series back from being applied?

Also a reviewed-by tag was sent by my colleague however, may not have been picked up as he is not on the mailing list.

Thanks,
Jamie.

Quoted 10 lines

Thanks,
Jamie.

Jamie Gibbons (3):
  board/beagleboard/beaglev_fire: fix update gateware feature configs/beaglev_fire: add support for overlays and update script board/beagleboard/beaglev_fire: cleanup gatewate update

Quoted 9 lines

 board/beagleboard/beaglev_fire/README.txt     | 13 +--- board/beagleboard/beaglev_fire/boot.cmd       |  1 + .../usr/share/microchip/update-gateware.sh    | 65 +++++++++++++---- --
 configs/beaglev_fire_defconfig                |  3 +

 4 files changed, 53 insertions(+), 29 deletions(-)

 mode change 100644 => 100755 board/beagleboard/beaglev_fire/rootfs- overlay/usr/share/microchip/update-gateware.sh

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#7 lore raw

Hi all,

Quoted 32 lines · Jamie.Gibbons--- via buildroot

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

Quoted 15 lines · Jamie Gibbons

Hi all,

The following patchset fixes the gateware update feature following the
addition of the firmware upload API in linux v6.6. Using debugfs for
firmware
updating has now been removed. The update-gateware script now makes use of the
firmware upload API with sysfs and enables applying overlays during boot.
The README steps for updating the firmware have also been optimised,
making it
easier for the user.

Quoted 9 lines

Three configs have been added:
      1. When applying overlays at boot time all dtbs need to be compiled with
      the -@ flag.
      2. The updated update-gateware script uses stat on the target to get the
      size of firmware files - add coreutils and it's dependency (busybox_show_others) for this.

Hi all,

Anything holding this series back from being applied?

Quoted 8 lines

Also a reviewed-by tag was sent by my colleague however, may not have been picked up as he is not on the mailing list.

Thanks,
Jamie.

Gentle reminder as I am still awaiting a response on the above and the series is almost a month old. With updates made to source what is currently in the Buildroot repository doesn't work. Any feedback? Any changes needed? Anything holding this back from being applied?

Looking forward to a response.

Thanks again,
Jamie

Quoted 22 lines
Quoted 16 lines

Thanks,
Jamie.

Jamie Gibbons (3):
  board/beagleboard/beaglev_fire: fix update gateware feature configs/beaglev_fire: add support for overlays and update script board/beagleboard/beaglev_fire: cleanup gatewate update

 board/beagleboard/beaglev_fire/README.txt     | 13 +--- board/beagleboard/beaglev_fire/boot.cmd       |  1 + .../usr/share/microchip/update-gateware.sh    | 65 +++++++++++++-- --
--
 configs/beaglev_fire_defconfig                |  3 +

Quoted 5 lines
 4 files changed, 53 insertions(+), 29 deletions(-)

 mode change 100644 => 100755
board/beagleboard/beaglev_fire/rootfs-
overlay/usr/share/microchip/update-gateware.sh

Quoted 4 lines

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

author Reviewed-by Conor Dooley on v1 1/3
#2 lore raw

Re: [Buildroot] [PATCH 1/3] board/beagleboard/beaglev_fire: fix update gateware feature

In reply to Jamie Gibbons via buildroot
Quoted 6 lines · Jamie Gibbons

Following the addition of the firmware upload API in linux v6.6, using
debugfs for firmware updating has been removed. Update the update-gateware script to use the firmware upload API with sysfs and enable applying the overlays during boot.

Hi all,

Anything holding this series back from being applied?

Also a reviewed-by tag was sent by my colleague however, it may not have been picked up as he is not on the mailing list.

Thanks,
Jamie

Quoted 83 lines

---
 board/beagleboard/beaglev_fire/boot.cmd       |  1 + .../usr/share/microchip/update-gateware.sh    | 41 ++++++++++++++--- --

 2 files changed, 31 insertions(+), 11 deletions(-)

 mode change 100644 => 100755 board/beagleboard/beaglev_fire/rootfs- overlay/usr/share/microchip/update-gateware.sh

board/beagleboard/beaglev_fire/boot.cmd +1 -0
index 05f4858bac..1402458d8b 100644
@@ -12,4 +12,5 @@ bootm loados ${scriptaddr};
  bootm ramdisk;
  bootm prep;
  fdt set /soc/ethernet@20110000 mac-address ${beaglevfire_mac_addr0};
+run design_overlays;
  bootm go;
(quoted diff) +0 -0

overlay/usr/share/microchip/update-gateware.sh
b/board/beagleboard/beaglev_fire/rootfs-
overlay/usr/share/microchip/update-gateware.sh
old mode 100644
new mode 100755
index f455037b60..ce55394343
--- a/board/beagleboard/beaglev_fire/rootfs-
overlay/usr/share/microchip/update-gateware.sh
+++ b/board/beagleboard/beaglev_fire/rootfs-
overlay/usr/share/microchip/update-gateware.sh

(quoted diff) +0 -0
@@ -13,20 +13,39 @@ fi

 cp "$1"/mpfs_dtbo.spi /lib/firmware/mpfs_dtbo.spi cp "$1"/mpfs_bitstream.spi /lib/firmware/mpfs_bitstream.spi

(quoted diff) +0 -2
-mount -t debugfs none /sys/kernel/debug
-

 # Trash existing device tree overlay in case the rest of the process fails:

board/beagleboard/beaglev_fire/rootfs-overlay/usr/share/microchip/update-gateware.sh +4 -1
-flash_erase /dev/mtd0 0 1024
+flash_erase /dev/mtd0 0 16
+
+# Get device tree overlay size
+dtbo_size=$(stat -c %s /lib/firmware/mpfs_dtbo.spi)

board/beagleboard/beaglev_fire/rootfs-overlay/usr/share/microchip/update-gateware.sh +2 -2
-# # Write device tree overlay
-dd if=/lib/firmware/mpfs_dtbo.spi of=/dev/mtd0 seek=1024
+# Write device tree overlay
+dd if=/lib/firmware/mpfs_dtbo.spi of=/dev/mtd0 bs=1 seek=$((0x400))

count="$dtbo_size" status=progress

 # Fake the presence of a golden image for now.

board/beagleboard/beaglev_fire/rootfs-overlay/usr/share/microchip/update-gateware.sh +1 -1
-dd if=/dev/zero of=/dev/mtd0 count=4 bs=1
+dd if=/dev/zero of=/dev/mtd0 count=1 bs=4


 # Initiate FPGA update.

board/beagleboard/beaglev_fire/rootfs-overlay/usr/share/microchip/update-gateware.sh +0 -4
-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.

board/beagleboard/beaglev_fire/rootfs-overlay/usr/share/microchip/update-gateware.sh +4 -1
-reboot
+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

board/beagleboard/beaglev_fire/rootfs-overlay/usr/share/microchip/update-gateware.sh +5 -0
+
+# Signal completion
+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

board/beagleboard/beaglev_fire/rootfs-overlay/usr/share/microchip/update-gateware.sh +3 -0
+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

(quoted diff) +2 -0
+# Linux shut-down and HSS restarting the board.
+if [ "$(cat /sys/class/firmware/mpfs-auto-update/error)" = "" ];
Quoted 8 lines

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

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#3 lore raw

Re: [Buildroot] [PATCH 1/3] board/beagleboard/beaglev_fire: fix update gateware feature

Hi all,

Quoted 11 lines · Jamie.Gibbons--- via buildroot

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

Quoted 7 lines · Jamie Gibbons

Following the addition of the firmware upload API in linux v6.6, using
debugfs for firmware updating has been removed. Update the update-gateware script to use the firmware upload API with sysfs and
enable applying the overlays during boot.

Quoted 9 lines

Hi all,

Anything holding this series back from being applied?

Also a reviewed-by tag was sent by my colleague however, it may not have been picked up as he is not on the mailing list.

This patch series was sent 2.5 months ago and I have not received any feedback, replies nor has it been merged. This series is important as what is currently in master does not work anymore.

Please let me know if there is anything holding this back from being merged.

Thanks,
Jamie.

Quoted 95 lines

Thanks,
Jamie

Quoted 93 lines

---
 board/beagleboard/beaglev_fire/boot.cmd       |  1 + .../usr/share/microchip/update-gateware.sh    | 41 ++++++++++++++- --
--

 2 files changed, 31 insertions(+), 11 deletions(-)

 mode change 100644 => 100755
board/beagleboard/beaglev_fire/rootfs-
overlay/usr/share/microchip/update-gateware.sh

board/beagleboard/beaglev_fire/boot.cmd +0 -0
index 05f4858bac..1402458d8b 100644
@@ -12,4 +12,5 @@ bootm loados ${scriptaddr};
  bootm ramdisk;
  bootm prep;

 fdt set /soc/ethernet@20110000 mac-address
${beaglevfire_mac_addr0};
+run design_overlays;
 bootm go;

(quoted diff) +0 -0

overlay/usr/share/microchip/update-gateware.sh
b/board/beagleboard/beaglev_fire/rootfs-
overlay/usr/share/microchip/update-gateware.sh
old mode 100644
new mode 100755
index f455037b60..ce55394343
--- a/board/beagleboard/beaglev_fire/rootfs-
overlay/usr/share/microchip/update-gateware.sh
+++ b/board/beagleboard/beaglev_fire/rootfs-
overlay/usr/share/microchip/update-gateware.sh

board/beagleboard/beaglev_fire/boot.cmd +0 -0
@@ -13,20 +13,39 @@ fi

 cp "$1"/mpfs_dtbo.spi /lib/firmware/mpfs_dtbo.spi cp "$1"/mpfs_bitstream.spi /lib/firmware/mpfs_bitstream.spi

board/beagleboard/beaglev_fire/boot.cmd +0 -2
-mount -t debugfs none /sys/kernel/debug
-

 # Trash existing device tree overlay in case the rest of the process
fails:

board/beagleboard/beaglev_fire/boot.cmd +6 -3
-flash_erase /dev/mtd0 0 1024
+flash_erase /dev/mtd0 0 16
+
+# Get device tree overlay size
+dtbo_size=$(stat -c %s /lib/firmware/mpfs_dtbo.spi)
 
-# # Write device tree overlay
-dd if=/lib/firmware/mpfs_dtbo.spi of=/dev/mtd0 seek=1024
+# Write device tree overlay
+dd if=/lib/firmware/mpfs_dtbo.spi of=/dev/mtd0 bs=1

seek=$((0x400))
count="$dtbo_size" status=progress

 # Fake the presence of a golden image for now.

board/beagleboard/beaglev_fire/boot.cmd +1 -1
-dd if=/dev/zero of=/dev/mtd0 count=4 bs=1
+dd if=/dev/zero of=/dev/mtd0 count=1 bs=4

 # Initiate FPGA update.

board/beagleboard/beaglev_fire/boot.cmd +0 -4
-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.

board/beagleboard/beaglev_fire/boot.cmd +4 -1
-reboot
+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

board/beagleboard/beaglev_fire/boot.cmd +5 -0
+
+# Signal completion
+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

board/beagleboard/beaglev_fire/boot.cmd +3 -0
+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

board/beagleboard/beaglev_fire/boot.cmd +2 -0
+# 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

Quoted 8 lines
Quoted 3 lines

/sys/class/firmware/mpfs-auto-update/error)"
+    exit 1
+fi

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot