|
|
View previous topic :: View next topic |
Author |
Message |
curt2go
Joined: 21 Nov 2003 Posts: 200
|
18F65K22 Bootloader |
Posted: Mon Mar 05, 2012 1:03 pm |
|
|
I hate to ask but I have looked in search but still am having problems.
I am using the AN1310 bootloader with the CCS files. I can compile the bootloader program and have it compile correct. I even load it on with the IDE and I know its running because I stuck a line in there to turn an LED on. I am using the internal osc but I don't think that makes a difference. When I run the AN1310 it does not recognise that my chip has a bootloader. Any help would be great... I know bootloaders have been beaten to death. I have a very old one that i use on the 8720 for years but need to get into the 21st century with my bootloading.
Here is the code. I have not changed anything in the bootloader.h or the loader.c files.
Code: |
#if defined(__PCM__)
#include <16F877.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7) // Jumpers: 8 to 11, 7 to 12
#elif defined(__PCH__)
#include <18F65K22.h>
#fuses INTRC_IO,NOWDT,NOPROTECT,NOPLLEN ,NOMCLR
#use delay(clock=8000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7,ERRORS) // Jumpers: 8 to 11, 7 to 12
#endif
#define _bootloader
#include <bootloader.h>
#include <loader.c>
#if defined(__PCM__)
#org LOADER_END+1,LOADER_END+10
#elif defined(__PCH__)
#org LOADER_END+2,LOADER_END+20
#endif
void application(void) {
while(TRUE);
}
#if defined(__PCH__)
#org 0x40,0x9F
#else
#org 0x20,0x3F
#endif
void main(void) {
setup_oscillator(OSC_8MHZ);
if(!input(PIN_B1)){
// output_low(pin_e4);
load_program();
}
application();
}
#ORG default
#int_global
void isr(void) {
jump_to_isr(LOADER_END+5*(getenv("BITS_PER_INSTRUCTION")/8));
} |
|
|
|
curt2go
Joined: 21 Nov 2003 Posts: 200
|
|
Posted: Mon Mar 05, 2012 2:03 pm |
|
|
Got it working with SIOW... Any thoughts? TTY |
|
|
RF_Developer
Joined: 07 Feb 2011 Posts: 839
|
|
Posted: Tue Mar 06, 2012 6:39 am |
|
|
The AN1310 bootloader is a high memory loader that needs no change to the application code to work. It does not need any vectors relocated in your code. Simply write it as normal.
In fact the AN1310 PC code does alter the restart vector for you, but that happens transparently as the code is loaded.
Its safer and less hassle all round to run the boot loader with the same fuse settings as your intended application code. In particular attempting to run the app code at different clock settings is bound to fail. If there are software clock related settings - some pics have a software selectable clock source and/or PLL - then you can run the bootloader say on internal clock then change clock settings in code during app code start-up, say with external clock and PLL enabled. You CAN bootload the config bits, i.e. the fuse settings, but this usually ends in bricking you app code. I tried accidentally to bootload debug code... it seemed to work, but as soon as the config bit were written it simply stopped and refused to run (as the debug code wasn't present!). Even iof you do manage to chane the config bits and get the PIC to run OK after, you'll need to reset the bits for the bootloader if you want it to run later, as when you bootload the next version of your code.
I've modified the AN1310 bootloader to work, and work pretty well, as an RS485 (half-duplex) loader. I still have one nasty issue, and yes its to do with the config bits ;-(
Have fun!
RF Developer |
|
|
curt2go
Joined: 21 Nov 2003 Posts: 200
|
|
Posted: Tue Mar 06, 2012 11:51 am |
|
|
Sounds like the SOIW might be the best way. Is there any 3rd party loaders that work? TTY |
|
|
RF_Developer
Joined: 07 Feb 2011 Posts: 839
|
|
Posted: Wed Mar 07, 2012 2:59 am |
|
|
The PC boootloader app supplied by Microchip works well and is meant to be portable, though I've only tested it on Windows 7. Source is supplied as well, which I've used to modify it to be half duplex compatible for use over RS485.
If by "third party" you mean if you can use your boot app of choice then there maybe some out there, but most work with the more common low end PIC bootloaders.
There doesn't seem to be a bootloader communincations protocol standard which would allow the use of any standards compliant app or loader combo. Perhaps there it would be nice if there was, but there isn't and the market is so small as to not make it worthwhile, nor likely of substantial take-up.
As I stated before, your code as presented above is NOT compatible with the AN1310 bootloader as its written for the more common low memory bootloader.
Edit: on checking AN1310 I find it can be configured as a low end bootoader. That doesn't stop the comms compatibility issues however.
Do you understand the problems with your code?
Are you working in low or high end bootloader mode?
Do you have some understanding of the issues of configuration fuses in bootloaded code?
Do you realise that you cannot have one size fits all PIC bootloader code, and that it has to be adjusted for different PICs AND tailored to some extent to the app code it will be expected to load?
As I said before I run AN1310 based bootloader code quite happily and it is indeed a reasonably 21st C solution. Works well once you understand what you need to do.
RF Developer. |
|
|
curt2go
Joined: 21 Nov 2003 Posts: 200
|
|
Posted: Wed Mar 07, 2012 9:28 am |
|
|
1) I have changed the code a bit to work with my chip. As far as I know, everything works fine using the SIOW.
I don't know a ton about bootloading but a general understanding. I have read about the config bits getting screwed up in some instances..Any help would be appreciated. How do you configure AN1310 for low end? |
|
|
|
|
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
|