February 28th, 2011 @ 23:28

Some of the non-security things that impressed me most at past Chaos Communication Congresses were the Project BlinkenLights-like talks, where buildings were transformed into large-scale pixel screens, enabling random users to control a light matrix spread over the whole surface of the building. From the original monochromatic setups in Berlin, Paris and Toronto to the RGB AllColorsAreBeautiful project in Munich, things have evolved quite a lot, and documentation about how the whole things are done is emerging.

This is why we, at hackEns, started working towards setting up such an installation on one of the fronts of our school dormitories in Montrouge, France (right outside Paris). The first step was obviously to design a working module to lighten each window, producing enough light intensity to do something impressive while still remaining cheap enough to deploy over the whole building (which is basically 6 floors with 8 windows on each floor, so 48 modules altogether). Let’s note that due to the specific structure of the building, our best call is to put the lights outside on the floor of the small balconies we have, as opposed to the previously mentioned projects where the lights were on the inside of the buildings.

Here is how the current module performs :

The module is remotely controlled from my laptop, which is connected to another computer through ssh, which is itself connected through an USB-to-serial wire to a RS485 transceiver which dispatches the commands to the light modules on the bus.
Our current control scheme is to use a tiny PIC10F per window to control each color component through PWM (given the output power of the LEDs, we actually use some transistors in the middle to do the power amplification). The PIC receives its orders on the RS485 bus. Note that since RS485 is limited to 32 receivers, we will actually use 2 RS485 buses with 24 receivers on each bus. The protocol we use on RS485 is quite simple, basically mentioning on a few bytes the module identifier and the three R/G/B components, with a few extra details for correct synchronization.

We tested a bunch of various high power LEDs, from simple 5mm high power LEDs to 3W StarLEDs through some very nice SuperFlux LEDs. Each kind of LEDs had its pros and cons, let’s list a few. The simple ones were really too direction, with a viewing angle of about 15°, so that it is almost impossible to melt the red/blue/green colors into something else. The superflux ones were pretty cool, produced quite nice melted colors, but were really not powerful enough (especially on the red side) so that we would need something between 5 or 10 of them to do something cool, leading to a lot of extra issues and requiring a lot more of PCB space. The StarLEDs are definitely the best on most aspects, a single StarLED produces awesomely bright colors, and a simple sheet of bakery paper is enough to ensure perfect color melting (which is already pretty good, except on the borders of the lightning area, due to the 3 single-color LEDs inside the StarLED being 0.5mm or so away of each other). The only issue with the StarLEDs is that they consume a lot of current, being powered at about 3V/1A. This leads to power supply and security issues, since we do not want to have wires with 50 amps running all over the front of the building. We intend to solve this issue by splitting the power supply scheme into a tree (with one or two branches per floor) and by powering each floor with higher voltages and lowering them to 12V or 5V with a switched-mode power supply on each floor.

The next milestones are to evaluate some cheap StarLEDs from Hong Kong, then to produce a prototype PCB and then to scale up to the building.

There are still a few issues right now, namely the fact that we need to find a cheap way to enclose our hardware to make the whole thing weatherproof, the fact that we need to get the approval of all the people living behind the windows we want to lighten, the approval of our lovely administration, and we need to find the money to find it. While the first three issues are pretty much a matter of time, any help on the financial side is obviously welcome. More specifically, if you know a company which could either provide financial support or hardware support (especially on the StarLED side, which are about 12 euros per LED, and which make it for more than 90% of the project budget), your help is more than welcome.

February 16th, 2011 @ 12:18

Yesterday we at hackEns received our BeagleBoard-xM, ordered from DigiKey during FOSDEM. Let’s first note for French people interested in getting such boards from DigiKey that we had to pay 39.15€ of VAT and similar fees to the UPS guy upon delivery. Now let’s move onto some context and tips about getting it to run.

The BeagleBoard-xM is a 8.25×8.25 cm board, powered by an ARM Cortex A8 CPU and relying on 512MB of RAM. It features, among other things, a microSD slot, a serial port, an ethernet port, an HDMI output, a S-Video port, 4 USB-A ports, 1 miniUSB OTG port and stereo input/output. There is basically all you need to build a simple desktop computer. Just plug in an USB keyboard, an USB mouse, an RJ-45 wire and your HDMI wire and boot it. Well, almost.

Before being able to run anything useful, you have to first power the board and then build a microSD card with an useful distribution on it.

First tip : connect your BeagleBoard-xM to your computer through the serial port. Buy an usb-to-serial adapter if needed, buy the serial wire if needed, but do not try to get things working blindly. You definitely won’t be able to debug any bootloader problem without a working serial link, and you’ll most likely waste much more time than you’d need to go to your local hardware shop and buy the required bits.

Now, let’s insert the provided microSD card into the slot, and move on.

TL;DR here : don’t try to power your BeagleBoard using USB OTG, use a regulated 5V DC power supply instead
Powering the board might seem easy, given that there is an USB OTG slot through which you can definitely feed power to the board to get it running (LEDs blinking), but there are two caveats. The first issue is that a single USB host port cannot supply enough power to the board to get it running smoothly. The most obvious symptom of this problem is that the board simply won’t boot (the bootloader will load the ramdisk and uncompress the kernel and hang there, or it might even start the bootsequence but will fail at some point with no obvious reason, or it might even reach the second issue, but even without the second issue it won’t be able to finish the bootsequence). As advised on some forums, you can use a Y-shaped USB wire like those you can get for 2.5″ USB external hard drives. This will enable you to give enough power to feed the BeagleBoard.
Yet, you will still encounter the second problem, which is that the kernel will panic at some point during the bootsequence, exhibiting a problem somewhere inside a musb_interrupt call. This seems to be because of a bug in the OTG module of the kernel used on the test system, which makes it impossible to boot with something plugged into the USB OTG port, so you’ll have to power your BeagleBoard using an external 5V power supply. We used a 2 amp regulated DC power supply for that purpose. Since it could only deliver 4.5V and 6V outputs, we had to use a 5V/1amp voltage regulator.

We were then able to boot on the test system, got a nice prompted, logged on, assessed the fact that we had a basic system, ran the mandatory testled tool, and halted to move on to the second part : setting up a complete system.

This is where the fun really begins, because most howtos are about the original BeagleBoard (non -xM), especially on the eLinux wiki, and that can be quite confusing. We’ll use Ångström distribution, which is a simple GNU/Linux distro targetted at embedded hardware, such as the BeagleBoard. This choice was made based on the fact that the Debian ARM packages are compiled for a more generic kind of ARM CPUs, on the fact that the current Ubuntu poorly performs on BeagleBoard-xM (it does not fully support the board’s CPU and downclocks it badly), and that the other competitors (Android, Maemo/Mer, Meego) did not look that great.

Basically, all you have to do to setup the microSD card is to follow the excellent instructions from Trey Weaver, with a few extra tips.

First, to be on the safe side, you can get all the files you need from the Ångström BeagleBoard demo fileserver : mkcard.txt, MLO, u-boot.bin, uImage, modules.tgz and the Angstrom-Beagleboard….tar.bz2 rootfs. You do not need to go through Narcissus.

Next, make SURE that the first file you copy to the boot filesystem is MLO, otherwise it won’t be able to boot (the bootloader has to be the very first bytes of the filesystem).

Next, when looking at other howtos, ignore all the bits about pressing the USER button, or about halting the autoboot to set the bootloader options : you do not need either. Indeed, the BeagleBoard-xM has no NAND flash to store the bootloader options, so doing the saveenv command of the bootloader will just make it hang. Instead, if you want to specify your own bootloader options, you have to produce a boot.scr file. To do so, install the mkimage tool (it’s packaged in debian and ubuntu as uboot-mkimage, it originally comes from OpenWRT bootloader u-boot which we use here). Then create a file (let’s call it boot_cmd for instance) containing the boot commands you want ; a basic command file is the following :
setenv bootargs 'console=ttyS2,115200n8 root=/dev/mmcblk0p2 rootfstype=ext3 rootwait'
mmc init
fatload mmc 0 0x80300000 uImage
bootm 0x80300000
Build the boot.scr file from it :
mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n "Beagleboard-xM boot script" -d boot_cmd boot.scr
Now all you have to do is to copy boot.scr to the boot partition (i.e. alongside the MLO, u-boot.bin & uImage files) and reset your BeagleBoard.
This can be useful to specify the video mode to use, for instance I use the following bootargs to get correct rendering on my LCD :
setenv bootargs 'console=ttyS2,115200n8 omapfb.mode=dvi:1360x768MR-16@60 root=/dev/mmcblk0p2 rootfstype=ext3 rootwait'

You should now be able to put your microSD into your BeagleBoard and get it running fully (I have a few initial hiccups with the microSD not being recognized or so at this point, I just moved it back and forth to my laptop and it worked beautifully since then). You should get a working GNOME environment (after a nice gdm prompt).

Let’s note that Ångström uses opkg package manager, which works in a pretty straightforward way, with install/remove/update/upgrade commands. Note that you have to use the list command to search packages, i.e. you need to do opkg list opencv to look for opencv-related packages, and not opkg search opencv as you would do with apt.

I was very pleased to see that opencv was installed by default (I guess, or at least I did not have to install it after performing an initial opkg upgrade), that my Logitech webcam was recognized from scratch and that I could use mplayer tv:// without any more tinkering to use it.
The current image does not come with a build chain, so you have to install the required bits to build your own apps. I believe all you need is to install the task-native-sdk package to get everything (gcc, g++, make, binutils…) setup. I guess I only had to install git, vim,pkgconfig and cmake by hand to feel home once that was done.

I am now investigating some issues related to building stuff using OpenCV, similar to those described here on Stack Overflow. I’ll keep you updated.

February 16th, 2011 @ 10:16

Once again, after months of silence, it’s about time to break it. Since the last post I left the USA after about 6 months there, thousands of miles travelled, dozens of burgers and subs eaten and hundreds of hours working there (being quite nostalgic those days, I guess I’ll post a lot more on this soonish, probably through a large overview of all the places I visited while in the US). I was quite happy to come back to France close to my family, as well as to get back to school.

The school season started extremely fine with a lot of motivation from a few friends and I about getting a robot built for the next Eurobot French national contest. Soon after, another guy announced his will to create a hackerspace inside the school, quickly gathering a lot of interest from other students. We soon founded hackEns, a hacking group with various goals, from getting a Fab Lab running with the required tools and a RepRap 3D printer to building musical instruments from leftover wood pieces, through building our robot, hacking a PS-2 keylogger or fixing the broken light & sound hardware lying around. We even have a place (well, it’s in the school’s basement) where we can freely work.

Months later, the group is definitely not dead. We hosted the build of a Huxley RepRap of two artists from a nearby school, our own Mendel RepRap is almost done, our robot is nearing the prototyping step and we have a few new projects in line, from building a RC car with a thermal engine to setting up a Blinkenlights-like project on one of our school’s dormitories. I’ll try to cover our latest activities and findings over time. Keep posted, it’s gonna be legen… wait for it… dary !

July 30th, 2010 @ 05:51

While sorting my pictures this evening, I was wondering how much pictures I captured with my EOS 450D camera since I got it. I knew (thanks to a doc about flashes I read a few days ago) that was I was looking for was the shutter actuation count of the camera.
Googling pointed me to a bunch of Windows or OSX related links, such as the nontheless nice 40D Shutter Count software, or pointers to exiftool, which did not work with the pictures taken on my 450D.
I then remembered the greatness of gphoto2 and gave it a shot.

  • Plugged the camera through USB, restarted it
  • Checked that it was detected with gphoto2 --auto-detect
  • Checked the capabilities with gphoto2 -a
  • Looked at the config options with gphoto2 --list-options
  • Found the /main/status/shuttercounter option
  • Ran gphoto2 --get-config=/main/status/shuttercounter
  • And here it is : 27781 shutter actuations

That number seems quite reliable, since I can have about 15000 of those pictures on my hard drive disks and I used to drop about 2 pics on 3 in my early days (I’m a lot softer on the shutter now, after experiencing the joys of picture sorting :p ).

Good to know I’m still far from the 100.000 actuations expected shutter life for 450D’s.

Well, thanks gphoto2 for your simplicity !

July 22nd, 2010 @ 01:18

A school friend, namely p4bl0, mentioned the idea of maintaining blog posts with git and a set of hooks which would produce the blog html from the contents of the repo. I loved the idea, but thought I could push it a little further : a blog engine which would use no other storage than git, with the post subject and contents being the commit message subject and contents. A post-commit or post-receive hook then produces the html. As simple as that !

You can find the source in BloGit git repo, and see an example at BloGit example. To use the source, you first have to pack it (using the pack script), which will merge the raw_post and raw_produce, producing a single post script (which I also included at the end of this post), which you can simply put in an empty directory and run it. It will unpack the other script (produce), initialize the git repo, and set the hooks. It’ll then prompt you for your post title and then open an editor for you to set your post contents. Save the file, and you’re done with your first post : check the index.html file which has been produced in the same directory. You can write your own stylesheet in the blogit-style.css file. Further posts can be done with the same post script.

Yet, the best way is probably just to use the usual git workflow. To initialize the repo and all, run post --unpack, and to post post --raw or git commit --allow-empty (when using git commit, leave a blank line between the subject line and the rest of the post). You can also amend existing commits (using git commit --amend), use the GIT_AUTHOR_* environment variables to change the author, and so on. Since merge commits are skipped by the html generator, it should work just great for multi author blogging !

PS : I know this is JUST a git log pretty printer, and that the whole thing is pretty much trivial. I also know that using versionned files to store the posts would allow a lot of extra bonuses (such as automatically adding “Updated on …” mentions based on the commit log of each single file). I just thought the idea was fun :p There are probably a lot of things to improve, or a lot of smart git features to use there that I overlooked. Feel free to leave a line :)

Read the rest of this entry »

July 16th, 2010 @ 05:46

Since Thunderbird 3 (or maybe before that), when you encounter an invalid SSL certificate, the GUI doesn’t even offer you to add an exception as in Firefox. Counter-intuitively, the same GUI than in Firefox is actually, available you just have to dig it through the menus. Here is a step-by-step tutorial with screenshots (had to do them for a doc, thought I’d share).

Go to Account Settings

In Security menu select View Certificates (alternatively, you can get there through Edit, Preferences, Advanced, Certificates, View Certificates if you have no Security menu here)

In Servers tab, hit Add Exception

Enter the address:port of the service you are using (without any protocol://) and hit Get Certificate

Hit Confirm Security Exception, and you're done !

July 14th, 2010 @ 23:29

TLDR : directly skip to the last paragraph

For a few weeks now a couple of friends and I have been working on a media player for Maemo 5 with some extra bonuses (mostly track scoring and track prediction). Now that we have something pretty much functional, I was willing to produce some .deb packages for easy installation. I knew it wouldn’t be an easy task — and it definitely wasn’t.

Since I had no Scratchbox setup in the first place (64 bits distro, etc.), I first tried the py2deb/PyPackager approach, which let’s you create .deb packages directly on the tablet for python apps. Sadly, this approach requires you to sort your source tree in a very strict manner, which is as it will be on the device. Since I plan to rebuild my package often and I don’t want to work in an uglily organized environment, this is not the solution.

I thus set a debian virtualbox and installed Scratchbox on it, and tried to use a very simple cdbs build system, using python-distutils.mk (I already had a distutils build system working), and then building the .deb with dpkg-buildpackage. Sadly, for an unknown reason (to me) this was putting the python libs into /var/lib/pyshared/, which is definitely not in the n900 PYTHON_PATH, plus the package did not include the empty __init__.py files in the packages (it seems they were removed by python-support which is used by python-distutils.mk and are meant to be reconstructed upon install, though they weren’t), which lead to a completely broken package.

The next attempt I made was to use sbdmock, which is used by the official maemo.org autobuilder. Sadly, while it was successfully building other packages, it never succeeded at building my package because “pyversions”, which is required by python-distutils.mk, was missing (seems this is a known problem — though this might actually be fixed now and I might just be lacking the right builddep).

Instead of try to do it right, I should probably have done it fast. Since I’m using a debian-based distribution on my laptop, all I had to do was :

  • Install python2.5 in the right prefix (/usr), restore the /usr/bin/python symlink to python2.6
  • Write a simple homemade debian/rules file which runs distutils and then sorts everything to the right package prefix (this is actually even easier if you only have one package since there is no sorting involved ; I included a sample one at the end of the post)
  • Specify Architecture: all in debian/control (since this is a full python package, it should run on any platform)
  • Run dpkg-buildpackage. Enjoy !

Let’s note that there is something called stdeb which might be easier than this process. Too bad I only found it now :sad:

Read the rest of this entry »

July 9th, 2010 @ 20:14

For months I have been having (temporary) freezes upon X/gdm login, sometimes even before that, lasting anywhere between 1 and 5 minutes (that’s on my Dell Latitude E4200). Actually, I could still move the cursor, and at times a panel widget would refresh, but nothing else. Logging on a tty and running top would show X.org eating 100% CPU (pretty much expected actually). Investigations of /var/log/Xorg.0.log revealed that X was continuously doing EDID probing because of an unknown TV1 monitor, while dmesg confirmed that something was going on with that mysterious TV1 output :
[ 12.924] (II) intel(0): Printing probed modes for output TV1
[ 15.065] (II) intel(0): Printing probed modes for output TV1
[ 15.477] (II) intel(0): Printing probed modes for output TV1
[ 15.892] (II) intel(0): Printing probed modes for output TV1
...

[drm] TV-1: set mode NTSC 480i 0
[drm] TV-1: set mode NTSC 480i 0
[drm] TV-1: set mode NTSC 480i 0
...

After spending quite a bunch of time trying to tell X to just ignore, I took the easy way and… switched to Ubuntu. But yesterday, I asked drago01 (maintainer of Compiz packages in Fedora) about the issue, and he immediately recognised the problem, calling it the “Ghost TV problem”. According to him and Adam Jackson (ajax), this is a screw up from hardware vendors. The graphics chipset thinks there is that TV plugged while there is definitely none.

Anyway, he also pointed me to the fix. 4 lines in xorg.conf and you’re done (this is actually my whole xorg.conf :p )

Section "Monitor"
Identifier "TV1"
Option "Ignore" "1"
EndSection

April 23rd, 2010 @ 08:08

While surfing and jumping from link to link, I stumbled upon The Real Costs of “Free” Search Site Services. While the global idea of the article holds a point, I guess that the emphasis is definitely not put on the right parts.

The bold parts are all about the money that gets wasted by ads on a free web service. Let’s review the initial assertions and the conclusion :

For a company employing 10,000 people with an average loaded cost of $50/hour

Users would thus waste 1 hour and 34 minutes

In total, the cost of having employees look at and occasionally click on distractions costs the company $1.2 million per year.

What’s wrong here ? Well, first I guess that the main problem is that the stunning effect of the article is that $1.2 million per year, which looks huge at first sight, but if you look a little more, this $1.2 million a year is for a 10.000 employees company, so that’s actually $120 per employee per year, which is, as specified, about 2 hours and a half of work of that employee over the whole year.

Now let’s get around the fact that the employees sometimes have to go pee. I’d say that’s easily 5 minutes lost a day in non productive hygiene stuff, at least, which amounts for a total of about 20 hours a year per employee lost, which gives an awful $1012 per year per employee, or for our test company $10.1 million a year. Urgh ! Guess it’s about time to get the WC outside of the work area and have your employees swipe out & back in when they get there, to remove this illegitimate 1 grand you are giving out to each employee each year for nothing but pee !

If we also include the fact that anyway the employees won’t be 100% productive all the time, which leads to even more wasted money, that $1.2 million a year starts looking a little bit ridiculous. That’s the whole problem with that article, they used that 10.000 fold factor to have some significantly stunning figures to give, while completely omitting to mention how that scaled to.

Based on some rough estimations (about 3 weeks of holidays, working 5 days a week, 8 hours a day), our company is spending about $100.000 a year on each employee, or a total of $1 billion a year on human resources (on just those working in front of a computer screen). Two conclusions : that “wasted” time amounts for just 0.12% of the company HR expenses in that field, and that company is huge : 10.000 employees working on a computer, it must either be a large IT company or a really large non-it company, and in both cases, even if they probably don’t rely on free services (that would be silly), $1.2 million is probably just pocket money for them

Don’t get me wrong, stupid wastes should be avoided as much as possible, but please, pretty please, don’t try to hold your point using huge scale factors. Numbers lie, but when the lies are unveiled, the liars just look like fools. It just doesn’t help and could be avoided, especially when there are other much more robust arguments (here against ad-powered free services) around.

April 21st, 2010 @ 20:54

After sorting out my clutter issues and finally producing a video of a clutter animation, I thought I’d use it on the initial goal, that animation I had written ages ago. What I had sadly forecast occurred, the video dumping awfully slowed down the animation.

The whole problem is that, for now at least, I don’t think it’s possible to run the animation frame per frame rather than time based. So I thought “let’s just defer the whole video generation to after the end of the animation, and bufferize the frames meanwhile”. Well, this worked… until oomkiller jumped in and killed my process. Urgh.

So, I can’t bufferize the whole video, but I can’t push the frames to gstreamer in real time directly from the animation either. Well, all I need is parallelism then ! Push frames to a queue which is consumed by another execution unit (by pushing the frames to gstreamer). And since threading pretty much sucks in Python (well, it would definitely since we need real parallelism), let’s use the new multiprocessing framework from Python 2.6. Using it is pretty straightforward : create some parallel structures (queues, pipes), spawn a new process with it’s own main function, push to the structures from one process, read from another, and you’re done. The only thing I’m still wondering is why there is a close() function on Queues when there is no obvious way to detect from the other end that the queue has been closed (which I worked around by pushing a None message).

Well, now I have a smooth animation and a smooth video dump, my two cores being nicely fully used :)

The code is available below, with the interesting parts being StageRecorder.create_pipeline, StageRecorder.dump_frame, StageRecorder.stop_recording and StageRecorder.process_runner.

Read the rest of this entry »