added bootloader force entry by input pin, projects changed back to build for the PIC18F2550
This commit is contained in:
@@ -49,7 +49,7 @@
|
||||
<conf name="default" type="2">
|
||||
<toolsSet>
|
||||
<developmentServer>localhost</developmentServer>
|
||||
<targetDevice>PIC18F4550</targetDevice>
|
||||
<targetDevice>PIC18F2550</targetDevice>
|
||||
<targetHeader></targetHeader>
|
||||
<targetPluginBoard></targetPluginBoard>
|
||||
<platformTool>PICkit3PlatformTool</platformTool>
|
||||
|
||||
@@ -5,10 +5,19 @@
|
||||
* Created on August 9, 2019, 6:14 PM
|
||||
*/
|
||||
|
||||
#include <xc.h>
|
||||
|
||||
#include "usb.h"
|
||||
#include "bootloader.h"
|
||||
|
||||
unsigned int uint_delay_counter;
|
||||
/**
|
||||
* Comment this out to not check the bootloader entry override switch.
|
||||
* THIS IS NOT RECOMMENDED!!
|
||||
* If disabled the ONLY way to enter firmware update mode is by a jump from the application code.
|
||||
* IF YOU FLASH BROKEN APPLICATION FIRMWARE YOU WILL HAVE A BRICK!!
|
||||
* At that point the device can only be reprogrammed by a dedicated programmer such as the ICD or Pickit 3.
|
||||
*/
|
||||
#define ENABLE_HARDWARE_MODE_OVERRIDE
|
||||
|
||||
/* Private prototypes */
|
||||
void main(void);
|
||||
@@ -19,11 +28,26 @@ const unsigned int FlashSignatureWord __at(APP_SIGNATURE_ADDRESS) = APP_SIGNATUR
|
||||
|
||||
void main(void)
|
||||
{
|
||||
/**
|
||||
* TODO: implement hardware IO-based method for forcing entry into bootloader
|
||||
*/
|
||||
goto DoFlashSignatureCheck;
|
||||
|
||||
#ifdef ENABLE_HARDWARE_MODE_OVERRIDE
|
||||
// immediately enter bootloader's firmware update mode if override switch is pressed
|
||||
PORTA = 0x00; // initialize PORTA by clearing output data latches
|
||||
ADCON1 = 0x0F; // disable analog functionality on PORTA pins
|
||||
CMCON = 0x07; // disable comparators on PORTA pins
|
||||
TRISAbits.RA0 = 1; // configure pin RA0 as input
|
||||
if (PORTAbits.RA0 == 1)
|
||||
{
|
||||
// switch is NOT pressed. bootloader will execute as normal
|
||||
ADCON1 = 0x00; // restore ADCON1 register to default state
|
||||
TRISAbits.RA0 = 0; // restore RA0 pin direction to default state (output)
|
||||
// start the signature check
|
||||
goto DoFlashSignatureCheck;
|
||||
}
|
||||
else
|
||||
{
|
||||
// switch IS pressed. bypass signature check and immediately enter firmware update mode
|
||||
BootMain();
|
||||
}
|
||||
#endif
|
||||
// normal operation: verify the firmware signature is valid. if it isn't enter
|
||||
// bootloader (fw update) mode so valid firmware can be flashed
|
||||
DoFlashSignatureCheck:
|
||||
@@ -50,7 +74,7 @@ DoFlashSignatureCheck:
|
||||
BootMain();
|
||||
}
|
||||
|
||||
void BootMain(void) __at(0x30)
|
||||
void BootMain(void) __at(BOOTLOADER_ENTRYPOINT)
|
||||
{
|
||||
//Make sure interrupts are disabled for this code (could still be on,
|
||||
//if the application firmware jumped into the bootloader via software methods)
|
||||
|
||||
Reference in New Issue
Block a user