Close
0%
0%

USB μC - USB PIC Bootloader

USB MSD Bootloader for PIC Microcontrollers

Similar projects worth following
A bootloader for PIC microcontrollers, that makes your USB capable PIC appear to your computer as a thumb drive. Programming can be done through MPLABX or by simply dragging and dropping your Intel hex file onto the drive. No programmer, drivers or software to install.

https://github.com/johnnydrazzi/USB-uC

Currently supports:
- PIC16F1454
- PIC16F1455
- PIC16F1459
- PIC18F14K50
- PIC18F24K50
- PIC18F25K50
- PIC18F45K50
- PIC18F26J53
- PIC18F46J53
- PIC18F27J53
- PIC18F47J53

Features

  • Different crystal options, including NO_XTAL.
  • Drag and drop programming or through MPLABX.
  • Read user flash as a PROG_MEM.BIN file (PIC18 only).
  • Erase user flash by deleting PROG_MEM.BIN (PIC18 only).
  • Read and write to EEPROM through a EEPROM.BIN file (PIC18 only).
  • Erase EEPROM by deleting EEPROM.BIN (PIC18 only).

PIC16F145X v0.03

Bootloader button is connected between RC4 and VDD (RC4 has 10K pull-down). A button is also between MCLR and GND (MCLR has weak internal pull-up). Bootloader/User LED is connected to RC5.

  • 12/16MHz or NO_XTAL crystal options, PLL Software Controlled (PLLEN), INTOSC soft select (SCS).
  • Brownout Reset is software controlled (SBOREN), 2.7V.
  • Watch Dog Timer is software controlled (SWDTEN).

Config Words:

Register:Binary:Hex:
CONFIG1:0b11001011 11001XXX0xCBCX
CONFIG2:0b11011010 110011110xDACF

PIC18F14K50 v0.05

Bootloader button is connected between RC0 and VDD (RC0 has 10K pull-down). A button is also between MCLR and GND (MCLR has 10K pull-up). Bootloader/User LED is connected to RC1.

  • 12MHz Crystal, PLL Software Controlled (PLLEN), INTOSC soft select (SCS).
  • EEPROM initialization via macros are supported.
  • Brownout Reset is software controlled (SBOREN), 2.7V.
  • Watch Dog Timer is software controlled (SWDTEN), 1:256 Postcaler.
  • Bootloader flash space and Config Words space is write protected.

Config Words:

Register:Binary:Hex:
CONFIG1L:0b000000000x00
CONFIG1H:0b001000100x22
CONFIG2L:0b000010100x0A
CONFIG2H:0b000100000x10
CONFIG3H:0b100000000x80
CONFIG4L:0b100000010x81
CONFIG5L:0b000000110x03
CONFIG5H:0b110000000xC0
CONFIG6L:0b000000100x02
CONFIG6H:0b100000000x80
CONFIG7L:0b000000110x03
CONFIG7H:0b010000000x40

PIC18F24K50 v0.06

When using 12/16MHz crystal versions of the bootloader, bootloader button is connected between RB6 and VDD (RB6 has 10K pull-down). A button is also between MCLR and GND (MCLR has 10K pull-up). Bootloader/User LED is connected to RB7.

For the NO_XTAL version, bootloader button is on RA6 and bootloader/User LED on RA7.

  • 12/16MHz or NO_XTAL crystal options, PLL Software Controlled (PLLEN), INTOSC soft select (SCS).
  • EEPROM initialization via macros are supported.
  • Brownout Reset is software controlled (SBOREN), 2.85V.
  • Watch Dog Timer is software controlled (SWDTEN), 1:256 Postcaler.
  • SDO on RB3, T3CKI on RC0, CCP2 on RC1.
  • PORTB pins are digital I/O at powerup.
  • Bootloader flash space and Config Words space is write protected.

Config Words:

Register:Binary:Hex:
CONFIG1L:0b001000000x20
CONFIG1H:0b0000XXXX0x0X
CONFIG2L:0b000000100x02
CONFIG2H:0b001000100x22
CONFIG3H:0b110100010xD1
CONFIG4L:0b100000010x81
CONFIG5L:0b000011110x0F
CONFIG5H:0b110000000xC0
CONFIG6L:0b000011100xE0
CONFIG6H:0b100000000x80
CONFIG7L:0b000011110x0F
CONFIG7H:0b010000000x40

PIC18FX5K50 v0.08

When using 12/16MHz crystal versions of the bootloader, bootloader button is connected between RB6 and VDD (RB6 has 10K pull-down). A button is also between MCLR and GND (MCLR has 10K pull-up). Bootloader/User LED is connected to RB7.

For the NO_XTAL version, bootloader button is on RA6 and bootloader/User LED on RA7.

  • 12/16MHz or NO_XTAL crystal options, PLL Software Controlled (PLLEN), INTOSC soft select (SCS).
  • EEPROM initialization via macros are supported.
  • Brownout...
Read more »

x-zip-compressed - 72.29 kB - 02/15/2019 at 07:00

Download

x-zip-compressed - 72.23 kB - 02/15/2019 at 07:00

Download

x-zip-compressed - 28.78 kB - 02/15/2019 at 07:00

Download

x-zip-compressed - 28.76 kB - 02/15/2019 at 07:00

Download

x-zip-compressed - 26.85 kB - 02/15/2019 at 07:00

Download

