Skip to content
Carl Peto edited this page Oct 25, 2020 · 1 revision

Elegoo and the "old bootloader"

Some Elegoo boards (as reported by Darin) seemed to need a slightly different protocol. This seems to be because they have different (older) bootloader code (presumably not "optiboot").

In the Arduino IDE there's a menu option called "Processor" which appears only when you select "Arduino Nano" (and possibly some other boards). It looks like the Nano came in variants with different MCUs, atmega328p, atmega168 and atmega328p (old bootloader). I think the latter is just an atmega328p with an older bootloader preloaded onto it in the factory.

In Darin's case, his board required the "old bootloader" option on the Arduino IDE and wouldn't work without it (the programming step fails with timeouts) and likewise wouldn't work on S4A. While it might be possible to program optiboot onto the atmega328p on that board, we wanted a solution out of the box (also not everyone has an ICSP to hand).

After studying the avrdude logs, we worked out that the only significant difference was that avrdude is run at a different baud rate, 57600 instead of the default 115200. To make this happen on S4A, go into the Settings, Advanced and put the following into "Extra build environment": BAUD=57600.

Arduino Nano

There are lots of types of Nano these days (as well as many other companies making clones). I am talking about my experiences with a standard "arduino nano". This is a small footprint board with a FTDI serial<->USB chip and an atmega328p MCU. Mine has a USB mini port (not USB micro). This pretty much worked for me straight out of the box. However, as discussed in the section about the Elegoo boards (above), some nanos use either different MCUs or the old bootloader. One customer also found this. We recommended the same fix, go into the Settings, Advanced and put the following into "Extra build environment": BAUD=57600.

Leonardo

This is a whole topic in its own right as it's a very different setup from an arduino UNO and clones.

For now, start with the basics of getting programming working for the Leonardo. You'll need a USB -> USB micro cable.

The next thing is programming. You can use an ICSP, which is probably the most reliable way to program. To program using serial programming and the bootloader, I found these settings worked in "Extra build environment"...

MCU=atmega32u4,PROGRAMMER=avr109,BAUD=57600

Note that on my board, I often (always?) seemed to have to press the reset button to get the serial port for programming to show up for a few seconds. The L LED also pulsed during these few seconds. I don't know if this is standard behaviour for a Leonardo board or not?

These steps allow basic building and uploading to the Leonardo, however you will not be able to do anything useful at first, not be able to access the hardware, because most programs you write that us standard primitives from the AVR library (digitalWrite, pinMode, etc.) will not work because the Leonardo is based on a different MCU with differing register locations. You will therefore likely need another module to support hardware access to make Leonardo programs that can actually do anything useful.

Other programmers and AVR based boards

The first thing to say (as people often ask) is whether non AVR based boards are supported. Currently the compiler, tools and standard library are AVR only. They should work with most boards, given some tweaking.

Generally, there are two issues with supporting boards:

  1. atmega328p based boards (nano v3, micro, uno, redboard, orange pip, seeeduino, etc.) - many of these will work out of the box. If not, you may need to slightly tweak the settings of avrdude to make the upload work. As you can see above, in extra build settings you can change the baud rate for avrdude and use a different programmer (for example if you have an ISP that needs support).

  2. other microcontrollers - as you can see above, you can specify the MCU to use. This will be passed to llc for compilation, avr-gcc for linking and avrdude for uploading so your compiler will work, however (as described in the Leonardo section above), you will not be able to access the hardware unless you have some kind of HAL (hardware access layer).

At the time of writing these are still in development (coming soon) so unless a chip shares pretty much the exact same register layout as the atmega328p, you won't be able to get useful programs working yet.