Skip to content

platformio fails to upload #31136

Closed
Closed

Description

@wucke13

Issue description

platformio fails to upload to an arduino, due to a missing library.
/home/$HOME/.platformio/packages/tool-avrdude/avrdude: error while loading shared libraries: libreadline.so.6: cannot open shared object file: No such file or directory

Steps to reproduce

  • Install platformio
  • initialize a project, make a sample main.c
  • platformio run -t upload.

Technical details

  • System: 17.09.1927.6a0a00d91e (Hummingbird)
  • Nix version: nix-env (Nix) 1.11.15
  • Nixpkgs version: "17.09.1927.6a0a00d91e"
  • Sandboxing enabled: build-use-sandbox = false

Activity

  1. lukateras commented on Nov 2, 2017

    @lukateras
    Member

    Probably could be fixed by adding readline62 to https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/arduino/platformio/chrootenv.nix targetPkgs. Not sure if it needs multiPkgs at all.

    I don't have an Arduino, could you please check the following?

    Save this as platformio.nix:

    { stdenv, buildFHSUserEnv }:
    
    buildFHSUserEnv {
      name = "platformio";
    
      targetPkgs = pkgs: with pkgs; [
        pythonPackages.python
        pythonPackages.setuptools
        pythonPackages.pip
        pythonPackages.bottle
        pythonPackages.platformio
        readline62
        zlib
      ];
    
      meta = with stdenv.lib; {
        description = "An open source ecosystem for IoT development";
        homepage = http://platformio.org;
        maintainers = with maintainers; [ mog ];
        license = licenses.asl20;
        platforms = with platforms; linux;
      };
    
      runScript = "platformio";
    }
    

    And build it with nix-build -E "with import <nixpkgs> {}; callPackage ./platformio.nix {}". Check if it uploads now with result/bin/platformio run -t upload.

  2. wucke13 commented on Nov 3, 2017

    @wucke13
    ContributorAuthor

    This does not work. An interesting side node: platformio itself downloads the avrdude binary to $HOME/.platformio/packages/tool-avrdude/avrdude_bin. The file $HOME/.platformio/packages/tool-avrdude/avrdude is only a wrapper script to redirect input and ouput:

    #!/bin/bash
    
    export LD_LIBRARY_PATH="`dirname "$0"`"
    exec -a "$0" "`dirname "$0"`/avrdude_bin" "$@"
    

    So an easy workaround is to install avrdude itself and replace

    exec -a "$0" "`dirname "$0"`/avrdude_bin" "$@"
    

    with
    exec -a "$0" "`which avrdude`" "$@"
    Can this be fixed in nix? Or is it somewhat unrealistic to provide the needed library for this prebuilt binary of avrdude?

  3. lukateras commented on Nov 3, 2017

    @lukateras
    Member

    This does not work.

    Could you please show stderr?

  4. wucke13 commented on Nov 5, 2017

    @wucke13
    ContributorAuthor

    By 'This does not work.' is meant, that the same error as described in the original bug report still occurs. The nix-expression itself builds fine, but without touching the problem.

  5. lukateras commented on Nov 5, 2017

    @lukateras
    Member

    I've just got ~/.platformio/packages/tool-avrdude and for me it doesn't depend on libreadline.so.6:

    $ result/bin/platformio-chrootenv -c "ldd ~/.platformio/packages/tool-avrdude/avrdude_bin"
    	linux-vdso.so.1 (0x00007ffcd0681000)
    	librt.so.1 => /usr/lib/librt.so.1 (0x00007ff61185d000)
    	libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007ff61163f000)
    	libm.so.6 => /usr/lib/libm.so.6 (0x00007ff61132c000)
    	libc.so.6 => /usr/lib/libc.so.6 (0x00007ff610f8d000)
    	/lib64/ld-linux-x86-64.so.2 (0x00007ff611a65000)
    

    Meaning that short-term you can probably just wipe out ~/.platformio and reinstall.

    Can this be fixed in nix? Or is it somewhat unrealistic to provide the needed library for this prebuilt binary of avrdude?

    The problem here is that LD_LIBRARY_PATH is overridden. This will be fixed after #31263 lands in and we switch to NIX_LD_LIBRARY_PATH for FHS chroot environments.

  6. wucke13 commented on Nov 8, 2017

    @wucke13
    ContributorAuthor

    Ok. I will close for now, and reopen if the problem persists in a while. Thanks!

  7. lukateras commented on Nov 8, 2017

    @lukateras
    Member

    @wucke13 Better to leave open if that's still an issue.

  8. wucke13 commented on Nov 8, 2017

    @wucke13
    ContributorAuthor

    Ok then. I still have the error. Did the following:

    1. rm -rf ~/.platformio
    2. sudo nixos-rebuild switch --upgrade
    3. platformio run -t upload inside of an platformio project folder. The following is the result:
    ******************************************************************************************************************************************************************************************************
    If you like PlatformIO, please:
    - follow us on Twitter to stay up-to-date on the latest project news > https://twitter.com/PlatformIO_Org
    - star it on GitHub > https://github.com/platformio/platformio
    - try PlatformIO IDE for IoT development > http://platformio.org/platformio-ide
    - donate to keep PlatformIO alive! > http://platformio.org/donate
    ******************************************************************************************************************************************************************************************************
    
    [Wed Nov  8 11:13:28 2017] Processing nanoatmega328 (platform: atmelavr, board: nanoatmega328, framework: arduino)
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    The platform 'atmelavr' has not been installed yet. Would you like to install it now? [y/N]: y
    Installing framework-arduinoavr package:
    Downloading  [####################################]  100%
    Unpacking  [####################################]  100%
    Installing tool-avrdude package:
    Downloading  [####################################]  100%
    Unpacking  [####################################]  100%
    Installing tool-scons package:
    Downloading  [####################################]  100%
    Unpacking  [####################################]  100%
    Installing toolchain-atmelavr package:
    Downloading  [####################################]  100%          
    Unpacking  [####################################]  100%          
    BeforeUpload(["upload"], [".pioenvs/nanoatmega328/firmware.hex"])
    Looking for upload port/disk...
    
    Warning! Please install `99-platformio-udev.rules` and check that your board's PID and VID are listed in the rules.
    https://raw.githubusercontent.com/platformio/platformio/develop/scripts/99-platformio-udev.rules
    
    Auto-detected: /dev/ttyUSB0
    "/home/wucke13/.platformio/packages/tool-avrdude/avrdude" -v -p atmega328p -C "/home/wucke13/.platformio/packages/tool-avrdude/avrdude.conf" -c arduino -b 57600 -P "/dev/ttyUSB0" -D -U flash:w:.pioenvs/nanoatmega328/firmware.hex:i
    /home/wucke13/.platformio/packages/tool-avrdude/avrdude: error while loading shared libraries: libreadline.so.6: cannot open shared object file: No such file or directory
    scons: *** [upload] Error 127
    ==================================================================================== [ ERROR ] Took 16.29 seconds ====================================================================================
    ❯❯❯ avrdude -v -p atmega328p -C "/home/wucke13/.platformio/packages/tool-avrdude/avrdude.conf" -c arduino -b 57600 -P "/dev/ttyUSB0" -D -U flash:w:.pioenvs/nanoatmega328/firmware.hex:i
    
    avrdude: Version 6.3, compiled on Feb 16 2016 at 21:30:04
             Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
             Copyright (c) 2007-2014 Joerg Wunsch
    
             System wide configuration file is "/home/wucke13/.platformio/packages/tool-avrdude/avrdude.conf"
             User configuration file is "/home/wucke13/.avrduderc"
             User configuration file does not exist or is not a regular file, skipping
    
             Using Port                    : /dev/ttyUSB0
             Using Programmer              : arduino
             Overriding Baud Rate          : 57600
             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: 2
             Firmware Version: 1.16
             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.00s
    
    avrdude: Device signature = 0x1e950f (probably m328p)
    avrdude: safemode: hfuse reads as 0
    avrdude: safemode: efuse reads as 0
    avrdude: reading input file ".pioenvs/nanoatmega328/firmware.hex"
    avrdude: writing flash (1810 bytes):
    
    Writing | ################################################## | 100% 0.59s
    
    avrdude: 1810 bytes of flash written
    avrdude: verifying flash memory against .pioenvs/nanoatmega328/firmware.hex:
    avrdude: load data flash data from input file .pioenvs/nanoatmega328/firmware.hex:
    avrdude: input file .pioenvs/nanoatmega328/firmware.hex contains 1810 bytes
    avrdude: reading on-chip flash data:
    
    Reading | ################################################## | 100% 0.45s
    
    avrdude: verifying ...
    avrdude: 1810 bytes of flash verified
    
    avrdude: safemode: hfuse reads as 0
    avrdude: safemode: efuse reads as 0
    avrdude: safemode: Fuses OK (E:00, H:00, L:00)
    
    avrdude done.  Thank you.
    

    So, the very same command does work on the avrdude binary provided by the nixpkgs, but not on the binary downloaded by platformio.

  9. reopened this on Nov 8, 2017
  10. mogorman commented on Jan 10, 2018

    @mogorman
    Contributor

    I don't have an avr handy to confirm avrdude works with the current platformio 3.5.0 package in master, but I can confirm that it ran to the point it hangs on the port

    [mog@worklaptop:~/platest]$ pio run -t upload --upload-port /dev/ttyUSB0
    [Wed Jan 10 09:33:43 2018] Processing diecimilaatmega168 (platform: atmelavr; board: diecimilaatmega168; framework: arduino)
    ----------------------------------------------------------------------------------------------------------------------------------
    Verbose mode can be enabled via `-v, --verbose` option
    Collected 24 compatible libraries
    Looking for dependencies...
    No dependencies
    Looking for upload port...
    Use manually specified: /dev/ttyUSB0
    Uploading .pioenvs/diecimilaatmega168/firmware.hex
    

    Can someone with privileges move cherrypick the commit into 17.09 ?

  11. lukateras commented on Jan 11, 2018

    @lukateras
    Member

    @mogorman: Sure. Which commit?

  12. mogorman commented on Jan 11, 2018

    @mogorman
    Contributor
  13. wucke13 commented on Jan 14, 2018

    @wucke13
    ContributorAuthor

    I checked #33367, and I can confirm that it did work to upload with that build. So, with that commit, this is solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions