AVRA Extended

The AVRA open source macro assembler is a fair alternative for hobbyists developing for AVR microcontrollers. For others the official full blown IDE is also available from MICROCHIP for download.

I stated using the official AVRA macro assembler, but soon enough I hit the wall when I wanted to write an include file with macros calculating delay cycles for busy-wait loops. It turns out that the official AVRA macro assembler comes with a serious limitation. That is, it comes with 32 integers for expression values, while the AVRSAM2 -the official macro assembler from Atmel- has 64 bit integers for the same.

Another oddity is that it blurs the boundaries between the preprocessor- and assembler directives. Also lacks support for function-like preprocessor macros, like #define SQR(X) ((X)*(X)).

So I decided to contribute and implement some missing features. After submitting the PRs, I had to realize that the origin seems to be abandoned and not being maintained any more.

Finally I continued to work on my fork and implemented those parts which I was lacking. All is on the devel branch.

Check out the change log. My repo can be found here.

ARVA Change log

Release 1.4.2b (2024-04-26, by Imre Horvath)

  • Add 64 bit expressions
  • Add preprocessor directives #define and #undef to define and undefine object- and function-like preprocessor macros
  • Add preprocessor operator ## to concatenate preprocessor tokens
  • Implement .undef assembler directive
  • Update makefile for macOS
  • Add the command line option -W to the help text
  • Add tests for the new features
AVRA Extended

AVRDIS

For those, who like to tinker with AVR microcontrollers, and prefer to use small commandline tools, native to their OS, this free and open source project can come in handy.

Avrdis can be used to disassemble the flash contents of an 8-bit AVR microcontroller stored in a intel hex file format. Without any options, it will dump the assembly source to the standard output, which in turn can be piped into another command or redirected into a file.

If you prefer, you can make it emit a more verbose listing with putting the word address first, then the raw instruction word and finally the assembly equivalent by calling with the -l option.

The typical intended use-case is the following. You happen to have an 8-bit AVR microcontroller with an application code in it’s flash, for which you do not have the source code, but you’d like to tinker with it, possible change it an then re-flash your modified code. With this tool this process becomes straightforward.

Workflow

  1. Use avrdude to read the flash contents into an intel hex file.
  2. Use avrdis to disassemble the code.
  3. Edit the source code.
  4. Assemble the source code using avrasm.exe, avrasm2.exe or avra on Unix derivatives.
  5. Use avrdude to flash back the modified code to the microcontroller.

If you’re interested, check out the avrdis tool on GitHub.

AVRDIS

AVR ISP (ATmega328P, Addr. auto inc., STK500v1 at 115.2 kbps)

You happen to have an Arduino Nano laying around, and wanted to program some AVRs but don’t have an AVRISP programmer?

No worries. If you use the Arduino IDE, then you can opt for the built-in example, the 11.ArduinoISP. This out-of-the-box option is certainly useful for a lot of people, however it has some shortcomings. Like you need to use the Arduino ecosystem -which makes your compiled code big- with the bundled compiler toolchain. Also the ArduinoISP is slow, it uses 19.200 kbps for the serial communication with your computer. Also, it uses a fixed SPI clock -which cannot be changed dynamically at runtime-, which can be too fast for targets running at low frequencies.

Since these shortcomings were not suitable for my application, and I wanted to learn some AVR assembly, the project avrispm328p was born.

It turns your ATmega328P-based board (like an Arduino Nano, Uno, etc.) into an AVR ISP with adjustable SCK half-period, using the STK500v1 protocol.

It’s open-source and free, check it out on GitHub!

AVR ISP (ATmega328P, Addr. auto inc., STK500v1 at 115.2 kbps)