[SOLVED] Mnt keyboard - Cannot flash firmware after updating repo

I updated my reform repo on 2023-01-16 to flash my keyboard firmware with some tweaks. I run into the following error while running flash.sh

info: unrecognized option ‘–property=ID_MODEL’
cannot find Atmel DFU bootloader USB device

Current status on the keyboard is R1 20220221. Before anyone asks I am using sudo.

When the device is in flashing mode lsusb sees the keyboard:

Bus 001 Device 019: ID 03eb:2ff4 Atmel Corp. atmega32u4 DFU bootloader

I’m not especially versed in parsing bash but I can tell that the initial error is output from the flash.sh itself.

Any tips?

Hi, thank you for your bug report! What is the output of the following command on the system on which you run flash.sh:

udevadm --version

Thanks!

The output is

249

–keystrokes–

That is likely too old. What system are you running? Debian stable has udev 252. According to the systemd NEWS file, at least version 250 is required. I should add these checks into the script.

I’m running kubuntu 22.04. Attempting to manually update shows:

udev is already the newest version (249.11-0ubuntu3.11)

Thank you! Yes, we should support that. I’ll prepare a fix.

If you like, you can try the following patch:

diff --git a/reform2-keyboard-fw/flash.sh b/reform2-keyboard-fw/flash.sh
index bd3c058..c18b0b5 100755
--- a/reform2-keyboard-fw/flash.sh
+++ b/reform2-keyboard-fw/flash.sh
@@ -12,6 +12,17 @@ if [ "$(id -u)" -ne 0 ]; then
 	exit 1
 fi
 
+get_property() {
+	path="$1"
+	property="$2"
+	if [ "$(udevadm --version)" -lt 250 ]; then
+		# no udevadm --property before version 250
+		udevadm info --query=property "$path" | sed -ne "s/^$property=//p"
+	else
+		udevadm info --query=property --property="$property" --value "$path"
+	fi
+}
+
 find_usb_device() {
 	result=
 	for p in /sys/bus/usb/devices/*; do
@@ -19,7 +30,7 @@ find_usb_device() {
 		[ "$(cat "$p/idVendor")" = "$1" ] || continue
 		[ -e "$p/idProduct" ] || continue
 		[ "$(cat "$p/idProduct")" = "$2" ] || continue
-		[ "$(udevadm info --query=property --property=ID_MODEL --value "$p")" = "$3" ] || continue
+		[ "$(get_property "$p" "ID_MODEL")" = "$3" ] || continue
 		if [ -n "$result" ]; then
 			echo "found more than one device matching $1 $2 $3" >&2
 			exit 1
@@ -46,8 +57,8 @@ path_keyboard=$(find_usb_device 03eb 2042 Reform_Keyboard)
 busnum_keyboard=
 devnum_keyboard=
 if [ -n "$path_keyboard" ] && [ -e "$path_keyboard" ]; then
-	busnum_keyboard="$(udevadm info --query=property --property=BUSNUM --value "$path_keyboard")"
-	devnum_keyboard="$(udevadm info --query=property --property=DEVNUM --value "$path_keyboard")"
+	busnum_keyboard="$(get_property "$path_keyboard" "BUSNUM")"
+	devnum_keyboard="$(get_property "$path_keyboard" "DEVNUM")"
 	echo " 1. Find out your keyboard firmware version in the 'System Status' by pressing" >&2
 	echo "    the circle key followed by the S key. The keyboard firmware version is on" >&2
 	echo "    on the last line in a date-based format YYYYMMDD. Then either:"
@@ -86,8 +97,8 @@ if [ -z "$path" ] || [ ! -e "$path" ]; then
 	exit 1
 fi
 
-busnum="$(udevadm info --query=property --property=BUSNUM --value "$path")"
-devnum="$(udevadm info --query=property --property=DEVNUM --value "$path")"
+busnum="$(get_property "$path" "BUSNUM")"
+devnum="$(get_property "$path" "DEVNUM")"
 
 # do some extra checks if we saw the usb device as a keyboard before
 if [ -n "$path_keyboard" ] && [ -e "$path_keyboard" ]; then
1 Like

That worked, thanks!

1 Like

Excellent! Thank you for reporting this issue and even testing the fix!

I filed this MR with my changes above: