USB Bootloader.


Closed Thread
Results 1 to 23 of 23

Thread: USB Bootloader.

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,516

    Default USB Bootloader.

    Hi guys,
    I'm trying to get an USB bootloader going on a 18F4550 on my EasyPIC4 board. As many others starting with this USB-thing I ran into problems.

    I downloaded the bootloader .hex file for 20Mhz crystal from the USB Bitwacker project site, this .hex is supposed to work with '4550 (and I believe it does but more on that later). Then I downloaded the Microchip USB framework 1.3 (MCHPFSUSB_Setup_v1.3.exe)and installed it on my PC. Finally I flashed the PIC with bootloader .hex file using the programmer on board the EasyPIC4 and it's associated software.

    Finally I connected the board to the PC....ding dong.....new device found and it magically installed the driver - really, can it be this easy??

    To get the device into bootload mode you're supposed to pull RC2 low when the device boots, I did that and could then select the board in the PICDEM(TM) FS USB Demo tool application - so far so good. The two status LED's connected to RC0 and RC1 also started to flash sequentially. I wipped up a quick PBP program, compiled it, loaded the .hex file into the PICDEM application and hit Program Device - success! This is why I think that bootlader .hex and chip is (or atleast was) working.

    My program, however, didn't run. I quickly figured out it might be because I forgot to add the DEFINE RESET_ORG 800h and I may have accidently overwritten the bootloader.....and therefor also the config word with the oscillator settings etc.


    Finally to the point. Since that mistake I can NOT get the PC to properly connect to the board. I've reflashed the bootloader several time, I've uninstalled and reinstalled the Microchip drivers and application but every time I connect the USB cable (no matter to which USB port) it does recognise it as a Custom Microchip USB device but it doesn't work. Sometimes I get a message"balloon" saying something like This device does not function properly and it shows there's something wrong with the device in the device manager. The two status LEDs on the board also now blinks together instead of sequentially.

    I've added 0.22uF extra decoupling on VUsb but that didn't help either.

    Is there anybody out there that might have an idea of what's going on here?

    Thanks a lot!
    /Henrik.

    By the way, if I do a search on 'USB' the search engine returns a bunch of threads located in the sub-forum [i]USB[/u] but if I navigate to the USB subforum from there's only three threads showing. What am I missing?

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default

    The only part I might be able to help with is the sub form part. At the bottom on the page there is a box that has from the beginning in it. Make sure that is selected.
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,516

    Default

    Thanks Dave,
    I thought it was weird with only three threads there, never noticed that selection at the bottom before....

    Still messing around with the USB stuff.... I got the 'other' USB bootloader from Microchip working (I believe it is the HID bootloader), well kind of.... I have a simple blink-a-led program that when flashed directly to the PIC works fine but when downloaded thru the bootloader it either doesn't "get there" or it never executes or there's something else going wrong.

    Just ordered my 2.6 upgrade from Mecanique, I hear the USB stuff is easier with 2.6 - although that probably won't help with the bootloader issues. I'll keep playing...

    Thanks!
    /Henrik.

  4. #4
    Join Date
    Oct 2004
    Posts
    448

    Default

    Quote Originally Posted by HenrikOlsson View Post
    Thanks Dave,
    I got the 'other' USB bootloader from Microchip working (I believe it is the HID bootloader), well kind of.... I have a simple blink-a-led program that when flashed directly to the PIC works fine but when downloaded thru the bootloader it either doesn't "get there" or it never executes or there's something else going wrong.

    Thanks!
    /Henrik.
    Absolutely the same problem here, Henrik. Did you make any progress?

    Moreover, I find that all the USB bootloaders at Microchip, by default use a setting of HS Oscillator, PLL enabled, HS used by USB; with this I always get a USB Device Not Recognized; I have to change it to HS Oscillator, HS used by USB to get the pic (18F4455 in my case) to be recognised by the PC. But beyond this point, the loader fails to 'burn' the program in the pic; I have used the DEFINE LOADER_USED 1 and DEFINE RESET_ORG 1000h.

    Wonder what I am doing wrong?

    Incidentally, the test program works despite the 2 defines if I program it directly using a Pickit2. Didnt really expect that to happen?

    Regards,

    Anand

  5. #5
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,516

    Default

    Hi,
    Sorry, no progress, I gave up on it for the time being. Still interested if you or anyone else has or finds a USB bootloader that "just works! though.

    /Henrik.

  6. #6
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530

    Default

    Did you guys see this thread:
    http://www.picbasic.co.uk/forum/show...usb+bootloader

    It talks about skipping over the bootloader code using:
    Code:
    DEFINE LOADER_USED 1
    DEFINE RESET_ORG 1000h ' For Microchip USB Bootloader
    Just wondering if that improves anything? Have yet to try the USB bootloader here though.

  7. #7
    Join Date
    Oct 2004
    Posts
    448

    Default

    First, thanks Scaler for the reference; I had included the 2 defines.

    Now, to sum up my observations; Henrik, these might be of use to you.

    1) A 10uF cap across the Vdd, Vss seems mandatory, regardless of whether you're powering up from the USB, or a separate supply.

    2) The Microchip HID bootloader works all right, although it gives a program/verify error. Once you program your code thru' the bootloader, you need to *re-start* the pic; a reset doesnt help. At this point, when the pic comes up again, your code will start executing happily.

    3) To get back into the booltoad mode, momentarily ground RA6. You're now ready to load another file thru' the bootloader.

    Not perfect, of course, I'd still like to not have the bootloader report the error, but seems to work otherwise.

    At times I feel like just giving in favour of a serial bootloader but the concept of a USB bootloader is too tempting to go away

    If anybody does any further work on this, or wishes to add more, I'd really appreciate it.

    Regards,

    Anand

  8. #8
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530

    Default

    Sorry Anand, missed that you already tried that. I got a chance to try out Microchip HID Bootloader v2.3 this morning on a 18f4550 using the Olimex PIC-USB-STK http://www.olimex.com/dev/pdf/PIC/PIC-USB-STK.pdf

    and I got an LED blinky to work. For this chip, you have to hold down PORTB.4 to get it into bootloader mode. Then I can program and verify correctly. The hex I was using assumes a 12 mhz oscillator, and uses PLL to bring it up to 48.

    Once my blinky program is loaded, I can hit the reset button, and my LED starts to blink.

  9. #9
    Join Date
    Oct 2004
    Posts
    448

    Default

    Quote Originally Posted by scalerobotics View Post
    For this chip, you have to hold down PORTB.4 to get it into bootloader mode. Then I can program and verify correctly. The hex I was using assumes a 12 mhz oscillator, and uses PLL to bring it up to 48.

    Once my blinky program is loaded, I can hit the reset button, and my LED starts to blink.
    Thanks a ton! Wasnt aware of the PORTB.4 switch, works perfect.

    Now, if I can just figure out why I get the error message, despite the code getting programmed alright!

    BTW, what hex file are you using for the bootloader? And, the Olimex schematic shows a 20 MHz crystal (the same as mine); how did you change the hex file to accomodate the 12 MHz?

    Thanks for the help!

    Anand

  10. #10
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530

    Default

    Glad to hear it almost works for you. What error message are you getting? Is it on verification? Are you changing any of the configs for the program you are trying to bootload?

    As far as my crystall, Hmmm....

    My eyes are getting bad.... Will have to check the board again when I get home. I have not changed the crystall, so it is just a matter of whether it matches the schematic. I will attach the hex file I am using tonight as well. But I think it came with Microchips MCHPFSUSB Framework install (79 meg download). I did not modify it, just programmed it directly.

    Walter

    Added:
    Here is some more information about their bootloader. This is included in the large downlaod, but you sort of have to search for it.

    http://www.scalerobotics.com/MCBootloader.html
    Last edited by ScaleRobotics; - 2nd March 2010 at 20:38.

  11. #11
    Join Date
    Oct 2004
    Posts
    448

    Default

    Walter, thanks for directing me to that page. I had done the 78MB download, but without your specific pointer I would never have noticed it.

    Am attaching a screen-grab of the window reporting the error. But for this, its all working precisely the way it is expected.

    Regards,

    Anand
    Attached Images Attached Images  

  12. #12
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530

    Default

    My mistake. I have a 20 mhz crystal (labeled T20.000 but the top of the T is really small ).

    I downloaded and installed the Microchip Application Libraries v2010-02-09, the .hex file is located here: C:\Microchip Solutions\USB Device - Bootloaders\HID - Bootloader

    There are two files named the same name .... exactly the same name ... but they do have different file sizes. They are called "USB Device - HID - HID Bootloader - C18 - PIC18F4550.hex"

    The first one does not seem to contain any configs, but the second one does. Your computer will need to have all the drivers contained in the Microchip Application Libraries to recognize your hardware's USB.

    The two LED's if you have them on PortD.0 and PortD.1, should flash sequentially if the bootloader firmware is running properly and connected to a computer.

    Edit:
    Hey Anand don't know what would be causing that ... mine doesn't give me a verify error. You would think that if it can program it, it could verify it....
    Attached Images Attached Images  
    Last edited by ScaleRobotics; - 3rd March 2010 at 06:43.

  13. #13
    Join Date
    Oct 2004
    Posts
    448

    Default

    Success at last!

    Walter, I have to thank you for this.

    BTW, the 2 files are not quite the same; the names do look identical, but then I noticed the first one was for 18F4450 and the second for 18F4550. In fact that gave me a clue; my device was a 18F4455, and I was using the firmware for 18F4550. Works, but gives the error I kept referring to.

    Swapping in an 18F4550 completely solved all problems.

    So, on to the next task. Once I figure out how to generate a hex file for the 18F4455, I'd be a truly happy camper.

    Will update this thread soon as I do the above!

    Thanks again,

    Anand

  14. #14
    Join Date
    Jul 2003
    Posts
    2,405

    Default

    Hi Anand,

    See if the attached works on your 18F4455. I've include default config settings, and a note
    on switching between load/run modes, interrupts, etc in the text file.
    Attached Files Attached Files
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  15. #15
    Join Date
    Oct 2004
    Posts
    448

    Default

    Bingo!

    Bruce, it worked flawlessly.

    How exactly did you generate it?

    Thanks a lot, that was the last obstacle that you removed!

    Anand

  16. #16
    Join Date
    Jul 2003
    Posts
    2,405

    Default

    Hi Anand,

    I compiled the original loader for your 18F4455. If you have C18, and want to change it yourself, here's how;

    1. Open the project in MPLAB.
    2. Remove the 18F4550 linker.
    3. Add the 18F4455 linker. (be sure to use the modified versions in the same folder)
    4. Select the 18F4455 under Configure > Select Device (almost forgot this one)
    5. Include the 18F4455 in the section shown below in main.c.

    Original looks like this;
    Code:
    #if defined(PIC18F4550_PICDEM_FS_USB)		// Configuration bits for PICDEM FS USB Demo Board
     	#if defined(__18F4550) || defined(__18F4553)
    Change it to;
    Code:
    #if defined(PIC18F4550_PICDEM_FS_USB)		// Configuration bits for PICDEM FS USB Demo Board
     	#if defined(__18F4550) || defined(__18F4553) || defined(__18F4455)
    Then compile. This forces it to use the config options below the #if defined section, and you definitely need the 18F4455 linker due to the difference in codespace.
    Last edited by Bruce; - 3rd March 2010 at 18:37. Reason: Select the 18F4455 under Configure > Select Device
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  17. #17
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,516

    Default

    Guys,
    I haven't had time to play any more with this and it will have to wait a little longer still. However, I'd like to take the oportunity to thank all of you for the last couple of days worth of posts in this thread!

    /Henrik.

  18. #18
    Join Date
    Oct 2004
    Posts
    448

    Default

    Bruce, thanks for the procedure to create new .hex bootload files. Do I understand the situation right, that one necessarily requires the C18 compiler to do this?

    And, I second Henrik's statement, thank you to all who helped.

    Regards,

    Anand

  19. #19
    Join Date
    Jul 2003
    Posts
    2,405

    Default

    Hi Anand,

    Yes. You will need the C18 compiler to make changes.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  20. #20
    Join Date
    Dec 2011
    Posts
    2

    Default Re: USB Bootloader.

    Yes, yes, this is an old thread but it is not an old topic. I have spun my mouse so much trying to get a HID bootloader working that I have worn my desktop. I have banged my head on things such as trying to refresh my copy of the 4550 firmware in the MCHPUSB BOOTLOADER\BOOTLOADER-Firmware for Pic18f4550 because my current firmware is screwed up from earlier editing. I have other concerns also such as dealing with interrupt addresses, changing the clock to agree with what I am using. Tired.

    Three feathers and a glass of milk to you folks who were successful with this dog. I might come back to this later....maybe! In place of this bootloader where it appears I will spend many more hours trying to get the thing to run, I just emptied two bucks from my wallet and placed an order on Ebay for a USB-RS232 adapter. Will it work? For two bucks I think it is worth a try.

    But getting back to this thread, I seriously compliment those who cracked this thing, I have a great deal more learning to do, just not enough time or desire to do it. But got to keep the faith..........in Microchip!

    Foggy

  21. #21
    Join Date
    Dec 2012
    Posts
    2

    Default Re: USB Bootloader.

    Hii every one ,i want quick reply please help me, i am performing a project where i connect VDIP1 with PIC 18F458 ,on PIC 18F458 i also connect LCD and keypad. I only like to read file from usb and want to display it on LCD.Any one give me an efficient code to full fill my requirement

  22. #22
    Join Date
    Oct 2011
    Posts
    54

    Default Re: USB Bootloader.

    Hi Foggy
    If you still want a USB bootloader that works with PBP then try this one.
    If I can get it to work then you should also. Get it here:-

    http://digital-diy.com/pic-micrcontr...otloaders.html

    Example program - **** DO NOT INCLUDE the line 'DEFINE LOADER USED 1' ****


    DEFINE OSC 48
    DEFINE RESET_ORG 0F00h 'Load code at 0F00h

    RED_LED VAR PORTC.0
    YELLOW_LED VAR PORTC.1
    GREEN_LED VAR PORTC.2

    START:
    HIGH RED_LED
    PAUSE 500
    LOW RED_LED
    HIGH YELLOW_LED
    PAUSE 500
    LOW YELLOW_LED
    HIGH GREEN_LED
    PAUSE 500
    LOW GREEN_LED
    GOTO START:


    Compile and then load the hex file produced into the PIC with the bootloader.
    Reset the PIC by taking MCLR pin low and the LEDs should blink
    Reset the PIC again by taking MCLR low and you should be back in bootloader mode. No need to hold PORTB.4 low as with the Microchip bootloader. Don't forget pull-up on MCLR.

    A few conclusions reached mainly by trial and error.
    1 - DEFINE LOADER_USED 1
    This is not required. As far as I can tell all it does is tell the compiler to load the hex file using Microcode Loader when "Compile/Program" is clicked and puts a jump to where the Microcode loader is in the PIC memory which we do not want.
    2 - DEFINE RESET_ORG 0F00h
    This IS required as it sets the memory address where the program will be loaded.
    3 - The bootloader software is best flashed to a BLANK PIC. It may take 2 or 3 erase cycles before the PIC is blank.
    4 - When flashing the PIC with PICKit programmer, click on "Tools" then "Enable code protect". This seems (so far) to prevent the bootloader from being accidentally over written.
    5 - Tested with Windows XP, PBP 2.6, PIC 18F2550 20mHz Xtal
    I have no other suitable PICs to test at the moment.

    I have tried it with a few short programs and so far it has worked 100%

    Phil

  23. #23
    Join Date
    Dec 2011
    Posts
    2

    Default Re: USB Bootloader.

    Quote Originally Posted by Sherbrook View Post
    Hi Foggy
    If you still want a USB bootloader that works with PBP then try this one.
    If I can get it to work then you should also. Get it here:-

    http://digital-diy.com/pic-micrcontr...otloaders.html

    Example program - **** DO NOT INCLUDE the line 'DEFINE LOADER USED 1' ****


    DEFINE OSC 48
    DEFINE RESET_ORG 0F00h 'Load code at 0F00h

    RED_LED VAR PORTC.0
    YELLOW_LED VAR PORTC.1
    GREEN_LED VAR PORTC.2

    START:
    HIGH RED_LED
    PAUSE 500
    LOW RED_LED
    HIGH YELLOW_LED
    PAUSE 500
    LOW YELLOW_LED
    HIGH GREEN_LED
    PAUSE 500
    LOW GREEN_LED
    GOTO START:


    Compile and then load the hex file produced into the PIC with the bootloader.
    Reset the PIC by taking MCLR pin low and the LEDs should blink
    Reset the PIC again by taking MCLR low and you should be back in bootloader mode. No need to hold PORTB.4 low as with the Microchip bootloader. Don't forget pull-up on MCLR.

    A few conclusions reached mainly by trial and error.
    1 - DEFINE LOADER_USED 1
    This is not required. As far as I can tell all it does is tell the compiler to load the hex file using Microcode Loader when "Compile/Program" is clicked and puts a jump to where the Microcode loader is in the PIC memory which we do not want.
    2 - DEFINE RESET_ORG 0F00h
    This IS required as it sets the memory address where the program will be loaded.
    3 - The bootloader software is best flashed to a BLANK PIC. It may take 2 or 3 erase cycles before the PIC is blank.
    4 - When flashing the PIC with PICKit programmer, click on "Tools" then "Enable code protect". This seems (so far) to prevent the bootloader from being accidentally over written.
    5 - Tested with Windows XP, PBP 2.6, PIC 18F2550 20mHz Xtal
    I have no other suitable PICs to test at the moment.

    I have tried it with a few short programs and so far it has worked 100%

    Phil
    Phil-- Thanks for taking time to respond to my earlier post!!! As I type, I have both versions, HID & MCHPUSB bootloaders working. The particular one that I am using for no real good reason is the MCHPUSB bootloader. Getting one of these to work can be veeeery tiring if you have not done so to begin with. Some of my problems included the oscillator selection for my "main" because the USB requires either 48 or 20 MHz. After that burden was resolved with the MCHUSB, I had to change the 18F4550 linker code.

    Another thing that pi$$ed me with the HID loader was I read that the bootloader screen would just pop up from the ether once the loader was properly configured. Now granted I might have missed something that directed one to fetch the program screen from Microchip Solutions. For my use at least with C18 I can get by with the the MCHPUSB loader. And of course, Michrochip has now introduced a newer, better, improved more better....eh, make that MUCH better compiler. I spoke to one of their technical gals last January about replacing my full version of C18. I was told that I am eligible for the upgrade....but don't do it now!

    I will say that using the USB loader it gives me greater desk real estate without having to use the programmer.

    Thanks again--

    Foggy
    Last edited by foggysail; - 2nd May 2013 at 03:49.

Similar Threads

  1. Simple USB Comms Problem
    By awmt102 in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 6th January 2010, 21:17
  2. Replies: 7
    Last Post: - 10th November 2008, 10:24
  3. USB Bootloader CRASH on Vista
    By mindthomas in forum USB
    Replies: 9
    Last Post: - 9th March 2008, 21:56
  4. 18F2550 MCRL/RE3 problem with USB bootloader Microchip
    By Ronald123 in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 24th September 2007, 11:48
  5. BootLoader with USB to Serial Convertors
    By mike101video in forum General
    Replies: 6
    Last Post: - 10th January 2006, 17:48

Members who have read this thread : 2

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts