Linux64 upload-reset appears to be a 32 bit binary

All distros
keypunch
Posts: 67
Joined: Tue Aug 02, 2016 2:26 am

Linux64 upload-reset appears to be a 32 bit binary

Post by keypunch » Thu Jun 01, 2017 4:46 am

When trying via the Arduino IDE using Arduino_STM32-master (29 May 2017 commit 920b57a) to upload a sketch for STM32F103C Generic Upload Method STM32uino bootloader the following Arduino messages display:

Code: Select all

Sketch uses 14228 bytes (10%) of program storage space. Maximum is 131072 bytes.
Global variables use 2816 bytes of dynamic memory.
/home/lubuntu/Downloads/arduino-1.8.2/hardware/Arduino_STM32/tools/linux/maple_upload: line 29: /home/lubuntu/Downloads/arduino-1.8.2/hardware/Arduino_STM32/tools/linux/upload-reset: No such file or directory
dfu-util 0.7

Copyright 2005-2008 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2012 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to dfu-util@lists.gnumonks.org

No DFU capable USB device found
Filter on vendor = 0x1eaf product = 0x0003
Waiting for /dev/ttyACM1 serial...Done
Files where:

Code: Select all

lubuntu@lubuntu:~/Downloads/arduino-1.8.2/hardware/Arduino_STM32/tools$ ls -ls /home/lubuntu/Downloads/arduino-1.8.2/hardware/Arduino_STM32/tools/linux64/maple_upload
4 -rwxr-xr-x 1 lubuntu lubuntu 1128 May 29 00:43 /home/lubuntu/Downloads/arduino-1.8.2/hardware/Arduino_STM32/tools/linux64/maple_upload
lubuntu@lubuntu:~/Downloads/arduino-1.8.2/hardware/Arduino_STM32/tools$ ls -ls /home/lubuntu/Downloads/arduino-1.8.2/hardware/Arduino_STM32/tools/linux64/upload-reset
8 -rwxr-xr-x 1 lubuntu lubuntu 7946 May 29 00:43 /home/lubuntu/Downloads/arduino-1.8.2/hardware/Arduino_STM32/tools/linux64/upload-reset

lubuntu@lubuntu:~/Downloads/arduino-1.8.2/hardware/Arduino_STM32/tools/linux64$ ls -ls
total 48
4 -rw-rw-r-- 1 lubuntu lubuntu  351 May 29 00:43 45-maple.rules
4 -rw-rw-r-- 1 lubuntu lubuntu  471 May 29 00:43 49-stlinkv1.rules
4 -rw-rw-r-- 1 lubuntu lubuntu  532 May 29 00:43 49-stlinkv2-1.rules
4 -rw-rw-r-- 1 lubuntu lubuntu  530 May 29 00:43 49-stlinkv2.rules
0 drwxrwxr-x 2 lubuntu lubuntu  100 May 29 19:38 dfu-util
4 -rwxr-xr-x 1 lubuntu lubuntu 1176 May 29 00:43 install.sh
4 -rwxr-xr-x 1 lubuntu lubuntu 1128 May 29 00:43 maple_upload
4 -rw-rw-r-- 1 lubuntu lubuntu   58 May 29 00:43 readme.txt
4 -rwxr-xr-x 1 lubuntu lubuntu   90 May 29 00:43 serial_upload
0 drwxrwxr-x 6 lubuntu lubuntu  140 May 29 19:38 src
0 drwxrwxr-x 2 lubuntu lubuntu  120 May 29 19:38 stlink
4 -rwxr-xr-x 1 lubuntu lubuntu 1207 May 29 00:43 stlink_upload
0 drwxrwxr-x 2 lubuntu lubuntu   60 May 29 19:38 stm32flash
8 -rwxr-xr-x 1 lubuntu lubuntu 7946 May 29 00:43 upload-reset
4 -rwxr-xr-x 1 lubuntu lubuntu 2812 May 29 00:43 upload_router
[1]+  Done                    leafpad /home/lubuntu/Downloads/arduino-1.8.2/hardware/Arduino_STM32/tools/linux/maple_upload  (wd: ~/Downloads/arduino-1.8.2/hardware/Arduino_STM32/tools)
(wd now: ~/Downloads/arduino-1.8.2/hardware/Arduino_STM32/tools/linux64)
lubuntu@lubuntu:~/Downloads/arduino-1.8.2/hardware/Arduino_STM32/tools/linux64$ file maple_upload  serial_upload stlink_upload  upload-reset
maple_upload:  Bourne-Again shell script, ASCII text executable
serial_upload: Bourne-Again shell script, ASCII text executable
stlink_upload: Bourne-Again shell script, ASCII text executable
upload-reset:  ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.6.24, BuildID[sha1]=dc8dc5ad6de94179a9d534b1a34aeb6d906640b1, not stripped
lubuntu@lubuntu:~/Downloads/arduino-1.8.2/hardware/Arduino_STM32/tools/linux64$ 
It would appear the linux64 upload-reset is a 32 bit binary and not a 64 bit binary. Hence why:

