summaryrefslogtreecommitdiffstats
path: root/patches
diff options
context:
space:
mode:
Diffstat (limited to 'patches')
-rw-r--r--patches/01_firmware-crc-sh.patch44
1 files changed, 44 insertions, 0 deletions
diff --git a/patches/01_firmware-crc-sh.patch b/patches/01_firmware-crc-sh.patch
new file mode 100644
index 0000000..bdadbce
--- /dev/null
+++ b/patches/01_firmware-crc-sh.patch
@@ -0,0 +1,44 @@
+Author: "P. J. McDermott" <pj@pehjota.net>
+Subject: Replace target_firmware/firmware-crc.pl with a shell script
+
+diff -Naur src.orig/target_firmware/CMakeLists.txt src/target_firmware/CMakeLists.txt
+--- src.orig/target_firmware/CMakeLists.txt 2014-09-11 14:35:37.000000000 -0400
++++ src/target_firmware/CMakeLists.txt 2014-10-23 13:45:37.456405846 -0400
+@@ -119,6 +119,6 @@
+ ADD_CUSTOM_COMMAND(
+ OUTPUT ${FIRMWARE_NAME}
+ DEPENDS fw.bin
+- COMMAND ${CMAKE_SOURCE_DIR}/firmware-crc.pl < fw.bin > ${FIRMWARE_NAME}
++ COMMAND ${CMAKE_SOURCE_DIR}/firmware-crc.sh < fw.bin > ${FIRMWARE_NAME}
+ )
+ ADD_CUSTOM_TARGET(gen-firmware ALL DEPENDS ${FIRMWARE_NAME})
+diff -Naur src/target_firmware.orig/firmware-crc.sh src/target_firmware/firmware-crc.sh
+--- src.orig/target_firmware/firmware-crc.sh 1969-12-31 19:00:00.000000000 -0500
++++ src/target_firmware/firmware-crc.sh 2014-10-23 13:21:56.080985994 -0400
+@@ -0,0 +1,26 @@
++#!/bin/sh
++
++crc=0
++while read b1 b2 b3 b4; do
++ v=$(( ($b1 << 24) | ($b2 << 16) | ($b3 << 8) | ($b4 << 0) ))
++ crc=$(( $crc ^ $v ))
++ b1=$(( ($v & 0xFF000000) >> 24 ))
++ b2=$(( ($v & 0x00FF0000) >> 16 ))
++ b3=$(( ($v & 0x0000FF00) >> 8 ))
++ b4=$(( ($v & 0x000000FF) >> 0 ))
++ printf "\\$(printf '%03o' "${b1}")"
++ printf "\\$(printf '%03o' "${b2}")"
++ printf "\\$(printf '%03o' "${b3}")"
++ printf "\\$(printf '%03o' "${b4}")"
++done <<-EOF
++ $(od -An -tu1 -v -w4 -)
++ EOF
++
++b1=$(( ($crc & 0xFF000000) >> 24 ))
++b2=$(( ($crc & 0x00FF0000) >> 16 ))
++b3=$(( ($crc & 0x0000FF00) >> 8 ))
++b4=$(( ($crc & 0x000000FF) >> 0 ))
++printf "\\$(printf '%03o' "${b1}")"
++printf "\\$(printf '%03o' "${b2}")"
++printf "\\$(printf '%03o' "${b3}")"
++printf "\\$(printf '%03o' "${b4}")"