Coder Social home page Coder Social logo

karosium / smbusb Goto Github PK

View Code? Open in Web Editor NEW
133.0 19.0 41.0 161 KB

USB SMBus Interface

License: GNU Lesser General Public License v2.1

Makefile 0.61% Batchfile 1.33% M4 1.61% Assembly 3.92% C 92.48% Shell 0.04%
firmware battery smbus flash hacking-tool

smbusb's People

Contributors

0r10nv avatar jalr avatar karosium avatar khseal avatar ondrej-zary avatar sheinz 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

smbusb's Issues

Scanning only works once

smbusb_scan -a only seems to work until it finds my controller (bq8030), after that it always comes back with ERROR -9.
First scan:

`------------------------------------
smbusb_scan

SMBusb Firmware Version: 1.0.1
Scanning for addresses..
Scan range: 00 - ff
Skipping: a0 a1

[16] ACK
[17] ACK
[19] ERROR: -9
[1a] ERROR: -9
[1b] ERROR: -9
[1c] ERROR: -9
[1d] ERROR: -9
[1e] ERROR: -9
[1f] ERROR: -9
`

Starting another scan after that:

`------------------------------------
smbusb_scan

SMBusb Firmware Version: 1.0.1
Scanning for addresses..
Scan range: 00 - ff
Skipping: a0 a1

[0] ERROR: -9
[1] ERROR: -9
[2] ERROR: -9
[3] ERROR: -9
[4] ERROR: -9
[5] ERROR: -9
[6] ERROR: -9
[7] ERROR: -9
[8] ERROR: -9
[9] ERROR: -9
[a] ERROR: -9
[b] ERROR: -9
[c] ERROR: -9
[d] ERROR: -9
[e] ERROR: -9
[f] ERROR: -9
[10] ERROR: -9
[11] ERROR: -9
[12] ERROR: -9
[13] ERROR: -9
[14] ERROR: -9
[15] ERROR: -9
[16] ERROR: -9
[17] ERROR: -9
`
Every time I plug in the FX2 it will work exactly once. I tested it on my laptop running Manjaro and on a Raspberry Pi 2.

writing program to bq8030 doesn't work

  1. I'm having trouble flashing the program. Normally I would blame my hardware for this but I played around with two batteries and both showed the same issue. One is now bricked but the other works so I can still try things out ;)

  2. In your blog you mentioned that Error -11 means LIBUSB_ERROR_NO_MEM.
    I tried to understand why that would happen and came across the writeProgramBlock function where you return status-2. If I understood that correctly SMBWriteBlock returns the size written successfully or alternatively a negative number in case of an error. If that is correct you should return (status > 0 ? status-2 : status); in writeProgramBlock and the same for writeEepromBlock. I'll send you a PR if you confirm this.

smbusb_bq8030flasher -f prg.bin --confirm-delete
------------------------------------
        smbusb_bq8030flasher
------------------------------------
SMBusb Firmware Version: 1.0.1
PEC is ENABLED
TI Boot ROM version 3.2
------------------------------------
Erasing program flash
Done
Flashing program flash
Error:-11

writing the eeprom works like a charm:

smbusb_bq8030flasher -w eep.bin --confirm-delete
------------------------------------
        smbusb_bq8030flasher
------------------------------------
SMBusb Firmware Version: 1.0.1
PEC is ENABLED
TI Boot ROM version 3.2
------------------------------------
Erasing eeprom(data) flash
Done
Flashing eeprom(data) flash
................................................................
Done!
Verifying
................................................................
Verified OK!

connection issue - smbusb firmware error

Hi,
I'm trying to compile the everything (, but I'm not sure it's correct.
Getting the following message after make:

