Skip to content

Updated software to latest versions. (August 2014) #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
libusb-win32-bin v1.2.1.0 (07/28/2010) - [Package Information]
libusb-win32-bin v1.2.6.0 (01/17/2012) - [Package Information]

ALL ARCHITECTURES:
x86\libusb0_x86.dll: x86 32-bit library. Must be renamed to libusb0.dll
On 64 bit, Installs to Windows\syswow64\libusb0.dll.
On 32 bit, Installs to Windows\system32\libusb0.dll.

x86\inf-wizard.exe: inf-wizard application with embedded libusb-win32
v1.2.1.0 binaries.
v1.2.6.0 binaries.

X86 ONLY ARCHITECTURES:
x86\libusb0.sys: x86 32-bit driver.
Expand Down
Binary file not shown.
Binary file not shown.
Binary file removed Drivers/Zadig/zadig_v2.0.1.160/zadig.exe
Binary file not shown.
Binary file added Drivers/Zadig/zadig_v2.1.0.658/zadig.exe
Binary file not shown.
89 changes: 89 additions & 0 deletions Firmware/pocket-prog/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,92 @@ o Fixed some build problems of the libusb python wrapper, and added

o Made the flash and SRAM sizes configurable in the Makefile.


2008-01-16 version 1.4

o Moved the assignment of a new USB device address to the interrupt
handler in order to avoid a race condition that sometimes occurred
when the PC was rebooted.

o Updated the schematics with zener diodes on the data lines, because
some PCs seem to have problems with 5V data signals.

o Changed the USB ids for the "spi" application to the VID/PID pair
of the USBtinyISP project (http://www.ladyada.net/make/usbtinyisp/),
because these ids are supported by avrdude since version 5.5.

o Avrdude-5.1 patch replaced by new patch for avrdude-5.4.

o New patch for lirc-0.8.2.

o New configuration macro USBTINY_FAST_CRC to switch between two
versions of the CRC algorithm: slow & small or fast & large.

o New make target "fuses" to program the low and high fuses.


2010-05-29 version 1.5

o Optimized the USB interrupt handler to make the code both faster
and smaller (22 bytes). The interrupt handler now also checks for
a pending transmission after an ignored packet and decodes it
directly without first returning from the interrupt handler.

o Improved the execution speed of both versions of the CRC function.
The "slow" version got 25% faster and 4 bytes smaller, while the
"fast" version got 50% faster but 8 bytes larger (suggested by
Reimar Döffinger).

o Added two new configuration macros:
USBTINY_DMINUS_PULLUP - control D- pullup resistor with an I/O pin.
USBTINY_USB_OK_LED - turn on a LED when the enumeration succeeded.

o Added new compiler and linker options to reduce the code size.

o Updated the timer input capture interrupt handler of the "ir"
application. The inline assembly code didn't work anymore with
newer gcc versions, because of changes in the register allocation.
The code now works for gcc-4.1.0 and gcc-4.3.4, but it is still
fragile.

o Other changes of the "ir" application:
- The maximum number of IR data bytes is now 36 instead of 35.
- The LED briefly flashes after USB enumeration.
- Added power filtering for the TSOP1738 device in the schematic.

o Added a new USBtiny application "usbtinyisp". This is a modified
version of the "spi" application, adapted for use in the USBtinyISP
AVR programmer (http://www.ladyada.net/make/usbtinyisp/). The code
works for both v1.0 and v2.0 devices.

o Added a new template USBtiny application in the "template" subdirectory.


2010-11-17 version 1.6

o Fix for avr-gcc version 4.3.5. Because of a new optimization that
suppresses part of the startup code when there are no initialized
variables in the C code, two variables in usbtiny/int.S were not
initialized anymore.

o Fixed incorrect initialization of "inpos" in ir/main.c. This bug
didn't affect the LIRC driver igorplugusb because it always uses
an offset of zero.


2014-05-02 version 1.7

o Changes for new avr-gcc and avr-libc versions:
- Use "const" for "PROGMEM" objects.
- Use new names for interrupt vectors.
- Use "inline" on "__attribute__((always_inline))" functions.

o Added a new configuration macro USBTINY_NO_DATA to control the use of
initialized data by USBtiny. When the data section is empty, the code
to initialize the data section will be omitted from the startup code.
(suggested by William Chops Westfield)

o Added support for transfers larger than 255 bytes through usb_in() by
defining USBTINY_CALLBACK_IN as 2 instead of 1. (suggested by Bernhard
Roth).

4 changes: 2 additions & 2 deletions Firmware/pocket-prog/Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# ======================================================================
# USBtiny global Makefile
#
# Copyright (C) 2006 Dick Streefland
# Copyright 2006-2010 Dick Streefland
#
# This is free software, licensed under the terms of the GNU General
# Public License as published by the Free Software Foundation.
# ======================================================================

DIR = spi ir util
DIR = spi ir usbtinyisp template util

all clean clobber:
@for i in $(DIR); do $(MAKE) $(MFLAGS) -C $$i $@; done
121 changes: 81 additions & 40 deletions Firmware/pocket-prog/README
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ the Atmel ATtiny microcontrollers. Of course, it will also work on the
ATmega series. The software is written for an AVR clocked at 12 MHz.
At this frequency, each bit on the USB bus takes 8 clock cycles, and
with a lot of trickery, it is possible to decode and encode the USB
waveforms by software. The USB driver needs between 1300 and 1400
waveforms by software. The USB driver needs approximately 1250 to 1350
bytes of flash space (excluding the optional identification strings),
depending on the configuration and compiler version, and 46 bytes RAM
(excluding stack space). The C interface consists of 3 to 5 functions,
Expand Down Expand Up @@ -50,37 +50,44 @@ configured at the top of the Makefile.
Other USB projects
==================

This software was inspired by two similar USB projects for the AVR:
This software was inspired by two similar USB projects for the AVR,
especially the second one:

http://www.cesko.host.sk/IgorPlugUSB/IgorPlug-USB%20(AVR)_eng.htm
http://www.obdev.at/products/avrusb/index.html

My version has the advantage that you have more freedom over which I/O
pins to use for the D+ and D- USB signals. You don't need to use bit 0
for the D+ signal. The only restriction is that both signals should be
on the same I/O port. When you select a pin for D+ that can also
generate an interrupt, only two I/O pins are required. The pin-change
interrupt is deliberately not used, so that it remains available for
other uses.

Another improvement is that the CRC calculation is faster, because it
uses a lookup table. A bit-wise calculation turned out to be too slow
for the USB controller in my laptop. For instance, the obdev code
worked fine on my desktop computer, but not on my laptop.
The IgorPlugUSB code and earlier versions of the obdev code had the
restriction that the D+ signal must be connected to bit 0 of an I/O
port, in addition to an interrupt input. That means that for devices
like the ATtiny2313, three I/O pins are required to control the USB bus.
One of the reasons I wrote USBtiny was to have more freedom over which
I/O pins to use for the D+ and D- USB signals. The only restriction
is that both signals should be on the same I/O port. When you select a
pin for D+ that can also generate an interrupt, only two I/O pins are
required. Later versions of the obdev code have also removed this
restriction. The pin-change interrupt is deliberately not used, so
that it remains available for other uses. Another improvement is an
optional faster CRC calculation that uses a lookup table to calculate
4 bits at a time.

Apart from these advantages, I think that my code is more readable and
easier to configure, but that impression may be caused by a mild form
of the NIH syndrome that I'm suffering from. In any case, I learned a
lot about the USB protocol, and writing the interrupt handler was a
nice puzzle.

The USBtinyISP project is an AVR in-circuit programmer based on USBtiny,
and is available as a kit:

http://www.ladyada.net/make/usbtinyisp/


Hardware
========

The AVR must be clocked with an external 12 MHz crystal. For an
ATtiny2313, this means that the low fuse byte must be reprogrammed,
for instance to 0xff. I also recommend to enable the BOD circuit,
for instance to 0xef. I also recommend to enable the BOD circuit,
when available. For the ATtiny2313, this means programming the high
fuse byte to 0xdb (BOD level is 2.7V).

Expand All @@ -91,8 +98,8 @@ which may be more convenient when you need to interface to 5V
peripherals. According to the USB specification, a device should not
be damaged by 5V signals. I've been running the AVR and USB bus at 5V,
and haven't encounter any problems so far, but I have some reports
of Viao laptops that do not work with 5V signals. In that case, you
can reduce the voltage of the USB data signals by adding 3V6 zener
of PCs and laptops that do not work with 5V signals. In that case,
you can reduce the voltage of the USB data signals by adding 3V6 zener
diodes from the data signals to ground.


Expand All @@ -106,14 +113,31 @@ port programmer. Because the most important parallel port signals are
connected to the DB-25 connecter, the same hardware (with different
firmware) could be used to control other parallel port devices. That
is also the reason why I connected the ACK signal to the INT1 pin.
I didn't bother to put capacitors on the crystal, but they are
recommended for reliable operation. The software, the schematic and
a Python test script can be found in the "spi" subdirectory.

The circuit may be powered via the diode at pin 14 of the DB-25
connector to enable reprograming the ATtiny2313 in-system. This
requires an adaptor cable between another SPI programmer and a DB-25
male connector with the following connections:
The software, the schematic and a Python test script can be found
in the "spi" subdirectory.

My AVR parallel port programmer follows the "bsd" design from Brian
Dean (http://www.bsdhome.com/avrdude/). For safety, I've used series
resistors in the output signals. The Atmel device is powered by the
data lines D1-D3, via 220 Ohm resistors. D0 is used to control a LED.
Here is an ASCII-art version of the schematic:

DB25 male ATtiny2313
--------- ----------
18 GND ----------------------+---- 10 GND
2 D0 ---- 330 ---- LED ----+
3 D1 ---- 220 ---+
4 D2 ---- 220 ---+-------------- 20 VCC
5 D3 ---- 220 ---+
7 D5 ---- 1K ------------------- 1 /RESET
8 D6 ---- 680 ------------------ 19 SCK
9 D7 ---- 1K ------------------- 17 MOSI
10 ACK --------------------------- 18 MISO

The USBtiny circuit may be powered via the diode at pin 14 of the
DB-25 connector to enable reprograming the ATtiny2313 in-system.
This requires an adaptor cable between another SPI programmer and
a DB-25 male connector with the following connections:

SPI DB25
--- ----
Expand All @@ -130,10 +154,11 @@ AVR. This means that you can send a 32-bit SPI command in a single USB
packet. In addition, you can read or write up to 255 bytes from/to
flash or EEPROM in a single control transfer.

The subdirectory "patches" contains a patch for avrdude-5.1 that adds
The subdirectory "patches" contains a patch for avrdude-5.4 that adds
support for controlling this SPI converter. The programmer name is
"usbtiny". You can use the -B option or the "sck" command to specify
the minimum SCK period in microseconds (range: 1..250, default: 10).
Native support for USBtiny was added in avrdude version 5.5.


USBtiny LIRC compatible IR receiver and LCD controller
Expand All @@ -153,13 +178,29 @@ setting the LCD_PRESENT macro in main.c to 0.

I adopted the "IgorPlug-USB" protocol, so that the existing LIRC
device driver "igorplugusb" could be used without modifications.
Nevertheless, a patch for lirc-0.8.0 is included in the "patches"
subdirectory, with the following modifications:
Nevertheless, patches for lirc-0.8.0 and lirc-0.8.2 are included
in the "patches" subdirectory, with the following modifications:
1) An increase of the sample rate from 10 to 100 times per second.
This is not required, but improves the responsiveness and repeat
behavior for some remote controls.
2) A fix from Reinhard Max to get correct gap timings.
3) A compilation fix for the latest 2.6 Linux kernels.
3) A compilation fix for the latest 2.6 Linux kernels (lirc-0.8.0).


USB AVR programmer and SPI interface
====================================

The subdirectory "usbtinyisp" contains a modified version of the "spi"
application, that was adapted for use in the USBtinyISP AVR programmer
(http://www.ladyada.net/make/usbtinyisp/). The code works for both v1.0
and v2.0 devices.


Template USBtiny application
============================

The directory "template" contains a minimal template application that
can be used as a starting point for new USBtiny applications.


Tools
Expand All @@ -179,14 +220,15 @@ programmer.

I initially used gcc-3.4.3 with the -Os option, which generates
reasonable compact code. Unfortunately, newer versions like gcc-4.1.0
generate about 10% more code, and as a result, the application code
generated about 10% more code, and as a result, the application code
did not fit in 2K anymore. To make it fit, I had to remove the optional
vendor and device strings, by undefining the USBTINY_VENDOR_NAME and
USBTINY_DEVICE_NAME macros.
USBTINY_DEVICE_NAME macros. Fortunately, code generation has improved
in later versions such as gcc-4.3.4.

The schematics were created with gschem, which is part of the gEDA
package. The conversion to Postscript is done with a script that
invokes gschem non-interactively.
The schematics were created with gschem, from the geda-gschem package.
The conversion to Postscript is done with a script that invokes gschem
non-interactively.

The "util" and application code subdirectories each contain their own
Makefile. In addition, there is a global Makefile that recursively
Expand All @@ -201,18 +243,17 @@ defines a class USBtiny that can be used to communicate with the
USBtiny firmware. This class is used by the test scripts.

The usbtiny.py module uses a Python wrapper around libusb that is
generated by "swig". Type "make" to build the wrapper. Of course, you
need to have swig, libusb and libusb-dev installed on your system.
generated by "swig". Type "make" to build the wrapper. You need to
have swig, libusb, libusb-dev and python-dev installed on your system.

Libusb needs appropriate permissions to open a USB device. This means
that you either have to run the scripts as "root", or you should
configure the hotplug or udev system to relax the permissions of the
device file created under /proc/bus/usb/ when the device is plugged
in. With udev, you can change the permissions by adding a rule like

SUBSYSTEM=="usb_device", MODE="0666"
in. For instance, you can create a file 99-usbtiny.rules with the
following content in /etc/udev/rules.d/:

to the udev rules in /etc/udev/rules.d/
SUBSYSTEM=="usb",ATTR{idVendor}=="1781",ATTR{idProduct}=="0c9f",GROUP="plugdev"


License
Expand Down
5 changes: 3 additions & 2 deletions Firmware/pocket-prog/ir/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ======================================================================
# Makefile for USB IR receiver
#
# Copyright (C) 2006 Dick Streefland
# Copyright 2006-2010 Dick Streefland
#
# This is free software, licensed under the terms of the GNU General
# Public License as published by the Free Software Foundation.
Expand All @@ -11,7 +11,8 @@ USBTINY = ../usbtiny
TARGET_ARCH = -mmcu=attiny2313
OBJECTS = main.o
FLASH_CMD = avrdude -pt2313 -U flash:w:main.hex
STACK = 39
FUSES_CMD = avrdude -pt2313 -U hfuse:w:0xdb:m -U lfuse:w:0xef:m
STACK = 38
FLASH = 2048
SRAM = 128
SCHEM = ir.ps
Expand Down
Binary file removed Firmware/pocket-prog/ir/crc.o
Binary file not shown.
Binary file removed Firmware/pocket-prog/ir/int.o
Binary file not shown.
Binary file modified Firmware/pocket-prog/ir/ir.ps
Binary file not shown.
2 changes: 2 additions & 0 deletions Firmware/pocket-prog/ir/ir.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/python
# ======================================================================
# ir.py - USBtiny/ir test program
#
# Copyright 2006-2008 Dick Streefland
# ======================================================================

import sys, os.path
Expand Down
Loading