Bootloader for 18LF25K50

As I promised some weeks ago, I'm sharing with you the bootloader for this pic, adapted to development board I'm working with. There are some highlights on this bootloader:

  • It is based on Microchip Application Libraries, which provides a generic bootloader for 18F devices.
  • In this case I adapted it to avoid using blinking LEDs and be able to distinguish between bootloader mode or normal execution. As you can see in the schematic, I use the RC2 pin to check it.
  • I used free version of C18 compiler and it has no optimization when compiling so the bootloader uses more than 0x1000 memory addresses so I changed all pointers for reset and interruptions. Final flash memory usage uses 0x1102, I'm trying to delete unused code in order to reduce it below 0x1000 to match with the general version.

This is the code I want to remark:

Vectors remapping:

#define REMAPPED_APPLICATION_RESET_VECTOR 0x121E
#define REMAPPED_APPLICATION_HIGH_ISR_VECTOR 0x1208
#define REMAPPED_APPLICATION_LOW_ISR_VECTOR 0x1218
#define BOOTLOADER_ABSOLUTE_ENTRY_ADDRESS 0x001C

Bootloader main code:

//Assuming the I/O pin check entry method is enabled, check the I/O pin value
//to see if we should stay in bootloader mode, or jump to normal applicaiton
//execution mode.

#ifdef ENABLE_IO_PIN_CHECK_BOOTLOADER_ENTRY

//Need to make sure the I/O pin is configured for digital mode so we
//can sense the digital level on the input pin.

mInitSwitch2();
mInitAllSwitches();

//Check Bootload Mode Entry Condition from the I/O pin (ex: place a
//pushbutton and pull up resistor on the pin)

if(sw2 == 1) {
  _asm
    goto REMAPPED_APPLICATION_RESET_VECTOR //If the user is not trying to enter the bootloader, go straight to the main application remapped "reset" vector.
  _endasm

  //If we get to here, the user is not pressing the pushbutton. We
  //should default to jumping into application run mode in this case.
  //Restore default "reset" value of registers we may have modified temporarily.
  //mDeInitSwitch2();

  //Before going to application image however, make sure the image
  //is properly signed and is intact.
  //goto DoFlashSignatureCheck;

} else {
  //User is pressing the pushbutton. We should stay in bootloader mode
  _asm goto BootMain _endasm
}
#endif //#ifdef ENABLE_IO_PIN_CHECK_BOOTLOADER_ENTRY

 

 You have Mplabx project at the bottom of this entry. Feel free to get in contact with me if you have any doubts.

Download Bootloader 28LF25K50

 

MPLAB C18 v3.46 for MAC OS X << |

MPLAB C18 v3.46 for MAC OS X

Next step I will share is a bootloader for 18LF25K50 to avoid the need to use any programmer to put the code on pic flash code memory. Microchip provides some libraries to make it easy with some versions for some microcontrollers to be changed as needed for our selected one. You can find those libraries here.

The Microchip libraries are provided to compile them with MplabC18 compiler and sometimes I work with my laptop running MAC OS X and 18LF25K50 was not supported for previous C18 version for MAC (v3.40). In the way to compile the bootloader on my laptop, I modified the executable compiler and I was able to hack it to work as v3.46.
At the same time I wrote to Microchip to obtain it at last version for MAC OS X. Surprisingly the sent me it 3 days after!! So I decided to share it expecting to be a good resource for you.

Download MPLAB C18 v3.46 for MAC OS X

Supported processors on this compiler:

PIC18C242       PIC18C252       PIC18C442       PIC18C452
PIC18C601       PIC18C658       PIC18C801       PIC18C858

PIC18F1220      PIC18F1230      PIC18F1320      PIC18F1330
PIC18F13K22     PIC18F13K50     PIC18F14K22     PIC18F14K22LIN
PIC18F14K50
PIC18F2220      PIC18F2221      PIC18F2320      PIC18F2321
PIC18F2331      PIC18F23K20     PIC18F23K22     PIC18F2410
PIC18F242       PIC18F2420      PIC18F2423      PIC18F2431
PIC18F2439      PIC18F2450      PIC18F2455      PIC18F2458
PIC18F248       PIC18F2480      PIC18F24J10     PIC18F24J11
PIC18F24J50     PIC18F24K20     PIC18F24K22     PIC18F24K50
PIC18F2510      PIC18F2515      PIC18F252       PIC18F2520
PIC18F2523      PIC18F2525      PIC18F2539      PIC18F2550
PIC18F2553      PIC18F258       PIC18F2580      PIC18F2585
PIC18F25J10     PIC18F25J11     PIC18F25J50     PIC18F25K20
PIC18F25K22     PIC18F25K50     PIC18F25K80
PIC18F2610      PIC18F2620      PIC18F2680      PIC18F2682
PIC18F2685      PIC18F26J11     PIC18F26J13     PIC18F26J50
PIC18F26J53     PIC18F26K20     PIC18F26K22     PIC18F26K80
PIC18F27J13     PIC18F27J53
PIC18F4220      PIC18F4221      PIC18F4320      PIC18F4321
PIC18F4331      PIC18F43K20     PIC18F43K22     PIC18F4410
PIC18F442       PIC18F4420
PIC18F4423      PIC18F4431      PIC18F4439      PIC18F4450
PIC18F4455      PIC18F4458      PIC18F448       PIC18F4480
PIC18F44J10     PIC18F44J11     PIC18F44J50     PIC18F44K20
PIC18F44K22     PIC18F4510      PIC18F4515
PIC18F452       PIC18F4520      PIC18F4523      PIC18F4525
PIC18F4539      PIC18F4550      PIC18F4553      PIC18F458
PIC18F4580      PIC18F4585      PIC18F45J10     PIC18F45J11
PIC18F45J50     PIC18F45K20     PIC18F45K22     PIC18F45K50
PIC18F45K80     PIC18F4610      PIC18F4620
PIC18F4680      PIC18F4682      PIC18F4685      PIC18F46J11
PIC18F46J13     PIC18F46J50     PIC18F46J53     PIC18F46K20
PIC18F46K22     PIC18F46K80     PIC18F47J13     PIC18F47J53
PIC18F6310
PIC18F6390      PIC18F6393      PIC18F63J11     PIC18F63J90
PIC18F6410      PIC18F6490      PIC18F6493      PIC18F64J11
PIC18F64J90     PIC18F6520
PIC18F6525      PIC18F6527      PIC18F6585      PIC18F65J10
PIC18F65J11     PIC18F65J15     PIC18F65J50     PIC18F65J90
PIC18F65J94    PIC18F65K22      PIC18F65K80     PIC18F65K90
PIC18F6620      PIC18F6621      PIC18F6622      PIC18F6627
PIC18F6628      PIC18F6680      PIC18F66J10     PIC18F66J11
PIC18F66J15     PIC18F66J16     PIC18F66J50     PIC18F66J55
PIC18F66J60     PIC18F66J65     PIC18F66J90     PIC18F66J93
PIC18F66J94     PIC18F66J99     PIC18F66K22
PIC18F66K80     PIC18F66K90
PIC18F6720      PIC18F6722      PIC18F6723      PIC18F67J10
PIC18F67J11     PIC18F67J50     PIC18F67J60     PIC18F67J90
PIC18F67J93     PIC18F67J94     PIC18F67K22     PIC18F67K90
PIC18F8310      PIC18F8390      PIC18F8393      PIC18F83J11
PIC18F83J90     PIC18F8410      PIC18F8490
PIC18F8493      PIC18F84J11     PIC18F84J90
PIC18F8520      PIC18F8525      PIC18F8527      PIC18F8585
PIC18F85J10     PIC18F85J11     PIC18F85J15     PIC18F85J50
PIC18F85J90     PIC18F85J94     PIC18F85K22     PIC18F85K90
PIC18F8620
PIC18F8621      PIC18F8622
PIC18F8627      PIC18F8628      PIC18F8680      PIC18F86J10
PIC18F86J11     PIC18F86J15     PIC18F86J16     PIC18F86J50
PIC18F86J55     PIC18F86J60     PIC18F86J65     PIC18F86J72
PIC18F86J90     PIC18F86J93     PIC18F86J94     PIC18F86K22
PIC18F86K90     PIC18F86J99
PIC18F8720      PIC18F8722      PIC18F8723      PIC18F87J10
PIC18F87J11     PIC18F87J50     PIC18F87J60     PIC18F87J72
PIC18F87J90     PIC18F87J93     PIC18F87J94     PIC18F87K22
PIC18F87K90     PIC18F95J94     PIC18F96J60     PIC18F96J65
PIC18F96J94     PIC18F96J99     PIC18F97J60     PIC18F97J94

PIC18LF13K22    PIC18LF13K50    PIC18LF14K22    PIC18LF14K50
PIC18LF23K22    PIC18LF24J10    PIC18LF24J11    PIC18LF24J50
PIC18LF24K22    PIC18LF24K50    PIC18LF25J10
PIC18LF25J11    PIC18LF25J50    PIC18LF25K22    PIC18LF25K50
PIC18LF25K80
PIC18LF26J11    PIC18LF26J13    PIC18LF26J50    PIC18LF26J53
PIC18LF26K22    PIC18LF26K80
PIC18LF27J13    PIC18LF27J53    PIC18LF43K22    PIC18LF44J10
PIC18LF44J11    PIC18LF44J50    PIC18LF44K22    PIC18LF45J10
PIC18LF45J11    PIC18LF45J50
PIC18LF45K22    PIC18LF45K50    PIC18LF45K80    PIC18LF46J11
PIC18LF46J13    PIC18LF46J50    PIC18LF46J53    PIC18LF46K22
PIC18LF45K80    PIC18LF47J13    PIC18LF47J53
PIC18LF65K80    PIC18LF66K80
PICMCV20USB

 

PIC18LF25K50 Configuration Bits << | >> Bootloader for 18LF25K50

Syndicate content