Skip to content

Getting Started

This guide gets you from an empty checkout to building the included blink example for an ATmega328P/Arduino Uno style board.

Current compiler requirement

You need the newest C3 Compiler

To use this library you need a version of the compiler that is newer or atleast 0.8.0, since that was the point that avr support was included in the default executable.

Install or update to the latest nightly C3 compiler and make sure c3c is on your PATH:

sh
c3c --version

You also need AVR upload tooling if you want to flash a board:

  • avrdude
  • an Arduino Uno / ATmega328P compatible board
  • a USB serial port such as /dev/ttyACM0 or /dev/ttyUSB0

Clone the project

sh
git clone https://github.com/jotrorox/arduino.c3l.git
cd arduino.c3l

The examples are standalone C3 projects. Start with examples/blink:

sh
cd examples/blink
c3c build

The blink example project declares the important AVR settings in project.json:

json
{
  "dependencies": ["arduino"],
  "cpu": "atmega328p",
  "targets": {
    "blink": {
      "target": "elf-avr",
      "use-stdlib": false,
      "link-libc": false,
      "no-entry": true
    }
  }
}

The output ELF is written to:

text
examples/blink/build/blink.elf

Flash the board

Connect the board and check the serial device. The included helper defaults to /dev/ttyACM0:

sh
./scripts/flash.sh

If your board appears on another port, edit examples/blink/scripts/flash.sh and change -P /dev/ttyACM0 to the correct device.