From b546a3ec126850641971ab2c013bc8101725e2af Mon Sep 17 00:00:00 2001 From: "Ake Hedman, Paradise of the Frog" Date: Fri, 10 Jul 2015 18:07:09 +0200 Subject: [PATCH] Fixed problem with init. button entry of bootloader. Default nickname is now used when entering bootloader by holding down init. button and power board. --- .gitignore | 10 + .../nbproject/Makefile-genesis.properties | 20 +- CANBoot.X/nbproject/Makefile-impl.mk | 12 +- CANBoot.X/nbproject/Makefile-variables.mk | 28 +-- CANBoot.X/nbproject/configurations.xml | 11 +- .../SuppressibleMessageMemo.properties | 27 ++- .../nbproject/private/configurations.xml | 12 +- CANBoot.X/nbproject/private/private.xml | 5 +- CANIO.asm | 177 +++++++++++++----- CANIO.def | 2 +- HISTORY | 8 + README.md | 13 +- firmware/pic18F2580/CANBoot.X.production.hex | 37 ---- 13 files changed, 228 insertions(+), 134 deletions(-) delete mode 100644 firmware/pic18F2580/CANBoot.X.production.hex diff --git a/.gitignore b/.gitignore index bd5c3d2..ef3a93f 100644 --- a/.gitignore +++ b/.gitignore @@ -50,3 +50,13 @@ /CANBoot.X/dist/pic18f26k80/production/*.map /CANBoot.X/nbproject/*.mk /CANBoot.X/nbproject/*.bash +/CANBoot.X/build/pic18f2580-40mhz/production/_ext/1472/CANIO.err +/CANBoot.X/build/pic18f2580-40mhz/production/_ext/1472/CANIO.lst +/CANBoot.X/build/pic18f2580-40mhz/production/_ext/1472/CANIO.o.d +/CANBoot.X/build/pic18f26k80-40mhz/production/_ext/1472/CANIO.err +/CANBoot.X/build/pic18f26k80-40mhz/production/_ext/1472/CANIO.lst +/CANBoot.X/build/pic18f26k80-40mhz/production/_ext/1472/CANIO.o.d +/CANBoot.X/dist/pic18f2580-40mhz/production/CANBoot.X.production.cof +/CANBoot.X/dist/pic18f2580-40mhz/production/CANBoot.X.production.map +/CANBoot.X/dist/pic18f26k80-40mhz/production/CANBoot.X.production.cof +/CANBoot.X/dist/pic18f26k80-40mhz/production/CANBoot.X.production.map diff --git a/CANBoot.X/nbproject/Makefile-genesis.properties b/CANBoot.X/nbproject/Makefile-genesis.properties index bc0da06..259a4dd 100644 --- a/CANBoot.X/nbproject/Makefile-genesis.properties +++ b/CANBoot.X/nbproject/Makefile-genesis.properties @@ -1,12 +1,12 @@ # -#Thu May 21 14:38:28 CEST 2015 -pic18f26k80.languagetoolchain.version=5.62 -conf.ids=pic18f2580,pic18f26k80 -pic18f2580.com-microchip-mplab-nbide-toolchainMPASMWIN-MPASMWINLanguageToolchain.md5=326d208065f034951cba5f33e504621d -configurations-xml=5611d846a0cc221aab4420c1ec685b01 -pic18f2580.languagetoolchain.dir=C\:\\Program Files (x86)\\Microchip\\MPLABX\\v3.00\\mpasmx -pic18f26k80.com-microchip-mplab-nbide-toolchainMPASMWIN-MPASMWINLanguageToolchain.md5=326d208065f034951cba5f33e504621d -com-microchip-mplab-nbide-embedded-makeproject-MakeProject.md5=e9e394344dac8fa7117638c068420ddd -pic18f26k80.languagetoolchain.dir=C\:\\Program Files (x86)\\Microchip\\MPLABX\\v3.00\\mpasmx +#Fri Jul 10 18:01:14 CEST 2015 +pic18f26k80-40mhz.languagetoolchain.dir=C\:\\Program Files (x86)\\Microchip\\MPLABX\\v3.05\\mpasmx +pic18f2580-40mhz.languagetoolchain.version=5.62 +conf.ids=pic18f2580-40mhz,pic18f26k80-40mhz +pic18f2580-40mhz.com-microchip-mplab-nbide-toolchainMPASMWIN-MPASMWINLanguageToolchain.md5=739c69f9ccb2f30dcb795546686f5cd4 +pic18f2580-40mhz.languagetoolchain.dir=C\:\\Program Files (x86)\\Microchip\\MPLABX\\v3.05\\mpasmx +configurations-xml=5ebaf599cd4aa2b9e10525c77cecdc63 +pic18f26k80-40mhz.languagetoolchain.version=5.62 +com-microchip-mplab-nbide-embedded-makeproject-MakeProject.md5=47805b5596804b87cda41e61096929be host.platform=windows -pic18f2580.languagetoolchain.version=5.62 +pic18f26k80-40mhz.com-microchip-mplab-nbide-toolchainMPASMWIN-MPASMWINLanguageToolchain.md5=739c69f9ccb2f30dcb795546686f5cd4 diff --git a/CANBoot.X/nbproject/Makefile-impl.mk b/CANBoot.X/nbproject/Makefile-impl.mk index 21125c3..083b88e 100644 --- a/CANBoot.X/nbproject/Makefile-impl.mk +++ b/CANBoot.X/nbproject/Makefile-impl.mk @@ -27,11 +27,11 @@ CLEAN_SUBPROJECTS=${CLEAN_SUBPROJECTS_${SUBPROJECTS}} PROJECTNAME=CANBoot.X # Active Configuration -DEFAULTCONF=pic18f26k80 +DEFAULTCONF=pic18f2580-40mhz CONF=${DEFAULTCONF} # All Configurations -ALLCONFS=pic18f2580 pic18f26k80 +ALLCONFS=pic18f2580-40mhz pic18f26k80-40mhz # build @@ -45,15 +45,15 @@ ALLCONFS=pic18f2580 pic18f26k80 # clobber .clobber-impl: .clobber-pre .depcheck-impl - ${MAKE} SUBPROJECTS=${SUBPROJECTS} CONF=pic18f2580 clean - ${MAKE} SUBPROJECTS=${SUBPROJECTS} CONF=pic18f26k80 clean + ${MAKE} SUBPROJECTS=${SUBPROJECTS} CONF=pic18f2580-40mhz clean + ${MAKE} SUBPROJECTS=${SUBPROJECTS} CONF=pic18f26k80-40mhz clean # all .all-impl: .all-pre .depcheck-impl - ${MAKE} SUBPROJECTS=${SUBPROJECTS} CONF=pic18f2580 build - ${MAKE} SUBPROJECTS=${SUBPROJECTS} CONF=pic18f26k80 build + ${MAKE} SUBPROJECTS=${SUBPROJECTS} CONF=pic18f2580-40mhz build + ${MAKE} SUBPROJECTS=${SUBPROJECTS} CONF=pic18f26k80-40mhz build diff --git a/CANBoot.X/nbproject/Makefile-variables.mk b/CANBoot.X/nbproject/Makefile-variables.mk index 88e34c5..e89a967 100644 --- a/CANBoot.X/nbproject/Makefile-variables.mk +++ b/CANBoot.X/nbproject/Makefile-variables.mk @@ -4,17 +4,17 @@ # NOCDDL # CND_BASEDIR=`pwd` -# pic18f2580 configuration -CND_ARTIFACT_DIR_pic18f2580=dist/pic18f2580/production -CND_ARTIFACT_NAME_pic18f2580=CANBoot.X.production.hex -CND_ARTIFACT_PATH_pic18f2580=dist/pic18f2580/production/CANBoot.X.production.hex -CND_PACKAGE_DIR_pic18f2580=${CND_DISTDIR}/pic18f2580/package -CND_PACKAGE_NAME_pic18f2580=canboot.x.tar -CND_PACKAGE_PATH_pic18f2580=${CND_DISTDIR}/pic18f2580/package/canboot.x.tar -# pic18f26k80 configuration -CND_ARTIFACT_DIR_pic18f26k80=dist/pic18f26k80/production -CND_ARTIFACT_NAME_pic18f26k80=CANBoot.X.production.hex -CND_ARTIFACT_PATH_pic18f26k80=dist/pic18f26k80/production/CANBoot.X.production.hex -CND_PACKAGE_DIR_pic18f26k80=${CND_DISTDIR}/pic18f26k80/package -CND_PACKAGE_NAME_pic18f26k80=canboot.x.tar -CND_PACKAGE_PATH_pic18f26k80=${CND_DISTDIR}/pic18f26k80/package/canboot.x.tar +# pic18f2580-40mhz configuration +CND_ARTIFACT_DIR_pic18f2580-40mhz=dist/pic18f2580-40mhz/production +CND_ARTIFACT_NAME_pic18f2580-40mhz=CANBoot.X.production.hex +CND_ARTIFACT_PATH_pic18f2580-40mhz=dist/pic18f2580-40mhz/production/CANBoot.X.production.hex +CND_PACKAGE_DIR_pic18f2580-40mhz=${CND_DISTDIR}/pic18f2580-40mhz/package +CND_PACKAGE_NAME_pic18f2580-40mhz=canboot.x.tar +CND_PACKAGE_PATH_pic18f2580-40mhz=${CND_DISTDIR}/pic18f2580-40mhz/package/canboot.x.tar +# pic18f26k80-40mhz configuration +CND_ARTIFACT_DIR_pic18f26k80-40mhz=dist/pic18f26k80-40mhz/production +CND_ARTIFACT_NAME_pic18f26k80-40mhz=CANBoot.X.production.hex +CND_ARTIFACT_PATH_pic18f26k80-40mhz=dist/pic18f26k80-40mhz/production/CANBoot.X.production.hex +CND_PACKAGE_DIR_pic18f26k80-40mhz=${CND_DISTDIR}/pic18f26k80-40mhz/package +CND_PACKAGE_NAME_pic18f26k80-40mhz=canboot.x.tar +CND_PACKAGE_PATH_pic18f26k80-40mhz=${CND_DISTDIR}/pic18f26k80-40mhz/package/canboot.x.tar diff --git a/CANBoot.X/nbproject/configurations.xml b/CANBoot.X/nbproject/configurations.xml index 7dedb90..a316fc7 100644 --- a/CANBoot.X/nbproject/configurations.xml +++ b/CANBoot.X/nbproject/configurations.xml @@ -21,6 +21,8 @@ ../CANIO.def + ../HISTORY + ../README.md @@ -28,7 +30,7 @@ Makefile - + localhost PIC18F2580 @@ -66,7 +68,7 @@ - + @@ -132,7 +134,7 @@ - + localhost PIC18F26K80 @@ -170,7 +172,7 @@ - + @@ -194,6 +196,7 @@ value="Press to browse for a specific firmware version"/> + diff --git a/CANBoot.X/nbproject/private/SuppressibleMessageMemo.properties b/CANBoot.X/nbproject/private/SuppressibleMessageMemo.properties index 7034e48..966f4ce 100644 --- a/CANBoot.X/nbproject/private/SuppressibleMessageMemo.properties +++ b/CANBoot.X/nbproject/private/SuppressibleMessageMemo.properties @@ -1,3 +1,28 @@ # -#Mon Aug 18 12:20:48 CEST 2014 +#Wed Jun 24 14:15:20 CEST 2015 +mdbDebugger/MEMORY_VIEW_LAST_HW_BP_RESOURCE_WARN=false +icd3/VPP_FIRST_WARNING=false +pk3/VPP_FIRST_WARNING=false +pkobskde/CHECK_4_HIGH_VOLTAGE_VPP=false +pk3/DEVID_MISMATCH=false +mdbDebugger/NO_HW_BP_RESOURCES_WARN=false +mdbDebugger/NO_HW_COMBINER_RESOURCES_WARNING=false +icd3/CAL_WARNING=false +pkobskde/VPP_FIRST_WARNING=false +mdbDebugger/MEMORY_VIEW_NO_HW_BP_RESOURCES_WARN=false +pk3/CHECK_CLOCK=false +mdbDebugger/LAST_HW_BP_RESOURCE_WARN=false +pk3/CHECK_4_HIGH_VOLTAGE_VPP=false +icd3/DEVID_MISMATCH=false +realice/DEVID_MISMATCH=false +realice/CHECK_CLOCK=false +pkoblicdbgr/DEVID_MISMATCH=false +pkoblicdbgr/CHECK_CLOCK=false +pkobskde/DEVID_MISMATCH=false +icd3/CHECK_CLOCK=false realice/CHECK_4_HIGH_VOLTAGE_VPP=true +pkoblicdbgr/CHECK_4_HIGH_VOLTAGE_VPP=false +pk3/CAL_WARNING=false +icd3/CHECK_4_HIGH_VOLTAGE_VPP=false +pkobskde/CHECK_CLOCK=false +realice/CAL_WARNING=false diff --git a/CANBoot.X/nbproject/private/configurations.xml b/CANBoot.X/nbproject/private/configurations.xml index daf2e07..51924e5 100644 --- a/CANBoot.X/nbproject/private/configurations.xml +++ b/CANBoot.X/nbproject/private/configurations.xml @@ -1,11 +1,11 @@ Makefile - 1 + 0 - - :=MPLABComm-USB-Microchip:=<vid>04D8:=<pid>9004:=<rev>0100:=<man>Microchip Technology, Inc. (www.microchip.com):=<prod>MPLAB REAL ICE tm (www.microchip.com):=<sn>JIT113110039:=<drv>x:=<xpt>b:=end - C:\Program Files (x86)\Microchip\MPLABX\v3.00\mpasmx + + :=MPLABComm-USB-Microchip:=<vid>04D8:=<pid>9004:=<rev>0100:=<man>Microchip Technology, Inc. (www.microchip.com):=<prod>MPLAB REAL ICE tm (www.microchip.com):=<sn>JIT113110039:=<drv>x:=end + C:\Program Files (x86)\Microchip\MPLABX\v3.05\mpasmx place holder 1 place holder 2 @@ -21,9 +21,9 @@ - + :=MPLABComm-USB-Microchip:=<vid>04D8:=<pid>9004:=<rev>0100:=<man>Microchip Technology, Inc. (www.microchip.com):=<prod>MPLAB REAL ICE tm (www.microchip.com):=<sn>JIT113110039:=<drv>x:=<xpt>b:=end - C:\Program Files (x86)\Microchip\MPLABX\v3.00\mpasmx + C:\Program Files (x86)\Microchip\MPLABX\v3.05\mpasmx place holder 1 place holder 2 diff --git a/CANBoot.X/nbproject/private/private.xml b/CANBoot.X/nbproject/private/private.xml index 09113fb..cd3e03d 100644 --- a/CANBoot.X/nbproject/private/private.xml +++ b/CANBoot.X/nbproject/private/private.xml @@ -3,9 +3,6 @@ - - file:/C:/Users/grodansparadis/development/vscp_pic1_bootloader/CANIO.asm - file:/C:/Users/grodansparadis/development/vscp_pic1_bootloader/CANIO.def - + diff --git a/CANIO.asm b/CANIO.asm index f3af7fd..5ae1f61 100644 --- a/CANIO.asm +++ b/CANIO.asm @@ -175,17 +175,51 @@ #include canio.def ; ***************************************************************************** -#ifdef __18F2580 -; WDT must be off +#ifdef __18F2580 + + ; WDT must be off CONFIG WDT = OFF, WDTPS = 128 CONFIG OSC = HSPLL CONFIG BOREN = BOACTIVE CONFIG STVREN = ON CONFIG BORV = 3 -; LVP must be off + + ; LVP must be off CONFIG LVP = OFF - CONFIG CPB = ON CONFIG BBSIZ = 2048 + + ; CONFIG5L + CONFIG CP0 = ON ; Code Protect 00800-03FFF (Enabled) + CONFIG CP1 = ON ; Code Protect 04000-07FFF (Enabled) + CONFIG CP2 = ON ; Code Protect 08000-0BFFF (Enabled) + CONFIG CP3 = ON ; Code Protect 0C000-0FFFF (Enabled) + + ; CONFIG5H + CONFIG CPB = ON ; Code Protect Boot (Enabled) + CONFIG CPD = OFF ; Data EE Read Protect (Disabled) + + ; CONFIG6L + CONFIG WRT0 = OFF ; Table Write Protect 00800-03FFF (Disabled) + CONFIG WRT1 = OFF ; Table Write Protect 04000-07FFF (Disabled) + CONFIG WRT2 = OFF ; Table Write Protect 08000-0BFFF (Disabled) + CONFIG WRT3 = OFF ; Table Write Protect 0C000-0FFFF (Disabled) + + ; CONFIG6H + ; if WRTB is ON device never comes out of bootload + CONFIG WRTC = OFF ; Config. Write Protect (Disabled) + CONFIG WRTB = OFF ; Table Write Protect Boot (Disabled) + CONFIG WRTD = OFF ; Data EE Write Protect (Disabled) + + ; CONFIG7L + CONFIG EBTR0 = OFF ; Table Read Protect 00800-03FFF (Disabled) + CONFIG EBTR1 = OFF ; Table Read Protect 04000-07FFF (Disabled) + CONFIG EBTR2 = OFF ; Table Read Protect 08000-0BFFF (Disabled) + CONFIG EBTR3 = OFF ; Table Read Protect 0C000-0FFFF (Disabled) + + ; CONFIG7H + ; If set to ON constants in flash can not be read. + CONFIG EBTRB = OFF ; *Table Read Protect Boot (Disabled) + #endif #ifdef __18F26K80 @@ -240,7 +274,7 @@ ; CONFIG6H CONFIG WRTC = OFF ; Config. Write Protect (Disabled) - CONFIG WRTB = ON ; Table Write Protect Boot (Disabled) + CONFIG WRTB = OFF ; Table Write Protect Boot (Disabled) CONFIG WRTD = OFF ; Data EE Write Protect (Disabled) ; CONFIG7L @@ -250,7 +284,7 @@ CONFIG EBTR3 = OFF ; Table Read Protect 0C000-0FFFF (Disabled) ; CONFIG7H - CONFIG EBTRB = ON ; Table Read Protect Boot (Disabled) + CONFIG EBTRB = OFF ; Table Read Protect Boot (Disabled) #endif @@ -262,18 +296,18 @@ #define TRUE 1 #define FALSE 0 -#define VSCP_BOOT_FLAG 0xff ; Boot flag is stored in EEPROM location 0 - ; and if there the bootloader will be activated. +#define VSCP_BOOT_FLAG 0xff ; Boot flag is stored in EEPROM location 0 + ; and if there the bootloader will be activated. -#define WREG1 PRODH ; Alternate working register +#define WREG1 PRODH ; Alternate working register #define WREG2 PRODL -#define MODE_WRT_UNLCK _bootCtlBits,0 ; Unlock write and erase -#define MODE_ERASE_ONLY _bootCtlBits,1 ; Erase without write -#define MODE_AUTO_ERASE _bootCtlBits,2 ; Enable auto erase before write -#define MODE_AUTO_INC _bootCtlBits,3 ; Enable auto inc the address -#define MODE_ACK _bootCtlBits,4 ; Acknowledge mode +#define MODE_WRT_UNLCK _bootCtlBits,0 ; Unlock write and erase +#define MODE_ERASE_ONLY _bootCtlBits,1 ; Erase without write +#define MODE_AUTO_ERASE _bootCtlBits,2 ; Enable auto erase before write +#define MODE_AUTO_INC _bootCtlBits,3 ; Enable auto inc the address +#define MODE_ACK _bootCtlBits,4 ; Acknowledge mode ; AKHE #define MODE_FLAG_WRT_UNLCK 0x01 @@ -282,7 +316,7 @@ #define MODE_FLAG_AUTO_INC 0x08 #define MODE_FLAG_ACK 0x10 -#define ERR_VERIFY _bootErrStat,0 ; Failed to verify +#define ERR_VERIFY _bootErrStat,0 ; Failed to verify #define CMD_NOP 0x00 #define CMD_RESET 0x01 @@ -465,56 +499,94 @@ _CANInit: ; AKHE If RC0 is zero on boot ; force bootloader mode +#ifdef __18F26K80 banksel ANCON0 clrf ANCON0 clrf ANCON1 - movlw b'00001100' +#endif + movlw b'00001100' ; CAN is input movwf TRISB movlw b'11111101' ; RC0 is input movwf TRISC - bsf PORTC,RC1 + bsf PORTC,RC1 ; Light status lamp movf PORTC,W - andlw b'00000001' - bz bootload_mode + andlw b'00000001' ; Check if button is pressed + bz button_pressed banksel EECON1 clrf EECON1 clrf EEADR ; Point to first location of EEDATA (BOOTFLAG) - clrf EEADRH - bsf EECON1, RD ; Read the control code - incfsz EEDATA, W - +#ifdef __18F26K80 + clrf EEADRH +#endif + + ; Read boot flag + BCF EECON1, EEPGD ; Point to DATA memory + BCF EECON1, CFGS ; Access EEPROM + BSF EECON1, RD ; EEPROM Read + NOP + INFSNZ EEDATA, W + BRA bootload_mode ; Bootloader if bootflag = 0xff + + banksel CANCON #ifdef NEAR_JUMP + movlw b'10000000' ; Set configure mode + movwf CANCON bra ResetRemapped ; If not 0xFF then normal reset #else + movlw b'10000000' ; Set configure mode + movwf CANCON goto ResetRemapped #endif + +button_pressed: + + banksel EECON1 + + ; If button is pressed we always use nickname 0xfe +#ifdef __18F26K80 + clrf EEADRH +#endif + movlw 01h; ; Point at nickname + movwf EEADR + movlw 0FEh ; Default nickname + movwf EEDATA ; Data Memory Value to write + movlw b'00000100' ; Setup for EEData + rcall _StartWrite bootload_mode: banksel EECON1 + + ; Make sure boot flag is set +#ifdef __18F26K80 + clrf EEADRH +#endif + clrf EEADR ; Point at bootflag + movlw 0FFh ; Bootloader enabled + movwf EEDATA ; Data Memory Value to write + movlw b'00000100' ; Setup for EEData + rcall _StartWrite clrf _bootSpcCmd ; Reset the special command register ; Get Nickname from EEPROM and save in RAM - movlw 0x01 + banksel EECON1 +#ifdef __18F26K80 + clrf EEADRH +#endif + banksel EEADR + movlw 01h movwf EEADR ; Point at nickname in EEPROM - bsf EECON1, RD ; Read the control code + BCF EECON1, EEPGD ; Point to DATA memory + BCF EECON1, CFGS ; Access EEPROM + BSF EECON1, RD ; EEPROM Read + NOP movf EEDATA, W movwf _vscpNickname movlw ( MODE_FLAG_AUTO_ERASE | MODE_FLAG_AUTO_INC | MODE_FLAG_ACK ) movwf _bootCtlBits - movlb d'15' ; Set Bank 15 - -#ifdef __18F2580 - bcf TRISB, CANTX ; Set the TX pin to output -#endif - -#ifdef __18F26K80 - ;movlw b'00001000' ; CAN RX is input - ;movwf TRISB -#endif banksel RXF0SIDH movlw CAN_RXF0SIDH ; Set filter 0 @@ -570,7 +642,7 @@ bootload_mode: _CANMain: banksel PORTC - bsf PORTC,RC0 ; AKHE: status on + bcf PORTC,RC1 ; AKHE: status on banksel RXB0CON bcf RXB0CON, RXFUL ; Clear the receive flag @@ -580,7 +652,8 @@ _CANMain: btfss RXB0CON, RXFUL ; Wait for a message bra $ - 4 ; AKHE: - bcf PORTC,RC0 ; AKHE: status off + banksel PORTC + bsf PORTC,RC1 ; AKHE: status off #ifdef ALLOW_GET_CMD btfss CAN_PG_BIT ; Put or get data? @@ -588,6 +661,7 @@ _CANMain: ; Put + banksel TXB0D0 lfsr 0, TXB0D0 ; Set pointer to the transmit buffer movlw 0x08 movwf _bootCount ; Setup the count to eight @@ -739,6 +813,7 @@ _SpecialCmdJp1: bra _SpecialCmdJp2 banksel EEADR + clrf EEADR ; AKHE - Point to first location of EEDATA clrf EEADRH clrf EEDATA ; and clear the data @@ -750,7 +825,7 @@ _SpecialCmdJp2: #ifdef ALLOW_GET_CMD bra _CANSendAck ; or send an acknowledge #else - bra _CANMain + goto _CANMain #endif ; ***************************************************************************** @@ -782,6 +857,7 @@ _SetPointers: movf _bootAddrL, W ; Copy the low pointer movwf TBLPTRL + banksel EECON1 movwf EEADR btfss MODE_AUTO_INC ; Adjust the pointer if auto inc is enabled @@ -828,7 +904,11 @@ _DecodeJp2: movf WREG2,W ; EEPROM data = 0xF00000 xorlw 0xF0 - bnz _CANMain + ;bnz _CANMain + bz _DecodeJp3 + bra _CANMain + +_DecodeJp3: #ifdef ALLOW_GET_CMD btfsc CAN_PG_BIT bra _EERead @@ -905,14 +985,17 @@ _PMWrite: #ifdef ALLOW_GET_CMD bra _CANSendAck #else - bra _CANMain + goto _CANMain #endif banksel TBLPTRL movf TBLPTRL, W ; Check for a valid 8 byte border andlw b'00000111' - bnz _CANMain - + ;bnz _CANMain + bz _PMWriteLp0 + goto _CANMain + +_PMWriteLp0: movlw 0x08 movwf WREG1 @@ -971,7 +1054,7 @@ _PMReadBackLp1: #ifdef ALLOW_GET_CMD bra _CANSendAck #else - bra _CANMain + goto _CANMain #endif ; ***************************************************************************** @@ -1036,7 +1119,7 @@ _CFGWrite: #ifdef ALLOW_GET_CMD bra _CANSendAck #else - bra _CANMain + goto _CANMain #endif ; ***************************************************************************** @@ -1121,7 +1204,7 @@ _EEWrite: #ifdef ALLOW_GET_CMD #else - bra _CANMain + goto _CANMain #endif ; ***************************************************************************** @@ -1160,7 +1243,7 @@ _EEWrite: _CANSendAck: btfss MODE_ACK - bra _CANMain + goto _CANMain _CANSendAck2: @@ -1200,7 +1283,7 @@ _CANSendMessage: bsf TXB0CON, TXREQ ; Start the transmission - bra _CANMain + goto _CANMain #endif ; ***************************************************************************** diff --git a/CANIO.def b/CANIO.def index 0102324..ba2745e 100644 --- a/CANIO.def +++ b/CANIO.def @@ -2,7 +2,7 @@ #define ALLOW_GET_CMD ;#define MODE_SELF_VERIFY -#define NEAR_JUMP +;#define NEAR_JUMP #define HIGH_INT_VECT 0x808 #define LOW_INT_VECT 0x818 #define RESET_VECT 0x800 diff --git a/HISTORY b/HISTORY index 9545934..c0a7d43 100644 --- a/HISTORY +++ b/HISTORY @@ -1,4 +1,12 @@ +2015-07-10 AKHE Version 0.2.4 +============================= +Fixed problem with not going into bootloader if init. button was not +pressed. +If init. button is pressed when a board is powered the bootloader is always +entered with nickname 0xfe (old code used the current nickname). + 2015-05-21 AKHE Version 0.2.3 +============================= Now compiles correctly for "K" devices. (Thanks to Stevens work) Bootloader mode is forced when the status button is held and the module is powerd up. diff --git a/README.md b/README.md index 3b0cec6..e423ca9 100644 --- a/README.md +++ b/README.md @@ -8,10 +8,15 @@ in most aspects it is the same. The changes just makes it works along side an in CAN4VSCP system. Use file/export in MPLAB(x) after build to write the HEX file. -When programmed into a device and activated (byte 0 in EEPROM is 0xFF on startup) or the status -button (RC0) is held low on startup, a confirm bootloader mode CAN message with id=0x000014nn/0x000015nn -and no data will be sent. Node id (nn) (least eight bits of id) is taken from EEPROM byte 1. -If byte 0 in EEPROM is not oxFF on startup a normal boot of the relocated code (offset=0x800) will take place. + +When programmed into a device and activated (byte 0 in EEPROM is 0xff on startup or the status +button (RC0) is held low on startup) a confirm bootloader mode CAN message with id=0x000014nn/0x000015nn +and no data will be sent. Node id (nn) (least eight bits of id) is taken from EEPROM byte 1. For a freshly +written bootloader nn=0xfe and this is also true for a bootloader that is entered by holding the init. button +and power a board. If the board has been forced in to bootloader mode by the VSCP firmware nn will be the +nickname the node had at that time. + +If byte 0 in EEPROM is not oxff on startup a normal boot of the relocated code (offset=0x800) will take place. Hex files for device programming is available here https://sourceforge.net/projects/m2m/files/VSCP%20Firmware/bootloader/ diff --git a/firmware/pic18F2580/CANBoot.X.production.hex b/firmware/pic18F2580/CANBoot.X.production.hex deleted file mode 100644 index 0809bae..0000000 --- a/firmware/pic18F2580/CANBoot.X.production.hex +++ /dev/null @@ -1,37 +0,0 @@ -:020000040000FA -:0400000025D014D023 -:02000800FFD027 -:02001800FFD017 -:02002A000000D4 -:04002C00A66E04A018 -:100030001200550EA76EAA0EA76EA6820000A6B2E9 -:10004000FED712000926D8B00A2A1200A66AA96AA9 -:10005000AA6AA680A83CD4D0056A010EA96EA68023 -:10006000A8500C6E1C0E046E0F019394000E006FCE -:10007000080E016FE81E056F100E026F000E036F71 -:100080000F0E186FFF0E196FFC0E1A6F000E1B6F0C -:10009000090E706EB80E716E050E726E200E736EC4 -:1000A0006F6A9DD0609E040060AEFDD763A206D04B -:1000B0000FEE46F0080E086EF46E07D00FEE66F0F5 -:1000C00065500F0B086EF46EEDE063B028D010EEB3 -:1000D00000F063B2E6CFEEFF63A2EECFE6FFF42EB0 -:1000E000F8D763B27ED005507AE0010AD8B4FF0099 -:1000F0000550020A03E10A6A096A0B900550030AD7 -:100100000DE1065009260AE107500A2207E10BB06B -:1001100005D0A96AAA6AA86A040E88DF5ED00250D8 -:10012000F86EF00BF36E0150F76EAA6E0050F66E8B -:10013000A96E04A605D008500026E86A0122022212 -:10014000300EF36003D063B20DD012D0F350300AFA -:1001500003E163B207D025D0F350F00AA3E163B204 -:100160002AD032D00900F5CFEEFFF42EFBD739D0DC -:1001700004A405D0F6503F0B02E1940E57DF04B201 -:100180002CD0F650070B8EE1080EF46EEE50F56E93 -:1001900059DF0D00F42EFAD70A00840E47DF09005C -:1001A0001CD0EE50F56E4EDF0C00C40E3FDF090090 -:1001B000F42EF7D712D0A66AA680A8CFEEFFA94AE0 -:1001C000AA2AF42EF8D70DD0EE50A86E3BDF040E0D -:1001D0002DDFA94AAA2AF42EF7D704A863D7456BC6 -:1001E00002D0080E456F40B7FED7000E416F080ED3 -:1001F000426F140E436F0C50446F438163A04391D0 -:04020000408750D70C -:00000001FF