From b3e025f443f0b86f56e2ed2945579f564d3ac57a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20Monda?= Date: Mon, 16 Oct 2017 23:26:37 +0200 Subject: [PATCH 01/29] Make reenumerate() set Wormhole.timeoutMs based on GenericHidInBuffer+2 --- lib/bootloader | 2 +- right/src/usb_protocol_handler.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/bootloader b/lib/bootloader index b754ecb..40cbba1 160000 --- a/lib/bootloader +++ b/lib/bootloader @@ -1 +1 @@ -Subproject commit b754ecbe686ff8f622d658f6a5768c9ef1d89995 +Subproject commit 40cbba1da1107d8adc320a130b661c28c8087f62 diff --git a/right/src/usb_protocol_handler.c b/right/src/usb_protocol_handler.c index 6f8d97b..d3c8042 100644 --- a/right/src/usb_protocol_handler.c +++ b/right/src/usb_protocol_handler.c @@ -72,6 +72,7 @@ void reenumerate(void) { Wormhole.magicNumber = WORMHOLE_MAGIC_NUMBER; Wormhole.enumerationMode = GenericHidInBuffer[1]; + Wormhole.timeoutMs = *((uint32_t*)(GenericHidInBuffer+2)); SCB->AIRCR = 0x5FA< Date: Tue, 17 Oct 2017 00:30:03 +0200 Subject: [PATCH 02/29] Fix indentation. --- right/src/usb_protocol_handler.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/right/src/usb_protocol_handler.h b/right/src/usb_protocol_handler.h index 11445e9..f4808df 100644 --- a/right/src/usb_protocol_handler.h +++ b/right/src/usb_protocol_handler.h @@ -23,7 +23,7 @@ UsbCommand_ReadUserConfiguration = 15, UsbCommand_GetKeyboardState = 16, UsbCommand_GetDebugInfo = 17, - UsbCommand_JumpToSlaveBootloader = 18, + UsbCommand_JumpToSlaveBootloader = 18, } usb_command_t; typedef enum { From 3230b94973c7c6b8afdf8396c1ac40d3d8daebb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20Monda?= Date: Tue, 17 Oct 2017 00:58:23 +0200 Subject: [PATCH 03/29] Make the left half call NVIC_SystemReset() upon receiving SlaveCommand_JumpToBootloader instead of jumping to the ROM address of the bootloader. This way the bootloader timeouts. Remove bootloader.c because it only contained JumpToBootloader() which is now unused. --- left/src/slave_protocol_handler.c | 2 +- shared/bootloader.c | 12 ------------ 2 files changed, 1 insertion(+), 13 deletions(-) delete mode 100644 shared/bootloader.c diff --git a/left/src/slave_protocol_handler.c b/left/src/slave_protocol_handler.c index 9e836e7..a517264 100644 --- a/left/src/slave_protocol_handler.c +++ b/left/src/slave_protocol_handler.c @@ -43,7 +43,7 @@ void SlaveRxHandler(void) uint8_t commandId = RxMessage.data[0]; switch (commandId) { case SlaveCommand_JumpToBootloader: - JumpToBootloader(); + NVIC_SystemReset(); break; case SlaveCommand_SetTestLed: TxMessage.length = 0; diff --git a/shared/bootloader.c b/shared/bootloader.c deleted file mode 100644 index 98832f7..0000000 --- a/shared/bootloader.c +++ /dev/null @@ -1,12 +0,0 @@ -#include "bootloader.h" - -void JumpToBootloader(void) { - uint32_t runBootloaderAddress; - void (*runBootloader)(void *arg); - - // Read the function address from the ROM API tree. - runBootloaderAddress = **(uint32_t **)(0x1c00001c); - runBootloader = (void (*)(void * arg))runBootloaderAddress; - - runBootloader(NULL); -} From 8951ca992b2e079bce955e904362f9135e93e64c Mon Sep 17 00:00:00 2001 From: Stephen Date: Thu, 19 Oct 2017 18:11:00 +0100 Subject: [PATCH 04/29] Build linux in CI (#61) * Linux build * Trigger another build * Another travis bump * cleanup travis * quotes required * Update .travis.yml * Update .travis.yml * try double escape * Update .travis.yml --- .travis.yml | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8e63734..2cdc8eb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,18 +1,25 @@ language: generic -os: osx cache: directories: - $HOME/Library/Caches/Homebrew/Cask -install: - - brew update && brew bundle -v - - /Applications/Eclipse\ CPP.app/Contents/MacOS/eclipse -noSplash - -application org.eclipse.equinox.p2.director - -repository http://gnuarmeclipse.sourceforge.net/updates - -installIUs ilg.gnuarmeclipse.managedbuild.cross.feature.group - -profileProperties org.eclipse.update.install.features=true -script: - - /Applications/Eclipse\ CPP.app/Contents/MacOS/eclipse -noSplash - -application org.eclipse.cdt.managedbuilder.core.headlessbuild - -import $TRAVIS_BUILD_DIR/left/build/kds - -import $TRAVIS_BUILD_DIR/right/build/kds - -build all +install: eclipse -noSplash + -application org.eclipse.equinox.p2.director + -repository http://gnuarmeclipse.sourceforge.net/updates + -installIUs ilg.gnuarmeclipse.managedbuild.cross.feature.group + -profileProperties org.eclipse.update.install.features=true +script: eclipse -noSplash + -application org.eclipse.cdt.managedbuilder.core.headlessbuild + -import $TRAVIS_BUILD_DIR/left/build/kds + -import $TRAVIS_BUILD_DIR/right/build/kds + -build all +matrix: + include: + - os: linux + sudo: required + before_install: + - curl https://nixos.org/nix/install | sh && . ~/.nix-profile/etc/profile.d/nix.sh + - nix-env -i gcc-arm-embedded-4.8-2014q1-20140314 + - nix-env -i eclipse-cpp + - os: osx + env: PATH="$PATH:/Applications/Eclipse CPP.app/Contents/MacOS" + before_install: brew update && brew bundle -v From 3d46584b795588dfa65dd39878394c86a5c45600 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20Monda?= Date: Fri, 20 Oct 2017 00:31:06 +0200 Subject: [PATCH 05/29] Don't try to npm install the dependencies of jump-to-bootloader.js but rather display instructions. --- right/build/kds/blhost-unix.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/right/build/kds/blhost-unix.sh b/right/build/kds/blhost-unix.sh index bcfce79..393d987 100755 --- a/right/build/kds/blhost-unix.sh +++ b/right/build/kds/blhost-unix.sh @@ -3,8 +3,8 @@ set -e # fail the script if a command fails PATH=$PATH:/usr/local/bin # This should make node and npm accessible on OSX. firmware_image=`pwd`/$1 -usb_dir=../../../lib/agent/usb -usb_binding=$usb_dir/node_modules/usb/build/Release/usb_bindings.node +usb_dir=../../../lib/agent/packages/usb +usb_binding=$usb_dir/node_modules/node-hid/build/Release/HID.node case "$(uname -s)" in Linux) @@ -24,8 +24,8 @@ blhost="../../../lib/bootloader/bin/Tools/blhost/$blhost_path/blhost --usb 0x1d5 set -x # echo on if [ ! -f $usb_binding ]; then - cd $usb_dir - npm install + echo 'You have to make jump-to-bootloader.js work by executing `npm i` in ${UhkFirmwareDirectory}/lib/agent' + exit 1 fi $usb_dir/jump-to-bootloader.js From 968c6c04167369f09d0fb317c40810f836905b69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20Monda?= Date: Fri, 20 Oct 2017 00:34:01 +0200 Subject: [PATCH 06/29] Call NVIC_SystemReset() instead of custom code. --- right/src/usb_protocol_handler.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/right/src/usb_protocol_handler.c b/right/src/usb_protocol_handler.c index d3c8042..d22d07d 100644 --- a/right/src/usb_protocol_handler.c +++ b/right/src/usb_protocol_handler.c @@ -73,8 +73,7 @@ void reenumerate(void) Wormhole.magicNumber = WORMHOLE_MAGIC_NUMBER; Wormhole.enumerationMode = GenericHidInBuffer[1]; Wormhole.timeoutMs = *((uint32_t*)(GenericHidInBuffer+2)); - SCB->AIRCR = 0x5FA< Date: Fri, 20 Oct 2017 00:34:45 +0200 Subject: [PATCH 07/29] Reference the latest version of Agent, containing the fixed uhk.js which makes jump-to-bootloader.js work. --- lib/agent | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/agent b/lib/agent index 3b59a1a..7c7fde6 160000 --- a/lib/agent +++ b/lib/agent @@ -1 +1 @@ -Subproject commit 3b59a1a6fadaa981a4ecf8db64d504407824d11a +Subproject commit 7c7fde6d30e213fdd958168d0f9a2d312f8b8bee From 25f80178797c25fa1d8b58be62097bef7ae6e4d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20Monda?= Date: Fri, 20 Oct 2017 00:52:32 +0200 Subject: [PATCH 08/29] Get rid of the now obsoleted bootloader_config.h --- right/src/buspal/bootloader_config.h | 6 ------ right/src/buspal/bus_pal_hardware.c | 1 - right/src/main.c | 1 - right/src/usb_composite_device.c | 1 - 4 files changed, 9 deletions(-) delete mode 100644 right/src/buspal/bootloader_config.h diff --git a/right/src/buspal/bootloader_config.h b/right/src/buspal/bootloader_config.h deleted file mode 100644 index 468cea4..0000000 --- a/right/src/buspal/bootloader_config.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef __BOOTLOADER_CONFIG_H__ -#define __BOOTLOADER_CONFIG_H__ - -//#define ENABLE_BUSPAL - -#endif diff --git a/right/src/buspal/bus_pal_hardware.c b/right/src/buspal/bus_pal_hardware.c index 9ada628..bd85b08 100644 --- a/right/src/buspal/bus_pal_hardware.c +++ b/right/src/buspal/bus_pal_hardware.c @@ -2,7 +2,6 @@ #include "usb_descriptor.h" #include "usb_device_config.h" #include "composite.h" -#include "bootloader_config.h" #include "microseconds/microseconds.h" #include "i2c.h" #include "peripherals/test_led.h" diff --git a/right/src/main.c b/right/src/main.c index 3b4917e..83e1d89 100644 --- a/right/src/main.c +++ b/right/src/main.c @@ -10,7 +10,6 @@ #include "usb_interfaces/usb_interface_basic_keyboard.h" #include "usb_interfaces/usb_interface_media_keyboard.h" #include "bus_pal_hardware.h" -#include "bootloader_config.h" #include "command.h" #include "bootloader/wormhole.h" #include "eeprom.h" diff --git a/right/src/usb_composite_device.c b/right/src/usb_composite_device.c index 77fdcc9..b7f7829 100644 --- a/right/src/usb_composite_device.c +++ b/right/src/usb_composite_device.c @@ -2,7 +2,6 @@ #include "usb_composite_device.h" #include "usb_descriptors/usb_descriptor_hid.h" #include "usb_descriptors/usb_descriptor_strings.h" -#include "bootloader_config.h" #include "bus_pal_hardware.h" #include "bootloader/wormhole.h" From a052f4f59c3351d2f5ce3497598dd618fb6f26ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20Monda?= Date: Sat, 21 Oct 2017 01:27:33 +0200 Subject: [PATCH 09/29] Add blhost script for the left firmware, too. --- left/build/kds/blhost-unix.sh | 38 +++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 left/build/kds/blhost-unix.sh diff --git a/left/build/kds/blhost-unix.sh b/left/build/kds/blhost-unix.sh new file mode 100755 index 0000000..bd49087 --- /dev/null +++ b/left/build/kds/blhost-unix.sh @@ -0,0 +1,38 @@ +#!/bin/sh +set -e # fail the script if a command fails + +PATH=$PATH:/usr/local/bin # This should make node and npm accessible on OSX. +firmware_image=`pwd`/$1 +usb_dir=../../../lib/agent/packages/usb +usb_binding=$usb_dir/node_modules/usb/build/Release/usb_bindings.node + +case "$(uname -s)" in + Linux) + blhost_path=linux/amd64 + ;; + Darwin) + blhost_path=mac + ;; + *) + echo 'Your operating system is not supported.' + exit 1 + ;; +esac + +blhost="../../../lib/bootloader/bin/Tools/blhost/$blhost_path/blhost --usb 0x1d50,0x6121 --buspal i2c,0x10,100k" + +set -x # echo on + +#if [ ! -f $usb_binding ]; then +# cd $usb_dir +# npm install +#fi + +$usb_dir/jump-to-slave-bootloader.js +$usb_dir/jump-to-bootloader.js buspal +sleep 1 +$blhost get-property 1 +$blhost flash-erase-all-unsecure +$blhost write-memory 0x0 uhk-left-release-srec/uhk-left.bin +$blhost reset +../../../lib/bootloader/bin/Tools/blhost/$blhost_path/blhost --usb 0x1d50,0x6121 reset From 89fef3d93317f08e106c0327b5fc90c0fff0cef9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20Monda?= Date: Sat, 21 Oct 2017 01:29:05 +0200 Subject: [PATCH 10/29] Upon receiving the reset BusPal command, reset the MCU and reenumerate in normal keyboard mode. --- right/src/buspal/command.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/right/src/buspal/command.c b/right/src/buspal/command.c index a22ad99..d5dd11b 100644 --- a/right/src/buspal/command.c +++ b/right/src/buspal/command.c @@ -6,6 +6,8 @@ #if FIXED_BUSPAL_BOOTLOADER #include "microseconds/microseconds.h" #endif +#include "bootloader/wormhole.h" + command_processor_data_t g_commandData; buspal_state_t g_buspalState = kBuspal_Idle; @@ -483,6 +485,10 @@ status_t bootloader_command_pump() handle_write_memory_command(g_commandData.packet, g_commandData.packetLength); g_commandData.state = kCommandState_DataPhaseWrite; + } else if (cmdTag == kCommandTag_Reset) { + Wormhole.magicNumber = WORMHOLE_MAGIC_NUMBER; + Wormhole.enumerationMode = EnumerationMode_NormalKeyboard; + NVIC_SystemReset(); } status = handle_command_internal(g_commandData.packet, g_commandData.packetLength); From 2e07627359579b8e75c5132b4f2ba0feea8a6538 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20Monda?= Date: Sat, 21 Oct 2017 03:12:21 +0200 Subject: [PATCH 11/29] Temporarily increase left bootloader timeout from 100ms to 3000 ms for testing purposes. --- shared/bootloader.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/bootloader.h b/shared/bootloader.h index 62894a9..fc1434e 100644 --- a/shared/bootloader.h +++ b/shared/bootloader.h @@ -11,7 +11,7 @@ // Macros: #define BOOTLOADER_TAG 0x6766636B - #define BOOTLOADER_TIMEOUT_MS 100 + #define BOOTLOADER_TIMEOUT_MS 3000 #define CLOCK_FLAG_HIGH_SPEED_MODE 0x01 #define DEFINE_BOOTLOADER_CONFIG_AREA(address) \ From e9920cfebb0d3db3673422f0a03aa296d8afddb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20Monda?= Date: Sat, 21 Oct 2017 03:28:54 +0200 Subject: [PATCH 12/29] Increase the delay from 1s to 2s and flash the firmware script argument. --- left/build/kds/blhost-unix.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/left/build/kds/blhost-unix.sh b/left/build/kds/blhost-unix.sh index bd49087..e796507 100755 --- a/left/build/kds/blhost-unix.sh +++ b/left/build/kds/blhost-unix.sh @@ -30,9 +30,9 @@ set -x # echo on $usb_dir/jump-to-slave-bootloader.js $usb_dir/jump-to-bootloader.js buspal -sleep 1 +sleep 2 $blhost get-property 1 $blhost flash-erase-all-unsecure -$blhost write-memory 0x0 uhk-left-release-srec/uhk-left.bin +$blhost write-memory 0x0 "$firmware_image" $blhost reset ../../../lib/bootloader/bin/Tools/blhost/$blhost_path/blhost --usb 0x1d50,0x6121 reset From f67bcced4a598a7d8dbcf8e07a32fb49fa68a755 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20Monda?= Date: Sat, 21 Oct 2017 03:35:17 +0200 Subject: [PATCH 13/29] Keep only one release and one debug build configuration. Add related kboot run configurations. --- left/build/kds/.cproject | 320 +------------------ left/build/kds/uhk-left release jlink.launch | 2 +- lib/agent | 2 +- 3 files changed, 6 insertions(+), 318 deletions(-) diff --git a/left/build/kds/.cproject b/left/build/kds/.cproject index cbdf1f3..c4dc44f 100644 --- a/left/build/kds/.cproject +++ b/left/build/kds/.cproject @@ -160,320 +160,8 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -485,7 +173,7 @@ - +