Inhaos Mega 2560 CORE mini: ISP connection defunct?

Hi,

(this is done under LINUX)

I want to backup the initial flash content of a Inhaos Mega 2560 CORE mini.
For that I have flashed the Arduino ISP sketch into my Arduino UNO R3. Connect
10,11,12,13,GND and Vcc with the CORE board, double checked to connections
and plugged the USB connector to the UNO finally.

The LEDs on the CORE went on an the BLINK sketch blinks.

To download the flash content from the command line I tried various avrdude commands like:

/usr/local/arduino-1.8.4/hardware/tools/avr/bin/avrdude -C/usr/local/arduino-1.8.4/hardware/tools/avr/etc/avrdude.conf -v -v -v -pm2560 -cavrisp2 -P /dev/ttyACM0 -b115200 -D -Uflash:r:Atmega2560.bin:r

I changed the baudrate and avrisp<->avrisp2

Nothing does impress the CORE much…avrdude times out each time.

I can flash the CORE via serial and bootloader…so the board seems ok so far.

I googled a lot but what I tried…it does not work.

Does anyone experienced the same problems with this board?
How can I make this to work?

Thanks a lot in advance!
Cheers
mcc

mcc01: Connect 10,11,12,13,GND and Vcc with the CORE board, double checked to connections and plugged the USB connector to the UNO finally.

You need to use different SPI pins for a Mega.

Hmmmm,...

In the source of the ArduinoISP-sketch (running on my UNO R3) there is a comment saying:

// On some Arduinos (Uno,...), pins MOSI, MISO and SCK are the same pins as
// digital pin 11, 12 and 13, respectively. That is why many tutorials instruct
// you to hook up the target to these pins. If you find this wiring more
// practical, have a define USE_OLD_STYLE_WIRING. This will work even when not
// using an Uno. (On an Uno this is not needed).

...so I thought, that connecting those pins to the counterparts of the Inhaos MEGA CORE mini would be OK. But it does not work, so it is obviously wrong.

What do you suggest to do differently as stated in the source of the ArduinoISP?

Thanks a lot of any help in advance! Cheers mcc

You have to use the SPI pins on the Mega, like already stated.

SPI: 50 (MISO), 51 (MOSI), 52 (SCK), 53 (SS). These pins support SPI communication...

Also in the code of the ArduinoISP there is mentioned:

// By default, the hardware SPI pins MISO, MOSI and SCK are used to communicate
// with the target. On all Arduinos, these pins can be found
// on the ICSP/SPI header:
//
//               MISO °. . 5V (!) Avoid this pin on Due, Zero...
//               SCK   . . MOSI
//                     . . GND
//
// On some Arduinos (Uno,...), pins MOSI, MISO and SCK are the same pins as
// digital pin 11, 12 and 13, respectively. That is why many tutorials instruct
// you to hook up the target to these pins. If you find this wiring more
// practical, have a define USE_OLD_STYLE_WIRING. This will work even when not
// using an Uno. (On an Uno this is not needed).

And where is the ICSP connector on your INHOAS?

My has none...

In the manual here
http://www.inhaos.com/uploadfile/otherpic/DS-Mega2560-CORE-V01-EN.pdf

on page 3 under “3. Programming via ISP” you will find the position of the ISP header pins.
The image is topview! You have to mirror the pins when connecting them from “down under”.

Cheers
mcc

Ok, I forgot that it is the ending of one of the long dual connectors.

Those pins are working as expected, I run a NRF24 over them.

So it seems you have something connected incorrectly.

Found the culprit....I think....

One cable has a "Wackelkontakt" (oh damn, what is that in English...Google says "slack joint").

But!

1.) The efuses could not be read...all are 0x00. The board is not recognized (had to use "-F") 2.) It seems, that the Arduino-ISP (or at least "with my configuration") suffers from the same problem described here: https://petervanhoyweghen.wordpress.com/2015/12/02/the-usbasp-and-atmega2560-mystery/

The hexfile created with this command:

/usr/local/arduino-1.8.4/hardware/tools/avr/bin/avrdude -C/usr/local/arduino-1.8.4/hardware/tools/avr/etc/avrdude.conf -pm2560 -cavrisp -P /dev/ttyACM0 -Uflash:r:Atmega25602.hex:i -v -F

