Coder Social home page Coder Social logo

libmpsse's People

Contributors

contradict avatar devttys0 avatar fletort avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

libmpsse's Issues

compilation warnings

x86_64-pc-linux-gnu-gcc -Wall -fPIC -fno-strict-aliasing -march=native -O2 -pipe -c  -DLIBFTDI1=0 mpsse_wrap.c  -I/usr/include/python3.4
mpsse_wrap.c: In function ‘_wrap_Read’:
mpsse_wrap.c:6935:5: warning: implicit declaration of function ‘PyString_FromStringAndSize’ [-Wimplicit-function-declaration]
     resultobj = PyString_FromStringAndSize((&result)->data, (&result)->size);
     ^
mpsse_wrap.c:6935:15: warning: assignment makes pointer from integer without a cast
     resultobj = PyString_FromStringAndSize((&result)->data, (&result)->size);
               ^
mpsse_wrap.c: In function ‘_wrap_Transfer’:
mpsse_wrap.c:6973:15: warning: assignment makes pointer from integer without a cast
     resultobj = PyString_FromStringAndSize((&result)->data, (&result)->size);
               ^

FT232 UART device gets disconnected when an SPI device is run

Hello,

I'm using the library to try and talk to a device using SPI over a USB interface with a Raspberry Pi. Two other RS-232 to USB cables are connected to the USB port. When I run a simple code that establishes a connection and pulls data out of the SPI device, one of the the other two devices stops appearing in the /dev/ttyUSB* list and I can't communicate with it anymore. Is there any solution to this problem?

Thanks,

Siddharth

ImportError: No module named pylibmpsse

I'm new to IoT firmware RE and I was following the blog at https://nvisium.com/blog/2019/08/07/extracting-firmware-from-iot-devices.html.

The author mentioned the following command:
sudo python spiflash.py -s 15000000 -r firmware.bin

I git cloned this repository, ran the above command and got the error:
ImportError: No module named mpsse

So, I ran the mpsse.py file in the src directory and got the error:
ImportError: No module named pylibmpsse

What is this library? How do I get spiflash.py to execute?

More information:

root@malnet:/opt/libmpsse/src/examples# python spiflash.py 
Traceback (most recent call last):
  File "spiflash.py", line 3, in <module>
    from mpsse import *
ImportError: No module named mpsse

root@malnet:/opt/libmpsse/src# python mpsse.py 
Traceback (most recent call last):
  File "mpsse.py", line 1, in <module>
    import pylibmpsse as _mpsse
ImportError: No module named pylibmpsse

root@malnet:/opt/libmpsse/src# python examples/spiflash.py 
Traceback (most recent call last):
  File "examples/spiflash.py", line 3, in <module>
    from mpsse import *
ImportError: No module named mpsse

root@malnet:/opt/libmpsse/src/examples# uname -a
Linux malnet 4.19.0-kali5-amd64 #1 SMP Debian 4.19.37-5kali1 (2019-06-20) x86_64 GNU/Linux

root@malnet:/opt/libmpsse/src/examples# python -V
Python 2.7.16

FastTransfer failing on build_block_buffer

FastTransfer was actually calling build_block_buffer which returns a pointer to the buffer rather than returning 0 or -1. Switching to fast_build_block_buffer got everything working for me.

make install fails on OS X due to non-portable install -D flag

sudo make install
install -D -m644 libmpsse.so //usr/local/lib/libmpsse.so
install: illegal option -- D
usage: install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode]
[-o owner] file1 file2
install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode]
[-o owner] file1 ... fileN directory
install -d [-v] [-g group] [-m mode] [-o owner] directory ...
make: *** [install] Error 64

==> -D is a GNU extension of the install program, not available in the BSD version of install that ships on OS X.

I2c HMC5883L connection issue to FT2232H

Hi,

I have HMC5883L magnetometer which needs to be connected to a PC through USB interface. I am connecting the HMC5883L to PC using an USB to I2c bridge FT2232H Numato breakout board.

For communicating to HMC5883L through the FTDI chip, I am using the MPSSE library. I have created a sample application to do this taking a reference using i2ceeprom.c file present in the examples folder.
But unfortunately the data I get from the device is always -1 even though the value I have written to that register it different. When I am writing the data to a particular register, I get an acknowledgment. Am I doing something wrong while writing the command?
Attaching the code for reference.
i2ctest.txt

Any comments will be helpful. I am blocked with this issue.

Regards,
Jyotsana.

Python 3 support

Hello! Is there any way to install this library for python 3? I've seen some forks that change some part of the code to be compatible with python 3 but they don't seem to address the issues regarding the libraries compiled specifically for python 2.

modified version

I have created a modified version with the following additional features:

  1. JTAG support
  2. Simultaneous READ/WRITE also for word-length that are no integer multiples of 8-Bits.
  3. READ back of the pin-state also for GPIOH
  4. Seamless switching from JTAG to SPI (and possibly I2C) and back
  5. Simultaneous use of GPIO with JTAG and/or SPI (and possibly I2C)

If somebody is interested or wants to add it to GitHub please drop me a note.
I have no experience with GitHub

Kind regard!

Wolfgang

Input pins are set to output type, buggy and/or dangerous if using inputs

In mpsse.c, lines 274-275:

		/* Clock, data out, chip select pins are outputs; all others are inputs. */
		mpsse->tris = DEFAULT_TRIS;

in mpsse.h, line 114:

'#define DEFAULT_TRIS            (SK | DO | CS | GPIO0 | GPIO1 | GPIO2 | GPIO3)  /* SK/DO/CS and GPIOs are outputs, DI is an input */

Pins that should be set as inputs are set as outputs.
Quick fix:

#define DEFAULT_TRIS            (SK | DO | CS)  /* SK/DO/CS are outputs, others are inputs */

random parallel compilation failures (-j4)

The source fails to compile around 1 from 5 times with the following error:

>>> Source configured.
>>> Compiling source in /var/tmp/portage/dev-embedded/libmpsse-1.3_p20150711/work/libmpsse-f1a6744b220d4e7b2c8719e705f56d8c171a6a32/src ...
make -j4 
x86_64-pc-linux-gnu-gcc -Wall -fPIC -fno-strict-aliasing -march=native -O2 -pipe -lftdi -Wl,-O1 -Wl,--as-needed -Wl,--hash-style=gnu -DLIBFTDI1=0 -c support.c
x86_64-pc-linux-gnu-gcc -Wall -fPIC -fno-strict-aliasing -march=native -O2 -pipe -lftdi -Wl,-O1 -Wl,--as-needed -Wl,--hash-style=gnu -DSWIGPYTHON -DLIBFTDI1=0 -c support.c
x86_64-pc-linux-gnu-gcc -Wall -fPIC -fno-strict-aliasing -march=native -O2 -pipe -lftdi -Wl,-O1 -Wl,--as-needed -Wl,--hash-style=gnu -DLIBFTDI1=0 -c mpsse.c
x86_64-pc-linux-gnu-gcc -Wall -fPIC -fno-strict-aliasing -march=native -O2 -pipe -lftdi -Wl,-O1 -Wl,--as-needed -Wl,--hash-style=gnu -c fast.c
x86_64-pc-linux-gnu-gcc -Wall -fPIC -fno-strict-aliasing -march=native -O2 -pipe -lftdi -Wl,-O1 -Wl,--as-needed -Wl,--hash-style=gnu -DSWIGPYTHON -DLIBFTDI1=0 -c mpsse.c
x86_64-pc-linux-gnu-gcc -Wall -fPIC -fno-strict-aliasing -march=native -O2 -pipe -shared -Wl,-soname,libmpsse.so mpsse.o fast.o support.o \
        -o libmpsse.so -lftdi -Wl,-O1 -Wl,--as-needed -Wl,--hash-style=gnu
/usr/bin/swig -python mpsse.i
collect2: error: ld terminated with signal 11 [Segmentation fault]
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/../../../../x86_64-pc-linux-gnu/bin/ld: error in mpsse.o(.eh_frame); no .eh_frame_hdr table will be created.
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/../../../../x86_64-pc-linux-gnu/bin/ld: mpsse.o: invalid string offset 1701981696 >= 825 for section `.strtab'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/../../../../x86_64-pc-linux-gnu/bin/ld: mpsse.o: invalid string offset 1701981696 >= 825 for section `.strtab'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/../../../../x86_64-pc-linux-gnu/bin/ld: mpsse.o: invalid string offset 1701981696 >= 825 for section `.strtab'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/../../../../x86_64-pc-linux-gnu/bin/ld: mpsse.o: invalid string offset 1701981696 >= 825 for section `.strtab'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/../../../../x86_64-pc-linux-gnu/bin/ld: mpsse.o: invalid string offset 1701981696 >= 825 for section `.strtab'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/../../../../x86_64-pc-linux-gnu/bin/ld: mpsse.o: invalid string offset 1701981696 >= 825 for section `.strtab'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/../../../../x86_64-pc-linux-gnu/bin/ld: mpsse.o: invalid string offset 1701981696 >= 825 for section `.strtab'
Makefile:21: recipe for target 'mpsse' failed
make: *** [mpsse] Error 1
make: *** Waiting for unfinished jobs....
x86_64-pc-linux-gnu-gcc -Wall -fPIC -fno-strict-aliasing -march=native -O2 -pipe -c  -DLIBFTDI1=0 mpsse_wrap.c  -I/usr/include/python2.7
x86_64-pc-linux-gnu-gcc -Wall -fPIC -fno-strict-aliasing -march=native -O2 -pipe -shared  mpsse_wrap.o mpsse.o support.o \
        -o _pylibmpsse.so -lftdi -Wl,-O1 -Wl,--as-needed -Wl,--hash-style=gnu -I/usr/include/python2.7
 * ERROR: dev-embedded/libmpsse-1.3_p20150711::pentoo failed (compile phase):
 *   emake failed
 * 
 * If you need support, post the output of `emerge --info '=dev-embedded/libmpsse-1.3_p20150711::pentoo'`,
 * the complete build log and the output of `emerge -pqv '=dev-embedded/libmpsse-1.3_p20150711::pentoo'`.
 * The complete build log is located at '/var/tmp/portage/dev-embedded/libmpsse-1.3_p20150711/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/dev-embedded/libmpsse-1.3_p20150711/temp/environment'.
 * Working directory: '/var/tmp/portage/dev-embedded/libmpsse-1.3_p20150711/work/libmpsse-f1a6744b220d4e7b2c8719e705f56d8c171a6a32/src'
 * S: '/var/tmp/portage/dev-embedded/libmpsse-1.3_p20150711/work/libmpsse-f1a6744b220d4e7b2c8719e705f56d8c171a6a32/src'

Is devttys0/libmpsse the de facto upstream for libmpsse?

I would like to add some changes, but I'd like to understand if this is the "right place" for libmpsse now. Was this repo first? Should it be the default upstream for most of the world's consumers of libmpsse?

I'd also like to update the FreeBSD port which is still pointing to the googlecode home for libmpsse. That archive is still available, but obviously it's not an active project there anymore.

I see there are some pending unreviewed (or at least uncommented) issues. If this is to be the default upstream version, maybe the community should add some helpful comments to assist the current committers. Or maybe this repo (if it's the consensus official repo) should add some committers to help maintain it.

make error (on OS X)

When trying make, an error occur (on OS X for me)
In file included from fast.c:10:
./mpsse.h:9:10: fatal error: 'ftdi.h' file not found

include <ftdi.h>

I think that as fast.c include maps.h, it need LIBFTDI1 define for its compilation.

Problems with libmpsse on OSX 10.11

Hey, so i have this weird problem, i followed the instructions and ran

./configure
make
make install

that part worked okay, apart from the tiny change i had to make to the MakeFIle to remove the "-D" option from the install command as its not supported by OSX, but when i tried to run the sample programs, i got this error

Traceback (most recent call last):
  File "gpio.py", line 7, in <module>
    io = MPSSE(GPIO)
  File "/Users/tabishimran/code/devttys0-mpsse/src/mpsse.py", line 70, in __init__
    raise Exception, self.ErrorString()
Exception: device not found

The install file says to install libftdi manually, i did that, and i also installed the D2XX and VCP drivers.
I still get the same error!
Any ideas?

Integrating with OSS-Fuzz

Greetings libmpsse developers and contributors,

We’re reaching out because your project is an important part of the open source ecosystem, and we’d like to invite you to integrate with our fuzzing service, OSS-Fuzz. OSS-Fuzz is a free fuzzing infrastructure you can use to identify security vulnerabilities and stability bugs in your project. OSS-Fuzz will:

  • Continuously run at scale all the fuzzers you write.
  • Alert you when it finds issues.
  • Automatically close issues after they’ve been fixed by a commit.

Many widely used open source projects like OpenSSL, FFmpeg, LibreOffice, and ImageMagick are fuzzing via OSS-Fuzz, which helps them find and remediate critical issues.

Even though typical integrations can be done in < 100 LoC, we have a reward program in place which aims to recognize folks who are not just contributing to open source, but are also working hard to make it more secure.

We want to stress that anyone who meets the eligibility criteria and integrates a project with OSS-Fuzz is eligible for a reward.

To help you getting started, we can attach our internal fuzzer for your project that you are welcome to use directly, or to use it as a starting point.

If you're not interested in integrating with OSS-Fuzz, it would be helpful for us to understand why—lack of interest, lack of time, or something else—so we can better support projects like yours in the future.

If we’ve missed your question in our FAQ, feel free to reply or reach out to us at [email protected].

Thanks!

Tommy
OSS-Fuzz Team

error: missing fdtdi1 library

I am unable to configure and build this library. The ./configure script complains that the libftdi1 library is missing but ldconfig reports the loaded library. I built and installed the FTDI library from here http://developer.intra2net.com/libftdi

root@iot2000:/opt/libmpsse/src# ./configure
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for size_t... yes
checking for stdlib.h... (cached) yes
checking for GNU libc compatible malloc... yes
checking libftdi1/ftdi.h usability... yes
checking libftdi1/ftdi.h presence... yes
checking for libftdi1/ftdi.h... yes
checking for ftdi_init in -lftdi1... no
error: missing libftdi1 library
root@iot2000:/opt/libmpsse/src# ldconfig -p | grep ftdi1
libftdi1.so.2 (libc6) => /usr/local/lib/libftdi1.so.2
libftdi1.so (libc6) => /usr/local/lib/libftdi1.so

Any thoughts as to what I could do to get the ./configure script to correctly detect the library?

Thanks

Unable to open device

After building and installing both the C and Python libraries I get the following error when opening a device in Python using c13df34.

File "/usr/local/lib/python2.7/dist-packages/mpsse.py", line 161, in Open
    if self.context.open == 0:
AttributeError: 'int' object has no attribute 'open'

I did not have this problem with the SWIG version prior to 235fd68.

Error while running C examples

Hello,
I am working with SPI NAND flash : http://pro0fc108.hkpic1.websiteonline.cn/upload/PN26Q01AWSIUG.pdf

After make example-code, I successfully obtained following :
bitbang ds1305.c gpio.c i2ceeprom.py spiflash.c test.bin
bitbang.c ds1305.py gpio.py Makefile spiflashfast
bitbang.py eeprom.bin i2ceeprom spiflashfast.c
ds1305 gpio i2ceeprom.c spiflash spiflash.py

But while executing ./spiflash, I am getting error ->

./spiflash: error while loading shared libraries: libmpsse.so: cannot open shared object file: No such file or directory

Kindly suggest

Thanks and regards
Asmita

including mpsse.h in projects can cause "duplicate symbol" linker errors

including mpsse.h in multiple source files can cause "duplicate symbol" linker errors due to fast_rw_buf being defined in the header file.

I removed
unsigned char fast_rw_buf[SPI_RW_SIZE + CMD_SIZE];
from mpsse.h
and added
static unsigned char fast_rw_buf[SPI_RW_SIZE + CMD_SIZE];
to fast.c

Maybe Im not sure how this is supposed to be used, but it only seems useful in fast.c's functions which are "For internal use only"

Erroneous clock frequency

Hello, I'm having a bit of trouble setting the clock frequency. For example if I create the I2C object using a 2 MHz frequency (TWO_MHZ parameter), the real observed frequency is 1,33 MHz. This ratio appears no matter the frequency I set, the real frequency is always 2/3 out of the frequency I set. Any reason for this?

Screenshot from 2020-04-09 12-22-16

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.