Archive for the HowTo Category

Saleae Logic — Gentoo Linux

Posted in HowTo on 13/04/2013 by Undersys

Certain company’s to me deserve my cash.. and that’s not easy.
Saleae is one of them. Saleae produces logic analyzer’s and 8 channel and a  16 channel version.

Logic analyzers are quite common and most of them are desk side stand alone units. Where Saleae differs is there logic analyzer  connects to your USB port.
Whats even better is this…

$ file Logic
Logic: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, stripped

That’s right, the software that interfaces the to the logic unit has a NATIVE Linux port. In fact there is a native version for Windows,Mac and Linux in both 32bit and 64bit! Not some shitty wine app or java rubbish its a pure native port and it works very well on every operating system. You can see why I like Saleae now!

Before you ask, in no way did Saleae make me or ask me to write about there device, I am doing it because its amazing.

I have brought the 8 channel version as I can’t see my self needing anymore channels then 8 but you can always have more then one right!

There is also another reason why I like Saleae’s product.
Its well made, comes in a nice case and is VERY small
You can see the logic and its attached probes in the below image.
That’s a standard SD card in the image to show you how small the logic really is.
Saleae also include the little probe clips, but you can just plug the end of the wires into a pin header if you want to.

The main set of 8 wires easily unplugs from the main logic unit to store easily in the provided case.

Now time to make it work!

To get the Logic detected under Linux you will need very little.
1) Kernel support for Cypress FX2.
2) LibUSB 0.1 (Legacy).

For number 1 You need to add FTDI_SIO support to your kernel :


For number 2 you need to emerge the following package :


Once you have the above two things, go ahead and plug the, if all has gone well dmesg will print something like this :

[950447.239197] usb 1-1.5.2: new high-speed USB device number 14 using ehci-pci
[950447.324654] usb 1-1.5.2: New USB device found, idVendor=0925, idProduct=3881
[950447.324658] usb 1-1.5.2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[950447.324662] usb 1-1.5.2: Product: Logic
[950447.324672] usb 1-1.5.2: Manufacturer: Saleae LLC

Now that your Logic is detected go do the download page and get your software.  The Linux package is labeled as “ubuntu”. Lucky for the rest of us Linux people its just a zip file that you can unpack anywhere and run the Logic application.
I like to extract it under /opt but you can run it anywhere you like.

You can see in the below image a test I did with my logic, the software interface is clean and easy to use but feature rich.logic-test
Click the above to get a higher res image.

owncloud on Centos with nginx and mysql

Posted in HowTo on 08/04/2013 by Undersys

In this post I am going to show you how to install the free owncloud server.
I will be using Centos , Nginx , mysql and PHP-FPM .

I am not a huge fan of Apache, hence why this guide has nginx!
Sadly some our dependencies  will pull in Apache web server under Centos.
Not to worry just don’t enable Apache/httpd.

Lets get stuck into it.

Firstly Disable selinux
Edit the  file “/etc/selinux/config” and ensure the selinux is disabled :


Next your going to need to add in the ngix repo
Create the file “/etc/yum.repos.d/nginx.repo” and enter the following into it :

name=nginx repo

Now its time to install all the packages you will need to run owncloud.

Install :

yum install mysql mysql-server
yum install nginx
yum install php php-gd php-xml-parser php-intl php-mysql php-mbstring php-xml php-fpm php-pear php-devel pcre-devel

Not the above command will pull in httpd! Yuck! Sadly you have no choice on Centos :

# repoquery --requires php
httpd-mmn = 20051115

That’s OK. Just don’t enable the silly thing.

Lastly since you’re using nginx and not apache you need to fix the default php cache directory permissions. Run the following :

# chown -R root:nginx /var/lib/php/

Ensure to start nginx and set it to start on boot :

# service nginx start
# chkconfig nginx on

Since nginx has no way to spawn a php process, unlike apache with mod_php you need to have anoter proces that can handle the php requests. This is where php-fpm comes into play.

You need to configure a few settings first.

The first settings are for the main server settings.
Edit the file “/etc/php-fpm.conf” set the following :

log_level = notice
emergency_restart_threshold = 10
process_control_timeout = 10s

Next you need to fix up the worker config file :
Edit the file” /etc/php-fpm.d/www.conf” and set the following:

user = nginx
group = nginx

You also need to fix the permissions for the php-fpm log directory.
Run the following command :

chown nginx:nginx -R /var/log/php-fpm/

Enable services to start on boot :

# service php-fpm start
# chkconfig php-fpm on

Now its time for Mysql ( You could try MariaDB if your feeling lucky). For now I will stick with Mysql.

First you need to start mysql and while your at it, set it to start on boot :

# service mysqld start
# chkconfig mysqld on

Now run teh first time install wizard :


Set a root password to something secure.
Answer the questions with the following responses :

Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y

Since your going to use the tarball install rather then the RPM package your going to need to create your databases and privileges for owncloud.

Log into mysql as the root user :

# mysql -u root -p"

Give it the root password you set during the start up script.

Now run the following SQl to create the database and assign privileges:

mysql> create database owncloud;
mysql> GRANT ALL PRIVILEGES ON owncloud.* TO "mycloud"@"localhost"  IDENTIFIED BY "password";
mysql> flush privileges;
mysql> quit

DO set a better password. DO NOT use the same password as the root account or any other account. This password will be stored in plain text !

Now its time to unroll the owncloud files into the server.
Install the latest OwnCloud distribution (Select Tar or Zip File) from

At the time of this article I used the command :

# wget

Extract the tarball into your web servers www directory ( or where ever you configured it). In my case :

# tar -xvf owncloud-5.0.3.tar.bz2 -C /cloud/www"

I will configure nginx to serve files form this directory later.

You will also need to set the correct permissions :

chown -R nginx:nginx /cloud/www/

You could skip this section and run everything in plain text but that would be stupid. I will be using NameCheep's Comodo PositiveSSL certificate, as I've used them many times

First up create the ssl working directory for nginx

# mkdir /etc/nginx/ssl

Now change into that directory, its time to create the key and csr request.

# cd  /etc/nginx/ssl
# openssl genrsa -des3 -out DOMAIN_NAME.COM.key 2048

Enter a password when prompted by the above command, the password is not important  we will remove it soon. Replace DOMAIN_NAME.COM with your fully qualified server domain name.

Now generate the CSR :

#  openssl req -new -key DOMAIN_NAME.COM.key -out DOMAIN_NAME.COM.csr

Answer the questions and make sure the server common name matches your fully qualified domain name. You don't need to enter the "extra" attributes.
The contents of the .csr file is what I will give to my certificate issuer.

Remove the password from the key with the following commands :

# openssl rsa -in -out  DOMAIN_NAME.COM.key

Enter the password for the last time, now the .key file will have no password.

Now upload the contents of the .csr file to NameCheep, select server type of "Other". Then wait for the approval email from NameCheep.

Once you have zip file that contains the certificate, root certificate and intermediate certificate. You need to bundle them into a .pem file for nginx. Unzip the bundle anywhere we will copy pem file to the correct location later.
Create the .pem bundle with the following commands :

# cat PositiveSSLCA2.crt >  DOMAIN_NAME.COM.pem
# cat AddTrustExternalCARoot.crt > DOMAIN_NAME.COM.pem

Now copy the DOMAIN_NAME.COM.pem file into /etc/nginx/ssl directory.

Finally its time to configure nginx it self.
The first file your going to set up will be the main server config file. You can find it at "/etc/nginx/nginx.conf"
Open it and replace all the contents with the below :

## Server Config
user				nginx;
worker_processes  		1;

error_log  			/var/log/nginx/error.log warn;
pid        			/var/run/;

events {
worker_connections 	 	1024;
multi_accept                  on;
use 				epoll;

## Server Config END

http {
## Types mapping
include       		/etc/nginx/mime.types;
default_type  		application/octet-stream;

## Types mapping END

## Main Server log settings
log_format  main  		'$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log  			/var/log/nginx/access.log  main;
## Main Server log settings END

## MISC server settings
sendfile        		on;
server_names_hash_bucket_size 64;

## MISC server settings END

## GZIP Settings
gzip  			on;
gzip_static       		on;
gzip_vary         		on;
## GZIP Settings END

## Security Settings
# Turn off srv version
server_tokens 		off;
# Set client requst body buffer
client_body_buffer_size  	1K;
# set client header buffer
client_header_buffer_size 	1k;
# Max size of client body request
client_max_body_size 		1k;
# Max large size of header/buffer to read from client
large_client_header_buffers 	2 1k;
# Read timeout for client body
client_body_timeout   	10;
# Timeout to read client header
client_header_timeout 	10;
# timeout for keepalive andheader keep alive
keepalive_timeout     	5 5;
# Timeout for client responce
send_timeout          	10;
## Security Settings END

## Include Server Blocks
include /etc/nginx/conf.d/*.conf;
## Include Server Blocks END

The next file defines the server blocks and there settings.
Create a file "/etc/nginx/conf.d/" Give it a name like DOMAIN_NAME.COM.conf. The following was mostly taken from the owncloud install guide . With a few modifications for my needs.

server {
  listen               [::]80;
  server_name          DOMAIN_NAME.COM;
  rewrite              ^ https://$server_name$request_uri? permanent;

server {
  listen       	       [::]:443;
  server_name 	       DOMAIN_NAME.COM;
  access_log 	       /var/log/nginx/access.log main;
  error_log	       /var/log/nginx/error.log warn;
  root 		       /cloud/www/owncloud;
  ssl 		       on;
  ssl_certificate      /etc/nginx/ssl/DOMAIN_NAME.COM.pem;
  ssl_certificate_key  /etc/nginx/ssl/DOMAIN_NAME.COM.key;
  client_max_body_size 10G;
  fastcgi_buffers 64   4K;
  rewrite              ^/caldav((/|$).*)$ /remote.php/caldav$1 last;
  rewrite              ^/carddav((/|$).*)$ /remote.php/carddav$1 last;
  rewrite              ^/webdav((/|$).*)$ /remote.php/webdav$1 last;
  index                index.php;
  error_page 403 =     /core/templates/403.php;
  error_page 404 =     /core/templates/404.php;

  location ~           ^/(data|config|\.ht|db_structure\.xml|README) {
  deny                 all;

location               / {
  rewrite              ^/.well-known/host-meta /public.php?service=host-meta last;
  rewrite              ^/.well-known/host-meta.json /public.php?service=host-meta-json last;
  rewrite              ^/.well-known/carddav /remote.php/carddav/ redirect;
  rewrite              ^/.well-known/caldav /remote.php/caldav/ redirect;
  rewrite              ^(/core/doc/[^\/]+/)$ $1/index.html;
  try_files            $uri $uri/ index.php;

location = 	       /favicon.ico {
  return 	       204;
  access_log           off;
  log_not_found        off;
location ~             ^(.+?\.php)(/.*)?$ {
  try_files            $1 = 404;  
  include              fastcgi_params;
  fastcgi_param        SCRIPT_FILENAME /cloud/www/owncloud$fastcgi_script_name;
  fastcgi_param        HTTPS on;

location ~* 	       ^.+\.(jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ {
  expires              30d;
  access_log           off;

Ensure you change all the "DOMAIN_NAME.COM" to your real servers fully qualified domain name.

Restart nginx after changing the above to config files.

To be able to upload any files bigger then 1MB you need to edit the php.ini file.

Open the file "/etc/php.ini" and set the following :

upload_max_filesize = 8G
post_max_size = 10G

This will allow you to upload an 8GB file, Set the vales to something that makes sense to you.

So very close now. Browse to your servers DNS name.
Enter a username and password for the owncloud admin account.
Try make this different too.
Next select the "advance install" drop down item.
Select "mysql" and enter the DB user,pass and DB name.
The above details are what you set up in step 4.

After that, create some users and have fun!.

There are obviously more things that can/could be done. Server Harding, mysql tuning better data structure placement etc but I will leave that up to you.
The above guide will get you a functional owncloud install with Nginx m Mysql and php-fpm.

Cowan iAudio x5 repair

Posted in HowTo on 26/07/2012 by Undersys

I use an Cowon iAudio x5 with Rockbox  to play my ogg vorbis files.

Its quite an old player now, but it fits my needs and I don’t see the point of buying new stuff when this works.
As expected I’ve had to replace a few batteries in it not a big deal.
I’ve also fixed the headphone jack as it had come loss some time a go. ( you can see the white pad on top to give it more pressure in the images below)

All of the x5 owners know about the little joy stick and how quickly it fails.
Mine had been on the way out for around a year now(pretty good given its close to 5 years old), back stopped working then down, then select now its useless.

Me been me, I guessed I could fix it! Your going to need to find a replacement joystick. No idea who made the original or what the part number is. After a lot of reading I found the “TPA511GLFS” made by ck components.

You can buy this online via Mouser or Digikey. I got mine via Digikey. There part number is 401-1130-6-ND Digikey will sell in one lot quantities so that works for me.

Your going to need a decent Soldering Iron, personalty I recommend Hakko. I used the FX-888 for this work.

So hear we go!

Undo the four screws at the back of the unit. Remove the tape holding down the wires. Keep the tape.
Remove the HDD by sliding the front edge of the battery (where the connector is) forward and up its a little tight! Unclip the HDD from the main PCB by gently lifting upwards on the connector.
Now remove the headphone and FM assembly along the top of the unit. Undo two black screws and lift gently from the opposite side to the headphone jack.
Remove the black HDD  protector.
Your player should look like this :-

Now unscrew all the black screws you can find, there are lot! Also remove the two silver screws at the base of the unit holding down the metal HDD clip.
At this point I also un solder the  battery to get it out of the road and as a safety measure. Note the pad with the box is the positive wire and the  far side is the negative wire the middle pad is not used.
Now your ready to remove the main PCB. Undo the tape and keep it. Remove the black support  near the white plug on the top of the unit.
Now lifting gently from the side with the USB port at the top of the unit. Lift upwards take care of the switches they are very fragile.  If you need to bend the plastic a bit near the switches and the USB port. Once you have cleared that pull the board towards the top of the player and out of the case. Turn the main board over it should look like this.
The silver joystick cover can now be popped off. along with the sticky sponge.
Hear is the bare switch:-
De-solder the switch. I like to use de soldering braid but what ever method works for you.
Switch removed, need to clean the pads lots of flux :-
Position the new switch as close to where the old one was a possible. The pads allow for a lot of moment and if your to far left or right you’re joystick will miss the hole! The pins line up exactly as the old switch.
New switch on :-
Reassemble the unit and test all functions. The main PCB be be fiddly to get back in. I like to insert the bottom connector first then push the USB plug down and slowly push down on the side with the switches taking good take to not brake the switches.

Your done!

References :-
Data sheet for the switch.
My Flicker (full size images)

HP’s PCI web console card a5858a — setup guide

Posted in HowTo on 22/07/2012 by Undersys

Well after a few years oh my web console card in my HP J6750 running fine.  After the move to HK it stopped responding on its IP.

Ok years have passed  and I have no idea what the default IP was or even how to reset this thing back to factory defaults.

Do recall this is a factory install option only on the rp24xx series. So documentation is a little sparse.
If your wondering how to power it see this post I wrote about how to power the card.

To reset the unit back to factory defaults do this :-
1) Press and hold Switch two (this is the switch closest to the serial port)
2) Press and hold Switch one (this is the switch closest to the LAN port)
3) Let go of Switch two, the lights should flash then let go out Switch one.

Default IP is always
Browse to that IP address and you will be greeted with a setup page for the web console.
After your done access the web console on your new IP.

I have a few pages on the web console you can download it hear.

Arduino 1.0 and Gentoo

Posted in HowTo on 14/04/2012 by Undersys

It has been a while since I used my Arduino.
Of course when I go to use it there is a new version of the software out 1.0.
As expected it won’t work out of the box on Gentoo.
Make sure you give my existing article a read though if you have other issues.

I had to change two things.


I got the following error :-

~/arduino-1.0/hardware/arduino/cores/arduino/Print.cpp: In member function ‘size_t Print::print(const __FlashStringHelper*)’:
~/arduino-1.0/hardware/arduino/cores/arduino/Print.cpp:44:9: error: ‘prog_char’ does not name a type
~/arduino-1.0/hardware/arduino/cores/arduino/Print.cpp:47:23: error: ‘p’ was not declared in this scope

It appears that Print.ccp is using depricated typedef.
avr-libc v1.8.0 and up have deprecated the “prog_char” type def and now its recommended to use of “char PROGMEM”.

So lets fix that…
Bash open the the “Print.ccp” file for me this is located at :-

On line 42 you will find the offending secion :-

size_t Print::print(const __FlashStringHelper *ifsh)
 const prog_char *p = (const prog_char *)ifsh;
 size_t n = 0;
 while (1) {
 unsigned char c = pgm_read_byte(p++);
 if (c == 0) break;
 n += write(c);
 return n;

Lets replace that section with one that supports new versions of avr-libc :-

size_t Print::print(const __FlashStringHelper *ifsh)
 const char PROGMEM *p = (const char PROGMEM *)ifsh;
 size_t n = 0;
 while (1) {
 unsigned char c = pgm_read_byte(p++);
 if (c == 0) break;
 n += write(c);
 return n;

After that I now got the following error :-
/usr/libexec/gcc/avr/ld: cannot open linker script file ldscripts/avr5.x: No such file or directory

Hmm we’ve seen this shit before, check my existing article.
Easy fix as root create the following symlink:-
# ln -s /usr/x86_64-pc-linux-gnu/avr/lib/ldscripts /usr/avr/lib/ldscripts

Done. If your lucky it should work correctly now!

Burning XGD3 and XGD2 xbox360 backups on Linux

Posted in Code, HowTo on 25/02/2012 by Undersys

There are a lot of guides out there on how to burn xbox360 backups under windows.
Well I don’t use windows.. and after fucking a lot of dual layer DVD’s I though a post was in order.

Firstly to have a correct XGD3 backup you need a Lite-on burner with the iXtream BurnerMax firmware. Find that your self..

Secondly you should be running abgx360 on all your backups prior to burning them.  They have a Linux version, make sure you have “xterm” installed to as it will use that for console output.

I wrote this small script that uses growisofs to burn xbox 360 backups to my Lite-on external burner.
Usage is simple:-
# ./ xgd3 filename.iso
replace xgd3 with xgd2 depending on what your burning.
Edit the DVD variable to your dvd-rw device.
Using this script and the below growisofs settings along side abgx360 i have had 100% success rate.


# Version: 1.0.0
# Date: 20120225
# Author:
# function: burn xbox 360 games with the correct layer break
# xgd2 layerbreak is 1913760, xgd3 is 2133520
# notes for growisfo :-
# -use-the-force-luke=notray = don't reload tray
# -use-the-force-luke=dao = burn disk at once
# -use-the-force-luke=break = manual set layer break
# Vars

# Chage this to match the dvd-rw device

# Functions

function testargs {
 if [[ -z $DTYPE ]]; then
 echo You must specify a disk type
 echo EG: xgd3 or xgd2

if [[ -z $INAME ]]; then
 echo You must specify a iso file name
 echo EG: /tmp/backup-game.iso

function burn {
 if [[ $DTYPE == xgd3 ]]; then
 echo Burning $INAME as $DTYPE with layerbreak 2133520..
 growisofs -use-the-force-luke=notray -use-the-force-luke=break:2133520 -speed=1 -Z $DVD=$INAME
 echo Done! Ejecting..
 eject $DVD
 echo Burning $INAME as $DTYPE with layerbreak 1913760..
 growisofs -use-the-force-luke=notray -use-the-force-luke=dao -use-the-force-luke=break:1913760 -dvd-compat -speed=2 -Z $DVD=$INAME
 echo Done! Ejecting..
 eject $DVD
# Main


# End

Cisco DDNS with namecheep

Posted in HowTo on 14/10/2011 by Undersys

First make sure you have correctly set up DDNS in the name cheep console.
You can test it with the following simple URL :-

Where :-
HOSTNAME = the host name of the machine eg
DOMAINNAME = the domain name eg
PASSWORD = the API password from namecheep, not your namecheep password
IPADDRESS = IP address you want to send to namecheep

Once you get a success message back from browsing to that URL you are ready to configure the Cisco IOS.

You need to parts, one on the external interface and one to set up the DDNS provider.

First we set up the provider section :-
I use the IP address as I do not have DNS configured on the Cisco, I use an internal BIND server.
Also note :-
ip=<a> is a Cisco substition for the interface’s IP.
The “method” can be called anything you want.
I want it to update every 15 minutes hence the interval command.

# conf t
ip ddns update method namecheap
 interval maximum 0 0 15 0

Second part is we add it to the external interface, in my case Dialer 0.

# conf t
ip ddns update namecheap

Exit from the config syntax.
Turn on debugging :-
# debug ip ddns update

Restart the physical interface that the Dialer is bound to. FastEthernet0 in my case. :-

# clear pppoe int Fa0

Check the logs and see what happens, if you entered everything right it should be up and running.
You can also check that IOS has parsed everything right by issuing this command :-
# show ip ddns update method