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

Readline support for MSVC #1186

Closed
mcuee opened this issue Nov 21, 2022 · 19 comments
Closed

Readline support for MSVC #1186

mcuee opened this issue Nov 21, 2022 · 19 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@mcuee
Copy link
Collaborator

mcuee commented Nov 21, 2022

As of now MSVC build does not support libreadline and then -c urclock may time out in terminal mode.

@mariusgreuel may have the solution from the discussion here.

@mcuee mcuee added the enhancement New feature or request label Nov 21, 2022
@mcuee
Copy link
Collaborator Author

mcuee commented Nov 21, 2022

The workaround for now is to use MinGW build below.

Once #1171 is merged, I will publish avrdude snapshot binaries for Linux/Windows/macOS. (Done)

@mcuee
Copy link
Collaborator Author

mcuee commented Nov 25, 2022

BTW, it is not too bad as there is a work around for the terminal mode using pipes.

Examples using the latest github action Windows binary.
https://github.com/avrdudes/avrdude/actions/runs/3539649818

C:\work\avr\avrdude_test\avrdude_bin\github_action\avrdude-msvc-x64>
 echo "dump eeprom 0 0x10" | .\avrdude -c arduino -P COM4 -p m328p  -t

avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e950f (probably m328p)
avrdude> >>> dump eeprom 0 0x10

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

0000  48 65 6c 6c 6f 2c 20 77  6f 72 6c 64 21 21 21 0a  |Hello, world!!! |

avrdude>
avrdude done.  Thank you.

C:\work\avr\avrdude_test\avrdude_bin\github_action\avrdude-msvc-x64> 
echo "dump flash 0 0x10" | .\avrdude -c urclock -P COM4 -p m328p  -t -xbootsize=2048
avrdude warning: compiled without readline library, cannot use avrdude -t -c urclock
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e950f (probably m328p)
avrdude> >>> dump flash 0 0x10

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

0000  0c 94 5c 00 0c 94 6e 00  0c 94 6e 00 0c 94 6e 00  | .\. .n. .n. .n.|

avrdude>
avrdude done.  Thank you.

C:\work\avr\avrdude_test\avrdude_bin\github_action\avrdude-mingw-x86_64> 
echo "dump eeprom 0 0x10" | .\avrdude -c arduino -P COM4 -p m328p  -t

avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e950f (probably m328p)
avrdude> >>> dump eeprom 0 0x10

Reading | ################################################## | 100% 0.08 s

0000  48 65 6c 6c 6f 2c 20 77  6f 72 6c 64 21 21 21 0a  |Hello, world!!! |

avrdude>
avrdude done.  Thank you.

C:\work\avr\avrdude_test\avrdude_bin\github_action\avrdude-mingw-x86_64> 
echo "dump flash 0 0x10" | .\avrdude -c arduino -P COM4 -p m328p  -t

avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e950f (probably m328p)
avrdude> >>> dump flash 0 0x10

Reading | ################################################## | 100% 0.07 s

0000  0c 94 5c 00 0c 94 6e 00  0c 94 6e 00 0c 94 6e 00  | .\. .n. .n. .n.|

avrdude>
avrdude done.  Thank you.

@mcuee
Copy link
Collaborator Author

mcuee commented Nov 25, 2022

@stefanrueger

Would you please change the warning message to something like the following? You can change the wording as you see fit.

warning: compiled without readline library,  'avrdude -t -c urclock' may not work. 
You may have to use work-around using piples like the following.
    echo "dump flash" | avrdude -t -c urclock

@mariusgreuel
Copy link
Contributor

@mcuee , @stefanrueger : I have not been able to keep up the pace you guys are working, but I am planning on fixing some Windows related issues around the upcoming holidays. This includes patching up the old readline library for Windows. I am assigning this issue to me.

@mariusgreuel mariusgreuel self-assigned this Nov 25, 2022
@stefanrueger
Copy link
Collaborator

I am assigning this issue to me.

@mariusgreuel Thank you. BTW, you can try avrdude -t -curclock with a STK500v1 bootloader, eg. This should keep the bootloader alive. Current git main requires -xdelay=350 for old optiboots.

Without libreadline one needs to pipe into avrdude:

echo "d fl 0 32; quit" | tr \; \\n | avrdude -t -curclock

@mcuee
Copy link
Collaborator Author

mcuee commented Nov 25, 2022

@mcuee , @stefanrueger : I have not been able to keep up the pace you guys are working, but I am planning on fixing some Windows related issues around the upcoming holidays. This includes patching up the old readline library for Windows. I am assigning this issue to me.

Thanks, Readline for MSVC build will be wonderful.

The other thing you may help is how to better detect Readline under Windows. Now it wrongly detect Strberry Perl's libreadline.a as having Readline for the MSVC build. I have to explicitly disable it in githhub action MSVC build with PR #1196.

@mariusgreuel
Copy link
Contributor

Now it wrongly detect Strberry Perl's libreadline.a

Yes, when you install Strawberry Perl, a lot of things break. They put their entire MinGW toolchain in the systems PATH variable, having no clue about the breakage this causes: StrawberryPerl/Perl-Dist-Strawberry#11

It surprises me to see this on a GitHub runner enabled by default. I dropped GitHub a message:
actions/runner-images#5459

@mcuee
Copy link
Collaborator Author

mcuee commented Dec 6, 2022

Build log using Readline-win32.

Failed because the directory structure is not correct.

@mcuee
Copy link
Collaborator Author

mcuee commented Dec 6, 2022

One more try -- just a hack to get the things build.

  1. build Readline-win32 from https://github.com/lltcggie/readline
  2. copy the necessary header files to src/readline
  3. copy the necessary library files to src/readline-bin.
1> CMake generation started for configuration: 'x64-Release'.
1> Command line: "C:\WINDOWS\system32\cmd.exe" /c "%SYSTEMROOT%\System32\chcp.com 65001 >NUL && "C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe"  -G "Ninja"  -DCMAKE_BUILD_TYPE:STRING="RelWithDebInfo" -DCMAKE_INSTALL_PREFIX:PATH="C:\work\avr\avrdude_test\avrdude_main\out\install\x64-Release" -DUSE_EXTERNAL:BOOL="True" -DHAVE_LIBREADLINE:FILEPATH="C:/work/avr/avrdude_test/avrdude_main/src/msvc/readline_bin/readline.lib" -DUSE_STATIC_LIBS:BOOL="true" -DCMAKE_C_COMPILER:FILEPATH="C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe"  -DCMAKE_MAKE_PROGRAM="C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\Ninja\ninja.exe" "C:\work\avr\avrdude_test\avrdude_main" 2>&1"
1> Working directory: C:\work\avr\avrdude_test\avrdude_main\out\build\x64-Release
1> [CMake] -- The C compiler identification is MSVC 19.29.30146.0
1> [CMake] -- Detecting C compiler ABI info
1> [CMake] -- Detecting C compiler ABI info - done
1> [CMake] -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped
1> [CMake] -- Detecting C compile features
1> [CMake] -- Detecting C compile features - done
1> [CMake] -- Found Git: C:/Program Files/Git/cmd/git.exe (found version "2.35.3.windows.1") 
1> [CMake] -- Found FLEX: C:/ProgramData/chocolatey/bin/win_flex.exe (found version "2.6.4") 
1> [CMake] -- Found BISON: C:/ProgramData/chocolatey/bin/win_bison.exe (found version "3.7.4")
1> [CMake] -- Fetching external libraries, please wait...
1> [CMake] -- The CXX compiler identification is MSVC 19.29.30146.0
1> [CMake] -- Detecting CXX compiler ABI info
1> [CMake] -- Detecting CXX compiler ABI info - done
1> [CMake] -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped
1> [CMake] -- Detecting CXX compile features
1> [CMake] -- Detecting CXX compile features - done
1> [CMake] -- Using external library 'libelf'
1> [CMake] -- Using external library 'libusb'
1> [CMake] -- Using external library 'libhidapi'
1> [CMake] -- Using external library 'libftdi'
1> [CMake] -- Configuration summary:
1> [CMake] -- ----------------------
1> [CMake] -- DO HAVE    libelf
1> [CMake] -- DO HAVE    libusb
1> [CMake] -- DON'T HAVE libusb_1_0
1> [CMake] -- DO HAVE    libhidapi
1> [CMake] -- DO HAVE    libftdi
1> [CMake] -- DON'T HAVE libftdi1
1> [CMake] -- DO HAVE    libreadline
1> [CMake] -- DISABLED   doc
1> [CMake] -- DISABLED   parport
1> [CMake] -- DISABLED   linuxgpio
1> [CMake] -- DISABLED   linuxspi
1> [CMake] -- ----------------------
1> [CMake] -- Configuring done
1> [CMake] -- Generating done
1> [CMake] -- Build files have been written to: C:/work/avr/avrdude_test/avrdude_main/out/build/x64-Release
1> Extracted CMake variables.
1> Extracted source files and headers.
1> Extracted code model.
1> Extracted toolchain configurations.
1> Extracted includes paths.
1> CMake generation finished.

