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

linux 64 binary does not work #1

Closed
ArminJo opened this issue Jan 5, 2021 · 22 comments
Closed

linux 64 binary does not work #1

ArminJo opened this issue Jan 5, 2021 · 22 comments

Comments

@ArminJo
Copy link

ArminJo commented Jan 5, 2021

Hi
I replaced the original micronucleus binary with your version, but all I got was:

> Please plug in the device ... 
> Press CTRL+C to terminate the program.

When switching back to the old binary I get at least:

Warning: device with unknown new version of Micronucleus detected.
This tool doesn't know how to upload to this new device. Updates may be available.
Device reports version as: 2.5

after attaching the digispark board.
The command is:
Launching/home/linux/sloeber//arduinoPlugin/packages/digistump/tools/micronucleus/2.0a4/launcher -cdigispark --timeout 60 -Uflash:w:/home/linux/WORKSPACE_SLOEBER/BlinkTest/Release/BlinkTest.hex:i

I am running on a 64 bit Linux Mint 20 Cinnamon

@stonehippo
Copy link
Owner

@ArminJo can you try the 32 bit version, as well?

The linux build is pretty vanilla, with the exception of enabling the static build. I’m not running an x64 linux on any local hardware at the moment, but I’ll try to find somewhere I can test to repro your issue.

@ArminJo
Copy link
Author

ArminJo commented Jan 11, 2021

I am sorry, but I have no 32 Bit Linux available.
But I have a question: If you run micronucleus on linux, does it recognize a e.g. Digispark board at arbritrary USB connectors/ports?

@stonehippo
Copy link
Owner

The CLI doesn't appear to have a way to specify the port, so I believe it scans for devices in a manner similar to USBTinyISP. I'll take a look through the source to see what it expects.

@stonehippo
Copy link
Owner

stonehippo commented Jan 12, 2021

@ArminJo

Ok yeah, there's a method in the library behind the CLI that attempts to iterate through the attached USB devices, checking to see if they match the micronucleus USB vendor ID. This can timeout, of course.

I assume the plugging in the device after starting the upload, or unplugging it and plugging it again doesn't kickoff the micronucleus detection for you?

I'll see about hacking something together to enumerate the devices seen on the USB bus via the tool. That should tell us whether it's detecting things or not. It's also possible that on linux, you'll either need to run with sudo or install the udev rules before this will work.

@ArminJo
Copy link
Author

ArminJo commented Jan 12, 2021

Thanks, but since the original Digispark version has no problems with detecting my device, sudo or udev should not be the reason.

@ArminJo
Copy link
Author

ArminJo commented Jan 27, 2021

Hi stonehippo,
I found the error.
Can you please make me and SpenceKonde a favor and compile the updated sources from https://github.com/micronucleus/micronucleus/tree/master/commandline again?
I added better error and print handling.
Thanks!
Armin

@stonehippo
Copy link
Owner

@ArminJo awesome. I will get to it ASAP (no later than this weekend) and ping you when the new version is available.

@stonehippo
Copy link
Owner

@ArminJo @SpenceKonde I’ve updated the Linux 32 bit and 64 bit builds for x86 archs using the code from the main repo (since it looks like my changes to the make file got pulled into there last week). Can you give pull them down and see if they work?

If these are good, I’ll rebuild the others, and finally get the Windows build done, as well.

@ArminJo
Copy link
Author

ArminJo commented Jan 30, 2021

@stonehippo Can you look at https://github.com/ArminJo/micronucleus-firmware/runs/1798561487?check_suite_focus=true#step:7:28 ?
I try to build a static MacOs binary, like you described in SpenceKonde/ATTinyCore#465 (comment) but it seems I get a dynamic one.
Do you have any clue?

@stonehippo
Copy link
Owner

@ArminJo I can't get that run. Would you mind sending the output?

I'll also try getting a new static MacOS build up shortly.

@ArminJo
Copy link
Author

ArminJo commented Jan 30, 2021

Thanks for the fast response, but what output do you mean? The executable is here

@stonehippo
Copy link
Owner

@ArminJo I meant that link to the run doesn't work for me. Thanks for linking to the binary.

@ArminJo
Copy link
Author

ArminJo commented Jan 30, 2021

I meant that link to the run doesn't work for me

Strange, do you get an 404?
Here is the log output:

 make USBFLAGS=-I/usr/local/Cellar/libusb-compat/0.1.5_1/include -I/usr/local/Cellar/libusb/1.0.24/include/libusb-1.0 USBLIBS=-L/usr/local/Cellar/libusb-compat/0.1.5_1/lib -lusb  -framework CoreFoundation -framework IOKit
Building library: library/micronucleus_lib.c...
gcc -I/usr/local/Cellar/libusb-compat/0.1.5_1/include -I/usr/local/Cellar/libusb/1.0.24/include/libusb-1.0 -Ilibrary -O -g -D MAC_OS -c library/micronucleus_lib.c
library/micronucleus_lib.c:294:16: warning: passing 'unsigned char [page_length]' to parameter of type 'char *' converts between pointers to integer types with different sign [-Wpointer-sign]
               page_buffer, page_length,
               ^~~~~~~~~~~
/usr/local/Cellar/libusb-compat/0.1.5_1/include/usb.h:310:30: note: passing argument to parameter 'bytes' here
        int value, int index, char *bytes, int size, int timeout);
                                    ^
