Author Topic: How bloody hard can it be to program an AVR chip?  (Read 37442 times)

0 Members and 1 Guest are viewing this topic.

Offline olsenn

  • Frequent Contributor
  • **
  • Posts: 993
Re: How bloody hard can it be to program an AVR chip?
« Reply #125 on: July 29, 2013, 10:50:31 pm »
The AVR ISP MKII should work just fine in AVR Studio 6. Just make sure when in the programming window to select the correct target board and check that the checksum is correct. Then you should be able to load in the .hex file and program it directly to the chip. If you are getting invalid checksums, try lowering the programming clock frequency
 

Offline c4757p

  • Super Contributor
  • ***
  • Posts: 7805
  • Country: us
  • adieu
Re: How bloody hard can it be to program an AVR chip?
« Reply #126 on: July 29, 2013, 10:58:07 pm »
The AVR ISP MKII should work just fine in AVR Studio 6.

Flip back a couple pages..... he chose not to use it.
No longer active here - try the IRC channel if you just can't be without me :)
 

Offline Stonent

  • Super Contributor
  • ***
  • Posts: 3824
  • Country: us
Re: How bloody hard can it be to program an AVR chip?
« Reply #127 on: July 31, 2013, 04:02:11 pm »
1. Flash the AVR as ISP sketch into your Arduino and wire it up.
2. Program with AVRDude.

The larger the government, the smaller the citizen.
 

Online EEVblog

  • Administrator
  • *****
  • Posts: 28916
  • Country: au
    • EEVblog
Re: How bloody hard can it be to program an AVR chip?
« Reply #128 on: July 31, 2013, 08:54:08 pm »
Sure, but that's a driver issue, a pretty GUI won't fix that.

Did I ever say it would?
 

Online EEVblog

  • Administrator
  • *****
  • Posts: 28916
  • Country: au
    • EEVblog
Re: How bloody hard can it be to program an AVR chip?
« Reply #129 on: July 31, 2013, 08:58:14 pm »
Flip back a couple pages..... he chose not to use it.

You'll find that I DID use AVR Studio initially, because that is what I always use for my AVR stuff.
It was the github download that was the problem, and that led me to trying avrdude without success.
Once I realised the github goof I simply went back to AVR studio and it worked first go.

The amount of misinformation in this thread has been staggering.
 

Offline casper.bang

  • Frequent Contributor
  • **
  • Posts: 311
  • Country: dk
  • Pro SE, amateur EE.
    • BangBits
Re: How bloody hard can it be to program an AVR chip?
« Reply #130 on: July 31, 2013, 09:50:39 pm »
The amount of misinformation in this thread has been staggering.

No offence Dave, you spent a large part of the first 45min of the 5h live video ranting about avrdude, drivers and avrstudio. After confirming firewalker's solution you could've marked the thread as fixed and/or edited your original post summarizing your mistake.  :-//
 

Online EEVblog

  • Administrator
  • *****
  • Posts: 28916
  • Country: au
    • EEVblog
Re: How bloody hard can it be to program an AVR chip?
« Reply #131 on: July 31, 2013, 09:57:25 pm »
No offence Dave, you spent a large part of the first 45min of the 5h live video ranting about avrdude, drivers and avrstudio.

Because in my experience they have been a PITA. AVR Studio included.

Quote
After confirming firewalker's solution you could've marked the thread as fixed and/or edited your original post summarizing your mistake.  :-//

Done.
 

Offline Stonent

  • Super Contributor
  • ***
  • Posts: 3824
  • Country: us
Re: How bloody hard can it be to program an AVR chip?
« Reply #132 on: August 01, 2013, 05:16:35 am »
Just thinking... Shouldn't something like the Makerbot use a through hole chip instead of SMD because of things like this?  Just pop out and pop in?
The larger the government, the smaller the citizen.
 

alm

  • Guest
Re: How bloody hard can it be to program an AVR chip?
« Reply #133 on: August 01, 2013, 05:32:31 am »
And then? Pop it into a devboard connected to the same programmer that failed to work? The problem was not in system programming, that worked just fine once Dave got the correct hex file and programming software.
 

Offline A Hellene

  • Frequent Contributor
  • **
  • Posts: 583
  • Country: gr
Re: How bloody hard can it be to program an AVR chip?
« Reply #134 on: August 01, 2013, 05:55:28 am »
It is a fact that AVR Studio 6 is a bloated piece of crapware. Whenever I am able to, I am still using the lightweight (in comparison) AVR Studio 4.19 (build 730) that also plays nicely with WinAVR (for any possible issues of AS 4.19 with WinAVR, please read this).

As for using poorly constructed programmers, I think that the following information might shed some light on the possible problems might arise from using "affordable" programmers:

The AVR line has two FLASH memory spaces: The firmware memory space, which is fully accessible by the User in R/W fashion, and the calibration memory space where the calibration/signature/etc. chip data is stored. That special memory space size is one page long (varying from 8..128 words for every chip family or FLASH size) and it is accessible through special undocumented programming instructions.

Now, if the ISP data cable is long enough (or poorly constructed) a programming instruction opcode can be corrupted and randomly match the opcode of an undocumented instruction, most commonly resulting in erasing the target chip calibration data space! That happens because the ISP protocol erase_cal_space instruction opcode is only four bytes long (just as the FLASH/EEPROM chip_erase instruction also is), and different in one bit only from the chip_erase opcode! The documented FLASH/EEPROM Memories Chip_Erase opcode is '0xAC 0x80 0x00 0x00' and the undocumented erase_cal_space opcode is '0xAC 0xC0 0x00 0x00'.

I have found out some of those undocumented opcodes by using a custom, fully configurable AVR programmer I designed back in 2002, that supports all the ISP/HVPP/HVSP modes, by later adding to its firmware some intelligent opcode searching/verification algorithms.


Custom AVR Programmer

Anyway, if the calibration data space is erased, then the chip signature will be reset and read FF.FF.FF! The signature will be read as 00.01.02 if the programming protocol is parallel (HVPP) and the target chip is missing, resulting in the programmer hardware reading back the address it has just sent to the missing target chip, since the same 8-bit data port of the target chip is used for data and for address transmission as well. The same also applies to the serial ISP programming protocol.

These are the contents of the first four data words (residing at the calibration address space 0x000..0x003) of the 64 data words stored at the calibration data space of a ATMega328-PU:

Custom AVR Programmer, m328 calibration space 0x000..0x003: The cursor points at the higher nybble of the [L]ow byte of the Word at 0x[000], according to the obscure '000L' information at the beginning of the first LCD line.
The User accessible data are the signature bytes (1E.95.14) and the 8 MHz oscillator calibration byte (0x8F).

This is the complete calibration space data dump of that specific chip above, as reported by the programmer through its UART line:
Code: [Select]
ATnega328
0x0000: 1E.8F 95.FF 14.D1 FF.26 FF.0B FF.17 FF.FF 4A.31
0x0008: 34.30 36.34 FF.03 1E.04 17.01 12.05 13.05 FF.FF
0x0010: FF.FF FF.FF FF.FF FF.FF FF.FF FF.FF FF.FF B8.87
0x0018: BC.55 53.63 AE.8F C3.46 B9.75 99.0F 57.0B D4.0E
0x0020: FF.FF FF.FF FF.FF FF.FF FF.FF FF.FF FF.FF FF.FF
0x0028: FF.FF FF.FF FF.FF FF.FF FF.FF FF.FF FF.FF FF.FF
0x0030: FF.FF FF.FF FF.FF FF.FF FF.FF FF.FF FF.FF FF.FF
0x0038: FF.FF FF.FF FF.FF FF.FF FF.FF FF.FF FF.FF 75.06

These are the signature bytes read with the m328 programming socket populated in the first picture, and with the socket empty in the second one:

Custom AVR Programmer, m328 signature read


Custom AVR Programmer, empty socket signature read

-George
Hi! This is George; and I am three and a half years old!
(This was one of my latest realisations, now in my early fifties!...)
 

Offline millerb

  • Regular Contributor
  • *
  • Posts: 71
  • Country: us
Re: How bloody hard can it be to program an AVR chip?
« Reply #135 on: August 01, 2013, 06:16:20 am »
AVR dude on Windows is an exercise in frustration. Prebuilt bins lag behind current by a good margin and are infrequently updated along with occasional bullshit driver issues which waste time sorting out. Rolling your own windows binary from latest is unpractical for most except for guys who understand how to setup and utilize the tool chain required to get the job done.

These problems are a non-issue in Linux land. For example, in Ubuntu, to get up and rolling all you'll need to do is "sudo apt-get install avrdude", 30 seconds later you're good to go. If you want to compile the latest it's just the standard "./configure, make, make install" routine, though you may need to fetch some libs first. Not much point in it though if you're going to use Atmel's development suite.

I never bother with it on either platform. Avrdude with a $10 programmer is only an inexpensive solution if your time has no value.
 

alm

  • Guest
Re: How bloody hard can it be to program an AVR chip?
« Reply #136 on: August 01, 2013, 09:07:44 am »
It works better under Linux than AVR studio ;). And it works fine with most Atmel programmers, especially in automated scripts. What's the advantage of stk500.exe or whatever the new version is called over avrdude? In both cases you look up the necessary parameters once and put them in a script.
 

Offline senso

  • Frequent Contributor
  • **
  • Posts: 867
  • Country: pt
    • My AVR tutorials
Re: How bloody hard can it be to program an AVR chip?
« Reply #137 on: August 01, 2013, 09:39:44 am »
Can I rant a bit mom?
I have used my AvrDragon and (shivers) arduinos with avrdude a LOT, under windows vista, 7, and a lot of debian and ubuntu flavours, never had a problem, try to use a freaking pickit3?
Oh excuse me sir, looks like you bought and old pickit3 that fails to update its firmware and bricks, Microchip gave me a new one, and I cant use the new one directly with MpLabX, only with the standalone program that half the time barks java exceptions like there is no tomorrow..
And don't even get me started on the crappy IDE that microchip has, jezzz
 

Offline ve7xen

  • Frequent Contributor
  • **
  • Posts: 657
  • Country: ca
    • VE7XEN Blog
Re: How bloody hard can it be to program an AVR chip?
« Reply #138 on: August 01, 2013, 09:41:26 am »
The problem is Windows' lack of a unified USB API and shitty driver model, not avrdude. Let's place the blame where it belongs.

I find when you start messing with drivers and weird hacks to use your oddball stuff or do oddball things it's time to boot Linux where things just work (tm). As is the case here.
73 de VE7XEN
 

Offline free_electron

  • Super Contributor
  • ***
  • Posts: 7160
  • Country: us
    • SiliconValleyGarage
Re: How bloody hard can it be to program an AVR chip?
« Reply #139 on: August 01, 2013, 11:18:35 am »
The problem is Windows' lack of a unified USB API and shitty driver model, not avrdude. Let's place the blame where it belongs.

I find when you start messing with drivers and weird hacks to use your oddball stuff or do oddball things it's time to boot Linux where things just work (tm). As is the case here.

eh. that's not true. winusb is the built-in uniform USB access layer.. it's just that nobody uses it ... they all want to muck around with libusb and other 3rd party crap....

@senso  : let me rant a bit...

Why don't you all take your PIC's and AVR's, and their development tools, push em together in a big pile , run over em repeatedly with some heavy trucks, douse the remainders in some gasoline and set them on fire.

And then switch to a nice ARM Cortex based machine like an STM32 cpu. They have a 32 bit processor for 32 cents now ... in SO package.  You can't beat that !

http://www.st.com/web/en/press/p3444

Professional Electron Wrangler.
Any comments, or points of view expressed, are my own and not endorsed , induced or compensated by my employer(s).
 

Offline ve7xen

  • Frequent Contributor
  • **
  • Posts: 657
  • Country: ca
    • VE7XEN Blog
Re: How bloody hard can it be to program an AVR chip?
« Reply #140 on: August 01, 2013, 11:27:31 am »
eh. that's not true. winusb is the built-in uniform USB access layer.. it's just that nobody uses it ... they all want to muck around with libusb and other 3rd party crap....
Ah, I stand corrected, I had never heard of this. I guess it's just the Linux heritage ported to Windows problem.

That said, I had problems with Atmel's 'official' libusb drivers (Jungo or something?) myself as well. Very picky about driver versions and blah.

Quote
Why don't you all take your PIC's and AVR's, and their development tools, push em together in a big pile , run over em repeatedly with some heavy trucks, douse the remainders in some gasoline and set them on fire.

And then switch to a nice ARM Cortex based machine like an STM32 cpu. They have a 32 bit processor for 32 cents now ... in SO package.  You can't beat that !

http://www.st.com/web/en/press/p3444
I've done a bit of each and as far as the free tools are concerned, AVR and MSP430 are orders of magnitude easier to get working than ARM. Just bringing a toolchain from compiled to compiling running code is a chore, requiring linker scripts, startup code, libc stubs etc. to be provided by the user while this is mostly automated in AVR and MSP430 tools.

The ARM chips are powerful, cheap, and flexible but the variety means you basically need to do all this junk manually every time you use one, and especially for someone not steeped in embedded development it's not an easy task and certainly not well documented. The manufacturers seem to expect you to just shell out for the $500-5000 tools where it's all built in.

Oh and let's not mention the variety of JTAG gizmos, ISP protocols and software you might need to use to load code into them...

ARM is great, but if we're in 'how bloody hard can it be just to <insert trivial-seeming task> ?' territory, I think it will easily win that contest on almost every count as well.
73 de VE7XEN
 

Offline Rufus

  • Super Contributor
  • ***
  • Posts: 2094
Re: How bloody hard can it be to program an AVR chip?
« Reply #141 on: August 01, 2013, 12:50:44 pm »
Quote from: free_electron link=topic=18725.msg270337#msg270337
And then switch to a nice ARM Cortex based machine like an STM32 cpu. They have a 32 bit processor for 32 cents now ... in SO package.  You can't beat that !

http://www.st.com/web/en/press/p3444

Because no one has any in stock and when Mouser do the price will be from 58 to 97 cents 2000 off and when ST can't shift millions of them to eek out a living in the cut-throat ARM market they will make them obsolete and he will have to redesign and re-qualify his product. ST have a shit web site and shit technical support to.

If it can do the job and 8 bit PIC from the 90's which Microchip still sell easily beats a 32bit ARM from ST that you can't buy any more.
 

Offline andyturk

  • Frequent Contributor
  • **
  • Posts: 891
  • Country: us
Re: How bloody hard can it be to program an AVR chip?
« Reply #142 on: August 01, 2013, 01:14:13 pm »
I've done a bit of each and as far as the free tools are concerned, AVR and MSP430 are orders of magnitude easier to get working than ARM. Just bringing a toolchain from compiled to compiling running code is a chore, requiring linker scripts, startup code, libc stubs etc. to be provided by the user while this is mostly automated in AVR and MSP430 tools.

No need to compile an ARM toolchain from source, just download one from here.

I've never touched AVR, but I've used MSP430 "professionally" and the tools provided by TI make me tear my hair out (what little there is left). The MSP430 is fine if you stay within the 64K boundary, but going beyond that limit turns it into a wicked hack. ARM with it's 32-bit design, is smooth and creamy all the way from tiny sub $1 parts up to M4 monsters. Combine that with a GCC toolchain that pretty much "just works", and it's a great architecture--well worth your time to get comfortable with.

Quote
The ARM chips are powerful, cheap, and flexible but the variety means you basically need to do all this junk manually every time you use one, and especially for someone not steeped in embedded development it's not an easy task and certainly not well documented. The manufacturers seem to expect you to just shell out for the $500-5000 tools where it's all built in.

Hey, fifteen bucks buys you a STM32F4Discovery board. It's got one of those monster M4 mcus on it (1M flash and 192K RAM!), plus an on-board programmer that you can use for any other STM32 mcu. It's gotta be one of the best deals out there. And if you're an RTOS fan, then check out ChibiOS (www.chibios.org). The guy who wrote the kernel works for ST and most of their mcus are supported out-of-the-box. It's got a really active community and the quality of the code is amazing for an open source project. Check it out!
 

Offline ve7xen

  • Frequent Contributor
  • **
  • Posts: 657
  • Country: ca
    • VE7XEN Blog
Re: How bloody hard can it be to program an AVR chip?
« Reply #143 on: August 01, 2013, 05:23:27 pm »
No need to compile an ARM toolchain from source, just download one from here.
Compiling the tools is the easy part and not what I was talking about. It's the boilerplate required just to get a hello world running. You're not going to have a working linker script, libc stuff sometimes causes problems, etc. I'd never touched a linker script before realizing (hours in of course) that I needed one, and documentation on them wasn't that easy to find. When I did find it, it requires digging through the data sheets and arch guides to find memory maps for your particular mcu and mapping it correctly (don't forget the correct stack identifiers for your other tools!). None of this is likely a big deal for an experienced embedded developer, but I consider myself a fairly proficient amateur, I have a computer science education and have been writing micro code for AVR for 5 or 6 years, and this took me 3 or 4 tries and many hours to get working the first time. Then I needed a larger stack and... Well you get where this is going. By contrast the AVR and MSP gcc tools just do the sensible thing with no input from me.

Once I got that working, yeah the arch is great and I have no complaints, but I don't really relish the thought of other noobs thinking it's as easy as AVR and jumping into it.

Quote
I've never touched AVR, but I've used MSP430 "professionally" and the tools provided by TI make me tear my hair out (what little there is left). The MSP430 is fine if you stay within the 64K boundary, but going beyond that limit turns it into a wicked hack. ARM with it's 32-bit design, is smooth and creamy all the way from tiny sub $1 parts up to M4 monsters. Combine that with a GCC toolchain that pretty much "just works", and it's a great architecture--well worth your time to get comfortable with.

Haven't worked with the larger MSP processors, and only used mspgcc which is I think unofficial. In my experience its also been painless.

Quote
Hey, fifteen bucks buys you a STM32F4Discovery board. It's got one of those monster M4 mcus on it (1M flash and 192K RAM!), plus an on-board programmer that you can use for any other STM32 mcu. It's gotta be one of the best deals out there. And if you're an RTOS fan, then check out ChibiOS (www.chibios.org). The guy who wrote the kernel works for ST and most of their mcus are supported out-of-the-box. It's got a really active community and the quality of the code is amazing for an open source project. Check it out!
I've got one of the TI stellaris m4 launch pads and various other cortex demo boards. Mostly playing with the cortex m0 discovery board right now. I've been meaning to try out chibios, it looks interesting for sure. I've not experimented with rtos before.
73 de VE7XEN
 

Offline firewalker

  • Super Contributor
  • ***
  • Posts: 2316
  • Country: gr
Re: How bloody hard can it be to program an AVR chip?
« Reply #144 on: August 01, 2013, 06:01:16 pm »
It is a fact that AVR Studio 6 is a bloated piece of crapware. Whenever I am able to, I am still using the lightweight (in comparison) AVR Studio 4.19 (build 730) that also plays nicely with WinAVR (for any possible issues of AS 4.19 with WinAVR, please read this).

As for using poorly constructed programmers, I think that the following information might shed some light on the possible problems might arise from using "affordable" programmers:

The AVR line has two FLASH memory spaces: The firmware memory space, which is fully accessible by the User in R/W fashion, and the ...

-George

With some parts was able to accidentally do it relatively easy (FF:FF:FF:FF sign). With AT90S2313 and AT90S1200. Did you noticed something similar or was something wrong with me and those chips?

And where is the link for your programmer?  :-+ :-+ :-+
Become a realist, stay a dreamer.

 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2898
  • Country: us
Re: How bloody hard can it be to program an AVR chip?
« Reply #145 on: August 01, 2013, 07:43:35 pm »
Quote
I have found out some of those undocumented opcodes
Neat!  Thanks for the info.

I don't suppose you've seen these written up anywhere, or written about what you've found yourself?
 

Offline A Hellene

  • Frequent Contributor
  • **
  • Posts: 583
  • Country: gr
Re: How bloody hard can it be to program an AVR chip?
« Reply #146 on: August 01, 2013, 10:09:41 pm »
With some parts was able to accidentally do it relatively easy (FF:FF:FF:FF sign). With AT90S2313 and AT90S1200. Did you noticed something similar or was something wrong with me and those chips?

And where is the link for your programmer?  :-+ :-+ :-+
Alexander, I did not design that custom programmer in order to be fiddling with the AVR configuration memory space.

The idea was to become able to be restoring the mangled fuses by the press of a single button, besides being able to program the target AVR chips! This is why I called that device an "Off-Line AVR Fuse Editor" in 2002, when I designed it; and, by then, the (8kB FLASH) m8515 master chip was more than adequate to be accessing the target AVRs Fuse and Program/Data spaces.


"Off-Line AVR Fuse Editor" initial design.

In 2004 I was forced to upgrade the programmer by changing the master chip with the 16kB FLASH m162, in order to add the extra functionality of searching for any possible undocumented programming commands by redesigning the device's programming engine almost from scratch!


I don't suppose you've seen these written up anywhere, or written about what you've found yourself?
Though I have not published any of my discoveries related to these undocumented programming commands, except of the erase_calibration_memories I have previously described, and of the announcement of the existence of such a custom programmer in that 2004 post above, there is at least one more AVRFreaks member (KKP) who has done something similar in 2006, fiddling with the configuration memory space of tiny13 by the use of his own custom programmer.


-George
Hi! This is George; and I am three and a half years old!
(This was one of my latest realisations, now in my early fifties!...)
 

Online andersm

  • Super Contributor
  • ***
  • Posts: 1001
  • Country: fi
Re: How bloody hard can it be to program an AVR chip?
« Reply #147 on: August 01, 2013, 11:45:05 pm »
eh. that's not true. winusb is the built-in uniform USB access layer.. it's just that nobody uses it ... they all want to muck around with libusb and other 3rd party crap....
With WinUSB you still need to muck around with custom INF files and other Windows headaches. It seems in Windows 8 they added a "generic" INF file that works - as long as the device includes a Microsoft-specific descriptor.

Offline free_electron

  • Super Contributor
  • ***
  • Posts: 7160
  • Country: us
    • SiliconValleyGarage
Re: How bloody hard can it be to program an AVR chip?
« Reply #148 on: August 02, 2013, 12:46:01 am »
No need to build your own toolchain.
ST Gives you a free one. And you can download tools from Atollic, Keil, IAR and plenty others. They work out of the box.

ST provides libraries for all peripherals. Just include the header file and off you go.
If you want it even easier : go get the compiler form Mikroe. I am using their Basic compiler for ARM. Works like a charm (yeah yeah , laugh all you want... Basic . Haha. I'm up and running in no time)

They let you compile 5k for free. That's a pretty large program. And the paid version is only 199$ with free update for life.

They have a nice arm based development board as well for 159 . One button and led per pin and you can even plonk huge devices with ethernet on them. Touc screen color lcd .. It's all there.. Including all libraries.

And it works with the standard jlink or stlink or their own (which is a true stlink) programmer /debugger
Professional Electron Wrangler.
Any comments, or points of view expressed, are my own and not endorsed , induced or compensated by my employer(s).
 

Offline andyturk

  • Frequent Contributor
  • **
  • Posts: 891
  • Country: us
Re: How bloody hard can it be to program an AVR chip?
« Reply #149 on: August 02, 2013, 03:16:48 am »
I am using their Basic compiler for ARM.

Nope, I don't believe it. You're just saying that to give us "code monkeys" indigestion.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf