pdesnoyers76
Posts: 22
Joined: Mon Feb 08, 2016 10:33 pm

RPI 2B can't load sketch to Arduino Pro Mini

Sat Feb 13, 2016 12:33 am

I follow the procedure from this web site to get the serial port up and connected to Arduino pro mini m328p.

http://spellfoundry.com/sleepy-pi/setti ... -raspbian/

Before I hook it up to my RPI, I tested it first with an arduino to see if it was functional. I loaded a dummy sketch to my m328p with and arduino uno r3 set as ISP. That works, and I sketch is sending data back to the arduino, I can see it via the serial console.

Next, RPI to m328p via the UART ports:
RPI m328p
GPIO 14: TXD -> RX
GPIO 15: RXD -> TX
GPIO 22: Reset -> RST
3.3v -> VCC
GND -> GND

Then I wired it as per url and I know I potentially have everything set right, the sketch on m328p is sending me data and I can see it from the serial console in Arduino IDE program from RPI. I aslo test in python a dummy scrip to see if the autoreset was working. And it does. The ready prompt from my sketch keep poping up from on the serial console. Why is its I can received data from the m328p via the UART port but and can't upload new sketch?
I keep getting these msg, I have my setting at 9600 baud, try every other speed with the same result.
avrdude-original: stk500_getsync() attempt 10 of 10: not in sync: resp=0x35

You don't need a USB to TTL gismos for this kind of setup... RPI can act as a programmer? Need help...

stevech
Posts: 144
Joined: Sun Jul 15, 2012 11:53 pm

Re: RPI 2B can't load sketch to Arduino Pro Mini

Sun Feb 14, 2016 12:33 am

User a serial or USB/serial bootloader, not this SPI programmer method.
Get an Arduino with the bootloader for serial pre-installed.

pdesnoyers76
Posts: 22
Joined: Mon Feb 08, 2016 10:33 pm

Re: RPI 2B can't load sketch to Arduino Pro Mini

Sun Feb 14, 2016 1:16 am

So you always need a USB/serial bootloader to load? That method suggested on that web site would not work?

User avatar
adun
Posts: 102
Joined: Fri Mar 20, 2015 9:25 am
Location: Switzerland

Re: RPI 2B can't load sketch to Arduino Pro Mini

Sun Feb 14, 2016 2:32 pm

To upload sketches using uart you must have a (arduino) bootloader pre loaded to your atmega328. That's why all arduino boards come preloaded with it. Using ISP does not need a bootloader and you can use the whole flash memory for your program.
You can also burn the arduino bootloader using ISP (SPI) and then program the chip like arduino uno through uart.

pdesnoyers76
Posts: 22
Joined: Mon Feb 08, 2016 10:33 pm

Re: RPI 2B can't load sketch to Arduino Pro Mini

Tue Feb 16, 2016 3:38 am

I did that successfully... then I can upload ode using programmer in IDE. It all ways works using the arduino, but when it try with
RPI it fail...ie I load sketch on the arduino to send the letter a on the serial port. I move the arduino to RPI and Iget data from the serial console in IDE. But I can't send a sketch. I'm I erasing the bootloader every time I load a sketch? I don't get it

User avatar
adun
Posts: 102
Joined: Fri Mar 20, 2015 9:25 am
Location: Switzerland

Re: RPI 2B can't load sketch to Arduino Pro Mini

Tue Feb 16, 2016 11:45 am

Are you programming the AVR through the RPi SPI (ISP) pins or UART?
With ISP you flash the whole chip -> overwrite the bootloader
With UART you need to choose that option in the IDE

pdesnoyers76
Posts: 22
Joined: Mon Feb 08, 2016 10:33 pm

Re: RPI 2B can't load sketch to Arduino Pro Mini

Tue Feb 16, 2016 8:32 pm

Ok, I did put the bootloader back on the Arduino PRO mini. The green light is blinking.

Next, RPI to m328p via the UART ports is connected as follow:
GPIO 14: TXD -> RX
GPIO 15: RXD -> TX
GPIO 22: Reset -> RST
3.3v -> VCC
GND -> GND

Still getting -> avrdude-original: stk500_getsync() attempt 10 of 10: not in sync: resp=0x00

"With UART you need to choose that option in the IDE" -> How? and Where?

pdesnoyers76
Posts: 22
Joined: Mon Feb 08, 2016 10:33 pm

Re: RPI 2B can't load sketch to Arduino Pro Mini

Tue Feb 16, 2016 10:21 pm

here the output

[email protected]:~# avrdude -v -c arduino -p ATMEGA328P -P /dev/ttyAMA0 -b 9600 -U flash:w:RFM12_Demo_ATmega328.cpp.hex

avrdude-original: Version 6.1, compiled on Jul 7 2015 at 10:29:47
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch

System wide configuration file is "/etc/avrdude.conf"
User configuration file is "/root/.avrduderc"
User configuration file does not exist or is not a regular file, skipping

Using Port : /dev/ttyAMA0
Using Programmer : arduino
Overriding Baud Rate : 9600
done with autoreset
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe
avrdude-original: stk500_recv(): programmer is not responding
avrdude-original: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe

User avatar
adun
Posts: 102
Joined: Fri Mar 20, 2015 9:25 am
Location: Switzerland

Re: RPI 2B can't load sketch to Arduino Pro Mini

Wed Feb 17, 2016 9:38 am

Ok put the bootloader back to the A328p using ISP with avrdude
Then download the arduino IDE.
Image
Select under Board: Arduino UNO
Select under Port the RPi uart port: Make sure you did Step 3 (Link the Serial port to the Arduino IDE) and fixed the DTR line from
your UP link.
PS: I hope you did use a voltage level converter between the RPi and the Arduino if it runs at 5V:
The 3.3V Arduino is 8MHz. To run at 16MHz, 5V is needed.

pdesnoyers76
Posts: 22
Joined: Mon Feb 08, 2016 10:33 pm

Re: RPI 2B can't load sketch to Arduino Pro Mini

Wed Feb 17, 2016 10:20 pm

Did all that. And still can't load sketch...
code for autoreset:

Code: Select all

#!/usr/bin/python

import RPi.GPIO as GPIO
import sys, os, re, time, fcntl

fd = sys.stdin.fileno()
fl = fcntl.fcntl(fd, fcntl.F_GETFL)
fcntl.fcntl(fd, fcntl.F_SETFL, fl | os.O_NONBLOCK)

GPIO.setmode(GPIO.BCM)
dtr = re.compile('.+TIOCM_DTR.+')
start = time.time()

def reset():
  pin = 36
  GPIO.setup(pin, GPIO.OUT)
  GPIO.output(pin, GPIO.HIGH)
  time.sleep(0.12)
  GPIO.output(pin, GPIO.LOW)

def process():
  while True:
    try: 
      duration = time.time() - start
      input = sys.stdin.readline().strip()
      if dtr.match(input):
        reset()
        return
      elif duration > 5000:
        return
    except:
      continue

process()
GPIO.cleanup()
print "done with autoreset"
For the test, I used the sketch blink in arduino ide and it failed the m328p is plugin as mention before, I try using Arduinio Uno, Sleepy pi, m328p 3.3 and 5v.... And still not working.... Dose it mater if arduino IDE was install before the uart port were available? m328p has the steady blinking ready light, so the bootloader is there and working... So I don't know.

User avatar
adun
Posts: 102
Joined: Fri Mar 20, 2015 9:25 am
Location: Switzerland

Re: RPI 2B can't load sketch to Arduino Pro Mini

Thu Feb 18, 2016 11:08 am

In your code
def reset():
pin = 36
GPIO.setup(pin, GPIO.OUT)
GPIO.output(pin, GPIO.HIGH)
time.sleep(0.12)
GPIO.output(pin, GPIO.LOW)
You define reset pin=36. If 36 is meant to be the J8 pin numbering this would be Pin36=GPIO16 and not 22 for Reset.

But you did set
GPIO.setmode(GPIO.BCM)
what means that the BCM pin numbering is used. GPIO 36 however is not available on RPi.

To use BOARD numbering system set

Code: Select all

GPIO.setmode(GPIO.BOARD)

pdesnoyers76
Posts: 22
Joined: Mon Feb 08, 2016 10:33 pm

Re: RPI 2B can't load sketch to Arduino Pro Mini

Fri Feb 19, 2016 2:42 am

I finally got my usb to uart bridge, and guess what, still not working...

So I plug the uart bridge to my PC and tried it without success. I went back to arduino and reburn the bootloader and here the output. It seam fine to me.

Code: Select all

C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -cstk500v1 -PCOM4 -b19200 -Uflash:w:C:\Program Files (x86)\Arduino\hardware\arduino\avr/bootloaders/atmega/ATmegaBOOT_168_atmega328_pro_8MHz.hex:i -Ulock:w:0x0F:m 

avrdude: Version 6.0.1, compiled on Apr 15 2015 at 19:59:58
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Reading | ################################################## | 100% 0.01s
         Copyright (c) 2007-2009 Joerg Wunsch


avrdude: verifying ...
         System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"
avrdude: 1 bytes of lock verified
avrdude: reading input file "0x05"
avrdude: writing efuse (1 bytes):

Writing | ################################################## | 100% 0.00s

avrdude: 1 bytes of efuse written
avrdude: verifying efuse memory against 0x05:
avrdude: load data efuse data from input file 0x05:
avrdude: input file 0x05 contains 1 bytes
avrdude: reading on-chip efuse data:

Reading | ################################################## | 100% 0.02s

avrdude: verifying ...
avrdude: 1 bytes of efuse verified
avrdude: reading input file "0xDA"
avrdude: writing hfuse (1 bytes):

Writing | ################################################## | 100% -0.00s

avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0xDA:
avrdude: load data hfuse data from input file 0xDA:
avrdude: input file 0xDA contains 1 bytes
avrdude: reading on-chip hfuse data:

Reading | ################################################## | 100% 0.02s

avrdude: verifying ...
avrdude: 1 bytes of hfuse verified
avrdude: reading input file "0xFF"
avrdude: writing lfuse (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0xFF:
avrdude: load data lfuse data from input file 0xFF:
avrdude: input file 0xFF contains 1 bytes
avrdude: reading on-chip lfuse data:

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

avrdude: verifying ...
avrdude: 1 bytes of lfuse verified

avrdude done.  Thank you.


         Using Port                    : COM4
         Using Programmer              : stk500v1
         Overriding Baud Rate          : 19200
         AVR Part                      : ATmega328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         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    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  4500 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 STK500 Version 1.x firmware
         Hardware Version: 2
         Firmware Version: 1.18
         Topcard         : Unknown
         Vtarget         : 0.0 V
         Varef           : 0.0 V
         Oscillator      : Off
         SCK period      : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e950f
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "C:\Program Files (x86)\Arduino\hardware\arduino\avr/bootloaders/atmega/ATmegaBOOT_168_atmega328_pro_8MHz.hex"
avrdude: writing flash (32652 bytes):

Writing | ################################################## | 100% 0.00s

avrdude: 32652 bytes of flash written
avrdude: verifying flash memory against C:\Program Files (x86)\Arduino\hardware\arduino\avr/bootloaders/atmega/ATmegaBOOT_168_atmega328_pro_8MHz.hex:
avrdude: load data flash data from input file C:\Program Files (x86)\Arduino\hardware\arduino\avr/bootloaders/atmega/ATmegaBOOT_168_atmega328_pro_8MHz.hex:
avrdude: input file C:\Program Files (x86)\Arduino\hardware\arduino\avr/bootloaders/atmega/ATmegaBOOT_168_atmega328_pro_8MHz.hex contains 32652 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% -0.00s

avrdude: verifying ...
avrdude: 32652 bytes of flash verified
avrdude: reading input file "0x0F"
avrdude: writing lock (1 bytes):

Writing | ################################################## | 100% 0.03s

avrdude: 1 bytes of lock written
avrdude: verifying lock memory against 0x0F:
avrdude: load data lock data from input file 0x0F:
avrdude: input file 0x0F contains 1 bytes
avrdude: reading on-chip lock data:

Reading | ################################################## | 100% 0.02s

avrdude: verifying ...
avrdude: 1 bytes of lock verified

avrdude done.  Thank you.
After I tried to upload a sketch via the arduino with the command line. Here the out put.

Code: Select all

C:\Program Files (x86)\Arduino\hardware\tools\avr\bin>avrdude -Cavrdude.conf -v -patmega328p -cstk500v1 -PCOM4 -b19200 -Uflash:w:C
:\Users\Philippe\AppData\Local\Temp\build9c9ef3bdfe2fccb480bc6e4bac749e41.tmp/Blink.ino.hex:i -D

avrdude: Version 6.0.1, compiled on Apr 15 2015 at 19:59:58
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "avrdude.conf"

         Using Port                    : COM4
         Using Programmer              : stk500v1
         Overriding Baud Rate          : 19200
         AVR Part                      : ATmega328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         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    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  4500 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 STK500 Version 1.x firmware
         Hardware Version: 2
         Firmware Version: 1.18
         Topcard         : Unknown
         Vtarget         : 0.0 V
         Varef           : 0.0 V
         Oscillator      : Off
         SCK period      : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.03s

avrdude: Device signature = 0x1e950f
avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as DA
avrdude: safemode: efuse reads as 5
avrdude: reading input file "C:\Users\Philippe\AppData\Local\Temp\build9c9ef3bdfe2fccb480bc6e4bac749e41.tmp/Blink.ino.hex"
avrdude: writing flash (1030 bytes):

Writing | ################################################## | 100% 1.31s

avrdude: 1030 bytes of flash written
avrdude: verifying flash memory against C:\Users\Philippe\AppData\Local\Temp\build9c9ef3bdfe2fccb480bc6e4bac749e41.tmp/Blink.ino.h
ex:
avrdude: load data flash data from input file C:\Users\Philippe\AppData\Local\Temp\build9c9ef3bdfe2fccb480bc6e4bac749e41.tmp/Blink
.ino.hex:
avrdude: input file C:\Users\Philippe\AppData\Local\Temp\build9c9ef3bdfe2fccb480bc6e4bac749e41.tmp/Blink.ino.hex contains 1030 byt
es
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.76s

avrdude: verifying ...
avrdude: 1030 bytes of flash verified

avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as DA
avrdude: safemode: efuse reads as 5
avrdude: safemode: Fuses OK (H:05, E:DA, L:FF)

avrdude done.  Thank you.
What wrong... Arduino UNO iis connect to pro mini as below --- on the chip it it mega328pau 1533
11 to 11, 12 to 12, 13 to 13, 10 to rst, 3.3 to vcc and GND to GND.

Help!!!!!!!!

User avatar
adun
Posts: 102
Joined: Fri Mar 20, 2015 9:25 am
Location: Switzerland

Re: RPI 2B can't load sketch to Arduino Pro Mini

Fri Feb 19, 2016 6:22 pm

So again you want to flash the bootloader on your Arduino Pro Mini using an Arduino UNO as ISP programmer?
I thought you want be able to upload sketches using uart.
I you want to do it with RPi fix the DTR-Code as I suggested above.
If you want to use an USB-Serial bridge you only have to choose the right uart-port in the Arduino IDE.
Check if you have an 3V or 5V arduino. -> If 5V use resistors
Image
If you have still problems upload a photo of your wiring.

pdesnoyers76
Posts: 22
Joined: Mon Feb 08, 2016 10:33 pm

Re: RPI 2B can't load sketch to Arduino Pro Mini

Fri Feb 19, 2016 9:21 pm

At this point I'm just try to get my PC to talk to the pro mini directly via a MICRO-USB-to-UART-TTL-Module-6Pin-Serial-Converter-CP2102(look on ebay). If I get that to work then it will be easier to get the RPI to work.

This is the pro mini I have:
http://www.amazon.ca/DIYmall-Leonardo-A ... tible+Nano

When I try with UART bridge, it's connected this way: UART Bridge - Pro Mini
DST - RST, 3.3V - VCC, GND -GND, TX - RX, RX -TX.

Simple question, can you send sketch to a pro mini without a programmer? Do in need specific bootloader on pro mini????

asandford
Posts: 1997
Joined: Mon Dec 31, 2012 12:54 pm
Location: Waterlooville

Re: RPI 2B can't load sketch to Arduino Pro Mini

Fri Feb 19, 2016 9:40 pm

pdesnoyers76 wrote: Simple question, can you send sketch to a pro mini without a programmer? Do in need specific bootloader on pro mini????
To load a sketch to a 'classic' Arduino (not the recent ARM hybrids), the 3 methods I've used are:
Use USB and bootloader (OK)
Use serial (UART) pins and a simulated DTR to pulse the reset pin, with a bootloader (Flakey)
Use the ICSP interface with SPI and wipe any bootloader, but load your sketch (OK)

pdesnoyers76
Posts: 22
Joined: Mon Feb 08, 2016 10:33 pm

Re: RPI 2B can't load sketch to Arduino Pro Mini

Sat Feb 20, 2016 12:38 pm

Use USB and bootloader (OK)
Doesn't work:
avrdude-original: stk500_recv(): programmer is not responding
Use serial (UART) pins and a simulated DTR to pulse the reset pin, with a bootloader (Flakey)
Doesn't work either:
avrdude-original: stk500_recv(): programmer is not responding
Use the ICSP interface with SPI and wipe any bootloader, but load your sketch (OK)
So far this is the only way I can load sketches.

I don't understand why the 2 first options don't work.

User avatar
adun
Posts: 102
Joined: Fri Mar 20, 2015 9:25 am
Location: Switzerland

Re: RPI 2B can't load sketch to Arduino Pro Mini

Sat Feb 20, 2016 3:03 pm

I told you in UP that your DTR code has some errors. That's why it doesn't work.
For the USB-Serial bridge it should work out of the box. Only thing I can imagine is that you did a wiring error. That's why I suggested that you post a photo of your setup.

pdesnoyers76
Posts: 22
Joined: Mon Feb 08, 2016 10:33 pm

Re: RPI 2B can't load sketch to Arduino Pro Mini

Sat Feb 20, 2016 6:45 pm

I told you in UP that your DTR code has some errors. That's why it doesn't work.
I saw that and thanks. But I might of post it but I apply that fix and it still didn't work. That's why I move to my PC with the USB/serial converter

As for picture there you go. And a side note I move the DTR from BLK to GRN on adrduino and it doesn't change the outcome.
Attachments
IMG_1017.jpg
IMG_1017.jpg (25.23 KiB) Viewed 4255 times
IMG_1020.jpg
IMG_1020.jpg (61.87 KiB) Viewed 4255 times
IMG_1019.jpg
IMG_1019.jpg (43.91 KiB) Viewed 4255 times

User avatar
adun
Posts: 102
Joined: Fri Mar 20, 2015 9:25 am
Location: Switzerland

Re: RPI 2B can't load sketch to Arduino Pro Mini

Sat Feb 20, 2016 11:58 pm

Let's first try to get the USB-UART methode running:
If you have a 5V arduino you must connect the 5V pin to VCC.
Are you sure you have a 3V3 arduino ?

However the correct wiring should be:

FTDI -> Arduino Pro Mini prog header
=============
DTR -> GRN (Reset)
RX -> TX
TX -> RX
3V3 ->VCC (If you have a 3V3 arduino)
CTS ->GND (If available)
GND->GND
GND->BLK

The arduino has a RAW pin where you can power it with any voltage from 3.4 to 12V.
If you are not sure just disconnect the 3V3 -> VCC line and connect 5V -> RAW.
avrdude-original: stk500_recv(): programmer is not responding
This error happens often when the reset before code upload can't be executed. That's why we had to fix the DTR line on the RPi.
So as the error is still there on both the RPI and the USB-Serial bridge you seem to have a problem with your reset line.
Other possibilities could be:
-bootloader is corrupted/has crashed
-you did not selected proper port and proper board from arduino IDE
-serial port is in use (console/PuTTY/Arduino Serial Monitor etc) or communicating with an other device
-old/bad usb-serial bridge driver
-wrong baud rate set

You can also try to manually reset the board to test if your problem is reset-related:
During upload, you should see avrdude sending.
The trick is to hit the reset button on the board immediately before packets are sent. Then the program should be uploaded successfully. If it doesn't work try to press the reset button on the board after you hit the upload button in different intervals of time up to 10 seconds or more.

pdesnoyers76
Posts: 22
Joined: Mon Feb 08, 2016 10:33 pm

Re: RPI 2B can't load sketch to Arduino Pro Mini

Sun Feb 21, 2016 11:33 am

It's working... The GRN I thought it was Ground. Why they didn't call it RST or just plain RESET.... What dose it stand for GRN, green? Anyways.... So I reconnect everything the way you said and change to 57600 baud and "ET VOILA".... I'm sure I already try this but... I tried again on RPI with the usb and it's work... So in turn I tried with the UART port and what do you know it works... At first it didn't because I had my reset in the wrong GPIO but in the end it work.

The combination of wiring being wrong and baud rate being set to low cause all my problem. So here how it plug.
In any case, baudrate at 57600
FTDI -> Arduino Pro Mini prog header
=============
DTR -> GRN (Reset)
RX -> TX
TX -> RX
3V3 ->VCC
GND->GND

This is how it's plug via the RPI
RPI -> Arduino Pro Mini prog header
=============
GPIO 16 -> GRN (Reset)
UART RX -> TX
UART TX -> RX
GPIO 1 3V3 ->VCC
GPIO 39 GND->GND

autoreset file:

Code: Select all

#!/usr/bin/python

import RPi.GPIO as GPIO
import sys, os, re, time, fcntl

fd = sys.stdin.fileno()
fl = fcntl.fcntl(fd, fcntl.F_GETFL)
fcntl.fcntl(fd, fcntl.F_SETFL, fl | os.O_NONBLOCK)

GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
dtr = re.compile('.+TIOCM_DTR.+')
start = time.time()
pin = 16

def reset():
  GPIO.setup(pin, GPIO.OUT)
  GPIO.output(pin, GPIO.HIGH)
  time.sleep(0.34)
  GPIO.output(pin, GPIO.LOW)

def process():
  while True:
    try: 
      duration = time.time() - start
      input = sys.stdin.readline().strip()
      if input is None: # == "":
        input = sys.stdin.readline().strip()
      if dtr.match(input):
        reset()
        return
      elif duration > 5000:
        return
    except Exception as e:
      if hasattr(e, 'errno'):
	if e.errno != 11: # Ignore resource unavailable
         raise
      else:
        raise

process()
print "avrdude-original: Using autoreset DTR on GPIO Pin " +str(pin)
GPIO.cleanup()
exit
It's always a code "13" -> Problem is between the keyboard and the chair....

Thanks for the help...

User avatar
adun
Posts: 102
Joined: Fri Mar 20, 2015 9:25 am
Location: Switzerland

Re: RPI 2B can't load sketch to Arduino Pro Mini

Sun Feb 21, 2016 8:07 pm

GRN stands for green and should be reffered to the green end of the FTDI board. But you're right this is confusing.
However I'm glad it finally worked.

Return to “Advanced users”