Linux Kernel Device Drivers for AVR V-USB Devices

V-USB is a really convenient library to implement USB communication between an AVR microcontroller and any USB host enabled system.

The host side software for a V-USB device is usually handled either from a class driver, such as for HID-compliant devices, or from an userspace libusb-based application.

This post shows how to implement a Linux kernel device driver for a simple ep0-based V-USB device.

https://fabiobaltieri.files.wordpress.com/2012/05/vusb-kernel-intro.jpg
Read more of this post

Advertisement

2.4 GHz Inverted F Antenna Eagle Library

ISM radios for microcontroller are becoming quite popular in last years, and if you are designing with wireless radios you have a wide choice of transceiver in both sub-gigahertz an 2.4 GHz bandwidth.

If you choose to go for 2.4 GHz, you’ll have the benefits of a wide choice of radios, relaxed constraints in protocol design and a small size antenna.

Focusing on the antenna, 2.4 GHz radios usually have a differential output which have to be adapted to a 50 Ohm single-ended signal suitable for Wi-Fi antennas, which can be connected to the radio using an RP-SMA connector or directly embedded into the PCB.

This post shows a printed antenna design, kindly provided by TI/Chipcon, suitable for 2.4 GHz ISM radios. You’ll also find a link for an Eagle library with some tuning variant.

https://fabiobaltieri.files.wordpress.com/2012/05/ifa.jpg Read more of this post

AVR Watch

Following the trend of doing things just-for-fun, this is a wrist watch using an AVR microcontroller and 7-segment display!

Features:

  • Open firmware and hardware design files
  • AVR and V-USB based
  • Uses SMD 7-segment display – retro look!
  • Integrated USB Maxim battery charger
  • Shows how to scan-drive 7-segment displays without external components

Drawbacks:

  • Short battery life (less than one week with a 100mAh LiPo battery)
  • Tricky to hand solder (if you don’t have an hot air station)
  • Makes people thinks you are crazy (I should put this one on “features”…)
  • Looks like a small time-bomb, I would not wear it while in an airport

https://fabiobaltieri.files.wordpress.com/2012/04/avr-watch-wrist.jpg

As most of my design, I made this one because I had some 7-segment display laying around and I wanted to build something with those (that’s also why I don’t have a project BOM). Also, I like the idea of having a DIY watch which looks like a lab power supply (it also displays battery level in Volts).

Read more of this post

LED Lighting on a Budget

LED based lighting is slowly entering the market of home lights side-to-side with traditional incandescent bulbs (which are phasing out in many countries) and more recent gas-discharge lights.

One of the best known advantage of LED lights is their power efficiency, which can be quite high when compared with traditional lights, but if you like to do a DIY light system for your house the most interesting aspect of LED is that you can dispose the single diodes in many ways to get the desired light effect.

LEDs can be obtained in many ways, and if you have some broken LED laptop display to tear down, then you can recycle that LEDs to do some ambient lighting in small environment.

https://fabiobaltieri.files.wordpress.com/2012/02/led_kitchen.jpg
https://fabiobaltieri.files.wordpress.com/2012/02/led_spot_far1.jpg

Here I’ll show a couple of example of how to use LED lights from broken laptop display, explaining how to drive the LED with series resistor or DC/DC converters.

Read more of this post

UART Bitrate Converter for GPS on Nikon Cameras

Modern Nikon DSLR cameras supports the connection of a GPS on the remote shutter port to include automatic geotagging of the shoots.

The camera uses a small proprietary double-sided connector to receive the position data form a remote GPS unit. The protocol used is the standard NMEA 0183.

Nikon official GPS unit is quite expensive, and I had an old Bluetooth GPS unit which I’m not using anymore but had the NMEA output at the wrong bitrate, as the camera only accept NMEA data at 4800bps, while the GPS works at 38400bps.

This project, made for my good friend and photographer David (checkout his blog!), is a small firmware for an ATMega168 to read the data from an high speed UART port, and reply that on a slower port, using a circular buffer for the data.

Read more of this post

Network Statistics with iptables and rrdtool

Netfilter is a powerful tool when it comes to select traffic on a Linux router.

When you set up a chain of rules with iptables, you are also get set of traffic counters with each rule you set, which can be used to see how many times the rule have matched.

If you place a chain of rules without any jump, the packet get counted and goes forward the chain, so that you can write a set of rules just to get some statistic of selected pattern of traffic in your network.

In this post I’ll show how to write some simple rule, get the data on a rrdtool database and plot a traffic graphic out of it.

Read more of this post

USB Sensors with ATtiny Microcontrollers

Working with embedded electronics, you will eventually ends up with some sensor between your hands, here I’ll show how to make a graph out of it!

This project involves a light sensor, a tiny 8-pin AVR USB key with the V-USB stack, a GNU/Linux system and rrdtool.


Read more of this post

Network Activity LED with Linux LED Subsystem

This is a nice userspace application I use on my router to control the Internet connection status LED in “smart” way.

The idea is simple, instead of just randomly blink the LED when there is some activity on the network, this application checks for the total bytes transferred on the network interface, and blinks the LED every 100KB of data.

That behavior is borrowed from modern electric counter, which have a LED that blinks every predefined number of Watt/hour.

That’s useful because you can quickly have an idea of the bandwidth utilization of your connection by just checking how often the LED blinks, so you can instantly identify a low-bandwidth constant traffic by a high-bandwidth traffic.

Read more of this post

FTDI based USB to UART/485 Interface

If you work with embedded electronics, UART ports is something you’ll probably use every day to interface with all your SoCs and microcontrollers. As modern PCs and laptops almost always lacks legacy serial ports, you need a good USB to UART interface for all your serial needs.

USB to RS232 interfaces are easily founds online and in computer stores, but if you need RS485 and TTL UART ports you may have some problem finding the right tool.

This projects is a compact USB to TTL UART or RS485 converter, based on the popular FTDI FT232 chip. It features 3.3V TTL UART operation and an 8P8C connector (sometimes referred as RJ-45) with on board termination and bus power injection options for 485 port.

Read more of this post

IPv6 Stateful Firewall with netfilter/ip6tables

IPv6 is coming!

Ok, that was just a provocation. If you have some interest in networking technologies you’ll know for sure that stable IPv6 implementation are around for many years now but very few providers give the user IPv6 connectivity. You can follow the IPv6 deployment status around the world on this Wikipedia page.

Anyway, for those of you who are lucky enough to have a real IPv6 connection, it’s time to add the “6” to some network utility, and that includes ip6tables!

This script is a stateful firewall for an IPv6 standalone and router installation, which provides the same level of security given by an IPv4 NAT router.

Read more of this post

Hexadecimal to Bit Display Utility

This is a very simple command-line utility to display 32bit hexadecimal numbers to a friendly bit-to-bit visualization, with a nice indication of bit offsets.

I found this really useful when decoding dumps of 32 bit registers against the register descriptions found in datasheets at 2 AM in the morning after a day spent watching boot logs on a terminal… this things can happen!

This is an example of the application call and output:

$ ./hex2bit deadbeef cafecafe 12345678
       bin:  3           2              1           0
            1098 7654 3210 9876 - 5432 1098 7654 3210

0xdeadbeef: 1101 1110 1010 1101 - 1011 1110 1110 1111 
0xcafecafe: 1100 1010 1111 1110 - 1100 1010 1111 1110 
0x12345678: 0001 0010 0011 0100 - 0101 0110 0111 1000

Read more of this post

Fun with ATtiny and V-USB

Sometime you have to do build just for the fun of it.

Recently, while I was about to order a set of PCBs from my favorite website, I told a friend about a really funny project based on the V-USB stack with ATtiny devices, and he was impressed by the size of the thing… So I decided to design my own ATtiny V-USB board!

This project is a really small USB gadget without any specific I/O, and it’s designed to fit into a USB connector with the exposed PCB as small as possible.

The original idea for this board was to use it for April-fool like jokes, but the project also uses a couple of interesting features of the V-USB stack.

Read more of this post

IPv6 Tunnel Broker on GNU/Linux Routers

IPv6 connectivity is slowly spreading around the net day after day. Sooner or later you may want to get IPv6 connectivity to your home, as some providers already does with brave users.

If your ISP does not give you native IPv6 connectivity you can still get your own IPv6 access in a number of ways.

Read more of this post

Daemonizing Processes and System Log

If you write software for embedded applications, sooner or later you will end up writing a daemon.

In my work I see many embedded applications, but very often the programmer write and debug all the program in foreground, and then forgets to implement a simple daemonize function.

The consequence is that when the application is started from the init scripts instead that from a command shell, it locks up the entire boot sequence of the system.

Also, when writing a background application, all the messages should be redirected to the system log… don’t reinvent the wheel rewriting a new logging system!

Here I’ll show a sample daemonize() function, and how to use the syslog() library function.

Read more of this post

Linux LED Subsystem

LEDs… Everyone likes that! Those little shiny electronic devices are mounted on any well-made electronic equipment to indicate at a glance its working status. They tell you when your network has activity, when your laptop battery is empty, when your hard-drive is working, when your amplifier is overloading… they may even light up your bedroom!

In embedded systems the proper design of the front panel, with the right LED illuminated icons, is an essential feature and if you are familiar with network troubleshooting you can understand why!

Well-made devices should have a panel that instantly gives you an idea of what’s working and what’s not just by looking at it.

If you are using Linux as your kernel on a SoC design, you’ll be glad to know that it has an entire subsystem dedicated to LEDs!

In this post I’ll show how you to check if your system has some controllable LEDs, and how to use that from userspace applications and kernel drivers.

Read more of this post