Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on RaspberryPi B+ #3

Closed
jmatsushita opened this issue Mar 12, 2015 · 8 comments
Closed

Error on RaspberryPi B+ #3

jmatsushita opened this issue Mar 12, 2015 · 8 comments

Comments

@jmatsushita
Copy link

Traceback (most recent call last):
  File "/usr/bin/autoreset", line 43, in <module>
    process()
  File "/usr/bin/autoreset", line 32, in process
    reset()
  File "/usr/bin/autoreset", line 18, in reset
    GPIO.setmode(GPIO.BCM)
ValueError: A different mode has already been set!
avrdude-original: stk500_recv(): programmer is not responding
@jmatsushita
Copy link
Author

Commenting out

GPIO.setmode(GPIO.BOARD)

Seems to workaround this particular error, but then I get the following error

avrdude -v -c arduino -p ATMEGA328P -P /dev/ttyAMA0 -b9600

avrdude-original: Version 5.11.1, compiled on May 23 2012 at 11:08:25
                  Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
                  Copyright (c) 2007-2009 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

avrdude-original: Using autoreset DTR on GPIO 4
avrdude-original: stk500_getsync(): not in sync: resp=0x6f

@shulter
Copy link

shulter commented Mar 12, 2015

avrdude-original: stk500_getsync(): not in sync: resp=0x6f

means, that the MCU did not reset or speaks at a wrong baud rate. A good indication for that is, if the returned error hex values are most of the time identical.

Try -b38400 instead of your -b9600 please.

@jmatsushita
Copy link
Author

Bingo! Works on the Raspberry Pi B. Will try B+ now.

avrdude -v -c arduino -p ATMEGA328P -P /dev/ttyAMA0 -b 38400 

avrdude-original: Version 5.11.1, compiled on May 23 2012 at 11:08:25
                  Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
                  Copyright (c) 2007-2009 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          : 38400
avrdude-original: Using autoreset DTR on GPIO 4
                  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 : Arduino
                  Description     : Arduino
                  Hardware Version: 3
                  Firmware Version: 4.4
                  Vtarget         : 0.3 V
                  Varef           : 0.3 V
                  Oscillator      : 28.800 kHz
                  SCK period      : 3.3 us

avrdude-original: AVR device initialized and ready to accept instructions

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

avrdude-original: Device signature = 0x1e950f
avrdude-original: safemode: lfuse reads as 0
avrdude-original: safemode: hfuse reads as 0
avrdude-original: safemode: efuse reads as 0

avrdude-original: safemode: lfuse reads as 0
avrdude-original: safemode: hfuse reads as 0
avrdude-original: safemode: efuse reads as 0
avrdude-original: safemode: Fuses OK

@jmatsushita
Copy link
Author

Works on the B+ as well with the GPIO.setmode(GPIO.BOARD) commented out.

@pb66
Copy link

pb66 commented Mar 13, 2015

Can you confirm are you saying that even after selecting the correct baud you still had to comment out "GPIO.setmode(GPIO.BOARD)" for this to work on a B+ ?

Paul

@jmatsushita
Copy link
Author

Hi Paul,

Yes that's correct. With the "GPIO.setmode(GPIO.BOARD)" as in the original code, but with this pull request modification (otherwise autoreset just runs in the background with no error message and I had to run strace manually to find out why), then that's the error:

avrdude -v  -c arduino -p ATMEGA328P -P /dev/ttyAMA0 -b 38400 -U flash:w:RF12_Demo_atmega328.cpp.hex

avrdude-original: Version 5.11.1, compiled on May 23 2012 at 11:08:25
                  Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
                  Copyright (c) 2007-2009 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          : 38400
Traceback (most recent call last):
  File "/usr/bin/autoreset", line 43, in <module>
    process()
  File "/usr/bin/autoreset", line 32, in process
    reset()
  File "/usr/bin/autoreset", line 18, in reset
    GPIO.setmode(GPIO.BCM)
ValueError: A different mode has already been set!

@pb66
Copy link

pb66 commented Mar 13, 2015

Ok, the issue seems to be strictly "RFM2Pi" related and not something deanmao would be aware of. deanmao originally used GPIO.setmode(GPIO.BOARD) & .pin 11 for reset (P1-26 or BCM GPIO07) and when it was adapted by @mharizanov he changed it to use (GPIO.setmode(GPIO.BCM) pin 4 (P1-7) but left the previous setmode in place (it just gone unnoticed in the background until now).

Since the mapping can change but the physical pin that aligns with the RFM2Pi cannot change. I think it would be wiser to revert back to the original GPIO.setmode(GPIO.BOARD), remove the (GPIO.setmode(GPIO.BCM) line and set the pin number to 7. This way it will always be right unless the rfm2pi is physically changed.

Are you in a position to (easily) test that theory by any chance? and then we can get the repo's updated.
Paul

@glynhudson
Copy link

Hi Paul,
I've just tested this and changing to 'BOARD' referencing and changing the pin to 7 works perfectly. I've changed autoreset to use this referencing to keep constant with hardware. I was getting the same error on RasPi2: openenergymonitor@3cfe865

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants