| View previous topic :: View next topic |
| Author |
Message |
SeeCwriter
Joined: 18 Nov 2013 Posts: 179
|
| #use rs232 in Bootloader |
Posted: Wed Jun 10, 2026 12:15 pm |
|
|
Does the #use rs232 setting in the bootloader file need to match the same setting in the main app?
PIC18F67K22, PCWH v5.123. |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 20164
|
|
Posted: Wed Jun 10, 2026 12:40 pm |
|
|
No.
You can change bud rate, format etc.. |
|
 |
SeeCwriter
Joined: 18 Nov 2013 Posts: 179
|
|
Posted: Wed Dec 02, 2026 5:12 pm |
|
|
Still using the 18F67K22, and PCWH v5.125.
I have a bootloader file from another project. It seems to work as expected. I use ccsbootloader.exe (v1.6) to download my app and it appears to finish normally with no errors.
But when I reboot after removing the push_button input, the program doesn't run. I've tried multiple times with the same results.
So I looked at the example bootloader, ex_bootloader.c, and there are some differences from my bootloader, which was a modified version of an example file from an earlier compiler.
The bootloader I'm using has this:
| Code: |
#org LOADER_END+2, LOADER_END+4
void application(void) {
while(TRUE);
}
...
#INT_GLOBAL
void isr( void )
{
jump_to_isr( LOADER_END + 9 );
}
|
While the same code in the current example has:
| Code: |
#org LOADER_END+1,LOADER_END+3
void application(void) {
while(TRUE);
}
...
#int_global
void isr(void) {
jump_to_isr(LOADER_END+5*(getenv("BITS_PER_INSTRUCTION")/8));
}
|
They are both for __PCH__ devices.
I modified my bootloader to match the example loader and my application still doesn't run.
The one other difference is that my loader runs at 19200 baud while the example is 9600. I wouldn't think that would matter.
My app runs fine if I don't use the bootloader. And I do include bootloader.h when building for the bootloader.
Therefore, that suggests that either the bootloader is jumping to wrong location for my app or my app is not at the right location. |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 20164
|
|
Posted: Thu Dec 03, 2026 1:43 am |
|
|
Look at how 'LOADER_END' is defined. It looks as if your loader is
setting this to one lower than the current example boot loader.
The actual placement of these vectors is in the hardware.
It looks like this loader is setting it to the last _word_ address in
the boot loader, not the last byte in the boot loader. |
|
 |
SeeCwriter
Joined: 18 Nov 2013 Posts: 179
|
|
Posted: Thu Dec 03, 2026 9:10 am |
|
|
I added this line to the bootloader:
| Code: |
#warning Loader end: LOADER_END
|
Output:
|
|
 |
SeeCwriter
Joined: 18 Nov 2013 Posts: 179
|
|
Posted: Thu Dec 03, 2026 10:46 am |
|
|
I found example file ex_bootloader.c, dated 2014. This is the application section:
| Code: |
#if defined(__PCM__)
#org LOADER_END+1,LOADER_END+2
#elif defined(__PCH__)
#org LOADER_END+2,LOADER_END+4
#endif
void application(void) {
while(TRUE);
}
|
So this example recognizes there is a difference between PCM and PCH PICs.
The same example from PCHW v5.125 has this:
| Code: |
#org LOADER_END+1,LOADER_END+3
void application(void) {
while(TRUE);
}
|
It doesn't care if PCM or PCH is used.
Can both be correct? |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 20164
|
|
Posted: Thu Dec 03, 2026 11:17 pm |
|
|
I'd have to go and read the manuals carefully. It looks as if the newer
compiler automatically makes the address align to the instruction boundary. |
|
 |
SeeCwriter
Joined: 18 Nov 2013 Posts: 179
|
|
Posted: Fri Dec 04, 2026 9:06 am |
|
|
Examining the loader lst files, shows that all instructions are placed on an even address. For example, the location of application is the same here
| Code: |
.................... #org LOADER_END+1,LOADER_END+3
.................... void application( void )
.................... {
.................... while( TRUE );
*
00500: BRA 0500
00502: RETURN 0
.................... }
|
as it is here
| Code: |
.................... #org LOADER_END+2, LOADER_END+4
.................... void application(void) {
.................... while(TRUE);
*
00500: BRA 0500
00502: RETURN 0
.................... }
....................
|
In both cases the value of LOADER_END is 0x4FF.
So it doesn't matter whether a PCM or PCH PIC used.
I used the Project Wizard to create a new bootloader, and it created the same code as my original bootloader.
Looking at my app's lst file, it is placed at 0x500:
And the jump location is the beginning of main():
| Code: |
....................
.................... void main()
*
03F54: CLRF FF8
|
So I don't understand why it doesn't work. |
|
 |
SeeCwriter
Joined: 18 Nov 2013 Posts: 179
|
|
Posted: Fri Dec 04, 2026 9:54 am |
|
|
My next test was to replace my application with example file ex_bootload.c. I changed it to use the PIC I'm using, then loaded it with the bootloader. It doesn't run either.
| Code: |
#include <18F67K22.h>
#use delay( internal=16MHz )
//#use rs232(icd) //Text through the ICD
#use rs232(baud=19200, xmit=PIN_C6, rcv=PIN_C7) //Text through the UART
//#define BOOTLOADER_MODE2X
#include <bootloader.h>
void main(void)
{
int8 i=0;
delay_ms(100);
printf("\r\nApplication Version 1.0\r\n");
while(TRUE)
{
printf("%3u ",i++);
delay_ms(300);
}
}
|
Perhaps the downloading process is corrupting the code. Not sure how to prove that. |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 20164
|
|
Posted: Fri Dec 04, 2026 12:28 pm |
|
|
On the downloading, it is vital that XON/XOFF flow control is enabled on
the UART port you use. There is no flow control hardware for the
bootloader, and the transmission _must_ stop while the flash memory
is written. |
|
 |
SeeCwriter
Joined: 18 Nov 2013 Posts: 179
|
|
Posted: Fri Dec 04, 2026 12:58 pm |
|
|
If I'm reading the debug file correctly that ccsbootloader.exe produces, XON/XOFF chars are being used.
Example:
| Code: |
0000.015 Dispatch WriteCom 00000014 :0405000013EF03F002[0D]
0000.028 Dispatch ReadCom 00000001 [13]
0000.028 Trigger Avail 00000001
0000.032 Dispatch ReadCom 00000002 [06][11]
0000.032 Trigger Avail 00000002
0000.033 Dispatch WriteCom 0000001C :080508000D0A4170706C69637B[0D]
0000.050 Dispatch ReadCom 00000001 [13]
0000.050 Trigger Avail 00000001
0000.055 Dispatch ReadCom 00000002 [06][11]
0000.055 Trigger Avail 00000002
0000.055 Dispatch WriteCom 0000002C :100510006174696F6E2056657273696F
6E20312E3B[0D]
0000.081 Dispatch ReadCom 00000001 [13]
0000.081 Trigger Avail 00000001
0000.086 Dispatch ReadCom 00000002 [06][11]
0000.086 Trigger Avail 00000002
|
It looks like about 5ms between code downloads. |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 20164
|
|
Posted: Sat Dec 05, 2026 12:34 pm |
|
|
The point is that support for XON/XOFF, _must_ be enabled in the UART
setup on the computer you are using to send this data. A PC Uart by default
does not have support for this enabled. The boot loader sends the characters
but unless the PC handler them transmission will not pause......  |
|
 |
SeeCwriter
Joined: 18 Nov 2013 Posts: 179
|
|
Posted: Sat Dec 05, 2026 12:52 pm |
|
|
Good point. But I would think that since I'm using CCS's ccsbootloader.exe app that it would take care of configuring the PC UART as needed.
In any case, I contacted CCS Tech Support and they are looking into it. I'll let you know what they come up with. |
|
 |
temtronic
Joined: 01 Jul 2010 Posts: 9659 Location: Greensville,Ontario
|
|
Posted: Sat Dec 05, 2026 6:53 pm |
|
|
One thing about 'defaults'... NEVER, ever ASSUME..
Always check and confirm !! |
|
 |
|