|
|
View previous topic :: View next topic |
Author |
Message |
davidd
Joined: 30 Sep 2010 Posts: 38
|
|
Posted: Thu Jan 28, 2016 12:58 pm |
|
|
ok
try placing some activity in application() like a blinking LED, then start from scratch and load only the bootloader. then reset and let it ride.
if application runs it means bootloader is working and all your fuses are correct etc... |
|
|
SeeCwriter
Joined: 18 Nov 2013 Posts: 160
|
|
Posted: Thu Jan 28, 2016 2:03 pm |
|
|
If I add any code to application() I get a compiler error about the code overrunning the segment. If I increase the end address of the #org statement to increase the size of the segment, I compiler error Invalid ORG range. |
|
|
davidd
Joined: 30 Sep 2010 Posts: 38
|
|
Posted: Thu Jan 28, 2016 6:15 pm |
|
|
You should be able to put something there.
Double check bootloader asm file and make sure no address is greater than 0x500.
edit: is there an #ORG range for application() ? maybe you have to change that. |
|
|
SeeCwriter
Joined: 18 Nov 2013 Posts: 160
|
|
Posted: Thu Jan 28, 2016 7:48 pm |
|
|
This is application:
Code: |
#org LOADER_END+2, LOADER_END+4
void application(void) {
while(TRUE) {
//output_high( HEARTBEAT_LED );
//delay_ms(100);
//output_low( HEARTBEAT_LED );
//delay_ms(100);
}
}
|
If I change the end address, I get a compiler error "invalid ORG Range."
The segment appears to be only 2-byte long. According to the list file it's address range is 0x500 - 0x502. |
|
|
davidd
Joined: 30 Sep 2010 Posts: 38
|
|
Posted: Thu Jan 28, 2016 7:51 pm |
|
|
increase loader_end+20, see what happens... |
|
|
SeeCwriter
Joined: 18 Nov 2013 Posts: 160
|
|
Posted: Fri Jan 29, 2016 9:38 am |
|
|
Compiler output with "loader_end+20":
Line 31: More info: Segment at 00000-00502 (0000 used)
Line 31: More info: Segment at 00504-0FFFE (0000 used) Priv
Line 31: More info: Segment at 10000-1FFFE (0000 used) Priv
Line 31: More info: Attempted to create: 00500-00512 for #org
Error 126 "gatrBL.c" Line 31: Invalid ORG range |
|
|
davidd
Joined: 30 Sep 2010 Posts: 38
|
|
Posted: Fri Jan 29, 2016 9:43 am |
|
|
Can you please post the asm file? |
|
|
SeeCwriter
Joined: 18 Nov 2013 Posts: 160
|
|
Posted: Fri Jan 29, 2016 10:06 am |
|
|
Because there was a compiler error a list file was not created. But here is the list for the last good compile from yesterday at 3pm:
Code: |
CCS PCH C Compiler, Version 5.054, 26313 28-Jan-16 15:00
Filename: C:\Projects\Pic\GATR\gatrBL.lst
ROM used: 922 bytes (1%)
Largest free fragment is 65536
RAM used: 73 (2%) at main() level
128 (3%) worst case
Stack used: 2 locations (1 in main + 1 for interrupts)
Stack size: 31
*
00000: GOTO 0322
.................... #include <gatrBL.h>
.................... #include <18F67K22.h>
.................... //////////// Standard Header file for the PIC18F67K22 device ////////////////
.................... ///////////////////////////////////////////////////////////////////////////
.................... //// (C) Copyright 1996, 2014 Custom Computer Services ////
.................... //// This source code may only be used by licensed users of the CCS C ////
.................... //// compiler. This source code may only be distributed to other ////
.................... //// licensed users of the CCS C compiler. No other use, reproduction ////
.................... //// or distribution is permitted without written permission. ////
.................... //// Derivative programs created using this software in object code ////
.................... //// form are not restricted in any way. ////
.................... ///////////////////////////////////////////////////////////////////////////
.................... #device PIC18F67K22
*
0001E: DATA 0D,0A
00020: DATA 53,65
00022: DATA 72,69
00024: DATA 61,6C
00026: DATA 20,42
00028: DATA 6F,6F
0002A: DATA 74,6C
0002C: DATA 6F,61
0002E: DATA 64,65
00030: DATA 72,20
00032: DATA 76,31
00034: DATA 2E,30
00036: DATA 0D,0A
00038: DATA 00,00
0003A: DATA 57,61
0003C: DATA 69,74
0003E: DATA 69,6E
00040: DATA 67,20
00042: DATA 66,6F
00044: DATA 72,20
00046: DATA 64,6F
00048: DATA 77,6E
0004A: DATA 6C,6F
0004C: DATA 61,64
0004E: DATA 2E,2E
00050: DATA 2E,00
00052: TBLRD*+
00054: MOVF FF5,F
00056: BZ 007A
00058: MOVFF FF6,49
0005C: MOVFF FF7,4A
00060: MOVFF FF8,4B
00064: MOVF FF5,W
00066: BTFSS F9E.4
00068: BRA 0066
0006A: MOVWF FAD
0006C: MOVFF 49,FF6
00070: MOVFF 4A,FF7
00074: MOVFF 4B,FF8
00078: BRA 0052
0007A: RETURN 0
*
000EA: MOVF FF2,W
000EC: MOVWF 03
000EE: BCF FF2.7
000F0: BSF F7F.7
000F2: BSF F7F.2
000F4: MOVLB F
000F6: MOVLW 55
000F8: MOVWF F7E
000FA: MOVLW AA
000FC: MOVWF F7E
000FE: BSF F7F.1
00100: NOP
00102: MOVF 03,W
00104: IORWF FF2,F
00106: MOVLB 0
00108: RETURN 0
0010A: BSF FD0.6
0010C: BCF F7F.6
0010E: MOVF FF6,W
00110: ANDLW 7F
00112: MOVWF 00
00114: MOVLW 80
00116: ANDWF FF6,F
00118: TBLRD*-
0011A: MOVFF 77,01
0011E: TSTFSZ 00
00120: BRA 0130
00122: MOVFF FEE,FF5
00126: MOVF 01,F
00128: BZ 0132
0012A: TBLWT+*
0012C: DECF 01,F
0012E: BRA 0136
00130: DECF 00,F
00132: TBLRD+*
00134: TBLWT*
00136: MOVLW 7F
00138: ANDWF FF6,W
0013A: XORLW 7F
0013C: BNZ 011E
0013E: BSF F7F.4
00140: RCALL 00EA
00142: RCALL 00EA
00144: TSTFSZ 01
00146: BRA 011E
00148: CLRF FF8
0014A: GOTO 0300 (RETURN)
....................
.................... #list
....................
.................... #device ADC=16
....................
.................... /*
.................... ** These fuses must match the fuses in the main application.
.................... */
.................... #FUSES PUT
.................... #FUSES HSM
.................... #FUSES NOWDT // Enable Watch Dog Timer
.................... #FUSES WDT512 // Watch Dog Timer uses 1:512 Postscale for 2-sec timeout.
.................... #FUSES BORV30 // Brown-out Reset at 3.0V.
....................
.................... //#define BOOTLOADER_AT_START
.................... #define BOOTLOADER_STREAM COM1
.................... //#use delay(clock=40000000,crystal=10000000)
.................... #use delay(clock=64000000,internal=16000000,restart_wdt)
.................... #use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=BOOTLOADER_STREAM)
*
0007C: BTFSS F9E.4
0007E: BRA 007C
00080: MOVWF FAD
00082: RETURN 0
....................
....................
....................
.................... #define _bootloader
....................
.................... // NOTE - User must include bootloader.h in application program
.................... #include <bootloader.h>
.................... ///////////////////////////////////////////////////////////////////////////
.................... //// BOOTLOADER.H ////
.................... //// ////
.................... //// This include file must be included by any application loaded ////
.................... //// by the example bootloader (ex_bootloader.c). ////
.................... //// ////
.................... //// The directives in this file relocate the reset and interrupt ////
.................... //// vectors as well as reserving space for the bootloader. ////
.................... //// ////
.................... //// LOADER_END may need to be adjusted for a specific chip and ////
.................... //// bootloader. LOADER_END must be 1 minus a multiple of ////
.................... //// FLASH_ERASE_SIZE. ////
.................... ///////////////////////////////////////////////////////////////////////////
.................... //// (C) Copyright 1996,2014 Custom Computer Services ////
.................... //// This source code may only be used by licensed users of the CCS ////
.................... //// C compiler. This source code may only be distributed to other ////
.................... //// licensed users of the CCS C compiler. No other use, ////
.................... //// reproduction or distribution is permitted without written ////
.................... //// permission. Derivative programs created using this software ////
.................... //// in object code form are not restricted in any way. ////
.................... ///////////////////////////////////////////////////////////////////////////
.................... #ifndef __BOOTLOADER_H__
.................... #define __BOOTLOADER_H__
....................
.................... #ifndef LOADER_END
.................... #if defined(__PCM__)
.................... #ifdef BOOTLOADER_MODE2X
.................... #define LOADER_END 0x4BF
.................... #else
.................... #define LOADER_END 0x33F
.................... #endif
.................... #elif defined(__PCH__)
.................... #define FLASH_SIZE getenv("FLASH_ERASE_SIZE")
.................... #if ((0x500 % FLASH_SIZE) == 0) //IF 0x500 is even flash boundary
.................... #define LOADER_END 0x4FF
.................... #else //ELSE, goto next even boundary
.................... #define LOADER_END ((0x500+FLASH_SIZE-(0x500 % FLASH_SIZE))-1)
.................... #endif
.................... #else
.................... #error Bootloader only works with PCM or PCH compiler
.................... #endif
.................... #endif
....................
.................... #define LOADER_SIZE LOADER_END
....................
.................... #ifndef BOOTLOADER_AT_START
.................... #define BOOTLOADER_AT_START
.................... #endif
....................
.................... #ifndef _bootloader
.................... #if defined(__PCM__)
.................... #build(reset=LOADER_END+1, interrupt=LOADER_END+5)
.................... #elif defined(__PCH__)
.................... #build(reset=LOADER_END+1, interrupt=LOADER_END+9)
.................... #endif
....................
.................... #org 0, LOADER_END {}
.................... #else
.................... #ifdef __PCM__
.................... #if getenv("PROGRAM_MEMORY") <= 0x800
.................... #org LOADER_END+3, (getenv("PROGRAM_MEMORY") - 1) {}
.................... #else
.................... #org LOADER_END+3, 0x7FF {}
.................... #if getenv("PROGRAM_MEMORY") <= 0x1000
.................... #org 0x800, (getenv("PROGRAM_MEMORY") - 1) {}
.................... #else
.................... #org 0x800, 0xFFF{}
.................... #if getenv("PROGRAM_MEMORY") <= 0x1800
.................... #org 0x1000, (getenv("PROGRAM_MEMORY") - 1) {}
.................... #else
.................... #org 0x1000, 0x17FF {}
.................... #if getenv("PROGRAM_MEMORY") <= 0x2000
.................... #org 0x1800, (getenv("PROGRAM_MEMORY") - 1) {}
.................... #else
.................... #org 0x1800, 0x1FFF {}
.................... #if getenv("PROGRAM_MEMORY") <= 0x2800
.................... #org 0x2000, (getenv("PROGRAM_MEMORY") - 1) {}
.................... #else
.................... #org 0x2000, 0x27FF {}
.................... #if getenv("PROGRAM_MEMORY") <= 0x3000
.................... #org 0x2800, (getenv("PROGRAM_MEMORY") - 1) {}
.................... #else
.................... #org 0x2800, 0x2FFF {}
.................... #if getenv("PROGRAM_MEMORY") <= 0x3800
.................... #org 0x3000, (getenv("PROGRAM_MEMORY") - 1) {}
.................... #else
.................... #org 0x3000, 0x37FF {}
.................... #org 0x3800, 0x3FFF {}
.................... #endif
.................... #endif
.................... #endif
.................... #endif
.................... #endif
.................... #endif
.................... #endif
.................... #else
.................... #if getenv("PROGRAM_MEMORY") <= 0x10000
.................... #org LOADER_END+5, (getenv("PROGRAM_MEMORY") - 1) {}
.................... #else
.................... #org LOADER_END+5, 0xFFFE {}
.................... #org 0x10000, (getenv("PROGRAM_MEMORY") - 1) {}
.................... #endif
.................... #endif
.................... #endif
....................
.................... #endif
....................
.................... #include <loader.c>
.................... ///////////////////////////////////////////////////////////////////////////
.................... //// loader.c ////
.................... //// ////
.................... //// This driver will take an Intel 8-bit Hex file over RS232 channels ////
.................... //// and modify the flash program memory with the new code. A proxy ////
.................... //// function is required to sit between the real loading function ////
.................... //// and the main code because the #org preprocessor command could ////
.................... //// possibly change the order of functions within a defined block. ////
.................... //// ////
.................... //// After each good line, the loader sends an ACKLOD character. The ////
.................... //// driver uses XON/XOFF flow control. Also, any buffer on the PC ////
.................... //// UART must be turned off, or to its lowest setting, otherwise it ////
.................... //// will miss data. ////
.................... //// ////
.................... //// ////
.................... ///////////////////////////////////////////////////////////////////////////
.................... //// (C) Copyright 1996,2014 Custom Computer Services ////
.................... //// This source code may only be used by licensed users of the CCS C ////
.................... //// compiler. This source code may only be distributed to other ////
.................... //// licensed users of the CCS C compiler. No other use, reproduction ////
.................... //// or distribution is permitted without written permission. ////
.................... //// Derivative programs created using this software in object code ////
.................... //// form are not restricted in any way. ////
.................... ///////////////////////////////////////////////////////////////////////////
....................
.................... #ifndef LOADER_END
.................... #define LOADER_END getenv("PROGRAM_MEMORY")-1
....................
.................... #if defined(__PCM__)
.................... #define LOADER_SIZE 0x27F
.................... #elif defined(__PCH__)
.................... #if (getenv("PROGRAM_MEMORY") % getenv("FLASH_ERASE_SIZE")) == 0
.................... #define LOADER_SIZE 0x3FF
.................... #else
.................... #define LOADER_SIZE (getenv("PROGRAM_MEMORY") % (getenv("FLASH_ERASE_SIZE")) - 1)
.................... #endif
.................... #endif
.................... #endif
....................
.................... #define LOADER_ADDR LOADER_END-LOADER_SIZE
....................
.................... #ifndef BOOTLOADER_AT_START
.................... #ORG LOADER_ADDR+4, LOADER_END auto=0 default
.................... #endif
....................
.................... #ifndef BUFFER_LEN_LOD
.................... #define BUFFER_LEN_LOD 64
.................... #endif
....................
.................... #ifdef BOOTLOADER_MODE2X
.................... #define BUFFER_COUNT 2
.................... #else
.................... #define BUFFER_COUNT 1
.................... #endif
....................
.................... #if defined(__PCM__) && !getenv("ENH16") && (BUFFER_COUNT == 2)
.................... struct
.................... {
.................... int8 idx;
.................... char *buffer;
.................... } rBuffer[BUFFER_COUNT];
....................
.................... char Buffer1[BUFFER_LEN_LOD];
.................... char Buffer2[BUFFER_LEN_LOD];
.................... #else
.................... struct
.................... {
.................... int8 idx;
.................... char buffer[BUFFER_LEN_LOD];
.................... } rBuffer[BUFFER_COUNT];
.................... #endif
....................
.................... #define ACKLOD 0x06
.................... #define XON 0x11
.................... #define XOFF 0x13
....................
.................... unsigned int atoi_b16(char *s);
....................
.................... #ifdef BOOTLOADER_STREAM
.................... #define BootLoaderGetc() fgetc(BOOTLOADER_STREAM)
.................... #define BootLoaderPutc(c) fputc(c, BOOTLOADER_STREAM)
.................... #else
.................... #define BootLoaderGetc() getc()
.................... #define BootLoaderPutc(c) putc(c)
.................... #endif
....................
.................... void real_load_program (void)
*
0014E: BCF 49.1
00150: CLRF 4F
00152: CLRF 4E
.................... {
.................... int1 do_ACKLOD, done=FALSE;
.................... int8 checksum, line_type;
.................... int16 l_addr,h_addr=0;
.................... int32 addr;
.................... #if getenv("FLASH_ERASE_SIZE") != getenv("FLASH_WRITE_SIZE")
.................... int32 next_addr;
.................... #endif
.................... int8 dataidx, i, count;
.................... int8 data[BUFFER_LEN_LOD / 2];
.................... #ifdef BOOTLOADER_MODE2X
.................... int8 buffidx;
.................... #endif
....................
.................... #if defined(__PCM__) && !getenv("ENH16") && (BUFFER_COUNT == 2)
.................... rBuffer[0].buffer = &Buffer1[0];
.................... rBuffer[1].buffer = &Buffer2[0];
.................... #endif
....................
.................... #ifdef BOOTLOADER_MODE2X
.................... buffidx = 0;
....................
.................... while (!done) // Loop until the entire program is downloaded
.................... {
.................... rBuffer[buffidx].idx = 0; // Read into the buffer until 0x0D ('\r') is received or the buffer is full
....................
.................... do {
.................... rBuffer[buffidx].buffer[rBuffer[buffidx].idx] = BootLoaderGetc();
....................
.................... } while ((rBuffer[buffidx].buffer[rBuffer[buffidx].idx++] != 0x0D) && (rBuffer[buffidx].idx <= BUFFER_LEN_LOD));
....................
.................... if(++buffidx >= BUFFER_COUNT)
.................... {
.................... #else
.................... while (!done) // Loop until the entire program is downloaded
00154: BTFSC 49.1
00156: BRA 030E
.................... {
.................... rBuffer[0].idx = 0;
00158: CLRF 06
....................
.................... do {
.................... rBuffer[0].buffer[rBuffer[0].idx] = BootLoaderGetc();
0015A: CLRF 03
0015C: MOVF 06,W
0015E: ADDLW 07
00160: MOVWF FE9
00162: MOVLW 00
00164: ADDWFC 03,W
00166: MOVWF FEA
00168: BTFSS F9E.5
0016A: BRA 0168
0016C: MOVFF FAE,FEF
....................
.................... } while ((rBuffer[0].buffer[rBuffer[0].idx++] != 0x0D) && (rBuffer[0].idx <= BUFFER_LEN_LOD));
00170: MOVF 06,W
00172: INCF 06,F
00174: CLRF 03
00176: ADDLW 07
00178: MOVWF FE9
0017A: MOVLW 00
0017C: ADDWFC 03,W
0017E: MOVWF FEA
00180: MOVF FEF,W
00182: SUBLW 0D
00184: BZ 018C
00186: MOVF 06,W
00188: SUBLW 40
0018A: BC 015A
.................... #endif
....................
.................... BootLoaderPutc(XOFF); // Suspend sender
0018C: MOVLW 13
0018E: RCALL 007C
....................
.................... do_ACKLOD = TRUE;
00190: BSF 49.0
....................
.................... #ifdef BOOTLOADER_MODE2X
.................... if(rBuffer[0].idx != rBuffer[1].idx)
.................... do_ACKLOD = FALSE;
.................... else
.................... {
.................... for(i=0;i<(rBuffer[0].idx-1);i++)
.................... {
.................... if(rBuffer[0].buffer[i] != rBuffer[1].buffer[i])
.................... {
.................... do_ACKLOD = FALSE;
.................... break;
.................... }
.................... }
....................
.................... if(do_ACKLOD)
.................... {
.................... #endif
.................... // Only process data blocks that start with ':'
.................... if (rBuffer[0].buffer[0] == ':')
00192: MOVF 07,W
00194: SUBLW 3A
00196: BTFSS FD8.2
00198: BRA 0300
.................... {
.................... count = atoi_b16 (&rBuffer[0].buffer[1]); // Get the number of bytes from the buffer
0019A: CLRF x7C
0019C: MOVLW 08
0019E: MOVWF x7B
001A0: RCALL 0084
001A2: MOVFF 01,56
....................
.................... // Get the lower 16 bits of address
.................... l_addr = make16(atoi_b16(&rBuffer[0].buffer[3]),atoi_b16(&rBuffer[0].buffer[5]));
001A6: CLRF x7C
001A8: MOVLW 0A
001AA: MOVWF x7B
001AC: RCALL 0084
001AE: MOVFF 01,77
001B2: CLRF x7C
001B4: MOVLW 0C
001B6: MOVWF x7B
001B8: RCALL 0084
001BA: MOVFF 77,4D
001BE: MOVFF 01,4C
....................
.................... line_type = atoi_b16 (&rBuffer[0].buffer[7]);
001C2: CLRF x7C
001C4: MOVLW 0E
001C6: MOVWF x7B
001C8: RCALL 0084
001CA: MOVFF 01,4B
....................
.................... addr = make32(h_addr,l_addr);
001CE: MOVFF 4E,52
001D2: MOVFF 4F,53
001D6: MOVFF 4C,50
001DA: MOVFF 4D,51
....................
.................... #if defined(__PCM__) // PIC16 uses word addresses
.................... addr /= 2;
.................... #endif
....................
.................... checksum = 0; // Sum the bytes to find the check sum value
001DE: CLRF 4A
.................... for (i=1; i<(rBuffer[0].idx-3); i+=2)
001E0: MOVLW 01
001E2: MOVWF 55
001E4: MOVLW 03
001E6: SUBWF 06,W
001E8: SUBWF 55,W
001EA: BC 0214
.................... checksum += atoi_b16 (&rBuffer[0].buffer[i]);
001EC: CLRF 03
001EE: MOVF 55,W
001F0: ADDLW 07
001F2: MOVWF 01
001F4: MOVLW 00
001F6: ADDWFC 03,F
001F8: MOVFF 01,77
001FC: MOVFF 03,78
00200: MOVFF 03,7C
00204: MOVFF 01,7B
00208: RCALL 0084
0020A: MOVF 01,W
0020C: ADDWF 4A,F
0020E: MOVLW 02
00210: ADDWF 55,F
00212: BRA 01E4
.................... checksum = 0xFF - checksum + 1;
00214: MOVLW FF
00216: BSF FD8.0
00218: SUBFWB 4A,W
0021A: ADDLW 01
0021C: MOVWF 4A
....................
.................... if (checksum != atoi_b16 (&rBuffer[0].buffer[rBuffer[0].idx-3])) {
0021E: MOVLW 03
00220: SUBWF 06,W
00222: CLRF 03
00224: ADDLW 07
00226: MOVWF 01
00228: MOVLW 00
0022A: ADDWFC 03,F
0022C: MOVFF 01,77
00230: MOVFF 03,78
00234: MOVFF 03,7C
00238: MOVFF 01,7B
0023C: RCALL 0084
0023E: MOVF 01,W
00240: SUBWF 4A,W
00242: BZ 0248
.................... do_ACKLOD = FALSE;
00244: BCF 49.0
.................... }
00246: BRA 0300
.................... else
.................... {
.................... // If the line type is 1, then data is done being sent
.................... if (line_type == 1)
00248: DECFSZ 4B,W
0024A: BRA 0250
.................... done = TRUE;
0024C: BSF 49.1
0024E: BRA 0300
.................... else if (line_type == 4)
00250: MOVF 4B,W
00252: SUBLW 04
00254: BNZ 0278
.................... h_addr = make16(atoi_b16(&rBuffer[0].buffer[9]), atoi_b16(&rBuffer[0].buffer[11]));
00256: CLRF x7C
00258: MOVLW 10
0025A: MOVWF x7B
0025C: RCALL 0084
0025E: MOVFF 01,77
00262: CLRF x7C
00264: MOVLW 12
00266: MOVWF x7B
00268: RCALL 0084
0026A: MOVFF 01,78
0026E: MOVFF 77,4F
00272: MOVFF 01,4E
00276: BRA 0300
.................... else if (line_type == 0)
00278: MOVF 4B,F
0027A: BNZ 0300
.................... {
.................... if ((addr < LOADER_ADDR || addr > LOADER_END) && addr < getenv("PROGRAM_MEMORY"))
0027C: MOVF 53,F
0027E: BNZ 028A
00280: MOVF 52,F
00282: BNZ 028A
00284: MOVF 51,W
00286: SUBLW 04
00288: BC 0300
0028A: MOVF 53,F
0028C: BNZ 0300
0028E: MOVF 52,W
00290: SUBLW 01
00292: BNC 0300
.................... {
.................... // Loops through all of the data and stores it in data
.................... // The last 2 bytes are the check sum, hence buffidx-3
.................... for (i = 9,dataidx=0; i < rBuffer[0].idx-3; i += 2)
00294: MOVLW 09
00296: MOVWF 55
00298: CLRF 54
0029A: MOVLW 03
0029C: SUBWF 06,W
0029E: SUBWF 55,W
002A0: BC 02E8
.................... data[dataidx++]=atoi_b16(&rBuffer[0].buffer[i]);
002A2: MOVF 54,W
002A4: INCF 54,F
002A6: CLRF 03
002A8: ADDLW 57
002AA: MOVWF 01
002AC: MOVLW 00
002AE: ADDWFC 03,F
002B0: MOVFF 01,77
002B4: MOVFF 03,78
002B8: CLRF 03
002BA: MOVF 55,W
002BC: ADDLW 07
002BE: MOVWF 01
002C0: MOVLW 00
002C2: ADDWFC 03,F
002C4: MOVFF 01,79
002C8: MOVFF 03,7A
002CC: MOVFF 03,7C
002D0: MOVFF 01,7B
002D4: RCALL 0084
002D6: MOVFF 78,FEA
002DA: MOVFF 77,FE9
002DE: MOVFF 01,FEF
....................
.................... #if getenv("FLASH_ERASE_SIZE") > getenv("FLASH_WRITE_SIZE")
.................... if ((addr!=next_addr) && (addr > (next_addr + (getenv("FLASH_ERASE_SIZE") - (next_addr % getenv("FLASH_ERASE_SIZE"))))) && ((addr & (getenv("FLASH_ERASE_SIZE")-1)) != 0))
.................... {
.................... #if defined(__PCH__) && defined(BOOTLOADER_AT_START)
.................... #if ((getenv("PROGRAM_MEMORY") % getenv("FLASH_ERASE_SIZE")) != 0)
.................... if (addr > (getenv("PROGRAM_MEMORY") - (getenv("PROGRAM_MEMORY") % getenv("FLASH_ERASE_SIZE"))))
.................... {
.................... read_program_memory(getenv("PROGRAM_MEMORY"), rBuffer[0].buffer, getenv("FLASH_ERASE_SIZE") - (getenv("PROGRAM_MEMORY") % getenv("FLASH_ERASE_SIZE")));
.................... erase_program_eeprom(addr);
.................... write_program_memory(getenv("PROGRAM_MEMORY"), rBuffer[0].buffer, getenv("FLASH_ERASE_SIZE") - (getenv("PROGRAM_MEMORY") % getenv("FLASH_ERASE_SIZE")));
.................... }
.................... else
.................... #endif
.................... #endif
.................... erase_program_eeprom(addr);
.................... }
.................... #if defined(__PCM__)
.................... next_addr = addr + count/2;
.................... #else
.................... next_addr = addr + count;
.................... #endif
.................... #endif
....................
.................... #if defined(__PCH__) && defined(BOOTLOADER_AT_START)
.................... #if ((getenv("PROGRAM_MEMORY") % getenv("FLASH_ERASE_SIZE")) != 0)
002E2: MOVLW 02
002E4: ADDWF 55,F
002E6: BRA 029A
.................... if (addr == (getenv("PROGRAM_MEMORY") - (getenv("PROGRAM_MEMORY") % getenv("FLASH_ERASE_SIZE"))))
.................... {
.................... read_program_memory(getenv("PROGRAM_MEMORY"), rBuffer[0].buffer, getenv("FLASH_ERASE_SIZE") - (getenv("PROGRAM_MEMORY") % getenv("FLASH_ERASE_SIZE")));
.................... write_program_memory(addr, data, count);
.................... write_program_memory(getenv("PROGRAM_MEMORY"), rBuffer[0].buffer, getenv("FLASH_ERASE_SIZE") - (getenv("PROGRAM_MEMORY") % getenv("FLASH_ERASE_SIZE")));
.................... }
.................... else
.................... #endif
.................... #endif
.................... write_program_memory(addr, data, count);
002E8: MOVFF 52,FF8
002EC: MOVFF 51,FF7
002F0: MOVFF 50,FF6
002F4: CLRF FEA
002F6: MOVLW 57
002F8: MOVWF FE9
002FA: MOVFF 56,77
002FE: BRA 010A
.................... }
.................... }
.................... }
.................... }
.................... #ifdef BOOTLOADER_MODE2X
.................... }
.................... }
....................
.................... buffidx = 0;
.................... #endif
....................
.................... if (do_ACKLOD)
00300: BTFSS 49.0
00302: BRA 0308
.................... BootLoaderPutc(ACKLOD);
00304: MOVLW 06
00306: RCALL 007C
....................
.................... BootLoaderPutc(XON);
00308: MOVLW 11
0030A: RCALL 007C
....................
.................... #ifdef BOOTLOADER_MODE2X
0030C: BRA 0154
.................... }
.................... #endif
.................... }
....................
.................... BootLoaderPutc(ACKLOD);
0030E: MOVLW 06
00310: RCALL 007C
.................... BootLoaderPutc(XON);
00312: MOVLW 11
00314: RCALL 007C
....................
.................... reset_cpu();
00316: RESET
00318: GOTO 031E (RETURN)
.................... }
....................
.................... unsigned int atoi_b16(char *s) { // Convert two hex characters to a int8
*
00084: CLRF x7D
.................... unsigned int result = 0;
.................... int i;
....................
.................... for (i=0; i<2; i++,s++) {
00086: CLRF x7E
00088: MOVF x7E,W
0008A: SUBLW 01
0008C: BNC 00E4
.................... if (*s >= 'A')
0008E: MOVFF 7C,03
00092: MOVFF 7B,FE9
00096: MOVFF 7C,FEA
0009A: MOVF FEF,W
0009C: SUBLW 40
0009E: BC 00C0
.................... result = 16*result + (*s) - 'A' + 10;
000A0: MOVF x7D,W
000A2: MULLW 10
000A4: MOVFF FF3,7F
000A8: MOVFF 7C,03
000AC: MOVFF 7B,FE9
000B0: MOVFF 7C,FEA
000B4: MOVF FEF,W
000B6: ADDWF x7F,W
000B8: ADDLW BF
000BA: ADDLW 0A
000BC: MOVWF x7D
000BE: BRA 00D8
.................... else
.................... result = 16*result + (*s) - '0';
000C0: MOVF x7D,W
000C2: MULLW 10
000C4: MOVFF FF3,7F
000C8: MOVFF 7B,FE9
000CC: MOVFF 7C,FEA
000D0: MOVF FEF,W
000D2: ADDWF x7F,W
000D4: ADDLW D0
000D6: MOVWF x7D
000D8: MOVF x7E,W
000DA: INCF x7E,F
000DC: INCF x7B,F
000DE: BTFSC FD8.2
000E0: INCF x7C,F
000E2: BRA 0088
.................... }
....................
.................... return(result);
000E4: MOVFF 7D,01
000E8: RETURN 0
.................... }
....................
.................... #ifndef BOOTLOADER_AT_START
.................... #ORG default
.................... #ORG LOADER_ADDR, LOADER_ADDR+3
.................... #endif
.................... void load_program(void)
.................... {
.................... real_load_program();
*
0031C: BRA 014E
0031E: GOTO 0396 (RETURN)
.................... }
....................
....................
.................... #define PUSH_BUTTON PIN_E3
.................... #define HEARTBEAT_LED PIN_C2
....................
.................... #if 0
.................... #warning Loader end: LOADER_END
.................... #warning Loader size: LOADER_SIZE
.................... #warning Loader addr: LOADER_ADDR
.................... #warning Program mem: getenv("PROGRAM_MEMORY")
.................... #warning Flash erase size: getenv("FLASH_ERASE_SIZE")
.................... #warning Flash write size: getenv("FLASH_WRITE_SIZE")
.................... #warning Bits per Instr: getenv("BITS_PER_INSTRUCTION")
.................... #warning Count = (getenv("PROGRAM_MEMORY") % getenv("FLASH_ERASE_SIZE"))
.................... #if getenv("PROGRAM_MEMORY") <= 0x10000
.................... #warning Program memory less than 65536
.................... #endif
.................... #endif
....................
.................... #INT_GLOBAL
.................... void isr(void){
.................... jump_to_isr(LOADER_END+9);
*
00008: GOTO 0508
0000C: NOP
0000E: NOP
00010: NOP
00012: NOP
00014: NOP
00016: NOP
00018: GOTO 0518
.................... }
....................
0001C: RETFIE 0
.................... #org LOADER_END+2, LOADER_END+4
.................... void application(void) {
.................... while(TRUE) {
*
00500: BRA 0500
.................... //output_high( HEARTBEAT_LED );
.................... //delay_ms(100);
.................... //output_low( HEARTBEAT_LED );
.................... //delay_ms(100);
.................... }
00502: RETURN 0
.................... }
....................
.................... void main()
*
00322: CLRF FF8
00324: BCF FD0.7
00326: MOVLW 70
00328: MOVWF FD3
0032A: MOVLW 40
0032C: MOVWF F9B
0032E: CLRF F64
00330: BSF F65.3
00332: MOVLW 82
00334: MOVWF FAF
00336: MOVLW 06
00338: MOVWF FD4
0033A: MOVLW A6
0033C: MOVWF FAC
0033E: MOVLW 90
00340: MOVWF FAB
00342: CLRF 48
00344: CLRF 47
00346: MOVLW 00
00348: MOVLB F
0034A: MOVWF x23
0034C: MOVWF x24
0034E: MOVWF x25
00350: BCF FC1.3
00352: BCF FC1.4
00354: BCF FC1.5
00356: MOVLB 1
00358: CLRF x88
0035A: MOVLB F
0035C: CLRF x2E
0035E: CLRF x2F
00360: CLRF x54
.................... {
.................... setup_oscillator( OSC_16MHZ | OSC_PLL_ON ); // Required when using Internal osc. with 4X PLL enabled.
00362: MOVLW 70
00364: MOVWF FD3
00366: MOVLW 40
00368: MOVWF F9B
0036A: CLRF F64
.................... output_low( HEARTBEAT_LED );
0036C: BCF F94.2
0036E: BCF F8B.2
....................
.................... printf("\r\nSerial Bootloader v1.0\r\n");
00370: MOVLW 1E
00372: MOVWF FF6
00374: MOVLW 00
00376: MOVWF FF7
00378: MOVLW 00
0037A: MOVWF FF8
0037C: MOVLB 0
0037E: RCALL 0052
....................
.................... // Enter Bootloader if Pin E3 is low after a RESET
.................... if ( !input(PUSH_BUTTON) )
00380: BSF F96.3
00382: BTFSC F84.3
00384: BRA 0396
.................... {
.................... // Let the user know it is ready to accept a download.
.................... printf("Waiting for download...");
00386: MOVLW 3A
00388: MOVWF FF6
0038A: MOVLW 00
0038C: MOVWF FF7
0038E: MOVLW 00
00390: MOVWF FF8
00392: RCALL 0052
....................
.................... load_program();
00394: BRA 031C
.................... }
....................
.................... application();
00396: RCALL 0500
....................
.................... }
00398: SLEEP
Configuration Fuses:
Word 1: C815 VREGSLEEP INTRC_HP SOSC_DIG NOXINST INTRC_IO NOPLLEN FCMEN IESO
Word 2: 2466 PUT BROWNOUT BORV30 ZPBORM NOWDT WDT512
Word 3: 8901 RTCOSC_T1 CCP2C1 MSSPMSK7 MCLR
Word 4: 0091 STVREN BBSIZ2K NODEBUG
Word 5: C0FF NOPROTECT NOCPB NOCPD
Word 6: E0FF NOWRT NOWRTC NOWRTB NOWRTD
Word 7: 40FF NOEBTR NOEBTRB
|
|
|
|
davidd
Joined: 30 Sep 2010 Posts: 38
|
|
Posted: Fri Jan 29, 2016 10:53 am |
|
|
there are interrupt vectors at 508 and 518 -- sorry about that.
I think what you can do is place a goto in the application(), and place a function after the interrupt vectors
like this:
Code: |
void application(void)
{ goto TEST_LOOP;}
#ORG 0x600
TEST_LOOP:
void blinker(void){
do{
heartbeat_ON;
delay_ms(500);
heartbeat_OFF;
delay_ms(500);
}
while (button_not_pressed);
cpu_reset();
}
| [/code] |
|
|
SeeCwriter
Joined: 18 Nov 2013 Posts: 160
|
|
Posted: Fri Jan 29, 2016 11:54 am |
|
|
No, that doesn't work. I get all kinds of compiler errors.
Code: |
#org LOADER_END+2, LOADER_END+4
void application(void) {
goto TEST_LOOP;
} // <-- Error 88: "Undefined label that was used in a GOTO > TEST_LOOP"
#org 0x600
TEST_LOOP: // <-- Error 43: "Expecting a declaration"
void blink_led()
{ // <-- Error 117: "Improper use of a function identifier"
while( !PROGRAMMING_MODE() ) {
output_high( HEARTBEAT_LED );
delay_ms(200);
output_low( HEARTBEAT_LED );
delay_ms(200);
}
cpu_reset();
}
|
I also tried it with TEST_LOOP inside of blink_led(). Same errors.
I wrapped "goto label" in #asm/#endasm and that removed the error in application(), but added the same
error to the #org statement.
I removed the #org 0x600 statement, and got the same errors as with the #org statement. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
davidd
Joined: 30 Sep 2010 Posts: 38
|
|
Posted: Fri Jan 29, 2016 3:50 pm |
|
|
Does your program run without the bootloader?
Make sure whatever fuses you have set in yourproject.c are either moved to the bootloader or the same in each. With the advice from this forum I put fuses in the bootloader and placed FUSES NONE in the main code.
in regards to application();
maybe try it this way see if it fits.
Code: |
#org LOADER_END+2, LOADER_END+4
void application(void) { blink_led(); }
#org 0x600
void blink_led(void)
{
while( !PROGRAMMING_MODE() ) {
output_high( HEARTBEAT_LED );
delay_ms(200);
output_low( HEARTBEAT_LED );
delay_ms(200);
}
cpu_reset();
} |
|
|
|
SeeCwriter
Joined: 18 Nov 2013 Posts: 160
|
|
Posted: Fri Jan 29, 2016 4:22 pm |
|
|
It turns out it wasn't the bootloader program that was the problem, it was the terminal program,
just as a previous poster mentioned. Both SIOW and MTTTY do not work for downloading files.
With Tera Term, everything worked, even the original program created by the wizard.
CCS should really remove any mention of SIOW.exe in the bootloader examples, since it doesn't work.
I lost several days rewriting a program that worked from the beginning. |
|
|
davidd
Joined: 30 Sep 2010 Posts: 38
|
|
Posted: Fri Jan 29, 2016 4:35 pm |
|
|
I am so glad you got it working!
I had the same issue with CCS_Bootloader.exe hanging half way through. but sometimes it would work and everything worked fine. |
|
|
jeremiah
Joined: 20 Jul 2010 Posts: 1345
|
|
Posted: Sat Jan 30, 2016 8:38 am |
|
|
SeeCwriter wrote: | It turns out it wasn't the bootloader program that was the problem, it was the terminal program,
just as a previous poster mentioned. Both SIOW and MTTTY do not work for downloading files.
With Tera Term, everything worked, even the original program created by the wizard.
CCS should really remove any mention of SIOW.exe in the bootloader examples, since it doesn't work.
I lost several days rewriting a program that worked from the beginning. |
I think one of the major problems here is people don't report this to CCS tech support. I think they make the mistake of thinking this forum is tech support, but it is really just a user forum, so it is hit or miss if the CCS crew actually reads into the details.
I would recommend sending them an email ( [email protected] ), link them this thread and the other threads you saw were people were having the same problem. Maybe they can identify and fix the issue. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|