]> git.donarmstrong.com Git - kiibohd-controller.git/commitdiff
Fixing default ErgoDox layout and adding FlashMode button
authorJacob Alexander <haata@kiibohd.com>
Sat, 22 Aug 2015 02:43:45 +0000 (19:43 -0700)
committerJacob Alexander <haata@kiibohd.com>
Sat, 22 Aug 2015 02:43:45 +0000 (19:43 -0700)
- Adds proper flashMode support for all keyboards and microcontrollers (usb and serial)
- flashModeEnabled must be set to 1 otherwise it will only show an error
  * This is on purpose (somewhat dangerous feature as it allows remote flashing)
- Capability cleanup

Macro/PartialMap/macro.h
Output/pjrcUSB/arm/usb_dev.c
Output/pjrcUSB/capabilities.kll
Output/pjrcUSB/output_com.c
Output/pjrcUSB/output_com.h
Output/uartOut/arm/uart_serial.c
Output/uartOut/capabilities.kll
Output/uartOut/output_com.c
Output/usbMuxUart/output_com.c
Scan/MDErgo1/leftHand.kll
Scan/MDErgo1/rightHand.kll

index eae77dd3009c7b7cae09e5f2c81141a61a690558..2df411e1c1914141baeaee84db67cac2a9fc45a1 100644 (file)
 
 
 
-// ----- Capabilities -----
-
-void Macro_layerState_capability( uint8_t state, uint8_t stateType, uint8_t *args );
-void Macro_layerLatch_capability( uint8_t state, uint8_t stateType, uint8_t *args );
-void Macro_layerLock_capability( uint8_t state, uint8_t stateType, uint8_t *args );
-void Macro_layerShift_capability( uint8_t state, uint8_t stateType, uint8_t *args );
-
-
-
 // ----- Functions -----
 
 void Macro_analogState( uint8_t scanCode, uint8_t state );
index 9af914d586391ce4bec3f46e337d72a798920ea8..37541e488f6856c2a82c17bde0e41fac10024bde 100644 (file)
@@ -34,6 +34,7 @@
 // Project Includes
 #include <Lib/OutputLib.h>
 #include <print.h>
+#include <kll_defs.h>
 
 // Local Includes
 #include "usb_dev.h"
