SkyForge: Creating Debian root filesystems in a Dockerfile-style

For a handful of projects work and hobby alike I use Debian. However, when you deal with embedded systems (e.g. ARM SoC) you normally don’t have the installer CD or even the disk drive. You end up creating a filesystem, compiling the kernel. Well, pretty much the usual way it goes.

The process can be somehow lengthy if done by hand using debootstrap and multistrap and especially mind-blowing if you are a total newbie. (Alas, I’m already no n00b here. Getting older, heh)
The worst part of it is that you not only need to create a root filesystem for debian, but set it up in a more or less sane way, e.g. set the default password, ssh keys… The usual thing.

In the Big Enterprise ™ we can see tools like vagrant creating us a base box in the VM and chef or puppet actually setting the system up. While we can use, say chef or chef-solo on an armhf board (why not?) we still have to make sure we have some base image it will set things up on, right?

(more…)

CMake + atom + .clang_complete

A few months ago I moved from emacs to atom that looked like a more modern replacement. Most important for me – it had awesome CMake code completion that was very good. I soon made use of automplete and lint with clang. Both were good, but needed a .clang_autocomplete in your project root to work properly. Apparently if your project file get a bunch of compiler flags from the build-system managing this file by hand is not something I wanted, so I ended up with this snipplet in CMake that gets the job done:

message(STATUS "Generarating ${CMAKE_SOURCE_DIR}/.clang_complete")
get_property(dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
file(WRITE ${CMAKE_SOURCE_DIR}/.clang_complete "")
foreach(dir ${dirs})
  file(APPEND ${CMAKE_SOURCE_DIR}/.clang_complete "-I${dir}\n")
endforeach()
string(REPLACE "'" "" CMAKE_C_FLAGS_SPLIT ${CMAKE_C_FLAGS})
string(REPLACE " " ";" CMAKE_C_FLAGS_SPLIT ${CMAKE_C_FLAGS_SPLIT})
foreach(flag ${CMAKE_C_FLAGS_SPLIT})
  file(APPEND ${CMAKE_SOURCE_DIR}/.clang_complete "${flag}\n")
endforeach()

If you use C++ in your project you need to use the CMAKE_CXX_FLAGS variable. This code also has the obvious limitation: If you pass via -D directive options that have spaces – this won’t quite work (e.g. -DRELEASE_CODENAME=”Black Burned Cookies”)

Doxygen && gh-pages

Github has a cool feature – it allows you to attach html pages to your repo. And if the web pages designer that brings memories of early 00s is somewhat useless – storing doxygen html docs there is a very cool feature.

However we can’t store any history in gh-pages branch. It would be utterly useless and may heavily bloat the repo (especially if you generate a plenty of diagrams with graphviz). So ideally we should:

  • Make a clean branch each time, commit all the docs we’ve generated
  • Do –force push, so that we’d drop everything on the remote side
  • Do it from our development branch, without switching to gh-pages
  • Potentially integrate with CI/Jenkins: Build succeded, unit-tests passed, static analysis okay – bump the docs!

Can be achieved easier than it sounds. Here’s my quick sniplet for this hackery in GNU/Make:

doxygen: 
	-rm -Rfv doxygen/
	( cat Doxyfile ; echo "PROJECT_NUMBER=0.1" ) | doxygen 
	cd doxygen/html;\
	rm -Rfv .git;\
	git init .; git checkout --orphan gh-pages;\
	git add *;\
	git commit -m "documentation-for-gh-pages";\
	git remote add origin git@github.com:MY_GITHUB_USERNAME/MY_GITHUB_PROJECT.git;\
	git push -u -f origin gh-pages

ESP8266: Say ‘hello’ to Frankenstein

Since I’ve got some homebrew development boards ready, it’s time to get hacking.
I stocked on coffee and gave esp8266 SDK a deep dive this weekend. The code is really weird, lots of things are unknown, API is shitty, blobs all around the place. First of all, to make things clear – I’m not going to fix or do anything with AT-command firmware. It sucks. Period. Sucks so much it can’t even prove useful as a reference most of the times. So… we need a replacement.

This is what I’m working on and that is now, after a weekend of hacking is in early alpha stage.

Say hello to Frankenstein Firmware for ESP8266.

(more…)

rf24boot v0.2 released!

DSC_0078

It was a busy month, but I finally managed to find a minute and update the rf24boot. Yes, the very thing that can push firmware updates via nRF24L01 wireless modules. Along is a regular bunch of updates to rf24 library in antares. One of the big news I finally took some 20 minutes and layed out a proper programming dongle. Since I didn’t have a cheap stm32 with usb around, and stm32f103ret6 looked like an overkill for this purpose this dongle still uses avr, vusb, but has a 16M (20M is possible as well) crystal. The lengthy changelog’s under the cut, but it’s big.

(more…)

Antares 0.2-rc1 released!

That’s it! It’s out. After two years of slow and steady development in my free time. Antares is a free and open source (GPLv2) buildsystem bundled with library code, aimed at bare metal targets. Sounds scary? Well, consider this an arduino for kernel hackers. If you are one – you have all the regular tools here: kconfig, GNU/Make, and no need to write Makefiles from scratch or collect sparse instructions over the web – just bootstrap a project, adjust the config to your needs and go!
0.2-rc1 is the first release that can be considered (more or less) stable for every day use. To find more about what it is and how it works – check out the README in Russian or English

snapshot9

(more…)

UBIFS over DVD+RW

Don’t ask why. I just though it might be a cool idea.

So what’s the catch? Packet writing over CD/DVD-/+RW media is pretty much the same as writing to a block device. The only bad thing is that:

  • Writes MUST be aligned
  • Writes must be of a fixed packet size
  • Before reading you must issue a flush command.

To hide this from the upper level pktcdvd module exists that assembles packets and sends them to the media. Well, this whole pktcdvd machinery reminded me of a NAND device actually, so I wondered if we could actually make an MTD device out of a CD or DVD. AND run UBIFS on top of it. (Or yaffs2. whatever). Details&code under the cut

(more…)

Ditching the x86 – moving on to armv7l

My home server has a long story. It all started with a Pentium 4, an old 20GB HDD and FreeBSD 6.2 … hell, I don’t even remember the exact year.
Anyway, after a few years, the hardware was finally put to rest, since it died and got resurrected thrice, I got an Intel Atom D410-based miniATX board, switched to linux, first debian, then agilia, then arch… Anyway, it used to be a nice server for personal needs, that crashed only on occasional HAD-effect, so it was… sufficient.
Now, the time has come to move on, to arm. The benefits were simple and straight:

  • 10W peak power consumption
  • Fully passive cooling
  • eMMC for the root partition
  • 4 cores!
  • Always a serial terminal, starting from uboot phase, so that I don’t have to carry a monitor to the closet where it is stationed.

I picked ODROID-X2 based around Exynos4212 Prime. ODROID-U2 looked worse, since had NAND soldered onboard. eMMC looked easier to replace. And the benchmarks said eMMC was faster.

IMG_20130521_133759

So, here go my adventures with this hardware.
(more…)

STLink as a serial terminal

A usual rant goes towards ST guys for their mindless design*. I don’t really know anyone, who does some heavy app development with no serial terminal for debugging (Or may be I don’t know many of them?). You know, gdb is good, but a good old ‘dmesg’-like stuff is usually even more helpful.
Anyway, while other people are trying to discover traces of sanity of the ST people by reversing STLinkv2 and discovering only huge holes in security so far, I decided to go a different way that works just fine with STLinkV1 and STLinkV2.
My first idea was to stuff the VCP example into the stlink’s uC (which is an STM32F103C8T6) and throw a little wires, but in the end – I didn’t want to ditch STLink completely (It helped me out a few times). Ideas? Sure!

IMG_20130506_100917

First step. What does STLink do? Right, apart from that breakpoint/step voodoo it writes and reads memory. Sounds good? Good! Enough to do pretty much anything.
(more…)