``Making all in firmware
make[1]: Entering directory '/home/jacob/Downloads/smbusb-master/firmware'
Makefile:17: warning: overriding recipe for target 'clean'
../fx2lib/lib/fx2.mk:100: warning: ignoring old recipe for target 'clean'
xxd -i build/smbusb_firmware.ihx firmware.h
cp firmware.h ../lib/firmware.h
make[1]: Leaving directory '/home/jacob/Downloads/smbusb-master/firmware'
Making all in lib
make[1]: Entering directory '/home/jacob/Downloads/smbusb-master/lib'
/bin/bash ../libtool --tag=CC --mode=compile gcc -DPACKAGE_NAME="libsmbusb" -DPACKAGE_TARNAME="libsmbusb" -DPACKAGE_VERSION="1.0.1" -DPACKAGE_STRING="libsmbusb\ 1.0.1" -DPACKAGE_BUGREPORT="[email protected]" -DPACKAGE_URL="" -DPACKAGE="libsmbusb" -DVERSION="1.0.1" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=".libs/" -DHAVE_LIBUSB_1_0=1 -DSTDC_HEADERS=1 -I. -g -O2 -I/usr/include/libusb-1.0 -MT libsmbusb_la-smbusb.lo -MD -MP -MF .deps/libsmbusb_la-smbusb.Tpo -c -o libsmbusb_la-smbusb.lo test -f 'smbusb.c' || echo './'smbusb.c
libtool: compile: gcc -DPACKAGE_NAME="libsmbusb" -DPACKAGE_TARNAME="libsmbusb" -DPACKAGE_VERSION="1.0.1" "-DPACKAGE_STRING="libsmbusb 1.0.1"" -DPACKAGE_BUGREPORT="[email protected]" -DPACKAGE_URL="" -DPACKAGE="libsmbusb" -DVERSION="1.0.1" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=".libs/" -DHAVE_LIBUSB_1_0=1 -DSTDC_HEADERS=1 -I. -g -O2 -I/usr/include/libusb-1.0 -MT libsmbusb_la-smbusb.lo -MD -MP -MF .deps/libsmbusb_la-smbusb.Tpo -c smbusb.c -fPIC -DPIC -o .libs/libsmbusb_la-smbusb.o
smbusb.c: In function ‘SMBOpenDeviceVIDPID’:
smbusb.c:89:2: warning: ‘libusb_set_debug’ is deprecated: Use libusb_set_option instead [-Wdeprecated-declarations]
89 | libusb_set_debug(NULL, 0);
| ^~~~~~~~~~~~~~~~
In file included from smbusb.c:27:
/usr/include/libusb-1.0/libusb.h:1325:18: note: declared here
1325 | void LIBUSB_CALL libusb_set_debug(libusb_context *ctx, int level);
| ^~~~~~~~~~~~~~~~
smbusb.c: In function ‘SMBOpenDeviceBusAddr’:
smbusb.c:112:2: warning: ‘libusb_set_debug’ is deprecated: Use libusb_set_option instead [-Wdeprecated-declarations]
112 | libusb_set_debug(NULL, 0);
| ^~~~~~~~~~~~~~~~
In file included from smbusb.c:27:
/usr/include/libusb-1.0/libusb.h:1325:18: note: declared here
1325 | void LIBUSB_CALL libusb_set_debug(libusb_context *ctx, int level);
| ^~~~~~~~~~~~~~~~
libtool: compile: gcc -DPACKAGE_NAME="libsmbusb" -DPACKAGE_TARNAME="libsmbusb" -DPACKAGE_VERSION="1.0.1" "-DPACKAGE_STRING="libsmbusb 1.0.1"" -DPACKAGE_BUGREPORT="[email protected]" -DPACKAGE_URL="" -DPACKAGE="libsmbusb" -DVERSION="1.0.1" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=".libs/" -DHAVE_LIBUSB_1_0=1 -DSTDC_HEADERS=1 -I. -g -O2 -I/usr/include/libusb-1.0 -MT libsmbusb_la-smbusb.lo -MD -MP -MF .deps/libsmbusb_la-smbusb.Tpo -c smbusb.c -o libsmbusb_la-smbusb.o >/dev/null 2>&1
mv -f .deps/libsmbusb_la-smbusb.Tpo .deps/libsmbusb_la-smbusb.Plo
/bin/bash ../libtool --tag=CC --mode=link gcc -g -O2 -I/usr/include/libusb-1.0 -version-info 1:1:0 -o libsmbusb.la -rpath /usr/local/lib libsmbusb_la-smbusb.lo libsmbusb_la-fxloader.lo -lusb-1.0 -lusb-1.0
libtool: link: rm -fr .libs/libsmbusb.a .libs/libsmbusb.la .libs/libsmbusb.lai .libs/libsmbusb.so .libs/libsmbusb.so.1 .libs/libsmbusb.so.1.0.1
libtool: link: gcc -shared -fPIC -DPIC .libs/libsmbusb_la-smbusb.o .libs/libsmbusb_la-fxloader.o -lusb-1.0 -g -O2 -Wl,-soname -Wl,libsmbusb.so.1 -o .libs/libsmbusb.so.1.0.1
libtool: link: (cd ".libs" && rm -f "libsmbusb.so.1" && ln -s "libsmbusb.so.1.0.1" "libsmbusb.so.1")
libtool: link: (cd ".libs" && rm -f "libsmbusb.so" && ln -s "libsmbusb.so.1.0.1" "libsmbusb.so")
libtool: link: ar cr .libs/libsmbusb.a libsmbusb_la-smbusb.o libsmbusb_la-fxloader.o
libtool: link: ranlib .libs/libsmbusb.a
libtool: link: ( cd ".libs" && rm -f "libsmbusb.la" && ln -s "../libsmbusb.la" "libsmbusb.la" )
cp ../firmware/firmware.h .
make[1]: Leaving directory '/home/jacob/Downloads/smbusb-master/lib'
Making all in tools
make[1]: Entering directory '/home/jacob/Downloads/smbusb-master/tools'
/bin/bash ../libtool --tag=CC --mode=link gcc -I../lib -g -O2 -I/usr/include/libusb-1.0 -o smbusb_bootstrap smbusb_bootstrap.o ../lib/libsmbusb.la -lusb-1.0 -lusb-1.0
libtool: link: gcc -I../lib -g -O2 -I/usr/include/libusb-1.0 -o .libs/smbusb_bootstrap smbusb_bootstrap.o ../lib/.libs/libsmbusb.so -lusb-1.0
/bin/bash ../libtool --tag=CC --mode=link gcc -I../lib -g -O2 -I/usr/include/libusb-1.0 -o smbusb_sbsreport smbusb_sbsreport.o ../lib/libsmbusb.la -lusb-1.0 -lusb-1.0
libtool: link: gcc -I../lib -g -O2 -I/usr/include/libusb-1.0 -o .libs/smbusb_sbsreport smbusb_sbsreport.o ../lib/.libs/libsmbusb.so -lusb-1.0
/bin/bash ../libtool --tag=CC --mode=link gcc -I../lib -g -O2 -I/usr/include/libusb-1.0 -o smbusb_bq8030flasher smbusb_bq8030flasher.o ../lib/libsmbusb.la -lusb-1.0 -lusb-1.0
libtool: link: gcc -I../lib -g -O2 -I/usr/include/libusb-1.0 -o .libs/smbusb_bq8030flasher smbusb_bq8030flasher.o ../lib/.libs/libsmbusb.so -lusb-1.0
/bin/bash ../libtool --tag=CC --mode=link gcc -I../lib -g -O2 -I/usr/include/libusb-1.0 -o smbusb_r2j240flasher smbusb_r2j240flasher.o ../lib/libsmbusb.la -lusb-1.0 -lusb-1.0
libtool: link: gcc -I../lib -g -O2 -I/usr/include/libusb-1.0 -o .libs/smbusb_r2j240flasher smbusb_r2j240flasher.o ../lib/.libs/libsmbusb.so -lusb-1.0
/bin/bash ../libtool --tag=CC --mode=link gcc -I../lib -g -O2 -I/usr/include/libusb-1.0 -o smbusb_m37512flasher smbusb_m37512flasher.o ../lib/libsmbusb.la -lusb-1.0 -lusb-1.0
libtool: link: gcc -I../lib -g -O2 -I/usr/include/libusb-1.0 -o .libs/smbusb_m37512flasher smbusb_m37512flasher.o ../lib/.libs/libsmbusb.so -lusb-1.0
/bin/bash ../libtool --tag=CC --mode=link gcc -I../lib -g -O2 -I/usr/include/libusb-1.0 -o smbusb_scan smbusb_scan.o ../lib/libsmbusb.la -lusb-1.0 -lusb-1.0
libtool: link: gcc -I../lib -g -O2 -I/usr/include/libusb-1.0 -o .libs/smbusb_scan smbusb_scan.o ../lib/.libs/libsmbusb.so -lusb-1.0
/bin/bash ../libtool --tag=CC --mode=link gcc -I../lib -g -O2 -I/usr/include/libusb-1.0 -o smbusb_comm smbusb_comm.o ../lib/libsmbusb.la -lusb-1.0 -lusb-1.0
libtool: link: gcc -I../lib -g -O2 -I/usr/include/libusb-1.0 -o .libs/smbusb_comm smbusb_comm.o ../lib/.libs/libsmbusb.so -lusb-1.0

make[1]: Leaving directory '/home/jacob/Downloads/smbusb-master/tools'
make[1]: Entering directory '/home/jacob/Downloads/smbusb-master'
make[1]: Nothing to be done for 'all-am'.
make[1]: Leaving directory '/home/jacob/Downloads/smbusb-master'

Then I'm running make install:

Making install in firmware
make[1]: Entering directory '/home/jacob/Downloads/smbusb-master/firmware'
Makefile:17: warning: overriding recipe for target 'clean'
../fx2lib/lib/fx2.mk:100: warning: ignoring old recipe for target 'clean'
make[1]: Nothing to be done for 'install'.
make[1]: Leaving directory '/home/jacob/Downloads/smbusb-master/firmware'
Making install in lib
make[1]: Entering directory '/home/jacob/Downloads/smbusb-master/lib'
/bin/bash ../libtool --tag=CC --mode=compile gcc -DPACKAGE_NAME="libsmbusb" -DPACKAGE_TARNAME="libsmbusb" -DPACKAGE_VERSION="1.0.1" -DPACKAGE_STRING="libsmbusb\ 1.0.1" -DPACKAGE_BUGREPORT="[email protected]" -DPACKAGE_URL="" -DPACKAGE="libsmbusb" -DVERSION="1.0.1" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=".libs/" -DHAVE_LIBUSB_1_0=1 -DSTDC_HEADERS=1 -I. -g -O2 -I/usr/include/libusb-1.0 -MT libsmbusb_la-smbusb.lo -MD -MP -MF .deps/libsmbusb_la-smbusb.Tpo -c -o libsmbusb_la-smbusb.lo test -f 'smbusb.c' || echo './'smbusb.c
libtool: compile: gcc -DPACKAGE_NAME="libsmbusb" -DPACKAGE_TARNAME="libsmbusb" -DPACKAGE_VERSION="1.0.1" "-DPACKAGE_STRING="libsmbusb 1.0.1"" -DPACKAGE_BUGREPORT="[email protected]" -DPACKAGE_URL="" -DPACKAGE="libsmbusb" -DVERSION="1.0.1" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=".libs/" -DHAVE_LIBUSB_1_0=1 -DSTDC_HEADERS=1 -I. -g -O2 -I/usr/include/libusb-1.0 -MT libsmbusb_la-smbusb.lo -MD -MP -MF .deps/libsmbusb_la-smbusb.Tpo -c smbusb.c -fPIC -DPIC -o .libs/libsmbusb_la-smbusb.o
smbusb.c: In function ‘SMBOpenDeviceVIDPID’:
smbusb.c:89:2: warning: ‘libusb_set_debug’ is deprecated: Use libusb_set_option instead [-Wdeprecated-declarations]
89 | libusb_set_debug(NULL, 0);
| ^~~~~~~~~~~~~~~~
In file included from smbusb.c:27:
/usr/include/libusb-1.0/libusb.h:1325:18: note: declared here
1325 | void LIBUSB_CALL libusb_set_debug(libusb_context *ctx, int level);
| ^~~~~~~~~~~~~~~~
smbusb.c: In function ‘SMBOpenDeviceBusAddr’:
smbusb.c:112:2: warning: ‘libusb_set_debug’ is deprecated: Use libusb_set_option instead [-Wdeprecated-declarations]
112 | libusb_set_debug(NULL, 0);
| ^~~~~~~~~~~~~~~~
In file included from smbusb.c:27:
/usr/include/libusb-1.0/libusb.h:1325:18: note: declared here
1325 | void LIBUSB_CALL libusb_set_debug(libusb_context *ctx, int level);
| ^~~~~~~~~~~~~~~~
libtool: compile: gcc -DPACKAGE_NAME="libsmbusb" -DPACKAGE_TARNAME="libsmbusb" -DPACKAGE_VERSION="1.0.1" "-DPACKAGE_STRING="libsmbusb 1.0.1"" -DPACKAGE_BUGREPORT="[email protected]" -DPACKAGE_URL="" -DPACKAGE="libsmbusb" -DVERSION="1.0.1" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=".libs/" -DHAVE_LIBUSB_1_0=1 -DSTDC_HEADERS=1 -I. -g -O2 -I/usr/include/libusb-1.0 -MT libsmbusb_la-smbusb.lo -MD -MP -MF .deps/libsmbusb_la-smbusb.Tpo -c smbusb.c -o libsmbusb_la-smbusb.o >/dev/null 2>&1
mv -f .deps/libsmbusb_la-smbusb.Tpo .deps/libsmbusb_la-smbusb.Plo
/bin/bash ../libtool --tag=CC --mode=link gcc -g -O2 -I/usr/include/libusb-1.0 -version-info 1:1:0 -o libsmbusb.la -rpath /usr/local/lib libsmbusb_la-smbusb.lo libsmbusb_la-fxloader.lo -lusb-1.0 -lusb-1.0
libtool: link: rm -fr .libs/libsmbusb.a .libs/libsmbusb.la .libs/libsmbusb.lai .libs/libsmbusb.so .libs/libsmbusb.so.1 .libs/libsmbusb.so.1.0.1
libtool: link: gcc -shared -fPIC -DPIC .libs/libsmbusb_la-smbusb.o .libs/libsmbusb_la-fxloader.o -lusb-1.0 -g -O2 -Wl,-soname -Wl,libsmbusb.so.1 -o .libs/libsmbusb.so.1.0.1
libtool: link: (cd ".libs" && rm -f "libsmbusb.so.1" && ln -s "libsmbusb.so.1.0.1" "libsmbusb.so.1")
libtool: link: (cd ".libs" && rm -f "libsmbusb.so" && ln -s "libsmbusb.so.1.0.1" "libsmbusb.so")
libtool: link: ar cr .libs/libsmbusb.a libsmbusb_la-smbusb.o libsmbusb_la-fxloader.o
libtool: link: ranlib .libs/libsmbusb.a
libtool: link: ( cd ".libs" && rm -f "libsmbusb.la" && ln -s "../libsmbusb.la" "libsmbusb.la" )
make[2]: Entering directory '/home/jacob/Downloads/smbusb-master/lib'
/bin/mkdir -p '/usr/local/lib'
/bin/bash ../libtool --mode=install /usr/bin/install -c libsmbusb.la '/usr/local/lib'
libtool: install: /usr/bin/install -c .libs/libsmbusb.so.1.0.1 /usr/local/lib/libsmbusb.so.1.0.1
libtool: install: (cd /usr/local/lib && { ln -s -f libsmbusb.so.1.0.1 libsmbusb.so.1 || { rm -f libsmbusb.so.1 && ln -s libsmbusb.so.1.0.1 libsmbusb.so.1; }; })
libtool: install: (cd /usr/local/lib && { ln -s -f libsmbusb.so.1.0.1 libsmbusb.so || { rm -f libsmbusb.so && ln -s libsmbusb.so.1.0.1 libsmbusb.so; }; })
libtool: install: /usr/bin/install -c .libs/libsmbusb.lai /usr/local/lib/libsmbusb.la
libtool: install: /usr/bin/install -c .libs/libsmbusb.a /usr/local/lib/libsmbusb.a
libtool: install: chmod 644 /usr/local/lib/libsmbusb.a
libtool: install: ranlib /usr/local/lib/libsmbusb.a
libtool: finish: PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/sbin" ldconfig -n /usr/local/lib


Libraries` have been installed in:
/usr/local/lib
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the '-LLIBDIR'
flag during linking and do at least one of the following:

  • add LIBDIR to the 'LD_LIBRARY_PATH' environment variable
    during execution
  • add LIBDIR to the 'LD_RUN_PATH' environment variable
    during linking
  • use the '-Wl,-rpath -Wl,LIBDIR' linker flag
  • have your system administrator add LIBDIR to '/etc/ld.so.conf'
    See any operating system documentation about shared libraries for
    more information, such as the ld(1) and ld.so(8) manual pages.

/bin/mkdir -p '/usr/local/include'
/usr/bin/install -c -m 644 libsmbusb.h '/usr/local/include'
/bin/mkdir -p '/usr/local/lib/pkgconfig'
/usr/bin/install -c -m 644 libsmbusb.pc '/usr/local/lib/pkgconfig'
make[2]: Leaving directory '/home/jacob/Downloads/smbusb-master/lib'
make[1]: Leaving directory '/home/jacob/Downloads/smbusb-master/lib'
Making install in tools
make[1]: Entering directory '/home/jacob/Downloads/smbusb-master/tools'
/bin/bash ../libtool --tag=CC --mode=link gcc -I../lib -g -O2 -I/usr/include/libusb-1.0 -o smbusb_bootstrap smbusb_bootstrap.o ../lib/libsmbusb.la -lusb-1.0 -lusb-1.0
libtool: link: gcc -I../lib -g -O2 -I/usr/include/libusb-1.0 -o .libs/smbusb_bootstrap smbusb_bootstrap.o ../lib/.libs/libsmbusb.so -lusb-1.0
/bin/bash ../libtool --tag=CC --mode=link gcc -I../lib -g -O2 -I/usr/include/libusb-1.0 -o smbusb_sbsreport smbusb_sbsreport.o ../lib/libsmbusb.la -lusb-1.0 -lusb-1.0
libtool: link: gcc -I../lib -g -O2 -I/usr/include/libusb-1.0 -o .libs/smbusb_sbsreport smbusb_sbsreport.o ../lib/.libs/libsmbusb.so -lusb-1.0
/bin/bash ../libtool --tag=CC --mode=link gcc -I../lib -g -O2 -I/usr/include/libusb-1.0 -o smbusb_bq8030flasher smbusb_bq8030flasher.o ../lib/libsmbusb.la -lusb-1.0 -lusb-1.0
libtool: link: gcc -I../lib -g -O2 -I/usr/include/libusb-1.0 -o .libs/smbusb_bq8030flasher smbusb_bq8030flasher.o ../lib/.libs/libsmbusb.so -lusb-1.0
/bin/bash ../libtool --tag=CC --mode=link gcc -I../lib -g -O2 -I/usr/include/libusb-1.0 -o smbusb_r2j240flasher smbusb_r2j240flasher.o ../lib/libsmbusb.la -lusb-1.0 -lusb-1.0
libtool: link: gcc -I../lib -g -O2 -I/usr/include/libusb-1.0 -o .libs/smbusb_r2j240flasher smbusb_r2j240flasher.o ../lib/.libs/libsmbusb.so -lusb-1.0
/bin/bash ../libtool --tag=CC --mode=link gcc -I../lib -g -O2 -I/usr/include/libusb-1.0 -o smbusb_m37512flasher smbusb_m37512flasher.o ../lib/libsmbusb.la -lusb-1.0 -lusb-1.0
libtool: link: gcc -I../lib -g -O2 -I/usr/include/libusb-1.0 -o .libs/smbusb_m37512flasher smbusb_m37512flasher.o ../lib/.libs/libsmbusb.so -lusb-1.0
/bin/bash ../libtool --tag=CC --mode=link gcc -I../lib -g -O2 -I/usr/include/libusb-1.0 -o smbusb_scan smbusb_scan.o ../lib/libsmbusb.la -lusb-1.0 -lusb-1.0
libtool: link: gcc -I../lib -g -O2 -I/usr/include/libusb-1.0 -o .libs/smbusb_scan smbusb_scan.o ../lib/.libs/libsmbusb.so -lusb-1.0
/bin/bash ../libtool --tag=CC --mode=link gcc -I../lib -g -O2 -I/usr/include/libusb-1.0 -o smbusb_comm smbusb_comm.o ../lib/libsmbusb.la -lusb-1.0 -lusb-1.0
libtool: link: gcc -I../lib -g -O2 -I/usr/include/libusb-1.0 -o .libs/smbusb_comm smbusb_comm.o ../lib/.libs/libsmbusb.so -lusb-1.0
make[2]: Entering directory '/home/jacob/Downloads/smbusb-master/tools'
/bin/mkdir -p '/usr/local/bin'
/bin/bash ../libtool --mode=install /usr/bin/install -c smbusb_bootstrap smbusb_sbsreport smbusb_bq8030flasher smbusb_r2j240flasher smbusb_m37512flasher smbusb_scan smbusb_comm '/usr/local/bin'
libtool: install: /usr/bin/install -c .libs/smbusb_bootstrap /usr/local/bin/smbusb_bootstrap
libtool: install: /usr/bin/install -c .libs/smbusb_sbsreport /usr/local/bin/smbusb_sbsreport
libtool: install: /usr/bin/install -c .libs/smbusb_bq8030flasher /usr/local/bin/smbusb_bq8030flasher
libtool: install: /usr/bin/install -c .libs/smbusb_r2j240flasher /usr/local/bin/smbusb_r2j240flasher
libtool: install: /usr/bin/install -c .libs/smbusb_m37512flasher /usr/local/bin/smbusb_m37512flasher
libtool: install: /usr/bin/install -c .libs/smbusb_scan /usr/local/bin/smbusb_scan
libtool: install: /usr/bin/install -c .libs/smbusb_comm /usr/local/bin/smbusb_comm

make[2]:` Nothing to be done for 'install-data-am'.
make[2]: Leaving directory '/home/jacob/Downloads/smbusb-master/tools'
make[1]: Leaving directory '/home/jacob/Downloads/smbusb-master/tools'
make[1]: Entering directory '/home/jacob/Downloads/smbusb-master'
make[2]: Entering directory '/home/jacob/Downloads/smbusb-master'
make[2]: Nothing to be done for 'install-exec-am'.
make[2]: Nothing to be done for 'install-data-am'.
make[2]: Leaving directory '/home/jacob/Downloads/smbusb-master'
make[1]: Leaving directory '/home/jacob/Downloads/smbusb-master'

And then I'm trying to run smbusb_scan -a and getting:

`------------------------------------
smbusb_scan

Error: Unable to open device. (insufficient permissions? connection issue?)`

My device is connected though, do you know what might be the problem?

armv7l/gcc - Build failed

SDCC : mcs51 2.9.0 #5416 (Jul 3 2016) (UNIX)
Adding --std-sdcc99 options to sdcc, same errors.

Making all in firmware
make[1]: Entering directory '/opt/SMBUS/smbusb/firmware'
Makefile:17: warning: overriding recipe for target 'clean'
../fx2lib/lib/fx2.mk:100: warning: ignoring old recipe for target 'clean'
mkdir -p build
make -C ../fx2lib/lib
make[2]: Entering directory '/opt/SMBUS/smbusb/fx2lib/lib'
sdcc -mmcs51  -I../include -c serial.c -o serial.rel
sdcc -mmcs51  -I../include -c i2c.c -o i2c.rel
sdcc -mmcs51  -I../include -c delay.c -o delay.rel
sdcc -mmcs51  -I../include -c setupdat.c -o setupdat.rel
sdcc -mmcs51  -I../include -c gpif.c -o gpif.rel
sdcc -mmcs51  -I../include -c eputils.c -o eputils.rel
sdcc -mmcs51  -I../include -c interrupts/spare_isr.c -o interrupts/spare_isr.rel
sdcc -mmcs51  -I../include -c interrupts/usbreset_isr.c -o interrupts/usbreset_isr.rel
sdcc -mmcs51  -I../include -c interrupts/ep4ff_isr.c -o interrupts/ep4ff_isr.rel
sdcc -mmcs51  -I../include -c interrupts/ep2ef_isr.c -o interrupts/ep2ef_isr.rel
sdcc -mmcs51  -I../include -c interrupts/ep0ping_isr.c -o interrupts/ep0ping_isr.rel
sdcc -mmcs51  -I../include -c interrupts/ep6ping_isr.c -o interrupts/ep6ping_isr.rel
sdcc -mmcs51  -I../include -c interrupts/ep4_isr.c -o interrupts/ep4_isr.rel
sdcc -mmcs51  -I../include -c interrupts/ep1ping_isr.c -o interrupts/ep1ping_isr.rel
sdcc -mmcs51  -I../include -c interrupts/ep1out_isr.c -o interrupts/ep1out_isr.rel
sdcc -mmcs51  -I../include -c interrupts/ep6ff_isr.c -o interrupts/ep6ff_isr.rel
sdcc -mmcs51  -I../include -c interrupts/errlimit_isr.c -o interrupts/errlimit_isr.rel
sdcc -mmcs51  -I../include -c interrupts/ep4isoerr_isr.c -o interrupts/ep4isoerr_isr.rel
sdcc -mmcs51  -I../include -c interrupts/gpifwf_isr.c -o interrupts/gpifwf_isr.rel
sdcc -mmcs51  -I../include -c interrupts/ep8_isr.c -o interrupts/ep8_isr.rel
sdcc -mmcs51  -I../include -c interrupts/ep6isoerr_isr.c -o interrupts/ep6isoerr_isr.rel
sdcc -mmcs51  -I../include -c interrupts/ep8ef_isr.c -o interrupts/ep8ef_isr.rel
sdcc -mmcs51  -I../include -c interrupts/suspend_isr.c -o interrupts/suspend_isr.rel
sdcc -mmcs51  -I../include -c interrupts/ep0out_isr.c -o interrupts/ep0out_isr.rel
sdcc -mmcs51  -I../include -c interrupts/ep8isoerr_isr.c -o interrupts/ep8isoerr_isr.rel
sdcc -mmcs51  -I../include -c interrupts/ep2ping_isr.c -o interrupts/ep2ping_isr.rel
sdcc -mmcs51  -I../include -c interrupts/ep4pf_isr.c -o interrupts/ep4pf_isr.rel
sdcc -mmcs51  -I../include -c interrupts/ep0in_isr.c -o interrupts/ep0in_isr.rel
sdcc -mmcs51  -I../include -c interrupts/ep2pf_isr.c -o interrupts/ep2pf_isr.rel
sdcc -mmcs51  -I../include -c interrupts/ep8ff_isr.c -o interrupts/ep8ff_isr.rel
sdcc -mmcs51  -I../include -c interrupts/gpifdone_isr.c -o interrupts/gpifdone_isr.rel
sdcc -mmcs51  -I../include -c interrupts/ep1in_isr.c -o interrupts/ep1in_isr.rel
sdcc -mmcs51  -I../include -c interrupts/ep8ping_isr.c -o interrupts/ep8ping_isr.rel
sdcc -mmcs51  -I../include -c interrupts/sof_isr.c -o interrupts/sof_isr.rel
sdcc -mmcs51  -I../include -c interrupts/ep0ack_isr.c -o interrupts/ep0ack_isr.rel
sdcc -mmcs51  -I../include -c interrupts/ep4ef_isr.c -o interrupts/ep4ef_isr.rel
sdcc -mmcs51  -I../include -c interrupts/sudav_isr.c -o interrupts/sudav_isr.rel
sdcc -mmcs51  -I../include -c interrupts/ep2ff_isr.c -o interrupts/ep2ff_isr.rel
sdcc -mmcs51  -I../include -c interrupts/sutok_isr.c -o interrupts/sutok_isr.rel
sdcc -mmcs51  -I../include -c interrupts/hispeed_isr.c -o interrupts/hispeed_isr.rel
sdcc -mmcs51  -I../include -c interrupts/ep2isoerr_isr.c -o interrupts/ep2isoerr_isr.rel
sdcc -mmcs51  -I../include -c interrupts/ep6ef_isr.c -o interrupts/ep6ef_isr.rel
sdcc -mmcs51  -I../include -c interrupts/ep2_isr.c -o interrupts/ep2_isr.rel
sdcc -mmcs51  -I../include -c interrupts/ibn_isr.c -o interrupts/ibn_isr.rel
sdcc -mmcs51  -I../include -c interrupts/ep8pf_isr.c -o interrupts/ep8pf_isr.rel
sdcc -mmcs51  -I../include -c interrupts/ep6_isr.c -o interrupts/ep6_isr.rel
sdcc -mmcs51  -I../include -c interrupts/ep6pf_isr.c -o interrupts/ep6pf_isr.rel
sdcc -mmcs51  -I../include -c interrupts/ep4ping_isr.c -o interrupts/ep4ping_isr.rel
sdas8051 -logs usbav.a51
sdcclib fx2.lib serial.rel i2c.rel delay.rel setupdat.rel gpif.rel eputils.rel interrupts/spare_isr.rel interrupts/usbreset_isr.rel interrupts/ep4ff_isr.rel interrupts/ep2ef_isr.rel interrupts/ep0ping_isr.rel interrupts/ep6ping_isr.rel interrupts/ep4_isr.rel interrupts/ep1ping_isr.rel interrupts/ep1out_isr.rel interrupts/ep6ff_isr.rel interrupts/errlimit_isr.rel interrupts/ep4isoerr_isr.rel interrupts/gpifwf_isr.rel interrupts/ep8_isr.rel interrupts/ep6isoerr_isr.rel interrupts/ep8ef_isr.rel interrupts/suspend_isr.rel interrupts/ep0out_isr.rel interrupts/ep8isoerr_isr.rel interrupts/ep2ping_isr.rel interrupts/ep4pf_isr.rel interrupts/ep0in_isr.rel interrupts/ep2pf_isr.rel interrupts/ep8ff_isr.rel interrupts/gpifdone_isr.rel interrupts/ep1in_isr.rel interrupts/ep8ping_isr.rel interrupts/sof_isr.rel interrupts/ep0ack_isr.rel interrupts/ep4ef_isr.rel interrupts/sudav_isr.rel interrupts/ep2ff_isr.rel interrupts/sutok_isr.rel interrupts/hispeed_isr.rel interrupts/ep2isoerr_isr.rel interrupts/ep6ef_isr.rel interrupts/ep2_isr.rel interrupts/ibn_isr.rel interrupts/ep8pf_isr.rel interrupts/ep6_isr.rel interrupts/ep6pf_isr.rel interrupts/ep4ping_isr.rel usbav.rel
make[2]: Leaving directory '/opt/SMBUS/smbusb/fx2lib/lib'
for a in dscr.a51; do \
 cp $a build/; \
 cd build && sdas8051 -logs `basename $a` && cd ..; done
for s in smbusb_firmware.c; do \
 THISREL=$(basename `echo "$s" | sed -e 's/\.c$/\.rel/'`); \
 sdcc -mmcs51  --code-size 0x1c00 --xram-size 0x0200 --xram-loc 0x1c00 -Wl"-b DSCR_AREA=0x1e00" -Wl"-b INT2JT=0x1f00" -c -I ../fx2lib/include -I "" $s -o build/$THISREL ; done

smbusb_firmware.c:70: syntax error: token -> '=' ; column 10

smbusb_firmware.c:74: syntax error: token -> '&' ; column 20
smbusb_firmware.c:82: error 159: in function pec_crc: name omitted for parameter 2
smbusb_firmware.c:72: warning 85: in function pec_crc unreferenced function argument : 'crc'
smbusb_firmware.c:72: warning 85: in function pec_crc unreferenced function argument : '_pec_crc_PARM_2'
../fx2lib/lib/fx2.mk:82: recipe for target 'build/smbusb_firmware.ihx' failed
make[1]: *** [build/smbusb_firmware.ihx] Error 1
make[1]: Leaving directory '/opt/SMBUS/smbusb/firmware'
Makefile:386: recipe for target 'all-recursive' failed
make: *** [all-recursive] Error 1

Followings with --stack-auto , --std-c99, but still failed to build.

 sdcc --stack-auto --std-c99 -mmcs51  --code-size 0x1c00 --xram-size 0x0200 --xram-loc 0x1c00 -Wl"-b DSCR_AREA=0x1e00" -Wl"-b INT2JT=0x1f00" -c -I ../fx2lib/include -I "" $s -o build/$THISREL ; done
smbusb_firmware.c:851: warning 85: in function handle_get_interface unreferenced function argument : 'ifc'
smbusb_firmware.c:860: warning 85: in function handle_set_interface unreferenced function argument : 'ifc'
smbusb_firmware.c:860: warning 85: in function handle_set_interface unreferenced function argument : 'alt_ifc'
sdcc --stack-auto --std-c99 -mmcs51  --code-size 0x1c00 --xram-size 0x0200 --xram-loc 0x1c00 -Wl"-b DSCR_AREA=0x1e00" -Wl"-b INT2JT=0x1f00" -o build/smbusb_firmware.ihx build/smbusb_firmware.rel build/dscr.rel fx2.lib -L ../fx2lib/lib

?ASlink-Warning-Undefined Global '__divulong_PARM_2' referenced by module 'serial'

?ASlink-Warning-Undefined Global '_handle_get_interface_PARM_2' referenced by module 'setupdat'

?ASlink-Warning-Undefined Global '__mullong_PARM_2' referenced by module 'serial'

?ASlink-Warning-Undefined Global '_handle_set_interface_PARM_2' referenced by module 'setupdat'

?ASlink-Error-Insufficient ROM/EPROM/FLASH memory.
../fx2lib/lib/fx2.mk:82: recipe for target 'build/smbusb_firmware.ihx' failed
make[1]: *** [build/smbusb_firmware.ihx] Error 1
make[1]: Leaving directory '/opt/SMBUS/smbusb/firmware'
Makefile:386: recipe for target 'all-recursive' failed
make: *** [all-recursive] Error 1

TODO: Support for newer sdcc versions

Looks like updating the fx2lib submodule lets the firmware build with the latest sdcc but would break compatibility with older versions which I assume a lot of people still have.

Quick fix if the firmware doesn't build with your SDCC (probably versions 3.8 and up):

cd fx2lib
git checkout master

Can't compile from sources

Hi.
I just tried to clone an follow instructions.
After:

./init.sh
./configure (options: --disable-firmware, --disable-tools)
make
make install

I tried to run:
smbusb_scan -a
and I got this error:

smbusb_scan: error while loading shared libraries: libsmbusb.so.1: cannot open shared object file: No such file or directory

Firmware seems unstable, help?

This project seems really useful. I am trying to use it to communicate with a smart battery / charger combination

https://www.rrc-ps.com/en/battery-packs/standard-battery-packs/products/rrc2054/
https://www.rrc-ps.com/en/power-management/power-management-modules/products/rrc-pmm240/

When I run watch -n 1 smbusb_sbsreport, it usually works a few times, but then starts failing consistently with all error values, like below

Manufacturer Name:          ERROR                                                                                                                                                                                   
Device Name:                ERROR                                                                                                                                                                                   
Device Chemistry:           ERROR                                                                                                                                                                                   
Serial Number:              4294967289                                                                                                                                                                              
Manufacture Date:           8390587.15.25                                                                                                                                                                           
                                                                                                                                                                                                                    
Battery Mode:               fffffff9                                                                                                                                                                                
At Rate Time To Empty:      4294967289 min                                                                                                                                                                          
At Rate OK:                 4294967289
Temperature:                -273.85 C
Voltage:                    4294967289 mV
Current:                    -9 mA
Average Current:            -7 mA
Max Error:                  4294967289 %
Relative State Of Charge    4294967289 %
Absolute State Of Charge    4294967289 %
Remaining Capacity:         4294967289 mAh(/10mWh)
Full Charge Capacity:       4294967289 mAh(/10mWh)
Run Time To Empty:          4294967289 min
Average Time To Empty:      4294967287 min
Average Time To Full:       4294967289 min
Charging Current:           4294967289 mA
Charging Voltage:           4294967289 mV
Battery Status:             0xfffffff9
Cycle Count:                4294967289

When I power cycle the FX2LP, then I start getting real values again. I unfortunately don't understand the code well enough to understand why this might be happening. Any ideas?

Python bindings compatible with 'smbus' module

There are two major smbus modules for Python, already:

But these are using Linux kernel i2c modules, so are not multi-platform, and I don't think there's a way to use them over USB.

I think it might be useful to create Python bindings for smbusb as well, preferably keeping the interface used by existing modules.

(Just wanted to start a discussion on that, feel free to comment.)

Arch Linux SDCC 3.6.0-4 build fail

Build is failing with Arch Linux because of the newer version of SDCC (3.6.0-4)

make
Making all in firmware
make[1]: Entering directory '/home/user/src/smbusb/firmware'
Makefile:17: warning: overriding recipe for target 'clean'
../fx2lib/lib/fx2.mk:100: warning: ignoring old recipe for target 'clean'
mkdir -p build
for a in dscr.a51; do \
 cp $a build/; \
 cd build && sdas8051 -logs `basename $a` && cd ..; done
for s in smbusb_firmware.c; do \
 THISREL=$(basename `echo "$s" | sed -e 's/\.c$/\.rel/'`); \
 sdcc -mmcs51  --code-size 0x3c00 --xram-size 0x0200 --xram-loc 0x3c00 -Wl"-b DSCR_AREA=0x3e00" -Wl"-b INT2JT=0x3f00" -c -I ../fx2lib/include -I "" $s -o build/$THISREL ; done
smbusb_firmware.c:851: warning 85: in function handle_get_interface unreferenced function argument : 'ifc'
smbusb_firmware.c:860: warning 85: in function handle_set_interface unreferenced function argument : 'ifc'
smbusb_firmware.c:860: warning 85: in function handle_set_interface unreferenced function argument : 'alt_ifc'
sdcc -mmcs51  --code-size 0x3c00 --xram-size 0x0200 --xram-loc 0x3c00 -Wl"-b DSCR_AREA=0x3e00" -Wl"-b INT2JT=0x3f00" -o build/smbusb_firmware.ihx build/smbusb_firmware.rel build/dscr.rel fx2.lib -L ../fx2lib/lib
make[1]: *** [../fx2lib/lib/fx2.mk:84: build/smbusb_firmware.ihx] Error 1
make[1]: Leaving directory '/home/user/src/smbusb/firmware'
make: *** [Makefile:385: all-recursive] Error 1

Failing command:

sdcc -mmcs51  --code-size 0x3c00 --xram-size 0x0200 --xram-loc 0x3c00 -Wl"-b DSCR_AREA=0x3e00" -Wl"-b INT2JT=0x3f00" -o build/smbusb_firmware.ihx build/smbusb_firmware.rel build/dscr.rel fx2.lib -L ../fx2lib/lib -V
+ /usr/bin/sdld -nf build/smbusb_firmware.lk
+ /usr/bin/sdld -nf build/smbusb_firmware.lk returned errorcode 139

If sdcc is downgraded to 3.6.0-3 smbusb builds successfully:

downgrade sdcc

Syntax error in configure script when building?

Hi. Sorry if I've done something dumb, but ./configure fails for me. I believe I've installed all the prerequisites, and I've run
aclocal
libtoolize
autoconf
automake --add-missing
./configure
...and configure fails with the following:
root@kali:/usr/local/share/smbusb# ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
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 whether gcc understands -c and -o together... yes
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking whether ln -s works... yes
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking how to print strings... printf
checking for a sed that does not truncate output... /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for fgrep... /bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking the maximum length of command line arguments... 1572864
checking how to convert x86_64-pc-linux-gnu file names to x86_64-pc-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-pc-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @file support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for a working dd... /bin/dd
checking how to truncate binary pipes... /bin/dd bs=4096 count=1
checking for mt... mt
checking if mt is a manifest tool... no
checking how to run the C preprocessor... gcc -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 dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
./configure: line 11931: syntax error near unexpected token 0.22' ./configure: line 11931: PKG_PROG_PKG_CONFIG(0.22)'

Thanks for any help.

adding support for /dev/i2c on linux?

First of all: thank you so much for all that useful information! :)

I was wondering if somebody has already adapted the tools to work with /dev/i2c on linux?
This is probably not a good idea, but messing with batteries is not a good idea in the first place i guess?

And apart from that, somewhere in a forum i saw a post suggesting that one could use a modified video cable to talk to i2c devices, and i was able to replicate some of the functionality of smbusb with i2c-tools and the vga port, including entering boot rom mode, checking the boot rom version (also 3.1 on my chip) and reading blocks with i2ctransfer.
But before i try to write and brick the chip i thought it would be a good moment to ask some dumb questions...
would it e.g. be possible to just edit/rewrite single blocks? (or actually 2 blocks if i understood that right?)
or in other words, is it necessary to dump, erase and rewrite everything?
the erase part is necessary as far as i understood?
I tried to understand the code of the flashing process without too much success so far.
if i get that right, a word write of 0x83DE to 0x12 would erase everything?
and then it does block writes?
and then, what does the
SMBSendByte(0x16,CMD_EXECUTE_FLASH);
do? is that just to exit the boot rom mode?
sorry for all the stupid questions...

Eeprom verification bypassed?

It looks like Eeprom verifying after writing to DF is bypassed.
Here in the code effective comparison length is Zero.

54 #define EEPROM_BLOCKSZ 0x20
...
58 #define EEPROM_RESERVED_BYTES 32

...
...
...

423 if (memcmp(block,block2,EEPROM_BLOCKSZ-EEPROM_RESERVED_BYTES) == 0) {
424 fprintf(stderr,".");
425 } else {
426 printf("Block verify fail. Block #%d\n",i);
427 exit(0);
428 }

Following correction to code should enable it.

...
416 for (i=0;i<EEPROM_BLOCK_COUNT - (EEPROM_RESERVED_BYTES/EEPROM_BLOCKSZ);i++) { ... }
...

423 if (memcmp(block,block2,EEPROM_BLOCKSZ) == 0) {
...
```C

If it's Ok will revert with pull request.

Test command write

case SMB_TEST_COMMAND_WRITE:
while (EP0CS&bmEPBUSY); // wait until ready
*EP0BUF = 0;
if (!i2c_start()) return FALSE;
if (!i2c_byteout(smb_addr)) goto tcwOver;
if (i2c_byteout(smb_cmd)) { (*EP0BUF)++; // Command ACK = command exists
} else {goto tcwOver;}
if (i2c_byteout(3)) { (*EP0BUF)++; // Data Byte #1 ACK = byte writable
} else {goto tcwOver;}
if (i2c_byteout(0)) { (*EP0BUF)++; // Data Byte #2 ACK = word writable
} else {goto tcwOver;}
if (!i2c_byteout(0)) {goto tcwOver;}
if (i2c_byteout(0)) { (*EP0BUF)++; // Data Byte #4 ACK = block writable
} else {goto tcwOver;}
if (i2c_byteout(0)) { (*EP0BUF)++; // Data Byte #5 ACK = >block writable
} else {goto tcwOver;}

Please, make me understand why first out byte is 0x03 ? I think, it should be 0x00 like others byte.

PLEASE RELEASE

Add precompiled files for cp2112. so i can directly use with my cp2112.

thanks

possible virus attack?

The Bitdefender Total Security denied the download of smbusb_2021-01_windows.zip with following message:
smbusb_2021-01_windows.zip tried to load a malicious resource detected as Trojan.Generic.31963029 and was blocked. Your device is safe.
Please can you check this?

Best Regards Michael

Error Opening SMBusb: libusb error -11

Hi
I am constantly getting following error :
Error Opening SMBusb: libusb error -11
both for smbusb_sbsreport and smbusb_scan

Device is enumerated as
Bus 001 Device 006: ID 04b4:8613 Cypress Semiconductor Corp. CY7C68013 EZ-USB FX2 USB 2.0 Development Kit

Any assistance is appreciated

Doesn't compile, failure in make

I have tried to compile, and fails. This is my output:

  • aclocal
  • libtoolize
libtoolize: Consider adding 'AC_CONFIG_MACRO_DIRS([m4])' to configure.ac,
libtoolize: and rerunning libtoolize and aclocal.
libtoolize: Consider adding '-I m4' to ACLOCAL_AMFLAGS in Makefile.am.
  • autoconf
  • automake --add-missing
  • ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
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 whether gcc understands -c and -o together... yes
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking whether ln -s works... yes
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking how to print strings... printf
checking for a sed that does not truncate output... /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for fgrep... /bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking the maximum length of command line arguments... 1572864
checking how to convert x86_64-pc-linux-gnu file names to x86_64-pc-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-pc-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for a working dd... /bin/dd
checking how to truncate binary pipes... /bin/dd bs=4096 count=1
checking for mt... mt
checking if mt is a manifest tool... no
checking how to run the C preprocessor... gcc -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 dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.22... yes
checking for libusb... yes
checking for libusb_init in -lusb-1.0... yes
checking for ANSI C header files... (cached) yes
checking for an ANSI C-conforming const... yes
checking for size_t... yes
checking for xxd... yes
checking for sdcc... yes
configure: -------------------------------
configure: Build: x86_64-pc-linux-gnu
configure: Host: x86_64-pc-linux-gnu
configure: Compiler: gcc
configure: Prefix: /usr/local
configure: -------------------------------
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating tools/Makefile
config.status: creating lib/Makefile
config.status: creating lib/libsmbusb.pc
config.status: creating Makefile
config.status: executing depfiles commands
config.status: executing libtool commands
  • make
Making all in firmware
make[1]: se entra en el directorio '/tmp/smbusb-1.0.1/firmware'
Makefile:17: atención: se anulan las instrucciones para el objetivo 'clean'
../fx2lib/lib/fx2.mk:100: atención: se ignoran las instrucciones viejas para el objetivo 'clean'
xxd -i build/smbusb_firmware.ihx firmware.h
cp firmware.h ../lib/firmware.h
make[1]: se sale del directorio '/tmp/smbusb-1.0.1/firmware'
Making all in lib
make[1]: se entra en el directorio '/tmp/smbusb-1.0.1/lib'
/bin/bash ../libtool  --tag=CC   --mode=compile gcc -DPACKAGE_NAME=\"libsmbusb\" -DPACKAGE_TARNAME=\"libsmbusb\" -DPACKAGE_VERSION=\"1.0.1\" -DPACKAGE_STRING=\"libsmbusb\ 1.0.1\" -DPACKAGE_BUGREPORT=\"[email protected]\" -DPACKAGE_URL=\"\" -DPACKAGE=\"libsmbusb\" -DVERSION=\"1.0.1\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DHAVE_LIBUSB_1_0=1 -DSTDC_HEADERS=1 -I.     -g -O2 -I/usr/include/libusb-1.0 -MT libsmbusb_la-smbusb.lo -MD -MP -MF .deps/libsmbusb_la-smbusb.Tpo -c -o libsmbusb_la-smbusb.lo `test -f 'smbusb.c' || echo './'`smbusb.c
libtool: compile:  gcc -DPACKAGE_NAME=\"libsmbusb\" -DPACKAGE_TARNAME=\"libsmbusb\" -DPACKAGE_VERSION=\"1.0.1\" "-DPACKAGE_STRING=\"libsmbusb 1.0.1\"" -DPACKAGE_BUGREPORT=\"[email protected]\" -DPACKAGE_URL=\"\" -DPACKAGE=\"libsmbusb\" -DVERSION=\"1.0.1\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DHAVE_LIBUSB_1_0=1 -DSTDC_HEADERS=1 -I. -g -O2 -I/usr/include/libusb-1.0 -MT libsmbusb_la-smbusb.lo -MD -MP -MF .deps/libsmbusb_la-smbusb.Tpo -c smbusb.c  -fPIC -DPIC -o .libs/libsmbusb_la-smbusb.o
libtool: compile:  gcc -DPACKAGE_NAME=\"libsmbusb\" -DPACKAGE_TARNAME=\"libsmbusb\" -DPACKAGE_VERSION=\"1.0.1\" "-DPACKAGE_STRING=\"libsmbusb 1.0.1\"" -DPACKAGE_BUGREPORT=\"[email protected]\" -DPACKAGE_URL=\"\" -DPACKAGE=\"libsmbusb\" -DVERSION=\"1.0.1\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DHAVE_LIBUSB_1_0=1 -DSTDC_HEADERS=1 -I. -g -O2 -I/usr/include/libusb-1.0 -MT libsmbusb_la-smbusb.lo -MD -MP -MF .deps/libsmbusb_la-smbusb.Tpo -c smbusb.c -o libsmbusb_la-smbusb.o >/dev/null 2>&1
mv -f .deps/libsmbusb_la-smbusb.Tpo .deps/libsmbusb_la-smbusb.Plo
/bin/bash ../libtool  --tag=CC   --mode=link gcc  -g -O2 -I/usr/include/libusb-1.0 -version-info 1:1:0  -o libsmbusb.la -rpath /usr/local/lib libsmbusb_la-smbusb.lo libsmbusb_la-fxloader.lo  -lusb-1.0  -lusb-1.0
libtool: link: rm -fr  .libs/libsmbusb.a .libs/libsmbusb.la .libs/libsmbusb.lai .libs/libsmbusb.so .libs/libsmbusb.so.1 .libs/libsmbusb.so.1.0.1
libtool: link: gcc -shared  -fPIC -DPIC  .libs/libsmbusb_la-smbusb.o .libs/libsmbusb_la-fxloader.o   -lusb-1.0  -g -O2   -Wl,-soname -Wl,libsmbusb.so.1 -o .libs/libsmbusb.so.1.0.1
libtool: link: (cd ".libs" && rm -f "libsmbusb.so.1" && ln -s "libsmbusb.so.1.0.1" "libsmbusb.so.1")
libtool: link: (cd ".libs" && rm -f "libsmbusb.so" && ln -s "libsmbusb.so.1.0.1" "libsmbusb.so")
libtool: link: ar cru .libs/libsmbusb.a  libsmbusb_la-smbusb.o libsmbusb_la-fxloader.o
ar: `u' modifier ignored since `D' is the default (see `U')
libtool: link: ranlib .libs/libsmbusb.a
libtool: link: ( cd ".libs" && rm -f "libsmbusb.la" && ln -s "../libsmbusb.la" "libsmbusb.la" )
cp ../firmware/firmware.h .
make[1]: se sale del directorio '/tmp/smbusb-1.0.1/lib'
Making all in tools
make[1]: se entra en el directorio '/tmp/smbusb-1.0.1/tools'
gcc -DPACKAGE_NAME=\"libsmbusb\" -DPACKAGE_TARNAME=\"libsmbusb\" -DPACKAGE_VERSION=\"1.0.1\" -DPACKAGE_STRING=\"libsmbusb\ 1.0.1\" -DPACKAGE_BUGREPORT=\"[email protected]\" -DPACKAGE_URL=\"\" -DPACKAGE=\"libsmbusb\" -DVERSION=\"1.0.1\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DHAVE_LIBUSB_1_0=1 -DSTDC_HEADERS=1 -I.     -g -O2 -I/usr/include/libusb-1.0 -MT smbusb_sbsreport.o -MD -MP -MF .deps/smbusb_sbsreport.Tpo -c -o smbusb_sbsreport.o smbusb_sbsreport.c
smbusb_sbsreport.c:31:23: fatal error: libsmbusb.h: No existe el archivo o el directorio
compilation terminated.
Makefile:458: fallo en las instrucciones para el objetivo 'smbusb_sbsreport.o'
make[1]: *** [smbusb_sbsreport.o] Error 1
make[1]: se sale del directorio '/tmp/smbusb-1.0.1/tools'
Makefile:386: fallo en las instrucciones para el objetivo 'all-recursive'
make: *** [all-recursive] Error 1

smbusb_sbsreport.c:31:23: fatal error: libsmbusb.h: No existe el archivo o el directorio No such file libsmbusb.h
Error in the path of the makefile?

Can't complete make command

Hi.
Little help please.

I was trying to compile the tarbal but I get the following error that some point:

$ make
Making all in firmware
make[1]: Entering directory '/home/psysc0rpi0n/Downloads/smbusb-1.0.1/firmware'
Makefile:6: ../fx2lib/lib/fx2.mk: No such file or directory
make[1]: *** No rule to make target '../fx2lib/lib/fx2.mk'.  Stop.
make[1]: Leaving directory '/home/psysc0rpi0n/Downloads/smbusb-1.0.1/firmware'
make: *** [Makefile:386: all-recursive] Error 1

What am I missing? I have pkg-config and libusb installed.

$ sudo apt install pkg-config
pkg-config is already the newest version (0.29-6).

$ sudo apt install libusb-1.0-0-dev
libusb-1.0-0-dev is already the newest version (2:1.0.22-2).

$ sudo apt install libusb-1.0-0
libusb-1.0-0 is already the newest version (2:1.0.22-2).

Add xxdi as an alternative to xxd

Hi, since the build depends on xxd, I searched which package provides it, finding dev-util/xxdi and app-editors/vim-core (on Gentoo). Since there is only one place where xxd is used, and it's invoked as "xxd -i", it would be useful to add xxdi as an alternative to xxd, since it's much smaller (xxdi is 8KiB, vim-core 14MiB).

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.