Showing posts with label Embedded. Show all posts
Showing posts with label Embedded. Show all posts

Apr 24, 2013

Build your Emdebian Grip for ARM (WM8850 support)

Here is the instruction that how to install an embedded debian OS for your ARM system. Linux Kernel Image for your ARM system is a prerequisite. [1]

Please follow the instruction step by step to build emdebian rootfs on Debian/Ubuntu. :)

1. Using Bootstrap

(Use apt-get install debootstrap to install it if you don't have yet.)

Use the command to retrieve the packages for ARM:
sudo debootstrap \
--arch=armel \
--include=vim,openssh-server \
--foreign \
squeeze grip/ http://www.emdebian.org/grip/

After this step, the installation rootfs is ready at "./grip", but it is like an installation disc rather than a working rootfs.
"--inculde" is to install any additional packages. In this example, vim and ssh server are added manually.

2. Write Rootfs to disk/SD card.

Copy the installation rootfs (at ./grip) to ext3 partition of a SD card or other media.

Save the following content to target's rootfs "/first.sh" :
#!/bin/sh
mkdir -p ./usr/share/man/man1
echo "proc /proc proc rw 0 0" >> /etc/fstab
echo 'deb http://www.emdebian.org/grip/ squeeze main' >> etc/apt/sources.list
echo 'deb http://ftp.tw.debian.org/debian squeeze main' >> etc/apt/sources.list
mount /proc /proc -t proc
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
/debootstrap/debootstrap --second-stage

3. First Boot

Before entering Linux Kernel, add "init=/bin/sh" to bootargs at uboot or other bootloader.[2] 
"#" prompt should be appeared. (If you can't see that, press enter to make sure your system isn't crash.). Just execute "/first.sh" at "/" and wait for couple minutes to install the base system.
if anything works normally, use "passwd" to modify root's password then reboot the system.

4. Second Boot

Modify bootargs from "init=/bin/sh" to "init=/sbin/init" at uboot or other bootloader before entering Linux Kernel. [3]

So far, login with root should be successfully. :)

P.S.

Attach some files for my WM8850 netbook.
[1] Linux Kernel :
[2] boot script for First Boot:
[3] boot script for Second Boot:
[4] Emdebian Linux on WM8850 Netbook
https://www.youtube.com/watch?v=JzPxJVLE2Zc&hd=1

Jan 23, 2013

Setup PlayStation Joysticks on Raspberry Pi



My friends and I are big fans of KOF. We all know the latency between PC and USB converter of PS joysticks is too long to enjoy our fight. However, the PS joysticks to PC via parallel port is a nice choice for low latency. (It you want to know how the converter works, please refer another Chinese site : http://stevie.myweb.hinet.net/adaptor2.htm )

PlayStation joysticks converter via Parallel Port.

Although it's nice but my computer with parallel port is broken. Why don't we play NeoGeo or MAME on Raspberry Pi? Thus, there is a plan in my mind to turn Raspberry Pi as a console game platform to play many kind of emulators, and RetroPie is a such great project supports SNES, NES, GBA. GB, SEGA, and MAME. In this part, I only focus on how to modify the joysticks and won't mention how to setup an emulator.

I should have a set of very handful joysticks for my game platform. The legacy PlayStation joysticks via GPIO is the best choice because it got the benefits of 12 buttons and 4-axis analog control, and the most important one is with very lower latency via GPIO than USB. If you are a fighting gamer (KOF, Street Fighter) as us, you will know why the latency is such important.


So, let's start to modify the converter for RaspberryPi.

gamecon_gpio_rpi is the driver for NES, SNES, GameCube, and PS Joystick via GPIO, and it's included in RetroPie. In this instruction, you will see how to connect a PS joys to Raspberry Pi. If you need to know the pin descriptions of PS joy, this site gives you how PS joysticks work. The connection method is some different between rev 1.0 and rev 2.0 of RPi. My RPi is rev 2.0, so I summarized the pin table. 


I start to make a simple connector for the P1 of RPi and DB25-Male. Here are some materials I prepared and the connector that I finished:




After a little work, connect with PS joysticks, converters, and RPi together. Start to test it!!!!


Before playing games, use RetroPie-Setup to install the emulator platform and gamecon_gpio_rpi driver for joysticks. The detail instruction can be found here. (The driver should be compiled and installed separately without RetroPie installed, but I haven't tried that yet. :P).

If the kernel module of gamecon_gpio_rpi is built correctly, you can install the module by the command:
pi@raspberrypi ~ $ sudo modprobe gamecon_gpio_rpi map=0,0,0,0,7,7 psx_delay=14

The parameter "map=0,0,0,0,7,7" is indicated using Pad5&6 as both PlayStation joysticks.
The parameter "psx_delay=14" configures the access delay for psx pads to 14ms. The default is 10ms, but it doesn't work correctly. 14ms is more save for me. 
After modprobe, there should be two joystick devices in /dev/input/jsX. (X indicated 0 & 1.) Then use the command to test:
pi@raspberrypi ~ $ jstest /dev/input/js0 

Driver version is 2.1.0.
Joystick (PSX controller) has 6 axes (X, Y, Rx, Ry, Hat0X, Hat0Y)
and 12 buttons (BtnX, BtnY, BtnTL, BtnTR, BtnTR2, BtnSelect, BtnStart, BtnMode, BtnThumbL, BtnThumbR, ?, ?).
Testing ... (interrupt to exit)
Axes:  0:-32767  1:-32767  2:-32767  3:-32767  4:-32767  5:-32767 Buttons:  0:off  1:off  2:off  3:off  4:off  5:off  6:off  7:off  8:off  9:off 10:off 11:off 


If all buttons and axis work well, congratulation that the joysticks setup correctly on RPi!!

There will be another article soon to share how to setup the emulators on RPi.