cleanup of all memory address-critical code so changing the location of the application code is more straightforward
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
#define BOOTLOADER_VERSION_MINOR 2 //Legal value 0-99. (1 = X.01)
|
||||
|
||||
//Section defining the address range to erase for the erase device command, along with the valid programming range to be reported by the QUERY_DEVICE command.
|
||||
#define PROGRAM_MEM_START_ADDRESS REMAPPED_APPLICATION_RESET_VECTOR //Beginning of application program memory (not occupied by bootloader). **THIS VALUE MUST BE ALIGNED WITH 64 BYTE BLOCK BOUNDRY** Also, in order to work correctly, make sure the StartPageToErase is set to erase this section.
|
||||
#define PROGRAM_MEM_START_ADDRESS APP_FW_MEMORY_OFFSET //Beginning of application program memory (not occupied by bootloader). **THIS VALUE MUST BE ALIGNED WITH 64 BYTE BLOCK BOUNDRY** Also, in order to work correctly, make sure the StartPageToErase is set to erase this section.
|
||||
|
||||
#define MAX_PAGE_TO_ERASE 511 //Last 64 byte page of flash on the PIC18F4550
|
||||
#define PROGRAM_MEM_STOP_ADDRESS 0x008000 //**MUST BE WORD ALIGNED (EVEN) ADDRESS. This address does not get updated, but the one just below it does: IE: If PROGRAM_MEM_STOP_ADDRESS = 0x200, 0x1FF is the last programmed address (0x200 not programmed)**
|
||||
@@ -397,7 +397,7 @@ void ProcessIO(void)
|
||||
//in this firmware and is available for requesting by the host software.
|
||||
PacketToPC.Command = QUERY_EXTENDED_INFO; //Echo the command byte
|
||||
PacketToPC.BootloaderVersion = ((unsigned int)BOOTLOADER_VERSION_MAJOR << 8)| BOOTLOADER_VERSION_MINOR;
|
||||
PacketToPC.ApplicationVersion = *(const unsigned int*)APP_VERSION_ADDRESS;
|
||||
PacketToPC.ApplicationVersion = *(const unsigned int*)APP_FW_VERSION_ADDRESS;
|
||||
PacketToPC.SignatureAddress = APP_SIGNATURE_ADDRESS;
|
||||
PacketToPC.SignatureValue = APP_SIGNATURE_VALUE;
|
||||
PacketToPC.ErasePageSize = ERASE_PAGE_SIZE;
|
||||
|
||||
@@ -29,18 +29,10 @@
|
||||
|
||||
#include "memory.h"
|
||||
|
||||
#define APP_SIGNATURE_VALUE 0x600D //leet "GOOD", implying that the erase/program was a success and the bootloader intentionally programmed the APP_SIGNATURE_ADDRESS with this value
|
||||
|
||||
void UserInit(void);
|
||||
void ProcessIO(void);
|
||||
|
||||
//Vector remapping/absolute address constants
|
||||
#define REMAPPED_APPLICATION_RESET_VECTOR APP_FW_MEMORY_OFFSET
|
||||
//#define REMAPPED_APPLICATION_HIGH_ISR_VECTOR APP_FW_MEMORY_OFFSET + 0x08 //See VectorRemap.asm
|
||||
//#define REMAPPED_APPLICATION_LOW_ISR_VECTOR APP_FW_MEMORY_OFFSET + 0x18 //See VectorRemap.asm
|
||||
#define BOOTLOADER_ABSOLUTE_ENTRY_ADDRESS BOOTLOADER_ENTRYPOINT //Execute a "goto 0x001C" inline assembly instruction, if you want to enter the bootloader mode from the application via software
|
||||
|
||||
//#define APP_SIGNATURE_ADDRESS APP_FW_MEMORY_OFFSET + 0x06 //0x1C06 and 0x1C07 contains the "signature" WORD, indicating successful erase/program/verify operation
|
||||
//#define APP_SIGNATURE_VALUE 0x600D //leet "GOOD", implying that the erase/program was a success and the bootloader intentionally programmed the APP_SIGNATURE_ADDRESS with this value
|
||||
//#define APP_VERSION_ADDRESS APP_FW_MEMORY_OFFSET + 0x16 //0x1C16 and 0x1C17 should contain the application image firmware version number
|
||||
|
||||
#endif /* BOOTLOADER_ */
|
||||
|
||||
|
||||
@@ -36,11 +36,11 @@ DoFlashSignatureCheck:
|
||||
|
||||
//Also make sure the first WORD of program memory in the app space
|
||||
//is not blank, meaning there is an application image programmed into the device.
|
||||
if(*(const unsigned int*)REMAPPED_APPLICATION_RESET_VECTOR != 0xFFFF)
|
||||
if(*(const unsigned int*)APP_FW_MEMORY_OFFSET != 0xFFFF)
|
||||
{
|
||||
//Go ahead and jump out of bootloader mode into the application run mode
|
||||
#asm
|
||||
goto REMAPPED_APPLICATION_RESET_VECTOR
|
||||
goto APP_FW_MEMORY_OFFSET
|
||||
#endasm
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user