Newbie seeking advice on hardware programmer device

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

February 8, 2018

 

Hello AVR enthusiast,

 

I have never programmed an Atmel chip.   But I have programmed other 8,  and 16-bit microcontrollers.

 

I am seeking advice on a  hardware programmer to load a hex file onto my ATMega328p 28-pin DIP microcontroller.    I bought the chip that had already been programmed with a bootloader, the so-called "Arduino bootloader-programmed chip".

 

On my 64-bit linux computer I installed the basic AVR tools from my repository's  APT deb packages:

        avr-libc
        binutils-avr
        gcc-avr
        srecord

 

I have the AVR Arduino/Genuino debian version 1.0.5 but have never used it.   ARDUINO 1.8.4 2017.08.23  It also installed extra packages called  arduino-core extra-xdg-menus libjna-java and librtx-java

 

I already created the .hex file using a make file and the avr-gcc cross-compiler in 64-bitr Debian Linux.    Now I am ready to load the executable onto the IC and run it.

 

Late last fall I decided to buy the "FTDI Serial - 232 USB Cable" to load the .hex file from my linux PC to the microcontroller through a USB 3.0 cable.

 

However, it failed miserably using avrdude from the command line.      I never found a "hardware programmer" option that avrdude recognized that worked.     Later, I found an issue with one horizontal rail on the breadboard, so I rewired the chip onto a new breadboard without issues.     All my attempts to program the chip (i.e., load the hex file onto it) since with this device have failed all winter long.

 

My next thought was getting an Arduino UNO w/ a DIP version of the chip and switching the onboard chip with my ATMega328p DIP IC in order to upload the hex file onto it.    Then switch the chip out of the Arduino UNO and snap it back into my bread-boarded circuit in order to test the executable (just the basic flashing LED program).   $25

 

However, since ATMEL dropped the price of the Atmel-ICE programmer device in half, I am wondering if that might be a better option for me?   $65

 

Would this device work w/ Debian linux using USB 3.0 ?

 

I understand using this Atmel-ICE programmer  would enable me to pre-load a bootloader onto a "bare" ATmega328p chip -- is this correct?

 

Would its JTAG programming be helpful when I become an intermediate AVR programmer?

 

Am guessing this Atmel-ICE programmer device would allow me to "program" -- in the hardware sense -- other Atmel ICs besides the 8-bit ATmega328p ?

 

Would this Atmel-ICE programmer be harder to use than an Arduino UNO ? 

 

Are there any other reasons the AVR ICE programmer might be worth the extra cost ? . . .

 

for example,
Would using Atmel-ICE programmer allow me to write a serial stream of data for debugging a running executable on my target chip back to the PC?   In other words, does it use the USB channel as a bidirectional data bus for debugging?

 

Are there any other issues I should be aware of ?

 

This JTAG stuff is all new to me.   I don't understand what it allows.
I looked at the pdf user manual for the ATmel-ICE programmer.   But am unfamiliar w/ the alphabet soup -- JTAG, SPI, UPDI, SWD, TPI.

Would somebody familiar with these technologies please point me in the right
direction?

 

Obviously the blinking LED "Hello World" program is only the first step in a long process of developing and troubleshooting C programs and interrupts.

 

If I omitted anything important information from this introduction, please tell me.

 

Jeff

 

 

Last Edited: Thu. Feb 8, 2018 - 06:20 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What a hassle, just get an Arduino Nano plug in a usb cable and use the Arduino IDE to get started!  

You can add an ISP programmer or use another Nano as a programmer to load directly instead of using the bootloader....

The arduino IDE uses AVRDUDE to load the hex file using either serial bootloader or just about any ISP programmer, i.e. USBASP...

You can use AVRDUDE from the command line too for barebones loading.

 

Get started the easy way, add to your knowledge while your having fun, instead of all the frustration you have now working with bare chips! 

 

Jim

 

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

There are lots of ways to get started with AVR's.

My first AVR programmer was some software I found on the internet that could bitbang an AT902313 over the LPT port.

My second AVR programmer was an AT90S2313 with AN910 burned into it.

Both of the above options are available for avrdude. It supports quite a lot of different programming hardware.

Which makes it more difficult to set up.

 

I've thought for quite some time that Atmel's ICE was not supported under linux, but apparentlythat is a false assumption:

