ImportError: No module named usb.core

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
KevinA
Posts: 12
Joined: Mon Nov 09, 2015 11:17 pm

ImportError: No module named usb.core

Post by KevinA » Wed May 30, 2018 6:48 pm

While discovering MicroPython I updated my stm32f4-discovery with a pre-built DFU image I found, works great. My next attempt was at building an image for the BLACK_F407VE/ZE/ZG boards I've had laying around collecting dust (Pet rocks). Installed Ubuntu 16.04 on Windows 10 and followed the guide to build/setup MicroPython, spent some time weeding my way through all the ways to install the ARM Tools and finally found the working way.
BUT:
ImportError: No module named usb.core stops everything

kevin@Gate:~/micropython/ports/stm32$ make BOARD=BLACK_F407VE deploy
Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.
Writing build-BLACK_F407VE/firmware.dfu to the board
Traceback (most recent call last):
File "../../tools/pydfu.py", line 20, in <module>
import usb.core
ImportError: No module named usb.core
Makefile:455: recipe for target 'deploy' failed
make: *** [deploy] Error 1
These boards are prefect for a LoRa project with the RTC+Battery+8 pin connector for a NRF24L01

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: ImportError: No module named usb.core

Post by dhylands » Wed May 30, 2018 8:04 pm

You need to install the pyusb module.

Code: Select all

sudo apt install python-usb
and/or

Code: Select all

sudo apt install python3-usb
depending on which version of python your distro uses for 'python'. Using apt is appropriate for ubuntu 16.04 and later. For other distros you may need to use a different installer.

KevinA
Posts: 12
Joined: Mon Nov 09, 2015 11:17 pm

Re: ImportError: No module named usb.core

Post by KevinA » Wed May 30, 2018 10:26 pm

Did that but another issue, my Windows 10 hosted linux has no lsusb devices!
( Found: In Windows Insider build #16176 WSL now allows access to serial devices (COM ports).)
$ make BOARD=BLACK_F407ZE deploy
Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.
Writing build-BLACK_F407ZE/firmware.dfu to the board
Traceback (most recent call last):
File "../../tools/pydfu.py", line 541, in <module>
main()
File "../../tools/pydfu.py", line 521, in main
init()
File "../../tools/pydfu.py", line 80, in init
raise ValueError('No DFU device found')
ValueError: No DFU device found
Makefile:455: recipe for target 'deploy' failed
make: *** [deploy] Error 1

No problem, cp firmware.dfu /mnt/e/f407ze.dfu then use the STM dfu tool
BUT:
The ZE and VE builds worked and are now loaded with MicroPython: ZG
LINK build-BLACK_F407ZG/firmware.elf
arm-none-eabi-ld: warning: cannot find entry symbol _start; defaulting to 0000000000008000
text data bss dec hex filename
0 0 0 0 0 build-BLACK_F407ZG/firmware.elf
Create build-BLACK_F407ZG/firmware.dfu
GEN build-BLACK_F407ZG/firmware.hex

The firmware.dfu is 309 bytes
The firmware.hex is 34 bytes
I did a make -B BOARD=BLACK_F407ZG and a while later I got the same results, very little code if any at all. From https://github.com/SpotlightKid/BLACK_F407ZG

FYI: After I used the STM DFU loader I disconnected the USB cable (mini-usb), removed the jumper but when I plugged the usb cable back into the units no flash drive or USB. After they sat around for 20 minutes I plugged the VE back in and it worked, same with the ZE.

KevinA
Posts: 12
Joined: Mon Nov 09, 2015 11:17 pm

Re: ImportError: No module named usb.core

Post by KevinA » Wed May 30, 2018 11:35 pm

It seems the BLACK_F4 are all using F405 linker and AF definitions except the ZG board, I change that to match the ZE board since the ZE was using the 1MB flash F405 linker code.... which includes ethernet for F405 devices, someday I'll spend the time to figure that out. D407ZG now works!

Post Reply