From b2a186cf92d91bbb7f98fff68c4edf571909bf89 Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Thu, 7 Oct 2021 10:57:48 +1100 Subject: Purge uGFX. (#14720) * Purge uGFX. * Remove remnants of visualizer. * Remove remnants of uGFX. --- util/chibios_conf_updater.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'util') diff --git a/util/chibios_conf_updater.sh b/util/chibios_conf_updater.sh index 5ba8aa677b..d1640b6729 100755 --- a/util/chibios_conf_updater.sh +++ b/util/chibios_conf_updater.sh @@ -38,7 +38,7 @@ find_chibi_files() { local search_path="$1" shift local conditions=( "$@" ) - for file in $(find -L "$search_path" -not -path '*/lib/chibios*' -and -not -path '*/lib/ugfx*' -and -not -path '*/util/*' -and \( "${conditions[@]}" \) | sort) ; do + for file in $(find -L "$search_path" -not -path '*/lib/chibios*' -and -not -path '*/util/*' -and \( "${conditions[@]}" \) | sort) ; do if [ -z "$(grep 'include_next' "$file")" ] ; then echo $file fi -- cgit v1.2.3 From e50867d52d9c255570630a23514842749b45e4c1 Mon Sep 17 00:00:00 2001 From: Stefan Kerkmann Date: Mon, 18 Oct 2021 07:23:20 +0200 Subject: [Core] Add support for RISC-V builds and GD32VF103 MCU (#12508) * Add support for RISC-V builds and GD32VF103 MCU * Add toolchain selection in chibios.mk based on the mcu selected in mcu_selection.mk * Reorder and added comments to chibios.mk to have a streamlined makefile * Add GD32VF103 mcu to possible targets for QMK. * Add STM32 compatibility for GD32VF103 MCU, this is hacky but more efficent then rewriting every driver. * Add GigaDevice DFU bootloader as flash target, please note that dfu-util of at least version 0.10 is needed. * Add analog driver compatibility * Add apa102 bitbang driver compatibility * Add ws2812 bitbang driver compatibility * Add eeprom in flash emulation compatibility * Allow faster re-builds with ccache * Add SiPeed Longan Nano to platform files * Add SiPeed Longan Nano Onekeys * Make quine compatible with other bootloaders * Support builds with picolibc * Add risc-v toolchain to arch and debian/ubuntu scripts --- util/install/arch.sh | 3 ++- util/install/debian.sh | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'util') diff --git a/util/install/arch.sh b/util/install/arch.sh index bef98ac37f..33c39212d3 100755 --- a/util/install/arch.sh +++ b/util/install/arch.sh @@ -6,7 +6,8 @@ _qmk_install() { sudo pacman --needed --noconfirm -S \ base-devel clang diffutils gcc git unzip wget zip python-pip \ avr-binutils arm-none-eabi-binutils arm-none-eabi-gcc \ - arm-none-eabi-newlib avrdude dfu-programmer dfu-util + arm-none-eabi-newlib avrdude dfu-programmer dfu-util \ + riscv64-elf-binutils riscv64-elf-gcc riscv64-elf-newlib sudo pacman --needed --noconfirm -U https://archive.archlinux.org/packages/a/avr-gcc/avr-gcc-8.3.0-1-x86_64.pkg.tar.xz sudo pacman --needed --noconfirm -S avr-libc # Must be installed after the above, or it will bring in the latest avr-gcc instead diff --git a/util/install/debian.sh b/util/install/debian.sh index 57588e371a..2a188334b6 100755 --- a/util/install/debian.sh +++ b/util/install/debian.sh @@ -15,7 +15,8 @@ _qmk_install() { build-essential clang-format diffutils gcc git unzip wget zip \ python3-pip binutils-avr gcc-avr avr-libc binutils-arm-none-eabi \ gcc-arm-none-eabi libnewlib-arm-none-eabi avrdude dfu-programmer \ - dfu-util teensy-loader-cli libhidapi-hidraw0 libusb-dev + dfu-util teensy-loader-cli libhidapi-hidraw0 libusb-dev \ + picolibc-riscv64-unknown-elf gcc-riscv64-unknown-elf binutils-riscv64-unknown-elf python3 -m pip install --user -r $QMK_FIRMWARE_DIR/requirements.txt } -- cgit v1.2.3 From 5da04fb45b0d5cddc6f49f88ea9c6a4037ef82ce Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Wed, 3 Nov 2021 08:26:40 +1100 Subject: Update to ChibiOS 20.3.4, support builds against trunk (#14208) * Add support for building against ChibiOS svn/trunk. * Swap to 21.6.x * Update to latest branch revision as released version is broken. * Updated configs. * Conf updates. * Updated ChibiOS * Convert STM32L422 to actual L422 ChibiOS platform. * Downgrade to 20.3.4 as ChibiOS 21.6.x is being aborted. * Rollback L422-based boards. --- util/chibios_conf_updater.sh | 101 +++++------------------------------------- util/update_chibios_mirror.sh | 4 +- 2 files changed, 13 insertions(+), 92 deletions(-) (limited to 'util') diff --git a/util/chibios_conf_updater.sh b/util/chibios_conf_updater.sh index d1640b6729..a5699ca3cb 100755 --- a/util/chibios_conf_updater.sh +++ b/util/chibios_conf_updater.sh @@ -3,6 +3,17 @@ set -eEuo pipefail umask 022 +##################### +# You will need to get an older JDK -- JDK 8 +# +# !!!!!!!! DO NOT INSTALL THIS IF YOU HAVE AN EXISTING JDK OR JRE INSTALLED !!!!!!!! +# +# For Debian 10-ish distro's: +# wget -qO - https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public | sudo apt-key add - +# sudo add-apt-repository --yes https://adoptopenjdk.jfrog.io/adoptopenjdk/deb/ +# sudo apt-get update && sudo apt-get install adoptopenjdk-8-hotspot + + sinfo() { echo "$@" >&2 ; } shead() { sinfo "" ; sinfo "---------------------------------" ; sinfo "-- $@" ; sinfo "---------------------------------" ; } havecmd() { command command type "${1}" >/dev/null 2>&1 || return 1 ; } @@ -11,8 +22,6 @@ this_script="$(realpath "${BASH_SOURCE[0]}")" script_dir="$(realpath "$(dirname "$this_script")")" qmk_firmware_dir="$(realpath "$script_dir/../")" -declare -A file_hashes - export PATH="$PATH:$script_dir/fmpp/bin" build_fmpp() { @@ -45,67 +54,6 @@ find_chibi_files() { done } -revert_chibi_files() { - local search_path="$1" - shead "Reverting ChibiOS config/board files..." - 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 - pushd "$search_path" >/dev/null 2>&1 - local relpath=$(realpath --relative-to="$search_path" "$file") - git checkout upstream/develop -- "$relpath" || git checkout origin/develop -- "$relpath" || true - popd >/dev/null 2>&1 - done -} - -populate_file_hashes() { - local search_path="$1" - shead "Determining duplicate config/board files..." - 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 - local key="file_$(clang-format "$file" | sha1sum | cut -d' ' -f1)" - local relpath=$(realpath --relative-to="$search_path" "$file") - file_hashes[$key]="${file_hashes[$key]:-} $relpath" - done - for file in $(find_chibi_files "$search_path" -name board.mk -or -name board.chcfg) ; do - local key="file_$(cat "$file" | sha1sum | cut -d' ' -f1)" - local relpath=$(realpath --relative-to="$search_path" "$file") - file_hashes[$key]="${file_hashes[$key]:-} $relpath" - done -} - -determine_equivalent_files() { - local search_file="$1" - for K in "${!file_hashes[@]}"; do - for V in ${file_hashes[$K]}; do - if [[ "$V" == "$search_file" ]] ; then - for V in ${file_hashes[$K]}; do - echo "$V" - done - return 0 - fi - done - done - return 1 -} - -deploy_staged_files() { - shead "Deploying staged files..." - for file in $(find "$qmk_firmware_dir/util/chibios-upgrade-staging" -type f) ; do - local relpath=$(realpath --relative-to="$qmk_firmware_dir/util/chibios-upgrade-staging" "$file") - sinfo "Deploying staged file: $relpath" - for other in $(determine_equivalent_files "$relpath") ; do - sinfo " => $other" - cp "$qmk_firmware_dir/util/chibios-upgrade-staging/$relpath" "$qmk_firmware_dir/$other" - done - done -} - -swap_mcuconf_f3xx_f303() { - shead "Swapping STM32F3xx_MCUCONF -> STM32F303_MCUCONF..." - for file in $(find_chibi_files "$qmk_firmware_dir" -name mcuconf.h) ; do - sed -i 's#STM32F3xx_MCUCONF#STM32F303_MCUCONF#g' "$file" - dos2unix "$file" >/dev/null 2>&1 - done -} - upgrade_conf_files_generic() { local search_filename="$1" local update_script="$2" @@ -150,35 +98,8 @@ upgrade_mcuconf_files() { popd >/dev/null 2>&1 } -update_staged_files() { - shead "Updating staged files with ChibiOS upgraded versions..." - for file in $(find "$qmk_firmware_dir/util/chibios-upgrade-staging" -type f) ; do - local relpath=$(realpath --relative-to="$qmk_firmware_dir/util/chibios-upgrade-staging" "$file") - sinfo "Updating staged file: $relpath" - cp "$qmk_firmware_dir/$relpath" "$qmk_firmware_dir/util/chibios-upgrade-staging/$relpath" - done -} - havecmd fmpp || build_fmpp -revert_chibi_files "$qmk_firmware_dir" -populate_file_hashes "$qmk_firmware_dir" - -shead "Showing duplicate ChibiOS files..." -for K in "${!file_hashes[@]}"; do - sinfo ${K#file_}: - for V in ${file_hashes[$K]}; do - sinfo " $V" - done -done - -if [ "${1:-}" == "-r" ] ; then - exit 0 -fi - -swap_mcuconf_f3xx_f303 -deploy_staged_files upgrade_mcuconf_files upgrade_chconf_files upgrade_halconf_files -update_staged_files diff --git a/util/update_chibios_mirror.sh b/util/update_chibios_mirror.sh index 83aee22817..0bf648ebfd 100755 --- a/util/update_chibios_mirror.sh +++ b/util/update_chibios_mirror.sh @@ -7,10 +7,10 @@ chibios_branches="trunk stable_20.3.x stable_21.6.x" # The ChibiOS tags to mirror -chibios_tags="ver20.3.1 ver20.3.2 ver20.3.3 ver21.6.0" +chibios_tags="ver20.3.1 ver20.3.2 ver20.3.3 ver20.3.4 ver21.6.0" # The ChibiOS-Contrib branches to mirror -contrib_branches="chibios-20.3.x" +contrib_branches="chibios-20.3.x chibios-21.6.x" ################################ # Actions -- cgit v1.2.3 From 5c2052fd476cb1d15eab66c23016a1add93f6767 Mon Sep 17 00:00:00 2001 From: Stefan Kerkmann Date: Sat, 20 Nov 2021 21:04:16 +0100 Subject: [Core] RISC-V toolchain and picolibc fixes (#15109) * [Core] Fix RISC-V toolchain installation The risc-v toolchain is only available on distributions based on Debian 11+ so we check for their availability before installing them. * [Core] Fix heap symbols and syscalls for picolibc picolibc internally uses __heap_start and __heap_end instead of the defacto chibios linker script standard __heap_base__ and __heap_end__ therefore we introduce these symbols as an alias. Usually all memory used within QMK is statically allocated, but some algorithms make usage of malloc and friends. Also the timeval struct is not defined by picolibc for syscalls, therefore it is declared as stub. --- util/install/debian.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'util') diff --git a/util/install/debian.sh b/util/install/debian.sh index 2a188334b6..3e02919bdd 100755 --- a/util/install/debian.sh +++ b/util/install/debian.sh @@ -11,12 +11,18 @@ _qmk_install_prepare() { _qmk_install() { echo "Installing dependencies" - sudo apt-get -yq install \ + sudo apt-get --quiet --yes install \ build-essential clang-format diffutils gcc git unzip wget zip \ python3-pip binutils-avr gcc-avr avr-libc binutils-arm-none-eabi \ gcc-arm-none-eabi libnewlib-arm-none-eabi avrdude dfu-programmer \ - dfu-util teensy-loader-cli libhidapi-hidraw0 libusb-dev \ - picolibc-riscv64-unknown-elf gcc-riscv64-unknown-elf binutils-riscv64-unknown-elf + dfu-util teensy-loader-cli libhidapi-hidraw0 libusb-dev - python3 -m pip install --user -r $QMK_FIRMWARE_DIR/requirements.txt + # RISC-V toolchains with picolibc support are only available for distributions based on Debian 11+. + 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 + sudo apt-get --quiet --yes install picolibc-riscv64-unknown-elf \ + gcc-riscv64-unknown-elf \ + binutils-riscv64-unknown-elf + fi + + python3 -m pip install --user -r "$QMK_FIRMWARE_DIR"/requirements.txt } -- cgit v1.2.3 From 2d71ac7541e81ae4313cecc7e7597d45f9a96809 Mon Sep 17 00:00:00 2001 From: Sergey Vlasov Date: Sun, 21 Nov 2021 01:01:22 +0300 Subject: Add Keyboardio Atreus 2 Bootloader to udev rules (#15241) The Keyboardio Atreus 2 Bootloader is a clone of the Caterina bootloader with different USB VID:PID values (1209:2302): https://github.com/keyboardio/Atreus2-Bootloader --- util/udev/50-qmk.rules | 3 +++ 1 file changed, 3 insertions(+) (limited to 'util') diff --git a/util/udev/50-qmk.rules b/util/udev/50-qmk.rules index db27d4dc81..57806f9df0 100644 --- a/util/udev/50-qmk.rules +++ b/util/udev/50-qmk.rules @@ -33,6 +33,9 @@ SUBSYSTEMS=="usb", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="05dc", TAG+="uacc SUBSYSTEMS=="usb", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="6124", TAG+="uaccess", ENV{ID_MM_DEVICE_IGNORE}="1" # Caterina (Pro Micro) +## pid.codes shared PID +### Keyboardio Atreus 2 Bootloader +SUBSYSTEMS=="usb", ATTRS{idVendor}=="1209", ATTRS{idProduct}=="2302", TAG+="uaccess", ENV{ID_MM_DEVICE_IGNORE}="1" ## Spark Fun Electronics ### Pro Micro 3V3/8MHz SUBSYSTEMS=="usb", ATTRS{idVendor}=="1b4f", ATTRS{idProduct}=="9203", TAG+="uaccess", ENV{ID_MM_DEVICE_IGNORE}="1" -- cgit v1.2.3 From b04f66f2452494206673323c9495ea6a56c0cb06 Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Sat, 27 Nov 2021 09:11:03 +1100 Subject: Add script for performing compilation size regression investigations. (#15303) * Add script for performing compilation size regression investigations. * Print deltas * Correct scoping. * Concurrency control * Job count control, skip zeros (unless no build output), fix usage. * Add usage under -h arg. * Updated usage output. * Copyright header. --- util/size_regression.sh | 79 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100755 util/size_regression.sh (limited to 'util') diff --git a/util/size_regression.sh b/util/size_regression.sh new file mode 100755 index 0000000000..988d1d9b5b --- /dev/null +++ b/util/size_regression.sh @@ -0,0 +1,79 @@ +#!/bin/bash + +# Copyright 2021 Nick Brassel (@tzarc) +# SPDX-License-Identifier: GPL-2.0-or-later + +set -eEuo pipefail + +job_count=$(getconf _NPROCESSORS_ONLN 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 2) +source_ref="0.11.0" +dest_ref="develop" +ignore_ref="master" +unset skip_zero + +function usage() { + echo "Usage: $(basename "$0") [-h] [-j ] [-s ] [-d ] [-n] planck/rev6:default" + echo " -h : Shows this usage page." + echo " -j : Change the number of threads to execute with. Defaults to \`$job_count\`." + echo " -s : Use source commit, branch, tag, or sha1 to start the search. Defaults to \`$source_ref\`." + echo " -d : Use destination commit, branch, tag, or sha1 to end the search. Defaults to \`$dest_ref\`." + echo " -i : The branch to ignore refs from. Defaults to \`$ignore_ref\`." + echo " -n : Skips printing changes if the delta is zero." + exit 1 +} + +if [[ ${#} -eq 0 ]]; then + usage +fi + +while getopts "hj:s:d:i:n" opt "$@" ; do + case "$opt" in + h) usage; exit 0;; + j) job_count="${OPTARG:-}";; + s) source_ref="${OPTARG:-}";; + d) dest_ref="${OPTARG:-}";; + i) ignore_ref="${OPTARG:-}";; + n) skip_zero=1;; + \?) usage >&2; exit 1;; + esac +done + +# Work out the target board +shift $((OPTIND-1)) +keyboard_target=$1 + +last_size=0 +last_line="" +function build_executor() { + git rev-list --oneline --no-merges ${source_ref}...${dest_ref} ^${ignore_ref} | while IFS= read -r line ; do + revision=$(echo $line | cut -d' ' -f1) + + make distclean >/dev/null 2>&1 + git checkout $revision >/dev/null 2>&1 || { echo "Failed to check out revision ${revision}" >&2 ; exit 1 ; } + make -j${job_count} $keyboard_target >/dev/null 2>&1 || true + file_size=$(arm-none-eabi-size .build/*.elf 2>/dev/null | awk '/elf/ {print $1}' 2>/dev/null || true) + + if [[ "$last_size" == 0 ]] ; then last_size=$file_size ; fi + if [[ -z "$file_size" ]] ; then file_size=0 ; fi + + if [[ -n "$last_line" ]] ; then + size_delta=$(( $last_size - $file_size )) + if { [[ -n "${skip_zero:-}" ]] && [[ $size_delta -ne 0 ]] ; } || [[ $file_size -eq 0 ]] ; then + printf "Size: %8d, delta: %+6d -- %s\n" "$last_size" "$size_delta" "$last_line" + fi + fi + + last_size=$file_size + last_line=$line + done + + if [ -n "$last_line" ] ; then + size_delta=0 + printf "Size: %8d, delta: %+6d -- %s\n" "$last_size" "$size_delta" "$last_line" + fi +} + +# The actual execution of all the builds needs to be the last command in the entire script +# - During builds, this script file will disappear, so we need the entire script to be +# loaded into the script interpreter at the time of execution. Do not refactor. +build_executor -- cgit v1.2.3