>------ Build All started: Project: avrdude_main, Configuration: x64-Release ------
  [1/136] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\data.c.obj
  [2/136] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\32.fsize.c.obj
  [3/136] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\checksum.c.obj
  [4/136] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\cntl.c.obj
  [5/136] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\begin.c.obj
  [6/136] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\32.getshdr.c.obj
  [7/136] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\32.newehdr.c.obj
  [8/136] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\32.newphdr.c.obj
  [9/136] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\32.getehdr.c.obj
  [10/136] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\32.getphdr.c.obj
  [11/136] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\assert.c.obj
  [12/136] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\cook.c.obj
  [13/136] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\64.xlatetof.c.obj
  [14/136] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\32.xlatetof.c.obj
  [15/136] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\errno.c.obj
  [16/136] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\end.c.obj
  [17/136] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\getbase.c.obj
  [18/136] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\gelfshdr.c.obj
  [19/136] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\getident.c.obj
  [20/136] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\fill.c.obj
  [21/136] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\gelftrans.c.obj
  [22/136] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\errmsg.c.obj
  [23/136] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\getaroff.c.obj
  [24/136] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\gelfehdr.c.obj
  [25/136] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\getarhdr.c.obj
  [26/136] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\getdata.c.obj
  [27/136] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\gelfphdr.c.obj
  [28/136] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\memset.c.obj
  [29/136] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\flag.c.obj
  [30/136] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\getscn.c.obj
  [31/136] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\input.c.obj
  [32/136] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\nextscn.c.obj
  [33/136] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\hash.c.obj
  [34/136] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\ndxscn.c.obj
  [35/136] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\rand.c.obj
  [36/136] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\getarsym.c.obj
  [37/136] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\newscn.c.obj
  [38/136] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\opt.delscn.c.obj
  [39/136] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\next.c.obj
  [40/136] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\kind.c.obj
  [41/136] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\newdata.c.obj
  [42/136] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\nlist.c.obj
  [43/136] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\rawdata.c.obj
  [44/136] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\rawfile.c.obj
  [45/136] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\verdef_32_tof.c.obj
  [46/136] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\swap64.c.obj
  [47/136] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\strptr.c.obj
  [48/136] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\verdef_32_tom.c.obj
  [49/136] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\x.elfext.c.obj
  [50/136] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\verdef_64_tom.c.obj
  [51/136] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\update.c.obj
  [52/136] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\verdef_64_tof.c.obj
  [53/136] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\version.c.obj
  [54/136] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\x.movscn.c.obj
  [55/136] Building C object _deps\libusb-build\CMakeFiles\libusb.dir\src\usb.c.obj
  [56/136] Building C object _deps\libelf-build\CMakeFiles\libelf.dir\src\x.remscn.c.obj
  [57/136] Building C object _deps\libusb-build\CMakeFiles\libusb.dir\src\descriptors.c.obj
  [58/136] Generating avrdude.conf
  [59/136] Linking C static library _deps\libelf-build\libelf.lib
  [60/136] Building CXX object _deps\libftdi-build\CMakeFiles\libftdi.dir\src\ftdi.cpp.obj
  [61/136] Linking CXX static library _deps\libftdi-build\libftdi.lib
  [62/136] Building CXX object _deps\libusb-build\CMakeFiles\libusb.dir\src\windows.cpp.obj
  [63/136] Building C object _deps\libusb-build\CMakeFiles\libusb.dir\src\error.c.obj
  [64/136] Building C object _deps\libusb-build\CMakeFiles\libusb.dir\src\registry.c.obj
  [65/136] Building C object _deps\libhidapi-build\CMakeFiles\libhidapi.dir\src\hid.c.obj
  [66/136] Linking CXX static library _deps\libusb-build\libusb.lib
  [67/136] Linking C static library _deps\libhidapi-build\libhidapi.lib
  [68/136] [FLEX][Parser] Building scanner with win_flex 2.6.4
  [69/136] [BISON][Parser] Building parser with bison 3.7.4
  [70/136] Building C object src\CMakeFiles\libavrdude.dir\crc16.c.obj
  [71/136] Building C object src\CMakeFiles\libavrdude.dir\arduino.c.obj
  [72/136] Building C object src\CMakeFiles\libavrdude.dir\avr910.c.obj
  [73/136] Building C object src\CMakeFiles\libavrdude.dir\flip1.c.obj
  [74/136] Building C object src\CMakeFiles\libavrdude.dir\avrftdi_tpi.c.obj
  [75/136] Building C object src\CMakeFiles\libavrdude.dir\buspirate.c.obj
  [76/136] Building C object src\CMakeFiles\libavrdude.dir\butterfly.c.obj
  [77/136] Building C object src\CMakeFiles\libavrdude.dir\avrpart.c.obj
  [78/136] Building C object src\CMakeFiles\libavrdude.dir\avr.c.obj
  [79/136] Building C object src\CMakeFiles\libavrdude.dir\avrcache.c.obj
  [80/136] Building C object src\CMakeFiles\libavrdude.dir\avrftdi.c.obj
  [81/136] Building C object src\CMakeFiles\libavrdude.dir\config.c.obj
  [82/136] Building C object src\CMakeFiles\libavrdude.dir\dfu.c.obj
  [83/136] Building C object src\CMakeFiles\libavrdude.dir\fileio.c.obj
  [84/136] Building C object src\CMakeFiles\libavrdude.dir\lists.c.obj
  [85/136] Building C object src\CMakeFiles\libavrdude.dir\jtag3.c.obj
  [86/136] Building C object src\CMakeFiles\libavrdude.dir\flip2.c.obj
  [87/136] Building C object src\CMakeFiles\libavrdude.dir\linuxgpio.c.obj
  [88/136] Building C object src\CMakeFiles\libavrdude.dir\jtagmkII.c.obj
  [89/136] Building C object src\CMakeFiles\libavrdude.dir\jtagmkI.c.obj
  [90/136] Building C object src\CMakeFiles\libavrdude.dir\linuxspi.c.obj
  [91/136] Building C object src\CMakeFiles\libavrdude.dir\ft245r.c.obj
  [92/136] Building C object src\CMakeFiles\libavrdude.dir\updi_state.c.obj
  [93/136] Building C object src\CMakeFiles\libavrdude.dir\updi_readwrite.c.obj
  [94/136] Building C object src\CMakeFiles\libavrdude.dir\usbasp.c.obj
  [95/136] Building C object src\CMakeFiles\libavrdude.dir\confwin.c.obj
  [96/136] Building C object src\CMakeFiles\libavrdude.dir\bitbang.c.obj
  [97/136] Building C object src\CMakeFiles\libavrdude.dir\usb_hidapi.c.obj
  [98/136] Building C object src\CMakeFiles\libavrdude.dir\serbb_posix.c.obj
  [99/136] Building C object src\CMakeFiles\libavrdude.dir\ppi.c.obj
  [100/136] Building C object src\CMakeFiles\libavrdude.dir\par.c.obj
  [101/136] Building C object src\CMakeFiles\libavrdude.dir\usb_libusb.c.obj
  [102/136] Building C object src\CMakeFiles\libavrdude.dir\pgm_type.c.obj
  [103/136] Building C object src\CMakeFiles\libavrdude.dir\pindefs.c.obj
  [104/136] Building C object src\CMakeFiles\libavrdude.dir\ppiwin.c.obj
  [105/136] Building C object src\CMakeFiles\libavrdude.dir\ser_avrdoper.c.obj
  [106/136] Building C object src\CMakeFiles\libavrdude.dir\ser_posix.c.obj
  [107/136] Building C object src\CMakeFiles\libavrdude.dir\pgm.c.obj
  [108/136] Building C object src\CMakeFiles\libavrdude.dir\micronucleus.c.obj
  [109/136] Building C object src\CMakeFiles\libavrdude.dir\urclock.c.obj
  [110/136] Building C object src\CMakeFiles\libavrdude.dir\serialupdi.c.obj
  [111/136] Building C object src\CMakeFiles\libavrdude.dir\stk500generic.c.obj
  [112/136] Building C object src\CMakeFiles\libavrdude.dir\teensy.c.obj
  [113/136] Building C object src\CMakeFiles\libavrdude.dir\updi_nvm.c.obj
  [114/136] Building C object src\CMakeFiles\libavrdude.dir\stk500.c.obj
  [115/136] Building C object src\CMakeFiles\libavrdude.dir\wiring.c.obj
  [116/136] Building C object src\CMakeFiles\libavrdude.dir\updi_link.c.obj
  [117/136] Building C object src\CMakeFiles\libavrdude.dir\usbtiny.c.obj
  [118/136] Building C object src\CMakeFiles\libavrdude.dir\stk500v2.c.obj
  [119/136] Building C object src\CMakeFiles\libavrdude.dir\__\lexer.c.obj
  [120/136] Building C object src\CMakeFiles\libavrdude.dir\update.c.obj
  [121/136] Building C object src\CMakeFiles\libavrdude.dir\xbee.c.obj
  [122/136] Building C object src\CMakeFiles\libavrdude.dir\__\config_gram.c.obj
  [123/136] Building C object src\CMakeFiles\libavrdude.dir\serbb_win32.c.obj
  [124/136] Building C object src\CMakeFiles\libavrdude.dir\pickit2.c.obj
  [125/136] Building C object src\CMakeFiles\libavrdude.dir\ser_win32.c.obj
  [126/136] Building CXX object src\CMakeFiles\libavrdude.dir\msvc\usleep.cpp.obj
  [127/136] Building RC object src\CMakeFiles\avrdude.dir\windows.rc.res
  Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
  
  
  Copyright (C) Microsoft Corporation.  All rights reserved.
  
  
  
  
  [128/136] Building C object src\CMakeFiles\avrdude.dir\avrintel.c.obj
  [129/136] Building C object src\CMakeFiles\avrdude.dir\main.c.obj
  [130/136] Building C object src\CMakeFiles\libavrdude.dir\msvc\gettimeofday.c.obj
  [131/136] Building C object src\CMakeFiles\avrdude.dir\developer_opts.c.obj
  [132/136] Building C object src\CMakeFiles\libavrdude.dir\msvc\getopt.c.obj
  [133/136] Building C object src\CMakeFiles\avrdude.dir\whereami.c.obj
  [134/136] Linking CXX static library src\libavrdude.lib
  [135/136] Building C object src\CMakeFiles\avrdude.dir\term.c.obj
  [136/136] Linking CXX executable src\avrdude.exe

