Author Topic: Programming an ATmega128, what way to go best?  (Read 2914 times)

0 Members and 1 Guest are viewing this topic.

Offline Random Model MakerTopic starter

  • Regular Contributor
  • *
  • Posts: 62
  • Country: lu
  • This profile has been abandoned. I'm now "RedLion"
Programming an ATmega128, what way to go best?
« on: July 10, 2018, 10:50:34 am »
Hello beautiful people,

I am currently at work (student intern) and I am trying to program an ATmega128, on a board, with an Arduino sketch. So far I have tried to program it with an Arduino ISP thing (this: https://store.arduino.cc/arduino-isp), but AVRdude always returns "invalid device signature".

So the goal is to program the board with either the Arduino sketch or the exported Hex file via Atmel Studio 7.
The board has both an ISP and JTAG port, with the following caveats:
- To the PDI and PDO pins of the ISP also connects a MAX232 through 4.7kOhms resistors
- I don't know if the JTAG is activated on the ATmega, as it has never been programmed before, it is "fresh out of the box".

There are various methods to program this thing that I can find at my workplace:
- A Segger J-Link Edu
- A Segger Atmel SAM-ICE
- Two Arduino UNO's
- Said Arduino ISP
- A selection of Altera and Xilinx programmers
- BUT nobody seems to have a real ISP programmer
To the best of my knowledge, none of the programmers are actually compatible, I don't know if I can program the ATmega with the Arduino stuff via Atmel Studio 7, and through the Arduino IDE it doesn't seem to work.   |O
Would it maybe help to take out the resistors and disconnect the MAX232? That would definitely make testing the serial port rather tedious. :(
It would not be dramatic if I had to buy an ISP programmer of some sort with company money, given that they do not cost a fortune, but it would mean I had to wait for another week until I can get going.
I'd think of something clever to say, but I got nothing, so I just won't.
 

Offline Random Model MakerTopic starter

  • Regular Contributor
  • *
  • Posts: 62
  • Country: lu
  • This profile has been abandoned. I'm now "RedLion"
Re: Programming an ATmega128, what way to go best?
« Reply #1 on: July 10, 2018, 12:50:31 pm »
Hang on everybody, I have to backpedal a second.  :palm:

We have a genuine PEBCAK:
I confused PDI and PDO on the PCB! |O

Flipped the leads and sure enough. Miracle.  :-[

Sorry for wasting your time everybody
I'd think of something clever to say, but I got nothing, so I just won't.
 
The following users thanked this post: bd139

Offline ljwinkler

  • Supporter
  • ****
  • Posts: 48
  • Country: ie
    • LJ Winkler's blog
Re: Programming an ATmega128, what way to go best?
« Reply #2 on: July 10, 2018, 01:31:48 pm »
The invalid device signature could be because you may be using a different version of the chip. I found these:

ATmega128A       1e9702
ATmega128RFA1  1ea701
ATmega128         1e9702


It's a common problem in the Arduino world, mixing the -P version with the non-P one.

In the matter of programming... You can load Arduino bootloader and then just simply use the cheapest USB2Serial cable.
You can find more details here: https://forum.arduino.cc/index.php?topic=134382.0 or here: https://github.com/MCUdude/MegaCore
There is a section describing contents of the boards.txt file where you define your board.

I personally use AtmelStudio with VisualMicro add-in (https://www.visualmicro.com/). It adds Arduino's IDE functionality (libraries, boards, etc.) to AtmelStudio. There is also a debugging part. Some of the advanced functions are in the paid version (as of now the licence is $30 for 1PC).

If you want an ISP - I use AVRdragon. It also supports high voltage programming for more stubborn (or 'bricked') MCUs. It comes very handy if you play with fuses and lock yourself out :)
Please note that loading program using ISP will overwrite the Arduino bootloader and you won't be able to use the USB2Serial to program it until you burn the bootloader again.
The bootloader is simply a very small program that waits for the data coming over serial and the chip then programs itself in the memory range specified by the fusebits (it is after the bootloader reserved space).

Or you can go fancy and use the Atmel's.... sorry, Microchip's ICE programmer.


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf