Maple Mini as ISP

andyman49
Posts: 5
Joined: Sun Feb 26, 2017 8:14 am

Maple Mini as ISP

Postby andyman49 » Sun Feb 26, 2017 8:52 am

Has anyone used a Maple Mini as a programmer for ATTiny devices using ArduinoISP such as shown here http://www.ernstc.dk/arduino/attiny85.html

ArduinoISP compiles and uploads fine with my Maple Mini clone, but I not having any success using a SPI interface of the Maple Mini to program the AATTiny device. Any guidance would be great.

stevestrong
Posts: 892
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: Maple Mini as ISP

Postby stevestrong » Sun Feb 26, 2017 9:14 am

Sorry, but not having time to read through all that links, could you specify what exactly is the problem?
Is the SPI signal not corresponding to what you expect? Or you don't know how to use the SPI API?

andyman49
Posts: 5
Joined: Sun Feb 26, 2017 8:14 am

Re: Maple Mini as ISP

Postby andyman49 » Sun Feb 26, 2017 9:43 am

I am using Arduino IDE 1.69, and uploaded ArduinoISP changing the appropriate SPI 1 pins to MOSI (pin 4), MISO (pin 5), SCK (pin 6), and SS (pin 7). I don't have a scope to look at the signals so I am troubleshooting in the dark. Just thought I would ask if anyone had already gone down this path.

stevestrong
Posts: 892
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: Maple Mini as ISP

Postby stevestrong » Sun Feb 26, 2017 12:19 pm

Would be nice to see your code, otherwise we are tapping in the dark.
Also, please use PXY (e.g. PA4) notation for pins, not pure numbers.

andyman49
Posts: 5
Joined: Sun Feb 26, 2017 8:14 am

Re: Maple Mini as ISP

Postby andyman49 » Mon Feb 27, 2017 12:32 pm

I am using the ArduinoISP sketch that is found in Arduino IDE 1.6.9 ( or similar versions) under File > Examples > ArduinoISP. I have substituted the following defined pin constants in that sketch with:

/* define SPI interface for Maple Mini use */
#define PIN_MOSI PA7 // physical pin 4 on Maple Mini
#define PIN_MISO PA6 // physical pin 5 on Maple Mini
#define PIN_SCK PA5 // physical pin 6 on Maple Mini
#define RESET PA4 // physical pin 7 on Maple Mini

/* define LED indicators for Maple Mini use */
#define LED_PMODE PB1 // Programming LED - communicating with slave
#define LED_HB PB14 // Heartbeat LED - shows the programmer is running
#define LED_ERR PB13 // Error LED - Lights up if something goes wrong

The sketch compiles fine without any errors, but will not upload a sketch to the ATTiny when I change the Board to ATTiny85 , select the Programmer to Arduino as ISP , Clock to Internal 1MHz. The IDE times out after 10 tries with the following message:

avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x03
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x03
avrdude done. Thank you.
Problem uploading to board.


My modified sketch MapleISP is attached.
Attachments
MapleISP.ino
(15.98 KiB) Downloaded 4 times

stevestrong
Posts: 892
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: Maple Mini as ISP

Postby stevestrong » Mon Feb 27, 2017 1:06 pm

You did not attach your version with changed pin definitions. Please attach always your currently used version.
Also, how did you upload the sketch? Over USB DFU?
Can you see some output in the serial monitor window? You could add something to be output to test the connection. Serial is for STM32F103 chip the USB serial, where the baudrate is "fictive".
Otherwise, if you use an USB to serial adapter to connect to Serial 1 pins (PA9/10) I think you should adapt the avrdude config file for the used serial baudrate.

andyman49
Posts: 5
Joined: Sun Feb 26, 2017 8:14 am

Re: Maple Mini as ISP

Postby andyman49 » Mon Feb 27, 2017 1:35 pm

I have attached the sketch with the PXY annotation for the pins that I swapped from the original ArduinoISP sketch. Upload is via USB DFU. Nothing visible in the Serial Monitor window. I will try your suggestion to add to some code to test the output connection.
Attachments
MapleISP_V1.ino
(16.17 KiB) Downloaded 7 times

stevestrong
Posts: 892
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: Maple Mini as ISP

Postby stevestrong » Mon Feb 27, 2017 1:43 pm

I would just add to setup a simple

Code: Select all

Serial.begin();
while ( !Serial.isConnected() ) ; // wait for serial connection before continue
Serial.println("Arduino ISP application");

Be aware, that after flashing the new software, it can take up to 5 seconds till Windows 10 re-enumerates the serial ports.
After starting the serial monitor of Arduino IDE, and after you see the serial output, you should then close the serial monitor window to free up the serial port, in order to let avrdude to communicate with the board.

andyman49
Posts: 5
Joined: Sun Feb 26, 2017 8:14 am

Re: Maple Mini as ISP

Postby andyman49 » Tue Feb 28, 2017 9:52 am

So far, that appears to have worked. Maple Mini seems to be running the MapleISP code. The on-board led (PB1) has a heartbeat going and indicates that it is ready to go into programming mode. The next step is to set up the IDE for the ATtiny45 target processor " Board: ATTiny25/45/85 Chip: ATtiny45 Programmer: Arduino as ISP " . Then I uploaded another sketch (Blink.ino) to the ATtiny target . That is when I get the error "avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x03"

User avatar
Rick Kimball
Posts: 754
Joined: Tue Apr 28, 2015 1:26 am
Location: Eastern NC, US
Contact:

Re: Maple Mini as ISP

Postby Rick Kimball » Tue Feb 28, 2017 3:47 pm

I'm not running on the maple mini, but on a redpill. I have problems with it running over the native USB port. When I upload to an avr chip, the first 256 bytes go fine, the next block of 256 ends up with the first 4-8 bytes being corrupt. This pattern repeats itself for each 256 bytes of upload. The first few bytes get corrupted. If I just change the SERIAL to use Serial1 instead, it just works properly with the same exact upload file and avr chip. I've tested with a few different ones, atmega328p, atmega644p, attiny861.

I took a quick look at the CDC ACM code and it seems nightmarish. If I had to guess, I'd say the USB native buffering has issues with this arduino isp code. To be honest, I've stayed away from the usb native port most of the time opting for hardware serial if needed.

For me switching to a hardware serial port isn't an issue. I have a couple of redpills where the usb connectors have come loose and adding a usb dongle is a requirement anyways.

I noticed you weren't syncing. You might try using the command line avrdude with a lot of -v -v -v -v -v .. to see what is actually being sent and returned at the byte level.

You might also check the baud rate, although that probably isn't a problem when you use the native USB. It might be if you switch to a usb dongle that doesn't automatically adjust the speed.

The other thing I noticed is that you are using the PA7->PA4 pins. Those aren't 5v tolerant. You might switch to different pins if you want to be able to run with both 5v and 3.3v chips. I changed the reset code so that it uses an open drain to puil down the pin and switches to input to let the reset pin float to whatever VCC is using. I do have a pull up resistor on the reset pin.

One last thing, I'm just using the bit banged SPI code instead of native. No speed requirements on this stuff. It is also much simpler and provides a lot more pin choice options. I have this same code running on a TI Stellaris launchpad and it works fine there also.
-rick


Return to “Maple mini”

Who is online

Users browsing this forum: No registered users and 1 guest