Build All succeeded.

Directory Structure for reference:
avrdude_main.zip

@mcuee
Copy link
Collaborator Author

mcuee commented Dec 6, 2022

Binary for reference (also included in the post above). Dynamic link to readline.dll as of now.
avrdude_msvc_readline_x64.zip

@mcuee
Copy link
Collaborator Author

mcuee commented Dec 6, 2022

The results seem to be okay with history. piping is a bit strange.

C:\work\avr\avrdude_test\avrdude_main\out\build\x64-Release\src [main ≡ +4 ~0 -0 !]> 
.\avrdude -c xplainedpro_updi -p t817 -qqt
avrdude> dump flash
>>> dump flash
0000  01 c0 d8 c0 11 24 80 91  40 00 88 23 69 f0 28 2f  |.....$..@..#i.(/|
0010  30 e0 83 fd 03 c0 2d 7f  23 2b 31 f4 80 93 40 00  |0.....-.#+1...@.|
0020  8c bb 80 e0 af d0 ec c0  a8 95 22 9a 2a 9a 10 92  |..........".*...|
0030  01 02 80 91 82 12 83 70  81 30 61 f5 8c e5 90 e0  |.......p.0a.....|
0040  80 93 08 08 90 93 09 08  81 e0 80 93 0b 08 83 e0  |...... ..... ...|
0050  80 93 07 08 10 92 05 08  80 ec 80 93 06 08 8b e0  |................|
0060  91 d0 07 9a 87 e0 81 50  c1 f4 a8 95 0d e9 83 e0  |.......P.... ...|
0070  d8 2e 7c d0 81 34 e9 f4  79 d0 18 2f 8c d0 81 e0  |..|..4..y../....|
0080  12 38 21 f0 89 e0 11 38  09 f0 83 e0 68 d0 80 e1  |.8!....8 ...h...|
0090  66 d0 ef cf 83 e7 90 e0  d3 cf 17 9a 2e ec 36 e5  |f.............6.|
00a0  a8 95 90 91 04 08 97 fd  e1 cf 21 50 31 09 c1 f7  |..........!P1 ..|
00b0  da cf 82 34 19 f4 84 e1  76 d0 e9 cf 85 34 11 f4  |...4....v....4..|
00c0  85 e0 fa cf 85 35 31 f4  51 d0 c8 2f 4f d0 d8 2f  |.....51.Q../O../|
00d0  62 d0 dd cf 86 35 21 f4  84 e0 65 d0 80 e0 d6 cf  |b....5!...e.....|
00e0  84 36 b9 f4 43 d0 42 d0  18 2f 40 d0 86 34 79 f4  |.6..C.B../@..4y.|
00f0  d0 58 3c d0 88 83 21 96  11 50 d9 f7 4c d0 04 bf  |.X<...!..P..L...|

avrdude> dump
>>> dump
Usage: dump <memory> <addr> <len>
       dump <memory> <addr> ...
       dump <memory> <addr>
       dump <memory> ...
       dump <memory>
avrdude> dump flash
>>> dump flash
0100  d0 92 00 10 80 91 02 10  83 70 e1 f7 c0 cf dc 5e  |.........p.....^|
0110  f0 cf 84 37 91 f4 2a d0  29 d0 18 2f 27 d0 f8 2e  |...7..*.)../'...|
0120  3a d0 86 e4 f8 12 07 c0  d0 58 88 81 21 96 17 d0  |:........X..!...|
0130  11 50 d9 f7 ac cf dc 5e  f8 cf 85 37 51 f4 2b d0  |.P.....^...7Q.+.|
0140  80 91 00 11 0c d0 80 91  01 11 09 d0 80 91 02 11  |.... ..... .....|
0150  9d cf 81 35 09 f0 bc cf  81 e0 14 d0 b9 cf 90 91  |...5 ...........|
0160  04 08 95 ff fc cf 80 93  02 08 08 95 80 91 04 08  |................|
0170  87 ff fc cf 90 91 01 08  80 91 00 08 92 fd 01 c0  |................|
0180  a8 95 08 95 90 91 01 01  90 fd fc cf 98 ed 94 bf  |................|
0190  80 93 00 01 08 95 ea df  80 32 19 f0 81 e0 f2 df  |.........2......|
01a0  ff cf 84 e1 dc cf cf 93  c8 2f e0 df c1 50 e9 f7  |........./...P..|
01b0  cf 91 f1 cf 68 30 48 f4  8d e9 84 bf 60 93 00 10  |....h0H.....`...|
01c0  80 91 02 10 83 70 e1 f7  08 95 fc 01 40 83 08 95  |.....p......@...|
01d0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
01e0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
01f0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff 01 09  |............... |

avrdude> dump flash
>>> dump flash
0200  19 c0 28 c0 27 c0 26 c0  25 c0 24 c0 23 c0 22 c0  |..(.'.&.%.$.#.".|
0210  21 c0 20 c0 1f c0 1e c0  1d c0 1c c0 57 c0 1a c0  |!. .........W...|
0220  19 c0 18 c0 17 c0 16 c0  15 c0 14 c0 13 c0 12 c0  |................|
0230  11 c0 10 c0 11 24 1f be  cf ef cd bf df e3 de bf  |.....$..........|
0240  2e e3 a0 e0 be e3 01 c0  1d 92 aa 30 b2 07 e1 f7  |...........0....|
0250  77 d0 b2 c0 d5 cf 8f b7  f8 94 40 91 02 3e 50 91  |w.........@..>P.|
0260  03 3e 60 91 04 3e 70 91  05 3e 8f bf 2f b7 f8 94  |.>`..>p..>../...|
0270  80 91 02 3e 90 91 03 3e  a0 91 04 3e b0 91 05 3e  |...>...>...>...>|
0280  2f bf 84 1b 95 0b a6 0b  b7 0b 88 3e 93 40 a1 05  |/.... . . .>.@..|
0290  b1 05 60 f3 08 95 90 e1  81 11 11 c0 90 93 26 04  |..`...........&.|
02a0  90 91 20 04 94 fd 0a c0  9f b7 f8 94 81 11 0a c0  |.. ... ....... .|
02b0  80 91 34 04 87 7f 80 93  34 04 9f bf 08 95 90 93  |..4.....4.......|
02c0  25 04 ee cf 80 91 34 04  88 60 f5 cf ef 93 ff 93  |%.....4..`......|
02d0  e0 e0 fe e3 8f 93 8f b7  8f 93 9f 93 7f 93 70 e0  |..............p.|
02e0  80 81 91 81 80 5d 9c 4f  80 83 91 83 88 5e 93 40  |.....].O.....^.@|
02f0  18 f0 80 83 91 83 7f 5f  92 81 97 0f 92 83 80 e0  |......._........|

avrdude> quit
>>> quit
avrdude>

C:\work\avr\avrdude_test\avrdude_main\out\build\x64-Release\src [main ≡ +5 ~0 -0 !]> echo "dump flash 0 0x40" 
| .\avrdude -c xplainedpro_updi -p t817 -qqt
avrdude> dump flash 0 0x40
>>> dump flash 0 0x40
0000  01 c0 d8 c0 11 24 80 91  40 00 88 23 69 f0 28 2f  |.....$..@..#i.(/|
0010  30 e0 83 fd 03 c0 2d 7f  23 2b 31 f4 80 93 40 00  |0.....-.#+1...@.|
0020  8c bb 80 e0 af d0 ec c0  a8 95 22 9a 2a 9a 10 92  |..........".*...|
0030  01 02 80 91 82 12 83 70  81 30 61 f5 8c e5 90 e0  |.......p.0a.....|

avrdude>
(arg: 4) (need to hit CTRL-C to exit)

C:\work\avr\avrdude_test\avrdude_bin> echo "dump flash" | .\avrdude_git_readline_msvc -c urclock -P COM13
 -p t817 -xbootsize=512 -t

avrdude_git_readline_msvc: AVR device initialized and ready to accept instructions
avrdude_git_readline_msvc: device signature = 0x1e9320 (probably t817)
avrdude> dump flash
>>> dump flash

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

