Go Down

Topic: Help in programming the Atmega1284 with maniacbug-mighty-1284p. (Read 28116 times) previous topic - next topic

leo72

During the last days I did a lot of tests trying to solve the problem.
If you're using the Mighty-1284p files by maniacbug, select the board "Mighty 1284p 16 MHz w/Optiboot" then put a 220K resistor in series on the line beetween the FT232 TX and the 1284p RX0 pins.

If you're using the "Original Mighty 1284p" board, then you could try with a 120K R. Or, maybe, without components.

With my 1284P, I was able to flash a sketch using a 175K over the line beetween my Arduino UNO R1 RX pin and the 1284P RX0 pin when I chose the 1284p board. Using the "Original Mighty" board, I was able to flash a sketch with no extra components. Using this board, remember to check the upload speed in file boards.txt: it has to be set a 57600 (it is by default).

oric_dan


During the last days I did a lot of tests trying to solve the problem.
If you're using the Mighty-1284p files by maniacbug, select the board "Mighty 1284p 16 MHz w/Optiboot" then put a 220K resistor in series on the line beetween the FT232 TX and the 1284p RX0 pins.

If you're using the "Original Mighty 1284p" board, then you could try with a 120K R. Or, maybe, without components.

With my 1284P, I was able to flash a sketch using a 175K over the line beetween my Arduino UNO R1 RX pin and the 1284P RX0 pin when I chose the 1284p board. Using the "Original Mighty" board, I was able to flash a sketch with no extra components. Using this board, remember to check the upload speed in file boards.txt: it has to be set a 57600 (it is by default).

Hi leo, I don't understand. You're actually bridging the Rx and Tx pins using a 220K resistor?
What does that do? Where did that idea come from?

Also, isn't 175K greater than the 1284P program space?

Also, I don't understand why the UNO board is in there during sketch uploading. ??

Also, I think the 1284P optiboot uses 115,200.

So, I don't understand anything here. [early morning] ?????


john1993


Ok, thanks, John, external signals. "even 50ohm or 100ohm suppressed" - is this on the pcb or at
the source? There is such a thing as "source series termination", which is using a 50R series-R at
the source end to quench ringing on a long line, and it works really really well.


any long wires hanging directly off the pin can be a source of noise pulse pickup so the series resistor had to be right on the avr pin to solve the problem. and youre right about low value series being common. specially high speed dram bus where pico-seconds matter. but for the rx0 problem 1k or 2k is better. has added advantge of allowing direct connection to 12v rs232 equipment w/o issues.

and i saw the xtl pin reset too but not much you can do about that except dont touch them. :)

leo72


Hi leo, I don't understand. You're actually bridging the Rx and Tx pins using a 220K resistor?

No. I put a 175K in series on the line between the Arduino pin and the 1284 pin.
Arduino RX ------ R ------- RX0 1284P

Quote

What does that do? Where did that idea come from?

A friend of mine investigated the problem using an oscilloscope and he went to the result that the 1284p bootloader based on the Optiboot 4.5 works too early. It sends the reset and then start sending the datas on the line. A R introduces a little retard on the transmission, helping the bootloader to properly receive the datas.

Quote

Also, isn't 175K greater than the 1284P program space?

I was talking about R values, not firmware sizes  :smiley-sweat:

Quote

Also, I don't understand why the UNO board is in there during sketch uploading. ??

I don't have an USB/serial board, so I removed the chip from my Arduino and I use the Atmega8U2 as a USB/serial converter.

Quote

Also, I think the 1284P optiboot uses 115,200.

The Optiboot 4.5 works at 115,200, the other bootloader included in the maniacbug's core is based on the Stk500v2 bootloader from Atmel, also used on oldest Arduinos (like 2009). It works at 57,600 and has a better management of the timings.

Quote

So, I don't understand anything here. [early morning] ?????



I hope I have explained better  ;)

retrolefty

Quote
A friend of mine investigated the problem using an oscilloscope and he went to the result that the 1284p bootloader based on the Optiboot 4.5 works too early. It sends the reset and then start sending the datas on the line. A R introduces a little retard on the transmission, helping the bootloader to properly receive the datas.


This sounds technically incorrect on many levels. The resistor may be acting as a low pass filter element in conjunction with the Rx input pin capacitance but that is all, there is no 'delay' possible otherwise. So if this does help then it's just a simpler one component low pass filter design, just like the resistor/cap low pass filter 'solution'.

Lefty

leo72


This sounds technically incorrect on many levels. The resistor may be acting as a low pass filter element in conjunction with the Rx input pin capacitance but that is all, there is no 'delay' possible otherwise. So if this does help then it's just a simpler one component low pass filter design, just like the resistor/cap low pass filter 'solution'.

Lefty

It did help. Your explanation sounds correct. I didn't think about the internal capacitance of the pin.

BTW I solved using the bootloader based on the Stk500v2 code included in the maniacbug's package. Burning that bootloader I can upload a sketch with no external components.

oric_dan



This sounds technically incorrect on many levels. The resistor may be acting as a low pass filter element in conjunction with the Rx input pin capacitance but that is all, there is no 'delay' possible otherwise. So if this does help then it's just a simpler one component low pass filter design, just like the resistor/cap low pass filter 'solution'.

Lefty

It did help. Your explanation sounds correct. I didn't think about the internal capacitance of the pin.

BTW I solved using the bootloader based on the Stk500v2 code included in the maniacbug's package. Burning that bootloader I can upload a sketch with no external components.


leo, thanks for the explanation. I guess I read everything backwards! With a 175K series-R and
talk of slowing things down, I would immediately assume it's a low-pass filter in conjunction
with the RX0 pin input impedance. Eg, R*C = 175K * 20pF = 3.5 usec approx. And the 10K,
100pF filter others are using would have similar effect.

As mentioned, I've been using maniacbug's optiboot at 115.2, and no low-pass, and have not
worried about any reset delays, and have had no problems with anything. And my 1284 test
board is a jumble of wires. So, still a little fuzzy about what's going on with everyone else.

I would think one could try patching maniacbug's optiboot to check for a delay problem.

pito

#112
Feb 01, 2013, 07:16 pm Last Edit: Feb 01, 2013, 08:14 pm by pito Reason: 1
I've taken my old 1284p off the shelf and tried to flash the mighty-optiboot (hex latest from repo, IDE 1.5.1r2, 16MHz xtal, 115k2), with no success. I am using Usbasp, optiboot_atmega1284p.hex from repo and from the forum topics as well (not compiled by myself yet), and all possible fuses settings.
When burned in I do not see the led on pin 13 flashing few times (D13 on mighty pin layout I guess) after a reset and the upload of a sketch shows:
Code: [Select]
..Binary sketch size: 15,508 bytes (of a 130,048 byte maximum)
processing.app.debug.RunnerException
at processing.app.debug.BasicUploader.uploadUsingPreferences(BasicUploader.java:126)
at processing.app.Sketch.upload(Sketch.java:1664)
at processing.app.Sketch.exportApplet(Sketch.java:1623)
at processing.app.Sketch.exportApplet(Sketch.java:1595)
at processing.app.Editor$DefaultExportHandler.run(Editor.java:2393)
at java.lang.Thread.run(Thread.java:619)


"Upload Using Programmer" (with the same Usbasp) works fine.
A similar setup with 328p and optiboot works fine here as well. It seems to me the 1284p' optiboot hex file includes something my programmer cannot process properly..

PS: when trying to burn the bootloader via Usbasp from IDE (Tools/Burn Bootloader) I get:
Code: [Select]

processing.app.debug.RunnerException
at processing.app.debug.BasicUploader.burnBootloader(BasicUploader.java:288)
at processing.app.Editor$47.run(Editor.java:2509)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

And my board:
Code: [Select]
##############################################################
mighty_opt.name=Mighty 1284p 16MHz using Optiboot
mighty_opt.upload.protocol=arduino
mighty_opt.upload.maximum_size=130048
mighty_opt.upload.speed=115200
mighty_opt.bootloader.low_fuses=0xff
mighty_opt.bootloader.high_fuses=0xde
mighty_opt.bootloader.extended_fuses=0xfd
#mighty_opt.bootloader.path=optiboot1284p
mighty_opt.bootloader.file=optiboot1284p/optiboot_atmega1284p.hex
mighty_opt.bootloader.unlock_bits=0x3F
mighty_opt.bootloader.lock_bits=0x0F
mighty_opt.build.mcu=atmega1284p
mighty_opt.build.f_cpu=16000000L
#mighty_opt.build.core=arduino:arduino
mighty_opt.build.core=standard1284p
mighty_opt.build.variant=mighty

retrolefty

I have a USBtiny programmer that also fails to burn the optiboot onto a 1284P chip, but can do it for a 644P chip. But this is a known limitation of the USBtiny programmer not being able to handle addresses higher then 64KB. But I was able using a standard arduino board to burn the optiboot loader onto the 1284P chip using Nick's great sketch. It has the optiboot loader code built into the sketch so the IDE is not involved.

http://www.gammon.com.au/forum/?id=11635

Lefty

pito

#114
Feb 01, 2013, 09:15 pm Last Edit: Feb 01, 2013, 09:36 pm by pito Reason: 1
Frankly, I am not aware of the fact Usbasp cannot flash at the top addresses. I used it with amforth for example - afaik it stores code on the top within the bootloader section - no issues ever..
So burned in with Nick's code:
Code: [Select]
Atmega chip programmer.
Written by Nick Gammon.
Entered programming mode OK.
Signature = 0x1E 0x97 0x05
Processor = ATmega1284P
Flash memory size = 131072 bytes.
LFuse = 0xFF
HFuse = 0xDE
EFuse = 0xFD
Lock byte = 0xFF
Clock calibration = 0x53
Bootloader address = 0x1FC00
Bootloader length = 508 bytes.
Type 'V' to verify, or 'G' to program the chip with the bootloader ...
Erasing chip ...
Writing bootloader ...
Committing page starting at 0x1FC00
Committing page starting at 0x1FD00
Written.
Verifying ...
No errors found.
Writing fuses ...
LFuse = 0xFF
HFuse = 0xDE
EFuse = 0xFD
Lock byte = 0xEF
Clock calibration = 0x53
Done.
Type 'C' when ready to continue with another chip ...


And uploading the working sketch:
Code: [Select]
Binary sketch size: 15,558 bytes (of a 130,048 byte maximum)
processing.app.debug.RunnerException
at processing.app.debug.BasicUploader.uploadUsingPreferences(BasicUploader.java:126)
at processing.app.Sketch.upload(Sketch.java:1664)
at processing.app.Sketch.exportApplet(Sketch.java:1623)
at processing.app.Sketch.exportApplet(Sketch.java:1595)
at processing.app.Editor$DefaultExportHandler.run(Editor.java:2393)
at java.lang.Thread.run(Thread.java:619)

:~

retrolefty


Frankly, I am not aware of the fact Usbasp cannot flash at the top addresses. I used it with amforth for example - afaik it stores code on the top within the bootloader section - no issues ever..


And I too don't know if USBasp has such a limitation or not, just reporting that a USBtiny does and a simple work around for me was using an arduino board and Nick's program.

Lefty


leo72

I knew that USBasp didn't have the 64 kB limit.
This is from the changelog of the last version of the firmware:

Quote

usbasp.2011-05-28 (v1.4)
------------------------
- added support for controllers with flash >128kb (by Slawomir Fra?)

pito

#117
Feb 02, 2013, 01:49 am Last Edit: Feb 02, 2013, 02:15 am by pito Reason: 1
Ok, an interesting stuff, indeed.
1. LED is on PB0 on my board, it flashes after reset, all programmers work fine :)
2. I did some editing of the avrdudeconf (added resetdelay = 15, similar to uno, and added ..tool=avrdude into boards) - that causes the avrdude resets the BT pin32 (aka dtr) now before the upload (I am using a BT module).

So the upload started, but finished with errors already published here. I did about 70 uploads of a 15kB sketch and my current findings are as follows (chip date 1027, breadboard, good decoupled, short wires (5cm long Rx, Tx to BT), no crossing with other signals or crystal):
1. without pull up/down resistor on RX and w/ short wires the probability of a successful upload ~10%
2. with pull-up/down 10k res on Rx - about 40%
3. with serial 10k in RX - 100% upload, even with a 20cm long Rx wire and while the wire touched/hold during the upload (the 20cm wire at the 1284p's Rx pin side)
4. w/o the serial 10k and with 20cm long Rx wire no luck.

That behavior might be caused, except "Rx pin signal/noise sensitivity", by a reversal of the 1284p's  Rx input pin direction, even for a very short time, thus it fires against the other output (ftdi's or BT's Tx), and when the current peak is not limited (ie. by a serial resistor) it flips internally into an undefined state. Hopefully the bootloader does not change the Rx direction (or switches internal pullups on/off on that pin) somewhere in the code..


pito

#118
Feb 02, 2013, 03:11 am Last Edit: Feb 02, 2013, 03:22 am by pito Reason: 1
I did following experiment - 58cm long Rx wire, passed beneath the crystal, did few loops with it creating a mess :) with 10k serial resistor wired as follows:

BTmodule_Tx --10kohm------>>---------58cm_wire------->>-----Crystal---->>----Rx pin 1284p

Uploaded an 127kB large sketch:
Code: [Select]

Binary sketch size: 127,052 bytes (of a 130,048 byte maximum)

Done 12x while touching the 58cm long wire during the upload from time to time - upload 100% ok. I did not test the code actually works, though :).


pito

#119
Feb 02, 2013, 10:28 am Last Edit: Feb 02, 2013, 11:01 am by pito Reason: 1
Solved?
With Low Fuse= F7 (Full Swing Oscillator 16K CK + 45ms) I cannot reproduce the upload errors anymore (the 10k serial resistor is not needed). It could be the 1284p operated @16MHz and 3V3 needs full swing (more power), otherwise the nearby RX pin may influence (modulate) the crystal oscillator frequency (especially with the DIP package with larger capacitance between the pins) and it comes to errors then..
PS: XTAL1 pin13 (RX is 14) - is the input of the crystal oscillator (high impedance, easy to modulate), would be better to have XTAL2 pin - the oscillator output - there (low impedance, harder to modulate)..

Go Up