Arduboy custom bootloader

Not yet but I’ll put it up on my github later when it’s cleaned and more documented (It’s pure assembly) also still need to find out how to make a proper makefile for it (just using a batch file atm and adding the boot signature at the end manually)

If your code is derived from the Caterina bootloader, I suggest you honour its license agreement, which I believe is included in comments at the start of the source code files.

Yes it’s based on the reversed Caterina bootloader (which I’ll include) and I’ll include the original licence too.


Too bad the weekends over again :frowning: So I had to stop optimizing. Bootloader size is currently at 3196 bytes (900 free bytes) no time for a making a new test. But he next one will be down 1K for sure :slight_smile:


OK I I’ve optimized and crunched enough for my liking. Bootloader size is down to 2752 bytes without removing features, actually added features :smiley:

I’ve also added software bootloader protection so any block write to flash or page commit in the bootloader area will not be executed.

Changed the timeout back to 7.5 secs for 4 flashy RGB LED cycles Updated the zip file with:


Just discovered @eried’s Dock the other day. Which I like so much I want to add write to display and read button support to the bootloader now. So when Arduboy is in bootloader, Arduboy could be used as a mini terminal.

The idea I have atm is to extend the AVR910 command ‘B’ (WriteMemoryBlock) by adding memory type ‘D’ that writes to a 1K display buffer and outputs ito oled when 1K address is reached.


Preventing writes to the bootloader area using software is totally unnecessary as long as the lock bits have been set properly.

If you have the capability to burn the bootloader, you also have the capability to properly set the lock bits. If you use the Arduino IDE to burn the bootloader, this will be done automatically.

The last part is usually the problem. You can easely forget to set them (even my recently purchased Arduboy didn’t have then configured)

What about If you don’t have the capability and the bootloader was burned by someone else who didn’t set the lock bits properly? You’d have to go through some trouble to get it fixed.

Hmmm… this taking about bootloader protection and lock bits. just gives me an Idea: I’ve freed over 1K of space in the bootloader. With just software bootloader protection I could make that area unprotected. That would be great for a selfprogramming bootloader extension or extra space

1 Like

I must admit, there have been many cases of the lock bits not being set, even on newer Arduboys.

Happened to me with my first one.
RIP my 1st arduboy, have no programmer to bring you back to life. qq

1 Like

I you have the capability to burn the bootloader, then forgetting to lock it isn’t a problem. You can always just burn it again if it gets corrupted.

If someone else burns the bootloader for you, then it should be their responsibility to make sure it’s protected. If not, it’s on them to correct the problem (which the Arduboy organisation has be very good about dealing with).

The proper way of handling the problem is not to add code that would be useless if the hardware is set properly. It should be handled by making sure the problem doesn’t occur, such as by using a script that both does the burning and sets the locks in one operation. Or, by using the Arduino IDE to burn the bootloader.

1 Like

Well I’m also keeping in mind that the bootloader can be used for the regular Arduino’s Leonaro, Micro ProMico,etc.

It’s a 30 byte protection now that only protects the 1st 3K of the bootloader allowing the last 1K to be self programmed if the bootloader bit’s are not set. I’ve also dubbed the bootloader ‘Cathy3K’ now because of it taking up 3K

But back to the Arduboy features. it’s in!
I’ve successfully added the streaming to display code, button reading and a little USB connector sprite to display in bootloader mode just for fun :sunny: Bootloader size is at 2988 bytes now.

bootloader hex file and python demo at:

Streaming is quite simple:

Set current address to 0 using command ‘A’,0x00,0x00 wait for response byte
8 times: write 128 bytes of display data using command ‘B’,0x00,0x80, ‘D’ followed by the 128 bytes of display data and wait for response byte

Reading the buttons is done using the hardware version command ‘v’ (lover case)
write command ‘v’, read response byte. if not equal ‘?’ (normal bootloader response) read another response byte.
button_AB_state = ResponseByte1 -‘1’, D-Pad_state = ResponseByte2 - ‘A’

Still need to work on command 'x to control the LEDs. So no control of the LEDs yet.


If you expect this to be usable with an Arduino Micro, make sure you have defines and/or code to take into account the fact that the polarity of the TX and RX LEDs is reversed. You set their pin high to turn them on rather than low.

Thanks I already have. Undefine ARDUBOY and you get ordinary optimized bootloader for Leonano/Micro, Change DEVICE_PID to 0x0037 and the Rx/Tx Led polarity is changed. Bootloader size is 2730 bytes for the ordinary version. Will make it public once I’m done with adding features and cleaned the source up.



1: You are now a hero.

2: Using Bad Apple as demo just made you a SUPER HERO.


I think it’s possible to create a new board type to define an Arduboy with a 3K bootloader and have it leave the bootloader unlocked if burned using the IDE. This would allow sketches to be 1K larger.

However, this may lead to complaints for any sketches taking advantage of this:
I’d love to be able to play SuperBigGame but it will only work on an enhanced bootloader Arduboy and mine’s a regular one :cry:

Is that possible? the free 1K is after the bootloader (has to be because of the vectors)

If this bootloader would end up on official Arduboy’s It would be a good reason to get another one :wink:

But seriously, I dislike the idea too of having games that require specific hardware (unless the dependency was SD Card)

I really haven’t thought much about the uses for it yet. It could also be wasted on customizable bootscreen to personalize your Arduboy :stuck_out_tongue:

I mainly started the optimalisation project to see if enough space could be freed to add SD card code. But as always I see and get nice ideas and get distracted :slight_smile: But I think these 258 bytes of Arduboy specific code turned out quite nicely (I’ll need some more bytes for the LED control but It will be under 3K total).

Oops, sorry. You’re right. I quickly looked at the datasheet and misread the table. I thought the bootloader was at the start of flash, not the end :flushed:

How did you reduce the size so? When I looked at this a while back the C code seemed pretty tight to me… I think the default compile has like 100 free bytes or something.

I can’t handle how awesome this all is, the amount of work that’s going into this is just incredible :trophy:


By assembly coding. I started by building caterina bootloader then reversed it to assembly and made it assemblable again, verified binaries as confirmation and then went to optimizing using byte crunching skills.