How to program on Ubuntu?

Go To Last Post
10 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I read this tutorial(https://www.nongnu.org/avr-libc/...), it was said I could compile and link in command line, I want know if I have made a file, how do I program it into Atmega328p, AVRDUDE? and how to?

 

my OS: Ubuntu 20.04 LTS

     programmer: Atmel ICE

     board:Arduino UNO

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

MianQi wrote:

     board:Arduino UNO

I keep the Arduino bootloader in my UNOs then I can use AVRDUDE in Linux to upload my hex.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

avrdude needs something to talk to. That can either be a piece of programmer electronics (like a "USBAsp" perhaps?) that sits between the Linux PC and the AVR or, as Nigel implies, the target AVR itself might contain bootloader software but, even then, you need some electronics between the PC and the AVR - in this case some kind of USB to UART interface probably.

 

So what equipment do you have to make the link between the PC and the AVR ?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
what equipment do you have to make the link between the PC and the AVR ?

MianQi wrote:
programmer: Atmel ICE

So see: https://www.avrfreaks.net/forum/atmel-ice-and-linux

 

Or, as suggested, use the Arduino bootloader ...

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
So what equipment do you have to make the link between the PC and the AVR ?

For Arduino UNO and family this equipment is merely a USB cable and telling AVRDUDE to use /dev/ttyUSB0 or equivalent device.

 

Interestingly the Arduino MEGA2560 with ATmega16U2 performing USB duty; the serial device presented is /dev/ttyACM0

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
So what equipment do you have to make the link between the PC and the AVR ?

 

I have both Arduino UNO with bootloader and Atmel ICE, and I want use the latter, since I want to program avr-libc code on Atmega328p, not use Arduino framework.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So have you looked at the linked thread?

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

MianQi wrote:
I have both Arduino UNO with bootloader and Atmel ICE, and I want use [], since I want to program avr-libc code on Atmega328p, not use Arduino framework.

Surely, the bootloader neither knows nor cares what libraries or frameworks you use - all it does is program a hex file into flash, and start it?

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

N.Winterbottom wrote:

For Arduino UNO and family this equipment is merely a USB cable and telling AVRDUDE to use /dev/ttyUSB0 or equivalent device.

 

Interestingly the Arduino MEGA2560 with ATmega16U2 performing USB duty; the serial device presented is /dev/ttyACM0

 

 

USB vs ACM

https://rfc1149.net/blog/2013/03...

 

/Bingo

Last Edited: Tue. Jan 5, 2021 - 07:44 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have moved on from the 328p, but some of what I was tinkering with may help. I recommend learning how to do a simple Makefile.

 

https://github.com/epccs/RPUno/blob/master/BlinkLED/Makefile

 

I used an Uno (which shows up as a modem, /dev/ttyACM0) for in-circuit programming. All my other UARTs or bridges show up as /dev/ttyAMAn or /dev/ttyUSBn, which allows the Makefile to select a bootload_port based on where the uploader is running (e.g., an R-Pi vs. Desktop). Upload to an Arduino needs the detection magic for the ACMn device added to that blink Makefile, but the Uno was only used for ISP.

 

To upload with an Atmel ICE, the avrdude "-c atmelice_isp" option needs to be used. The following Makefile I will link does "-c stk500v1 -P /dev/ttyACM0 -b 19200" where the ICE option needs to be. As I said, I used an Arduino Uno loaded with an ISP sketch.
 
https://github.com/epccs/RPUno/blob/master/Bootloader/Makefile

 

Once you upload with the Atmel ICE it will nuke the bootloader. I would recommend having a few 328p on hand and putting one in a breadboard for the Atmel ICE; once you can program them on a new chip, it is probably safe enough to nuke the Arduino. Not everything works in avrdude, so don't trust that atmelice_isp will work as you want; few use it with that tool; it is not Microchip software, so don't expect their support.