Sfoglia il codice sorgente

Adding jump to bootloader key

- Now enabled by default
- Added protection around remote jumps
capsense
Jacob Alexander 8 anni fa
parent
commit
59d425ccfe

+ 9
- 3
Debug/cli/cli.c Vedi File



// ----- Includes ----- // ----- Includes -----


// Compiler Includes
//#include <stdarg.h>

// Project Includes // Project Includes
#include <buildvars.h> #include <buildvars.h>
#include "cli.h" #include "cli.h"
#include <led.h> #include <led.h>
#include <print.h> #include <print.h>
#include <kll_defs.h>








void cliFunc_reload( 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 // Request to output module to be set into firmware reload mode
Output_firmwareReload(); Output_firmwareReload();
} }

+ 13
- 0
Macro/PartialMap/macro.c Vedi File

printHex( argSet[2] ); printHex( argSet[2] );
print( "..." NL ); 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); 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] ); capability( argSet[0], argSet[1], &argSet[2] );
} }

+ 1
- 32
Output/pjrcUSB/arm/usb_dev.c Vedi File



void usb_device_reload() 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 // 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 // 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 // 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++ ) for ( int pos = 0; pos < sizeof(sys_reset_to_loader_magic); pos++ )
(&VBAT)[ pos ] = sys_reset_to_loader_magic[ pos ]; (&VBAT)[ pos ] = sys_reset_to_loader_magic[ pos ];

+ 1
- 1
Output/pjrcUSB/output_com.c Vedi File

// Display capability name // Display capability name
if ( stateType == 0xFF && state == 0xFF ) if ( stateType == 0xFF && state == 0xFF )
{ {
print("Output_flashMode(usbCode)");
print("Output_flashMode()");
return; return;
} }



+ 1
- 1
Output/usbMuxUart/output_com.c Vedi File

// Display capability name // Display capability name
if ( stateType == 0xFF && state == 0xFF ) if ( stateType == 0xFF && state == 0xFF )
{ {
print("Output_flashMode(usbCode)");
print("Output_flashMode()");
return; return;
} }