Modifying, making custom bootloader

Hello,

I'm trying to understand how bootloaders work and how to modify/create my own.
First goal is to modify existing bootloader just to change MCU name that appears next to COM port in Arduino IDE ( I think it's defined by a bootloade?).

Currently I'm playing with SAMD21G18 DIY breakout board (it's a stand alone chip with crystal).
I've burned Adafruit feather bootloader from here (with Atmel ICE).

What IDE is used to create bootloaders?
What programming language is used to create them?
Is it very hard to write my own?

I practically don't have any knowledge about bootloades, so please be patient – this learning curve is very steep :slight_smile:

A good start would be to find the bootloaders in the Arduino core of choice. For the AVR Arduinos, you find them in Arduino/hardware/avr/bootloaders. There is a subdirectory for each version. The 'atmega' bootloader is for older Arduinos (pre-UNO) except the ancient boards with ATmega8 chips for which you need the 'atmega8' bootloader. The UNO uses the 'optiboot' style which is faster and takes up less room than the earlier bootloaders. The 'caterina' bootloader is for the Leonardo, Micro, and others that have built-in USB.

For optional cores, like the esp8266, you would look in the 'packages' folder where the optional cores are stored. The esp8266 bootloaders are in packages/esp8266/hardware/esp8266/2.5.2/bootloaders.

Each bootloader has a file called "Makefile" which are the build instructions used by the 'make' command. It will take some study to get everything set up to compile the bootloaders when you type 'make'. In the case of the 'optiboot' bootloader I had to uncomment "ENV ?= arduino" to tell it to use the compilers that came with the Arduino core and add another '../' to the TOOLROOT. After those two changes, all I had to do was type 'make' and it built "optiboot_atmega328.hex" from scratch.