does contain a mirrored contents ("wrap around" as stated in the linked article). This may imply either: The Arduino-ISP creates the wrap by not correctly use the three-byte commands (see link) or Inhaos has burned the bootloader twice by using a defective ISP programmer...also not using thre-byte commands.

This is the output of that command:

avrdude: Version 6.3, compiled on Jan 17 2017 at 11:00:16
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "/usr/local/arduino-1.8.4/hardware/tools/avr/etc/avrdude.conf"
         User configuration file is "/home/mccramer/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/ttyACM0
         Using Programmer              : avrisp
         AVR Part                      : ATmega2560
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PA0
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    10     8    0 no       4096    8      0  9000  9000 0x00 0x00
           flash         65    10   256    0 yes    262144  256   1024  4500  4500 0x00 0x00
           lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : STK500
         Description     : Atmel AVR ISP
         Hardware Version: 3
         Firmware Version: 6.2
         Vtarget         : 0.3 V
         Varef           : 0.3 V
         Oscillator      : 28.800 kHz
         SCK period      : 3.3 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x000000 (retrying)

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x000000 (retrying)

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x000000
avrdude: Yikes!  Invalid device signature.
avrdude: Expected signature for ATmega2560 is 1E 98 01
avrdude: safemode: hfuse reads as 0
avrdude: safemode: efuse reads as 0
avrdude: reading flash memory:

Reading | ################################################## | 100% 29.37s

avrdude: writing output file "Atmega2560.hex"

avrdude: safemode: hfuse reads as 0
avrdude: safemode: efuse reads as 0
avrdude: safemode: Fuses OK (E:00, H:00, L:00)

avrdude done.  Thank you.

Is there a way to wipe the flash (NOT the eeprom) completly without wiping the bootloader (the bootloader is the original one of Inhaos)? Do you own an untouched Inhaos MEGA 2560 Core, from which you could do an "image backup" (hex) to check whether there is an mirrored bootloader (and if not, sent me the file, please :), PM me if so :)

Thanks a lot in advance for your support and help, Whandall! Cheers mcc

No, I will not dismantle my setup to get access to the SPI pins to readout the Flash via avrdude.

You could dump the whole flash (or parts of it) with a sketch.

void setup() {
  Serial.begin(250000);
  dumpFF(0x3E000, 0x2000, F("FAR "));
}
void loop() {}

void pHexByte(byte what) {
  if (what < 16) {
    Serial.write('0');
  }
  Serial.print(what, HEX);
}

