Development


Introduction

For many years, for all my MCU projects using Atmel MCUs, I have used the IDE provided by Atmel or now Microchip. First I started using AVR Studio up to version 4.19 and then switched to Atmel Studio 7.0. Is I’m using a MacIntosh I had to run Windows in a virtual machine. Recently Microchip has started to support Atmel MCUs in their MPLAB X IDE development environment which is also supported on macOS natively. But the avrasm2 was not always included and currently is no longer included as well.

AVRASM2 on macOS

For a short time Microchip inlcuded avrasm2 in the XC8 compiler package for their MPLAB® X IDE even in the macOS version. That is there was a macOS binary of avrasm2 included. You can still download Version 2.05 of the XC8 package from the Microchip web page however you need to have macOS High Sierra or older in order to be able to use the installer. It will not run on Mojave, Catalina, Big Sur, Monteray and newer.

However once you have installed the XC8 package on an older macOS you can find the binary in the folder where you installed the XC8 compilers and copy it to a newer macOS. It will at least run under Catalina and Big Sur. You just need to copy the binary avrasm2.

You still need the inlcude files and you will get a warning when assembling code for the new V4 (AVR128DA, DB, DD) and V4S (Atmega480x) cores, but it will create a working binary. The include files are as well included in the Version 2.05 installer but they are outdated.

The warning is also thrown by the Windows version in Atmel Studio 7.0 so you can most likely just ignore it.

Now I have a complete assembler toolchain for my AVR software developement on my macOS.

Using avrasm2 on macOS

Having a macOS binary makes it much easier to use assembler for AVR MCUs. I have placed all include files form Microchip Studio 7.0 into a direcotry avrasmincludes. You need to make sure that you update them manually when a new version of Microchip Studio 7.0 is available. For this purpose I still have a Windows 10 VM but now I only need it for updates and to run WinCUPL and AVRISP.

avrasm2 on macOs supports the same command line options as the windows versions.

peter@Peters-Mini ~/AVR-Projects/Qbridge11-v2-3 % avrasm2 -h
AVRASM: AVR macro assembler 2.2.7 (build 15 Jan 12 2018 06:14:42)
Copyright (C) 1995-2018 ATMEL Corporation

usage: avrasm2 [options] file.asm

 Options:
    -f O|M|I|G -  output file format:
        -fO Debug info for simulation in AVR Studio (default)
            -fO1 | -fO2 - force format version 1 or 2 (default: auto)
        -fM Motorola hex
        -fI Intel hex
        -fG Generic hex format
        -f- No output file
    -o ofile   Put output in 'ofile'.
    -d dfile   Generate debug info for simulation in AVR Studio in 'dfile'.
               Can only be used with the -f [M|I|G] option.
    -l lfile   Generate listing in 'lfile'
    -m mfile   Generate map in 'mfile'
    -e efile   Place EEPROM contents in 'efile'
    -w         Relative jumps are allowed to wrap for program ROM
               up to 4k words in size
    -C ver     Specify AVR core version
    -c         Case sensitive
    -1/-2      Turn on/off AVR Assembler version 1 compatibility.
    -p1|0      Set/unset AVRASM1 implicit .device include (also set by -1)
    -I dir     Preprocessor: Add 'dir' to include search path
    -i file    Preprocessor: Explicitly pre-include file
    -D name[=value] Preprocessor: Define symbol. If =value is
               omitted, it is set to 1.
    -U name    Preprocessor: Undefine symbol.
    -S file    Produce include/label info file for AVR Studio
    -v verbosity [0-9][s]:
        -vs Include target resource usage statistics
        -vl Output low-level assembly code to stdout
        -vk Keep output files if source file empty
        -v0 Silent, only error messages printed
        -v1 Error and warning messages printed
        -v2 Error, warning, and  info messages printed (default)
        -v3-v9 Unspecified, increasing amounts of assembler internal dumps.
    -V         Format map and list files for Verilog.
    -8 -|+     Force Disable/Ebable 8kB check for JMP/CALL
    -O i|w|e   Overlap report: ignore|warning|error [error]
    -W-b|+bo|+bi Byte operand out of range warning disable|overflow|integer
    -W+ie|+iw  Unsupported instruction error | warning
    -W+fw      Label slip caused by forward ref accepted (DANGEROUS)
    -FD|Tfmt   __DATE__ | __TIME__ format, using strftime(3) format string
    -h         this help

peter@Peters-Mini ~/AVR-Projects/Qbridge11-v2-3 [1] % 

The native macOS assembler is very fast, a large project is assembled within seconds.

peter@Peters-Mini ~/AVR-Projects/Qbridge11-v2-3 % avrasm2 -fI -o Qbridge11-v2.hex  -m Qbridge11-v2.map  -l Qbridge11-v2.lss  -S Qbridge11-v2.tmp  -W+ie -I..\include  -d Qbridge11-v2.obj  -I ../include -I ../avrasminclude Qbridge11-v2.asm
AVRASM: AVR macro assembler 2.2.7 (build 15 Jan 12 2018 06:14:42)
Copyright (C) 1995-2018 ATMEL Corporation

Qbridge11-v2.asm(1): Including file '../avrasminclude/m1284Pdef.inc'
Qbridge11-v2.asm(98): Including file '../include/macro-library-v1-0.asm'
Qbridge11-v2.asm(99): Including file '../include/FAT/fat-defs.asm'
Qbridge11-v2.asm(335): Including file 'Qbridge11-rlv12-defs-v2.asm'
Qbridge11-v2.asm(1103): Including file 'Qbridge11-rlv12-csr-v2.asm'
Qbridge11-v2.asm(1309): Including file '../include/monitor-chartbl-v1-3.asm'
Qbridge11-v2.asm(1336): Including file '../include/monitor-subtbl-v1-3.asm'
Qbridge11-v2.asm(1663): Including file '../include/monitor-v1-6.asm'
Qbridge11-v2.asm(1668): Including file '../include/print-v1-2.asm'
Qbridge11-v2.asm(1673): Including file '../include/tparse-v1-2.asm'
Qbridge11-v2.asm(1678): Including file '../include/malloc-v1-0.asm'
Qbridge11-v2.asm(1683): Including file '../include/SD-Card-IO-v2-0.asm'
Qbridge11-v2.asm(1688): Including file 'Qbridge11-rlv12-v2.asm'
Qbridge11-v2.asm(1694): Including file 'Qbridge11-monitor.asm'
Qbridge11-v2.asm(1697): Including file 'Qbridge11-cli.asm'
Qbridge11-v2.asm(1699): Including file 'fdisk.asm'
Qbridge11-v2.asm(1701): Including file 'FAT-library-v1-3.asm'
Qbridge11-v2.asm(1703): Including file 'Qbridge11-mountvolume-v1-0.asm'
Qbridge11-v2.asm(1869): Including file 'Qbridge11-monitor-pdp11.asm'
Qbridge11-v2.asm(1873): Including file 'crashdump.asm'
Qbridge11-v2.asm(1): Including file '../avrasminclude/m1284Pdef.inc'
Qbridge11-v2.asm(98): Including file '../include/macro-library-v1-0.asm'
Qbridge11-v2.asm(99): Including file '../include/FAT/fat-defs.asm'
Qbridge11-v2.asm(335): Including file 'Qbridge11-rlv12-defs-v2.asm'
Qbridge11-v2.asm(1103): Including file 'Qbridge11-rlv12-csr-v2.asm'
Qbridge11-v2.asm(1309): Including file '../include/monitor-chartbl-v1-3.asm'
Qbridge11-v2.asm(1336): Including file '../include/monitor-subtbl-v1-3.asm'
Qbridge11-v2.asm(1663): Including file '../include/monitor-v1-6.asm'
Qbridge11-v2.asm(1668): Including file '../include/print-v1-2.asm'
Qbridge11-v2.asm(1673): Including file '../include/tparse-v1-2.asm'
Qbridge11-v2.asm(1678): Including file '../include/malloc-v1-0.asm'
Qbridge11-v2.asm(1683): Including file '../include/SD-Card-IO-v2-0.asm'
Qbridge11-v2.asm(1688): Including file 'Qbridge11-rlv12-v2.asm'
Qbridge11-v2.asm(1694): Including file 'Qbridge11-monitor.asm'
Qbridge11-v2.asm(1697): Including file 'Qbridge11-cli.asm'
Qbridge11-v2.asm(1699): Including file 'fdisk.asm'
Qbridge11-v2.asm(1701): Including file 'FAT-library-v1-3.asm'
Qbridge11-v2.asm(1703): Including file 'Qbridge11-mountvolume-v1-0.asm'
Qbridge11-v2.asm(1869): Including file 'Qbridge11-monitor-pdp11.asm'
Qbridge11-v2.asm(1873): Including file 'crashdump.asm'

"ATmega1284P" memory use summary [bytes]:
Segment   Begin    End      Code   Data   Used    Size   Use%
---------------------------------------------------------------
[.cseg] 0x000000 0x00902a  19654  16466  36120  131072  27.6%
[.dseg] 0x000100 0x000f75      0   3686   3686   16384  22.5%
[.eseg] 0x000000 0x000000      0      0      0    4096   0.0%

Assembly complete, 0 errors. 0 warnings
peter@Peters-Mini ~/AVR-Projects/Qbridge11-v2-3 % 

avrdude and avrfuses

With avrdude and avrfuses I can program the MCUs and

To load the binary files into the MCU you can still use Atmel Studio or instead use avrdude as a native macOS command line tool

/usr/local/bin/avrdude -P usb -c avrispmkII -p ATmega1284P -s -B 1MHz -U flash:w:Qbridge11-v2.hex

Since avrdude 7.0 and newer macOS versions the USB problems on macOS have disappeared.

pymcuprog

The problem with avrdude on macOS is that it relies on the USB framework which on macOS no longer is the correct way to communicate with USB devices. Therefore I was unable to use avrdude to program modern AVR models like the AVR128 series.

However there is a python script available that allows to use the Atmel-ICE in updi mode so you can program the new AVR128 series on the Mac as well.

The script can be found at Python Package Index

Currently I’m using the Curiosity Nano boards which come with a on-board programmer and debugger therefore I mostly just use the feature to copy the HEX file to the Volume which the Curiosity Nano announces on the USB port. This works well with macOS and Windows.

cp main-v2-1.hex /Volumes/CURIOSITY

is all that is required to load a new program to the Flash of the MCU