http://www.avrfreaks.net/search/site/ice%2520linux?so=0

 

JTAG (& Debugwire) does not only allow programming, but also debugging. In combination with the right software you cans place breakpoints, step through your code, and examine RAM contents, Registers, I/O, etc.

This will give you a pretty good idea what you can do with debugwire.

Note that this reverse engineered version lacks integration with GUI tools etc.

https://sites.google.com/site/wayneholder/debugwire

 

Most "hobby level" programmers use ISP only. The ICE does JTAG ( & probably debugwire ? )

A good "hobby level" ISP programmer is USBasp (from Tomas Fischl) and these used to be available for about USD2 from Ali / Ebay, but lately they seem to be putting software into those things which breakes easy software compatiblility with the

 

Yet another popular programmer seems to be USBTinyISP, but I have not used that one.

https://www.aliexpress.com/wholesale?SearchText=USBTinyISP

 

Even though I quite dislike the "arduino" environment, if you have an "arduino" compatible board it should be a no-brainer to get your first blinking led project going.

"arduino" boards usually also have an ISP connector and are therefore easily reusable for more "bare bones" projects.

There are also "arduino" programs with wich you can turn an "arduino" board into an ISP programmer, which is compatible with avrdude.

 

You will have to decide in which direction you want to go.

If you've chosen a direction we can probably help with discrete problems.

 

From your description it is not possible to give more fitting help. There are simply too many things which could have gone wrong for a first program:

- Is your hex file compiled & linked propperly?

- Compiled & programming for the right target processor.

- Why install srecord if you make (intel) hex files?

- Is everything wired properly? Short circuits, etc.

- Does your arduino chip actually have the bootloader programmed into it?

- Does your arduino chip have a crystal? (I think it should be 16MHz).

- Decoupling caps.

- udev troubles.

- Why USB 3? That does not have any advantage for low speed AVR stuff. Last time I tried USB3 was unreliable on my Linux Box.

 

Starting with a complete development board makes it much easier to get started.

"arduino nano" seems to bee a good choice. It doesn't have that horrible "arduino" pinout connector and is breadboard friendly:

https://www.aliexpress.com/whole...

 

Maybe Eric Steven Raymond's website on "how to ask questions the smart way" helps in formulating your questions in a way that can be more directly answered:

http://www.catb.org/~esr/faqs/smart-questions.html

Paul van der Hoeven.
Bunch of old projects with AVR's:
http://www.hoevendesign.com

Last Edited: Thu. Feb 8, 2018 - 09:02 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you for taking time to write.

 

"Most "hobby level" programmers use ISP only. The ICE does JTAG ( & probably debugwire ? )

A good "hobby level" ISP programmer is USBasp (from Tomas Fischl) and these used to be available for about USD2 from Ali / Ebay, but lately they seem to be putting software into those things which breakes easy software compatiblility with the"

 

I don't understand the difference between ISP and JTAG.     I will peruse the wayneholder/debugwire  URL you posted .

 

I know US3.0 speed isn't necessary.  It was the USB standard when I had my computer built.  I understand any USB device (like for example the Atmel ICE programmer) should signal to use its lower USB speed if it can't handle USB3.0 speed.

 

<

$ file blink_1MHz.hex
blink_1MHz.hex: ASCII text, with CRLF line terminators
jeff@neptune1:~/avr/blink_1MHz$ lsf  blink_1MHz.hex
-rw-r--r-- 1 jeff jeff 598 Jan 14 03:27 blink_1MHz.hex
jeff@neptune1:~/avr/blink_1MHz$ cat  blink_1MHz.hex
:100000000C9434000C943E000C943E000C943E0082
:100010000C943E000C943E000C943E000C943E0068
:100020000C943E000C943E000C943E000C943E0058
:100030000C943E000C943E000C943E000C943E0048
:100040000C943E000C943E000C943E000C943E0038
:100050000C943E000C943E000C943E000C943E0028
:100060000C943E000C943E0011241FBECFEFD4E050
:10007000DEBFCDBF0E9454000C9466000C940000BB
:100080008FEF84B987B98EEF8AB908950AC02AE53F
:100090000000000000000000000000002150C1F737
:1000A00001970097A1F708950E944000CFEFC8B9CB
:1000B000C5B9CBB984EF91E00E94460018B815B8D5
:1000C0001BB884EF91E00E944600F1CFF894FFCF77
:00000001FF

$ cat  blink_1MHz.c
/*
    5-10-07
    Copyright Spark Fun Electronics� 2007
    Nathan Seidle
    nathan at sparkfun.com
    
    ATmega168

        Example Blink
        Toggles all IO pins at 1Hz
*/

#include <avr/io.h>

//Define functions
//======================
void ioinit(void);      //Initializes IO
void delay_ms(uint16_t x); //General purpose delay
//======================

int main (void)
{
    ioinit(); //Setup IO pins and defaults

    while(1)
    {
                PORTC = 0xFF;
                PORTB = 0xFF;
                PORTD = 0xFF;
                delay_ms(500);

                PORTC = 0x00;
                PORTB = 0x00;
                PORTD = 0x00;
                delay_ms(500);
    }
   
    return(0);
}

void ioinit (void)
{
    //1 = output, 0 = input
    DDRB = 0b11111111; //All outputs
    DDRC = 0b11111111; //All outputs
    DDRD = 0b11111110; //PORTD (RX on PD0)
}

//General short delays
void delay_ms(uint16_t x)
{
  uint8_t y, z;
  for ( ; x > 0 ; x--){
    for ( y = 0 ; y < 90 ; y++){
      for ( z = 0 ; z < 6 ; z++){
        asm volatile ("nop");
      }
    }
  }
}

>

 

Last Edited: Fri. Feb 9, 2018 - 01:49 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

A good thing to skim for ISP and JTAG etc is On-chip Debugging chapter in a user guide for a debugger...

:: Morten

 

(yes, I work for Atmel, yes, I do this in my spare time, now stop sending PMs)

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

 

meolsen:    I am afraid I don't yet know where to find the "user guide for a debugger..."

to which you refer.

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

Hmmmm..............maybe I should consider using the Pololu USB AVR Programmer v2

detailed at https://www.pololu.com/product/3... $15

 

Would it be more likely to work w/ avrdude in linux than the FTDI Serial - 232 USB Cable I ( https://www.adafruit.com/product/70 it uses the FTDI chip) I had been using ?   $18

 

 

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

meolsen:    I am afraid I don't yet know where to find the "user guide for a debugger..."

to which you refer.

Just click the link....

:: Morten

 

(yes, I work for Atmel, yes, I do this in my spare time, now stop sending PMs)

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

The nega328 doesn’t have jtag, but it does have isp and debugwire. As explained by others, isp can only program/verify/erase the flash so your cheapy isp dongles will happily load the code onto the chip, you might want to use debugwire to debug your code on chip. For debugwire you need something more expensive like the atmel ice. You can debug using flashing leds and poking messages out the serial port but on chip debug is more powerful.
If you’re wanting to start out with a new chip, then maybe you should look at something a bit more modern. There’s a variety of devices based on the Arm cortex m0/4 that can be got for usd$5 and upwards for a board with a chip and debugger. And free linux tools if you choose carefully.

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

Kartman wrote:
For debugwire you need something more expensive like the atmel ice.
The mega328 issue in dwire-debug was fixed.

http://www.avrfreaks.net/forum/debugwire-usb-uart?page=1#comment-2300886

Kartman wrote:
There’s a variety of devices based on the Arm cortex m0/4 that can be got for usd$5 and upwards for a board with a chip and debugger.
Can't beat that as it's 9USD for megaAVR.

http://new.microchipdirect.com/product/Other?keywords=ATMEGA328PB-XMINI

 

Edit: 2nd URL

 

 

"Dare to be naïve." - Buckminster Fuller

Last Edited: Fri. Feb 9, 2018 - 02:43 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Jeff_embedded wrote:
Am guessing this Atmel-ICE programmer device would allow me to "program" -- in the hardware sense -- other Atmel ICs besides the 8-bit ATmega328p ?
Yes other than SAM9 and SAMA5 (those are by SAM-ICE)

Jeff_embedded wrote:
Would using Atmel-ICE programmer allow me to write a serial stream of data for debugging a running executable on my target chip back to the PC?
Yes via SPI or USART; via UART is in Power Debugger.

 


Atmel-ICE

Introduction to the Atmel-ICE

http://www.microchip.com/webdoc/GUID-DDB0017E-84E3-4E77-AAE9-7AC4290E5E8B/index.html?GUID-9CE8935E-37FA-47CB-8C59-5C15BA6E2105

Atmel-ICE is a powerful development tool for debugging and programming ARM Cortex-M based Atmel SAM and Atmel AVR microcontrollers with On-Chip Debug capability.

It supports:

...

http://www.microchip.com/developmenttools/productdetails.aspx?partno=at91sam-ice

Atmel-ICE

Connecting to Data Gateway Interface
http://www.microchip.com/webdoc/GUID-DDB0017E-84E3-4E77-AAE9-7AC4290E5E8B/index.html?GUID-8D4DA50A-2099-481B-82E5-7B4885B82F11

Power Debugger

Data Gateway Interface
http://www.microchip.com/webdoc/GUID-EAD481FD-28E6-4CD5-87FB-5165E7687C12/index.html?GUID-D768034C-7BF9-4FE0-8320-C89B72B35625

Power Debugger

CDC Interface

http://www.microchip.com/webdoc/GUID-EAD481FD-28E6-4CD5-87FB-5165E7687C12/index.html?GUID-09600EC6-FB0F-49BF-A51C-A633CAC281A9

http://www.microchip.com/Developmenttools/ProductDetails.aspx?PartNO=ATPOWERDEBUGGER

 

"Dare to be naïve." - Buckminster Fuller

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

Thank you, gchapman, for taking time to explain that.    And for the URLs, as all this stuff (like the Power Debugger) is new to me.

 

I see that the Atmel ICE is a debugger as well as a "hardware programmer".   Does this mean I can use it to look at register contents, single-step, show ATMega328p memory locations, and set breakpoints in the hex code from my linux PC using USB 3.0?     Or must a WIndows PC be used that has special driver firmware for the Atmel ICE added to it from Atmel's "front-end software packages" ?

 

I had gathered from the video on Wayne's Tinkering page that the undocumented debugwire could only be used on another MCU to debug the code on the target MCU.   

Is it possible to debug using only the target MCU if I use an Atmel ICE ?

 

Which would be easier for a newbie to learn w/ ATMega328p - Atmel ICE or the Atmel Power Debugger ?

Last Edited: Fri. Feb 9, 2018 - 04:49 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Jeff_embedded wrote:
Does this mean I can use it to look at register contents, single-step, show ATMega328p memory locations, and set breakpoints in the hex code from my linux PC using USB 3.0?
Yes if AVaRICE is built from its repository.

Atmel-ICE has a micro USB 2 connector so will need an adapter to go from USB 3.

Jeff_embedded wrote:
Or must a WIndows PC be used that has special driver firmware for the Atmel ICE added to it from Atmel's "front-end software packages" ?
Atmel-ICE firmware will likely be programmed via Atmel Studio.

Atmel Studio atbackend.exe communicates with Atmel-ICE firmware, or, AVaRICE communicates with Atmel-ICE firmware.

Jeff_embedded wrote:
Is it possible to debug using only the target MCU if I use an Atmel ICE ?
Atmel-ICE, Wayne's debugWIRE interface, dwire-debug

Jeff_embedded wrote:
Which would be easier for a newbie to learn w/ ATMega328p - Atmel ICE or the Atmel Power Debugger ?
Atmel-ICE

  • Complete enclosure (Power Debugger has a half shell enclosure)
  • Less expensive
  • Portable
  • If don't need UART via USB CDC ACM

 


http://avarice.sourceforge.net/

https://sourceforge.net/p/avarice/code/HEAD/tree/trunk/avarice/ChangeLog (search for edbg)

Atmel-ICE

Connecting to the Host Computer

http://www.microchip.com/webdoc/GUID-DDB0017E-84E3-4E77-AAE9-7AC4290E5E8B/index.html?GUID-FB14C49A-04A9-49A9-ADFF-D322070EE580

http://www.microchip.com/webdoc/GUID-ECD8A826-B1DA-44FC-BE0B-5A53418A47BD/index.html (Atmel Studio, search for atbackend)

Wayne's announcement thread :

AVR/Arduino Hardware Debugger on the Cheap

http://www.avrfreaks.net/forum/avrarduino-hardware-debugger-cheap

debugWIRE via USB UART
http://www.avrfreaks.net/forum/debugwire-usb-uart

 

"Dare to be naïve." - Buckminster Fuller