void dumpFF(unsigned long adr, long len, const __FlashStringHelper* pfx) {
  byte idx;
  if (len) {
    for (; len > 0; len -= 16, adr += 16) {
      Serial.print(pfx);
      pHexByte(adr >> 16);
      pHexByte(adr >> 8);
      pHexByte(adr);
      Serial.write(':');
      Serial.write(' ');
      for (idx = 0; idx < 16; idx++) {
        if (idx < len ) {
          pHexByte(pgm_read_byte_far(adr + idx));
          Serial.write(' ');
        } else {
          Serial.print(F("   "));
        }
      }
      Serial.write('\'');
      for (idx = 0; (idx < 16) && (idx < len); idx++) {
        byte curr = pgm_read_byte_far(adr + idx);
        Serial.write(curr < 0x20 ? '.' : curr);
      }
      Serial.write('\'');
      Serial.println();
    }
  }
}
FAR 03E000: 0D 94 F6 F2 0D 94 1F F3 0D 94 1F F3 0D 94 1F F3 '.”öò.”.ó.”.ó.”.ó'
FAR 03E010: 0D 94 1F F3 0D 94 1F F3 0D 94 1F F3 0D 94 1F F3 '.”.ó.”.ó.”.ó.”.ó'
FAR 03E020: 0D 94 1F F3 0D 94 1F F3 0D 94 1F F3 0D 94 1F F3 '.”.ó.”.ó.”.ó.”.ó'
FAR 03E030: 0D 94 1F F3 0D 94 1F F3 0D 94 1F F3 0D 94 1F F3 '.”.ó.”.ó.”.ó.”.ó'
FAR 03E040: 0D 94 1F F3 0D 94 1F F3 0D 94 1F F3 0D 94 1F F3 '.”.ó.”.ó.”.ó.”.ó'
FAR 03E050: 0D 94 1F F3 0D 94 1F F3 0D 94 1F F3 0D 94 1F F3 '.”.ó.”.ó.”.ó.”.ó'
FAR 03E060: 0D 94 1F F3 0D 94 1F F3 0D 94 1F F3 0D 94 1F F3 '.”.ó.”.ó.”.ó.”.ó'
FAR 03E070: 0D 94 1F F3 0D 94 1F F3 0D 94 1F F3 0D 94 1F F3 '.”.ó.”.ó.”.ó.”.ó'
FAR 03E080: 0D 94 1F F3 0D 94 1F F3 0D 94 1F F3 0D 94 1F F3 '.”.ó.”.ó.”.ó.”.ó'
FAR 03E090: 0D 94 1F F3 0D 94 1F F3 0D 94 1F F3 0D 94 1F F3 '.”.ó.”.ó.”.ó.”.ó'
FAR 03E0A0: 0D 94 1F F3 0D 94 1F F3 0D 94 1F F3 0D 94 1F F3 '.”.ó.”.ó.”.ó.”.ó'
FAR 03E0B0: 0D 94 1F F3 0D 94 1F F3 0D 94 1F F3 0D 94 1F F3 '.”.ó.”.ó.”.ó.”.ó'
FAR 03E0C0: 0D 94 1F F3 0D 94 1F F3 0D 94 1F F3 0D 94 1F F3 '.”.ó.”.ó.”.ó.”.ó'
FAR 03E0D0: 0D 94 1F F3 0D 94 1F F3 0D 94 1F F3 0D 94 1F F3 '.”.ó.”.ó.”.ó.”.ó'
FAR 03E0E0: 0D 94 1F F3 41 54 6D 65 67 61 32 35 36 30 00 41 '.”.óATmega2560.A'
FAR 03E0F0: 72 64 75 69 6E 6F 20 65 78 70 6C 6F 72 65 72 20 'rduino explorer '
FAR 03E100: 73 74 6B 35 30 30 56 32 20 62 79 20 4D 4C 53 00 'stk500V2 by MLS.'
FAR 03E110: 42 6F 6F 74 6C 6F 61 64 65 72 3E 00 48 75 68 3F 'Bootloader>.Huh?'
FAR 03E120: 00 43 6F 6D 70 69 6C 65 64 20 6F 6E 20 20 3D 20 '.Compiled on  = '
FAR 03E130: 00 43 50 55 20 54 79 70 65 20 20 20 20 20 3D 20 '.CPU Type     = '
FAR 03E140: 00 5F 5F 41 56 52 5F 41 52 43 48 5F 5F 20 3D 20 '.__AVR_ARCH__ = '
FAR 03E150: 00 41 56 52 20 4C 69 62 43 20 56 65 72 20 3D 20 '.AVR LibC Ver = '
FAR 03E160: 00 47 43 43 20 56 65 72 73 69 6F 6E 20 20 3D 20 '.GCC Version  = '
FAR 03E170: 00 43 50 55 20 73 69 67 6E 61 74 75 72 65 3D 20 '.CPU signature= '
FAR 03E180: 00 4C 6F 77 20 66 75 73 65 20 20 20 20 20 3D 20 '.Low fuse     = '
FAR 03E190: 00 48 69 67 68 20 66 75 73 65 20 20 20 20 3D 20 '.High fuse    = '
FAR 03E1A0: 00 45 78 74 20 66 75 73 65 20 20 20 20 20 3D 20 '.Ext fuse     = '
FAR 03E1B0: 00 4C 6F 63 6B 20 66 75 73 65 20 20 20 20 3D 20 '.Lock fuse    = '
FAR 03E1C0: 00 53 65 70 20 20 39 20 32 30 31 30 00 31 2E 36 '.Sep  9 2010.1.6'

This is the wrong format to be used for backup / flashed back into the CORE. Forthermore any other information, avrdude prints usually is missing.

Cheers mcc

So what?

You are not able to change the format to the needed? Then you should not mess around with that stuff.

That code example could at least give a view of the content of your flash, to use avrdude you have to connect the pins correctly, at least to read the fuses.

Ok....

I see.

I will keep my fingers off the Arduinos for now on...

I think its better for me to go back to my previous hobby...fishing and golf on sundays.

I still do not understand, why you would need to program via programmer, I use the normal bootloader way without feeling any need to change bootloader or erase sketches.