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
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 @@
-
+
@@ -608,7 +296,7 @@
-
+
@@ -656,11 +344,11 @@
+
-
diff --git a/left/build/kds/uhk-left release jlink.launch b/left/build/kds/uhk-left release jlink.launch
index 4ca5813..ca1a053 100644
--- a/left/build/kds/uhk-left release jlink.launch
+++ b/left/build/kds/uhk-left release jlink.launch
@@ -70,7 +70,7 @@
-
+
diff --git a/left/src/main.c b/left/src/main.c
index 623793f..81e31ed 100644
--- a/left/src/main.c
+++ b/left/src/main.c
@@ -36,17 +36,12 @@ key_matrix_t keyMatrix = {
}
};
-#define ALWAYS_ENTER_BOOTLOADER (0)
- /*! set to 1 for easier bootloader debugging. With this, the KL03 always enters bootloader mode after reset */
-
int main(void)
{
InitClock();
InitPeripherals();
KeyMatrix_Init(&keyMatrix);
-#if ALWAYS_ENTER_BOOTLOADER
- JumpToBootloader(); /* << EST: \todo Temporary only */
-#endif
+
while (1) {
KeyMatrix_Scan(&keyMatrix);
__WFI();
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/lib/agent b/lib/agent
index 3b59a1a..133f8be 160000
--- a/lib/agent
+++ b/lib/agent
@@ -1 +1 @@
-Subproject commit 3b59a1a6fadaa981a4ecf8db64d504407824d11a
+Subproject commit 133f8be370b3c8919a10b3da8597974297dc2f5d
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/package.json b/package.json
index 00ad51b..3a39c42 100644
--- a/package.json
+++ b/package.json
@@ -11,6 +11,10 @@
"bugs": {
"url": "https://github.com/UltimateHackingKeyboard/firmware/issues"
},
+ "dependencies": {
+ "commander": "^2.11.0",
+ "shelljs": "^0.7.8"
+ },
"version": "2.1.0",
"dataModelVersion": "1.0.0",
"usbProtocolVersion": "1.2.0",
diff --git a/right/build/kds/blhost-unix.sh b/right/build/kds/blhost-unix.sh
index bcfce79..b8b1f1f 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,11 +24,11 @@ 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
+$usb_dir/reenumerate.js bootloader
$blhost flash-security-disable 0403020108070605
$blhost flash-erase-region 0xc000 475136
$blhost flash-image $firmware_image
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/buspal/command.c b/right/src/buspal/command.c
index a22ad99..99e9445 100644
--- a/right/src/buspal/command.c
+++ b/right/src/buspal/command.c
@@ -3,9 +3,10 @@
#include "crc16.h"
#include "bus_pal_hardware.h"
#include "peripherals/test_led.h"
-#if FIXED_BUSPAL_BOOTLOADER
- #include "microseconds/microseconds.h"
-#endif
+#include "microseconds/microseconds.h"
+#include "bootloader/wormhole.h"
+
+#define FIXED_BUSPAL_BOOTLOADER 1 // Used to mark the fixed BusPal bootloader. Macro usage can be removed in the future.
command_processor_data_t g_commandData;
buspal_state_t g_buspalState = kBuspal_Idle;
@@ -483,6 +484,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);
diff --git a/right/src/config.h b/right/src/config.h
index a9d4bcc..f5d3291 100644
--- a/right/src/config.h
+++ b/right/src/config.h
@@ -5,7 +5,5 @@
#define I2C_WATCHDOG
// #define LED_DRIVER_STRESS_TEST
- #define FIXED_BUSPAL_BOOTLOADER 1 // Used to mark the fixed BusPal bootloader. Macro usage can be removed in the future.
-// #define FORCE_BUSPAL 1
#endif
diff --git a/right/src/main.c b/right/src/main.c
index 3b4917e..cdc2ab5 100644
--- a/right/src/main.c
+++ b/right/src/main.c
@@ -9,8 +9,8 @@
#include "peripherals/test_led.h"
#include "usb_interfaces/usb_interface_basic_keyboard.h"
#include "usb_interfaces/usb_interface_media_keyboard.h"
+#include "usb_protocol_handler.h"
#include "bus_pal_hardware.h"
-#include "bootloader_config.h"
#include "command.h"
#include "bootloader/wormhole.h"
#include "eeprom.h"
@@ -44,13 +44,14 @@ void UpdateUsbReports(void)
return;
}
+ KeyMatrix_Scan(&KeyMatrix);
+
+ memcpy(CurrentKeyStates[SlotId_RightKeyboardHalf], KeyMatrix.keyStates, MAX_KEY_COUNT_PER_MODULE);
+
ResetActiveUsbBasicKeyboardReport();
ResetActiveUsbMediaKeyboardReport();
ResetActiveUsbSystemKeyboardReport();
- KeyMatrix_Scan(&KeyMatrix);
-
- memcpy(CurrentKeyStates[SlotId_RightKeyboardHalf], KeyMatrix.keyStates, MAX_KEY_COUNT_PER_MODULE);
UpdateActiveUsbReports();
SwitchActiveUsbBasicKeyboardReport();
@@ -79,11 +80,6 @@ void main(void)
InitPeripherals();
EEPROM_LaunchTransfer(EepromOperation_Read, ConfigBufferId_HardwareConfig, hardwareConfigurationReadFinished);
-#ifdef FORCE_BUSPAL
- Wormhole.magicNumber = WORMHOLE_MAGIC_NUMBER;
- Wormhole.enumerationMode = EnumerationMode_BusPal;
-#endif
-
if (Wormhole.magicNumber == WORMHOLE_MAGIC_NUMBER && Wormhole.enumerationMode == EnumerationMode_BusPal) {
Wormhole.magicNumber = 0;
init_hardware();
diff --git a/right/src/slave_drivers/is31fl3731_driver.c b/right/src/slave_drivers/is31fl3731_driver.c
index e43e0ad..67a2abb 100644
--- a/right/src/slave_drivers/is31fl3731_driver.c
+++ b/right/src/slave_drivers/is31fl3731_driver.c
@@ -70,7 +70,7 @@ void LedSlaveDriver_Init(uint8_t ledDriverId) {
currentLedDriverState->phase = LedDriverPhase_SetFunctionFrame;
currentLedDriverState->ledIndex = 0;
memset(LedDriverValues[ledDriverId], LED_BRIGHTNESS_LEVEL, LED_DRIVER_LED_COUNT);
- LedDisplay_SetText(3, "ABC");
+ LedDisplay_SetText(3, "FTY");
}
status_t LedSlaveDriver_Update(uint8_t ledDriverId) {
diff --git a/right/src/slave_drivers/kboot_driver.c b/right/src/slave_drivers/kboot_driver.c
new file mode 100644
index 0000000..f7f220a
--- /dev/null
+++ b/right/src/slave_drivers/kboot_driver.c
@@ -0,0 +1,80 @@
+#include "slave_drivers/kboot_driver.h"
+#include "slave_scheduler.h"
+#include "i2c.h"
+
+kboot_driver_state_t KbootDriverState;
+
+static uint8_t rxBuffer[MAX_KBOOT_COMMAND_LENGTH];
+static uint8_t pingCommand[] = {0x5a, 0xa6};
+static uint8_t resetCommand[] = {0x5a, 0xa4, 0x04, 0x00, 0x6f, 0x46, 0x0b, 0x00, 0x00, 0x00};
+static uint8_t ackMessage[] = {0x5a, 0xa1};
+
+static status_t tx(uint8_t *buffer, uint8_t length)
+{
+ return I2cAsyncWrite(KbootDriverState.i2cAddress, buffer, length);
+}
+
+static status_t rx(uint8_t length)
+{
+ return I2cAsyncRead(KbootDriverState.i2cAddress, rxBuffer, length);
+}
+
+void KbootSlaveDriver_Init(uint8_t kbootInstanceId)
+{
+}
+
+status_t KbootSlaveDriver_Update(uint8_t kbootInstanceId)
+{
+ status_t status = kStatus_Uhk_IdleSlave;
+
+ switch (KbootDriverState.commandType) {
+ case KbootCommand_Idle:
+ break;
+ case KbootCommand_Ping:
+ switch (KbootDriverState.phase) {
+ case 0:
+ status = tx(pingCommand, sizeof(pingCommand));
+ KbootDriverState.phase++;
+ break;
+ case 1:
+ KbootDriverState.status = Slaves[SlaveId_KbootDriver].previousStatus;
+ KbootDriverState.phase = KbootDriverState.status == kStatus_Success ? 2 : 0;
+ return kStatus_Uhk_NoTransfer;
+ case 2:
+ status = rx(10);
+ KbootDriverState.phase++;
+ break;
+ case 3:
+ KbootDriverState.status = Slaves[SlaveId_KbootDriver].previousStatus;
+ if (KbootDriverState.status == kStatus_Success) {
+ KbootDriverState.commandType = KbootCommand_Idle;
+ } else {
+ KbootDriverState.phase = 0;
+ return kStatus_Uhk_NoTransfer;
+ }
+ }
+ break;
+ case KbootCommand_Reset:
+ switch (KbootDriverState.phase) {
+ case 0:
+ status = tx(resetCommand, sizeof(resetCommand));
+ KbootDriverState.phase++;
+ break;
+ case 1:
+ status = rx(2);
+ KbootDriverState.phase++;
+ break;
+ case 2:
+ status = rx(18);
+ KbootDriverState.phase++;
+ break;
+ case 3:
+ status = tx(ackMessage, sizeof(ackMessage));
+ KbootDriverState.commandType = KbootCommand_Idle;
+ break;
+ }
+ break;
+ }
+
+ return status;
+}
diff --git a/right/src/slave_drivers/kboot_driver.h b/right/src/slave_drivers/kboot_driver.h
new file mode 100644
index 0000000..707baca
--- /dev/null
+++ b/right/src/slave_drivers/kboot_driver.h
@@ -0,0 +1,40 @@
+#ifndef __KBOOT_DRIVER_H__
+#define __KBOOT_DRIVER_H__
+
+// Includes:
+
+ #include "fsl_common.h"
+
+// Macros:
+
+ #define MAX_KBOOT_COMMAND_LENGTH 32
+
+// Typedefs:
+
+ typedef enum {
+ KbootDriverId_Singleton,
+ } kboot_driver_id_t;
+
+ typedef enum {
+ KbootCommand_Idle,
+ KbootCommand_Ping,
+ KbootCommand_Reset,
+ } kboot_command_t;
+
+ typedef struct {
+ kboot_command_t commandType;
+ uint8_t i2cAddress;
+ uint8_t phase;
+ uint32_t status;
+ } kboot_driver_state_t;
+
+// Variables:
+
+ extern kboot_driver_state_t KbootDriverState;
+
+// Functions:
+
+ void KbootSlaveDriver_Init(uint8_t kbootInstanceId);
+ status_t KbootSlaveDriver_Update(uint8_t kbootInstanceId);
+
+#endif
diff --git a/right/src/slave_scheduler.c b/right/src/slave_scheduler.c
index f01aa10..7ebf081 100644
--- a/right/src/slave_scheduler.c
+++ b/right/src/slave_scheduler.c
@@ -4,6 +4,7 @@
#include "main.h"
#include "slave_drivers/is31fl3731_driver.h"
#include "slave_drivers/uhk_module_driver.h"
+#include "slave_drivers/kboot_driver.h"
#include "i2c.h"
#include "i2c_addresses.h"
@@ -39,6 +40,11 @@ uhk_slave_t Slaves[] = {
.update = LedSlaveDriver_Update,
.perDriverId = LedDriverId_Left,
},
+ {
+ .init = KbootSlaveDriver_Init,
+ .update = KbootSlaveDriver_Update,
+ .perDriverId = KbootDriverId_Singleton,
+ },
};
static void slaveSchedulerCallback(I2C_Type *base, i2c_master_handle_t *handle, status_t previousStatus, void *userData)
@@ -51,6 +57,8 @@ static void slaveSchedulerCallback(I2C_Type *base, i2c_master_handle_t *handle,
uhk_slave_t *previousSlave = Slaves + previousSlaveId;
uhk_slave_t *currentSlave = Slaves + currentSlaveId;
+ previousSlave->previousStatus = previousStatus;
+
if (isFirstIteration) {
bool wasPreviousSlaveConnected = previousSlave->isConnected;
previousSlave->isConnected = previousStatus == kStatus_Success;
diff --git a/right/src/slave_scheduler.h b/right/src/slave_scheduler.h
index 80b8095..cbae515 100644
--- a/right/src/slave_scheduler.h
+++ b/right/src/slave_scheduler.h
@@ -13,6 +13,7 @@
SlaveId_RightAddon,
SlaveId_RightLedDriver,
SlaveId_LeftLedDriver,
+ SlaveId_KbootDriver,
} slave_id_t;
typedef void (slave_init_t)(uint8_t);
@@ -25,6 +26,7 @@
slave_update_t *update;
slave_disconnect_t *disconnect;
bool isConnected;
+ status_t previousStatus;
} uhk_slave_t;
typedef enum {
diff --git a/right/src/usb_composite_device.c b/right/src/usb_composite_device.c
index 77fdcc9..b848834 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"
@@ -12,9 +11,9 @@ usb_composite_device_t UsbCompositeDevice;
usb_device_class_config_struct_t UsbDeviceCompositeClassConfig[USB_DEVICE_CONFIG_HID] = {
{UsbGenericHidCallback, (class_handle_t)NULL, &UsbGenericHidClass},
{UsbBasicKeyboardCallback, (class_handle_t)NULL, &UsbBasicKeyboardClass},
- {UsbMouseCallback, (class_handle_t)NULL, &UsbMouseClass},
{UsbMediaKeyboardCallback, (class_handle_t)NULL, &UsbMediaKeyboardClass},
{UsbSystemKeyboardCallback, (class_handle_t)NULL, &UsbSystemKeyboardClass},
+ {UsbMouseCallback, (class_handle_t)NULL, &UsbMouseClass},
};
usb_device_class_config_list_struct_t UsbDeviceCompositeConfigList = {
@@ -43,9 +42,9 @@ static usb_status_t UsbDeviceCallback(usb_device_handle handle, uint32_t event,
UsbCompositeDevice.currentConfiguration = *temp8;
UsbGenericHidSetConfiguration(UsbCompositeDevice.genericHidHandle, *temp8);
UsbBasicKeyboardSetConfiguration(UsbCompositeDevice.basicKeyboardHandle, *temp8);
- UsbMouseSetConfiguration(UsbCompositeDevice.mouseHandle, *temp8);
UsbMediaKeyboardSetConfiguration(UsbCompositeDevice.mediaKeyboardHandle, *temp8);
UsbSystemKeyboardSetConfiguration(UsbCompositeDevice.systemKeyboardHandle, *temp8);
+ UsbMouseSetConfiguration(UsbCompositeDevice.mouseHandle, *temp8);
error = kStatus_USB_Success;
break;
case kUSB_DeviceEventGetConfiguration:
@@ -60,9 +59,9 @@ static usb_status_t UsbDeviceCallback(usb_device_handle handle, uint32_t event,
UsbCompositeDevice.currentInterfaceAlternateSetting[interface] = alternateSetting;
UsbGenericHidSetInterface(UsbCompositeDevice.genericHidHandle, interface, alternateSetting);
UsbBasicKeyboardSetInterface(UsbCompositeDevice.basicKeyboardHandle, interface, alternateSetting);
- UsbMouseSetInterface(UsbCompositeDevice.mouseHandle, interface, alternateSetting);
UsbMediaKeyboardSetInterface(UsbCompositeDevice.mediaKeyboardHandle, interface, alternateSetting);
UsbSystemKeyboardSetInterface(UsbCompositeDevice.systemKeyboardHandle, interface, alternateSetting);
+ UsbMouseSetInterface(UsbCompositeDevice.mouseHandle, interface, alternateSetting);
error = kStatus_USB_Success;
}
}
@@ -118,9 +117,9 @@ void InitUsb(void)
USB_DeviceClassInit(CONTROLLER_ID, &UsbDeviceCompositeConfigList, &UsbCompositeDevice.deviceHandle);
UsbCompositeDevice.genericHidHandle = UsbDeviceCompositeConfigList.config[USB_GENERIC_HID_INTERFACE_INDEX].classHandle;
UsbCompositeDevice.basicKeyboardHandle = UsbDeviceCompositeConfigList.config[USB_BASIC_KEYBOARD_INTERFACE_INDEX].classHandle;
- UsbCompositeDevice.mouseHandle = UsbDeviceCompositeConfigList.config[USB_MOUSE_INTERFACE_INDEX].classHandle;
UsbCompositeDevice.mediaKeyboardHandle = UsbDeviceCompositeConfigList.config[USB_MEDIA_KEYBOARD_INTERFACE_INDEX].classHandle;
UsbCompositeDevice.systemKeyboardHandle = UsbDeviceCompositeConfigList.config[USB_SYSTEM_KEYBOARD_INTERFACE_INDEX].classHandle;
+ UsbCompositeDevice.mouseHandle = UsbDeviceCompositeConfigList.config[USB_MOUSE_INTERFACE_INDEX].classHandle;
NVIC_SetPriority((IRQn_Type)irqNumber, USB_DEVICE_INTERRUPT_PRIORITY);
NVIC_EnableIRQ((IRQn_Type)irqNumber);
diff --git a/right/src/usb_descriptors/usb_descriptor_configuration.c b/right/src/usb_descriptors/usb_descriptor_configuration.c
index 91017b6..175aaa1 100644
--- a/right/src/usb_descriptors/usb_descriptor_configuration.c
+++ b/right/src/usb_descriptors/usb_descriptor_configuration.c
@@ -89,37 +89,6 @@ uint8_t UsbConfigurationDescriptor[USB_CONFIGURATION_DESCRIPTOR_TOTAL_LENGTH] =
USB_SHORT_GET_HIGH(USB_BASIC_KEYBOARD_INTERRUPT_IN_PACKET_SIZE),
USB_BASIC_KEYBOARD_INTERRUPT_IN_INTERVAL,
- // Mouse interface descriptor
- USB_DESCRIPTOR_LENGTH_INTERFACE,
- USB_DESCRIPTOR_TYPE_INTERFACE,
- USB_MOUSE_INTERFACE_INDEX,
- USB_INTERFACE_ALTERNATE_SETTING_NONE,
- USB_MOUSE_ENDPOINT_COUNT,
- USB_CLASS_HID,
- USB_HID_SUBCLASS_BOOT,
- USB_HID_PROTOCOL_MOUSE,
- USB_STRING_DESCRIPTOR_NONE,
-
- // Mouse HID descriptor
- USB_DESCRIPTOR_LENGTH_HID,
- USB_DESCRIPTOR_TYPE_HID,
- USB_SHORT_GET_LOW(USB_HID_VERSION),
- USB_SHORT_GET_HIGH(USB_HID_VERSION),
- USB_HID_COUNTRY_CODE_NOT_SUPPORTED,
- USB_REPORT_DESCRIPTOR_COUNT_PER_HID_DEVICE,
- USB_DESCRIPTOR_TYPE_HID_REPORT,
- USB_SHORT_GET_LOW(USB_MOUSE_REPORT_DESCRIPTOR_LENGTH),
- USB_SHORT_GET_HIGH(USB_MOUSE_REPORT_DESCRIPTOR_LENGTH),
-
- // Mouse endpoint descriptor
- USB_DESCRIPTOR_LENGTH_ENDPOINT,
- USB_DESCRIPTOR_TYPE_ENDPOINT,
- USB_MOUSE_ENDPOINT_INDEX | (USB_IN << USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_SHIFT),
- USB_ENDPOINT_INTERRUPT,
- USB_SHORT_GET_LOW(USB_MOUSE_INTERRUPT_IN_PACKET_SIZE),
- USB_SHORT_GET_HIGH(USB_MOUSE_INTERRUPT_IN_PACKET_SIZE),
- USB_MOUSE_INTERRUPT_IN_INTERVAL,
-
// Media keyboard interface descriptor
USB_DESCRIPTOR_LENGTH_INTERFACE,
USB_DESCRIPTOR_TYPE_INTERFACE,
@@ -181,6 +150,37 @@ uint8_t UsbConfigurationDescriptor[USB_CONFIGURATION_DESCRIPTOR_TOTAL_LENGTH] =
USB_SHORT_GET_LOW(USB_SYSTEM_KEYBOARD_INTERRUPT_IN_PACKET_SIZE),
USB_SHORT_GET_HIGH(USB_SYSTEM_KEYBOARD_INTERRUPT_IN_PACKET_SIZE),
USB_SYSTEM_KEYBOARD_INTERRUPT_IN_INTERVAL,
+
+ // Mouse interface descriptor
+ USB_DESCRIPTOR_LENGTH_INTERFACE,
+ USB_DESCRIPTOR_TYPE_INTERFACE,
+ USB_MOUSE_INTERFACE_INDEX,
+ USB_INTERFACE_ALTERNATE_SETTING_NONE,
+ USB_MOUSE_ENDPOINT_COUNT,
+ USB_CLASS_HID,
+ USB_HID_SUBCLASS_BOOT,
+ USB_HID_PROTOCOL_MOUSE,
+ USB_STRING_DESCRIPTOR_NONE,
+
+ // Mouse HID descriptor
+ USB_DESCRIPTOR_LENGTH_HID,
+ USB_DESCRIPTOR_TYPE_HID,
+ USB_SHORT_GET_LOW(USB_HID_VERSION),
+ USB_SHORT_GET_HIGH(USB_HID_VERSION),
+ USB_HID_COUNTRY_CODE_NOT_SUPPORTED,
+ USB_REPORT_DESCRIPTOR_COUNT_PER_HID_DEVICE,
+ USB_DESCRIPTOR_TYPE_HID_REPORT,
+ USB_SHORT_GET_LOW(USB_MOUSE_REPORT_DESCRIPTOR_LENGTH),
+ USB_SHORT_GET_HIGH(USB_MOUSE_REPORT_DESCRIPTOR_LENGTH),
+
+ // Mouse endpoint descriptor
+ USB_DESCRIPTOR_LENGTH_ENDPOINT,
+ USB_DESCRIPTOR_TYPE_ENDPOINT,
+ USB_MOUSE_ENDPOINT_INDEX | (USB_IN << USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_SHIFT),
+ USB_ENDPOINT_INTERRUPT,
+ USB_SHORT_GET_LOW(USB_MOUSE_INTERRUPT_IN_PACKET_SIZE),
+ USB_SHORT_GET_HIGH(USB_MOUSE_INTERRUPT_IN_PACKET_SIZE),
+ USB_MOUSE_INTERRUPT_IN_INTERVAL,
};
usb_status_t USB_DeviceGetConfigurationDescriptor(
diff --git a/right/src/usb_descriptors/usb_descriptor_hid.c b/right/src/usb_descriptors/usb_descriptor_hid.c
index 85682d6..18c005f 100644
--- a/right/src/usb_descriptors/usb_descriptor_hid.c
+++ b/right/src/usb_descriptors/usb_descriptor_hid.c
@@ -12,9 +12,9 @@ usb_status_t USB_DeviceGetHidDescriptor(
usb_status_t USB_DeviceGetHidReportDescriptor(
usb_device_handle handle, usb_device_get_hid_report_descriptor_struct_t *hidReportDescriptor)
{
- if (USB_MOUSE_INTERFACE_INDEX == hidReportDescriptor->interfaceNumber) {
- hidReportDescriptor->buffer = UsbMouseReportDescriptor;
- hidReportDescriptor->length = USB_MOUSE_REPORT_DESCRIPTOR_LENGTH;
+ if (USB_GENERIC_HID_INTERFACE_INDEX == hidReportDescriptor->interfaceNumber) {
+ hidReportDescriptor->buffer = UsbGenericHidReportDescriptor;
+ hidReportDescriptor->length = USB_GENERIC_HID_REPORT_DESCRIPTOR_LENGTH;
} else if (USB_BASIC_KEYBOARD_INTERFACE_INDEX == hidReportDescriptor->interfaceNumber) {
hidReportDescriptor->buffer = UsbBasicKeyboardReportDescriptor;
hidReportDescriptor->length = USB_BASIC_KEYBOARD_REPORT_DESCRIPTOR_LENGTH;
@@ -24,9 +24,9 @@ usb_status_t USB_DeviceGetHidReportDescriptor(
} else if (USB_SYSTEM_KEYBOARD_INTERFACE_INDEX == hidReportDescriptor->interfaceNumber) {
hidReportDescriptor->buffer = UsbSystemKeyboardReportDescriptor;
hidReportDescriptor->length = USB_MEDIA_KEYBOARD_REPORT_DESCRIPTOR_LENGTH;
- } else if (USB_GENERIC_HID_INTERFACE_INDEX == hidReportDescriptor->interfaceNumber) {
- hidReportDescriptor->buffer = UsbGenericHidReportDescriptor;
- hidReportDescriptor->length = USB_GENERIC_HID_REPORT_DESCRIPTOR_LENGTH;
+ } else if (USB_MOUSE_INTERFACE_INDEX == hidReportDescriptor->interfaceNumber) {
+ hidReportDescriptor->buffer = UsbMouseReportDescriptor;
+ hidReportDescriptor->length = USB_MOUSE_REPORT_DESCRIPTOR_LENGTH;
} else {
return kStatus_USB_InvalidRequest;
}
diff --git a/right/src/usb_descriptors/usb_descriptor_system_keyboard_report.c b/right/src/usb_descriptors/usb_descriptor_system_keyboard_report.c
index 488bf1e..fe6e005 100644
--- a/right/src/usb_descriptors/usb_descriptor_system_keyboard_report.c
+++ b/right/src/usb_descriptors/usb_descriptor_system_keyboard_report.c
@@ -6,12 +6,13 @@ uint8_t UsbSystemKeyboardReportDescriptor[USB_SYSTEM_KEYBOARD_REPORT_DESCRIPTOR_
HID_RI_USAGE(8, HID_RI_USAGE_GENERIC_DESKTOP_SYSTEM_CONTROL),
HID_RI_COLLECTION(8, HID_RI_COLLECTION_APPLICATION),
// System key
- HID_RI_LOGICAL_MINIMUM(8, 0x00),
- HID_RI_LOGICAL_MAXIMUM(8, 0xFF),
- HID_RI_USAGE_MINIMUM(8, 0x00),
- HID_RI_USAGE_MAXIMUM(8, 0xFF),
+ HID_RI_REPORT_SIZE(8, 2),
HID_RI_REPORT_COUNT(8, USB_SYSTEM_KEYBOARD_MAX_KEYS),
- HID_RI_REPORT_SIZE(8, 0x08),
- HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_ARRAY | HID_IOF_ABSOLUTE),
+ HID_RI_LOGICAL_MINIMUM(8, 1),
+ HID_RI_LOGICAL_MAXIMUM(8, 3),
+ HID_RI_USAGE(8, 0x82),
+ HID_RI_USAGE(8, 0x81),
+ HID_RI_USAGE(8, 0x83),
+ HID_RI_INPUT(8, HID_IOF_NO_PREFERRED_STATE | HID_IOF_NULLSTATE),
HID_RI_END_COLLECTION(0),
};
diff --git a/right/src/usb_descriptors/usb_descriptor_system_keyboard_report.h b/right/src/usb_descriptors/usb_descriptor_system_keyboard_report.h
index 905faa3..e269f14 100644
--- a/right/src/usb_descriptors/usb_descriptor_system_keyboard_report.h
+++ b/right/src/usb_descriptors/usb_descriptor_system_keyboard_report.h
@@ -3,7 +3,7 @@
// Macros:
- #define USB_SYSTEM_KEYBOARD_REPORT_DESCRIPTOR_LENGTH 21
+ #define USB_SYSTEM_KEYBOARD_REPORT_DESCRIPTOR_LENGTH 23
#define USB_SYSTEM_KEYBOARD_MAX_KEYS 1
// Variables:
diff --git a/right/src/usb_device_config.h b/right/src/usb_device_config.h
index de013da..1aa0013 100644
--- a/right/src/usb_device_config.h
+++ b/right/src/usb_device_config.h
@@ -4,22 +4,22 @@
// KHCI instance count
#define USB_DEVICE_CONFIG_KHCI 1
+#include "usb_interfaces/usb_interface_generic_hid.h"
#include "usb_interfaces/usb_interface_basic_keyboard.h"
#include "usb_interfaces/usb_interface_media_keyboard.h"
#include "usb_interfaces/usb_interface_system_keyboard.h"
#include "usb_interfaces/usb_interface_mouse.h"
-#include "usb_interfaces/usb_interface_generic_hid.h"
// Device instance count, the sum of KHCI and EHCI instance counts
#define USB_DEVICE_CONFIG_NUM 1
// HID instance count
#define USB_DEVICE_CONFIG_HID ( \
+ USB_GENERIC_HID_INTERFACE_COUNT +\
USB_BASIC_KEYBOARD_INTERFACE_COUNT + \
USB_MEDIA_KEYBOARD_INTERFACE_COUNT + \
USB_SYSTEM_KEYBOARD_INTERFACE_COUNT + \
- USB_MOUSE_INTERFACE_COUNT + \
- USB_GENERIC_HID_INTERFACE_COUNT \
+ USB_MOUSE_INTERFACE_COUNT \
)
// Whether the device is self-powered: 1 supported, 0 not supported
@@ -34,11 +34,11 @@
// How many endpoints are supported in the stack
#define USB_DEVICE_CONFIG_ENDPOINTS ( \
USB_CONTROL_ENDPOINT_COUNT + \
+ USB_GENERIC_HID_ENDPOINT_COUNT + \
USB_BASIC_KEYBOARD_ENDPOINT_COUNT + \
USB_MEDIA_KEYBOARD_ENDPOINT_COUNT + \
USB_SYSTEM_KEYBOARD_ENDPOINT_COUNT + \
- USB_MOUSE_ENDPOINT_COUNT + \
- USB_GENERIC_HID_ENDPOINT_COUNT \
+ USB_MOUSE_ENDPOINT_COUNT \
)
// The maximum buffer length for the KHCI DMA workaround
diff --git a/right/src/usb_interfaces/usb_interface_generic_hid.c b/right/src/usb_interfaces/usb_interface_generic_hid.c
index c24d19f..9514199 100644
--- a/right/src/usb_interfaces/usb_interface_generic_hid.c
+++ b/right/src/usb_interfaces/usb_interface_generic_hid.c
@@ -1,5 +1,6 @@
#include "usb_composite_device.h"
#include "usb_interface_generic_hid.h"
+#include "usb_protocol_handler.h"
static usb_device_endpoint_struct_t UsbGenericHidEndpoints[USB_GENERIC_HID_ENDPOINT_COUNT] =
{
diff --git a/right/src/usb_interfaces/usb_interface_generic_hid.h b/right/src/usb_interfaces/usb_interface_generic_hid.h
index 0235cdb..d9b9f71 100644
--- a/right/src/usb_interfaces/usb_interface_generic_hid.h
+++ b/right/src/usb_interfaces/usb_interface_generic_hid.h
@@ -5,7 +5,6 @@
#include "usb_api.h"
#include "usb_descriptors/usb_descriptor_device.h"
- #include "usb_protocol_handler.h"
// Macros:
diff --git a/right/src/usb_interfaces/usb_interface_media_keyboard.h b/right/src/usb_interfaces/usb_interface_media_keyboard.h
index 410be13..e4c9064 100644
--- a/right/src/usb_interfaces/usb_interface_media_keyboard.h
+++ b/right/src/usb_interfaces/usb_interface_media_keyboard.h
@@ -9,10 +9,10 @@
// Macros:
- #define USB_MEDIA_KEYBOARD_INTERFACE_INDEX 3
+ #define USB_MEDIA_KEYBOARD_INTERFACE_INDEX 2
#define USB_MEDIA_KEYBOARD_INTERFACE_COUNT 1
- #define USB_MEDIA_KEYBOARD_ENDPOINT_INDEX 5
+ #define USB_MEDIA_KEYBOARD_ENDPOINT_INDEX 4
#define USB_MEDIA_KEYBOARD_ENDPOINT_COUNT 1
#define USB_MEDIA_KEYBOARD_INTERRUPT_IN_PACKET_SIZE 8
diff --git a/right/src/usb_interfaces/usb_interface_mouse.h b/right/src/usb_interfaces/usb_interface_mouse.h
index c79a124..4f8b05c 100644
--- a/right/src/usb_interfaces/usb_interface_mouse.h
+++ b/right/src/usb_interfaces/usb_interface_mouse.h
@@ -8,10 +8,10 @@
// Macros:
- #define USB_MOUSE_INTERFACE_INDEX 2
+ #define USB_MOUSE_INTERFACE_INDEX 4
#define USB_MOUSE_INTERFACE_COUNT 1
- #define USB_MOUSE_ENDPOINT_INDEX 4
+ #define USB_MOUSE_ENDPOINT_INDEX 6
#define USB_MOUSE_ENDPOINT_COUNT 1
#define USB_MOUSE_INTERRUPT_IN_PACKET_SIZE 8
diff --git a/right/src/usb_interfaces/usb_interface_system_keyboard.h b/right/src/usb_interfaces/usb_interface_system_keyboard.h
index 59592e4..7dc8108 100644
--- a/right/src/usb_interfaces/usb_interface_system_keyboard.h
+++ b/right/src/usb_interfaces/usb_interface_system_keyboard.h
@@ -10,10 +10,10 @@
// Macros:
- #define USB_SYSTEM_KEYBOARD_INTERFACE_INDEX 4
+ #define USB_SYSTEM_KEYBOARD_INTERFACE_INDEX 3
#define USB_SYSTEM_KEYBOARD_INTERFACE_COUNT 1
- #define USB_SYSTEM_KEYBOARD_ENDPOINT_INDEX 6
+ #define USB_SYSTEM_KEYBOARD_ENDPOINT_INDEX 5
#define USB_SYSTEM_KEYBOARD_ENDPOINT_COUNT 1
#define USB_SYSTEM_KEYBOARD_INTERRUPT_IN_PACKET_SIZE 1
diff --git a/right/src/usb_protocol_handler.c b/right/src/usb_protocol_handler.c
index 6f8d97b..bd7e16f 100644
--- a/right/src/usb_protocol_handler.c
+++ b/right/src/usb_protocol_handler.c
@@ -9,12 +9,16 @@
#include "led_pwm.h"
#include "slave_scheduler.h"
#include "slave_drivers/uhk_module_driver.h"
+#include "slave_drivers/kboot_driver.h"
#include "bootloader/wormhole.h"
#include "peripherals/adc.h"
#include "eeprom.h"
#include "keymaps.h"
#include "microseconds/microseconds_pit.c"
#include "i2c_watchdog.h"
+
+uint8_t UsbDebugInfo[USB_GENERIC_HID_OUT_BUFFER_LENGTH];
+
// Functions for setting error statuses
void setError(uint8_t error)
@@ -72,8 +76,8 @@ void reenumerate(void)
{
Wormhole.magicNumber = WORMHOLE_MAGIC_NUMBER;
Wormhole.enumerationMode = GenericHidInBuffer[1];
- SCB->AIRCR = 0x5FA<> 0;
- GenericHidOutBuffer[2] = I2C_Watchdog >> 8;
- GenericHidOutBuffer[3] = I2C_Watchdog >> 16;
- GenericHidOutBuffer[4] = I2C_Watchdog >> 24;
+ UsbDebugInfo[0] = I2C_Watchdog >> 0;
+ UsbDebugInfo[1] = I2C_Watchdog >> 8;
+ UsbDebugInfo[2] = I2C_Watchdog >> 16;
+ UsbDebugInfo[3] = I2C_Watchdog >> 24;
- GenericHidOutBuffer[5] = I2cSchedulerCounter >> 0;
- GenericHidOutBuffer[6] = I2cSchedulerCounter >> 8;
- GenericHidOutBuffer[7] = I2cSchedulerCounter >> 16;
- GenericHidOutBuffer[8] = I2cSchedulerCounter >> 24;
+ UsbDebugInfo[4] = I2cSchedulerCounter >> 0;
+ UsbDebugInfo[5] = I2cSchedulerCounter >> 8;
+ UsbDebugInfo[6] = I2cSchedulerCounter >> 16;
+ UsbDebugInfo[7] = I2cSchedulerCounter >> 24;
- GenericHidOutBuffer[9] = I2cWatchdog_OuterCounter >> 0;
- GenericHidOutBuffer[10] = I2cWatchdog_OuterCounter >> 8;
- GenericHidOutBuffer[11] = I2cWatchdog_OuterCounter >> 16;
- GenericHidOutBuffer[12] = I2cWatchdog_OuterCounter >> 24;
+ UsbDebugInfo[8] = I2cWatchdog_OuterCounter >> 0;
+ UsbDebugInfo[9] = I2cWatchdog_OuterCounter >> 8;
+ UsbDebugInfo[10] = I2cWatchdog_OuterCounter >> 16;
+ UsbDebugInfo[11] = I2cWatchdog_OuterCounter >> 24;
- GenericHidOutBuffer[13] = I2cWatchdog_InnerCounter >> 0;
- GenericHidOutBuffer[14] = I2cWatchdog_InnerCounter >> 8;
- GenericHidOutBuffer[15] = I2cWatchdog_InnerCounter >> 16;
- GenericHidOutBuffer[16] = I2cWatchdog_InnerCounter >> 24;
-/*
+ UsbDebugInfo[12] = I2cWatchdog_InnerCounter >> 0;
+ UsbDebugInfo[13] = I2cWatchdog_InnerCounter >> 8;
+ UsbDebugInfo[14] = I2cWatchdog_InnerCounter >> 16;
+ UsbDebugInfo[15] = I2cWatchdog_InnerCounter >> 24;
+
+ memcpy(GenericHidOutBuffer, UsbDebugInfo, USB_GENERIC_HID_OUT_BUFFER_LENGTH);
+
+ /*
uint64_t ticks = microseconds_get_ticks();
uint32_t microseconds = microseconds_convert_to_microseconds(ticks);
uint32_t milliseconds = microseconds/1000;
@@ -277,6 +284,13 @@ void jumpToSlaveBootloader(void)
UhkModuleStates[uhkModuleDriverId].jumpToBootloader = true;
}
+void sendKbootCommand(void)
+{
+ KbootDriverState.phase = 0;
+ KbootDriverState.i2cAddress = GenericHidInBuffer[2];
+ KbootDriverState.commandType = GenericHidInBuffer[1];
+}
+
// The main protocol handler function
void UsbProtocolHandler(void)
@@ -331,6 +345,9 @@ void UsbProtocolHandler(void)
case UsbCommand_JumpToSlaveBootloader:
jumpToSlaveBootloader();
break;
+ case UsbCommand_SendKbootCommand:
+ sendKbootCommand();
+ break;
default:
break;
}
diff --git a/right/src/usb_protocol_handler.h b/right/src/usb_protocol_handler.h
index 11445e9..6ced15e 100644
--- a/right/src/usb_protocol_handler.h
+++ b/right/src/usb_protocol_handler.h
@@ -23,7 +23,8 @@
UsbCommand_ReadUserConfiguration = 15,
UsbCommand_GetKeyboardState = 16,
UsbCommand_GetDebugInfo = 17,
- UsbCommand_JumpToSlaveBootloader = 18,
+ UsbCommand_JumpToSlaveBootloader = 18,
+ UsbCommand_SendKbootCommand = 19,
} usb_command_t;
typedef enum {
@@ -40,6 +41,10 @@
JumpToBootloaderError_InvalidModuleDriverId = 1,
} jump_to_bootloader_error_t;
+// Variables:
+
+ extern uint8_t UsbDebugInfo[USB_GENERIC_HID_OUT_BUFFER_LENGTH];
+
// Functions:
void UsbProtocolHandler(void);
diff --git a/scripts/update-slave-firmware.js b/scripts/update-slave-firmware.js
new file mode 100755
index 0000000..0fbf455
--- /dev/null
+++ b/scripts/update-slave-firmware.js
@@ -0,0 +1,61 @@
+#!/usr/bin/env node
+const program = require('commander');
+require('shelljs/global');
+
+config.fatal = true;
+
+program
+ .usage('update-slave-firmware ')
+ .parse(process.argv)
+
+let firmwareImage = program.args[0];
+
+if (!firmwareImage) {
+ echo('No firmware image specified');
+ exit(1);
+}
+
+if (!firmwareImage.endsWith('.bin')) {
+ echo('Firmware image extension is not .bin');
+ exit(1);
+}
+
+if (!test('-f', firmwareImage)) {
+ echo('Firmware image does not exist');
+ exit(1);
+}
+
+let usbDir = '../../../lib/agent/packages/usb';
+let usbBinding = usbDir + '/node_modules/usb/build/Release/usb_bindings.node';
+
+let blhostPath;
+switch (process.platform) {
+ case 'linux':
+ blhostPath = 'linux/amd64/blhost';
+ break;
+ case 'darwin':
+ blhostPath = 'mac/blhost';
+ break;
+ case 'win32':
+ blhostPath = 'win/blhost.exe';
+ break;
+ default:
+ echo('Your operating system is not supported');
+ exit(1);
+ break;
+}
+
+let blhostUsb = `../../../lib/bootloader/bin/Tools/blhost/${blhostPath} --usb 0x1d50,0x6121`;
+let blhostBuspal = blhostUsb + ' --buspal i2c,0x10,100k';
+
+config.verbose = true;
+
+exec(`${usbDir}/send-kboot-command-to-slave.js ping 0x10`);
+exec(`${usbDir}/jump-to-slave-bootloader.js`);
+exec(`${usbDir}/reenumerate.js buspal`);
+exec(`${blhostBuspal} get-property 1`);
+exec(`${blhostBuspal} flash-erase-all-unsecure`);
+exec(`${blhostBuspal} write-memory 0x0 ${firmwareImage}`);
+exec(`${blhostUsb} reset`);
+exec(`${usbDir}/reenumerate.js normalKeyboard`);
+exec(`${usbDir}/send-kboot-command-to-slave.js reset 0x10`);
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);
-}