Advertisements

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

Advertisements

Iptables Stateful Firewall and NAT Routing

Network packet filtering! Whether is your home or your company, modern networks have many systems connected. Even a small domestic network can provide connectivity to many devices of different kinds: PCs, laptops, printers, smartphones, game consoles, your neighbor’s laptop (wait… what?!), NASes, media players, TVs…

If you have some basic knowledge in networking, you’ll probably want a way to control all the traffic going through your network, and if you are running a GNU/Linux system, you probably already have what you need… Netfilter!

What you’ll find here are some examples of common Netfilter (iptables) configurations and some scripts I use as a base for my firewalls and network installations.

These are really useful if you need some advanced firewall configuration and you choose to run your own GNU/Linux system as a router instead of a commercial one. Also, these scripts may come in handy if you need to quickly replace a broken router with a spare PC.

Read more of this post

Using Serial Ports on GNU/Linux Systems

While for the modern PC user serial ports are just a page on Wikipedia, for the embedded developer a 3 wire UART can be a simple point-to-point bus, or even the only way you have to access the debug data of the system.

Serial ports are almost always used in SoC based designs as the bus to access the bootloader command prompt and the debugging console, and is not uncommon to find SoC with 5 or more serial ports. Also, many peripherals communicate with the main processor via UARTs, such as GPS, GSM modems, Bluetooth radio, field bus devices and general purpose microcontrollers.

On a GNU/Linux system, a serial port is just a character device file, which can be opened, written, read and closed. However, to properly use the device from a C application, you have to use a certain command sequence, which can be quite tricky if you never did it before.

Read more of this post