@@ -872,6 +873,14 @@ void usb_tx( uint32_t endpoint, usb_packet_t *packet )
 
 void usb_device_reload()
 {
+       if ( flashModeEnabled_define == 0 )
+       {
+               print( NL );
+               warn_print("flashModeEnabled not set, cancelling firmware reload...");
+               info_msg("Set flashModeEnabled to 1 in your kll configuration.");
+               return;
+       }
+
 // MCHCK
 #if defined(_mk20dx128vlf5_)
 
@@ -882,7 +891,7 @@ void usb_device_reload()
        PORTA_PCR3 = PORT_PCR_PFE | PORT_PCR_MUX(1); // Internal pull-up
 
        // Check for jumper
-       if ( GPIOA_PDIR & (1<<3) )
+       if ( GPIOA_PDIR & (1<<3) && flashModeEnabled_define != 0 )
        {
                print( NL );
                warn_print("Security jumper not present, cancelling firmware reload...");
index a9b1eb495b0bf158ab9de064b9bcb3c607dcd20d..7646625196bdafda113dfd1ea0fbfdcf443e9ddb 100644 (file)
@@ -1,10 +1,10 @@
 Name = pjrcUSBCapabilities;
-Version = 0.5;
+Version = 0.6;
 Author = "HaaTa (Jacob Alexander) 2014-2015";
-KLL = 0.3b;
+KLL = 0.3c;
 
 # Modified Date
-Date = 2015-07-12;
+Date = 2015-08-21;
 
 
 # Output capabilities
@@ -21,3 +21,12 @@ kbdProtocolNKRO => Output_kbdProtocolNKRO_capability();
 keyboardLocale => KeyboardLocale_define;
 keyboardLocale = 0;
 
+# Bootloader Mode capability
+# XXX
+# By default this is disabled on purpose
+# It is a large security hazard
+flashModeEnabled => flashModeEnabled_define;
+flashModeEnabled = 0;
+
+flashMode => Output_flashMode_capability();
+
index dc6bfcd0a4e7b47f1c736b01ba42f7e06ae81812..d594ac1c32ec0e1be1fbfad1377913949feec143 100644 (file)
@@ -484,6 +484,19 @@ void Output_usbCodeSend_capability( uint8_t state, uint8_t stateType, uint8_t *a
        }
 }
 
+void Output_flashMode_capability( uint8_t state, uint8_t stateType, uint8_t *args )
+{
+       // Display capability name
+       if ( stateType == 0xFF && state == 0xFF )
+       {
+               print("Output_flashMode(usbCode)");
+               return;
+       }
+
+       // Start flash mode
+       Output_firmwareReload();
+}
+
 
 
 // ----- Functions -----
index 0462c20d3c372f60ae2025c2b5b609d472b2502f..c82ed989964430986df5273bbc1df39d5858da1a 100644 (file)
@@ -84,20 +84,6 @@ extern          uint8_t  Output_DebugMode; // 0 - Debug disabled, 1 - Debug enab
 
 
 
-// ----- Capabilities -----
-
-// Output capabilities
-void Output_consCtrlSend_capability( uint8_t state, uint8_t stateType, uint8_t *args );
-void Output_noneSend_capability( uint8_t state, uint8_t stateType, uint8_t *args );
-void Output_sysCtrlSend_capability( uint8_t state, uint8_t stateType, uint8_t *args );
-void Output_usbCodeSend_capability( uint8_t state, uint8_t stateType, uint8_t *args );
-
-// Configuration capabilities
-void Output_kbdProtocolBoot_capability( uint8_t state, uint8_t stateType, uint8_t *args );
-void Output_kbdProtocolNKRO_capability( uint8_t state, uint8_t stateType, uint8_t *args );
-
-
-
 // ----- Functions -----
 
 void Output_setup();
index db7a3aac0d8f280385120cfac67b3d7dba9023f6..d06f2f59e10c121d47f2ba1cc1672829c38127df 100644 (file)
@@ -27,6 +27,8 @@
 // Project Includes
 #include <Lib/OutputLib.h>
 #include <Lib/Interrupts.h>
+#include <print.h>
+#include <kll_defs.h>
 
 // Local Includes
 #include "uart_serial.h"
@@ -325,6 +327,48 @@ void uart_serial_flush_output()
 
 void uart_device_reload()
 {
+       if ( flashModeEnabled_define == 0 )
+       {
+               print( NL );
+               warn_print("flashModeEnabled not set, cancelling firmware reload...");
+               info_msg("Set flashModeEnabled to 1 in your kll configuration.");
+               return;
+       }
+
+// MCHCK
+#if defined(_mk20dx128vlf5_)
+
+       // MCHCK Kiibohd Variant
+       // Check to see if PTA3 (has a pull-up) is connected to GND (usually via jumper)
+       // Only allow reload if the jumper is present (security)
+       GPIOA_PDDR &= ~(1<<3); // Input
+       PORTA_PCR3 = PORT_PCR_PFE | PORT_PCR_MUX(1); // Internal pull-up
+
+       // Check for jumper
+       if ( GPIOA_PDIR & (1<<3) && flashModeEnabled_define != 0 )
+       {
+               print( NL );
+               warn_print("Security jumper not present, cancelling firmware reload...");
+               info_msg("Replace jumper on middle 2 pins, or manually press the firmware reload button.");
+       }
+       else
+       {
+               // Copies variable into the VBAT register, must be identical to the variable in the bootloader to jump to the bootloader flash mode
+               for ( int pos = 0; pos < sizeof(sys_reset_to_loader_magic); pos++ )
+                       (&VBAT)[ pos ] = sys_reset_to_loader_magic[ pos ];
+               SOFTWARE_RESET();
+       }
+
+// Kiibohd mk20dx256vlh7
+#elif defined(_mk20dx256vlh7_)
+       // Copies variable into the VBAT register, must be identical to the variable in the bootloader to jump to the bootloader flash mode
+       for ( int pos = 0; pos < sizeof(sys_reset_to_loader_magic); pos++ )
+               (&VBAT)[ pos ] = sys_reset_to_loader_magic[ pos ];
+       SOFTWARE_RESET();
+
+// Teensy 3.0 and 3.1
+#else
        asm volatile("bkpt");
+#endif
 }
 
index d45e18129670fed78b2d015f2b743066ab45a278..663c034206c3c1c63bb7f10434c68842d7c6f5e7 100644 (file)
@@ -1,12 +1,21 @@
 Name = uartOutCapabilities;
-Version = 0.1;
+Version = 0.2;
 Author = "HaaTa (Jacob Alexander) 2014";
 KLL = 0.3;
 
 # Modified Date
-Date = 2014-09-27;
+Date = 2014-08-21;
 
 
 # Capabilties available to the uartOut output module
 usbKeyOut   => Output_usbCodeSend_capability( usbCode : 1 );
 
+# Bootloader Mode capability
+# XXX
+# By default this is disabled on purpose
+# It is a large security hazard
+flashModeEnabled => flashModeEnabled_define;
+flashModeEnabled = 0;
+
+flashMode => Output_flashMode_capability();
+
index 8558fc101686b5dbbb559e88b2c541e3f9404caa..a45193bc818e436abf5467796df9a3699501fe3d 100644 (file)
@@ -129,6 +129,19 @@ void Output_usbCodeSend_capability( uint8_t state, uint8_t stateType, uint8_t *a
        }
 }
 
+void Output_flashMode_capability( uint8_t state, uint8_t stateType, uint8_t *args )
+{
+       // Display capability name
+       if ( stateType == 0xFF && state == 0xFF )
+       {
+               print("Output_flashMode(usbCode)");
+               return;
+       }
+
+       // Start flash mode
+       Output_firmwareReload();
+}
+
 
 
 // ----- Functions -----
index 3fa26c93909182582df47f3cc56a16f7e68ee29a..928f342313a315895ef60f5c5989fa62db40867b 100644 (file)
@@ -490,6 +490,19 @@ void Output_usbCodeSend_capability( uint8_t state, uint8_t stateType, uint8_t *a
        }
 }
 
+void Output_flashMode_capability( uint8_t state, uint8_t stateType, uint8_t *args )
+{
+       // Display capability name
+       if ( stateType == 0xFF && state == 0xFF )
+       {
+               print("Output_flashMode(usbCode)");
+               return;
+       }
+
+       // Start flash mode
+       Output_firmwareReload();
+}
+
 
 
 // ----- Functions -----
index c814c55f6bf22e7eb1a5a20e5a8bf574e11c42e6..a2b3a36ebcc2f0ad2d2b3f410ea86de8eef1bec2 100644 (file)
@@ -1,4 +1,4 @@
-Name = MDErgo1 Right Hand;
+Name = MDErgo1 Left Hand;
 Version = 0.1;
 Author = "HaaTa (Jacob Alexander) 2015";
 KLL = 0.3c;
@@ -8,22 +8,22 @@ Date = 2015-08-06;
 
 
 # Top Row
-S0x02 : U"6";
+S0x02 : U"Esc";
 S0x03 : U"5";
 S0x04 : U"4";
 S0x05 : U"3";
 S0x06 : U"2";
 S0x07 : U"1";
-S0x08 : U"Esc";
+S0x08 : U"Equals";
 
 # Top-Middle Row
-S0x0B : U"F4";
+S0x0B : U"Function1";
 S0x0C : U"T";
 S0x0D : U"R";
 S0x0E : U"E";
 S0x0F : U"W";
 S0x10 : U"Q";
-S0x11 : U"Tab";
+S0x11 : U"Backslash";
 
 # Middle Row
 S0x15 : U"G";
@@ -31,14 +31,14 @@ S0x16 : U"F";
 S0x17 : U"D";
 S0x18 : U"S";
 S0x19 : U"A";
-S0x1A : U"Function1";
+S0x1A : U"Tab";
 
 # Top Thumb Cluster
-S0x1B : U"Home";
-S0x1C : U"End";
+S0x1B : U"LAlt";
+S0x1C : U"LCtrl";
 
 # Bottom-Middle Row
-S0x1D : U"F5";
+S0x1D : U"Function2";
 S0x1E : U"B";
 S0x1F : U"V";
 S0x20 : U"C";
@@ -47,15 +47,15 @@ S0x22 : U"Z";
 S0x23 : U"Left Shift";
 
 # Bottom Thumb Cluster
-S0x24 : U"Left Alt";
-S0x25 : U"Left Ctrl";
+S0x24 : U"Home";
+S0x25 : U"End";
 S0x26 : U"Delete";
-S0x27 : U"Space";
+S0x27 : U"Backspace";
 
 # Bottom Row
 S0x28 : U"Function5";
-S0x29 : U"Backtick";
-S0x2A : U"Right Brace";
-S0x2B : U"Left Brace";
-S0x2C : U"Function3";
+S0x29 : U"Function4";
+S0x2A : U"Function3";
+S0x2B : U"Backtick";
+S0x2C : U"LGui";
 
index 840b69687f79a1a19416f7b9af4111ddf3f0a086..d31000e131ca20858a96715f40eda35f6eb52d12 100644 (file)
@@ -8,22 +8,22 @@ Date = 2015-08-06;
 
 
 # Top Row
-S0x02 : U"7";
-S0x03 : U"8";
-S0x04 : U"9";
-S0x05 : U"0";
-S0x06 : U"Minus";
-S0x07 : U"Equal";
-S0x08 : U"Backspace";
+S0x02 : U"Function6";
+S0x03 : U"6";
+S0x04 : U"7";
+S0x05 : U"8";
+S0x06 : U"9";
+S0x07 : U"0";
+S0x08 : U"Minus";
 
 # Top-Middle Row
-S0x0B : U"PageUp";
+S0x0B : U"Left Brace";
 S0x0C : U"Y";
 S0x0D : U"U";
 S0x0E : U"I";
 S0x0F : U"O";
 S0x10 : U"P";
-S0x11 : U"BackSlash";
+S0x11 : U"Right Brace";
 
 # Middle Row
 S0x15 : U"H";
@@ -34,11 +34,11 @@ S0x19 : U"Semicolon";
 S0x1A : U"Quote";
 
 # Top Thumb Cluster
-S0x1B : U"PrintScreen";
-S0x1C : U"Insert";
+S0x1B : U"RAlt";
+S0x1C : U"RCtrl";
 
 # Bottom-Middle Row
-S0x1D : U"PageDown";
+S0x1D : U"Function7";
 S0x1E : U"N";
 S0x1F : U"M";
 S0x20 : U"Comma";
@@ -47,16 +47,15 @@ S0x22 : U"Slash";
 S0x23 : U"Right Shift";
 
 # Bottom Thumb Cluster
-S0x24 : U"Right Alt";
-S0x25 : U"Right Ctrl";
+S0x24 : U"PageUp";
+S0x25 : U"PageDown";
 S0x26 : U"Enter";
-S0x27 : U"Function2";
+S0x27 : U"Space";
 
 # Bottom Row
 S0x28 : U"Left";
 S0x29 : U"Down";
 S0x2A : U"Up";
 S0x2B : U"Right";
-S0x2C : U"Function4";
-
+S0x2C : U"RGui";