Skip to content

Entries from September 2013.

NAND kernel driver activity visualisation

Just found: an interesting method to check how your NAND driver (and filesystem kernel module) behave during massive write operations. I've added additional printk-s() to NAND driver kernel module write() call and collected data during filling all available filesystem space.

Output dmesg logs have been preprocessed and offset call parameter has been presented as a graph using gnuplot (horizontally: write number, vertically: offset):

229

What can we see from that graph:

  • some writes at offset 0 - typically dangerous as might overwrite bootloader area, I've added them intentionally in this graph by reflashing bootloader manually
  • with missing space wear levelling is less efficient - right part of the graph
  • we can see that catalog location (blocks with filesystem metadata) is moved dynamically across all space to avoid multiple writes to the same location (NAND specific), we see the location has been changed ~6 times during whole operation (probably relocation is done after every 2000 write operations)
  • two different partitions are visible (one at ~60M, one at ~10M)

join() in AWK scripting language

AWK is small but very useful Unix scripting language that is mainly aimed at text files filtering and modification. If you're on embedded device you might expect bigger brothers (as Perl / Python) are not available, but AWK is usually shipped with busybox (= small).

One of missing functionalities is join() function (the opposite of splitting string by regular expression). One can implement it pretty easily, however:

function join(array, sep,
   result, i)
{
        if (sep == "")
                sep = " "
        else if (sep == SUBSEP) # magic value
                sep = ""
        result = array[1]
        for (i = 2; i in array; i++)
                result = result sep array[i]
        return result
}

Usage:

split(s, arr, "|")
output = join(arr, "|")

As a result input string s will have the same contents as output. The function is useful for scripted modification of CSV files.