0000  01 c0 d8 c0 11 24 80 91  40 00 88 23 69 f0 28 2f  |.....$..@..#i.(/|
0010  30 e0 83 fd 03 c0 2d 7f  23 2b 31 f4 80 93 40 00  |0.....-.#+1...@.|
0020  8c bb 80 e0 af d0 ec c0  a8 95 22 9a 2a 9a 10 92  |..........".*...|
0030  01 02 80 91 82 12 83 70  81 30 61 f5 8c e5 90 e0  |.......p.0a.....|
0040  80 93 08 08 90 93 09 08  81 e0 80 93 0b 08 83 e0  |...... ..... ...|
0050  80 93 07 08 10 92 05 08  80 ec 80 93 06 08 8b e0  |................|
0060  91 d0 07 9a 87 e0 81 50  c1 f4 a8 95 0d e9 83 e0  |.......P.... ...|
0070  d8 2e 7c d0 81 34 e9 f4  79 d0 18 2f 8c d0 81 e0  |..|..4..y../....|
0080  12 38 21 f0 89 e0 11 38  09 f0 83 e0 68 d0 80 e1  |.8!....8 ...h...|
0090  66 d0 ef cf 83 e7 90 e0  d3 cf 17 9a 2e ec 36 e5  |f.............6.|
00a0  a8 95 90 91 04 08 97 fd  e1 cf 21 50 31 09 c1 f7  |..........!P1 ..|
00b0  da cf 82 34 19 f4 84 e1  76 d0 e9 cf 85 34 11 f4  |...4....v....4..|
00c0  85 e0 fa cf 85 35 31 f4  51 d0 c8 2f 4f d0 d8 2f  |.....51.Q../O../|
00d0  62 d0 dd cf 86 35 21 f4  84 e0 65 d0 80 e0 d6 cf  |b....5!...e.....|
00e0  84 36 b9 f4 43 d0 42 d0  18 2f 40 d0 86 34 79 f4  |.6..C.B../@..4y.|
00f0  d0 58 3c d0 88 83 21 96  11 50 d9 f7 4c d0 04 bf  |.X<...!..P..L...|

avrdude>
(arg: 4) (need to hit CTRL-C to exit)

@mcuee
Copy link
Collaborator Author

mcuee commented Dec 6, 2022

Yet the other way is to get the Readline binary from vcpkg, and copy the necessary into a directory named readline, then move the file under src/msvc directory.

PS C:\work\avr\avrdude_test\avrdude_pr1207> & 'C:\Program Files\CMake\bin\cmake.exe' -D HAVE_LIBREADLINE:FILEPATH=C:\work\avr\avrdude_test\avrdude_pr1207\src\msvc\readline\readline.lib  -D USE_EXTERNAL=TRUE -B build
-- Building for: Visual Studio 17 2022
-- Selecting Windows SDK version 10.0.22000.0 to target Windows 10.0.22621.
-- The C compiler identification is MSVC 19.31.31105.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.31.31103/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Found Git: C:/Program Files/Git/cmd/git.exe (found version "2.33.0.windows.2")
-- Found FLEX: C:/ProgramData/chocolatey/bin/win_flex.exe (found version "2.6.4")
-- Found BISON: C:/ProgramData/chocolatey/bin/win_bison.exe (found version "3.7.4")
-- Fetching external libraries, please wait...
-- The CXX compiler identification is MSVC 19.31.31105.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.31.31103/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Using external library 'libelf'
-- Using external library 'libusb'
-- Using external library 'libhidapi'
-- Using external library 'libftdi'
-- Configuration summary:
-- ----------------------
-- DO HAVE    libelf
-- DO HAVE    libusb
-- DON'T HAVE libusb_1_0
-- DO HAVE    libhidapi
-- DO HAVE    libftdi
-- DON'T HAVE libftdi1
-- DO HAVE    libreadline
-- DISABLED   doc
-- DISABLED   parport
-- DISABLED   linuxgpio
-- DISABLED   linuxspi
-- ----------------------
-- Configuring done
-- Generating done
-- Build files have been written to: C:/work/avr/avrdude_test/avrdude_pr1207/build

@mcuee
Copy link
Collaborator Author

mcuee commented Dec 6, 2022

Result binary seems to work fine.

  1. With PR Consider libreadline/libedit only in interactive mode #1207, everything seems to work fine
PS C:\work\avr\avrdude_test\avrdude_pr1207\build\src\RelWithDebInfo> 
.\avrdude -c urclock -P COM1 -p m328p -xbootsize=512 -qqt
avrdude> help
>>> help
Valid commands:
  dump    : dump <memory> [<addr> <len> | <addr> ... | <addr> | ...]
  read    : alias for dump
  write   : write <memory> <addr> <data>[,] {<data>[,]}
          : write <memory> <addr> <len> <data>[,] {<data>[,]} ...
  flush   : synchronise flash & EEPROM writes with the device
  abort   : abort flash & EEPROM writes (reset the r/w cache)
  erase   : perform a chip erase
  sig     : display device signature bytes
  part    : display the current part information
  send    : send a raw command: send <b1> <b2> <b3> <b4>
  verbose : change verbosity
  quell   : set quell level for progress bars
  help    : show help message
  ?       : same as help
  quit    : quit after writing out cache for flash & EEPROM

Note that not all programmer derivatives support all commands. Flash and
EEPROM type memories are normally read and written using a cache via paged
read and write access; the cache is synchronised on quit or flush commands.
The part command displays valid memory types for use with dump and write.

avrdude> dump flash 0 0x20
>>> dump flash 0 0x20
0000  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0010  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|

avrdude> quit
>>> quit
avrdude>
PS C:\work\avr\avrdude_test\avrdude_pr1207\build\src\RelWithDebInfo> echo "dump flash 0 0x20" 
| .\avrdude -c urclock -P COM1 -p m328p -xbootsize=512 -qqt
avrdude> >>> dump flash 0 0x20
0000  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0010  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|

avrdude>

git main has the same issue as before when it comes to pipes.

PS C:\work\avr\avrdude_test\avrdude_main\build\src\Release>
echo "dump flash 0 0x20" | .\avrdude -c urclock -P COM1 -p m328p -xbootsize=512 -qqt
avrdude> dump flash 0 0x20
>>> dump flash 0 0x20
0000  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0010  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|

avrdude>
avrdude> (need to hit Control-C to exit)

readline_msvc_x64.zip

@mcuee
Copy link
Collaborator Author

mcuee commented Dec 6, 2022

Just to illustrate the issue again with readline-win32. PR #1207 is good for this case.

PS C:\work\avr\avrdude_test\avrdude_bin> echo "dump flash 0 0x20" | .\avrdude_git_msvc_readline
 -c urclock -P COM1 -p m328p -xbootsize=512 -qqt
avrdude> dump flash 0 0x20
>>> dump flash 0 0x20
0000  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0010  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|

avrdude>
avrdude>(need to hit CTRL-C to get out)

PS C:\work\avr\avrdude_test\avrdude_bin> echo "dump flash 0 0x20" | .\avrdude_pr1207_msvc_readline
 -c urclock -P COM1 -p m328p -xbootsize=512 -qqt
avrdude> >>> dump flash 0 0x20
0000  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0010  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|

avrdude>

@stefanrueger
Copy link
Collaborator

avrdude>(need to hit CTRL-C to get out)

I think @mariusgreuel is aware of this. Somehow reading from a pipe/file does not generate EOF he told us.

@mcuee
Copy link
Collaborator Author

mcuee commented Dec 7, 2022

avrdude>(need to hit CTRL-C to get out)

I think @mariusgreuel is aware of this. Somehow reading from a pipe/file does not generate EOF he told us.

Good to know that. No idea why PR #1207 helps in this case.

@mcuee
Copy link
Collaborator Author

mcuee commented Jan 2, 2023

@mariusgreuel mentioned that he would like to include this in the 7.1 release.

#1242 (comment)

I was planning on going through the issues assigned to me. At least I would like to include #1186 in the next release.

@mcuee
Copy link
Collaborator Author

mcuee commented Jan 3, 2023

@mariusgreuel, @stefanrueger @dl8dtl and @MCUdude

I have added this to 7.1 milestone. I think PR #1259 is almost there. Hopefully the fix for the remaining issues will not take too much time.

@stefanrueger
Copy link
Collaborator

Closing as PR #1264 addresses this.

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

Successfully merging a pull request may close this issue.

3 participants