You are here

Planet Linux Australia

Subscribe to Planet Linux Australia feed
Planet Linux Australia -
Updated: 56 min 5 sec ago

Chris Smart: Cross-compiling a PowerPC64 LE kernel and hitting a GCC bug

Thu 03rd Sep 2015 18:09

Being new at OzLabs I’m dipping my toes into various projects and having a play with PowerPC and so I thought I’d cross-compile the Linux kernel on Fedora. Traditionally PowerPC has been big endian, however it also supports little endian so I wanted to build all the things.

Fedora uses a single cross toolchain that can build all four variants, whereas Debian/Ubuntu splits this out into two different toolchains (a BE and an LE one).

Install dependencies in Fedora:

$ sudo dnf install gcc make binutils-powerpc64-linux-gnu gcc-powerpc64-linux-gnu gcc-c++-powerpc64-linux-gnu bc ncurses-devel

Get the v4.2 kernel:

$ git clone --branch v4.2 --depth 1 && cd linux

Successful big endian build of the kernel, using the default config for pseries:

$ ARCH=powerpc CROSS_COMPILE=powerpc64-linux-gnu- make pseries_defconfig

$ ARCH=powerpc CROSS_COMPILE=powerpc64-linux-gnu- make -j$(nproc)

# clean after success

$ ARCH=powerpc CROSS_COMPILE=powerpc64-linux-gnu- make clean

$ ARCH=powerpc CROSS_COMPILE=powerpc64-linux-gnu- make mrproper

Building a little endian kernel however, resulted in a linker problem:

$ ARCH=powerpc CROSS_COMPILE=powerpc64-linux-gnu- make pseries_defconfig

$ ARCH=powerpc CROSS_COMPILE=powerpc64-linux-gnu- make menuconfig

# change architecture to little endian:

# Endianness selection (Build big endian kernel) --->

# (X) Build little endian kernel

$ ARCH=powerpc CROSS_COMPILE=powerpc64-linux-gnu- make V=1

Here was the result:

powerpc64-linux-gnu-gcc -mlittle-endian -mno-strict-align -m64 -Wp,-MD,arch/powerpc/kernel/vdso64/ -nostdinc -isystem /usr/lib/gcc/powerpc64-linux-gnu/5.2.1/include -I./arch/powerpc/include -Iarch/powerpc/include/generated/uapi -Iarch/powerpc/include/generated -Iinclude -I./arch/powerpc/include/uapi -Iarch/powerpc/include/generated/uapi -I./include/uapi -Iinclude/generated/uapi -include ./include/linux/kconfig.h -D__KERNEL__ -Iarch/powerpc -DHAVE_AS_ATHIGH=1 -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -std=gnu89 -msoft-float -pipe -Iarch/powerpc -mtraceback=no -mabi=elfv2 -mcmodel=medium -mno-pointers-to-nested-functions -mcpu=power7 -mno-altivec -mno-vsx -mno-spe -mspe=no -funit-at-a-time -fno-dwarf2-cfi-asm -mno-string -Wa,-maltivec -fno-delete-null-pointer-checks -O2 --param=allow-store-data-races=0 -Wframe-larger-than=2048 -fno-stack-protector -Wno-unused-but-set-variable -fomit-frame-pointer -fno-var-tracking-assignments -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fconserve-stack -Werror=implicit-int -Werror=strict-prototypes -Werror=date-time -DCC_HAVE_ASM_GOTO -Werror -shared -fno-common -fno-builtin -nostdlib -Wl, -Wl,--hash-style=sysv -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(" -D"KBUILD_MODNAME=KBUILD_STR(" -Wl,-T arch/powerpc/kernel/vdso64/ arch/powerpc/kernel/vdso64/sigtramp.o arch/powerpc/kernel/vdso64/gettimeofday.o arch/powerpc/kernel/vdso64/datapage.o arch/powerpc/kernel/vdso64/cacheflush.o arch/powerpc/kernel/vdso64/note.o arch/powerpc/kernel/vdso64/getcpu.o -o arch/powerpc/kernel/vdso64/

/usr/bin/powerpc64-linux-gnu-ld: arch/powerpc/kernel/vdso64/sigtramp.o: file class ELFCLASS64 incompatible with ELFCLASS32

/usr/bin/powerpc64-linux-gnu-ld: final link failed: File in wrong format

collect2: error: ld returned 1 exit status

arch/powerpc/kernel/vdso64/Makefile:26: recipe for target 'arch/powerpc/kernel/vdso64/' failed

make[2]: *** [arch/powerpc/kernel/vdso64/] Error 1

scripts/ recipe for target 'arch/powerpc/kernel/vdso64' failed

make[1]: *** [arch/powerpc/kernel/vdso64] Error 2

Makefile:949: recipe for target 'arch/powerpc/kernel' failed

make: *** [arch/powerpc/kernel] Error 2

All those files were 64bit, however:

arch/powerpc/kernel/vdso64/cacheflush.o: ELF 64-bit LSB relocatable, 64-bit PowerPC or cisco 7500, version 1 (SYSV), not stripped

arch/powerpc/kernel/vdso64/datapage.o: ELF 64-bit LSB relocatable, 64-bit PowerPC or cisco 7500, version 1 (SYSV), not stripped

arch/powerpc/kernel/vdso64/getcpu.o: ELF 64-bit LSB relocatable, 64-bit PowerPC or cisco 7500, version 1 (SYSV), not stripped

arch/powerpc/kernel/vdso64/gettimeofday.o: ELF 64-bit LSB relocatable, 64-bit PowerPC or cisco 7500, version 1 (SYSV), not stripped

arch/powerpc/kernel/vdso64/note.o: ELF 64-bit LSB relocatable, 64-bit PowerPC or cisco 7500, version 1 (SYSV), not stripped

arch/powerpc/kernel/vdso64/sigtramp.o: ELF 64-bit LSB relocatable, 64-bit PowerPC or cisco 7500, version 1 (SYSV), not stripped

An strace of the failing powerpc64-linux-gnu-gcc command above showed that collect2 (and ld) were being called with an option setting the format to 32bit:

24904 execve("/usr/libexec/gcc/powerpc64-linux-gnu/5.2.1/collect2", ["/usr/libexec/gcc/powerpc64-linux"..., "-plugin", "/usr/libexec/gcc/powerpc64-linux"..., "-plugin-opt=/usr/libexec/gcc/pow"..., "-plugin-opt=-fresolution=/tmp/cc"..., "--sysroot=/usr/powerpc64-linux-g"..., "--build-id", "--no-add-needed", "--eh-frame-hdr", "--hash-style=gnu", "-shared", "--oformat", "elf32-powerpcle", "-m", "elf64lppc", "-o", ...], [/* 66 vars */]

Alan Modra tracked it down to some 32bit hard-coded entries in GCC sysv4.h and sysv4le.h and submitted a patch to the GCC mailing list (Red Hat bug).

I re-built the Fedora cross-gcc package with his patch and it solved the linker problem for me. Hurrah!

Categories: thinktime

Craige McWhirter: Craige McWhirter: Getting started with Xmonad

Wed 02nd Sep 2015 23:09

Over the years I've found window managers and desktop environments increasingly getting in my way. It was for this reason I ditched GNOME for Enlightenment 0.17 and again why I recently ditched Enlightenment 0.19 for Xmonad.

I'd tried Xmonad back in 2013 because Haskell but walked away after a fairly half-hearted look. I gave it a much more serious look this time and I'm happy to say that it's here to stay.

Xmonad is light, fast and behaves exactly how I expect it to.

Here's how I went about settling into Xmonad on Debian Jessie:

An Overview of My Xmonad Environment

The current environment I've settled on with Xmonad looks like this:


For the impatient, follow these steps below and you should be on your way:

$ sudo apt-get install xmonad libghc-xmonad-contrib-dev libghc-xmonad-dev suckless-tools trayer xscreensaver scrot $ wget myconfig and install it here $ wget this xinitrc to here $ wget -O /tmp/ $ mkdir -p ~/.fonts/OpenSans $ unzip -d ~/.fonts/OpenSans /tmp/ $ fc-cache -fv

Select "Default Session" when logging in via GDM, LightDM etc. Enjoy.

Get the Gear

For those of us that are a little more Zen about learning, let's install the packages:

$ sudo apt-get install xmonad libghc-xmonad-contrib-dev libghc-xmonad-dev suckless-tools trayer xscreensaver scrot Optional Font Installation:

The configuration I provide for xmobar uses the Open Sans font. You can change this to any font that you desire. However if you wish to use Open Sans, here is how you go about getting and installing it:

  1. Download the font:
$ mkdir ~/.fonts/OpenSans $ wget -O /tmp/
  1. Unzip the font:
$ cd ~/.fonts/OpenSans $ unzip /tmp/
  1. Rebuild the font cache information files:
$ fc-cache -fv

This will provide you with the all the tools that make up my Xmonad environment.

Configure Your Xsession

The very minimum that you'll need to do is edit / create ~/.xsession to have at least this line:


You can get more creative than this if you like, I recommend reading Getting started with xmonad and How can I use xmonad with a display manager?.

Configure Xmonad

Xmonad, unsurprisingly uses Haskell as it's configuration language. Here is the ~/.xmonad/xmonad.hs I used at the time of writing:

import XMonad import XMonad.Hooks.DynamicLog import XMonad.Hooks.ManageDocks import XMonad.Util.Run(spawnPipe) import XMonad.Util.EZConfig(additionalKeys) import System.IO main = do -- Spawn the xmobar status bar xmproc <- spawnPipe "/usr/bin/xmobar ~/.xmobarrc" xmonad $ defaultConfig -- Set your preferred mouse focus behaviour { focusFollowsMouse = False -- Set your default terminal , terminal = "terminology" -- Configure some default interactions between Xmonad and xmobar , manageHook = manageDocks <+> manageHook defaultConfig , layoutHook = avoidStruts $ layoutHook defaultConfig , logHook = dynamicLogWithPP $ xmobarPP { ppOutput = hPutStrLn xmproc , ppTitle = xmobarColor "green" "" . shorten 50 } , modMask = mod4Mask -- Rebind Mod to the Windows key -- Configure some additional keys } `additionalKeys` -- Lock the screen with Windows+Shift+z [ ((mod4Mask .|. shiftMask, xK_z), spawn "xscreensaver-command -lock") -- Capture the current window with control+PrintScreen , ((controlMask, xK_Print), spawn "sleep 0.2; scrot -s") -- Capture the current desktop with PrintScreen , ((0, xK_Print), spawn "scrot") -- Turn off the display port with Windows+d - Useful for undocking my laptop , ((mod4Mask, xK_d), spawn "/usr/bin/xrandr --output DP1 --off") -- Turn on the display port and set it as the primary display with Windows+Shift+d - tailor to your screen , ((mod4Mask .|. shiftMask, xK_d), spawn "/usr/bin/xrandr --output DP1 --primary ; /usr/bin/xrandr --output LVDS1 --mode 1280x800; /usr/bin/xrandr --output DP1 --mode 2560x1440; /usr/bin/xrandr --output DP1 --left-of LVDS1") -- Volume control keys, if needed. Yours may be different. , ((0 , 0x1008FF11), spawn "amixer set Master 2%-") , ((0 , 0x1008FF13), spawn "amixer set Master 2%+") , ((0 , 0x1008FF12), spawn "amixer set Master toggle") ] Configure xmobar

Xmobar uses ~/.xmobarrc as it's configuration file. I am using the Open Sans font. If you did not download and install that in the earlier steps, you may want to change the font = line to a font that you do have installed.

Here is my .xmobarrc file:

Config { font = "xft:Open Sans:size=10:antialias=true" , bgColor = "black" , fgColor = "grey" , position = TopW L 90 , lowerOnStart = True , commands = [ Run Cpu ["-L","3","-H","70","--normal","green","--high","red", "-t", "CPU <total>"] 10 , Run CpuFreq ["-t", "<cpu0>GHz <cpu1>GHz"] 10 , Run Memory ["-t", "MEM <usedratio>%"] 10 , Run Date "%a %b %_d %H:%M" "date" 10 , Run Battery ["-t","BAT <left>", "-h", "green", "60", "-l", "red", "10"] 10 , Run StdinReader , Run Weather "YSSY" ["-t"," <tempC>C","-L","10","-H","35","--normal","green","--high","red","--low","lightblue"] 36000 , Run DynNetwork [] 10 ] , sepChar = "%" , alignSep = "}{" , template = "%StdinReader% }{ %cpu% %cpufreq% | %memory% | %dynnetwork% | %battery% %YSSY% <fc=#ee9a00>%date%</fc>" }

I'd recommend looking up your nearest weather station here and replacing YSSY with that station's code. Unless you live in Sydney, Australia, in which case, you're set.

Configure Trayer

I use trayer as my system tray and I place it to the right of the screen in the gap left by my xmobar configuration:

trayer --edge top --align right --SetDockType true --SetPartialStrut true \ --expand true --width 10 --transparent true --alpha 0 --tint 0x000000 --height 19 &

I currently run this manually but it could easily be launched automatically elsewhere.

Login & Get Comfortable

There's a useful list of default key bindings and handy cheatsheet which you'll need to familiarise yourself with.

I've found xmonad to be fast and unobtrusive with default behaviour that continually surprises me by doing exactly what I expected.

Very happy convert here.

Categories: thinktime

BlueHackers: tears in rain | Wil Wheaton

Wed 02nd Sep 2015 10:09

I walked out of the loading dock, through a cloud of rotting garbage, and into the alleyway behind the theater. A curtain of rain fell between me and my destination, a little over a block away.

“Do you want to wait here, while I get you an umbrella?” Liz, the producer from Wizards of the Coast, asked me.

“No,” I said, stepping into the rain, extending my arms outward and turning my palms and face to the sky, “it’s been so long since I felt rain fall on my body, I’m not going to let this opportunity pass me by.”

I walked down the sidewalk, surrounded by other PAX attendees. Some were not bothered by the rain, while others held up programs and newspapers and other things to keep it away. A man walked his dog next to me. The dog was unperturbed by the weather. We got to the corner and waited for the light to change. The rain intensified and it was glorious.

“Are you sure this is okay?” She said.

“Oh yes, this is so much more than okay,” I answered, “this is perfect.”


I’ve been feeling pretty much the opposite of awesome for several weeks, now, and actually getting to sit down, face to face, in a semi-quiet few moments with real people who wanted to be there with me was … restorative, I guess is the best word. One player told me, “Thank you for everything you do. From Tabletop to Titansgrave — which is the best thing I’ve ever seen — to talking so openly about anxiety and depression.”


Read Wil’s entire post at

Categories: thinktime

Binh Nguyen: Native Instrument's 'pkg' File Format, Web Documentation Compiler/Scraper, Thoughts on the JSF/Counter-Stealth Technologies, and More

Tue 01st Sep 2015 13:09
Sometimes you get installation errors in Windows and it is absolutely infuriating because the manufacturer offers you no easy way of correcting (and understanding where the error actually is because of arcane error messages) the file short of re-downloading the entire ISO, etc... This is when some basic reverse engineering skills come in handy.

As you can see below, Native Instrument's 'pkg' file format is actually just a xar archive which includes several other archived files as well.

xar -x -f "Maschine 2 Factory Library Library Part 5.pkg"

user@machine:/media/sda1/NIMCN2FL100$ cd Folder

user@machine:/media/sda1/NIMCN2FL100/Folder$ ls

Bom  PackageInfo  Payload  Scripts

user@machine:/media/sda1/NIMCN2FL100/Folder$ file *

Bom:         Mac OS X bill of materials (BOM) file

PackageInfo: XML document text

Payload:     gzip compressed data, from Unix

Scripts:     gzip compressed data, from Unix

user@machine:/media/sda1/NIMCN2FL100/Folder$ mv Payload Payload.gz

user@machine:/media/sda1/NIMCN2FL100/Folder$ mv Scripts Scripts.gz

user@machine:/media/sda1/NIMCN2FL100/Folder$ gunzip Scripts.gz

user@machine:/media/sda1/NIMCN2FL100/Folder$ ls

Bom  PackageInfo  Payload.gz  Scripts

user@machine:/media/sda1/NIMCN2FL100/Folder$ vim Scripts

user@machine:/media/sda1/NIMCN2FL100/Folder$ gunzip Payload.gz

user@machine:/media/sda1/NIMCN2FL100/Folder$ ls

Bom  PackageInfo  Payload  Scripts

user@machine:/media/sda1/NIMCN2FL100/Folder$ file *

Bom:         Mac OS X bill of materials (BOM) file

PackageInfo: XML document text

Payload:     ASCII cpio archive (pre-SVR4 or odc)

Scripts:     ASCII cpio archive (pre-SVR4 or odc)

The trend towards placing all documentation online can be infuriating at times. It means you have to have a permanent connection on at all times for referencing. The only option is to run a web crawler/web site downloader over it but as I've discovered in the past the performance of such programs can be frustrating. Recently, I had a similar encounter with some trading software. I wrote a custom script to download all relevant files and then compiling them into a single PDF file.

This reminds me, you don't always have to resort to multi-threading to achieve parallelism/higher performance (I've come across some people who have almost basically assumed this). In fact, in some languages you can't even do it.

If you've ever watched some of the online courses from MOOCs and seen some of the better quality YouTube productions (or other free video upload sites out there) you're sometimes left wondering why you or others would want to pay. Anyhow, as stated previously I don't like being online all the time and want to download things for offline perusal. Recently, I had a problem with regards to merging them though. One, it wasn't being done properly and two, MP3 tag information was corrupted. I found out mp3wrap and vbrfix did the job.

You may have to chance some code in mp3wrap if you use more than 256 files though. ./configure, make, make install...

mp3wrap.h:#define MAXNUMFILE 512

Can't believe that in this day and age we don't have better mp3 file verification checking options. Guessing I haven't found the right tool yet?

- as stated before the US seems more guarded with regards to the program than most other people - most advances in 'stealth' have so far come from iterative science and technology advances. I think the next major advance will likely come from left field though. Something which affects the science in general rather than something more specific to stealth/defense technology alone. Like 'stealth' my guess is that it may take a bit of time before we feel the impact of such technology in the real world though

- if you look at the program more carefully it's much more obvious how savings can accrue over the life of the JSF program. It's clear that the core designs across each of the variants is no longer as similar as was originally intended but modular design, self diagnostics/testing, etc... will still play a role over the entire lifetime of the program

Marine In The F-35 Test Force Shares His Experiences

- the irony is that some of the primary mechanisms that are currently used to reduce temperature for IR stealth are actually used in satellite technology and more inauspicious areas like motorsport technology

- one of the odd things which has struck me about the Russia/Chinese with regards to their defense/intelligence setup is that even if they have the ability to re-produce some Western technologies they sometimes choose not to. Think about the Buran. They're generally more practical and economical with regards to use of technology. Look at the way finances were handled during the KGB era. They were miserly when it came to budgeting for possible assets when compared to their Western counterparts. That's why I'm not entirely certain that the reason why they are behind the eight ball on aircraft stealth is simply because they don't have the ability to bridge the gap... At various times throughout history they've held the lead with regards to submarine, missile, and various other core defense technologies. I think that it may simply come down to the fact that they may be trying to do their best allocate their resources in such a way that to acheive their defensive needs for the best price? Either way, I don't think that a war involving the US and near peer threats such as Russia and China is going to be clear cut as some people think (especially when the modernisation of their militaries are complete). It will be somewhat of a slugfest...

- even if the JSF can perform CAS duties relatively well there's something we're missing here. The JSF is incredibly expensive and the way that stealth is so integral to the aircraft means that every time the aircraft gets hit its RCS increases. For anyone to assume that the JSF is not going to get hit in CAS duties is nonsensical especially if it's going to try to takeover the role of the A10 (in a like for like replacement) at some point. I still prefer a group of loitering drones that can be called in for an immediate support at any point if and when required. It should be cheaper, quicker, and more survivable (if designed correctly)... This could be a moot point though if Allied nations only continue to engage in non near-peer threat engagements such as been the case recently though...

- the most common argument that the Russians/Chinese have when the West accuses them of something is that the West isn't any different. The funny thing about this is that technically they're right. It's just the level that each side is willing to stoop to. The US spies on friend and foe alike using mostly technological means though while the former is more reliant on HUMINT. In the context of economic intelligence I'd be very interested to know just exactly how the numbers add up knowing how much the West spends on technical intelligence and the same goes for the Russians/Chinese as well... Both sides sound rediculous at times accusing one another of any wrong doing...,7340,L-4696268,00.html

- if you think about the nature of defense now it's somewhat bemusing. Our concept of what defense seems to be almost completely focused around the notion of force projection and qualitative/quantitative superiority. To me some of what is done has little to do with defense anymore as it does attempting to shape the world in the way we want simply because we can...

- there's so much information out there regarding a lot of sensitive military technology I just find it hard to believe some of the classification levels for information that are held when it comes to some stuff and why we would hold people accountable for stuff that is already out in the open and confirmed by official sources. Sometimes it seems as though much of what the Russians/Chinese need to reverse engineer some technologies can either be purchased or else obtained from free and open sources

JSF Making Stealth productionJuly48 TEXT READABLE.pdf


F-35 High Energy Laser

Stealth question - Reduction in RCS

- as stated previously, most people who watch this space know that stealth bombers can be tracked from thousands of kilometers away provided equipment is tuned correctly, environmental conditions are favourable, etc... To me, a lot of the power projection capabilities (or anything which facilitates them) makes me feel as though they have homing beacons. This includes sensor technology which relies on any active measures such as long range RADAR, AWACS, re-fuelling, AEGIS class warships, aircraft carriers, etc... They're just asking to be hit (by near peer threats) which probably explains the reasons behind increasing sensory capabilities of 5th gen aircraft such as the JSF and increasing de-centralisation of capabilities in 6th gen aircraft designs

- if you know a little bit about military technology you'll be aware that one of the things that are of slight concern are electronic hardware which when illuminated by certain, unique frequencies basically become homing beacons. The thing is, if you think about this for a bit isn't it possible to achieve the same thing using microchips (or anything that is symmetrical on an aircraft)? I mean, one of the core tenets of RADAR stealth is incorporating non-planform design. Namely, reducing parallel and symmetrical shapes. The legs on a microchip are spaced evenly and symmetrically apart. Provided sufficient power and at favourable angles isn't it also possible to achieve the same thing using electronics (and other objects) aboard most aircraft (epsecially if their designs are unique)? The main issues would be power and projection of course...

- in the Iraq war much of the RADAR capabilities were knocked out extremely early. The opposite has been true in Syria where much equipment has been turned off and turned on only periodically. Much like my beacon idea I'm wondering why we couldn't use the same concept to detect SAM and RADAR systems. If we know the rough design, then we should know the rough frequency/wavelength that they operate with... Radiate at sufficient power and at the right angle and they should re-radiate? Perhaps a job for drones which would search for equipment based on rough intelligence estimates for mobile equipment in particular?

- people often harp on about how Western defense technology is superior but we've never really seen a genuine encounter between near peer threats for a long time. It's also clear that neither side. Operationally, both Russia and the United States have never really given in to their partners on national security concerns. Their partners often don't receieve the same information nor do they recieve the same technology (same fear that the US has regarding the F-22 Raptor. They don't want to have to go to war against equipment that is equally adept which they built. They also worry about OPSEC of allied nations believing that we could leak information since we spend less on national security). I wouldn't be surprised if (much like during the Cold War) much of the publicly available information we have regarding upper end equipment is substantially wrong

- much has been made of DAS in the JSF. Some Russian fighter aircraft have had much of this basic, core functionality (all around sensory capability) for decades

- a RAND defense analyst recently floated around the idea of a slow moving aircraft with large payload capabilities as an alternative to conventional fighter jets. It would actually render 5th gen fighters completely irrelevant if implemented correctly...

- I've been looking at the design of the PAK-FA slightly more closely and noticed how it had multi-band RADAR capabilities for various purposes. The thing which struck me was the updated R-77 capability whereby the jet provides information in unison with the missile's own internal targeting system. Even if one fails, the other system has enough redundancy to be able to potentially re-acquire a lock. Interestingly, if we think about this slightly what if we use the same idea in combination with jets and ships or jets and large RADAR. Updated information from longer wavelength RADAR in combination with the missiles' or jets' on targeting systems would allow for an increased chance of lock and reduced chances of being outwitted through decoys as well...

- modern rules of engagement may mean that visual identification may be necessary before a pilot can launch an attack rendering any BVR capabilities a moot point

- for a while now the defense and intelligence have used animals such as dolphins and sea lions for various purposes including recon as well as force proection. Something I've been curious about is whether or not we can use animals as radiators undersea as well as in the air... Think about this, if you are in a room with furniture and you scream it sounds different to if it were empty. It's the same if you scream in front of someone versus if you scream with nothing in front of you. If you can activate all animals in your surronding area (using beacons at abnormal frequencies or otherwise training them and attaching 'radiators' to them) to either create sound you can detect the presence of other objects in your immediate vicinity (without giving away your position as well). Roughly the same principle that allowed the detection and shooting down of the original F-117 stealth bomber

If you've ever worked with laptops (or any device) with dead batteries you've probably wondered about how to restore them to working condition...
Categories: thinktime

Arjen Lentz: Full Roof Cover Combining PV Solar and Heat |

Tue 01st Sep 2015 11:09

Bluescope unveils “world first” built-in solar array that generates electricity and heat, and acts as roofing.

Categories: thinktime

Ben Martin: Inspecting ODF round trips for attribute retention

Mon 31st Aug 2015 20:08
Given an office application one might like to know which attributes are preserved properly across a load and save cycle. For example, is the background color or margin size mutated just by loading and saving an ODF file with OfficeAppFoo version 0.1.

The odfautotests project includes many tests on simple ODF documents to see how well each office application preserves the information in the document. Though testing ODF attribute preservation might not be as simple as one might first imagine. Consider the below document with a single paragraph using a custom style:


  <text:p text:style-name="style">hello world</text:p>


In the styles.xml file one might see something like the following:






     <style:text-properties fo:background-color="transparent" />


This input is obviously designed to see how well the fo:background-color style information is preserved by office applications. One thing to notice is that the style:family attribute in the above is paragraph.

If one loads and saves a document with the above fragments in it using LibreOffice 4.3.x then they might see something like the following in the output ODF file. In content.xml:

<text:p text:style-name="TestStyle">hello world</text:p>

And in the styles.xml file the background-color attribute is preserved:

<style:style style:name="TestStyle"



      <style:text-properties fo:background-color="transparent"/>


One can test if the attribute has been preserved using XPath selecting on the @style-name of the text:p and then making sure that the matching style:style has the desired fo:background-color sub attribute.

The XPath might look something like the below, which has been formatted for display:



  or (not(@s:display-name) and @s:name='TestStyle')]


Performing the load and save using Word 2016 is quite interesting. The resulting content.xml file might have:

<style:style style:name="P1"




     <style:paragraph-properties fo:break-before="page"/>



<office:text text:use-soft-page-breaks="true">

  <text:p text:style-name="P1">hello world</text:p>


and in styles.xml the background-color setting is pushed up to the paragraph style level.

<style:style style:name="TestStyle"



      <style:text-properties fo:hyphenate="false"/>


<style:default-style style:family="paragraph">


<style:text-properties ... fo:background-color="transparent"

So to see if the output ODF has the fo:background-color setting one has to consider not just the directly used style "P1" but also parent style elements which might contain the attribute instead. In this case it was pushed right up to the paragraph style.

For the Word output the above XPath doesn't necessarily work. If the attribute we are looking for has been pushed up to paragraph then we should look for it there instead. Also, if we are looking at the paragraph level then we need to be sure that there is no attribute directly at the lower, TestStyle, level. Also it helps to ensure in the selection that the paragraph is really a parent of the TestStyle, or P1 in the above.

After a bit of pondering I found an interesting solution that can evaluate using plain XPath1.0. To test the value I pick off the fo:background-color from both the TestStyle and also the paragraph level. If those values are passed to concat() then, if the attribute is only at the TestStyle or paragraph level we get something that can be used to test the value. If the attribute appears at both levels are are in trouble.

