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

Claim interface on OS X. #16

Merged
merged 1 commit into from
May 27, 2015
Merged

Claim interface on OS X. #16

merged 1 commit into from
May 27, 2015

Conversation

tcr
Copy link
Contributor

@tcr tcr commented May 2, 2015

This might not be useful to merge in, but this is the fix I had to apply to fix endpoint enumeration failing on OS X. See #9 for the same error message.

@tcr tcr mentioned this pull request May 2, 2015
@gicking
Copy link

gicking commented May 5, 2015

hi Tim,

with your change to main.c (see here) and the described unloading of the kernel extensions (see here) I can now program using stm8flash under MacOS X. Thanks a lot for that!

But is unloading the kernel extensions the only possible solution? Afterwards I cannot use USB-sticks or SD-cards. And I am concerned that I forget to re-load them and lose this important functionality - until reboot (just checked) or I find this thread again...

Under Linux and Windows the ST-Link mounts as a drive with 3 files, under OS X not. Is that the reason why the kernel extensions have to be disabled? If yes, would it be an option to identify and solve the issue with mounting the ST-Link? Sorry to be so annoying, but the current solution just seems very complicated.

For your support thanks a lot in advance!

Georg

@tcr
Copy link
Contributor Author

tcr commented May 5, 2015

But is unloading the kernel extensions the only possible solution? Afterwards I cannot use USB-sticks or SD-cards. And I am concerned that I forget to re-load them and lose this important functionality - until reboot (just checked) or I find this thread again...

There are lots of issues with USB CDC drivers too on OS X which require unloading. You may find some luck in looking into if there are solutions there (google kextunload, CDC, Arduino)

Under Linux and Windows the ST-Link mounts as a drive with 3 files, under OS X not. Is that the reason why the kernel extensions have to be disabled? If yes, would it be an option to identify and solve the issue with mounting the ST-Link?

That's the case. Inside USB Prober the device is listed as a Mass Storage Device, but why it doesn't mount is beyond me. I suspect that solving the mounting issues would not resolve this particular problem though—if it is an issue with the kernel claiming the device, the specified endpoints would still not be able to be accessed.

@TorstenRobitzki
Copy link
Contributor

this works for me on OS/X without the need to unload any kernel extensions.

vdudouyt added a commit that referenced this pull request May 27, 2015
Claim interface on OS X.
@vdudouyt vdudouyt merged commit 4e454ee into vdudouyt:master May 27, 2015
@gicking
Copy link

gicking commented Jun 7, 2015

hi Torsten,

I just downloaded the fresh version of stm8flash from GitHub. And with patch #17 merged I can now compile and run "stm8flash" under MacOSX 10.10.3. However, I just still need to unload the Kernel extensions for USB-sticks and flash cards using:

sudo kextunload -b com.apple.driver.AppleUSBCardReader
sudo kextunload -b com.apple.iokit.IOUSBMassStorageClass

Any idea what do you do different? While the above is not the end of the world it makes stm8flash impossible to use for non-admins and it is inconvenient. Any help is highly appreciated!

Georg

@TorstenRobitzki
Copy link
Contributor

Hi Georg,
sorry, no idea. I have a vanilla OS/X 10.9. and a colleague of mine uses 10.10. without problems. The only problem that we face is that stm8flash hangs very often. But that's fixable by unplugging and plugging the usb cable.

What are the symptoms you are facing?

Cheers,
Torsten

@gicking
Copy link

gicking commented Jun 7, 2015

Hi Torsten,

below is the console output with and without unloading kernel extensions. This is similar to what is described (and solved) here

Georg


stm8flash -c stlink -p stm8s105 -w blinky.ihx
Determine FLASH area
Writing Intel hex file 427 bytes at 0x8000... OK
Bytes written: 427


stm8flash -c stlink -p stm8s105 -w blinky.ihx
Determine FLASH area
libusb: error [darwin_claim_interface] USBInterfaceOpen: another process has device opened for exclusive access
Assertion failed: (r == 0), function usb_init, file main.c, line 103.
make: *** [flash] Abort trap: 6

@TorstenRobitzki
Copy link
Contributor

It would be interesting to know which other process claimed the usb device. Does this occur when starting stm8flash the first time on a freshly booted computer?

@tcr
Copy link
Contributor Author

tcr commented Jun 7, 2015

I think the process is the kernel extension itself, e.g. AppleUSBCardReader is trying to read the STM8 board as a mass storage device (as its USB descriptor states). As long as the kernel thinks it can talk to the device, it will lock it for exclusive access.

https://github.com/libusb/libusb/wiki/FAQ#how-can-i-run-libusb-applications-under-mac-os-x-if-there-is-already-a-kernel-extension-installed-for-the-device

As for why different machines behave differently—a great question, perhaps this is reflected in the USB Prober logs?

@gicking
Copy link

gicking commented Jun 9, 2015

hi Torsten,

yes, this occurs also on a freshly booted computer. I guess tcr is correct, since the ST-Link on the discovery board is mounted as a drive under Win and Linux - and it doesn't under OS X. However, that information doesn't really help...

@tcr: where can I find the USB Prober logs?

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

Successfully merging this pull request may close these issues.

4 participants