Appearance
Build & Flash
This page explains how the example projects are built and uploaded.
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.
Build an example
Use blink as the first test:
sh
cd examples/blink
c3c buildThe build uses examples/blink/project.json. The important settings are:
dependencies: ["arduino"]— imports this library.dependency-search-paths: ["../../.."]— lets the example find the library from insideexamples/blink.cpu: "atmega328p"— selects the target MCU.target: "elf-avr"— builds an AVR ELF file.use-stdlib: falseandlink-libc: false— keeps the binary freestanding.no-entry: true— uses the exportedstartsymbol instead of a hosted entry point.
Output:
text
build/blink.elfFlash with the helper script
sh
./scripts/flash.shThe script runs c3c build and then uploads with avrdude:
sh
avrdude -c arduino -p atmega328p -P /dev/ttyACM0 -b 115200 \
-U flash:w:build/blink.elf:eChange the serial port
If your board is not on /dev/ttyACM0, edit scripts/flash.sh.
Common Linux device names:
/dev/ttyACM0/dev/ttyUSB0
You can often find the device with:
sh
ls /dev/ttyACM* /dev/ttyUSB*Permissions
On Linux, your user may need access to the serial device. Depending on your distribution, adding the user to dialout, uucp, or a similar group may be required.
Troubleshooting
- Confirm that
c3c --versionreports a nightly build. - Confirm the board is an ATmega328P-compatible Arduino Uno style board.
- Check the serial port in
scripts/flash.sh. - Make sure no serial monitor is currently using the port.