Closed BastienCagna closed 4 days ago
Apparently new kernel versions base the GPIO numbers at 512, not 0. So, another workaround is to add 512 to the gpio numbers of your linuxgpio entry in ~/.avrduderc.
@BastienCagna It's been some time. Has your question been answered? Can the issue be closed?
Hey, Thanks for your answers @stefanrueger ! Sorry I didn't work oon this project since my post. I guess I fixed the issue I was describing using libgpio. But now, it's looks like avrdude can not communicate with the MCU. Whe I execute the following command (which just worked few minutes ago on raspberry pi 3B), it says that the MCU is not responding :(
sudo /usr/local/bin/avrdude -p t2313 -c linuxgpio -P gpiochip0 -U flash:w:test.hex -v
avrdude: Version 7.3-20240428 (37ac6eba)
Copyright the AVRDUDE authors;
see https://github.com/avrdudes/avrdude/blob/main/AUTHORS
System wide configuration file is /usr/local/etc/avrdude.conf
User configuration file is /root/.avrduderc
User configuration file does not exist or is not a regular file, skipping
using libgpiod for linuxgpio
Using port : gpiochip0
Using programmer : linuxgpio
avrdude: input file test.hex auto detected as Intel Hex
AVR Part : ATtiny2313
Programming modes : ISP, HVPP, debugWIRE, SPM
Programmer Type : linuxgpio
Description : Use the Linux sysfs interface to bitbang GPIO lines
Pin assignment : libgpiod
RESET = 22
SCK = 11
SDO = 10
SDI = 9
avrdude bitbang_initialize() error: AVR device not responding
avrdude main() error: initialization failed, rc=-1
- double check the connections and try again
- use -B to set lower the bit clock frequency, e.g. -B 125kHz
- use -F to override this check
avrdude done. Thank you.
It tried to change baudrate (-B 100) but it also failed. I also tried with gpiochip4 but same error.
Also, here is the state of pinctrl just after trying to flash:
$ pinctrl
0: ip pu | hi // ID_SDA/GPIO0 = input
1: ip pu | hi // ID_SCL/GPIO1 = input
2: no pu | -- // GPIO2 = none
3: no pu | -- // GPIO3 = none
4: no pu | -- // GPIO4 = none
5: no pu | -- // GPIO5 = none
6: no pu | -- // GPIO6 = none
7: no pu | -- // GPIO7 = none
8: no pu | -- // GPIO8 = none
9: ip pd | lo // GPIO9 = input
10: ip pd | lo // GPIO10 = input
11: ip pd | lo // GPIO11 = input
12: no pd | -- // GPIO12 = none
13: no pd | -- // GPIO13 = none
14: no pd | -- // GPIO14 = none
15: no pd | -- // GPIO15 = none
16: no pd | -- // GPIO16 = none
17: no pd | -- // GPIO17 = none
18: no pd | -- // GPIO18 = none
19: no pd | -- // GPIO19 = none
20: no pd | -- // GPIO20 = none
21: no pd | -- // GPIO21 = none
22: ip pd | lo // GPIO22 = input
23: no pd | -- // GPIO23 = none
24: no pd | -- // GPIO24 = none
25: no pd | -- // GPIO25 = none
26: op dh pd | hi // GPIO26 = output
27: no pd | -- // GPIO27 = none
...
I then tried to set mannualy the pin to their needed function (using a0 for GPIO9 10 & 11 et setting 22 to ouput and high logical state). avrdude looks to not change those state and not reset is seen on the MCU.
I have no ~/.avrduderc but I guess it is equivalent to the global configuration made in avrdude.conf. So your workaround is to specify SCK = 512 + 11 = 523 ? For me it failed (but as I said, the first problem looks already fixed now for me).
If it may help, Here is a sample of my avrdude.conf (by the way, the empty default spi suprised me):
#
# Overall avrdude defaults; suitable for ~/.config/avrdude/avrdude.rc
#
default_parallel = "/dev/parport0";
default_serial = "/dev/ttyS0";
default_spi = "";
# default_baudrate = 115200;
# default_bitclock = 2.5;
default_linuxgpio = "gpiochip4";
allow_subshells = no;
# This programmer bitbangs GPIO lines using the Linux libgpiod or sysfs GPIO interface
#
# To enable it set the configuration below to match the GPIO lines connected
# to the relevant ISP header pins and uncomment the entry definition. In case
# you don't have the required permissions to edit this system wide config
# file put the entry in a separate <your name>.conf file and use it with
# -C+<your name>.conf on the command line.
#
# To check if your avrdude build has support for the linuxgpio programmer
# compiled in, use -c?type on the command line and look for linuxgpio in the
# list. If it's not available you need pass the --enable-linuxgpio=yes option
# to configure and recompile avrdude.
#
#
# #------------------------------------------------------------
# # linuxgpio
# #------------------------------------------------------------
#
programmer
id = "linuxgpio";
desc = "Use the Linux sysfs interface to bitbang GPIO lines";
type = "linuxgpio";
prog_modes = PM_ISP;
connection_type = linuxgpio;
reset = 22;
sck = 11;
sdo = 10;
sdi = 9;
;
@BastienCagna The short of it is that I don't have an answer. This requires more debugging. The posted run looks like libgpiod
is compiled in and working; you are using the latest git-main. You tried -P gpiochip0
and also -P gpiochip4
(which seems to be suggested by the build system judging from your system avrdude.conf). You say it works with an RPi 3b. Is the failing run on an RPi 5? Have you installed libgpiod-dev
and compiled avrdude on the RPi 5? @mcuee can you reproduce above? @BastienCagna Can you post a -vv
output and upload the output of a -vvvv
run?
the empty default spi suprised me
@BastienCagna If you know a method to set default_spi
from the build system please let us know. @mcuee? @MCUdude?
It looks like neither the auto tools nor Cmake deals with the default_spi
port.
It may be as simple as adding set(DEFAULT_SPI_PORT "/dev/spidev0.0")
here:
And DEFAULT_SPI_PORT="/dev/spidev0.0"
here:
@stefanrueger and @BastienCagna
I do not have Raspberry Pi 5, but libgpiod and git main work well for me on my Raspberry Pi 400. I have no idea why it does not work on Raspberry Pi 5.
I can only suggest @BastienCagna to check the connection. The other suggestion is to try linuxspi as well to see if that works or not. Or try another MCU to see if that makes a difference or not.
Reference: my test results posted for PR #1792.
It may be as simple as adding ...
@MCUdude Great idea! Do you want to do a PR?
@BastienCagna Any updates on this issue? Thanks.
It may be as simple as adding ...
@MCUdude Great idea! Do you want to do a PR?
Adding enhancement
label to capture this one.
Do we have an update on this? @BastienCagna Have you solved the problem and want to share the solution?
Other than that I suggest closing the issue in a week or so
@BastienCagna
Any updates? If not we will close the issue.
No updates. Close this issue for now. Please reopen if you have new info.
Hello, I was using avrdude to flash my MCU from an old Raspberry Pi 3 and recently move to the new Pi 5. I was used to flash using this command:
But now, it return that:
I know that this new version of the raspberry use the new RP1 chip to control GPIO. Could it be the source of this trouble? May exist a workarround?
Regards, Bastien