Code: Select all

/home/lubuntu/Downloads/arduino-1.8.2/hardware/Arduino_STM32/tools/linux/maple_upload: line 29: /home/lubuntu/Downloads/arduino-1.8.2/hardware/Arduino_STM32/tools/linux/upload-reset: No such file or directory

Regards,

John L. Males
Toronto, Ontario
Canada
01 June 2017 00:46 EDT

ag123
Posts: 831
Joined: Thu Jul 21, 2016 4:24 pm

Re: Linux64 upload-reset appears to be a 32 bit binary

Post by ag123 » Thu Jun 01, 2017 2:47 pm

upload reset linux64 is there
https://github.com/rogerclarkmelbourne/ ... ls/linux64

actually even if upload-reset is 32bits it should still run. however, there may be some dependencies

Code: Select all

Arduino_STM32/tools/linux64> ldd upload-reset 
linux-gate.so.1 (0xf76f6000)
libc.so.6 => /lib/libc.so.6 (0xf74fb000)
/lib/ld-linux.so.2 (0xf76f9000)
you would probably need the 32 bit libraries to run it

in the mean time, to do a sketch install, press the reset button and click the install button on arduino ide as soon as the blinks starts (normally almost immediately)

alternatively to do a sketch install on the command line you could use dfu-util

Code: Select all

dfu-util -l

Code: Select all

dfu-util -a 2 -R -D sketch.bin
the sketch.bin file is in /tmp/arduino_build_nnnnn
Last edited by ag123 on Thu Jun 01, 2017 3:01 pm, edited 1 time in total.

keypunch
Posts: 67
Joined: Tue Aug 02, 2016 2:26 am

Re: Linux64 upload-reset appears to be a 32 bit binary

Post by keypunch » Thu Jun 01, 2017 3:00 pm

@ag123

The issue is not if upload-reset is in the linux64 directory. It is that the upload-reset is a 32 bit binary in a directory for 64 bit items of which all other binaries are in fact 64 bit binaries. If one wants to use a 32 bit binary then one can use the binaries in the linux directory which are 32 bit binaries. Why would a 32 bit binary be in both the 32 and 64 bit binaries? The purpose of a 64 bit directory is to have 64 bit binaries.


Regards,

John L. Males
Toronto, Ontario
Canada
01 June 2017 15:00 EDT

ag123
Posts: 831
Joined: Thu Jul 21, 2016 4:24 pm

Re: Linux64 upload-reset appears to be a 32 bit binary

Post by ag123 » Thu Jun 01, 2017 3:01 pm

i think the 64 bits version is not yet compiled, hence, the 32 bit version is copied into the 64 bits directory
it should still work so long as the dependent 32 bit dynamic link libraries are available on the system.

alternatively you could compile it and put a copy in your local linux64 directory.
https://github.com/rogerclarkmelbourne/ ... load-reset

ag123
Posts: 831
Joined: Thu Jul 21, 2016 4:24 pm

Re: Linux64 upload-reset appears to be a 32 bit binary

Post by ag123 » Thu Jun 01, 2017 3:14 pm

i've just compiled it and uploaded it here

Code: Select all

gcc -o upload-reset upload-reset.c
take note of the following dependencies

Code: Select all

Arduino_STM32/tools/linux64/src/upload-reset> ldd upload-reset
linux-vdso.so.1 (0x00007fff286e8000)
libc.so.6 => /lib64/libc.so.6 (0x00007fd693bc4000)
/lib64/ld-linux-x86-64.so.2 (0x00007fd693fab000)
i'm building this on opensuse 13.2 linux 64, my setup is rather old. do verify the crc and sha1 sig.

Code: Select all

>uname -a
Linux snoopy 3.16.6-2-desktop #1 SMP PREEMPT Mon Oct 20 13:47:22 UTC 2014 (feb42ea) x86_64 x86_64 x86_64 GNU/Linux
>unzip -v upload-reset.zip 
Length   Method    Size  Cmpr    Date    Time   CRC-32   Name
--------  ------  ------- ---- ---------- ----- --------  ----
   19432  Defl:N     5812  70% 2017-06-01 23:09 627578c1  upload-reset
>file upload-reset
upload-reset: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 3.0.0, BuildID[sha1]=0987effada8924a8ac079d07028b8b77fdceb703, not stripped
before you install/copy it into tools/linux64 folder, it test it using

Code: Select all

>./upload-reset /dev/maple
it should cause the maple mini / blue pill to reset and the led flashes
Attachments
upload-reset.zip
upload-reset
(5.85 KiB) Downloaded 25 times

ag123
Posts: 831
Joined: Thu Jul 21, 2016 4:24 pm

Re: Linux64 upload-reset appears to be a 32 bit binary

Post by ag123 » Thu Jun 01, 2017 3:39 pm

for the others who are using linux, do test it out as there is a chance those libc dynamic link libraries etc on your system are different.
however, dynamic linking allows it to work on any system with the appropriate dll versions and possibly prevent 'hard fault' with calls into the kernel.
do comment in this thread if it works for you or not

User avatar
Rick Kimball
Posts: 1069
Joined: Tue Apr 28, 2015 1:26 am
Location: Eastern NC, US
Contact:

Re: Linux64 upload-reset appears to be a 32 bit binary

Post by Rick Kimball » Thu Jun 01, 2017 4:03 pm

keypunch wrote:The issue is not if upload-reset is in the linux64 directory. It is that the upload-reset is a 32 bit binary in a directory for 64 bit items of which all other binaries are in fact 64 bit binaries. If one wants to use a 32 bit binary then one can use the binaries in the linux directory which are 32 bit binaries. Why would a 32 bit binary be in both the 32 and 64 bit binaries? The purpose of a 64 bit directory is to have 64 bit binaries.
My fix to this when I didn't have 32 bit libraries installed was:

Code: Select all

cd to the tools directory
mv linux linux32
mv linux64 linux
-rick

keypunch
Posts: 67
Joined: Tue Aug 02, 2016 2:26 am

Re: Linux64 upload-reset appears to be a 32 bit binary

Post by keypunch » Thu Jun 01, 2017 4:10 pm

Rick Kimball wrote:
keypunch wrote:The issue is not if upload-reset is in the linux64 directory. It is that the upload-reset is a 32 bit binary in a directory for 64 bit items of which all other binaries are in fact 64 bit binaries. If one wants to use a 32 bit binary then one can use the binaries in the linux directory which are 32 bit binaries. Why would a 32 bit binary be in both the 32 and 64 bit binaries? The purpose of a 64 bit directory is to have 64 bit binaries.
My fix to this when I didn't have 32 bit libraries installed was:

Code: Select all

cd to the tools directory
mv linux linux32
mv linux64 linux

Rick,

This is what I did actually. That is how I discovered that the upload-reset in the linux64 directory was in fact a 32 bit and not 64 bit binary. I checked the 32 bit linux/linux32 direcory binaries in case the binary was inverted and all the binaries in the linux/linux32 directory were 32 bit. Ergo shortfall of a 64 bit binary that was the upload-reset.


Regards,

John L. Males
Toronto, Ontario
Canada
01 June 2017 16:10

ag123
Posts: 831
Joined: Thu Jul 21, 2016 4:24 pm

Re: Linux64 upload-reset appears to be a 32 bit binary

Post by ag123 » Thu Jun 01, 2017 4:19 pm

for some reason that i don't fully understand a fixed upload-reset seem to make thing 'worse'
prior that with the 'not working' 32 bit upload-reset, i simply press reset
now with the fixed 64 bits upload-reset, the reset seemed goofy
it doesn't seem to work with certain sketches installed :lol:

i.e. it probably has nothing to do with whether it is 32 bits or 64 bits upload-reset
rather the reset in the sketch itself doesn't work all the time. it seemed to be dependent on the sketch installed on the device

keypunch
Posts: 67
Joined: Tue Aug 02, 2016 2:26 am

Re: Linux64 upload-reset appears to be a 32 bit binary

Post by keypunch » Thu Jun 01, 2017 4:42 pm

@ ag123

The binary is 64 bit. it would seem to me best to static link binaries meant to accomodate ranges of distributions and distribution libraries that can change. In such situtaion of my own code that needs to span different distributions and releases that reduces variables related to dynamic libraries with different naming conventions and/or binary interfaces at the library level quite a bit.

If one does the "upload-reset /dev/maple" from the CLI outside the Arduino IDE what is the expected behaviour? For example is there any visual indications?

I have done both inside and outside the IDE. First outside the IDE. I asked the question above as there seems to be mixed behaviour.


Regards,

John L. Males
Toronto, Ontario
Canada
01 June 2017 12:41 EDT
01 June 2017 13:31 EDT Small, but important typo correction jlm

P.S. Opps prior posts today I mixed up stating EDT when was UTC. Sorry. jlm
Last edited by keypunch on Thu Jun 01, 2017 5:32 pm, edited 1 time in total.

Post Reply