Wiring Forum
http://wiring.org.co/cgi-bin/yabb/YaBB.pl
Programming Questions & Help >> Programs >> Bootloader problem
http://wiring.org.co/cgi-bin/yabb/YaBB.pl?num=1287426339

Message started by SAzabi on 10/18/10 at 18:25:39

Title: Bootloader problem
Post by SAzabi on 10/18/10 at 18:25:39
Hello!
I got Olimex Atmega128 header board with 16Mhz crystal ans ICSP pinout. So, actually, it should be able to be flashed with Wired bootloader. I'm using AVR Pocker Programmer from Sparkfun and latest WinARV/avrdude. I've tried atmega128 bootloader, atmega128 bootloader with atmega1281 support and atmega128 bootloader with 7 sec delay. I even compiled one myself. And always I got validation error: 0x11!=0xff.
I've tried another bootloader (modified Hitec robonova, wich also uses atmega128, but with diff. crystal), and it flashes and verifies ok.
Tried different speed also. No help.
What could be the problem?

Title: Re: Bootloader problem
Post by SAzabi on 10/18/10 at 18:45:18
Update: opened hex files with ponyprog: they all consist of FFFF only.

Title: Re: Bootloader problem
Post by barragan on 10/18/10 at 18:52:28
hi, if the processor is atmega128 then you must use the atmega128stk500boot.hex, this bootloader wait for 3 seconds for new code to upload so this is good if the DTR line on the serial (ftdi or other) is attached to the RESET via a 100nF capacitor (this is for the autoreset feature). The other bootloader atmega128stk500boot_7SecondsDelay.hex was for older boards with no autoreset, so it waits for 7 seconds for the user to reset manually the board and upload code.
The other thing are the fuses, you can program them using the atmel avrstudio:
SPI enabled
Boot flash section size = 1024
Boot reset vector enabled
Brown-out detection level 4.0V
Brown-out detection enabled
CKOPT fuse enabled
Ext Crystal 16K CK + 64ms

Also, Wiring doesn't require the 32K XTAL anymore.

Let me know.

Title: Re: Bootloader problem
Post by barragan on 10/18/10 at 19:00:22
I've checked on the AVR-MT-128 and it should work fine. Just remember the pin mapping for the atmega128
PORTD are wiring pins 0-7
PORTC are wiring pins 8-15
PORTA are wiring pins 16-23
PORTB are wiring pins 24-31
PORTE are wiring pins 32-39
PORTF are wiring analog input pins 0-7 (or digital pins 40-47)
PORTG are wiring pins 48-53

the 32Khz in the original design is NO longer used/needed.


Title: Re: Bootloader problem
Post by SAzabi on 10/18/10 at 19:45:08
Thanks for answering!
I dont't have 32Khz crystal there - desoldered it long time ago. Also, I've found out PORT to pins configuration also (but thanks anyway).
I thought if I will not touch fusebits they will be by default. Could it be the problem?

Title: Re: Bootloader problem
Post by barragan on 10/19/10 at 03:22:44
Yes, the fuses I mentioned are not the default on the atmega128 uses, you have to set them first.

Title: Re: Bootloader problem
Post by SAzabi on 10/19/10 at 14:03:39
Changed fuses - still error. I've just noticed, that hex file is only 5Kb. I believe it should be bigger?

Title: Re: Bootloader problem
Post by barragan on 10/19/10 at 15:11:02
Please use the hex from the wiring code website.

Title: Re: Bootloader problem
Post by SAzabi on 10/19/10 at 16:13:26
I do! I've tried every hex from wiring website. I can't connect my svn client to repository, so downloaded directly. Mabe because of that error appears?
Could you, please attach it here?

Title: Re: Bootloader problem
Post by barragan on 10/19/10 at 23:56:24
I can't attach files send me an e-mail and I will send you the file. The only bootloader that work with your board is the atmega128stk500boot.hex or the atmega128stk500boot_7SecondsDelay.hex, it has to be flashed (loaded in the Flash memory) and setup the fuses accordingly.
I've tested svn co svn://aeon.uniandes.edu.co/wiring/trunk/wiring and it works well, it should get you a copy of the whole source tree.
What is the error you're getting? How are you programming the fuses?

Title: Re: Bootloader problem
Post by SAzabi on 10/20/10 at 04:31:11
Hooray! Finally, I was able to flash it. Bootloader - atmega128stk500boot.hex, programmer - AVR Pocket Programmer from Sparkfun (usbtiny actually).
Verification error was on 0x1f800 (nt sure I'm right, don't have it near me at the moment), It's code beginning actually.
Avrdude wasn't able to deal with this error even when I've chosen atmega 1280 or 1281.
Later I found way to use AVRStudio with usbtiny (on ladyada website, you'll need few apps to connect usbtiny and AVRStudio).
I programmed fusebits with AVRStudio, all as you sad, barragan.
Tried to flash - somekind or error appeared (atmega128 was chosen in options).
Changed atmega128 on atmega1281 in AVRStudio connection options and, tada!, I'm able to flash my atmega128 from it and it verifies!
Will try to load some code today to check if it flashed properly.
barragan, thanks for the help with fuses!

P.S. but still no luck with avrdude)))

Title: Re: Bootloader problem
Post by barragan on 10/20/10 at 20:42:18
great, what is the problem with avrdude? Remember if your olimex board doesn't have the auto-reset (serial DTR connected to RESET) you need to press the olimex board reset switch just right after pressing the upload button on the Wiring environment. By pressing the reset button the bootloader gets ready to receive the new code from the Wiring software.

Title: Re: Bootloader problem
Post by SAzabi on 10/21/10 at 05:20:18
No idea what the problem:) I don't mind until I can use AVRStudio:) Anyway, I have to chose atmega1281 to be able to flash board.

Olimex board does not have reset button. I've connected reset leg of atmega to dtr via capacitor (around 270 nF, the smallest I have at the moment). It works.
The other problem appeared is that I'm using Inex UCON232S USB to Serial Converter (based on ft232R chip). It appears as com2 in system. I setup Wiring Software, choose atmega128, firmware v.2 and com2. But all stucks on Uploading. Wiring compiles .hex file, starts avrdude, avrdude send something out, but receives no answer from atmega128.
First, I've connected UCON232S and atmega as on Wiring board scheme to legs num 2 and 3. No effect. In wiring mini board description says we should use pins 32, 33.  Tried that ones - no effect again.
Thinking on that yet.
Tried to flash hex directly through avrstudio (used LED blink tutorial code) - and it works, LED turns on/off according to timing specified.
But Wiring does not connect to board itself, don't know why yet.

P.S. Could it be serial port speed issue?

Title: Re: Bootloader problem
Post by barragan on 10/21/10 at 05:51:32
yes it might be related to speed, for the bootloader is 115200, but there is no chance for it to work flashing it as an atmega1281 since your chip is the atmega128. Let me know.

Title: Re: Bootloader problem
Post by SAzabi on 10/21/10 at 08:27:28
But it does flash as atmega1281. And it does not as atmega128. On the chip it signed as atmega128. Don't know why that so.
The main problem now is to connect Wiring software and board.
Btw, which atmega128 pins should I connect to RX/TX on ftdi chip? 32/33 as in Wiring Mini descriptio or 2/3 as in "big" Wiring board scheme?

Title: Re: Bootloader problem
Post by barragan on 10/21/10 at 13:50:31
2 and 3 also exist in the Mini, 2 and 3 are Serial1 and 32 and 33 are Serial Rx/Tx in both schematics Wiring big and Mini 32 and 33 are the ones going to the FTDI, that's the Serial port used by the bootloader and for programming the board.
Yes your chip must be flashed as atmega128, do a chip erase (in the loading the bootloader using avrstudio). Also check avrstudio can properly read the chip signature. Set fuses, burn bootloader hexfile, set the bootloader protection to Mode 3 (third tab on the programming window of the avrstudio)

Title: Re: Bootloader problem
Post by SAzabi on 10/21/10 at 18:33:49
Ok, I was confused with pin numbers, thought 32/33 are of atmega128 numering, not Wiring board.
Anyway. Erase gave nothing. I'm still able to flash fusebits only when I chose IC as atmega128. I'm not able to flash bootloader or program.
If I chose atmega1281 in options, I am able to flash bootloader and program and it works (tried led blink).
All that goes in AVRStudio.
As I wrote, I use Inex usb to com stick. It works just great with my robonova - it also flashes via serial port.
But when I try to upload program through Wiring software it just stucks. Avrdude sends something to port and reveives nothing back.
I've soldered atmega128 pin 2 on TX pin of stick and pin 3 or RX pin (tx pin marked on db9 as pin 3, rx as pin 2).
I use

Title: Re: Bootloader problem
Post by worapoht on 10/21/10 at 18:53:37

SAzabi wrote on 10/21/10 at 18:33:49:
I've soldered atmega128 pin 2 on TX pin of stick and pin 3 or RX pin (tx pin marked on db9 as pin 3, rx as pin 2).
I use

no.. no.. if you mean Inex's UCON-232S blue stick , output signal from DB9 is RS-232 level not 5V logic level which connect to AVR's chip.
for modificiation on small blue stick is hard way that I'd not recommend to do..
You need MAX232 IC & circuit to translate RS-232 Level back to Logic.
or change USB converter to single FTDI chip only such as Sparkfun's FTDI basic breakout board
http://www.sparkfun.com/commerce/product_info.php?products_id=9115

this will be okay..

Title: Re: Bootloader problem
Post by SAzabi on 10/22/10 at 03:40:14
Thanks! Just looked at datasheet of another IC placed on Inex stick (Hin213...) and found it to be level converter. Stupid me)
Have to make breakboard for my ft232rl chip.
Thank you!

Wiring Forum » Powered by YaBB 2.5 AE!
YaBB Forum Software © 2000-2010. All Rights Reserved.