Friday 23 January 2015

cx_Freeze and Pygame

I've just recently finished work on a game project for University as part of my Software Engineering module. The game is written in Python, using Pygame as a nice wrapper around SDL. Using Python and Pygame was a great choice, but distributing the project proved to be difficult. One of the requirements was that the project must run on the University computers, which have an old version of Python 2 and don't allow for the installation of Pygame or any other libraries.

In order to get around this, I remembered using a project called cx_Freeze. cx_Freeze allows you to distribute a Python program as an executable - removing the need for Python and libraries that your program requires. You can run cx_Freeze from the command line or by creating a distutils setup script. I looked around to find a suitable script for use with pygame, all of the scripts I tried resulted in the error:

pygame.error: File is not a Windows BMP file

This is because Pygame doesn't support loading PNG files without the use of SDL_image. With this in mind, it's important to tell cx_Freeze where your libSDL installation is. You can do this by assigning a path to bin_paths_include. I created my binaries using the following script:

To build the binaries, the script should be run as follows:

python2.7 cx_build.py build

This will create a new directory called build - inside of which will be another directory containing the created binary and required libraries. 

Tuesday 30 December 2014

31C3 Torrents

31C3 Videos are out


On the 31C3 wiki, there are some directions for downloading the torrents, but no single torrent list. I have collected together all of the torrents URLs, they are stored in this text file.

With a bit of wget magic, it is possible to get all of the torrent files, ready to be used with your favourite client.


    wget -i torrents.txt

Happy viewing. :-)

Friday 5 December 2014

Howm Version 0.5

I've decided that I want to do write ups of new releases of software that I create, in order to gather my thoughts and share some extra information with those that are interested.

With that said, I have just released a new version of howm. Version 0.5 brings some of the biggest changes to howm, including:
  • Configuration is done through cottage.
  • Howm no longer requires recompiling.
  • sxhkd is used for handling keypresses.

Why?

Why go to the effort of 106 commits, spanning 2 months? When I first created howm I just wanted something fun to hack on and hadn't considered the architecture particularly. When I first shared howm on Hacker News and also reddit I began to realise that recompiling after each configuration change wasn't going to cut it. I also realised that scripting howm was an important idea.

This led me to write cottage - a small utility to allow users to run howm commands over a local UNIX socket. This idea flourished as I realised that configuration should be moved out of howm also.

Configuration

Howm is now configured using cottage. The syntax is easy to understand (you don't need to understand C to make changes to howm anymore) and you're told when you make an error. Here's an example that shows how to change the border width:

    cottage -c border_px 4

By collecting multiple cottage commands together, it is possible to create a configuration file in the form of a shell script. This is heavily inspired by baskerville's bspwm, but takes the idea further by adding more descriptive error messages when something goes wrong.

Keybindings

Keeping a config.h file crammed with keybindings felt archaic, so I decided to switch over to using sxhkd. sxhkd listens for keypresses and then runs predefined commands. Joining sxhkd together with cottage allows for keybinding logic to be removed from howm - instead allowing all commands to be passed through a UNIX socket. This means that there is no longer a distinction between commands sent by cottage over the UNIX socket and commands resulting from keypresses.

Future Releases 

As more howm releases are made, I have a list of features that I want to see incorporated. Here's a brief summary of them:
  • Unit testing: I want most of howm to be covered by unit tests.
  • Cottage query howm's state: I think it would be great to be able to see howm's configuration as it is running. I also want to prevent people from having to hack shellscripts around howm's ugly output - cottage should be able to tell you everything you need to know.
  • Visual Mode: Being able to select certain windows and then perform an operation upon them would be excellent.
  • Better mouse support: The ability to move and resize windows using the mouse is a feature that howm should have.

 Conclusion

I hope that people enjoy the new features and new way of doing things with howm. I understand that some people may not like the addition of extra dependencies - but the move away from recompiling after a configuration change has removed howm's depencies on a compiler and working build system.

Thursday 4 December 2014

MIPS Creator CI20 Initial Review

Back in August of 2014, Imagination Technologies announced a programme designed to provide low cost development systems that cover all of Imagination's SoC IP. The first single board computer created by this programme is the MIPS Creator CI20 (referred to from here onwards as the CI20) - a MIPS-based development board aimed at hobbyists and Linux developers alike. This move was in response to a demand from the Linux community to get access to MIPS-based hardware, in the form of a development board - not consumer devices which offer minimal I/O capabilities. After the CI20's announcement, developers were invited to sign up for the chance to receive one of the first 1,000 boards - I was lucky enough to receive one a few weeks ago.

An unboxed MIPS CI20 on a black background

I have been meaning to review the CI20 for a while, but I wanted to wait for pricing details to be announced. The CI20 is clearly going to be compared to other single board computers (think Rpi, BeagleBone etc), but the CI20's price will be a deciding factor in how successful it is, as well as how it compares to its competition. Imagination Technologies announced today the price of the CI20 (£50 / $65) as well as when it will be available (January 2015).

Specification

The CI20 boasts an impressive specification - at the heart of which is an Ingenic JZ4780 SoC - a 1.2Ghz XBurst MIPS32 processor paired with a PowerVR SGX GPU. The CI20 also has 1GB of DDR3 RAM and 8GB NAND storage - as well as a plethora of I/O connectors. A full list of the CI20's spec can be found on the excellent eLinux page.


Image from Ingenic Semiconductor, all rights reserved

Below is a table that was provided by Imagination Technologies when they announced the CI20. It compares the CI20's specifications to those of its nearest rivals:


What's in the box?

Inside of the CI20's box I received:
  • The CI20 itself
  • A power supply with multiple plug faces
  • A USB-to-serial adapter

Initial Boot

As my monitor doesn't have HDMI support, I connected up the serial-to-USB adapter to the CI20's main expansion pins - as is detailed here. It is useful to note that the CI20's expansion pin header is compatible with that of the Raspberry Pi. I then plugged in the power supply and an ethernet cable.

On my laptop I loaded up minicom and issued the following command:

    minicom -b 115200 -o -D /dev/ttyUSB0

After getting serial access, I was presented with the following prompt:



Booting the CI20 into Linux, connected to by a serial cable


I logged in using the default credentials (user: ci20, password: ci20) and proceeded to install the latest updates, an SSH server and a VNC server. The CI20 runs Debian with XFCE4 and comes bundled with some graphics demos, I haven't had time to try those out yet though.

Exploring

After installing ssh, I unplugged my CI20's serial connector, left it plugged into ethernet and used SSH to access it from my laptop. I ran a few commands to look at the board's specs.

cat /proc/info 
cat /proc/cpuinfo
cat /proc/meminfo
cat /proc/meminfo
uname -a
uname -a

After some initial exploring over SSH, it was time to connect to the CI20 using VNC to take a look at it running XFCE.

CI20 Debian desktop - running XFCE

Summary

Throughout the time I spent with the CI20, I was constantly reminded of how it outclasses other single board computers. Comparing it to my Raspberry Pi (admittedly it is only a Model B), made it apparent how quick the CI20 feels. The hardware offerings of the CI20 are far superior to the other single board computers that I have mentioned in this article - although it is more expensive.

With this being the first device to come out of the Creator programme, not all distributions are supported and neither are all packages. The eLinux distro page mentions support for: Arch, Debian, Gentoo, Yocto and Angstrom - at the time of writing. There is also an ongoing effort to port XMBC to the CI20. Android is also supported, but I haven't got around to loading this on and trying it.

I'm also slightly concerned about the use of a PowerVR GPU - history isn't kind to the PowerVR architecture with it receiving lots of flak from the open source community as a result of drivers being provided in the form of binary blobs. Only time will tell if Imagination Technologies will continue to port the binary blob to newer kernel versions.

I have a few ideas for projects that I want to complete with the CI20 and will post the results of those here soon.