Pages: 1 2 [3] 4 5 6   Go Down
Author Topic: Using the 1284p/664p (IDE, bread board and boot loaders)  (Read 18943 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 43
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


By the way, I found a bootloader posted here with source: http://ryanmsutton.com/2011/06/arduino-bootloader-for-atmega-1284p/

This week I am going to try and bring up a 1284p, and this looks like what I'll start with right now.

Let me know how you get on. I tried that one but no luck for me. I've tried several and I don't believe they are all bad so it must be something I am doing or not doing. Hard to figure out what when uploading sketches works but bootloaders don't.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 4
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've tried several and I don't believe they are all bad so it must be something I am doing or not doing. Hard to figure out what when uploading sketches works but bootloaders don't.

i have same problem, but i use USBTinyISP v2 and it "Works with any AVR ISP chip with 64K of flash (or less) - does not work with Atmega1281/1280/2561/2560" i can upload small sketches like "blink" with it, but when i try to Burn Bootloader to Sanguino1284 there is some error after few minutes..  "debug" led start flashing on some bootloaders..
Logged

Seattle, WA
Offline Offline
God Member
*****
Karma: 8
Posts: 673
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

This week I am going to try and bring up a 1284p, and this looks like what I'll start with right now.
Let me know how you get on. I tried that one but no luck for me. I've tried several and I don't believe they are all bad so it must be something I am doing or not doing. Hard to figure out what when uploading sketches works but bootloaders don't.


Works great.  I used Ryan M. Sutton's bootloader with a couple modifications:
* 16MHz
* 57600 baud (highest that works)
* Enabled watchdog mods

Burned it with mega-isp #04.

Be sure to get the fuses right.  This is a pretty BIG bootloader, which requires the maximum available bootloader size, so a 'high' fuse of D8.

I haven't brought up the core yet, just testing with a real simple AVR blink:

Code:
#include <avr/io.h>
#include <util/delay.h>

#define LED_DDR  DDRB
#define LED_PORT PORTB
#define LED      PINB1

int main(void)
{
  LED_DDR |= _BV(LED);

  while(1)
  {
    LED_PORT |= _BV(LED);
    _delay_ms(500);
    LED_PORT &= ~_BV(LED);
    _delay_ms(500);
  }

  return 0;
}
« Last Edit: November 21, 2011, 11:26:14 pm by maniacbug » Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 43
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Works great.  I used Ryan M. Sutton's bootloader with a couple modifications:
* 16MHz
* 57600 baud (highest that works)
* Enabled watchdog mods

Burned it with mega-isp #04.

Be sure to get the fuses right.  This is a pretty BIG bootloader, which requires the maximum available bootloader size, so a 'high' fuse of D8.

I haven't brought up the core yet, just testing with a real simple AVR blink:

Thanks, I'll give that a try again. Can you please upload the relevant section from boards.txt?
Logged

Seattle, WA
Offline Offline
God Member
*****
Karma: 8
Posts: 673
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks, I'll give that a try again. Can you please upload the relevant section from boards.txt?

At the moment, I cut out the IDE so no boards.txt needed.  When it's all done and working perfectly, I'll bring it into the IDE and craft a working boards.txt file.

Setting fuses:
Code:
$ avrdude -p m1284p -P /dev/tty.usbserial-A40081RP -c avrisp -b 19200 -e -Ulock:w:0x3F:m -Uefuse:w:0xfd:m -Uhfuse:w:0xD8:m -Ulfuse:w:0xFF:m -Ulock:w:0x0F:m

Burning bootloader:
Code:
$ avrdude -p m1284p -P /dev/tty.usbserial-A40081RP -c avrisp -b 19200 -F -U flash:w:ATmegaBOOT_1284P.hex

Uploading sketch:
Code:
$ avrdude -V -F -D -C /usr/local/avrtools/etc/avrdude.conf -p atmega1284p -c stk500v1 -b 57600 -P /dev/tty.usbserial-A600eHIs  -U flash:w:16000000/Blink_Simple.hex:i
Logged


Seattle, WA
Offline Offline
God Member
*****
Karma: 8
Posts: 673
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok, here it is.  Posted a full set of hardware platform files, compatible with 1.0, tested against RC1, as Mighty 1284P.

There are surprisingly few changes needed to the 1.0 Arduino core files.  I will see if I can interest the development team in taking them, and then the 1284p platform would be simpler still because it wouldn't need to duplicate the core files.

I still have to do some more exhaustive testing of PWM pins, SPI, ADC's, etc.  Basic sketches uploaded and tested fine.  Bootloader was programmed fine from the IDE.
« Last Edit: November 23, 2011, 12:57:43 am by maniacbug » Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 43
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

There are surprisingly few changes needed to the 1.0 Arduino core files.  I will see if I can interest the development team in taking them, and then the 1284p platform would be simpler still because it wouldn't need to duplicate the core files.

The pin mapping doesn't belong in the core libraries and adding yet more mappings only increases the mess. The SD library supports the ATmega644P Sanguino, but it won't work with my Calunium. Why? Because I chose to use a different pin mapping, one which placed the SPI interface in the same place as the standard Arduino. I recently asked (on the issues page on Google code) what needs to be done so that all the pin mapping information is held in pins_arduino.h, and no processor or board specific assumptions are made by the main libraries, but I haven't yet received an answer.

Logged

Seattle, WA
Offline Offline
God Member
*****
Karma: 8
Posts: 673
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The pin mapping doesn't belong in the core libraries

Indeed.  But it's not in the core anymore, it's in 'variants'.  So what specifically is the problem?  Just the SD library?

adding yet more mappings only increases the mess.

Totally agree.  If I could have found something that worked end to end, I would have used that.  Wish I would have found your calunium platform on github originally.  But it doesn't include a bootloader smiley-neutral  So still more work needed to bring together an end-to-end solution.

Also, there are plenty reasonable points of view on how 1284P pins should be laid out.  Really the core should be agnostic to that, and in my couple days of experience with this, pins_arduino.h lets you control the pins plenty well.  I found only one hard-coded pin reference that needed to be fixed in the core, and submitted a patch for it issue 727.

I chose to use a different pin mapping, one which placed the SPI interface in the same place as the standard Arduino.

Right, this is the classic problem faced in this situation.  I looked at what the Mega did, and the Mega completely doesn't maintain SPI pin compatibility in any way.  So Mega already breaks SPI & I2C shield compat, making this beahviour kind of 'standard' though certainly debatable.

I recently asked (on the issues page on Google code) what needs to be done so that all the pin mapping information is held in pins_arduino.h, and no processor or board specific assumptions are made by the main libraries, but I haven't yet received an answer.

What further board-specific assumptions do you want to get rid of?  Perhaps a more effective approach would be to send in a patch that accomplishes it.
Logged


Peoples Republic of Cantabrigia
Offline Offline
God Member
*****
Karma: 6
Posts: 691
Arduino happiness
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


i have same problem, but i use USBTinyISP v2 and it "Works with any AVR ISP chip with 64K of flash (or less) - does not work with Atmega1281/1280/2561/2560" i can upload small sketches like "blink" with it, but when i try to Burn Bootloader to Sanguino1284 there is some error after few minutes..  "debug" led start flashing on some bootloaders..
I ran into that problem about two weeks ago and contacted adafruit industries to update their store and usbtiny support pages. Fwiw, ladyada knew of the problem already but I guess she hadn't seen the need yet to update her website pages.

As far as uploading stuff goes, my guess is that success depends on how big your program is and where in the memory space it is being stored. Boot loaders are impossible to be burned at the present time with the usbtiny, ladyada stated that hardware and software issues are the reason. In other words, do not expect a firmware update to make your usbtiny 1284p-compatible.

I had good luck uploading the brewtroller boot loader, etc. onto my tqfp-form factor 1284p using the avr ISP mk2.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Ok, here it is.  Posted a full set of hardware platform files, compatible with 1.0, tested against RC1, as Mighty 1284P.

Awesome! In the end, I used maniacbug's files and it worked like a charm. Only tested blink and PWM on an LED so far. Serial0 is working too. Managed to first burn the bootloader using the IDE on a macbook and then to upload sketches without any trouble.

Is the second hw serial port supported ?

And also, what are the changes to the core files ?

Thanks a lot!
Logged

Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 446
Posts: 23868
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Try some
Serial1.print (data);
commands, see if they work.
On my 1284 board, I added a surface mount version of RS232 driver to interface the 2nd port to the world.
http://www.dipmicro.com/store/MAX232, needs four 1uF caps too for output voltage conversion.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Newbie
*
Karma: 0
Posts: 43
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The pin mapping doesn't belong in the core libraries

Indeed.  But it's not in the core anymore, it's in 'variants'.  So what specifically is the problem?  Just the SD library?
That was badly written on my part. I meant standard libraries.

adding yet more mappings only increases the mess.

Totally agree.  If I could have found something that worked end to end, I would have used that.  Wish I would have found your calunium platform on github originally.  But it doesn't include a bootloader smiley-neutral  So still more work needed to bring together an end-to-end solution.

Well I can happily say that thanks to your instructions above I now have a working bootloader.  smiley



Also, there are plenty reasonable points of view on how 1284P pins should be laid out.  Really the core should be agnostic to that, and in my couple days of experience with this, pins_arduino.h lets you control the pins plenty well.  I found only one hard-coded pin reference that needed to be fixed in the core, and submitted a patch for it issue 727.

I've found three: Ethernet/utility/w5100.h, SD/utility/Sd2PinMap.h, and Firmata/Boards.h.

I recently asked (on the issues page on Google code) what needs to be done so that all the pin mapping information is held in pins_arduino.h, and no processor or board specific assumptions are made by the main libraries, but I haven't yet received an answer.

What further board-specific assumptions do you want to get rid of?  Perhaps a more effective approach would be to send in a patch that accomplishes it.

It will be a bit of work to move the pin-specific stuff from Sd2PinMap.h to the various pins_arduino.h files. I don't mind doing that if it is likely to be accepted. Maybe I should email David Mellis before I start.
Logged

Seattle, WA
Offline Offline
God Member
*****
Karma: 8
Posts: 673
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Awesome! In the end, I used maniacbug's files and it worked like a charm. Only tested blink and PWM on an LED so far. Serial0 is working too. Managed to first burn the bootloader using the IDE on a macbook and then to upload sketches without any trouble.

Thanks a lot!

Cool, glad to hear it's working.  Nice to get some more eyes on this.

Quote
Is the second hw serial port supported ?

Yup.  I did a massive test pass yesterday, with tests for both UARTS, 8 ADC channels, 8 PWM pins, 3 external interrupts, SPI, and I2C.  

I found a couple problems with PWM and INT2, which are fixed in the patch below, and also checked into github 7c48aa8748

Quote
And also, what are the changes to the core files ?

The entire change is copied below.  This has been submitted as issues 727 and 728.  Feel free to add comments in those issues if you'd also like to see them in.

Code:
diff --git a/hardware/arduino/cores/arduino/Arduino.h b/hardware/arduino/cores/arduino/Arduino.h
index ebd374a..c05b919 100755
--- a/hardware/arduino/cores/arduino/Arduino.h
+++ b/hardware/arduino/cores/arduino/Arduino.h
@@ -47,3 +47,3 @@ extern "C"{
 #else  
-#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
+#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1284P__)
 #define INTERNAL1V1 2
@@ -213,2 +213,2 @@ long map(long, long, long, long, long);
 
-#endif
\ No newline at end of file
+#endif
diff --git a/hardware/arduino/cores/arduino/WInterrupts.c b/hardware/arduino/cores/arduino/WInterrupts.c
index e06b03f..3b9fe08 100755
--- a/hardware/arduino/cores/arduino/WInterrupts.c
+++ b/hardware/arduino/cores/arduino/WInterrupts.c
@@ -112,2 +112,15 @@ void attachInterrupt(uint8_t interruptNum, void (*userFunc)(void), int mode) {
       break;
+    
+    case 2:
+    #if defined(EICRA) && defined(ISC20) && defined(ISC21) && defined(EIMSK)
+      EICRA = (EICRA & ~((1 << ISC20) | (1 << ISC21))) | (mode << ISC20);
+      EIMSK |= (1 << INT2);
+    #elif defined(MCUCR) && defined(ISC20) && defined(ISC21) && defined(GICR)
+      MCUCR = (MCUCR & ~((1 << ISC20) | (1 << ISC21))) | (mode << ISC20);
+      GICR |= (1 << INT2);
+    #elif defined(MCUCR) && defined(ISC20) && defined(GIMSK) && defined(GIMSK)
+      MCUCR = (MCUCR & ~((1 << ISC20) | (1 << ISC21))) | (mode << ISC20);
+      GIMSK |= (1 << INT2);
+    #endif
+      break;
 #endif
@@ -239,2 +252,9 @@ SIGNAL(INT1_vect) {
 
+#if defined(EICRA) && defined(ISC20)
+SIGNAL(INT2_vect) {
+  if(intFunc[EXTERNAL_INT_2])
+    intFunc[EXTERNAL_INT_2]();
+}
+#endif
+
 #endif
diff --git a/hardware/arduino/cores/arduino/wiring_analog.c b/hardware/arduino/cores/arduino/wiring_analog.c
index 902b153..ade6cac 100644
--- a/hardware/arduino/cores/arduino/wiring_analog.c
+++ b/hardware/arduino/cores/arduino/wiring_analog.c
@@ -43,9 +43,3 @@ int analogRead(uint8_t pin)
 
-#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
- if (pin >= 54) pin -= 54; // allow for channel or pin numbers
-#elif defined(__AVR_ATmega32U4__)
- if (pin >= 18) pin -= 18; // allow for channel or pin numbers
-#else
- if (pin >= 14) pin -= 14; // allow for channel or pin numbers
-#endif
+ if (pin >= A0) pin -= A0; // allow for channel or pin numbers
 
diff --git a/hardware/arduino/cores/arduino/wiring_private.h b/hardware/arduino/cores/arduino/wiring_private.h
index 41d1d40..f0ceb0c 100755
--- a/hardware/arduino/cores/arduino/wiring_private.h
+++ b/hardware/arduino/cores/arduino/wiring_private.h
@@ -56,2 +56,4 @@ extern "C"{
 #define EXTERNAL_NUM_INTERRUPTS 8
+#elif defined(__AVR_ATmega1284P__)
+#define EXTERNAL_NUM_INTERRUPTS 3
 #else

EDIT: Changes posted on github and issues created on Arduino issue tracker now.
« Last Edit: November 24, 2011, 05:05:58 pm by maniacbug » Logged


Seattle, WA
Offline Offline
God Member
*****
Karma: 8
Posts: 673
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I've found three: Ethernet/utility/w5100.h, SD/utility/Sd2PinMap.h, and Firmata/Boards.h.
...
It will be a bit of work to move the pin-specific stuff from Sd2PinMap.h to the various pins_arduino.h files. I don't mind doing that if it is likely to be accepted. Maybe I should email David Mellis before I start.

Indeed, yes I see them now.  They are in libraries I don't use, so I don't run across them.  WTF is Sd2PinMap reimplementing the pin mappings from pins_arduino.h?!  Seems like all three just need to be ported to use pins_arduino.h definitions.  It would be surprising if the developers wouldn't take good fixes to these.
Logged


UK
Offline Offline
Sr. Member
****
Karma: 7
Posts: 436
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Evening,

ManiacBug,  I've been ill for the past few months so not been messing with the 1284p and prior to that I was finishing the project I was working on.

I've just setup Arudino 1.0 and changed my project to work and whilst setting everything up I decided to get the 1284p working again.  I plugged in my board which I designed as per the beginning of this thread and which worked under 0.22  the program is still on the board and it started flashing away as it should.

I downloaded the zip file from your site as I wanted to get it going with v 1.0 and re-started Arduino.  The board appears under the list and I loaded my original 1284p test program (my board has 8 leds and the program flashes all 8 in various sequences).

When I click upload though it compiles correctly but then I get the error:

avrdude: stk500_getsync(): not in sync: resp=0x00
Logged

Pages: 1 2 [3] 4 5 6   Go Up
Jump to: