I also explain how to burn a bootloader to a 3D Printer that doesn’t have one yet. But really, you might not even need one!
Use a USBtinyISP as a programmer or re-purpose an Arduino board you might already have to upload anything even to mainboards that do not come with a bootloader installed.
Now, one of the questions that was unanswered in that video was “How do I upload firmware if I can’t do it through USB because my board has no booatloader installed on it?” – well, that’s exactly what we’re going to look at today.
So, what even is a bootloader and why do you need it?
Well, it’s a small piece of software that runs on your mainboard’s processor every time it starts up. So every time you power the machine on or when you hit reset. And normally, it just takes a second or two and then starts loading the regular firmware that’s already on your board. Except if it detects that you want to upload new firmware when the bootloader runs, in that case it will take the firmware you’re uploading through the USB serial port and overwrite whatever is already saved in the processor’s flash memory. The bootloader is exactly why you can normally upload firmware so easily just through the USB port.
Now, when you don’t have a bootloader installed, there is nothing else on the board that will handle that process of accepting the firmware from your computer and then writing it to the flash storage. There is, however, a separate feature built into the AtMega processors that these boards use that still lets you write new software onto it, and that’s exactly how these boards are programmed when they’re made: What I’m talking about is an ICSP, the in-circuit serial programmer. Pretty much all boards have this six-pin header labeled ICSP, and that’s exactly what we’re going to use. It allows to us write to the entire flash memory of the board, while uploading through USB with the bootloader only lets you write to the space that is not taken up by the bootloader yet.
And that actually brings up a question that you should ask yourself before you get into this: Do you even need a bootloader? Because the thing is, yeah, you can use the ICSP to flash a bootloader to the board and then upload your firmware through USB, but you can also just flash the entire firmware to the board with the in-circuit serial programmer and leave out the bootloader entirely. I mean, you need the ICSP hardware either way.
So pros and cons here:
If you have a bootloader, it makes uploading new stuff through USB possible, but if you don’t use one, you save that one second every time your machine starts up, but you also save some flash space on the processor. Now, the thing is, your manufacturer hopefully didn’t just leave out a bootloader because they didn’t know any better – even though that’s entirely possible, usually it’s because saving that space lets them use a cheaper processor without having to disable too many features in the firmware. You see, almost every feature you turn on in Marlin uses some amount of space, and you can see that after you’ve compiled the firmware in Arduino with the “Verify” button, it shows it right down here. Want to use a BL Touch? That’ll be 5kB. Want to use Universal Bed Leveling? Well, there go another 43kB. It all adds up.
The “largest” 8-bit processor you could have is the ATmega 2560, which comes with, as the name suggests, 256kB of flash memory – yes, that is “kilo”bytes, not even “mega”byte, and 8kB of that is taken up by the bootloader, according to the Arduino page. The ATmega 1280, which is used by a lot of budget 3D printers, is basically identical to the 2560, but: it has less flash memory. You might have guessed it, it 128kB, as the name implies. And interestingly enough, Arduino say that only 4kB of that are used by the bootloader. Still, it’s 4kB that might make the difference between you being able to use a firmware with all the features you planned on, vs. not being able to fit it on the processor at all.
In the early days, we were even using processors as puny as an ATmega 644P, and you can take a wild guess how much flash storage that had – yes, 32kB. No, just kidding, it’s 64kB. But at the time the Sprinter firmware was the hot firmware in town, and that didn’t do nearly as much as Marlin does today.
Alright, so if you go without a bootloader, you get to save a few kilobytes of flash storage and one second of startup time, but really, unless you need every last byte of that flash memory, I think you should still install a bootloader. But whichever option you choose of installing a bootloader or not, you will need specific hardware to act as the in-circuit serial programmer. One of the popular options is simply using a second, spare Arduino, and I’ll show you how to set that up in a second, but what I like to use is the USBtinyISP, which is just a small little dedicated board that comes with USB on one side and the ICSP headers on the other. I find that’s faster to set up and just overall easier to use – plus, you can get them Aliexpress for just $3, so it’s actually cheaper than getting an Arduino board just for doing that job. I’ve linked them in the video description below – either on the cheap from China, or as a high-quality version directly from Adafruit, who actually designed the USBtinyISP as an open-source project – which is why you now have the option of buying a cheap one in the first place, so thank you Adafruit for that!
So if you’re on Windows, you might need to install the driver for the USBtinyISP, which, again, you can get from Adafruit. Also linked below. Before you plug in the programmer to your board, there’s one more thing that you should check, and that’s this jumper right here, which you can use to power your mainboard or Arduino that you’re programming from the USB port on the programmer, but since there’s a lot of stuff to power on a 3D printer mainboard from that 5V rail, it’s better to turn on your 3D printer’s power supply and to remove that jumper so that no current flows back into your computer’s USB port. After that, you can plug everything in.
In the Arduino software, you should pick the right programmer and board, and then you have the choice of either burning a bootloader to the board right here in “Tools > Burn bootloader” or uploading the firmware you’ve got open with the “Sketch > upload using programmer” option.
Keep in mind that this overwrites *everything* that is already saved to your processor, so if you burn a bootloader first and then try to write the firmware using the programmer as well, it’s actually going to overwrite the bootloader, too. So if you want to go with a bootloader, first burn the bootloader with the programmer and then unplug everything and upload your firmware through USB, just like I describe in the previous video.
On the other hand, if you upload your firmware directly with the programmer, to update it later, you will need to use the programmer again, since you can not upload it through USB. Either way you choose leaves you with a firmware that is functionally the same as the other.
So, lastly, let’s check out how you can use an Arduino board you might already have instead of a dedicated USBtinyISP. This is based on the guide on Arduino’s website, so I’ll keep it short here.
You start by wiring the Arduino to your board like this, but just like before, I’d recommend leaving out that 5V connection and instead turning on your printer’s power supply.
Connect the Arduino to your computer, then in the Arduino software, go to “File > Examples > ArduinoISP”, open that, select the correct Arduino board you’re using from the “boards” menu and hit upload.
This will now flash your Arduino to work as a programmer.
So now you can select the “Arduino as ISP” programmer and choose “Burn bootloader” to install a bootloader on the board that’s connected to the Arduino or, just like before, directly upload a firmware you have open by going to “Sketch > upload using programmer”.
So, really, after you uploaded the ArduinoISP sketch to your Arduino board, you can use it just like the USBtinyISP or any other programmer.
So that’s that, I hope it cleared up some things about programmers, bootloaders and why you may or may not want one.
If you don’t think this video was helpful, let me know in the comments below what I should improve, otherwise, give the video a thumbs up, get subscribed for more videos like it and don’t forget to hit that bell so you actually won’t miss any.
Subscriptions kinda don’t matter anymore to YouTube if you don’t hit the bell, so, pretty please?
And yeah, to keep the channel running, I’d appreciate your support on Patreon, but even just buying things through the affiliate links in the description helps out a ton.
So thank you all for watching and I’ll see you in the next one!
USBtinyISP drivers (Windows)
You can support me without spending a single penny!