Apr 01 2012

Arch Linux Chroot for Asus Transformer

Category: Uncategorizedadmin @ 7:05 pm

I started using Arch some months ago and I really enjoying it. Coming from a released based distro, it feels really nice been able to choose exactly what you want to run in your system and always have the packages up to date. For a while I have been planning on running ubuntu in my transformer but I just don’t feel too comfortable with ubuntu , so decided to run arch in my transformer. I couldn’t find a tutorial so I scavenged the net and found bits and peace that I put together to make this tutorial. What I like about arch is that I am in control of my system and  I can run exactly what I want, thanks awesomely documented Arch!

This is a tutorial that will show you how to run Arch Linux in a chrooted environment within your Asus Tarsnformer. I will not provide a simple script that if you run it will do everything for you, instead I will teach you how to make your own installation by grabbing all necessary elements.

You will need:

Arch Live image: Go to http://archlinuxarm.org/developers/downloads and grab the omap 3/4 package.

Install environment: It can be your internal storage or a sd/micro card. Here I will show how to use the micro sd card.

Script for starting the chroot: I grabbed mine from http://forum.xda-developers.com/showthread.php?t=1517993&highlight=chroot and did some modifications. Thanks-miska-

Rooted Asus Transformer(Prime?) with Terminal: You need root to mount the file system and loop devices. In theory this should work in the Prime too.

Linux Machine

Step 1:

For installing arch in a (micro)sd card (I prefer micro as I don’t need the dock for using it), first you need to format the card and make two partitions. (I used gparted) Make one partition fat and assign a small amount of space(I have a 4gb micro and assigned 128mb to the fat partition), then make the rest ext4. Make sure the fat partition is first and the ext one is second.

Step 2:

Now as root you need to extract the package in the ext partition of your card. REMEMBER to be root, I got stuck thinking there was something wrong with the package I downloaded but it was that I was unpacking as normal user.

# tar -c /path/to/extpartition -xzf  ArchLinuxARM-omap-smp-latest.tar.gz

Now you have a arch environment in your (micro)sd card.

Step 3:

In your asus transformer create a folder called ‘arch’ in the root of your internal storage.

#mkdir /sdcard/arch

Or use a file manager.

Now place this script somewhere in your transformer, I usually keep it in /sdcard/Downloads

#!/bin/sh

# Modify this according to your needs
DEVICE=”/dev/block/mmcblk1p2″
LOOP=”no”

# Maybe this as well
MNT_PATH=”/mnt/sdcard/arch”

# Modify only if you know, what are you doing
BINDS=”dev dev/pts proc sys mnt/sdcard”
ANDROID_BINDS=” /system /data ”
TMPS=”tmp var/tmp var/log var/run”

MY_MOUNTS=”"

unset PS1

# Helper functions

die() {
echo ” $1″
exit 1
}

safe_mount() {
mkdir -p “$MNT_PATH”"$2″
if [ "$3" ]; then
OPTION=” $3 ”
else
OPTION=”"
fi
if [ -z "`mount | grep " $MNT_PATH$2 "`" ]; then
mount $OPTION “$1″ “$MNT_PATH$2″ || die “Can’t mount $2!!!”
fi
MY_MOUNTS=”$MNT_PATH$2 $MY_MOUNTS”
}

# Real work

[ "`whoami || echo root`" = "root" ] || die “You must be root first!”
LOOP_ARG=”"
[ "$LOOP" = "no" ] || LOOP_ARG=” -o loop ”

safe_mount $DEVICE “” “$LOOP_ARG -t ext4 ”

for i in $BINDS; do
safe_mount “/$i” “/$i” ” -o bind ”
done

if [ -d /Removable ]; then
for i in /Removable/*; do
[ -d "$i" ] && safe_mount $i /mnt$i ” -o bind ”
done
fi

for i in $ANDROID_BINDS; do
safe_mount $i /mnt/android$i ” -o bind ”
done

for i in $TMPS; do
safe_mount none /$i ” -t tmpfs ”
done

mount -o remount,ro “$MNT_PATH”
chroot “$MNT_PATH” /sbin/fsck.ext2 -y “$DEVICE”
mount -o remount,rw “$MNT_PATH”

# Tweak configuration of the chroot during first start

#if [ \! -f "$MNT_PATH"/etc/profile.d/tweak.sh ]; then
#mkdir -p “$MNT_PATH”/home/opensuse
echo ‘nameserver 8.8.8.8′ > “$MNT_PATH”/etc/resolv.conf
#echo ‘net:x:3003:root,opensuse’ >> “$MNT_PATH”/etc/group
#echo ‘opensuse:x:1000:100::/home/opensuse:/bin/bash’ >> “$MNT_PATH”/etc/passwd
#echo ‘opensuse:$1$joWqOQdr$YsapocP32UtdiR3PKBXVM1:15395:0:::::’ \
# >> “$MNT_PATH”/etc/shadow
#sed -i ‘s|^root:.*|root:$1$joWqOQdr$YsapocP32UtdiR3PKBXVM1:15395:0:::::|’ \
# “$MNT_PATH”/etc/shadow
#echo ‘#!/bin/sh
#export TERM=linux
#export LANG=”en_US.utf-8″
#export EDITOR=”busybox vi”
#alias vi=”busybox vi”
#precmd() { :; }
#if [ "`whoami`" = root ]; then
# export HOME=/root
# export USER=root
# hostname -F /etc/HOSTNAME
#fi
#if [ -z "$CHROOTED" ]; then
# export CHROOTED=yes
# export HOME=”/home/opensuse”
# export USER=”opensuse”
# su opensuse
#fi
#’ > “$MNT_PATH”/etc/profile.d/tweak.sh
#fi

export PATH=”/bin:/sbin:/usr/bin:/usr/sbin:/system/xbin:/system/bin”

# Chroot

chroot “$MNT_PATH” /bin/bash
#chroot “$MNT_PATH” /root/init.sh

# Cleanup

echo “Umount everything”
for i in $MY_MOUNTS; do
umount -l $i
done

 

Step 4:

Chmod +x the script and run it as root.

su
#chmod +x scriptname.sh
sh scriptname.sh

The script will mount the ext partition of your (micro)sd card in /sdcard/arch and will chroot into it. It also does other really nice things, such as mounting your android partitions to /mnt so you can access them from within your arch environment. I have disabled some lines that are used to set up a some environment variables, but you should still be able to get a fully functional command-line environment and you can enable them and modify them as you want.

Step 5:

The rest is completely up to you,  now you have arch running in your transformer. But what!? You need X?! really???? Ok, so lets create a vnc server so we can remote into it.

Your network connection should work, so the first thing to do is an update

#pacman -Syu

Now install xorg

#pacman -S xorg-server xorg-xinit xorg-twm xorg-xclock xterm

Now install a vncserver

#pacman -S tightvnc

And now this is the tricky part(And I spent a lot of time in this).

I grabbed this script from the UbuntuInstaller post. This is the script they use for setting a resolution at each boot. What I did was to remove the resolution prompt and fix the resolution to 1280×752(fullscreen) and remove some ubuntu stuff. I also added an export for HOME and USER that will allow you to run ‘vncserver’ as root.

#!/bin/bash
#############################################
# Asks User to screen size and saves as REZ #
#############################################
#echo “Now enter the screen size you want in pixels (e.g. 800×480), followed by [ENTER]:”

#read REZ

###########################################
# Tidy up previous LXDE and DBUS sessions #
###########################################
#rm /tmp/.X* > /dev/null 2>&1
#rm /tmp/.X11-unix/X* > /dev/null 2>&1
#rm /root/.vnc/localhost* > /dev/null 2>&1
#rm /var/run/dbus/pid > /dev/null 2>&1

############################################################
# enable workaround for upstart dependent installs #
# in chroot’d environment. this allows certain packages #
# that use upstart start/stop to not fail on install. #
# this means they will have to be launched manually though #
############################################################
#dpkg-divert –local –rename –add /sbin/initctl > /dev/null 2>&1
#ln -s /bin/true /sbin/initctl > /dev/null 2>&1
###############################################
# start vnc server with given resolution and #
# DBUS server, (and optionally an SSH server) #
###############################################
export HOME=”/root/”
export USER=”root”
vncserver :0 -geometry 1280×752
dbus-daemon –system –fork > /dev/null 2>&1
/etc/rc.d/sshd start
#echo
#echo “If you see the message ‘New ‘X’ Desktop is localhost:0′ then you are ready to VNC into your ubuntu OS..”
#echo
#echo “If VNC’ing from a different machine on the same network as the android device use the 1st address below:”
##########################################
# Output IP address of android device #
##########################################
ifconfig | grep “inet addr”

#echo
#echo “If using androidVNC, change the ‘Color Format’ setting to 24-bit colour, and once you’ve VNC’d in, change the ‘input mode’ to touchpad (in settings)”

#echo
#echo “To shut down the VNC server and exit the ubuntu environment, just enter ‘exit’ at this terminal – and WAIT for all shutdown routines to finish!”
#echo

###############################################################
# Spawn and interactive shell – this effectively halts script #
# execution until the spawning shell is exited (i.e. you want #
# to shut down vncserver and exit the ubuntu environment) #
###############################################################
/bin/bash -i

#########################################
# Disable upstart workaround and #
# kill VNC server (and optionally SSH) #
# Rename used xstartup to its first file#
#########################################
vncserver -kill :0
/etc/rc.d/sshd stop

 

Place this script in /root/, give it the name ‘init.sh’ and make sure it is executable(chmod +x). Now in the previous script comment the line:

chroot “$MNT_PATH” /bin/bash

and uncomment the line

chroot “$MNT_PATH” /root/init.sh

 

Step 6:

Now you should be able to start a vncserver with twm as your window manager and a xterm.

You can now go to

https://wiki.archlinux.org/index.php/Desktop_Environment

or

https://wiki.archlinux.org/index.php/Window_Manager

and set up the desktop environment that you like the most.

Remember that you need to set up the graphical environment to start manually and not at boot. In a normal environment you would usually use ‘startx’ which will read the .xinitrc file and run the programs from there. In our case put everything that needs to go into .xinitrc into ~/.vnc/xstartup. An example of my ~/.vnc/xstartup

#!/bin/bash

xrdb $HOME/.Xresources
exec startfluxblox

This will start an empty fluxbox window manager.

 

 

 


Mar 14 2012

Major Update for Mechtactics

Category: AI Competitionadmin @ 3:43 am

I did a great task this last three days and I rewrote my game. This time I made sure to do everything correctly all the way from the beginning.  Please go to http://mechtactics.cesarandres.com for more info.


Jan 15 2012

This is an update of the progress in my game PT 2

Category: AI Competition,My stuffadmin @ 9:32 am

First the most important, I finally came up with  a name for my game and is going to be Mech Tactics. Since last time a lot of progress have been done and now I finally feel that this game has a complete body.

Map Generator: 100%

Finished already, nothing to work on.

Server: 95%

I improved the server speed by saving the information of the objects that changed rather than a snapshot of the current state. I also did some modifications to how data was send to/from the clients, and now the messages are send and read byte by byte, this fixes the problem of reading xml from the tcp buffer. I still need to fix some bugs were the server listener will remain listening even after closing the launcher. Another problem is also xml tags not being closed if the server is stopped in the middle of the simulation.

Simulator: 95%

Everything seems to work fine, but I haven’t tried to simulate units attacking to each others, it should work fine but I will need to test this before I can say I am done with the simulator.

Client: 100%

There is nothing else to do with the client, I have done some changes but this is more for debugging the simulator and the visualizer.

Data-Objects: 100%

Done.

Visualizer: 95%

Right now the visualizer will move and create units. It should also be capable of removing the dead units but this has not being tested yet.

Here is an snapshot of the visualizer, using some really crappy sprites.

 


Dec 16 2011

This is an update of the progress in my game

Category: AI Competitionadmin @ 11:04 pm

Finally done with classes and I have spent a good portion of yesterday and today working on the different parts of the game. The progress so far is like this:

Map Generator: 99%

I worked a little bit more than expected in this map generator, using my own algorithm I finally got  a I fully working map generator. The generator will create maps based on a maximum height and a size. The resulting maps are homogeneous, meaning that the map will have hills and valleys that are equally dispersed from each other this for not giving any advantage to any player but still force them to find the best path between two points.

Server: 85%

Using the server code from torchedterra I am just adding some modifications to separate the launcher logic from the server logic. I will also be changing some communication logic between the client and the server.

Simulator: 50%

The biggest changes are in the simulator. The simulator receives the list of commands from the server and analyzes them, this counts as a turn and the results are send as a list with the changed elements. All the preexisting logic of the simulator was discarded as torchedtorre gameplay has no similarity with this turn-based strategy styled game.

Client: 95%

Based on the client for torchedterra, this client is not really that different. The only difference is that rather than send one command, I will be sending a list of commands and some connection client-server has had some minor changes.

Data-Objects: 80%

The data objects are the representation of all the elements of the that live between client and server, such as the connection, the commands, results, and in-game objects. A big change has being done on this ares, mainly regarding high lever changes to fit the logic of the game.

Visualizer: 0%

Eventually I need to make the visualizer for this game. The plans are to make a visualizer that can show the saved games and also should be capable of showing the game running in real time.  I will probably some code I have from my mapgenerator test. I am not planning in making anything too fancy and probably I will stick to using the canvas.

 

So that is my update, I will keep working on this during this break.


Nov 27 2011

Starting with Android Development in Linux – Getting what you need

Category: Android,Android App DevCesar @ 6:16 am

Developing in Linux is something a little bit more obscure than working on Windows or Mac. Usually things on Windows or Mac are really straight forward, just download some kind of GUI and then press Next until you get the Finish button. In Linux you will have to deal with the terminal and editing files, which may seem hard or confusing at first but you will notice that it also gives you access to a lot more customization options. I will assume you already know how to move in the terminal or in the Desktop Environment, compress/uncompress, copy, move and delete files and you already have a JDK  compatible with the specifications here: http://developer.android.com/sdk/requirements.html.

All the information here is the combination of the official Android documentation and my own personal experience.

http://developer.android.com/sdk/installing.html

The SDK

The main element to start with Android Development is to get the SDK, which can be found at:

http://developer.android.com/sdk/index.html

Here you will download android-sdk_rXX-linux.tgz, where XX represents the revision number.

 

The IDE

The IDE of choice for Android Development is Eclipse. The most recent version of Eclipse as of this post is Eclipse Indigo, which I have some troubles getting it to work with the Android SDK, so my recommendation is to stick with Eclipse Helios SR2, anyways its not like a lot have changed between versions. Eclipse Helios SR2  can be found here:

http://www.eclipse.org/downloads/packages/release/helios/sr2

If you want to test the newest edition of Eclipse it can be found here:

http://www.eclipse.org/downloads/

Remember to get the classic, java or javaee version of Eclipse.

Setting the Environment

This is based on my personal experience should work exactly the same in any other system.

Now go to the terminal and lets go the the location where the files where downloaded.

Now uncompress the files with the `tar -xf` command. Example:

tar -xf  eclipse-java-indigo-SR1-linux-gtk-x86_64.tar.gz

tar -xf  android-sdk_r15-linux.tgz

Is also really handy to add the location of you sdk to your path, this can be done this way:

Edit your ~/.bash_profile or ~/.bashrc file. Look for a line that sets the PATH environment variable and add the full path to the tools/ and platform-tools/ directories to it. If you don’t see a line setting the path, you can add one:

  • export PATH=${PATH}:<sdk>/tools:<sdk>/platform-tools

Now lets move the folders to a location we can access them easily. We are going to make eclipse executable and then move eclipse/ to /usr/local/lib/ and create a link to the binary file in /usr/loca/bin/, for this we are going to do:

chmod +x ./eclipse/eclipse

sudo mv ./eclipse /usr/loca/lib

sudo ln /usr/local/lib/eclipse/eclipse /usr/local/bin/eclipse

Now lets move the folder android-sdk to the home directory and make it not visible:

mv ./android-sdk ~/.android-sdk

Note:

If you are developing on a 64-bit machiine you may need some 32bit libs so you can execute this files. Assuming you are in ubuntu, just run this command:

sudo apt-get install ia32-libs

In more recent versions of Ubuntu this libs are already included.

The Plugin

This part is really straight forward and is also cross-plataform so you can follow the instructions in here http://developer.android.com/sdk/eclipse-adt.html.

Now you will be able to access the Android SDK from Eclipse, the next step is going to be to download the components of the SDK, this part will take a long time. This is also straight forward and cross-plataform, instuctions here: http://developer.android.com/sdk/adding-components.html.

 

Up to this point you should have the Eclipse set-up, the SDK with the different components you want and an Emulator. Soon I will post some examples for people to start with ther first apps, until then you can start reading here: http://developer.android.com/resources/browser.html?tag=tutorial.


Nov 26 2011

Flood Monitor App

Category: Android App DevCesar @ 5:43 am

Last week I started working on an Android app that interact with http://flood.cs.ndsu.nodak.edu/index.php.  So far I got the main functionality working, upload comments and pictures and a map for viewing the markers posted. I am still waiting for a server-side php application to be ready so I can read the database and project markers on the map, but that I a simple job to do.  Here is an example of what is done so far.

Tags: , , ,


Aug 03 2011

Android Wars Update

Category: Android,AndroidWars,My stuffCesar @ 7:57 pm

So I last week I meet the people from the CustomWars forums, mainly  JakeSamiRulz who helped me a lot by providing me with guidelines and his experience for doing a AW style of game.  Now I have joined their team and even though we are not working in the same game, our projects share a lot of similarities and we will work together to bring our own projects to finish. I also decided to open source my code, in an attempt to get one of my goal which was to bring this game to as many people as possible and if possible even get other people involved. I will post more info and some links in the near future once all the merge is done.


Jun 04 2011

Acer Aspire One 532h Linux guide

Category: My stuffCesar @ 11:22 pm

This little machine is a good and sturdy friend. Despite that, I have being having some problems with some part of the hardware. The main problems for me is the lack of multitouch in some cases(depending on the OS and kernel), the mic that is terribly faulty and the lack of support for the sd car reader.

 

Multitouch: The trackpad wont show multitouch support for some linux versions depending on the distro or kernel. Most commonly I had this problem in ubuntu 10.04 and 10.10. For fixing this, download this package:

https://launchpadlibrarian.net/60964128/synaptics-dkms_1.1.1_all.deb

Install and enable multitouch in the mouse settings.

 

SD Card reader: The sd card reader uses weird proprietary drivers and was not really intended to use in linux.  Me and other usesr were figthing for a while to get this working. Finally a patch was submitted and I made a script(which I lost and now I founf it fryliyng throught the internet) both can be found in here:

https://bugs.launchpad.net/ubuntu/+source/linux/+bug/530277

 

Finally, for the mic,  think the mic is just really bad and it doesnt even work properly on Windows. To get sound from the mic follow the steps in this forum:

http://ubuntuforums.org/showthread.php?t=1379587

 

If the fact that the F2 key doenst work properly you can try this:

http://forum.eeeuser.com/viewtopic.php?id=8636

I haven’t tried it as I really don’t care about not being able to turnoff the wifi. But you can give it a try, it most probably work.

 

Have fun :)


Jun 02 2011

Update

Category: Android,AndroidWarsCesar @ 1:57 am

I have being really busy this last days, I had to move to a new place and on top of that I got sick, so really coding was not a priority :( . Now I feel better and in college we had a guy from EA that came to talk about social gaming and the evolution of this new trend. I was not expecting anything special but I have to  admit the talk was really cool and gave me a good overview of how the big companies are dealing with this new form of entertainment. Lets see if I manage to add some social feature to AW :)


Apr 20 2011

Android-Wars Project

Category: Android,AndroidWarsCesar @ 6:17 pm

The project have been going slowly but never stopped. I have started  a new Design Document for the project which is in the repo. I have also fixed some issues and keep working on the classes for the main game activity. More updates coming soon.


Next Page »