]> git.donarmstrong.com Git - kiibohd-controller.git/commitdiff
Adding jump to bootloader key
authorJacob Alexander <haata@kiibohd.com>
Mon, 12 Oct 2015 05:07:11 +0000 (22:07 -0700)
committerJacob Alexander <haata@kiibohd.com>
Mon, 12 Oct 2015 05:07:11 +0000 (22:07 -0700)
- Now enabled by default
- Added protection around remote jumps

Debug/cli/cli.c
Macro/PartialMap/macro.c
Output/pjrcUSB/arm/usb_dev.c
Output/pjrcUSB/output_com.c
Output/usbMuxUart/output_com.c

index 03fb3ca44b2924888d3b8247e124d7f422123364..149d12d49af22457731942f9d56582c791c1e672 100644 (file)
 
 // ----- Includes -----
 
-// Compiler Includes
-//#include <stdarg.h>
-
 // Project Includes
 #include <buildvars.h>
 #include "cli.h"
 #include <led.h>
 #include <print.h>
+#include <kll_defs.h>
 
 
 
@@ -517,6 +515,14 @@ void cliFunc_led( char* args )
 
 void cliFunc_reload( char* args )
 {
+       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;
+       }
+
        // Request to output module to be set into firmware reload mode
        Output_firmwareReload();
 }
index 8f1d1b826e78a2bc16bc3daef114695dee0e0604..e861f0edabe1f3106e42806303b19a467a8d8e22 100644 (file)
@@ -1378,6 +1378,19 @@ void cliFunc_capSelect( char* args )
                        printHex( argSet[2] );
                        print( "..." NL );
 
+                       // Make sure this isn't the reload capability
+                       // If it is, and the remote reflash define is not set, ignore
+                       if ( flashModeEnabled_define == 0 ) for ( uint32_t cap = 0; cap < CapabilitiesNum; cap++ )
+                       {
+                               if ( CapabilitiesList[ cap ].func == (const void*)Output_flashMode_capability )
+                               {
+                                       print( NL );
+                                       warn_print("flashModeEnabled not set, cancelling firmware reload...");
+                                       info_msg("Set flashModeEnabled to 1 in your kll configuration.");
+                                       return;
+                               }
+                       }
+
                        void (*capability)(uint8_t, uint8_t, uint8_t*) = (void(*)(uint8_t, uint8_t, uint8_t*))(CapabilitiesList[ cap ].func);
                        capability( argSet[0], argSet[1], &argSet[2] );
                }
index e913006e615d06970ed8e5408f0ced007a2b7af9..782f3ace91d024a4e1d5c8bec32cb3b57db762b1 100644 (file)
@@ -911,40 +911,9 @@ 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_)
-
-       // 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_)
+#if defined(_mk20dx128vlf5_) || 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 ];
index d594ac1c32ec0e1be1fbfad1377913949feec143..2e97e42450060c34ee67c1e926825a71747eb2e4 100644 (file)
@@ -489,7 +489,7 @@ void Output_flashMode_capability( uint8_t state, uint8_t stateType, uint8_t *arg
        // Display capability name
        if ( stateType == 0xFF && state == 0xFF )
        {
-               print("Output_flashMode(usbCode)");
+               print("Output_flashMode()");
                return;
        }
 
index 928f342313a315895ef60f5c5989fa62db40867b..44c5b4920bf1c2c6353f2810c7b7d51e59252db7 100644 (file)
@@ -495,7 +495,7 @@ void Output_flashMode_capability( uint8_t state, uint8_t stateType, uint8_t *arg
        // Display capability name
        if ( stateType == 0xFF && state == 0xFF )
        {
-               print("Output_flashMode(usbCode)");
+               print("Output_flashMode()");
                return;
        }