Jason writes:
On Fri, Dec 07, 2018 at 05:05:30PM -0000, Dan Purgert wrote: > Jason wrote: > > Does anyone know if there is a console based Arduino IDE available for > > Debian? I am interested in making a portable programmer that could be > > taken out on a job to edit and upload Arduino programs on site, without > > messing with a mouse. > > Don't know of any IDEs for the commandline, but you can always use > avrdude straight from the commandline to handle writing the compiled hex > to the thing. And what could I use to create the compiled hex?
Hello,I was able to get to run a blinking program on an Arduino Nano v3 with the following codes (two files, .hex and .o file are generated as part of the process):
-- BEGIN Makefile --
# depends: avr-libc, avrdude, gcc-avr
build:
avr-gcc -Os -DF_CPU=16000000UL -mmcu=atmega328p -c -o led.o led.c
avr-gcc -mmcu=atmega328p led.o -o led
avr-objcopy -O ihex -R .eeprom led led.hex
upload:
avrdude -F -V -c arduino -p ATMEGA328P -P /dev/ttyUSB0 \
-b 57600 -U flash:w:led.hex
-- END Makefile --
-- BEGIN led.c --
#include <avr/io.h>
#include <util/delay.h>
#define BLINK_DELAY_MS 2000
void main()
{
/* PB5(SCK) = 17 = D13 = LED3 */
/* set pin 5 of PORTB for output*/
DDRB |= _BV(DDB5);
while(1) {
/*
* _BV: Bit mask for port: /usr/lib/avr/include/avr/iom328p.h
* /usr/lib/avr/include/avr/sfr_defs.h
*/
/* set pin 5 high to turn led on */
PORTB |= _BV(PORTB5);
_delay_ms(BLINK_DELAY_MS);
/* set pin 5 low to turn led off */
PORTB &= ~_BV(PORTB5);
_delay_ms(BLINK_DELAY_MS);
}
}
-- END led.c --
It is invoked as follows
$ make build
$ make upload
and assumes that the Arduino is recognized under /dev/ttyUSB0.
HTH
Linux-Fan
Attachment:
pgpJXL3uuwRXA.pgp
Description: PGP signature