Author Topic: To Bootload Or Not To Bootload That Is The Question....  (Read 2289 times)

0 Members and 1 Guest are viewing this topic.

Offline KilroywashereTopic starter

  • Regular Contributor
  • *
  • Posts: 105
  • Country: ca
  • He has the stink of oil and electric circuitry...
To Bootload Or Not To Bootload That Is The Question....
« on: March 13, 2019, 01:58:14 am »
So i know bootloading sets up the micro but..... I have not used the bootload option in arduino IDE ... So my question is .... When do you bootload?  Like if i get a attiny85  its not the same bootloader as the atmega328p right?
He is part of the dead...he has no place here. He has the stink of oil and electric circuitry about him. He is obsolete...
 

Offline ataradov

  • Super Contributor
  • ***
  • Posts: 11905
  • Country: us
    • Personal site
Re: To Bootload Or Not To Bootload That Is The Question....
« Reply #1 on: March 13, 2019, 02:22:50 am »
MCU bootloaders typically do not set up anything, in fact their goal should be to be as unobtrusive as possible. They are used to perform in-field firmware updates. So if you need in-field updates, then you need a bootloader, otherwise you don't.

And yes, bootloaders for those two devices will be different.
Alex
 
The following users thanked this post: Kilroywashere

Offline KilroywashereTopic starter

  • Regular Contributor
  • *
  • Posts: 105
  • Country: ca
  • He has the stink of oil and electric circuitry...
Re: To Bootload Or Not To Bootload That Is The Question....
« Reply #2 on: March 13, 2019, 02:30:21 am »
They are used to perform in-field firmware updates. So if you need in-field updates, then you need a bootloader, otherwise you don't.

What is an example of a In-field firmware update .... I mean since i dont know what it is .... i wont likely ever need to bootload ....
He is part of the dead...he has no place here. He has the stink of oil and electric circuitry about him. He is obsolete...
 

Offline ataradov

  • Super Contributor
  • ***
  • Posts: 11905
  • Country: us
    • Personal site
Re: To Bootload Or Not To Bootload That Is The Question....
« Reply #3 on: March 13, 2019, 02:33:51 am »
Have you ever updated the OS on your phone? The final step of the process, after the new firmware is downloaded by the old OS, is performed by the bootloader.

Firmware upgrade on any other electronics you have - the same exact thing, the actual update is done by the bootloaders.

You don't release a product for sale, then you don't need a bootloader, for sure.

Arduino uses a bootloader to actually program the device without a real programmer. This is also sort of in-field update.
Alex
 
The following users thanked this post: Kilroywashere

Offline ejeffrey

  • Super Contributor
  • ***
  • Posts: 4033
  • Country: us
Re: To Bootload Or Not To Bootload That Is The Question....
« Reply #4 on: March 13, 2019, 03:18:43 am »
For development systems like Arduino, the bootloader is there so that users can program the micro over a serial port without a dedicated programmer.  That is a common application.

Another reason to use a bootloader is if your application is on external storage the processor can't natively address.  A bootloader could copy your code from a SPI flash into RAM.  Some microcontrollers actually have a bootloader in ROM to support multiple booting options.

Another reason is if you have multiple application images the bootloader can select between.  For instance maybe you have a separate application image for a diagnostic mode.  The bootloader can check for something like a specific button held at power up. To launch the diagnostic image instead of the regular application.

The last option works well with field updates.  To avoid bricking your device, you can have a factory image in write protected flash and a slot for an upgraded image.  Normally the bootloader will chain to the newest image but if an upgrade fails or has a bug it can fall back to the factory image.
 
The following users thanked this post: Kilroywashere

Offline KilroywashereTopic starter

  • Regular Contributor
  • *
  • Posts: 105
  • Country: ca
  • He has the stink of oil and electric circuitry...
Re: To Bootload Or Not To Bootload That Is The Question....
« Reply #5 on: March 13, 2019, 03:28:12 am »
Holy crap... I did not know that it was that involved .....  So is The Arduino IDE really just bootloading the programs you put on it?


Or did i misunderstand this?  Is the arduino not really a programmer?
He is part of the dead...he has no place here. He has the stink of oil and electric circuitry about him. He is obsolete...
 

Offline ataradov

  • Super Contributor
  • ***
  • Posts: 11905
  • Country: us
    • Personal site
Re: To Bootload Or Not To Bootload That Is The Question....
« Reply #6 on: March 13, 2019, 03:46:51 am »
If it is a plain basic Arduino, then yes, it uses a bootloader.

Arduino Zero includes a programmer on board, but I don't know if they actually use it. As far as I know they still have a bootloader, probably to make things more universal.
« Last Edit: March 13, 2019, 03:48:58 am by ataradov »
Alex
 

Offline KilroywashereTopic starter

  • Regular Contributor
  • *
  • Posts: 105
  • Country: ca
  • He has the stink of oil and electric circuitry...
Re: To Bootload Or Not To Bootload That Is The Question....
« Reply #7 on: March 13, 2019, 04:30:54 am »
Hmm.. so lets say a PicKit is a real programmer .... what are the advantages/disadvantages of arduino's UNO  compared to a PicKit....

I know thats a can of worms .... but This seems important to me ....  Say i make a widget with arduino uno ... that widget had the code bootloaded i guess

Whats the difference if i make the same widget using a PicKit Programmer .... Is one easier to update  the widget than the other ?


I can assume they both have bootloading options? but i guess im really trying to know the difference between them Pic seems more Pro ... I have yet to be-able to use my K150 Pic programmer I have never got it to work .... and im too cheap to buy a $200 pickit
He is part of the dead...he has no place here. He has the stink of oil and electric circuitry about him. He is obsolete...
 

Offline ataradov

  • Super Contributor
  • ***
  • Posts: 11905
  • Country: us
    • Personal site
Re: To Bootload Or Not To Bootload That Is The Question....
« Reply #8 on: March 13, 2019, 04:35:25 am »
Hmm.. so lets say a PicKit is a real programmer .... what are the advantages/disadvantages of arduino's UNO  compared to a PicKit....
Arduino is a product, PicKit is a tool. What is the advantage of a microwave oven over a screwdriver?

I know thats a can of worms .... but This seems important to me ....  Say i make a widget with arduino uno ... that widget had the code bootloaded i guess
Whats the difference if i make the same widget using a PicKit Programmer .... Is one easier to update  the widget than the other ?

Easier for whom? Final user? Manufacturer?

Does the product actually need updates by the customer? If not, then it makes no difference how the firmware got into it in a first place.

I can assume they both have bootloading options? but i guess im really trying to know the difference between them Pic seems more Pro ... I have yet to be-able to use my K150 Pic programmer I have never got it to work .... and im too cheap to buy a $200 pickit
You need to first decide on the MCU architecture/type you want to use. There are lots of cheap options for ARM-based MCUs. And for others too.
Alex
 
The following users thanked this post: Kilroywashere

Offline KilroywashereTopic starter

  • Regular Contributor
  • *
  • Posts: 105
  • Country: ca
  • He has the stink of oil and electric circuitry...
Re: To Bootload Or Not To Bootload That Is The Question....
« Reply #9 on: March 13, 2019, 04:42:45 am »
Pick the right tool for the job i guess... But are not all tools products for us to buy :P


But i get ya....  it does not really make a difference .... if you need something specific you will find the right tools for the job...

some tools are easier and more complex than others...

Thank you for chatting with me !
He is part of the dead...he has no place here. He has the stink of oil and electric circuitry about him. He is obsolete...
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4349
  • Country: us
Re: To Bootload Or Not To Bootload That Is The Question....
« Reply #10 on: March 13, 2019, 08:19:32 am »
Quote
What is an example of a In-field firmware update
Well, you know, the endless cycle of debugging software probably counts.
Being able to bootload new code over an ordinary computer connection, without having to dig out a special-purpose programmer, connect up a half-dozen signals or more that may or may not conflict with your actual product (or, taking the chip out and reprogramming it separately) is a HUGE advantage.Not as much as it used to be, now that you can get development boards with built-in programmers, debug/ICSP interfaces are much laxer about number of pins and voltages, and USB is a cheap and common high-speed interface with power.  But hugely important, none-the-less.
Quote
so lets say a PicKit is a real programmer .... what are the advantages/disadvantages of arduino's UNO  compared to a PicKit....
Well, my PICKit4 has an 8-pin connector.  Not all of those pins are used for any one device (it does JTAG, SWD, ISP, ICSP, PDI, UPDI, TPI, DebugWire, and probably more...)  But it's a pretty huge debug connector if I just want to "plug and play" during the debug phase of my software.  (Yeah, yeah, "adapter cables", "jumpers", etc.  PITA.)  My Arduinos just plug into a USB connector, and use the same serial pins for bootloading that I use for debug printouts.  Convenient and "low impact."

Quote
Arduino Zero includes a programmer on board, but I don't know if they actually use it.
I believe that they do.  (they don't currently use the debug capabilities that the programmer also provides.)  The new "Uno WiFi 2" also has the programmer/debugger chip.
 

Offline Nerull

  • Frequent Contributor
  • **
  • Posts: 694
Re: To Bootload Or Not To Bootload That Is The Question....
« Reply #11 on: March 13, 2019, 04:50:56 pm »
The arduino bootloader is what allows you to program the device over UART or via USB. The bootloader option in the menu flashes a bootloader using a programmer to a chip that doesn't have one. If you get a blank chip with nothing programmed and drop it in an Uno, it won't be able to program it.

The Arduino IDE doesn't 'bootload' anything - the bootloader is a small piece of code on the chip itself that runs first on startup, typically has some way to check if it should go into programming mode, and if not it jumps into the normal program code.

You can use a programmer to flash code without a bootloader, but then you lose the ability to program the chip without using a programmer.

The chip in the Pickit 4 contains a bootloader which allows it to be flashed with new and target-specific firmware when you use it.
 

Online rstofer

  • Super Contributor
  • ***
  • Posts: 9963
  • Country: us
Re: To Bootload Or Not To Bootload That Is The Question....
« Reply #12 on: March 13, 2019, 06:27:05 pm »
If  you are building a product that doesn't need serial IO, you are unlikely to add the USB->Serial chip and there is no reason to use up code space on a boot loader.  You would probably use ICSP or <whatever> to program the device upon assembly and that would be the end of it.  No doubt the serial pins would be used for something in the product.  You could break out an ICSP header for future use or just have some pads for pogo pins used during factory programming.

A huge advantage of the Arduino compatible devices is the existence of that bootloader.  It takes up a bit of memory space but it allows nearly instant updating following compilation.  I certainly don't look back fondly at having to use JTAG or ICSP.

You can see the STM32 boards coming with the same features (plus debugging) whereas the MBED approach is to use a 2d CPU to emulate bulk storage - also a nice prgramming approach.  In this case, debugging is done with printf().
 

Offline Rick Law

  • Super Contributor
  • ***
  • Posts: 3490
  • Country: us
Re: To Bootload Or Not To Bootload That Is The Question....
« Reply #13 on: March 13, 2019, 06:45:27 pm »
As a hobbyist with limited and non-professional experience, let me make an attempt to put it in more beginner's terms to help you understand what the boot loader is.

A boot-loader is a start-up program that can load another program or run a previously loaded program.

UNO, Arduino NANO, ATTiny, 8080, 6502 whatever Microprocessor/MCU, doesn't matter.  When it powers up, it goes to a boot location (boot address) to begin doing whatever it should do when it powers up.

If your MCU has a specific purpose (say controlling a flashlight), you can with an "ISP" (hardware called "In System Programmer") stuff a flashlight  controlling program into that MCU.  Of course that flashlight program will be loaded at the location that the MCU goes to when it powers up.  The MCU can be programed by other means.  ISP hardware and protocol allows it to be programmed AFTER it is installed in a system already - hence the name In-System-Programmer.

For your MCU driven flashlight (or your microwave oven, or your dishwasher...), chances are, you are always running that specific program, you wont be changing it.  On the other hand, you may want to change your flashlight program or run something entirely different.  In that case, you merely load the other program using an ISP.  Well, of course assuming your hardware supports it - otherwise there is no point in ISP-ing your microwave oven program to your flashlight's MCU.

Now, to make it really easier to reassign to different purpose, you can make a power-up program that can load another program.  So, instead of needing an ISP, your power-up program first detects if you want to load a new program, or to run the existing one you last loaded.  That kinds of power-up program is called boot-loader.

The Arduino IDE is NOT on your MCU.  It is on your PC.  It allows you to edit and compiles your code, and if you choose to, it can tell the power up code (boot loader) to get ready to receive the code to to flash.  The IDE sends the code down.  The flashing is done within the MCU by the power up (boot loader) code.

Boot-loader is not a new concept.  In the early days of computing, the early computers powers up and begin with talking to the punch-card-reader.  The stack of key-punch cards contains your "power-up" code with each code punched as holes in different positions on a card.

When your Arduino MCU (in UNO/NANO/whatever) powers up, it goes to the power-up (boot) code and in the case of Arduino, it would contain the Arduino boot loader as the power up code.  The boot loader would check for a specific condition.  If that condition exist, it gets ready to download new program.  If not, it would jump to your prior downloaded program.  When you choose to flash using your Arduino IDE, the IDE reboots the MCU, sent it the signal to get ready to download.  The bootloader sees the condition, it receives the downloaded program and flashes it.  So the IDE doesn't do the flashing; it tells the boot loader "I want to flash", sends down the program, and waits for the MCU to send back the flash-status.

As exampled above, your hardware has to support it too...  There is no point in downloading your dish-washer MCU program onto your Arduino MCU because your Arduino UNO doesn't have a water jet or dryer on the board.  UNO, NANO, MEGA, all has different default hardware (and/or different MCU in the same AVR line of MCUs) so they can do different level of things.  The ATTiny13 has so little memory it can't even run a boot loader.  ATTiny85 has enough for a boot loader and then not much else.  ATMEGA 318 or 328 are the MCU in NANO/UNO/Mini, they have enough to run the boot-loader as well as another program.  None of them has water-valve or dish-dryer heater, but they have the IO-ports to control one if you hook up the Arduino board to one.

Each of these MCU's or boards has different hardware, so their boot-loader may do similar things but they are different.  The ATMEGA 328's has more memory/features than the 318's.  The 318's has more than ATTiny85.  The ATTiny85 has more than the ATTiny13.  The ATTiny85 doesn't even have I2C or RS232-Serial for example, it has a "universal serial" that can be used to support either I2C or RS232 but no TX/RX lines.  The boot loader has to initialize different things and supports different feature/size in the "user program" so the differences in the boot loaders are significant while the type of functions they perform are similar.  So, you will find the Tiny85's boot loader to be entirely different than the UNO's boot loader.

Typically, the NANO/UNO are ATMEGA 328's, but you can find super cheap ones on AliEpxress/eBay with ATMEGA 318's.   I almost made a mistake once with some super cheap NANOs/UNOs but 318 instead of 328.

The Arduino IDE, the Arduino boot-loader, the standard Arduino board hardware, and the standard Arduino code libraries together is what can be consider as the Ardunio environment.

I have ATTiny13 on my simple flashlights.  I have ATTiny85 on my flashlights with more option.  While the 85 can, I don't use boot loader and I do not use any of the standard Arduino library.  I use NANO/UNO for more complex tasks - well, "more complex" as in needing more than ATTiny85.  While I may not download programs to those "mission-specific" NANO/UNO all the time, but I have the space and it does make my life easier to just keep the boot loader and use the Arduino-specific stuff in my case.

Hope this "layman's explanation" helps...

EDIT: replaced the phrase "wake up" with "power up" so as not to confuse with sleep mode type awaking.
« Last Edit: March 13, 2019, 07:01:09 pm by Rick Law »
 

Offline sleemanj

  • Super Contributor
  • ***
  • Posts: 3051
  • Country: nz
  • Professional tightwad.
    • The electronics hobby components I sell.
Re: To Bootload Or Not To Bootload That Is The Question....
« Reply #14 on: March 13, 2019, 08:01:47 pm »
It should be pointed out, that in Arduino land "burn bootloader" is also how you set fuses, so for example, even if using an ATTiny13 which doesn't generally have any room for a bootloader you still want to "Burn Bootloader" to set the fuses.

---

For those unaware, fuses are configuration bits, set-able only using a programmer not via the bootloader, they set things like the clock source and divider, brown out detection level, reset disable...
~~~
EEVBlog Members - get yourself 10% discount off all my electronic components for sale just use the Buy Direct links and use Coupon Code "eevblog" during checkout.  Shipping from New Zealand, international orders welcome :-)
 

Offline Rick Law

  • Super Contributor
  • ***
  • Posts: 3490
  • Country: us
Re: To Bootload Or Not To Bootload That Is The Question....
« Reply #15 on: March 13, 2019, 08:34:15 pm »
It should be pointed out, that in Arduino land "burn bootloader" is also how you set fuses, so for example, even if using an ATTiny13 which doesn't generally have any room for a bootloader you still want to "Burn Bootloader" to set the fuses.

---

For those unaware, fuses are configuration bits, set-able only using a programmer not via the bootloader, they set things like the clock source and divider, brown out detection level, reset disable...

I was not even aware there is a "burn bootloader".

I've been using an ISP to set the fuses.  That worked well for me.

While on the topic of ISP, the Arduino ISP program in the Arduino "Examples" folder works well for AVR.  It turns an UNO/NANO into an ISP.  I use that as my programmer to flash into my NANOs, UNOs, Tiny12, Tiny25, and my Tiny85.  I used that so much that I have a dedicated NANO (on a proto-board) with SOIC clip (for TinyXX) and a 6 pin jumper socket for the NANO/UNOs.

Having that on a dedicated NANO makes it easy to read back the program whenever I am confused by "what's on this NANO?"  Grabbing the flash content from the NANO and scanning the text strings would give me a good idea of what is actually in the MCU's flash.  Without a dedicated ISP, I found it too troublesome to hook up a NANO, download the ISP, blah, blah, blah...
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf