Skip to content

Instantly share code, notes, and snippets.

@tmpvar
Created January 16, 2014 23:07
Show Gist options
  • Save tmpvar/8465252 to your computer and use it in GitHub Desktop.
Save tmpvar/8465252 to your computer and use it in GitHub Desktop.

Building

Prerequisites

sudo apt-get install gcc-avr avrdude avr-libc
cd /home/user7/Desktop/grbl8c

make

that should look something like:

/home/user7/Desktop/grbl8c $ make
avr-gcc -Wall -Os -DF_CPU=16000000 -mmcu=atmega328p -I. -ffunction-sections -c main.c -o main.o
avr-gcc -Wall -Os -DF_CPU=16000000 -mmcu=atmega328p -I. -ffunction-sections -c motion_control.c -o motion_control.o
avr-gcc -Wall -Os -DF_CPU=16000000 -mmcu=atmega328p -I. -ffunction-sections -c gcode.c -o gcode.o
avr-gcc -Wall -Os -DF_CPU=16000000 -mmcu=atmega328p -I. -ffunction-sections -c spindle_control.c -o spindle_control.o
avr-gcc -Wall -Os -DF_CPU=16000000 -mmcu=atmega328p -I. -ffunction-sections -c coolant_control.c -o coolant_control.o
avr-gcc -Wall -Os -DF_CPU=16000000 -mmcu=atmega328p -I. -ffunction-sections -c serial.c -o serial.o
avr-gcc -Wall -Os -DF_CPU=16000000 -mmcu=atmega328p -I. -ffunction-sections -c protocol.c -o protocol.o
avr-gcc -Wall -Os -DF_CPU=16000000 -mmcu=atmega328p -I. -ffunction-sections -c stepper.c -o stepper.o
avr-gcc -Wall -Os -DF_CPU=16000000 -mmcu=atmega328p -I. -ffunction-sections -c eeprom.c -o eeprom.o
avr-gcc -Wall -Os -DF_CPU=16000000 -mmcu=atmega328p -I. -ffunction-sections -c settings.c -o settings.o
avr-gcc -Wall -Os -DF_CPU=16000000 -mmcu=atmega328p -I. -ffunction-sections -c planner.c -o planner.o
avr-gcc -Wall -Os -DF_CPU=16000000 -mmcu=atmega328p -I. -ffunction-sections -c nuts_bolts.c -o nuts_bolts.o
avr-gcc -Wall -Os -DF_CPU=16000000 -mmcu=atmega328p -I. -ffunction-sections -c limits.c -o limits.o
avr-gcc -Wall -Os -DF_CPU=16000000 -mmcu=atmega328p -I. -ffunction-sections -c print.c -o print.o
avr-gcc -Wall -Os -DF_CPU=16000000 -mmcu=atmega328p -I. -ffunction-sections -c report.c -o report.o
avr-gcc -Wall -Os -DF_CPU=16000000 -mmcu=atmega328p -I. -ffunction-sections -o main.elf main.o motion_control.o gcode.o spindle_control.o coolant_control.o serial.o protocol.o stepper.o eeprom.o settings.o planner.o nuts_bolts.o limits.o print.o report.o -lm -Wl,--gc-sections
rm -f grbl.hex
avr-objcopy -j .text -j .data -O ihex main.elf grbl.hex
avr-size -C --mcu=atmega328p main.elf
AVR Memory Usage
----------------
Device: atmega328p

Program:   26554 bytes (81.0% Full)
(.text + .data + .bootloader)

Data:       1537 bytes (75.0% Full)
(.data + .bss + .noinit)

if you have a avrmkii ISP programmer you can do this

Flash with arduino firmware

if you are flashing to an arduino UNO with the arduino bootloader running on it you can do this:

first unplug and then plug the UNO back into a usb port

/home/user7/Desktop/grbl8c $ dmesg | tail
[  235.947922] cdc_acm 3-1.2:1.0: ttyACM0: USB ACM device
[  286.896450] b43-phy0: Loading firmware version 666.2 (2011-02-23 01:15:07)
[  286.983628] IPv6: ADDRCONF(NETDEV_UP): wlp3s0: link is not ready
[  317.275395] tg3 0000:02:00.0 enp2s0f0: Link is up at 100 Mbps, full duplex
[  317.275415] tg3 0000:02:00.0 enp2s0f0: Flow control is on for TX and on for RX
[  317.275421] tg3 0000:02:00.0 enp2s0f0: EEE is disabled
[  317.275459] IPv6: ADDRCONF(NETDEV_CHANGE): enp2s0f0: link becomes ready
[  499.958832] usb 3-1.2: USB disconnect, device number 5
[  566.426317] usb 3-1.2: new full-speed USB device number 6 using ehci-pci
[  566.525718] cdc_acm 3-1.2:1.0: ttyACM0: USB ACM device

we're looking for the line that specifies tty* in my case it was ttyACM0, which is a file that lives under the /dev/ directory

so to program the arduino we need to run the following command

PROGRAMMER="-c arduino -P /dev/ttyACM0" make flash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment