!! This preliminary documentation is 'alpha' quality. I will be writing up a set of readmes that describes the template, the Makefile and skeleton AVR project in much more detail. !!
XcodeAVR is an Xcode project template that creates a working AVR build environment integrated into Xcode. This will allow you to build, flash and do (limited) debugging from within Xcode.
The template is also set up to include the avr-libc header files as well as the MCU specific header files such that code completion will work as expected with register names, etc. from within Xcode.
Although this will work with Arduino boards using the Arduino bootloader, this is NOT an Arduino development environment and does not use nor need anything related to the Arduino tool chain and its libraries.
The accompanying Makefile was built to work stand-alone from the command line as well as integrated in the Xcode project template.
This is a work in progress as there are many additions that are needed in order to make a full featured AVR build environment.
There are a few requirements needed for this project template to install and to properly function.
- avr-gcc -- the AVR gcc compiler
- avr-binutils -- the AVR binutils
- avr-libc -- the C standard library for AVR targets
- avrdude -- flash the code to the AVR target
- minicom -- my preferred terminal emulator, used for serial debugging
There are many different ways to install the required tools, I prefer Mac Ports. With Mac Ports installed:
% sudo port install avr-gcc # installs avr-binutils as a dependency
% sudo port install avr-libc
% sudo port install avrdude
% sudo port install minicom
I am currently using this with Xcode version 11.3.1.
After cloning this repository into a local directory on your computer, cd
to that directory and execute the setup script XcodeAVR_setup
.
[~] % git clone https://github.com/getoffmyhack/XcodeAVR.git XcodeAVR
[~] % cd XcodeAVR
[~/XcodeAVR] % ./XcodeAVR_setup
This will attempt to locate the AVR tools, create a TemplateInfo.plist file and copy all the needed files to your local Xcode template directory.
This is a very simple PERL script and does very little error checking. As long as the AVR tools are all installed, it should successfully work.
Usage is straight forward as any project template in Xcode.
- Launch Xcode and
Create a new Xcode Project
:
- Select the
Cross-platform
templates then selectXcodeAVR
:
- Choose the Project Options. This is where you select the target
MCU
, the connectedProgrammer
, the programmer'sIO Port
and the MCU's clockFrequency
.
This will create a fully functional skeleton AVR project that can be compiled and flashed on the target MCU. The project with it's Makefile can also be used directly from the command line as well as its integrated features with Xcode.
The following build targets are available within Xcode as well as from the command line, for example:
% make build flash
-
Build -- The default target that compiles all source files and links all object files creating a flashable binary file.
-
Flash -- Flashes the project binary to the target MCU.
-
Clean -- Removes all build generated intermediate and final binary files.
-
Serial -- Launches a serial terminal using
minicom
and connects to configured serial port. -
All -- Build, Flash and Serial