OpenWrt Forum Archive

Topic: i2c_tiny_usb ported to LittleWire/Digispark ATtiny85

The content of this topic has been archived on 6 May 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Till Harbaum's venerable i2c_tiny_usb hardware has had drivers in OpenWrt for years. His hardware uses a quartz crystal as a clock. A long time ago, V-USB gained a no-crystal mode for ATtiny85-like hardware; the code uses USB frame timing to calibrate the on-chip RC oscillator at reset.

The ATtiny85-with-USB-without-crystal is/was popular in the Arduino world as one of the the smallest and cheapest devices that can be used standalone. A version of it is available as the Adafruit Trinket.

I cut&paste Till Harbaum's i2c_tiny_usb device into the LittleWire firmware tree. It works reasonably well as a kernel I2C device, although it is slow. If you change the USB ID in my source code, it will be recognized and used by the Linux kernel driver without changes.

https://github.com/nopdotcom/i2c_tiny_u … ittle-Wire

For the final extreme of ATtiny85 software USB, see http://8pino.strikingly.com/

Hello,

So, can I use my digispark Atiny85 to act as a I2C-TinyUSB, and from there connect my I2C devices?

What USB device ID should I use in order to be recognized and used by the Linux Kernel Driver?

Thanks,
Jabss

Yes, you can use the Digispark as an i2c adapter. Remember to use external pullup resistors; the ATtiny85 has very weak internal pullups. I use 2.2kΩ, but 4.7kΩ is probably the correct value for the pair of resistors at an I2C speed of 100kHz.

For information on the USB IDs used by i2c-tiny-usb, see https://github.com/nopdotcom/i2c_tiny_u … fig.h#L157

I haven't been able to reach Till Harbaum about the USB ID permission issue. I don't think there will be any problem distributing firmware images recompiled with the i2c-tiny-usb IDs. If you build binaries, feel free to post a link to them.

Thanks for the quick reply.

Can I compile your code in arduino IDE, or do I have to do it in other way? If so, how?

Thanks!
Jabss

The code is designed to be compiled with avr-gcc and avr-libc. Debian/Ubuntu have packages named "gcc-avr" and "avr-libc". If you install those packages, typing "make hex" will produce a main.hex you can use the micronucleus command to flash.

You can either build the micronucleus command from scratch, or you can install the Digispark Arduino IDE. There's a bin directory in there with it. There's also a complete avr-gcc/avr-libc inside, but I don't know if you can just set your PATH to point to /Applications/DigisparkArduino.app/Contents/Resources/Java/hardware/tools/avr/bin and have "make hex" work. BTW, if you're on a Mac, "brew cask install crosspack-avr" will get you a decent AVR toolchain.

Hello,

Thanks for your help. I still haven't confirmed it works because I need to do some soldering. However, I have good indications:

[ 2773.553333] i2c i2c-11: connected i2c-tiny-usb device

So, how did I do it (from my linux box - I'm too techie for windows and too poor for Mac smile )?

Adding it here so it can help people in the future (and also myself):

First, cloned your git repository.

mkdir digispark
cd digispark/
git clone https://github.com/nopdotcom/i2c_tiny_usb-on-Little-Wire
cd i2c_tiny_usb-on-Little-Wire/

(I also uncommented the USB ID as per your help)

Then, installed "gcc-avr" and "avr-libc":

sudo apt-get install gcc-avr avr-libc

Then, compiled. It worked at first time!

user@server$ make hex
avr-objcopy -j .text -j .data -O ihex main.elf main.hex
avr-size -C --mcu=attiny85 main.elf
AVR Memory Usage
----------------
Device: attiny85

Program:    3126 bytes (38.2% Full)
(.text + .data + .bootloader)

Data:         66 bytes (12.9% Full)
(.data + .bss + .noinit)

The result is the "main.hex" file.

Then, I followed this digispark tutorial that teaches how to add digispark support t Arduino IDE.
(https://digistump.com/wiki/digispark/tu … connecting)
This installs micronucleus in so it can be used to upload to Digispark.
I had to search for it, in my case it was in "/home/user/.arduino15/packages/digistump/tools/micronucleus/2.0a4".

After finding it, it was just a matter of copping all the files to the same directory and run:

sudo ./micronucleus --run --dump-progress --type intel-hex main.hex

{status:"waiting",step:1,steps:6,progress:0.500000}
> Please plug in the device ... 
> Press CTRL+C to terminate the program.
> Device is found!
{status:"connecting",step:2,steps:6,progress:0.000000}
{status:"connecting",step:2,steps:6,progress:0.180000}
{status:"connecting",step:2,steps:6,progress:0.360000}
{status:"connecting",step:2,steps:6,progress:0.540000}
{status:"connecting",step:2,steps:6,progress:0.720000}
{status:"connecting",step:2,steps:6,progress:1.000000}
> Device has firmware version 1.6
> Available space for user applications: 6012 bytes
> Suggested sleep time between sending pages: 8ms
> Whole page count: 94  page size: 64
> Erase function sleep duration: 752ms
{status:"parsing",step:3,steps:6,progress:0.000000}
{status:"parsing",step:3,steps:6,progress:1.000000}
{status:"parsing",step:3,steps:6,progress:1.000000}
> Erasing the memory ...
{status:"erasing",step:4,steps:6,progress:0.000000}
{status:"erasing",step:4,steps:6,progress:0.010000}
{status:"erasing",step:4,steps:6,progress:0.020000}
{status:"erasing",step:4,steps:6,progress:0.030000}
{status:"erasing",step:4,steps:6,progress:0.040000}
{status:"erasing",step:4,steps:6,progress:0.050000}
{status:"erasing",step:4,steps:6,progress:0.060000}
{status:"erasing",step:4,steps:6,progress:0.070000}
{status:"erasing",step:4,steps:6,progress:0.080000}
{status:"erasing",step:4,steps:6,progress:0.090000}
{status:"erasing",step:4,steps:6,progress:0.100000}
{status:"erasing",step:4,steps:6,progress:0.110000}
{status:"erasing",step:4,steps:6,progress:0.120000}
{status:"erasing",step:4,steps:6,progress:0.130000}
{status:"erasing",step:4,steps:6,progress:0.140000}
{status:"erasing",step:4,steps:6,progress:0.150000}
{status:"erasing",step:4,steps:6,progress:0.160000}
{status:"erasing",step:4,steps:6,progress:0.170000}
{status:"erasing",step:4,steps:6,progress:0.180000}
{status:"erasing",step:4,steps:6,progress:0.190000}
{status:"erasing",step:4,steps:6,progress:0.200000}
{status:"erasing",step:4,steps:6,progress:0.210000}
{status:"erasing",step:4,steps:6,progress:0.220000}
{status:"erasing",step:4,steps:6,progress:0.230000}
{status:"erasing",step:4,steps:6,progress:0.240000}
{status:"erasing",step:4,steps:6,progress:0.250000}
{status:"erasing",step:4,steps:6,progress:0.260000}
{status:"erasing",step:4,steps:6,progress:0.270000}
{status:"erasing",step:4,steps:6,progress:0.280000}
{status:"erasing",step:4,steps:6,progress:0.290000}
{status:"erasing",step:4,steps:6,progress:0.300000}
{status:"erasing",step:4,steps:6,progress:0.310000}
{status:"erasing",step:4,steps:6,progress:0.320000}
{status:"erasing",step:4,steps:6,progress:0.330000}
{status:"erasing",step:4,steps:6,progress:0.340000}
{status:"erasing",step:4,steps:6,progress:0.350000}
{status:"erasing",step:4,steps:6,progress:0.360000}
{status:"erasing",step:4,steps:6,progress:0.370000}
{status:"erasing",step:4,steps:6,progress:0.380000}
{status:"erasing",step:4,steps:6,progress:0.390000}
{status:"erasing",step:4,steps:6,progress:0.400000}
{status:"erasing",step:4,steps:6,progress:0.410000}
{status:"erasing",step:4,steps:6,progress:0.420000}
{status:"erasing",step:4,steps:6,progress:0.430000}
{status:"erasing",step:4,steps:6,progress:0.440000}
{status:"erasing",step:4,steps:6,progress:0.450000}
{status:"erasing",step:4,steps:6,progress:0.460000}
{status:"erasing",step:4,steps:6,progress:0.470000}
{status:"erasing",step:4,steps:6,progress:0.480000}
{status:"erasing",step:4,steps:6,progress:0.490000}
{status:"erasing",step:4,steps:6,progress:0.500000}
{status:"erasing",step:4,steps:6,progress:0.510000}
{status:"erasing",step:4,steps:6,progress:0.520000}
{status:"erasing",step:4,steps:6,progress:0.530000}
{status:"erasing",step:4,steps:6,progress:0.540000}
{status:"erasing",step:4,steps:6,progress:0.550000}
{status:"erasing",step:4,steps:6,progress:0.560000}
{status:"erasing",step:4,steps:6,progress:0.570000}
{status:"erasing",step:4,steps:6,progress:0.580000}
{status:"erasing",step:4,steps:6,progress:0.590000}
{status:"erasing",step:4,steps:6,progress:0.600000}
{status:"erasing",step:4,steps:6,progress:0.610000}
{status:"erasing",step:4,steps:6,progress:0.620000}
{status:"erasing",step:4,steps:6,progress:0.630000}
{status:"erasing",step:4,steps:6,progress:0.640000}
{status:"erasing",step:4,steps:6,progress:0.650000}
{status:"erasing",step:4,steps:6,progress:0.660000}
{status:"erasing",step:4,steps:6,progress:0.670000}
{status:"erasing",step:4,steps:6,progress:0.680000}
{status:"erasing",step:4,steps:6,progress:0.690000}
{status:"erasing",step:4,steps:6,progress:0.700000}
{status:"erasing",step:4,steps:6,progress:0.710000}
{status:"erasing",step:4,steps:6,progress:0.720000}
{status:"erasing",step:4,steps:6,progress:0.730000}
{status:"erasing",step:4,steps:6,progress:0.740000}
{status:"erasing",step:4,steps:6,progress:0.750000}
{status:"erasing",step:4,steps:6,progress:0.760000}
{status:"erasing",step:4,steps:6,progress:0.770000}
{status:"erasing",step:4,steps:6,progress:0.780000}
{status:"erasing",step:4,steps:6,progress:0.790000}
{status:"erasing",step:4,steps:6,progress:0.800000}
{status:"erasing",step:4,steps:6,progress:0.810000}
{status:"erasing",step:4,steps:6,progress:0.820000}
{status:"erasing",step:4,steps:6,progress:0.830000}
{status:"erasing",step:4,steps:6,progress:0.839999}
{status:"erasing",step:4,steps:6,progress:0.849999}
{status:"erasing",step:4,steps:6,progress:0.859999}
{status:"erasing",step:4,steps:6,progress:0.869999}
{status:"erasing",step:4,steps:6,progress:0.879999}
{status:"erasing",step:4,steps:6,progress:0.889999}
{status:"erasing",step:4,steps:6,progress:0.899999}
{status:"erasing",step:4,steps:6,progress:0.909999}
{status:"erasing",step:4,steps:6,progress:0.919999}
{status:"erasing",step:4,steps:6,progress:0.929999}
{status:"erasing",step:4,steps:6,progress:0.939999}
{status:"erasing",step:4,steps:6,progress:0.949999}
{status:"erasing",step:4,steps:6,progress:0.959999}
{status:"erasing",step:4,steps:6,progress:0.969999}
{status:"erasing",step:4,steps:6,progress:0.979999}
{status:"erasing",step:4,steps:6,progress:0.989999}
{status:"erasing",step:4,steps:6,progress:0.999999}
{status:"erasing",step:4,steps:6,progress:1.000000}
> Starting to upload ...
{status:"writing",step:5,steps:6,progress:0.000000}
{status:"writing",step:5,steps:6,progress:0.010645}
{status:"writing",step:5,steps:6,progress:0.021291}
{status:"writing",step:5,steps:6,progress:0.031936}
{status:"writing",step:5,steps:6,progress:0.042582}
{status:"writing",step:5,steps:6,progress:0.053227}
{status:"writing",step:5,steps:6,progress:0.063872}
{status:"writing",step:5,steps:6,progress:0.074518}
{status:"writing",step:5,steps:6,progress:0.085163}
{status:"writing",step:5,steps:6,progress:0.095808}
{status:"writing",step:5,steps:6,progress:0.106454}
{status:"writing",step:5,steps:6,progress:0.117099}
{status:"writing",step:5,steps:6,progress:0.127745}
{status:"writing",step:5,steps:6,progress:0.138390}
{status:"writing",step:5,steps:6,progress:0.149035}
{status:"writing",step:5,steps:6,progress:0.159681}
{status:"writing",step:5,steps:6,progress:0.170326}
{status:"writing",step:5,steps:6,progress:0.180971}
{status:"writing",step:5,steps:6,progress:0.191617}
{status:"writing",step:5,steps:6,progress:0.202262}
{status:"writing",step:5,steps:6,progress:0.212908}
{status:"writing",step:5,steps:6,progress:0.223553}
{status:"writing",step:5,steps:6,progress:0.234198}
{status:"writing",step:5,steps:6,progress:0.244844}
{status:"writing",step:5,steps:6,progress:0.255489}
{status:"writing",step:5,steps:6,progress:0.266134}
{status:"writing",step:5,steps:6,progress:0.276780}
{status:"writing",step:5,steps:6,progress:0.287425}
{status:"writing",step:5,steps:6,progress:0.298071}
{status:"writing",step:5,steps:6,progress:0.308716}
{status:"writing",step:5,steps:6,progress:0.319361}
{status:"writing",step:5,steps:6,progress:0.330007}
{status:"writing",step:5,steps:6,progress:0.340652}
{status:"writing",step:5,steps:6,progress:0.351297}
{status:"writing",step:5,steps:6,progress:0.361943}
{status:"writing",step:5,steps:6,progress:0.372588}
{status:"writing",step:5,steps:6,progress:0.383234}
{status:"writing",step:5,steps:6,progress:0.393879}
{status:"writing",step:5,steps:6,progress:0.404524}
{status:"writing",step:5,steps:6,progress:0.415170}
{status:"writing",step:5,steps:6,progress:0.425815}
{status:"writing",step:5,steps:6,progress:0.436460}
{status:"writing",step:5,steps:6,progress:0.447106}
{status:"writing",step:5,steps:6,progress:0.457751}
{status:"writing",step:5,steps:6,progress:0.468397}
{status:"writing",step:5,steps:6,progress:0.479042}
{status:"writing",step:5,steps:6,progress:0.489687}
{status:"writing",step:5,steps:6,progress:0.500333}
{status:"writing",step:5,steps:6,progress:0.510978}
{status:"writing",step:5,steps:6,progress:0.521623}
{status:"writing",step:5,steps:6,progress:0.532269}
{status:"writing",step:5,steps:6,progress:0.542914}
{status:"writing",step:5,steps:6,progress:0.553560}
{status:"writing",step:5,steps:6,progress:0.564205}
{status:"writing",step:5,steps:6,progress:0.574850}
{status:"writing",step:5,steps:6,progress:0.585496}
{status:"writing",step:5,steps:6,progress:0.596141}
{status:"writing",step:5,steps:6,progress:0.606786}
{status:"writing",step:5,steps:6,progress:0.617432}
{status:"writing",step:5,steps:6,progress:0.628077}
{status:"writing",step:5,steps:6,progress:0.638723}
{status:"writing",step:5,steps:6,progress:0.649368}
{status:"writing",step:5,steps:6,progress:0.660013}
{status:"writing",step:5,steps:6,progress:0.670659}
{status:"writing",step:5,steps:6,progress:0.681304}
{status:"writing",step:5,steps:6,progress:0.691949}
{status:"writing",step:5,steps:6,progress:0.702595}
{status:"writing",step:5,steps:6,progress:0.713240}
{status:"writing",step:5,steps:6,progress:0.723886}
{status:"writing",step:5,steps:6,progress:0.734531}
{status:"writing",step:5,steps:6,progress:0.745176}
{status:"writing",step:5,steps:6,progress:0.755822}
{status:"writing",step:5,steps:6,progress:0.766467}
{status:"writing",step:5,steps:6,progress:0.777112}
{status:"writing",step:5,steps:6,progress:0.787758}
{status:"writing",step:5,steps:6,progress:0.798403}
{status:"writing",step:5,steps:6,progress:0.809049}
{status:"writing",step:5,steps:6,progress:0.819694}
{status:"writing",step:5,steps:6,progress:0.830339}
{status:"writing",step:5,steps:6,progress:0.840985}
{status:"writing",step:5,steps:6,progress:0.851630}
{status:"writing",step:5,steps:6,progress:0.862275}
{status:"writing",step:5,steps:6,progress:0.872921}
{status:"writing",step:5,steps:6,progress:0.883566}
{status:"writing",step:5,steps:6,progress:0.894212}
{status:"writing",step:5,steps:6,progress:0.904857}
{status:"writing",step:5,steps:6,progress:0.915502}
{status:"writing",step:5,steps:6,progress:0.926148}
{status:"writing",step:5,steps:6,progress:0.936793}
{status:"writing",step:5,steps:6,progress:0.947438}
{status:"writing",step:5,steps:6,progress:0.958084}
{status:"writing",step:5,steps:6,progress:0.968729}
{status:"writing",step:5,steps:6,progress:0.979375}
{status:"writing",step:5,steps:6,progress:0.990020}
{status:"writing",step:5,steps:6,progress:1.000000}
> Starting the user app ...
{status:"running",step:6,steps:6,progress:0.000000}
{status:"running",step:6,steps:6,progress:1.000000}
>> Micronucleus done. Thank you!

dmesg shows some good news:

[ 2773.526627] usb 8-1.2: new low-speed USB device number 74 using xhci_hcd
[ 2773.551509] usb 8-1.2: New USB device found, idVendor=0403, idProduct=c631
[ 2773.551522] usb 8-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 2773.551528] usb 8-1.2: Product: i2c-tiny-usb on littleWire
[ 2773.551534] usb 8-1.2: Manufacturer: nop.com
[ 2773.551538] usb 8-1.2: SerialNumber: 113
[ 2773.552738] i2c-tiny-usb 8-1.2:1.0: version 2.01 found at bus 008 address 074
[ 2773.553333] i2c i2c-11: connected i2c-tiny-usb device

Looks really promising! Thank you! I finally have some use for my digisparks. Bought them with this exact purpose in mind but only afterwards realised that it wasn't to work like that...

Thanks!
Jabss

By the way, have you ever though adding 1-W support to this? big_smile  a digispark with I2C and 1-Wire "mediation" via USB would be fenomenal!

Thank you for writing that up. I've put a copy on https://github.com/nopdotcom/i2c_tiny_u … ingOnLinux to help other people.

I do most of my work on Linux, but I need some closed-source Mac tools for a project. :-/

I hadn't thought about onewire in the same firmware. I would probably use regular LittleWire if I didn't have a need for kernel I2C compatibility.

I suppose I could create a virtual I2C->onewire adapter. Hmm, no promises. :-)

Hello,

Unfortunately I don't have good news. I'm not sure what the problem is (it may be related with my I2C-tools package), but I'm getting a segmentation fault everytime I scan the I2C BUS.

Some status:

lsusb

Bus 001 Device 010: ID 0403:c631 Future Technology Devices International, Ltd i2c-tiny-usb interface
Bus 001 Device 005: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port
Bus 001 Device 004: ID 0665:5161 Cypress Semiconductor USB to Serial
Bus 001 Device 003: ID 0951:16a5 Kingston Technology 
Bus 001 Device 008: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port
Bus 001 Device 007: ID 05e3:0606 Genesys Logic, Inc. USB 2.0 Hub / D-Link DUB-H4 USB 2.0 Hub
Bus 001 Device 006: ID 1a40:0101 Terminus Technology Inc. 4-Port HUB
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 1a40:0101 Terminus Technology Inc. 4-Port HUB
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

dmesg

[131172.690000] usb 1-1.4.1: new low-speed USB device number 10 using ehci-platform
[131172.810000] i2c-tiny-usb 1-1.4.1:1.0: version 2.01 found at bus 001 address 010
[131172.810000] i2c i2c-0: connected i2c-tiny-usb device 

i2cdetect -l

i2c-0    i2c           i2c-tiny-usb at bus 001 device 010    I2C adapter 

looking good.... Let's scan the bus...

i2cdetect 0

 WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will probe file /dev/i2c-0.
I will probe address range 0x03-0x77.
Continue? [Y/n] y
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- Segmentation fault

and dmesg:

[131403.720000] i2c i2c-0: failure writing data
[131403.730000] i2c i2c-0: failure writing data
[131403.730000] i2c i2c-0: failure writing data
[131403.740000] i2c i2c-0: failure writing data
[131403.740000] i2c i2c-0: failure writing data
[131403.750000] i2c i2c-0: failure writing data
[131403.750000] i2c i2c-0: failure writing data
[131403.760000] i2c i2c-0: failure writing data
[131403.760000] i2c i2c-0: failure writing data
[131403.770000] i2c i2c-0: failure writing data
[131403.770000] i2c i2c-0: failure writing data
[131403.780000] i2c i2c-0: failure writing data
[131403.780000] i2c i2c-0: failure writing data
[131403.790000] i2c i2c-0: failure writing data
[131403.790000] i2c i2c-0: failure writing data
[131403.800000] i2c i2c-0: failure writing data
[131403.800000] i2c i2c-0: failure writing data
[131403.810000] i2c i2c-0: failure writing data
[131403.820000] i2c i2c-0: failure writing data
[131403.820000] i2c i2c-0: failure writing data
[131403.830000] i2c i2c-0: failure writing data
[131403.830000] i2c i2c-0: failure writing data
[131403.840000] i2c i2c-0: failure writing data
[131403.840000] i2c i2c-0: failure writing data
[131403.850000] i2c i2c-0: failure writing data
[131403.850000] i2c i2c-0: failure writing data
[131403.860000] i2c i2c-0: failure writing data
[131403.860000] i2c i2c-0: failure writing data
[131403.870000] i2c i2c-0: failure writing data
[131403.870000] i2c i2c-0: failure writing data
[131403.880000] i2c i2c-0: failure writing data
[131403.880000] i2c i2c-0: failure writing data
[131403.890000] i2c i2c-0: failure writing data
[131403.890000] i2c i2c-0: failure writing data
[131403.900000] i2c i2c-0: failure writing data
[131403.910000] i2c i2c-0: failure writing data
[131403.910000] i2c i2c-0: failure writing data
[131403.920000] i2c i2c-0: failure writing data
[131403.920000] i2c i2c-0: failure writing data
[131403.930000] i2c i2c-0: failure writing data
[131403.930000] i2c i2c-0: failure writing data
[131403.940000] i2c i2c-0: failure writing data
[131403.940000] i2c i2c-0: failure writing data
[131403.950000] usb 1-1.4.1: USB disconnect, device number 10
[131403.970000] CPU 0 Unable to handle kernel paging request at virtual address 00000000, epc == 830da1cc, ra == 830da14c
[131403.980000] Oops[#1]:
[131403.980000] CPU: 0 PID: 17011 Comm: i2cdetect Not tainted 3.18.11 #1
[131403.980000] task: 82f16b98 ti: 82ff8000 task.ti: 82ff8000
[131403.980000] $ 0   : 00000000 00000001 00000007 00000000
[131403.980000] $ 4   : 00000000 01b9c4e2 00000000 0000002e
[131403.980000] $ 8   : 00000000 82ff9e68 00000000 00000057
[131403.980000] $12   : 7ffa9060 82712200 00000000 7ffa9080
[131403.980000] $16   : 00000000 82ff9dc8 8267ec08 8335e500
[131403.980000] $20   : 00000001 00000001 00000000 80000000
[131403.980000] $24   : 00000000 7707a7d0                  
[131403.980000] $28   : 82ff8000 82ff9cb8 000007d0 830da14c
[131403.980000] Hi    : 00000001
[131403.980000] Lo    : 00000000
[131403.980000] epc   : 830da1cc 0x830da1cc
[131403.980000]     Not tainted
[131403.980000] ra    : 830da14c 0x830da14c
[131403.980000] Status: 1100fc03    KERNEL EXL IE 
[131403.980000] Cause : 00800008
[131403.980000] BadVA : 00000000
[131403.980000] PrId  : 00019750 (MIPS 74Kc)
[131403.980000] Modules linked in: ath9k ath9k_common pppoe ppp_async iptable_nat ath9k_hw ath pppox ppp_generic pl2303 nf_nat_ipv4 nf_conntrack_ipv6 nf_conntrack_ipv4 mac80211 ipt_REJECT ipt_MASQUERADE cypress_m8 cfg80211 xt_time xt_tcpudp xt_state xt_nat xt_multiport xt_mark xt_mac xt_limit xt_id xt_conntrack xt_comment xt_TCPMSS xt_REDIRECT xt_LOG xt_CT usbserial ums_usbat ums_sddr55 ums_sddr09 ums_karma ums_jumpshot ums_isd200 ums_freecom ums_datafab ums_cypress ums_alauda slhc nf_reject_ipv4 nf_nat_masquerade_ipv4 nf_nat_ftp nf_nat nf_log_ipv4 nf_defrag_ipv6 nf_defrag_ipv4 nf_conntrack_rtcache nf_conntrack_ftp nf_conntrack iptable_raw iptable_mangle iptable_filter ip_tables crc_ccitt compat i2c_tiny_usb i2c_dev ledtrig_usbdev ip6t_REJECT nf_reject_ipv6 nf_log_ipv6 nf_log_common ip6table_raw ip6table_mangle ip6table_filter ip6_tables x_tables nfsv3 nfs tun lockd sunrpc grace cifs dns_resolver nls_utf8 ipv6 sha256_generic md5 md4 hmac ecb des_generic arc4 crypto_blkcipher usb_storage sd_mod scsi_mod ext4 jbd2 mbcache crc16 crypto_hash ohci_platform ohci_hcd ehci_platform ehci_hcd gpio_button_hotplug usbcore nls_base usb_common
[131403.980000] Process i2cdetect (pid: 17011, threadinfo=82ff8000, task=82f16b98, tls=770d7440)
[131403.980000] Stack : 80234564 8023452c 82fbc100 01b9c496 00000000 0000002d 82ff9d80 00000000
[131403.980000]       000007d0 00000021 8267ec08 00000000 80400000 00c80c7d 82ff9dc8 00000001
[131403.980000]       80380000 fffffff5 00000000 80225108 83888c4c 00000005 82fb19e0 800a490c
[131403.980000]       00000000 8267ec08 82ff9dc8 00000001 8267ec08 00000001 82ff9d80 00000000
[131403.980000]       00000000 802259fc 82600000 80060830 82f16b98 82f14eb8 00000000 82712200
[131403.980000]       ...
[131403.980000] Call Trace:
[131403.980000] [<830da1cc>] 0x830da1cc
[131403.980000] 
[131403.980000] 
[131403.980000] Code: 08c36892  24a5a4dc  8c840000 <8c850000> afa60010  afa70014  8e230008  00052a00  00b72825 
[131404.230000] ---[ end trace 5884ad8e1e6b4809 ]---

strange...  after this, the digispark stops responding and is not seen in lsusb anymore...

Could it be because my i2c-tools version is not native from CC? Since it wasn't available in the repositories, I installed it from the BB repository.

Package: i2c-tools
Version: 3.0.3-1
Depends: libc
Status: install user installed
Architecture: ar71xx
Installed-Time: 1436399942

But again, if it was, wouldn't return an error by the time I do the "i2c-tools -l" ?

By the way, I tried with two different Digisparks and the problem is the same.

Any idea?

Thanks,
Jabss

(Last edited by jabss on 13 Jul 2015, 12:18)

I think this is symptomatic of an I2C bus lockup. If a USB device fails to respond to commands within a given period of time, the device is declared to be disconnected. So if an I2C device holds the bus open, the Digispark will disconnect. This kind of thing can happen sometimes if the pull-up resistors are missing.

I think a USB disconnect in response to I2C faults is bad behavior of i2c-tinyusb, but it's what I think is happening.

Do you have a known-good I2C slave you can test with? Have you tried the LittleWire.rb code as an i2c client?

Hello,

Changing the pins for SDA and SCK made it work:

 $ sudo i2cdetect 0
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will probe file /dev/i2c-0.
I will probe address range 0x03-0x77.
Continue? [Y/n] y
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: 20 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         
 

Thanks!
Jabss

Hello,

I must say this is working great with I2C and that I couldn't be happier.
Have you considered the challenge of adding 1-Wire to it?
It would simply bring these tiny-USBs to another different level!

Cheers,
jabss

Can you please share digispark Atiny85 to i2c hex ... Thanks.

jabss wrote:

Have you considered the challenge of adding 1-Wire to it?

Yes, I worked on that a little, but the potential interrupt timing difficulties made my head hurt, and I obviously got distracted with other things. Sorry about that...

I had problems detecting the an tiny RTC (DS1307) via the tiny-usb-i2c/LitteWire. After some trials it worked when I changed the clock calibration settings in main.c:

removing the "0.5" from line:

int         x, optimumDev, targetValue = (unsigned)(1499 * (double)F_CPU / 10.5e6 + 0.5);

to:

int         x, optimumDev, targetValue = (unsigned)(1499 * (double)F_CPU / 10.5e6 );

Hope it helps someone else.

Thanks for all the great info!

@Dasaki,

Thank you for your post. For sure it may help the community to troubleshoot potential problems.

Myself I'm not knowledgeable enough to trobleshoot in the code, I would never be able to find that line and understand what to change. Once more, thanks!

Anyway and by the way, you look like an excellent canditate to take the challenge to add the 1-wire protocol to this atiny85 ? big_smile

Thanks,
Jabss

The discussion might have continued from here.