For example:

<style:style style:name="TestStyle"

<style:text-properties ... fo:background-color="transparent"  />


<style:default-style style:family="paragraph">

<style:text-properties ... fo:background-color="#FF0000"/>


Considering the semantic XPath query of concat( TestStyle/@fo:background-color, paragraph/@fo:background-color ) the result would be  transparent#FF0000 which would not match a string comparison with 'transparent'.

The trick is to use an array selector on the second item in the concat() call. If we only return the paragraph/@fo:background-color value if there is no value associated with the TestStyle then the concat will effectively only return one or the other (directly on TestStyle or nothing on TestStyle and the attribute from paragraph).

With this the query can allow the office application to move the information to a parent of the style and still match for a test.

Categories: thinktime

Michael Still: Walk to the Southern Most Point

Mon 31st Aug 2015 17:08
I've just realized that I didn't post any pics of my walk to the most southern point of the ACT. The CBC had a planned walk to the southern most point on the ACT border and I was immediately intrigued. So, I took a day off work and gave it a go. It was well worth the experience, especially as Matthew the guide had a deep knowledge of the various huts and so forth in the area. A great day.


See more thumbnails

Interactive map for this route.

Tags for this post: blog pictures 20150818-southernmostpoint photo canberra bushwalk

Related posts: Goodwin trig; Big Monks; Geocaching; Confessions of a middle aged orienteering marker; A quick walk through Curtin; Narrabundah trig and 16 geocaches

Categories: thinktime

Tridge on UAVs: An awesome day at CMAC

Mon 31st Aug 2015 16:08

Anyone who has been involved in aeromodelling for a while dreams of having one of those days when everything works right. It doesn't happen often, but when it does it sure is nice!

CanberraUAV had one of those days yesterday. It was a wonderful sunny winters day at our local flying field and we were test flying our latest creations.

First up was the "Vampire Mark 2", a combined plane quadcopter built by Jack Pittar. It consists of a senior telemaster with a 15cc petrol engine, but with the addition of 4 quadcopter motors. It was the maiden flight yesterday, and it was setup with a Pixhawk controlling the quad engines and the rest controlled manually as a normal RC model. We flew with two pilots (Justin Galbraith and Jack Pittar). The takeoff was vertical as a quadcopter, and it then transitioned to fixed wing flight using the extremely simple method of advancing the throttle on the plane while lowering the throttle on the telemaster. Transition was very easy and the plane reached 31m/s in forward flight at full throttle. The landing transition was equally easy. Jack lowered the throttle on the plane while Justin raised the throttle on the quadcopter. No problems!

Given this was the first flight of a highly experimental aircraft we were pretty pleased with the result! Jack is thinking of building an even bigger version soon that will be able to complete the 2016 OBC mission with plenty of room for equipment.

Next up was our JS90 helicopter, originally built by Ryan Pope and adapted for autonomous flight.

This is the flybar version of the JS90-v2 heli from Hobbyking, with a OS GT15HZ petrol engine fitted, along with a Pixhawk2 and a new "Blue Label" Lidar from pulsedlight. We've been flying (and crashing!) this heli for a while now, but yesterday was finally the day when we got to try high speed autonomous flight.

apart from a small gap where we lost telemetry in the north west corner you can see the tracking in the auto mission was great. Once we learned how to tune a flybar heli (which turns out to be extremely simple!) it flies really well. We did have some issues getting it to fly as fast as we want. Above about 17m/s it occasionally pulled back and stopped for a second before continuing. We knew it could do more as it happily flew at over 27m/s in ALT_HOLD mode. With some help from Randy and a small code change to help with tuning we think we've tracked down the cause of that issue and expect to be doing 27m/s AUTO missions next weekend.

Next up was another quad plane, this one quite different from the big telemaster build!

We had been trying to track down a problem with loiter on the Parrot Bebop when running ArduPilot. We suspected there may have been a GPS lag issue, so we wanted to get some flight data that would allow us to compare the performance of a uBlox GPS with the GPS in the Bebop for dynamic flight. We thought a good way to do that would be to strap the Bebop to a plane and take it for a fly. The results were very interesting! For this flight we saw a lag on the Bebop GPS of over 5 seconds, which must be some sort of buffering issue. We'll chat to Julien from Parrot to see if we can track down the issue.

Next we thought it would be fun to see if something else could lift the tiny Bebop. Peter had his Solo there, so we strapped the Bebop to it and went for a fast fly in drift mode. Great fun!

Overall it was a fantastic day! Next week we're really looking forward to trying the Trex700 petrol conversion that Greg has built which you can see in the background in this photo of our build day on Saturday. The build looks really good and we expect it to perform even better than the JS90, as Greg has managed to fit a Pixhawk while still being able to install the canopy. That should reduce drag quite a lot.

The switch of focus for CanberraUAV to VTOL aircraft has been a lot of work, but the results are really paying off and we're having a lot of fun in the process. We hope that we'll have a lot more weekends like this one in the future.

Categories: thinktime

David Rowe: FreeDV SM1000 v SSB demo

Mon 31st Aug 2015 10:08

Great demo of FreeDV 1600 (SM1000 at one end) and SSB between AA6E and K5MVP. You can really notice the reduced audio bandwidth and ever present noise of SSB compared to FreeDV. This is just the start – we are gradually improving the low SNR robustness and speech quality of FreeDV. Thanks so much Martin for posting this.

I like watching the fading FreeDV signal. I think there is a “lowpass” effect on the signal – more power allocated to low frequency carriers. This may be due to the transmitter tx filter, or possibly the SM1000. FreeDV is only as good as the SNR of the weakest carrier. Ideally they should all be the same power. This is one of the “tuning” issues I’d like to look into over the next few months.

Categories: thinktime

Sridhar Dhanapalan: Twitter posts: 2015-08-24 to 2015-08-30

Mon 31st Aug 2015 00:08
Categories: thinktime

Francois Marier: Letting someone ssh into your laptop using Pagekite

Sun 30th Aug 2015 07:08

In order to investigate a bug I was running into, I recently had to give my colleague ssh access to my laptop behind a firewall. The easiest way I found to do this was to create an account for him on my laptop and setup a pagekite frontend on my Linode server and a pagekite backend on my laptop.

Frontend setup

Setting up my Linode server in order to make the ssh service accessible and proxy the traffic to my laptop was fairly straightforward.

First, I had to install the pagekite package (already in Debian and Ubuntu) and open up a port on my firewall by adding the following to both /etc/network/iptables.up.rules and /etc/network/ip6tables.up.rules:

-A INPUT -p tcp --dport 10022 -j ACCEPT

Then I created a new CNAME for my server in DNS: 3600 IN CNAME

With that in place, I started the pagekite frontend using this command:

pagekite --clean --isfrontend --rawports=virtual --ports=10022 Backend setup

After installing the pagekite and openssh-server packages on my laptop and creating a new user account:

adduser roc

I used this command to connect my laptop to the pagekite frontend:

pagekite --clean --service_on=raw/ Client setup

Finally, my colleague needed to add the folowing entry to ~/.ssh/config:

Host CheckHostIP no ProxyCommand /bin/nc -X connect -x %h:10022 %h %p

and install the netcat-openbsd package since other versions of netcat don't work.

On Fedora, we used netcat-openbsd-1.89 successfully, but this newer package may also work.

He was then able to ssh into my laptop via ssh

Making settings permanent

I was quite happy settings things up temporarily on the command-line, but it's also possible to persist these settings and to make both the pagekite frontend and backend start up automatically at boot. See the documentation for how to do this on Debian and Fedora.

Categories: thinktime

Stewart Smith: Running OPAL in qemu – the powernv platform

Fri 28th Aug 2015 13:08

Ben has a qemu tree up with some work-in-progress patches to qemu to support the PowerNV platform. This is the “bare metal” platform like you’d get on real POWER8 hardware running OPAL, and it allows us to use qemu like my previous post used the POWER8 Functional Simulator – to boot OpenPower firmware.

To build qemu for this, follow these steps:

apt-get -y install gcc python g++ pkg-config libz-dev libglib2.0-dev \ libpixman-1-dev libfdt-dev git git clone cd qemu ./configure --target-list=ppc64-softmmu make -j `grep -c processor /proc/cpuinfo`

This will leave you with a ppc64-softmmu/qemu-system-ppc64 binary. Once you’ve built your OpenPower firmware to run in a simulator, you can boot it!

Note that this qemu branch is under development, and is likely to move/change or even break.

I do it like this:

cd ~/op-build/output/images; # so skiboot.lid is in pwd ~/qemu/ppc64-softmmu/qemu-system-ppc64 -m 1G -M powernv \ -kernel zImage.epapr -nographic \ -cdrom ~/ubuntu-vivid-ppc64el-mini.iso

and this lets me test that we launch the Ubunut vivid installer correctly.

You can easily add other qemu options such as additional disks or networking and verify that it works correctly. This way, you can do development on some skiboot functionality or a variety of kernel and op-build userspace (such as the petitboot bootloader) without needing either real hardware or using the simulator.

This is useful if, say, you’re running on ppc64el, for which the POWER8 functional simulator is currently not available on.

Categories: thinktime

Stewart Smith: doing nothing on modern CPUs

Fri 28th Aug 2015 12:08

Sometimes you don’t want to do anything. This is understandably human, and probably a sign you should either relax or get up and do something.

For processors, you sometimes do actually want to do absolutely nothing. Often this will be while waiting for a lock. You want to do nothing until the lock is free, but you want to be quick about it, you want to start work once that lock is free as soon as possible.

On CPU cores with more than one thread (e.g. hyperthreading on Intel, SMT on POWER) you likely want to let the other threads have all of the resources of the core if you’re sitting there waiting for something.

So, what do you do? On x86 there’s been the PAUSE instruction for a while and on POWER there’s been the SMT priority instructions.

The x86 PAUSE instruction delays execution of the next instruction for some amount of time while on POWER each executing thread in a core has a priority and this is how chip resources are handed out (you can set different priorities using special no-op instructions as well as setting the Relative Priority Register to map how these coarse grained priorities are interpreted by the chip).

So, when you’re writing spinlock code (or similar, such as the implementation of mutexes in InnoDB) you want to check if the lock is free, and if not, spin for a bit, but at a lower priority than the code running in the other thread that’s doing actual work. The idea being that when you do finally acquire the lock, you bump your priority back up and go do actual work.

Usually, you don’t continually check the lock, you do a bit of nothing in between checking. This is so that when the lock is contended, you don’t just jam every thread in the system up with trying to read a single bit of memory.

So you need a trick to do nothing that the complier isn’t going to optimize away.

Current (well, MySQL 5.7.5, but it’s current in MariaDB 10.0.17+ too, and other MySQL versions) code in InnoDB to “do nothing” looks something like this:

ulint ut_delay(ulint delay) { ulint i, j; UT_LOW_PRIORITY_CPU(); j = 0; for (i = 0; i < delay * 50; i++) { j += i; UT_RELAX_CPU(); } if (ut_always_false) { ut_always_false = (ibool) j; } UT_RESUME_PRIORITY_CPU(); return(j); }

On x86, UT_RELAX_CPU() ends up being the PAUSE instruction.

On POWER, the UT_LOW_PRIORITY_CPU() and UT_RESUME_PRIORITY_CPU() tunes the SMT thread priority (and on x86 they’re defined as nothing).

If you want an idea of when this was all written, this comment may be a hint:

/*!< in: delay in microseconds on 100 MHz Pentium */

But, if you’re not on x86 you don’t have the PAUSE instruction, instead, you end up getting this code:

# elif defined(HAVE_ATOMIC_BUILTINS) # define UT_RELAX_CPU() do { \ volatile lint volatile_var; \ os_compare_and_swap_lint(&volatile_var, 0, 1); \ } while (0)

Which you may think “yep, that does nothing and is not optimized away by the compiler”. Except you’d be wrong! What it actually does is generates a lot of memory traffic. You’re now sitting in a tight loop doing atomic operations, which have to be synchronized between cores (and sockets) since there’s no real way that the hardware is going to be able to work out that this is only a local variable that is never accessed from anywhere.

Additionally, the ut_always_false and j variable there is also attempts to trick the complier into not optimizing the loop away, and since ut_always_false is a global, you’re generating traffic to a single global variable too.

Instead, what’s needed is a compiler barrier. This simple bit of nothing tells the compiler “pretend memory has changed, so you can’t optimize around this point”.

__asm__ __volatile__ ("":::"memory")

So we can eliminate all sorts of useless non-work and instead do what we want: do nothing (a for loop for X iterations that isn’t optimized away by the compiler) and don’t have side effects.

In MySQL bug 74832 I detailed this with the appropriately produced POWER assembler. Unfortunately, this patch (submitted under the OCA) has sat since November 2014 (so, over 9 months) with no action. I’m a bit disappointed by that to be honest.

Anyway, the real moral of this story is: don’t implement your own locking primitives. You’re either going to get it wrong or you’ll be wrong in a few years when everything changes under you.

See also:

Categories: thinktime

Donna Benjamin: D8 Accelerate - Game over?

Thu 27th Aug 2015 11:08
Thursday, August 27, 2015 - 10:47

The Drupal 8 Accelerate campaign has raised over two hundred and thirty thousand dollars ($233,519!!).  That's a lot of money! But our goal was to raise US$250,000 and we're running out of time. I've personally helped raise $12,500 and I'm aiming to raise 8% of the whole amount, which equals $20,000. I've got less than $7500 now to raise. Can you help me? Please chip in.

Most of my colleagues on the board have contributed anchor funding via their companies. As a micro-enterprise, my company Creative Contingencies is not in a position to be able to that, so I set out to crowdfund my share of the fundraising effort.

I'd really like to shout out and thank EVERYONE who has made a contribution to get me this far.Whether you donated cash, or helped to amplify my voice, thank you SO so soooo much. I am deeply grateful for your support.

If you can't, or don't want to contribute because you do enough for Drupal that's OK! I completely understand. You're awesome. :) But perhaps you know someone else who is using Drupal, who will be using Drupal you could ask to help us? Do you know someone or an organisation who gets untold value from the effort of our global community? Please ask them, on my behalf, to Make a Donation

If you don't know anyone, perhaps you can help simply by sharing my plea? I'd love that help. I really would!

And if you, like some others I've spoken with, don't think people should be paid to make Free Software then I urge you to read Ashe Dryden's piece on the ethics of unpaid labor in the Open Source Community. It made me think again.

Do you want to know more about how the money is being spent? 


Perhaps you want to find out how to apply to spend it on getting Drupal8 done?


Are you curious about the governance of the program?


And just once more, with feeling, I ask you to please consider making a donation.

So how much more do I need to get it done? To get to GAME OVER?

  • 1 donation x $7500 = game over!
  • 3 donations x $2500
  • 5 donations x $1500
  • 10 donations x $750
  • 15 donationsx $500 <== average donation
  • 75 donations x $100 <== most common donation
  • 100 donations x $75
  • 150 donations x $50
  • 500 donations x $15
  • 750 donations x $10 <== minimum donation

Thank you for reading this far. Really :-)

Categories: thinktime

James Morris: Linux Security Summit 2015 – Wrapup, slides

Thu 27th Aug 2015 05:08

The slides for all of the presentations at last week’s Linux Security Summit are now available at the schedule page.

Thanks to all of those who participated, and to all the events folk at Linux Foundation, who handle the logistics for us each year, so we can focus on the event itself.

As with the previous year, we followed a two-day format, with most of the refereed presentations on the first day, with more of a developer focus on the second day.  We had good attendance, and also this year had participants from a wider field than the more typical kernel security developer group.  We hope to continue expanding the scope of participation next year, as it’s a good opportunity for people from different areas of security, and FOSS, to get together and learn from each other.  This was the first year, for example, that we had a presentation on Incident Response, thanks to Sean Gillespie who presented on GRR, a live remote forensics tool initially developed at Google.

The keynote by sysadmin, Konstantin Ryabitsev, was another highlight, one of the best talks I’ve seen at any conference.

Overall, it seems the adoption of Linux kernel security features is increasing rapidly, especially via mobile devices and IoT, where we now have billions of Linux deployments out there, connected to everything else.  It’s interesting to see SELinux increasingly play a role here, on the Android platform, in protecting user privacy, as highlighted in Jeffrey Vander Stoep’s presentation on whitelisting ioctls.  Apparently, some major corporate app vendors, who were not named, have been secretly tracking users via hardware MAC addresses, obtained via ioctl.

We’re also seeing a lot of deployment activity around platform Integrity, including TPMs, secure boot and other integrity management schemes.  It’s gratifying to see the work our community has been doing in the kernel security/ tree being used in so many different ways to help solve large scale security and privacy problems.  Many of us have been working for 10 years or more on our various projects  — it seems to take about that long for a major security feature to mature.

One area, though, that I feel we need significantly more work, is in kernel self-protection, to harden the kernel against coding flaws from being exploited.  I’m hoping that we can find ways to work with the security research community on incorporating more hardening into the mainline kernel.  I’ve proposed this as a topic for the upcoming Kernel Summit, as we need buy-in from core kernel developers.  I hope we’ll have topics to cover on this, then, at next year’s LSS.

We overlapped with Linux Plumbers, so LWN was not able to provide any coverage of the summit.  Paul Moore, however, has published an excellent write-up on his blog. Thanks, Paul!

The committee would appreciate feedback on the event, so we can make it even better for next year.  We may be contacted via email per the contact info at the bottom of the event page.

Categories: thinktime

BlueHackers: The Legacy of Autism and the Future of Neurodiversity

Tue 25th Aug 2015 09:08

The New York Times published an interesting review of a book entitled “NeuroTribes: The Legacy of Autism and the Future of Neurodiversity”, authored by Steve Silberman (534 pp. Avery/Penguin Random House).

Silberman describes how autism was discovered by a few different people around the same time, but with each the publicity around their work is warped by their environment and political situation.

This means that we mainly know the angle that one of the people took, which in turn warps our view of Aspergers and autism. Ironically, the lesser known story is actually that of Hans Asperger.

I reckon it’s an interesting read.

Categories: thinktime

James Purser: Mark got a booboo

Mon 24th Aug 2015 23:08

Mark Latham losing his AFR column because an advertiser thought his abusive tweets and articles weren't worth being associated with isn't actually a freedom of speech issue.

Nope, not even close to it.

Do you know why?


No one is stopping Latho from spouting his particular brand of down home "outer suburban dad" brand of putresence.

Hell, all he has to do to get back up and running is go and setup a wordpress account and he can be back emptying his bile duct on the internet along with the rest of us who don't get cushy newspaper jobs because we managed to completely screw over our political career in a most spectacular way

Hey, he could setup a Patreon account and everyone who wants to can support him directly, either monthly sub, or a per flatulence rate.

This whole thing reeks of a massive sense of entitlement, both with Latho himself and his media supporters. Bolt, Devine and others who have lept to his defence all push this idea that any move to expose writers to consequences arising from their rantings is some sort of mortal offense against democracy and freedom. Of course, while they do this, they demand the scalps of anyone who dares to write abusive rants against their own positions.


Oh and as I've been reminded, Australia doesn't actually have Freedom of Speech as they do in the US.

Blog Catagories: media
Categories: thinktime

David Rowe: Dual Rav 4 SM1000 Installation

Mon 24th Aug 2015 15:08

Andy VK5AKH, and Mark VK5QI, have mirror image SM1000 mobile installations, same radio, even the same car! Some good lessons learned on testing and debugging microphone levels that will be useful for other people installing their SM1000. Read all about it on Mark’s fine blog.

Categories: thinktime

David Rowe: Codec 2 Masking Model Part 1

Mon 24th Aug 2015 11:08

Many speech codecs use Linear Predictive Coding (LPC) to model the short term speech spectrum. For very low bit rate codecs, most of the bit rate is allocated to this information.

While working on the 700 bit/s version of Codec 2 I hit a few problems with LPC and started thinking about alternatives based on the masking properties of the human ear. I’ve written Octave code to prototype these ideas.

I’ve spent about 2 weeks on this so far, so thought I better write it up. Helps me clarify my thoughts. This is hard work for me. Many of the steps below took several days of scratching on paper and procrastinating. The human mind can only hold so many pieces of information. So it’s like a puzzle with too many pieces missing. The trick is to find a way in, a simple step that gets you a working algorithm that is a little bit closer to your goal. Like evolution, each small change needs to be viable. You need to build a gentle ramp up Mount Improbable.

Problems with LPC

We perceive speech based on the position of peaks in the speech spectrum. These peaks are called formants. To clearly perceive speech the formants need to be distinct, e.g. two peaks with a low level (anti-formant) region between them.

LPC is not very good at modeling anti-formants, the space between formants. As it is an all pole model, it can only explicitly model peaks in the speech spectrum. This can lead to unwanted energy in the anti-formants which makes speech sound muffled and hard to understand. The Codec 2 LPC postfilter improves the quality of the decoded speech by suppressing interformant-energy.

LPC attempts to model spectral slope and other features of the speech spectrum which are not important for speech perception. For example “flat”, high pass or low pass filtered speech is equally easy for us to understand. We can pass speech through a Q=1 bandpass or notch filter and it will still sound OK. However LPC wastes bits on these features, and get’s into trouble with large spectral slope.

LPC has trouble with high pitched speakers where it tends to model individual pitch harmonics rather than formants.

LPC is based on “designing” a filter to minimise mean square error rather than the properties of the human ear. For example it works on a linear frequency axis rather than log frequency like the human ear. This means it tends to allocates bits evenly across frequency, whereas an allocation weighted towards low frequencies would be more sensible. LPC often produces large errors near DC, an important area of human speech perception.

LPC puts significant information into the bandwidth of filters or width of formants, however due to masking the ear is not very sensitive to formant bandwidth. What is more important is sharp definition of the formant and anti-formant regions.

So I started thinking about a spectral envelope model with these properties:

  1. Specifies the location of formants with just 3 or 4 frequencies. Focuses on good formant definition, not the bandwidth of formants.
  2. Doesn’t care much about the relative amplitude of formants (spectral slope). This can be coarsely quantised or just hard coded using, e.g. voiced speech has a natural low pass spectral slope.
  3. Works in the log amplitude and log frequency domains.

Auditory Masking

Auditory masking refers to the “capture effect” of the human ear, a bit like an FM receiver. If you hear a strong tone, then you cant hear slightly weaker tones nearby. The weaker ones are masked. If you can’t hear these masked tones, there is no point sending them to the decoder. So we can save some bits. Masking is often used in (relatively) high bit rate audio codecs like MP3.

I found some Octave code for generating masking curves (Thanks Jon!), and went to work applying masking to Codec 2 amplitude modelling.

Masking in Action

Here are some plots to show how it works. Lets take a look at frame 83 from hts2a, a female speaker. First, 40ms of the input speech:

Now the same frame in the frequency domain:

The blue line is the speech spectrum, the red the amplitude samples {Am}, one for each harmonic. It’s these samples we would like to send to the decoder. The goal is to encode them efficiently. They form a spectral envelope, that describes the speech being articulated.

OK so lets look at the effect of masking. Here is the masking curve for a single harmonic (m=3, the highest one):

Masking theory says we can’t hear any harmonics beneath the level of this curve. This means we don’t need to send them over the channel and can save bits. Yayyyyyy.

Now lets plot the masking curves for all harmonics:

Wow, that’s a bit busy and hard to understand. Instead, lets just plot the top of all the masking curves (green):

Better. We can see that the entire masking curve is dominated by just a few harmonics. I’ve marked the frequencies of the harmonics that matter with black crosses. We can’t really hear the contribution from other harmonics. The two crosses near 1500Hz can probably be tossed away as they just describe the bottom of an anti-formant region. So that leaves us with just three samples to describe the entire speech spectrum. That’s very efficient, and worth investigating further.

Spectral Slope and Coding Quality

Some speech signals have a strong “low pass filter” slope between 0 an 4000Hz. Others have a “flat” spectrum – the high frequencies are about the same level as low frequencies.

Notice how the high frequency harmonics spread their masking down to lower frequencies? Now imagine we bumped up the level of the high frequency harmonics, e.g. with a first order high pass filter. Their masks would then rise, masking more low frequency harmonics, e.g. those near 1500Hz in the example above. Which means we could toss the masked harmonics away, and not send them to the decoder. Neat. Only down side is the speech would sound a bit high pass filtered. That’s no problem as long as it’s intelligible. This is an analog HF radio SSB replacement, not Hi-Fi.

This also explains why “flat” samples (hts1a, ve9qrp) with relatively less spectral slope code well, whereas others (kristoff, cq_ref) with a strong spectral slope are harder to code. Flat speech has improved masking, leaving less perceptually important information to model and code.

This is consistent with what I have heard about other low bit rate codecs. They often employ pre-processing such as equalisation to make the speech signal code better.

Putting Masking to work

Speech compression is the art of throwing stuff away. So how can we use this masking model to compress the speech? What can we throw away? Well lets start by assuming only the samples with the black crosses matter. This means we get to toss quite a bit of information away. This is good. We only have to transmit a subset of {Am}. How I’m not sure yet. Never mind that for now. At the decoder, we need to synthesise the speech, just from the black crosses. Hopefully it won’t sound like crap. Let’s work on that for now, and see if we are getting anywhere.

Attempt 1: Lets toss away any harmonics that have a smaller amplitude than the mask (Listen). Hmm, that sounds interesting! Apart from not being very good, I can hear a tinkling sound, like trickling water. I suspect (but haven’t proved) this is because harmonics are coming and going quickly as the masking model puts them above and below the mask, which makes them come and go quickly. Little packets of sine waves. I’ve heard similar sounds on other codecs when they are nearing their limits.

Attempt 2: OK, so how about we set the amplitude of all harmonics to exactly the mask level (Listen): Hmmm, sounds a bit artificial and muffled. Now I’ve learned that muffled means the formants are not well formed. Needs more difference between the formats and anti-formant regions. I guess this makes sense if all samples are exactly on the masking curve – we can just hear ALL of them. The LPC post filter I developed a few years ago increased the definition of formants, which had a big impact on speech quality. So lets try….

Attempt 3: Rather than deleting any harmonics beneath the mask, lets reduce their level a bit. That way we won’t get tinkling – harmonics will always be there rather than coming and going. We can use the mask instead of the LPC post filter to know which harmonics we need to attenuate (Listen).

That’s better! Close enough to using the original {Am} (Listen), however with lots of information removed.

For comparison here is Codec 2 700B (Listen and Codec 2 1300 (aka FreeDV 1600 when we add FEC) Listen. This is the best I’ve done with LPC/LSP to date.

The post filter algorithm is very simple. I set the harmonic magnitudes to the mask (green line), then boost only the non-masked harmonics (black crosses) by 6dB. Here is a plot of the original harmonics (red), and the version (green) I mangle with my model and send to the decoder for synthesis:

Here is a spectrogram (thanks Audacity) for Attempt 1, 2, and 3 for the first 1.6 seconds (“The navy attacked the big”). You can see the clearer formant representation with Attempt 3, compared to Attempt 2 (lower inter-formant energy), and the effect of the post filter (dark line in center of formants).

Command Line Kung Fu

If you want to play along:

~/codec2-dev/build_linux/src$ ./c2sim ../../raw/kristoff.raw --dump kristoff


octave:49> newamp_batch("../build_linux/src/kristoff");


~/codec2-dev/build_linux/src$ ./c2sim ../../raw/kristoff.raw --amread kristoff_am.out -o - | play -t raw -r 8000 -e signed-integer -b 16 - -q

The “newamp_fbf” script lets you single step through frames.


To synthesise the speech at the decoder I also need to come up with a phase for each harmonic. Phase and speech is still a bit of a mystery to me. Not sure what to do here. In the zero phase model, I sampled the phase of the LPC synthesis filter. However I don’t have one of them any more.

Lets think about what the LPC filter does with the phase. We know at resonance phase shifts rapidly:

The sharper the resonance the faster it swings. This has the effect of dispersing the energy in the pitch pulse exciting the filter.

So with the masking model I could just choose the center of each resonance, and swing the phase about madly. I know where the center of each resonance is, as we found that with the masking model.

Next Steps

The core idea is to apply a masking model to the set of harmonic magnitudes {Am} and select just 3-4 samples of that set that define the mask. At the decoder we use the masking model and a simple post filter to reconstruct a set of {Am_} that we use to synthesise the decoded speech.

Still a few problems to solve, however I think this masking model holds some promise for high quality speech at low bit rates. As it’s completely different to conventional LPC/LSP I’m flying blind. However the pieces are falling into place.

I’m currently working on i) how to reduce the number of samples to a low number ii) how to determine which ones we really need (e.g. discarding interformant samples); and iii) how to represent the amplitude of each sample with a low or zero number of bits. There are also some artifacts with background noise and chunks of spectrum coming and going.

I’m pretty sure the frequencies of the samples can be quantised coarsely, say 3 bits each using scalar quantisation, or perhaps 8 bit/s frame using VQ. There will also be quite a bit of correlation between the amplitudes and frequencies of each sample.

For voiced speech there will be a downwards (low pass) slope in the amplitudes, for unvoiced speech more energy at high frequencies. This suggests joint VQ of the sample frequencies and amplitudes might be useful.

The frequency and amplitude of the mask samples will be highly correlated in time (small frame to frame variations) so will have good robustness to bit errors if we apply trellis decoding techniques. Compared to LPC/LSP the bandwidth of formants is “hard coded” by the masking curves, so the dreaded LSPs-too-close due to bit errors R2D2 noises might be a thing of the past. I’ll explore robustness to bit errors when we get to the fully quantised stage.

Categories: thinktime

Sridhar Dhanapalan: Twitter posts: 2015-08-17 to 2015-08-23

Mon 24th Aug 2015 00:08
Categories: thinktime