Close
0%
0%

USB μC

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.02

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.04

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.05

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.07

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...
Read more »

Zip Archive - 25.20 kB - 04/07/2018 at 15:38

Download

Zip Archive - 9.51 kB - 04/07/2018 at 15:38

Download

Zip Archive - 27.20 kB - 04/07/2018 at 15:38

Download

Zip Archive - 27.31 kB - 04/07/2018 at 15:38

Download

Zip Archive - 66.03 kB - 04/07/2018 at 15:38

Download

View all 6 files

  • 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

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