View all 6 files

  • Compliance Tests Done

    Johnny6 days ago 0 comments

    New version is up! 

    Even though the previous version worked fine, I wasn't aware that my USB stack and MSC library wasn't passing all USB Ch9 and MSC compliance tests (using USB20CV). Now that my libraries are updated, I decided to update the bootloaders too.

    PS: The PIC16F145X bootloader had 20-35 words to spare with this version! Almost didn't make it.

View project log

  • 1
    Setup Project

    Right click on your MPLABX project, and select Properties. Under XC8 global options, click XC8 linker. In the Option categories dropdown, select Additional options. In the Codeoffset input, you need to put an offset of 0x2000. (For PIC16F145X offset is in words, therefore 0x1000)

    If you are using the a J Series bootloader:

    In the Option categories dropdown, select Memory Model. In the ROM ranges input, you need to put a range starting from the Codeoffset to 1KB from last byte in flash. e.g. For X7J53, 2000-1FBFF is used. This makes sure your code isn't placed in the same Flash Page as the Config Words. That area is write protected.

  • 2
    Download From MPLABX

    You can get MPLABX to download your code every time you press build. To set this up, right click on your MPLABX project, and select Properties. Under Conf: [Default], click Building. Check the Execute this line after build box and place in this line of code (use the drive letter or name of your device depending on OS):

    Windows example: 

    cp ${ImagePath} E:\ 

    Needs a space following "\".

    OSX example:

    cp ${ImagePath} /Volumes/PIC18FX7J53

    Linux example: 

    cp ${ImagePath} /media/PIC18FX7J53
  • 3
    Start Bootloader

    If you have previously loaded a program, reset your device or insert the USB cable, whilst holding down the button. The on-board LED blinks fast 3 times to indicate bootloader mode is active. If no program is present, just insert the USB. Your PIC will now appear in My Computer as a thumb drive.

View all 6 instructions

Enjoy this project?

Share

Discussions

Santiago Jose wrote 02/05/2019 at 16:14 point

Currently I only have one pic for development, if I charge the booloader could I re-record another program in the section that is recorded by the bootloader? I do not want to lose the pic in case of having problems with the bootloader

  Are you sure? yes | no

Johnny wrote 02/05/2019 at 23:00 point

ah, I understand. The write protection bits in the config words just prevent your user code from being able to overwrite the protected areas. You can still write over it again with a programmer. The code protection bits prevent a programmer from reading back your memory contents (stop people from stealing your firmware). When I was first learning about PICs, I made the same assumption.

  Are you sure? yes | no

Santiago Jose wrote 02/01/2019 at 22:41 point

Hello, excellent work ... but I have a question, if I load the .hex in the pic, I could not load a different program because of the write protection?

  Are you sure? yes | no

Johnny wrote 02/05/2019 at 10:25 point

Hey, thanks. The bootloader protects itself and the configuration words when loading your hex file. Just be careful with your user code, that you haven't written code that writes to locations in flash that have the bootloader or config words. Some of the bootloaders have protection from this where possible, but it wasn't possible for all of them.

  Are you sure? yes | no

Santiago Jose wrote 02/05/2019 at 13:33 point

I recently acquired a pic18f24k50 to make tests, Do you have a bootloader without code protection for this pic?

  Are you sure? yes | no

Johnny wrote 02/05/2019 at 15:13 point

Not sure I understand your question. The user space is not write protected. It's a bootloader after all.

  Are you sure? yes | no

Muth wrote 03/21/2018 at 09:31 point

Great news for the 18F14K50, I should test it as I have some of them, just need to find some time :)

  Are you sure? yes | no

Johnny wrote 03/21/2018 at 11:40 point

I look forward to your feedback. The latest version has a EEPROM.BIN file you can open in a hex editor. You can read and modify the EEPROM through that file. I'll update the instructions tonight.

  Are you sure? yes | no

Alex wrote 03/06/2018 at 17:45 point

This looks great! Are there any plans to support more controllers? Or to publish the code, so that others could add additional controller support? 

  Are you sure? yes | no

Johnny wrote 03/06/2018 at 23:16 point

Cheers Alex. I have a few in mind I want to support. PIC18F25/45K50, and PIC16F1455. I have already designed some modules for 25K50 and 1455. I think the J series will be easy to port. I had a go at the 45K50 the other day, with some difficulty. I'll keep trying on 25/45K50, they seem to be popular.

  Are you sure? yes | no

Muth wrote 03/06/2018 at 13:56 point

Very nice ! Will you keep your code closed ? (which I understand perfectly)

  Are you sure? yes | no

Johnny wrote 03/06/2018 at 14:28 point

Thanks Muth. Hopefully it gets used other than just me. I'm still undecided about opening the code.

  Are you sure? yes | no

Jarrett wrote 03/06/2018 at 17:47 point

Yeah, totally your call. :)
If another data point is useful, I would totally retarget this for a different chip - Maybe PIC18F14k50 - If I had the source.

  Are you sure? yes | no

Johnny wrote 03/06/2018 at 23:24 point

I'm working on porting the 45K50 next, that should be similar right?

  Are you sure? yes | no

Jarrett wrote 03/08/2018 at 17:19 point

That'd be cool. That's a good family.

  Are you sure? yes | no

Johnny wrote 03/10/2018 at 08:47 point

X5K50 parts are now supported.

  Are you sure? yes | no

davedarko wrote 03/02/2018 at 08:03 point

So what's the current status, is it working yet?

  Are you sure? yes | no

Johnny wrote 03/02/2018 at 14:41 point

Hey Dave, yeah firmware for X7J53 is working well. Plan on compiling with XC8 Pro some time over the weekend to see how small I can get the bootloader. I'll release the hex after that hopefully.

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates