Why use a bootloader?


Closed Thread
Page 1 of 2 12 LastLast
Results 1 to 40 of 41
  1. #1
    Join Date
    Jan 2008
    Location
    Sweden
    Posts
    187

    Default Why use a bootloader?

    Whatīs the point as a hobby PIC programmer to use a bootloader if you have a programmer?

    You can program the PIC witout a programmer but you still need a USB/Serial interface to a PC, right?

  2. #2
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    Sometimes you need to update the software on chips soldered to the PCB. Without a bootloader, this could be a real problem.

    If you can remove the pic from the circuit, well you can do it with the programmer, But with the bootloader you don't need to remove the chip and this is an additional plus.

    Al.
    Last edited by aratti; - 24th January 2009 at 22:55.
    All progress began with an idea

  3. #3
    Join Date
    Jan 2008
    Location
    Sweden
    Posts
    187


    Did you find this post helpful? Yes | No

    Default

    You could use ICSP if you want to update the software on a PIC on a PCB

  4. #4
    Join Date
    Sep 2007
    Location
    USA, CA
    Posts
    271


    Did you find this post helpful? Yes | No

    Default

    First, bootloaders are faster than a programmer. Second, ICSP takes up more pins (3), and limits the hardware to the pins. A bootloader only takes two serial pins, and if you already have a serial connection, requires no special treatment. Third, if you have the board in an enclosure, it is safer to have a serial connection to the outside world than your mclr pin.

    In reality, from a hobbyist standpoint, it doesn't make a big difference. It is convenient, however.

  5. #5
    Join Date
    Mar 2006
    Location
    China
    Posts
    266


    Did you find this post helpful? Yes | No

    Default Because

    Because a bootloader will save tons of money when then enduser can correct the major bugs in the software just by using a serial cable and downloading the patch from internet :-)

    In true errata Microchip style...

  6. #6
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

    Default

    Note that a bootloader (normaly) cannot lock your code on the PIC. So for commercial usage this is a minus.

    Ioannis

  7. #7
    Join Date
    Mar 2006
    Location
    China
    Posts
    266


    Did you find this post helpful? Yes | No

    Default Sure it can

    Any bootloader can program the pic even if code protection is turned on... it is just access to the code area with a programmer that code protection protects from. Not from inside the PIC.

    BUT since you download the HEX file from internet it better be a loader with encryption or the code is public anyway :-)

  8. #8
    Join Date
    Jan 2008
    Location
    Sweden
    Posts
    187


    Did you find this post helpful? Yes | No

    Default

    Ok..

    Where do i start if i want to use a bootloader?

    I have a PCB with a FTDI232BM chip that convert USB <--> RS232 signals and the PIC is a 18F2550, will it work to program via the FTDI chip or do i have to have a real USB connection?

    Where can i download a bootloader for the PIC and a PC software to program the PIC?

  9. #9
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    If you're using a USB PIC, you may want to use Microchip's Bootloader. (this one use the USB port) OR PICCoder

    If you have MicroCode Studio plus, you already have bootloader firmware in... unless you have to purchase MicroCode Loader.(this one use RS-232 port)

    Other option, is to find a freeware, I heard good comment on Tiny Bootloader.(also RS-232)

    Once you have any bootloader firmware, you need to dump the firmware .HEX file in your PIC first by using your favourite PIC programmer.

    Once it's done, you just need to compile your code and use your bootloader utility to update your PIC.

    That's it!

    EDIT: See difference from one bootloader to another... DEFINE LOADER_USED 1 have to be used.
    Last edited by mister_e; - 30th January 2009 at 00:18.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  10. #10
    Join Date
    Jan 2008
    Location
    Sweden
    Posts
    187


    Did you find this post helpful? Yes | No

    Thumbs up

    Well that was easy.... Tiny Bootloader worked on the first try....
    The loading time with Tiny bootloader is much faster then the PICkit2 programmer..

  11. #11
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    hum, interesting to know. Thanks for your feedback.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  12. #12
    Join Date
    Jan 2008
    Location
    Sweden
    Posts
    187


    Did you find this post helpful? Yes | No

    Default

    Hmm i have now also try Microcode studio plus loader and that doesīt work good..

    I have loaded the right HEX file with my PICkit2 programmer and then when i try to "Compile and program" i get the message "Please reset the target microcontroller" and when i do that with the MCLR pin nothings happends... then i klick on the close button in the right corner of the window and now microcode loader starts to program the PIC, but i have to try severel times before the PIC works after the programming from the microloader.

  13. #13
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    It will work all the time if you use their schematic as it add a connection to MCLR and you'll not need to do it yourself... hence why I'd modified my EasyPIC 4 board in the past.

    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  14. #14
    Join Date
    Jan 2008
    Location
    Sweden
    Posts
    187


    Did you find this post helpful? Yes | No

    Default

    But it should work to reset it manualy.

    And when using microloader the programming time is slow.. my small testprogram takes about 6 secounds whit microloader and with Tiny Bootloader it takes "0.249 sec"...

  15. #15
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Yup, but MicroCode do more check than Tiny... this is why Microcode firmware is 'round 2.5 time bigger than Tiny.

    Sometimes there's a price to pay if you want reliability or speed
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  16. #16
    Join Date
    Jan 2008
    Location
    Sweden
    Posts
    187


    Did you find this post helpful? Yes | No

    Default

    Yes thatīs true.

    But with microcode and manual reset i have to program the PIC severel times whit the same program before the PIC starts...

    So i think something is wrong.

    I will do some more tests and then give you some feedback here.

  17. #17
    Join Date
    Jan 2008
    Location
    Sweden
    Posts
    187


    Did you find this post helpful? Yes | No

    Default

    Why do you sometimes have the define
    DEFINE BOOTLOADER_USED 1

    Tiny bootloader works with and without this define so i wonder what does the define do?

  18. #18
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    in fact it has to be
    Code:
    DEFINE LOADER_USED 1
    What it does? From memory, It reserved the first 4 code location for the bootloader (1-2 nop and a GOTO to the bootloader code (at the end of the code space))

    Why it works with Tiny... can't tell, maybe he correct the .hex file for you... but as it's a small program, you're not experimenting issue just yet.

    Keep the DEFINE LOADER_USED 1 at the top.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  19. #19
    Join Date
    Jan 2008
    Location
    Sweden
    Posts
    187


    Did you find this post helpful? Yes | No

    Default

    Yes, thats why i trying to get the Microloader to work..

    another question
    Will a "software reset" work to get into the "bootloader mode"?

    http://www.picbasic.co.uk/forum/showthread.php?t=899
    Code:
    Asm
    bcf PCLATH, 3
    bcf PCLATH, 4
    goto 0
    EndAsm
    or has it to be a real MCLR reset?

  20. #20
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    As you're using a 18F
    Code:
    @    RESET
    should do. bootloader mode get out pretty fast of there, not like Tiny (which I can recall something like ~1 Sec before getting out)
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  21. #21
    Join Date
    Jan 2008
    Location
    Sweden
    Posts
    187


    Did you find this post helpful? Yes | No

    Default

    Hmm... why doesīt microloader work...

    When i press the program button the message "Please restet the PIC in order to access bootloader process"

    I press the reset button on the PCB (MCLR) and nothing happens..... i have to close the message window then the programming starts. is that normal?

    Shouldīt the programming starts when i press the MCLR button?

  22. #22
    Join Date
    Jan 2008
    Location
    Sweden
    Posts
    187


    Did you find this post helpful? Yes | No

    Default

    Another thing with Microloader and Microcode studio plus is the way i have to set the COM port.

    (I use a virutuel COM port, not a real one.)

    If i run only the Microcode loader i canīt set the COM port at all, the dropdownlist is empty and "gray". if i run Microcode studio i can set the COM port via the ICD toolbar but when i use my PIC18F2550 i canīt so to set the right COM port i have to change the device to 16F628A and then change the COM port and then change the device back to 18F2550.

  23. #23
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default

    Hi Fredrick,
    The best way to do it is to add the connection to MCLR as per Steves previous message. It is rock-solid, I've been using ot for years. If you don't want to do that try holding down the Reset-button, click compile and program and when the program window pops up quickly release the reset-button.

    The virtual COM port MIGHT be a problem, I've never had any problems personally but I've read about bad drivers and strange chip-sets in some of the cheap USB<->RS232 dongles.

  24. #24
    Join Date
    Jan 2008
    Location
    Sweden
    Posts
    187


    Did you find this post helpful? Yes | No

    Default

    This is the way my hardware looks like


    So i think that i just have to sold a wire from DTR pin from the FTDI chip to MCLR pin on the PIC with a 100ohm resistor in serie to get the software reset in microloader to work, right?

  25. #25
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    In theory yes it has to work. Now the small timing issue you may have is the latency of the USB to serial converter. But I do remember to have successfully used some in the past.

    Finger crossed.

    One thing I would suggest to be really careful about is if you use ICSP later... MCLR have to go somewhere 'round 13Volts... not sure if your converter will like it... As Mackrackit says... "Always wear safety glasses while programming. "
    Last edited by mister_e; - 31st January 2009 at 20:29.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  26. #26
    Join Date
    Jan 2008
    Location
    Sweden
    Posts
    187


    Did you find this post helpful? Yes | No

    Default

    Now i have a jumper from MCLR to the FTDI DTR pin via 100Ohms resistor and now the Microcode Loader works whitout any problems but the programming time is very slow about 10 sec for a 994 byts program, is there any way to speed that up?

    But Microloader has a bug, if your computer doesīt have any real serial ports you will not be available to change the COM port becouse the dropdownlist is locked and empty, however if you connect only one USB<-->Seriel cabel and then start the loader program the right com port will be selected and it workīs but the dropdownlist will still show "None" COM ports.

    If you have a computer with a real serial port you will se both the real one and the virituel port in the dropdownlist.

    And whitin MicroCode studio plus you will not be available to select the com port unless you change the device to a ICD compatibel PIC and then change the port and back to the PIC you are useing (in my case 18F2550.)

    My Microcode Studio Version is 3.0.0.5

  27. #27
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Did you tried by changing the port and baudrate speed in the Mcloader application?

    As far as i'm aware of, it set the baudrate to 9600, should work faster with higher speed OSC. It's been a long time I used a bootloader though
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  28. #28
    Join Date
    Jan 2008
    Location
    Sweden
    Posts
    187


    Did you find this post helpful? Yes | No

    Default

    I have set it to the maximun speed 115200, the standard value was 19200.
    And yes itīs a bit faster now and it still works ok, no programming errors.

    Is the author of Microcode Studio on this forum?
    Mayby he can release a bugfix for the COM port issue.

  29. #29
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Well it's not a com port issue, it's not even an issue, it's a hidden feature, and it's probably like that for reliability rather than for speed

    If you want to speed up a bit the process, you may uncheck some Verify options in MicroCode Loader option.

    This said, the COM setting in MCSP is for ICD, not bootloader.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  30. #30
    Join Date
    Jan 2008
    Location
    Sweden
    Posts
    187


    Did you find this post helpful? Yes | No

    Default

    Yes, but I mean the issue with selecting the COM port in the loader app.

    and in the help file for MCSP it says

    Using the Loader with MicroCode Studio Plus

    Connect a serial cable between your computer and development board. Apply power to the board.
    From the ICD toolbar, select the serial port you will be using to communicate with the development board.
    i canīt select any COM port there becous itīs locked, until i select an ICD compatibel PIC then i can change the port and then i have to change back to the PIC Iīm using.

  31. #31
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Ah, I see, well let's forget the help file then

    Not sure how bad some Virtual Port could be, but It may cause some problem with some Chipset/Driver combination.

    Real serial port have their place, but agreed, not a big majority release serial product now... Even some PCI (or whatever else PC slot) are just silly priced now.
    Last edited by mister_e; - 1st February 2009 at 20:12.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  32. #32
    Join Date
    Jan 2008
    Location
    Sweden
    Posts
    187


    Did you find this post helpful? Yes | No

    Default

    Yea...
    Microcode studio plus is still the best editor for PBP that i know about.
    Is there anyone here that are using a better editor?

  33. #33
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Define the word better and we may come up with some idea.

    MPLAB is fine, but you don't have serial com port access, no plug-in facility either.

    PsPad, nice code editor, but no PBP syntax embedded in

    CodeDesigner was great a while back, no longer supported, no serial communication utility, no plug-in facility either.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  34. #34
    Join Date
    Jan 2008
    Location
    Sweden
    Posts
    187


    Did you find this post helpful? Yes | No

    Default

    I use PsPad as the default editor in windows, i like that editor, i have used Codedesigner in the past for PBP but switched to MCS and later to MCSP , MPLAB has so many functions that I donīt use there are just there to confuse me.

    Microcode studio is simple to use without extra functions i donīt use and have a nice and clean interface with PBP syntax.

  35. #35
    Join Date
    Jan 2005
    Location
    France
    Posts
    97


    Did you find this post helpful? Yes | No

    Default MCloader question

    I got a board with a 16F874 and a Max 232 on board
    (TX data and RX data goes to the normal PIC pins RC6 and RC7)

    16F874 (20 Mhz) is OK (tested with a Blink program !)

    SO, I try to use MCloader (version 1.0.1.7)
    I burn bootloader file to the 16F874
    I use my blink (Pic Basic pro 2.60) with the define user command
    compilation ...
    start MCloader ... reset MCLR .. nothing append .. still the message on MCloader about waiting a reset !
    question :
    is the DTR signal is used to reset the pic via the MAX232 and the 100 ohm resistor
    is it used with the "software reset" option I see in MCloader setup

    Can I use bootloader without this software reset option (I have just a push button on MCLR) ?
    thanks.
    Francois F1CHF

  36. #36
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default Re: Why use a bootloader?

    Hi,
    Yes, the DTR signal is used to remotely reset the PIC but you can easily use it without that feature, I do that all the time on one of my developement boards from SURE electronics. I hit Program and it asks me to reset the device - which I do - and it downloads the code to the device.

    When it doesn't work it's usually because I've specified the wrong COM-port which happens to me from time to time, especially when using USB->COM dongles/adapters.

    It's important that you flash the PIC with bootloader.hex file for the correct oscillator speed (20MHz in your case) and that you put DEFINE LOADER_USED 1 in your program.

    /Henrik.

  37. #37
    Join Date
    Jan 2005
    Location
    France
    Posts
    97


    Did you find this post helpful? Yes | No

    Default Re: Why use a bootloader?

    OK Henrick
    Thanks for your reply
    I use a laptop with one COM port (and in MCloader there is no more choice than COM1)
    this COM1 is working with my serial programmer
    It is important that you said ...

    TX and RX lines (via MAX232) goes to RC6 and RC7
    good bootloader file burned in the pic (16F874_20.hex from MCloader directory)
    compilation (using PBP v 2.6) using good define user line (this program "blink" was tested and PIC is OK)
    power on the PIC
    start MCloader .. load hex file ... push program icon .... depress RESET button on PIC board

    download should works beetween the laptop and te PIC ...

    am I right ?

  38. #38
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default Re: Why use a bootloader?

    Hello,
    Yes, when you press Program there should pop up two messages/windows, first one with a progress bar that says Programming and then, when it can't reset the PIC, a second one saying Please reset target microcontroller in order to access the bootloader process... When you reset the PIC the second window will close and you can monitor the progress in the first window, it only takes a couple of seconds depending on the size of the program.

    Have you verified that the serial communication is working, ie by using HSEROUT/HSERIN to send and receive data. Perhaps you've mixed up the RX/TX lines?

    /Henrik.

  39. #39
    Join Date
    Jan 2005
    Location
    France
    Posts
    97


    Did you find this post helpful? Yes | No

    Default Re: Why use a bootloader?

    Same player shout again
    I am still in the same marmelade !
    I have checked the hardware RX TX max232 seems good (no mix)
    I will try to test as you said (transmit between PIC and laptop)
    I suspect also that my programmer is not wonderfull
    I must program sometimes 5 times to avoid errors
    I must compare iniatial file from MCloader (16F874_20.hex) with the data burned in the pic !
    I have tried with two differents PIC

    for this week I will be out for 3 days, so, hold the line !
    I lost already 3 days on this crazy thing, no problem because I am retired ! hi ...
    Francois

  40. #40
    Join Date
    Jan 2005
    Location
    France
    Posts
    97


    Did you find this post helpful? Yes | No

    Default Re: Why use a bootloader?

    Still me, with the same problem
    I spent one day without success !
    abstract : I got garbage using Hserout (to test my RS232 line for bootloader function)
    see my terminal V1.9 log file (hexa dump and ascii dump)
    question :
    What is wrong in my design ?
    I have tested in XT and HS clock mode
    I have changed the MAX232
    LCD and Blink led seems normal (pic is alive !)
    I am lost !
    Thnaks in advance
    Francois

    the program test is the following :
    ' Using PIC 16F874 @ 20MHZ
    '
    DEFINE OSC 20
    ' Set LCD Data port
    DEFINE LCD_DREG PORTD
    ' Set starting Data bit (0 or 4) if 4-bit bus
    DEFINE LCD_DBIT 4
    ' Set LCD Register Select port
    DEFINE LCD_RSREG PORTD
    ' Set LCD Register Select bit
    DEFINE LCD_RSBIT 2
    ' Set LCD Enable port
    DEFINE LCD_EREG PORTD
    ' Set LCD Enable bit
    DEFINE LCD_EBIT 3
    ' Set LCD bus size (4 or 8 bits)
    DEFINE LCD_BITS 4
    ' Set number of lines on LCD
    DEFINE LCD_LINES 2

    ' Hardware configuration
    ' ======================
    TRISC = %10000000 ' PORTC.7 is the RX input
    ' PORTC.6 is the TX output

    ' Serial communication definition
    ' ===============================
    ' Using internal USART and MAX232 to interface to PC

    DEFINE HSER_RCSTA 90h ' enable serial port, enable continuous receive
    DEFINE HSER_TXSTA 20h ' enable transmit, BRGH=1
    DEFINE HSER_SPBRG 129 ' 2400 Baud @ 20MHz, 0,17%
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically

    Pause 500

    start:
    high portd.1
    pause 100
    low portd.1

    lcdout $FE ,1,"test"
    pause 500
    lcdout $FE ,1, "to see"
    pause 500


    hserout ["test TEST"]
    pause 1000
    goto start
    Attached Files Attached Files

Similar Threads

  1. PIC18F4680 bootloader
    By vinyl_theif in forum General
    Replies: 1
    Last Post: - 29th January 2009, 17:45
  2. 18F4550 Bootloader enter via eeprom setting
    By bradb in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 22nd November 2008, 23:51
  3. USBDemo with Bootloader
    By vacpress in forum USB
    Replies: 4
    Last Post: - 25th January 2007, 22:29
  4. Bootloader Problems
    By rossfree in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 11th February 2005, 17:51
  5. Replies: 3
    Last Post: - 26th January 2005, 13:41

Members who have read this thread : 1

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