Modified: 2022-09
Demo of using CMake to create a toolchain for building and flashing firmware for the Incuvers Control Board. I have supplied a sample program which blinks the SCK
LED (PORTB1) at 2Hz. It also uses an ISR tied to the interrupt vector for completed usart reception to echo characters back to a serial console.
You will need avr-libc
and the avr
code generation tooling. On MacOSX you can use homebrew
to install these dependancies:
brew tap osx-cross/avr
brew install avr-gcc
Your code generation tools root should be under /usr/local/bin
try running avr-gcc --version
in the terminal to ensure it is found.
You will need to define the serial device for the control board. Furthermore the following programs need to be found in the CGT_ROOT
path:
- avr-gcc
- avr-objcopy
- avrdude
- avr-g++
- avr-strip
Once this is confirmed update the cmake definitions in the CMakeLists.txt
:
set(SERIAL_PORT "/dev/tty.usbserial-A10JTC54")
set(CGT_ROOT "/usr/local/bin")
Run the cmake project configuration:
mkdir build
cd build
cmake ..
Compile the firmware to .elf
format and then object copy to .hex
:
make -j4
Flash the .hex
binary to the control board:
make flash
I've added a fuse directive to setup the chips fuses according to the ATMEL2560:
make fuses
Open a serial console to the control board by targetting the usb device in /dev
and run at 115200
baud:
$ screen /dev/yourusbdevice 115200
...
type some random stuff in the console and ensure characters echo back.
To exit screen:
ctrl+a
to enter command mode, then pressk
for kill and then pressy
to confirm kill
ATMEL 2560 Datasheet to get started baremetal programming.