1 warning generated.
Building library: library/littleWire_util.c...
gcc -I/usr/local/Cellar/libusb-compat/0.1.5_1/include -I/usr/local/Cellar/libusb/1.0.24/include/libusb-1.0 -Ilibrary -O -g -D MAC_OS -c library/littleWire_util.c
Building command line tool: micronucleus...
gcc -I/usr/local/Cellar/libusb-compat/0.1.5_1/include -I/usr/local/Cellar/libusb/1.0.24/include/libusb-1.0 -Ilibrary -O -g -D MAC_OS -o micronucleus micronucleus.c micronucleus_lib.o littleWire_util.o -L/usr/local/Cellar/libusb-compat/0.1.5_1/lib -lusb -framework CoreFoundation -framework IOKit
rm -f *.o

and this is the directory listing after the build. The binary is only 54k and not >100k as your static one.

total 168
-rw-r--r--  1 runner  staff    805 Jan 30 19:51 49-micronucleus.rules
-rw-r--r--  1 runner  staff   2107 Jan 30 19:51 Makefile
-rw-r--r--  1 runner  staff   1451 Jan 30 19:51 Readme
drwxr-xr-x  5 runner  staff    160 Jan 30 19:51 builds
drwxr-xr-x  6 runner  staff    192 Jan 30 19:51 library
-rwxr-xr-x  1 runner  staff  53464 Jan 30 19:53 micronucleus
-rw-r--r--  1 runner  staff  16184 Jan 30 19:51 micronucleus.c
drwxr-xr-x  3 runner  staff     96 Jan 30 19:53 micronucleus.dSYM

@ArminJo
Copy link
Author

ArminJo commented Jan 30, 2021

And every time it is build, a few bytes changed at 3 or 4 locations, This leads to overwriting the old executable even if nothing in the code has changed. Do you know a compile or link switch to suppress this?

@stonehippo
Copy link
Owner

@ArminJo I'm not sure about the byte changes, but I'm pretty sure I know what you're not getting a static build. The changes in my fork of the repo are a bit off from the diff in my readme, and that's what got pulled into the core micronucleus repo. I'm going to do a PR to correct that. And I can see that it's not quite right in your version of the Makefile either.

Try replacing the MacOS section of the CLI Makefile with this:

else ifeq ($(shell uname), Darwin)
	USBFLAGS=$(shell libusb-config --cflags || libusb-legacy-config --cflags)
	USBLIBS = /usr/local/opt/libusb-compat/lib/libusb.a
	EXE_SUFFIX =
	OSFLAG = -D MAC_OS
	USBLIBS += /usr/local/opt/libusb/lib/libusb-1.0.a
	USBLIBS += -framework CoreFoundation
	USBLIBS += -framework IOKit
	# Uncomment these to create a dual architecture binary:
	# OSFLAG += -arch x86_64 -arch i386

It's the explicit reference to libusb-compat that's needed.

@ArminJo
Copy link
Author

ArminJo commented Jan 30, 2021

My current commandline is:
gcc -I/usr/local/Cellar/libusb-compat/0.1.5_1/include -I/usr/local/Cellar/libusb/1.0.24/include/libusb-1.0 -Ilibrary -O -g -D MAC_OS -o micronucleus micronucleus.c micronucleus_lib.o littleWire_util.o -L/usr/local/Cellar/libusb-compat/0.1.5_1/lib -lusb -framework CoreFoundation -framework IOKit

@stonehippo
Copy link
Owner

stonehippo commented Jan 30, 2021

@ArminJo When running via Make, this is what I get.

gcc -I/usr/local/Cellar/libusb-compat/0.1.5_1/include -Ilibrary  -O -g -D MAC_OS -o micronucleus micronucleus.c micronucleus_lib.o littleWire_util.o /usr/local/opt/libusb-compat/lib/libusb.a /usr/local/opt/libusb/lib/libusb-1.0.a -framework CoreFoundation -framework IOKit

The diff seems to be the path to libusb.

I just pushed a fix to the Makefile to my fork at https://github.com/stonehippo/micronucleus, and have submitted that as a PR to the upstream repo. I'll put the latest static build in https://github.com/stonehippo/micronucleus-commandline-builds, too.

@ArminJo
Copy link
Author

ArminJo commented Jan 30, 2021

I do not understand it!
In your repo logfile https://github.com/stonehippo/micronucleus/runs/1798998407?check_suite_focus=true#step:6:30
I see
gcc -I/usr/local/Cellar/libusb-compat/0.1.5_1/include -Ilibrary -O -g -D MAC_OS -o micronucleus micronucleus.c micronucleus_lib.o littleWire_util.o -L/usr/local/Cellar/libusb-compat/0.1.5_1/lib -lusb -lusb

which is different from:

gcc -I/usr/local/Cellar/libusb-compat/0.1.5_1/include -Ilibrary -O -g -D MAC_OS -o micronucleus micronucleus.c micronucleus_lib.o littleWire_util.o /usr/local/opt/libusb-compat/lib/libusb.a /usr/local/opt/libusb/lib/libusb-1.0.a -framework CoreFoundation -framework IOKit

Don't you use the github action, do you build it manually?

@stonehippo
Copy link
Owner

@ArminJo Nope, I'm not using the GitHub Actions. Those were inherited from the upstream repo, and I haven't had a chance to confirm that they work correctly. A quick look at .github/workflows/build-pkg.sh leads me to believe it needs an update. It more or less duplicates the original Makefile, and the USBLIBS and USBFLAGS values don't match the updates I made.

I can say with certainty the build works correctly when run locally.

@stonehippo
Copy link
Owner

@ArminJo OK, I've fixed the action so that it gets the correct libs for a static build now, too. The master-LATEST release in my fork now has a static version of the MacOS CLI in its build.

@ArminJo
Copy link
Author

ArminJo commented Feb 4, 2021

Thanks for support
Armin

@ArminJo ArminJo closed this as completed Feb 4, 2021
@stonehippo
Copy link
Owner

@ArminJo Glad to help out. Thanks for getting new builds set.

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

No branches or pull requests

2 participants