aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
Diffstat (limited to 'util')
-rwxr-xr-xutil/chibios_conf_updater.sh103
-rwxr-xr-xutil/install/arch.sh3
-rwxr-xr-xutil/install/debian.sh11
-rwxr-xr-xutil/update_chibios_mirror.sh4
4 files changed, 25 insertions, 96 deletions
diff --git a/util/chibios_conf_updater.sh b/util/chibios_conf_updater.sh
index 5ba8aa677..a5699ca3c 100755
--- a/util/chibios_conf_updater.sh
+++ b/util/chibios_conf_updater.sh
@@ -3,6 +3,17 @@
3set -eEuo pipefail 3set -eEuo pipefail
4umask 022 4umask 022
5 5
6#####################
7# You will need to get an older JDK -- JDK 8
8#
9# !!!!!!!! DO NOT INSTALL THIS IF YOU HAVE AN EXISTING JDK OR JRE INSTALLED !!!!!!!!
10#
11# For Debian 10-ish distro's:
12# wget -qO - https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public | sudo apt-key add -
13# sudo add-apt-repository --yes https://adoptopenjdk.jfrog.io/adoptopenjdk/deb/
14# sudo apt-get update && sudo apt-get install adoptopenjdk-8-hotspot
15
16
6sinfo() { echo "$@" >&2 ; } 17sinfo() { echo "$@" >&2 ; }
7shead() { sinfo "" ; sinfo "---------------------------------" ; sinfo "-- $@" ; sinfo "---------------------------------" ; } 18shead() { sinfo "" ; sinfo "---------------------------------" ; sinfo "-- $@" ; sinfo "---------------------------------" ; }
8havecmd() { command command type "${1}" >/dev/null 2>&1 || return 1 ; } 19havecmd() { command command type "${1}" >/dev/null 2>&1 || return 1 ; }
@@ -11,8 +22,6 @@ this_script="$(realpath "${BASH_SOURCE[0]}")"
11script_dir="$(realpath "$(dirname "$this_script")")" 22script_dir="$(realpath "$(dirname "$this_script")")"
12qmk_firmware_dir="$(realpath "$script_dir/../")" 23qmk_firmware_dir="$(realpath "$script_dir/../")"
13 24
14declare -A file_hashes
15
16export PATH="$PATH:$script_dir/fmpp/bin" 25export PATH="$PATH:$script_dir/fmpp/bin"
17 26
18build_fmpp() { 27build_fmpp() {
@@ -38,74 +47,13 @@ find_chibi_files() {
38 local search_path="$1" 47 local search_path="$1"
39 shift 48 shift
40 local conditions=( "$@" ) 49 local conditions=( "$@" )
41 for file in $(find -L "$search_path" -not -path '*/lib/chibios*' -and -not -path '*/lib/ugfx*' -and -not -path '*/util/*' -and \( "${conditions[@]}" \) | sort) ; do 50 for file in $(find -L "$search_path" -not -path '*/lib/chibios*' -and -not -path '*/util/*' -and \( "${conditions[@]}" \) | sort) ; do
42 if [ -z "$(grep 'include_next' "$file")" ] ; then 51 if [ -z "$(grep 'include_next' "$file")" ] ; then
43 echo $file 52 echo $file
44 fi 53 fi
45 done 54 done
46} 55}
47 56
48revert_chibi_files() {
49 local search_path="$1"
50 shead "Reverting ChibiOS config/board files..."
51 for file in $(find_chibi_files "$search_path" -name chconf.h -or -name halconf.h -or -name mcuconf.h -or -name board.c -or -name board.h -or -name board.mk -or -name board.chcfg) ; do
52 pushd "$search_path" >/dev/null 2>&1
53 local relpath=$(realpath --relative-to="$search_path" "$file")
54 git checkout upstream/develop -- "$relpath" || git checkout origin/develop -- "$relpath" || true
55 popd >/dev/null 2>&1
56 done
57}
58
59populate_file_hashes() {
60 local search_path="$1"
61 shead "Determining duplicate config/board files..."
62 for file in $(find_chibi_files "$search_path" -name chconf.h -or -name halconf.h -or -name mcuconf.h -or -name board.c -or -name board.h) ; do
63 local key="file_$(clang-format "$file" | sha1sum | cut -d' ' -f1)"
64 local relpath=$(realpath --relative-to="$search_path" "$file")
65 file_hashes[$key]="${file_hashes[$key]:-} $relpath"
66 done
67 for file in $(find_chibi_files "$search_path" -name board.mk -or -name board.chcfg) ; do
68 local key="file_$(cat "$file" | sha1sum | cut -d' ' -f1)"
69 local relpath=$(realpath --relative-to="$search_path" "$file")
70 file_hashes[$key]="${file_hashes[$key]:-} $relpath"
71 done
72}
73
74determine_equivalent_files() {
75 local search_file="$1"
76 for K in "${!file_hashes[@]}"; do
77 for V in ${file_hashes[$K]}; do
78 if [[ "$V" == "$search_file" ]] ; then
79 for V in ${file_hashes[$K]}; do
80 echo "$V"
81 done
82 return 0
83 fi
84 done
85 done
86 return 1
87}
88
89deploy_staged_files() {
90 shead "Deploying staged files..."
91 for file in $(find "$qmk_firmware_dir/util/chibios-upgrade-staging" -type f) ; do
92 local relpath=$(realpath --relative-to="$qmk_firmware_dir/util/chibios-upgrade-staging" "$file")
93 sinfo "Deploying staged file: $relpath"
94 for other in $(determine_equivalent_files "$relpath") ; do
95 sinfo " => $other"
96 cp "$qmk_firmware_dir/util/chibios-upgrade-staging/$relpath" "$qmk_firmware_dir/$other"
97 done
98 done
99}
100
101swap_mcuconf_f3xx_f303() {
102 shead "Swapping STM32F3xx_MCUCONF -> STM32F303_MCUCONF..."
103 for file in $(find_chibi_files "$qmk_firmware_dir" -name mcuconf.h) ; do
104 sed -i 's#STM32F3xx_MCUCONF#STM32F303_MCUCONF#g' "$file"
105 dos2unix "$file" >/dev/null 2>&1
106 done
107}
108
109upgrade_conf_files_generic() { 57upgrade_conf_files_generic() {
110 local search_filename="$1" 58 local search_filename="$1"
111 local update_script="$2" 59 local update_script="$2"
@@ -150,35 +98,8 @@ upgrade_mcuconf_files() {
150 popd >/dev/null 2>&1 98 popd >/dev/null 2>&1
151} 99}
152 100
153update_staged_files() {
154 shead "Updating staged files with ChibiOS upgraded versions..."
155 for file in $(find "$qmk_firmware_dir/util/chibios-upgrade-staging" -type f) ; do
156 local relpath=$(realpath --relative-to="$qmk_firmware_dir/util/chibios-upgrade-staging" "$file")
157 sinfo "Updating staged file: $relpath"
158 cp "$qmk_firmware_dir/$relpath" "$qmk_firmware_dir/util/chibios-upgrade-staging/$relpath"
159 done
160}
161
162havecmd fmpp || build_fmpp 101havecmd fmpp || build_fmpp
163revert_chibi_files "$qmk_firmware_dir"
164populate_file_hashes "$qmk_firmware_dir"
165
166shead "Showing duplicate ChibiOS files..."
167for K in "${!file_hashes[@]}"; do
168 sinfo ${K#file_}:
169 for V in ${file_hashes[$K]}; do
170 sinfo " $V"
171 done
172done
173
174if [ "${1:-}" == "-r" ] ; then
175 exit 0
176fi
177
178swap_mcuconf_f3xx_f303
179 102
180deploy_staged_files
181upgrade_mcuconf_files 103upgrade_mcuconf_files
182upgrade_chconf_files 104upgrade_chconf_files
183upgrade_halconf_files 105upgrade_halconf_files
184update_staged_files
diff --git a/util/install/arch.sh b/util/install/arch.sh
index bef98ac37..33c39212d 100755
--- a/util/install/arch.sh
+++ b/util/install/arch.sh
@@ -6,7 +6,8 @@ _qmk_install() {
6 sudo pacman --needed --noconfirm -S \ 6 sudo pacman --needed --noconfirm -S \
7 base-devel clang diffutils gcc git unzip wget zip python-pip \ 7 base-devel clang diffutils gcc git unzip wget zip python-pip \
8 avr-binutils arm-none-eabi-binutils arm-none-eabi-gcc \ 8 avr-binutils arm-none-eabi-binutils arm-none-eabi-gcc \
9 arm-none-eabi-newlib avrdude dfu-programmer dfu-util 9 arm-none-eabi-newlib avrdude dfu-programmer dfu-util \
10 riscv64-elf-binutils riscv64-elf-gcc riscv64-elf-newlib
10 sudo pacman --needed --noconfirm -U https://archive.archlinux.org/packages/a/avr-gcc/avr-gcc-8.3.0-1-x86_64.pkg.tar.xz 11 sudo pacman --needed --noconfirm -U https://archive.archlinux.org/packages/a/avr-gcc/avr-gcc-8.3.0-1-x86_64.pkg.tar.xz
11 sudo pacman --needed --noconfirm -S avr-libc # Must be installed after the above, or it will bring in the latest avr-gcc instead 12 sudo pacman --needed --noconfirm -S avr-libc # Must be installed after the above, or it will bring in the latest avr-gcc instead
12 13
diff --git a/util/install/debian.sh b/util/install/debian.sh
index 57588e371..3e02919bd 100755
--- a/util/install/debian.sh
+++ b/util/install/debian.sh
@@ -11,11 +11,18 @@ _qmk_install_prepare() {
11_qmk_install() { 11_qmk_install() {
12 echo "Installing dependencies" 12 echo "Installing dependencies"
13 13
14 sudo apt-get -yq install \ 14 sudo apt-get --quiet --yes install \
15 build-essential clang-format diffutils gcc git unzip wget zip \ 15 build-essential clang-format diffutils gcc git unzip wget zip \
16 python3-pip binutils-avr gcc-avr avr-libc binutils-arm-none-eabi \ 16 python3-pip binutils-avr gcc-avr avr-libc binutils-arm-none-eabi \
17 gcc-arm-none-eabi libnewlib-arm-none-eabi avrdude dfu-programmer \ 17 gcc-arm-none-eabi libnewlib-arm-none-eabi avrdude dfu-programmer \
18 dfu-util teensy-loader-cli libhidapi-hidraw0 libusb-dev 18 dfu-util teensy-loader-cli libhidapi-hidraw0 libusb-dev
19 19
20 python3 -m pip install --user -r $QMK_FIRMWARE_DIR/requirements.txt 20 # RISC-V toolchains with picolibc support are only available for distributions based on Debian 11+.
21 if sudo apt-get install --simulate --quiet --yes picolibc-riscv64-unknown-elf gcc-riscv64-unknown-elf binutils-riscv64-unknown-elf > /dev/null 2>&1; then
22 sudo apt-get --quiet --yes install picolibc-riscv64-unknown-elf \
23 gcc-riscv64-unknown-elf \
24 binutils-riscv64-unknown-elf
25 fi
26
27 python3 -m pip install --user -r "$QMK_FIRMWARE_DIR"/requirements.txt
21} 28}
diff --git a/util/update_chibios_mirror.sh b/util/update_chibios_mirror.sh
index 83aee2281..0bf648ebf 100755
--- a/util/update_chibios_mirror.sh
+++ b/util/update_chibios_mirror.sh
@@ -7,10 +7,10 @@
7chibios_branches="trunk stable_20.3.x stable_21.6.x" 7chibios_branches="trunk stable_20.3.x stable_21.6.x"
8 8
9# The ChibiOS tags to mirror 9# The ChibiOS tags to mirror
10chibios_tags="ver20.3.1 ver20.3.2 ver20.3.3 ver21.6.0" 10chibios_tags="ver20.3.1 ver20.3.2 ver20.3.3 ver20.3.4 ver21.6.0"
11 11
12# The ChibiOS-Contrib branches to mirror 12# The ChibiOS-Contrib branches to mirror
13contrib_branches="chibios-20.3.x" 13contrib_branches="chibios-20.3.x chibios-21.6.x"
14 14
15################################ 15################################
16# Actions 16# Actions