Fixing default ErgoDox layout and adding FlashMode button
- 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
This commit is contained in:
		
							parent
							
								
									1cbc175551
								
							
						
					
					
						commit
						9c52fb32fa
					
				
					 11 changed files with 148 additions and 62 deletions
				
			
		| 
						 | 
				
			
			@ -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...");
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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 -----
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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 -----
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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 -----
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue