Advertisements

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

Advertisements

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

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

Hello, WordPress!

Hello, WordPress!

My name is Fabio, I’m a Free Software enthusiast with an orientation for lowlevel software and firmware programming and some bit of hardware design.

I write on these pages to give something back to the community, and I plan to post on many subjects of my interests, which include GNU/Linux systems, networking, microcontrollers, automation, electronic design and complete projects I make in my spare time.

Learn more about me on the about me page.

Enjoy!