diff options
Diffstat (limited to 'util')
-rwxr-xr-x | util/activate_msys2.sh | 1 | ||||
-rwxr-xr-x | util/activate_wsl.sh | 1 | ||||
-rwxr-xr-x | util/atmega32a_program.py | 110 | ||||
-rwxr-xr-x | util/docker_build.sh | 4 | ||||
-rwxr-xr-x | util/linux_install.sh | 18 | ||||
-rwxr-xr-x | util/macos_install.sh | 5 | ||||
-rwxr-xr-x | util/msys2_install.sh | 66 | ||||
-rwxr-xr-x | util/new_keyboard.sh | 21 | ||||
-rwxr-xr-x | util/travis_compiled_push.sh | 2 | ||||
-rwxr-xr-x | util/win_shared_install.sh | 4 |
10 files changed, 68 insertions, 164 deletions
diff --git a/util/activate_msys2.sh b/util/activate_msys2.sh index 1ddffbaad..85d645e6d 100755 --- a/util/activate_msys2.sh +++ b/util/activate_msys2.sh @@ -5,6 +5,7 @@ function export_variables { export PATH=$PATH:$util_dir export PATH=$PATH:$util_dir/dfu-programmer export PATH=$PATH:$util_dir/dfu-util-0.9-win64 + export PATH=$PATH:$util_dir/bootloadHID.2012-12-08/commandline export PATH=$PATH:$util_dir/flip/bin export PATH=$PATH:$util_dir/avr8-gnu-toolchain/bin export PATH=$PATH:$util_dir/gcc-arm-none-eabi/bin diff --git a/util/activate_wsl.sh b/util/activate_wsl.sh index e2312b56d..cd88d2b65 100755 --- a/util/activate_wsl.sh +++ b/util/activate_wsl.sh @@ -7,6 +7,7 @@ function export_variables { export DFU_PROGRAMMER=$download_dir/dfu-programmer/dfu-programmer.exe export DFU_UTIL=$download_dir/dfu-util-0.9-win64/dfu-util.exe export TEENSY_LOADER_CLI=$download_dir/teensy_loader_cli.exe + export BOOTLOADHID_PROGRAMMER=$download_dir/bootloadHID.2012-12-08/commandline/bootloadHID.exe export BATCHISP=batchisp.exe } diff --git a/util/atmega32a_program.py b/util/atmega32a_program.py deleted file mode 100755 index 9438c7e77..000000000 --- a/util/atmega32a_program.py +++ /dev/null @@ -1,110 +0,0 @@ -#!/usr/bin/env python -# Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com>, Sebastian Kaim <sebb@sebb767.de> -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - -from __future__ import print_function - -import os -import sys -import time -import argparse -import usb - - -def check_keyboard_normal_mode(vendor, product): - """Returns a device if a ps2avrGB device in normal made (that is in keyboard mode) or None if it is not found.""" - return usb.core.find(idVendor=vendor, idProduct=product) - -def check_keyboard_bootloader_mode(): - """Returns True if a ps2avrGB device in bootloader (flashable) mode is found and False otherwise.""" - return (usb.core.find(idVendor=0x16c0, idProduct=0x05df) is not None) - -def flash_keyboard(firmware_file): - """Calls bootloadHID to flash the given file to the device.""" - print('Flashing firmware to device ...') - if os.system('bootloadHID -r "%s"' % firmware_file) == 0: - print('\nDone!') - else: - print('\nbootloadHID returned an error.') - -def print_device_info(dev): - """Prints all infos for a given USB device""" - print('Device Information:') - print(' idVendor: %d (0x%04x)' % (dev.idVendor, dev.idVendor)) - print(' idProduct: %d (0x%04x)' % (dev.idProduct, dev.idProduct)) - print('Manufacturer: %s' % (dev.iManufacturer)) - print('Serial: %s' % (dev.iSerialNumber)) - print('Product: %s' % (dev.iProduct), end='\n\n') - -def send_device_to_bootloader_mode(dev): - """Tries to send a given ps2avrGB keyboard to bootloader mode to allow flashing.""" - try: - dev.set_configuration() - - request_type = usb.util.build_request_type( - usb.util.CTRL_OUT, - usb.util.CTRL_TYPE_CLASS, - usb.util.CTRL_RECIPIENT_DEVICE) - - USBRQ_HID_SET_REPORT = 0x09 - HID_REPORT_OPTION = 0x0301 - - dev.ctrl_transfer(request_type, USBRQ_HID_SET_REPORT, HID_REPORT_OPTION, 0, [0, 0, 0xFF] + [0] * 5) - except usb.core.USBError: - # for some reason I keep getting USBError, but it works! - pass - -def auto_int(value): - """Helper for argparse to enable auto base detection""" - return int(value, 0) - -parser = argparse.ArgumentParser(description='Flash bootloadHID device') -parser.add_argument('--vendor', type=auto_int, default=0x20A0, help='Non bootloader idVendor to search for (default: 0x%(default)04x)') -parser.add_argument('--product', type=auto_int, default=0x422D, help='Non bootloader idProduct to search for (default: 0x%(default)04x)') -parser.add_argument('firmware_hex', type=argparse.FileType('r'), help='Firmware hex file to flash') -args = parser.parse_args() - -kb = check_keyboard_normal_mode(args.vendor, args.product) - -if kb is not None: - print('Found a keyboard in normal mode. Attempting to send it to bootloader mode ...', end='') - send_device_to_bootloader_mode(kb) - print(' done.') - print("Hint: If your keyboard can't be set to bootloader mode automatically, plug it in while pressing the bootloader key to do so manually.") - print(" You can find more infos about this here: https://github.com/qmk/qmk_firmware/tree/master/keyboards/ps2avrGB#setting-the-board-to-bootloader-mode") - -attempts = 12 # 60 seconds -found = False -for attempt in range(1, attempts + 1): - print("Searching for keyboard in bootloader mode (%i/%i) ... " % (attempt, attempts), end='') - - if check_keyboard_bootloader_mode(): - print('Found', end='\n\n') - flash_keyboard(args.firmware_hex.name) - found = True - break - else: - print('Nothing.', end='') - - if attempt != attempts: # no need to wait on the last attempt - print(' Sleeping 5 seconds.', end='') - time.sleep(5) - - # print a newline - print() - -if not found: - print("Couldn't find a flashable keyboard. Aborting.") - sys.exit(2) diff --git a/util/docker_build.sh b/util/docker_build.sh index 99d59d169..bf13f5097 100755 --- a/util/docker_build.sh +++ b/util/docker_build.sh @@ -37,6 +37,9 @@ else exit 1 fi fi +if [ -z "$keyboard" ]; then + keyboard=all +fi if [ -n "$target" ]; then if [ "$(uname)" = "Linux" ] || docker-machine active >/dev/null 2>&1; then usb_args="--privileged -v /dev:/dev" @@ -51,6 +54,7 @@ dir=$(pwd -W 2>/dev/null) || dir=$PWD # Use Windows path if on Windows # Run container and build firmware docker run --rm -it $usb_args \ + --user $(id -u):$(id -g) \ -w /qmk_firmware \ -v "$dir":/qmk_firmware \ -e ALT_GET_KEYBOARDS=true \ diff --git a/util/linux_install.sh b/util/linux_install.sh index c54a80623..922981418 100755 --- a/util/linux_install.sh +++ b/util/linux_install.sh @@ -10,6 +10,16 @@ SOLUS_INFO="Your tools are now installed. To start using them, open new terminal util_dir=$(dirname "$0") +# For those distros that do not package bootloadHID +install_bootloadhid() { + wget https://www.obdev.at/downloads/vusb/bootloadHID.2012-12-08.tar.gz -O - | tar -xz -C /tmp + cd /tmp/bootloadHID.2012-12-08/commandline/ + if make; then + sudo cp bootloadHID /usr/local/bin + fi + cd - +} + if grep ID /etc/os-release | grep -qE "fedora"; then sudo dnf install \ arm-none-eabi-binutils-cs \ @@ -28,6 +38,7 @@ if grep ID /etc/os-release | grep -qE "fedora"; then glibc-headers \ kernel-devel \ kernel-headers \ + libusb-devel \ make \ perl \ python3 \ @@ -54,7 +65,9 @@ elif grep ID /etc/os-release | grep -qE 'debian|ubuntu'; then gcc-avr \ git \ libnewlib-arm-none-eabi \ + libusb-dev \ python3 \ + python3-pip \ unzip \ wget \ zip @@ -70,12 +83,14 @@ elif grep ID /etc/os-release | grep -q 'arch\|manjaro'; then avr-libc \ avr-gcc \ base-devel \ + bootloadhid \ clang \ dfu-programmer \ dfu-util \ diffutils \ gcc \ git \ + libusb-compat \ python \ python-pip \ unzip \ @@ -138,6 +153,7 @@ elif grep ID /etc/os-release | grep -qE "opensuse|tumbleweed"; then dfu-tool \ dfu-programmer \ gcc \ + libusb-devel \ python3 \ unzip \ wget \ @@ -177,6 +193,7 @@ elif grep ID /etc/os-release | grep -q solus; then avrdude \ dfu-util \ dfu-programmer \ + libusb-devel \ python3 \ git \ wget \ @@ -214,4 +231,5 @@ else fi # Global install tasks +install_bootloadhid pip3 install --user -r ${util_dir}/../requirements.txt diff --git a/util/macos_install.sh b/util/macos_install.sh index f993003f0..a4037cce9 100755 --- a/util/macos_install.sh +++ b/util/macos_install.sh @@ -24,6 +24,9 @@ fi brew tap osx-cross/avr brew tap osx-cross/arm brew update -brew install avr-gcc@8 arm-gcc-bin dfu-programmer avrdude clang-format dfu-util python3 +brew install avr-gcc@8 arm-gcc-bin@8 dfu-programmer avrdude clang-format dfu-util python3 +brew install --HEAD https://raw.githubusercontent.com/robertgzr/homebrew-tap/master/bootloadhid.rb brew link --force avr-gcc@8 +brew link --force arm-gcc-bin@8 + pip3 install -r "${util_dir}/../requirements.txt" diff --git a/util/msys2_install.sh b/util/msys2_install.sh index 58397c7a3..d1e24ca6d 100755 --- a/util/msys2_install.sh +++ b/util/msys2_install.sh @@ -8,25 +8,27 @@ installflip=false util_dir=$(dirname "$0") echo "Installing dependencies needed for the installation (quazip)" -pacman --needed -S base-devel mingw-w64-x86_64-toolchain mingw-w64-x86_64-clang msys/git msys/p7zip msys/python3 msys/unzip +pacman --needed --noconfirm --disable-download-timeout -Sy base-devel mingw-w64-x86_64-toolchain mingw-w64-x86_64-clang msys/git msys/p7zip mingw-w64-x86_64-python3-pip msys/unzip source "$dir/win_shared_install.sh" function install_avr { rm -f -r "$avrtools" - wget "http://ww1.microchip.com/downloads/en/DeviceDoc/avr8-gnu-toolchain-3.6.1.1752-win32.any.x86.zip" + wget "https://blog.zakkemble.net/download/avr-gcc-8.3.0-x86-mingw.zip" echo "Extracting AVR toolchain..." - unzip -q avr8-gnu-toolchain-3.6.1.1752-win32.any.x86.zip - mv avr8-gnu-toolchain-win32_x86/ avr8-gnu-toolchain - rm __MACOSX -R - rm avr8-gnu-toolchain-3.6.1.1752-win32.any.x86.zip - pacman --needed -S mingw-w64-x86_64-avrdude + unzip -q -d . avr-gcc-8.3.0-x86-mingw.zip + mv avr-gcc-8.3.0-x86-mingw avr8-gnu-toolchain + rm avr8-gnu-toolchain/bin/make.exe + rm avr-gcc-8.3.0-x86-mingw.zip + pacman --needed --disable-download-timeout -S mingw-w64-x86_64-avrdude } function install_arm { - wget -O gcc-arm-none-eabi.zip "https://developer.arm.com/-/media/Files/downloads/gnu-rm/6-2017q2/gcc-arm-none-eabi-6-2017-q2-update-win32.zip?product=GNU%20ARM%20Embedded%20Toolchain,ZIP,,Windows,6-2017-q2-update" - unzip -d gcc-arm-none-eabi gcc-arm-none-eabi.zip - rm gcc-arm-none-eabi.zip + rm -f -r "$armtools" + wget -O gcc-arm-none-eabi-8-2019-q3-update-win32.zip "https://developer.arm.com/-/media/Files/downloads/gnu-rm/8-2019q3/RC1.1/gcc-arm-none-eabi-8-2019-q3-update-win32.zip" + echo "Extracting ARM toolchain..." + unzip -q -d gcc-arm-none-eabi gcc-arm-none-eabi-8-2019-q3-update-win32.zip + rm gcc-arm-none-eabi-8-2019-q3-update-win32.zip } function extract_flip { @@ -43,17 +45,10 @@ if [ -f "FlipInstaller.exe" ]; then fi if [ ! -d "$avrtools" ]; then - while true; do - echo - echo "The AVR toolchain is not installed." - echo "This is needed for building AVR based keboards." - read -p "Do you want to install it? (Y/N) " res - case $res in - [Yy]* ) install_avr; break;; - [Nn]* ) break;; - * ) echo "Invalid answer";; - esac - done + echo + echo "The AVR toolchain is not installed." + echo "This is needed for building AVR based keyboards." + install_avr else while true; do echo @@ -68,17 +63,10 @@ else fi if [ ! -d "$armtools" ]; then - while true; do - echo - echo "The ARM toolchain is not installed." - echo "This is needed for building ARM based keyboards." - read -p "Do you want to install it? (Y/N) " res - case $res in - [Yy]* ) install_arm; break;; - [Nn]* ) break;; - * ) echo "Invalid answer";; - esac - done + echo + echo "The ARM toolchain is not installed." + echo "This is needed for building ARM based keyboards." + install_arm else while true; do echo @@ -103,18 +91,10 @@ then echo "The line source ~/qmk_utils/activate_msys2.sh is already added to your /.bashrc" echo "Not adding it twice!" else - while true; do echo - echo "Do you want to add 'source ~/qmk_utils/activate_msys2.sh' to the end of your" - echo ".bashrc file? Without this make won't find the needed utils, so if you don't" - echo "want to do it automatically, then you have to do it manually later." - read -p "(Y/N)? " res - case $res in - [Yy]* ) echo "source ~/qmk_utils/activate_msys2.sh" >> ~/.bashrc; break;; - [Nn]* ) break;; - * ) echo "Invalid answer";; - esac - done + echo "Adding 'source ~/qmk_utils/activate_msys2.sh' to the end of your" + echo ".bashrc file. Without this make won't find the needed utils." + echo "source ~/qmk_utils/activate_msys2.sh" >> ~/.bashrc; fi echo diff --git a/util/new_keyboard.sh b/util/new_keyboard.sh index 11c6497e2..1f08790ad 100755 --- a/util/new_keyboard.sh +++ b/util/new_keyboard.sh @@ -32,8 +32,10 @@ set_git_username() { # Copy the template files to the new keyboard directory. copy_templates() { + mkdir -p "$keyboard_dir" + echo -n "Copying base template files..." - cp -r "quantum/template/base" "${keyboard_dir}" + cp -r "quantum/template/base/." "${keyboard_dir}" echo " done" echo -n "Copying $keyboard_type template files..." @@ -41,8 +43,8 @@ copy_templates() { echo " done" echo -n "Renaming keyboard files..." - mv "${keyboard_dir}/keyboard.c" "${keyboard_dir}/${keyboard_name}.c" - mv "${keyboard_dir}/keyboard.h" "${keyboard_dir}/${keyboard_name}.h" + mv "${keyboard_dir}/keyboard.c" "${keyboard_dir}/${keyboard_base_name}.c" + mv "${keyboard_dir}/keyboard.h" "${keyboard_dir}/${keyboard_base_name}.h" echo " done" } @@ -74,8 +76,8 @@ replace_placeholders() { replace_year_placeholders() { local replace_year_filenames=( "${keyboard_dir}/config.h" - "${keyboard_dir}/${keyboard_name}.c" - "${keyboard_dir}/${keyboard_name}.h" + "${keyboard_dir}/${keyboard_base_name}.c" + "${keyboard_dir}/${keyboard_base_name}.h" "${keyboard_dir}/keymaps/default/config.h" "${keyboard_dir}/keymaps/default/keymap.c" ) @@ -88,10 +90,10 @@ replace_keyboard_placeholders() { "${keyboard_dir}/config.h" "${keyboard_dir}/info.json" "${keyboard_dir}/readme.md" - "${keyboard_dir}/${keyboard_name}.c" + "${keyboard_dir}/${keyboard_base_name}.c" "${keyboard_dir}/keymaps/default/readme.md" ) - replace_placeholders "%KEYBOARD%" "$keyboard_name" "${replace_keyboard_filenames[@]}" + replace_placeholders "%KEYBOARD%" "$keyboard_base_name" "${replace_keyboard_filenames[@]}" } # Replace %YOUR_NAME% with the username. @@ -100,8 +102,8 @@ replace_name_placeholders() { "${keyboard_dir}/config.h" "${keyboard_dir}/info.json" "${keyboard_dir}/readme.md" - "${keyboard_dir}/${keyboard_name}.c" - "${keyboard_dir}/${keyboard_name}.h" + "${keyboard_dir}/${keyboard_base_name}.c" + "${keyboard_dir}/${keyboard_base_name}.h" "${keyboard_dir}/keymaps/default/config.h" "${keyboard_dir}/keymaps/default/keymap.c" ) @@ -136,6 +138,7 @@ echo while [ -z "$keyboard_name" ]; do prompt "Keyboard Name" "" keyboard_name=$prompt_return + keyboard_base_name=$(basename $keyboard_name) done keyboard_dir="keyboards/$keyboard_name" diff --git a/util/travis_compiled_push.sh b/util/travis_compiled_push.sh index e0490cd70..c18e42a29 100755 --- a/util/travis_compiled_push.sh +++ b/util/travis_compiled_push.sh @@ -13,7 +13,7 @@ if [[ "$TRAVIS_BRANCH" == "master" && "$TRAVIS_PULL_REQUEST" == "false" ]] ; the # fix formatting git checkout master git diff --diff-filter=AM --name-only -n 1 -z ${TRAVIS_COMMIT_RANGE} | xargs -0 dos2unix -git diff --diff-filter=AM --name-only -n 1 -z ${TRAVIS_COMMIT_RANGE} | grep -e '^drivers' -e '^quantum' -e '^tests' -e '^tmk_core' | grep -v 'quantum/template' | xargs -0 clang-format +git diff --diff-filter=AM --name-only -n 1 -z ${TRAVIS_COMMIT_RANGE} '*.c' '*.h' '*.cpp' | grep -z -e '^drivers' -e '^quantum' -e '^tests' -e '^tmk_core' | grep -zv -e 'quantum/template' -e 'tmk_core/protocol/usb_hid' | xargs -0 clang-format -i git diff --diff-filter=AM --name-only -n 1 -z ${TRAVIS_COMMIT_RANGE} | xargs -0 git add git commit -m "format code according to conventions [skip ci]" && git push git@github.com:qmk/qmk_firmware.git master diff --git a/util/win_shared_install.sh b/util/win_shared_install.sh index f8fc9308f..7ad000bfc 100755 --- a/util/win_shared_install.sh +++ b/util/win_shared_install.sh @@ -18,6 +18,10 @@ function install_utils { wget 'https://www.pjrc.com/teensy/teensy_loader_cli_windows.zip' unzip teensy_loader_cli_windows.zip + echo "Installing bootloadHID" + wget 'https://www.obdev.at/downloads/vusb/bootloadHID.2012-12-08.zip' + unzip bootloadHID.2012-12-08.zip + echo "Installing Atmel Flip" wget 'http://ww1.microchip.com/downloads/en/DeviceDoc/Flip%20Installer%20-%203.4.7.112.exe' mv Flip\ Installer\ \-\ 3.4.7.112.exe FlipInstaller.exe |