The Ethernet header

Ethernet (vlan) header

Having spent quite a lot of time in the last year or so writing Ethernet driver software, I find myself looking at this picture every now and then, when trying to decipher a tcpdump file or just random traces of Ethernet packages in an error log. To save some time trying to find this picture or a similar one – I thought I might as well add it here.

Courtesy of Wikipedia.

A simple CRC implementation

Every now and then I find myself worrying about data transmitted over a media now showing up correctly on the other side. The best way to make sure this is the case is to add a CRC calculation to the data being transmitted.

While the web is swamped with implementations of CRC calculations, I still find it useful to have one reliable piece of software doing this type of calculation conveniently at hand, enter this zip archive.

The linked to CRC code was provided by Michael Barr at

Have your Makefile upload built binary to a target

A colleague of mine introduced me to this really handy pice of command line software that has helped me in my daily work since then: curl.

By simply adding a few extra lines to the end of my final rule of the Makefile I’m currently using I can now have the newly built binary automatically uploaded to a any folder on an target board of my liking, without having to do all these steps myself:

# Build finaly binary. If "IP" is defined on command line, upload
# built binary using curl.
$(TARGET_NAME).out : ...
ifdef IP
curl -T $(TARGET_NAME).out ftp://x:x@$(IP)/c/bin/

Simly add the IP address to use when invoking the Makefile, and you’re all set:

$ make IP=

Memory Access through a structure

One of the more common things you do as an Embedded Systems programmer is accessing registers of different peripherals.

Rather than hardcoding the address to each and every register in a peripheral, I find it convenient to typedef a C-struct for easy access of these registers. Setup the struct with a layout identical to that of your hardware registers, assign a pointer to the structure to point at the (base)address of the hardware registers in question, and voila! Access each register as a regular element of the structure for read/write operations.

typedef struct {
volatile uint8_t STATUS;
volatile uint8_t TX_REG;
volatile uint8_t RX_REG;
} hw_device_t;

hw_device_t * const ptr = (hw_device_t *) 0xFF000000;

hw_device->RX_REG = 0x10;
hw_device->TX_REF = 0x03;
uint8_t current_status = hw_device->STATUS;

Note: all elements of structure should be made volatile to avoid compiler optimizations.

New platform, same contents

I’ve decided to give WordPress a try, to see if it’s a platform that fits my needs.

The main purpose of this page is still for me to gather up some pieces of information that I want to be able to access wherever I may be in the world.

I will however also add some pages related to my area of profession as an Embedded Systems developer. This could be both an electronic version of my Curriculum Vitae, and some handy tools and tricks that I am using in my profession, and want to keep track of.