Im working with GUI's PyQt for my AVR board.I want to implement the dfu-programmer bootloader in my application so I can use it inside. I've generated the libdfu.so (and copied into my /usr/lib) with the following command :
gcc -shared -Wl,-soname,libdfu -o libdfu.so -fPIC arguments.o main.o commands.o dfu.o atmel.o util.o intel_hex.o
All the object files are from the dfu-programmer sources, I don't really know if it's the good way to do so. I've tried to load the library with the testlib.py here:
import ctypes
testlib = ctypes.CDLL('libdfu.so')
testlib.usage()
And it give me this error :
$ python teslib.py
Traceback (most recent call last):
File "teslib.py", line 3, in <module>
testlib = ctypes.CDLL('libdfu.so')
File "/usr/lib/python2.6/ctypes/__init__.py", line 353, in __init__
self._handle = _dlopen(self._name, mode)
OSError: /usr/lib/libdfu.so: undefined symbol: usb_init
I also tried to import the libusb-1.0.so before library because the bootloader use it but it do开发者_如何学Cn't work (same error)...
Any solutions? Thanks.
I've found the problem,it was a dependencies with the libusb.so. To issue this I've set the LDFLAGS and CPPFLAGS (to respective /usr/lib and /usr/include directories) and add the -libusb option to my previous command :
gcc -shared -Wl,-soname,dfulib.so.1 -o dfulib.so.1.0.1 arguments.o commands.o atmel.o dfu.o intel_hex.o main.o util.o -lusb -ldl
Thanks. :) (hope it can help someone again)
精彩评论