Code Monkey home page Code Monkey logo

Comments (9)

MCUdude avatar MCUdude commented on August 14, 2024 1

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:

https://github.com/MCUdude/avrdude/blob/37ac6ebaa0330470d14cff37256dfd94293fda83/src/CMakeLists.txt#L90

And DEFAULT_SPI_PORT="/dev/spidev0.0" here:

https://github.com/MCUdude/avrdude/blob/37ac6ebaa0330470d14cff37256dfd94293fda83/src/configure.ac#L452-L462

from avrdude.

stefanrueger avatar stefanrueger commented on August 14, 2024

Try installing libgpiod-dev and the rebuild avrdue to use libgpiod instead

from avrdude.

stefanrueger avatar stefanrueger commented on August 14, 2024

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.

from avrdude.

stefanrueger avatar stefanrueger commented on August 14, 2024

@BastienCagna It's been some time. Has your question been answered? Can the issue be closed?

from avrdude.

BastienCagna avatar BastienCagna commented on August 14, 2024

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;
;


from avrdude.

stefanrueger avatar stefanrueger commented on August 14, 2024

@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?

from avrdude.

mcuee avatar mcuee commented on August 14, 2024

@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.

from avrdude.

stefanrueger avatar stefanrueger commented on August 14, 2024

It may be as simple as adding ...

@MCUdude Great idea! Do you want to do a PR?

from avrdude.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.