5,598,779 Members 34,378 Now Online
XDA Developers Android and Mobile Development Forum

[GUIDE] Native Debian on Samsung Galaxy i7500

Tip us?
(Last edited by frank47; 26th January 2014 at 01:57 PM.) Reason: Updated clock settings
Junior Member - OP
Thanks Meter 1
Posts: 8
Join Date: Oct 2013
Default [GUIDE] Native Debian on Samsung Galaxy i7500

Hello fellow phone enthusiasts,

there are some sources on the internet describing how to run Debian on the Samsung Galaxy i7500 (Samsung's first Android device). Unfortunately, none of these sources can act as a complete guide, so I thought I could try to fill this void. This guide is far from complete and will hopefully grow over time. Anyway, I hope this is helpful for some people that are trying to do the same.

Note that this post should have gone into the development section, but I'm not senior enough to post there. Also the URLs in this guide are messed up for the same reason. Each messed up URL is marked with "(FIX this url)". I will fix these things as soon as possible, if there is any interest in this guide.

Best regards,

This guide is for experienced users only. You might brick your phone while following this guide. I will not take responsibilty for any harm that may happen to you, your phone or those around you when following this guide. Please read and understand the complete guide before doing the first step. You have been warned.

Make a nandroid backup (can be done in the recovery image). Really, do it. Even if you think there's no valuable data, you must do a nandroid backub, because you will need to have the boot.img to boot back into android after debian has been installed. You must also copy your nandroid backup onto your PC.

1. Credits
A few years ago, there has been quite an active development community for the Galaxy i7500. Unfortunately, these forums have now pretty much died and I was not an active member of that community, because I was using it as my primary device back then and had no interest in hacking it.

Anyway, a HUGE THANK YOU goes to the fine fellas from drakaz.com and the GAOSP. You guys are awesome!

The actual hard technical work for this guide has been done by the authors of the following guides. I'm simply trying to understand what they did and write a step-by-step guide using their expertise:
  • (FIX this url)https :// code . google . com/p/linux-on-android/wiki/BasicSteps
  • (FIX this url)https :// wiki . debian . org/ChrootOnAndroid
  • (FIX this url)http :// www . bananenfisch . net/?p=1056
  • (FIX this url)https :// sven . killig . de/android/console.html

2. Overview
The goal of this guide is to have a running Debian Squeeze (Debian 6) running natively on a Samsung Galaxy i7500. Debian will not be run in a chroot environment on top of android, but instead the phone will directly boot into debian when powering it on. Debian will be installed on a SD card, so that we could still boot into Android, should we really mess things up at some point. It will not be true dual boot though (i.e. you have to reflash the boot section from a PC to boot into Android).

2.1 Primary goals
In the end, I'd like have the following functionality:
  • WLAN
  • Bluetooth
  • X Window / Graphical User Interface

All this is possible with below description now.

But this means we will loose the ability to make phone calls, send text messages, use GPS, connect to the internet through 3G or anything else you would normally expect from a smartphone. It's very likely possible to also have this functionality included, but I simply don't need it for my project. If someone else is willing to investigate this, I would be interested in the results though.

2.2 Prerequisites
Things you'll need include:
  • good Linux knowlegde
  • 1 rooted Samsung Galaxy i7500 (I recommend to flash GAOSP)
  • 1 micro SD card (I'm using an 8 GiB class 4 card)
  • 1 computer running Linux with the following software installed (I'm using Debian & Fedora, but any distribution that has debootstrap should work)
  • debootstrap
  • git
  • fastboot (I suggest to use the version that comes with your distro, but you can also try the one from the Android SDK)
  • GCC cross-compiler for ARM in order to compile the kernel (Debian and Fedora come with compiler versions, that didn't work for me, so I'm using version 7 of the Android NDK, i. e. GCC version 4.4.3)

3. Installing Debian
Note that I had already GAOSP2 beta 3 installed on the i7500. I don't know if any of these steps are possible without installing GAOSP first.

3.1 Prepare partitions on SD card
The Samsung Galaxy i7500 has an "internal SD card" which will be preserved for use with Android, the recovery image, a.s.o. The external SD card will be used for debian. ALL data on the external card will be lost after below steps.
  1. Put the SD card into an SD card reader or boot the i7500 into recovery mode (press "vol-" and "call" buttons when switching on the phone). Note that using GAOSP directly didn't work for me, because for some reason only the first partition was shown on the PC.
  2. Code:
    cfdisk /dev/sdX
    (replace X with the correct letter for your SD card, and then create the one big enough partition for your needs, I created one 4GiB primary partition leaving me 4GiB for playing around later)
  3. Code:
    sudo mke2fs /dev/sdX1

3.2 Build debian filesystem structure
Create a directory for the newly created debian partition (I assume it' s called "debian") and run the following commands
  1. Code:
    sudo mount /dev/sdX1 ./debian/
  2. Code:
    sudo debootstrap --verbose --arch armel --foreign squeeze ./debian/ (FIX this url) http :// ftp . de . debian . org/debian
  3. Code:
    sudo umount ./debian/

3.3 Finalize the debian installation
The following is based on the steps as described here (FIX this url) wiki. debian.org/ChrootOnAndroid and www . bananenfisch .net/?p=1056.
  1. Boot phone into GAOSP
  2. Open terminal
  3. Code:
  4. Code:
    cd /data/local
  5. Code:
    mkdir debian
  6. Code:
    mount /dev/block/mmcblk1p1 /data/local/debian

Finalize bootstrap:
chroot /data/local/debian /debootstrap/debootstrap --second-stage
Mount special file systems and chroot into Debian:
  1. Code:
    for f in dev dev/pts proc sys ; do mount -o bind /$f /data/local/debian /$f ; done
  2. Code:
    chroot /data/local/debian /bin/bash

Finalise the installation:
  1. Code:
    echo "deb (FIX this url) http :// ftp . de . debian . org/debian/ squeeze main non-free contrib" > /etc/apt/sources.list
  2. Code:
    apt-get update
  3. Code:
    rm -f /etc/mtab
  4. Code:
    ln -s /proc/mounts /etc/mtab
  5. Code:
    passwd root
  6. Code:
    echo i7500 > /etc/hostname
  7. Code:
    apt-get install openssh-server
  8. Code:
    apt-get clean && apt-get autoclean

The ssh-sever can be started whenever you like through
/etc/init.d/ssh start
Afterwards you can log in from your PC using "ssh root@" into the chroot environment.

3.4 Configure locale
We need to set the locale for the system (otherwise there will always be warning messages, e.g. when installing new software):
  1. Code:
    apt-get install locales console-data keyboard-configuration

You might want to tweak a few more settings (especially if your locale is not en_US). You can use:
  1. Code:
    echo export LANG=en_US.UTF-8 >> /root/.bashrc
  2. Code:
    export LC_ALL="en_US.utf8"
  3. Code:
    dpkg-reconfigure locales
  4. Code:
    dpkg-reconfigure console-data
  5. Code:
    dpkg-reconfigure keyboard-configuration

3.5 Installing additional software
You can now start installing additional software that you might need (I suggest you log into your phone through ssh as described above). You'll be needing an editor to edit configuration files (I choose vim). For setting up WiFi the package "wpasupplicant" is needed.
apt-get install vim less wpasupplicant
3.6 Chroot into debian
If you at a later time want to chroot into your debian environment, I recommend to store the following commands in a shell script (I stored it in /data/local/debian.sh) which you can then run as root.
mount /dev/block/mmcblk1p1 /data/local/debian
for f in dev dev/pts proc sys ; do mount -o bind /$f /data/local/debian/$f ; done
chroot /data/local/debian /bin/bash

4. Create boot image
4.1 Build kernel
Perform the following steps on your PC:
  1. Download the Galaxo kernel sources: git clone (FIX this url) https :// github . com/drakaz/GalaxoKernel.git
  2. Apply the patch described on (FIX this url) https :// code . google . com/p/linux-on-android/wiki/BasicSteps (themddi_toshiba_smd.c patch doesn't work, do the change manually)
  3. Apply patch as described here: (FIX this url) http :// sven . killig . de/android/console.html
  4. copy attached config.txt file to .config

I will eventually create a branch on github containing the patches and default config. But for now, you'll have to do the patching yourself.
  1. Code:
    make ARCH=arm CROSS_COMPILE=/path/to/android-ndk-r7/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi- oldconfig
  2. Code:
    make ARCH=arm CROSS_COMPILE=/path/to/android-ndk-r7/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-
  3. Code:
    make ARCH=arm CROSS_COMPILE=/path/to/android/android-ndk-r7/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi- modules

4.2 Install modules
The modules need to be installed on the SD card partition, so you need to boot your phone into recovery and mount the SD card. Then execute the following command.
sudo make ARCH=arm CROSS_COMPILE=/path/to/android-ndk-r7/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi- INSTALL_MOD_PATH=/path/to/sdcard modules_install
In order for the WLAN kernel module to work the following files need to be copied from the GAOSP ROM to the /etc/ folder on the phone:
  1. rtecdc.bin
  2. nvram.txt

4.3 Minimal boot file system
A boot file system (a.k.a. initramfs) is needed to start the debian boot process. Create a folder called minimal_initramfs with the follwoing content:
|-- dev/
|-- init*
|-- mnt/
|   `-- root/
|-- proc/
|-- sbin/
|   `-- busybox*
`-- sys/
A binary of busybox can be downloaded from the busybox website (use busybox-armv4tl). The file "init" is actually a shell script with the following content:
#!/sbin/busybox sh
# initramfs pre-boot init script

# Something (what?) needs a few cycles here
/sbin/busybox sleep 1

# Populate /dev
/sbin/busybox mknod /dev/mmcblk1p1 b 179 9

# Mount the root filesystem, second partition on micro SDcard
/sbin/busybox mount -t ext2 -o noatime,nodiratime /dev/mmcblk1p1 /mnt/root

# Transfer root to SDcard
exec /sbin/busybox switch_root /mnt/root /sbin/init
The directory structure must then be compressed. To do this run the following sequence of commands when in the minimal_initramfs directory:
find . | cpio --quiet -H newc -o | gzip > ../minimal.cpio.gz
4.4 Creating the image
For creating the image you need the tool mkbootimg which you can find in android_bootimg_tools.tar.gz. Run the following command to create the boot image from the initramfs and the kernel you created above:
./mkbootimg --kernel /path/to/Galaxo-kernel/arch/arm/boot/zImage --ramdisk /path/to/minimal.cpio.gz --cmdline "fbcon=font:VGA8x8" --pagesize 2048 --base 10000000 -o debian_boot.img
5. Configuring network
5.1 Setting up the interface
Your /etc/network/interfaces file on the phone should look like this:
# Used by ifup(8) and ifdown(8). See the interfaces(5) manpage or
# /usr/share/doc/ifupdown/examples for more information.
auto lo
iface lo inet loopback

auto eth0
allow-hotplug eth0

iface eth0 inet dhcp
wpa-driver wext
wpa-conf /etc/wpa_supplicant.conf
5.2 Setting up wireless encryption
For network configuration we'll be using wpa_supplicant which we already installed in one of the above steps. On the phone create the file /etc/wpa_supplicant.conf with the following content. Please enter the correct values for ssid, psk and key_mgmt for your network:
5.3 Loading drivers
In order for the WLAN kernel module to be loaded add the following line to /etc/modules:
bcm4325 firmware_path=/etc/rtecdc.bin nvram_path=/etc/nvram.txt
6. Flashing the boot image and booting into Debian
Now it's finally time to finally flash the previously created boot image. At this time, be sure that you only have your Galaxy connected to your PC. Otherwise you might brick any other connected phone. On the PC run
sudo fastboot flash boot debian_boot.img
Then boot the Galaxy into fastboot mode by pressing "call" when powering on the phone.

When the process is finished the phone will boot into Debian and automatically connect to your wireless network (if the set-up was correct). You can now connect to the phone through ssh and enjoy your new pocket server.

If you may ever want to boot into android again, you just need to flash the original boot.img that you created with nandroid:
sudo fastboot flash boot boot.img
7. Bluetooth
7.1 Compile brcm_patchram_plus
For getting bluetooth operational it is necessary to use Broadcom's brcm_patchram_plus software. As it is not available as a Debian Squeeze package, we need to compile it ourselves. So we need to install the following packages on the phone:
apt-get install git gcc make libbluetooth-dev
Then it's possible to download the sources:
git clone (FIX this url)https :// github . com / MarkMendelsohn / brcm_patchram.git
And compile the tool using:
7.2 Activating bluetooth
In order for bluetooth to work the following files need to be copied from the GAOSP ROM to the same folder on the phone that you compiled the brcm_patchram_plus in:
  • BCM4325D1_004.002.004.0153.0156.hcd

After that it's possible to execute the followig commands:
echo 0 > /sys/class/rfkill/rfkill0/state
echo 1 > /sys/class/rfkill/rfkill0/state
./brcm_patchram_plus -d --enable_hci --baudrate 3000000 --use_baudrate_for_download --patchram BCM4325D1_004.002.004.0153.0156.hcd /dev/ttyHS0
The last command will never terminate and you will get a lot of output due to the (-d) switch. After starting a new console, you will be able to scan for bluetooth devices using:
hcitool -i hci0 scan
7.3 Connecting a keyboard
I'm using a Rapoo E6100 keyboard and the following procedure worked fine for me. It should be similar with other keyboards.
apt-get install python-bluez python-gobject python-dbus bluez-compat
cd /usr/share/doc/bluez/examples
Press pairing button on keyboard then
./simple-agent hci0 6C:xx:xx:xx:xx:xx
(use the bluetooth address of your keyboard, according to the scan in the previous chapter)
The script will ask for a PIN. I entered 0000 on both the keyboard and phone and the keyboard was registered.
./test-device trusted 6C:xx:xx:xx:xx:xx yes
(again use the bluetooth address of your keyboard)

hidd --connect 6C:xx:xx:xx:xx:xx
Now you should be good to use your keyboard.

7.4 Automate patchram
Right now, the KB is not automatically connected on boot, because the patchram command from above needs to be executed on every boot. Hence the following commands should be added to /etc/rc.local (before the exit 0):
#Activate bluetooth
echo 0 > /sys/class/rfkill/rfkill0/state
echo 1 > /sys/class/rfkill/rfkill0/state
/path/to/brcm_patchram_plus --enable_hci --baudrate 3000000 --use_baudrate_for_download --patchram /path/to/BCM4325D1_004.002.004.0153.0156.hcd /dev/ttyHS0 &

8. Setting the clock
I was having trouble with my clock forgetting the day and time after each reboot. It was a flaw in my kernel config. In the current version of attached config file this is fixed. Anyway, I'm also running NTP to have the clock more accurate.
apt-get install ntpdate
NTP already come nicely pre-configured (thanks, Debian maintainers!). After that the timezone can be selected using
dpkg-reconfigure tzdata
9. GUI (X.org)
X.org works almost out-of-the-box since we already pathed the kernel as described in chapter 4 above. Based on the description from (FIX this url)https :// code . google . com/p/linux-on-android/wiki/BasicSteps only two minor changes have been made:
  • The framebuffer device is at /dev/fb0 instead of /dev/graphcics/fb0
  • I use evdev instead of tslib, because it provided better results for me (thanks to pabs from #debian-mobile for pointing me there)

9.1 Install X.org
All we need to do is download the software
apt-get install xorg xserver-xorg-video-fbdev xserver-xorg-input-evdev
9.2 Configuring X.org
Now create /etc/X11/xorg.conf:
Section "InputDevice"
        Identifier      "Touchscreen"
        Driver          "evdev"
        Option          "Device"        "/dev/input/event2"

Section "Device"
        Identifier      "Configured Video Device"
        Driver "fbdev"
        Option          "fbdev"         "/dev/fb0"

Section "Monitor"
        Identifier      "Configured Monitor"
        Option          "DPMS"  "false"

Section "Screen"
        Identifier      "Default Screen"
        Monitor         "Configured Monitor"
        Device          "Configured Video Device"

Section "ServerLayout"
        Identifier      "Default"
        Screen          "Default Screen"
        InputDevice     "Touchscreen" "CorePointer"

Section "ServerFlags"
        Option          "DefaultServerLayout"   "Default"
9.3 Testing X.org
For testing X.org I've installed icewm and created the following /root/.xsession
exec icewm
Then just type in startx from the console and you have X. Of course you will have to change this to whatever you need or maybe even make X start on boot.

9.4 Boot into Browser
For my target system I want the phone to directly boot into a browser. This can easily be achieved by using the nodm package:
apt-get install nodm
and midori as browser:
apt-get install midori
We'll also need a user account. I called my user "default". But naturally you can of course choose whatever you like.
adduser default
Then nodm has to be configured in /etc/default/nodm:
# nodm configuration

# Set NODM_ENABLED to something different than 'false' to enable nodm

# User to autologin for

# xinit program

# First vt to try when looking for free VTs

# X session

# Options for the X server
NODM_X_OPTIONS='vt7 -nolisten tcp'

# If an X session will run for less than this time in seconds, nodm will wait an
# increasing bit of time before restarting the session.

And we have to create ~/.xsession for our user:
midori -e Fullscreen &
exec icewm
A few tweaks in the icewm config (~/.icewm/preferences) will make the window manager look more nicely:
WorkspaceNames=" 1 "
10. Power management
The kernel is already configured with many different frequency govenors. Also the default govenor is set to "ondemand" but for some reason the when looking at /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor it's using the "performance" govenor. This can be solved by simply installing cpufreq-utils:
apt-get install cpufrequtils
The default settings are already using "ondemand", which seems to be a good choice. Anyway, further optimisations can be done in /etc/default/cpufrequtils if needed.

The phone still gets a little too warm for my taste (I think warmer than in android). Maybe there's something that could fix this, but I'm not an expert.

11. Known shortcomings
  • The whole set-up is in a really, REALLY early alpha stage
  • If any of the hardware buttons is touched in text mode the phone crashes (does not happen when in X.org)
  • The screen will time-out after some time, I have no idea how to wake it up again
  • Did I mention this is in an alpha stage?

12. Future improvements
  • Switching to a newer kernel version: The latest version of GAOSP runs on kernel version 2.6.35, while this guide is using 2.6.27. I have experimented with 2.6.29, but I had trouble getting a working frame buffer.
  • Switching to the latest version of debian (wheezy).
Attached Files
File Type: txt config.txt - [Click for QR Code] (40.3 KB, 0 views)
(Last edited by frank47; 26th January 2014 at 01:58 PM.)
Junior Member - OP
Thanks Meter 1
Posts: 8
Join Date: Oct 2013
Default History

Initial version

Minimized the the init script by removing mounts for /dev, /proc, and /sys. These are not necessary and mounting /dev prevents Debian's udev from working correctly.

Added description for bluetooth.

Added description for graphical user interface (X.org).

Boot into X/Browser and power management

Updated clock settings
Junior Member - OP
Thanks Meter 1
Posts: 8
Join Date: Oct 2013
Video Video proof

Hi all,

to get a better understanding what this is all about please watch the attached video. Please excuse the poor quality and the fingerprints on the screen.

As you can see the framebuffer output has a few quirks, but hopefully this will work out as soon as X is working.

Attached Files
File Type: zip test.zip - [Click for QR Code] (7.03 MB, 11 views)
Junior Member - OP
Thanks Meter 1
Posts: 8
Join Date: Oct 2013
Smile All goals achieved

Okay, I think I now have achieved all goals. I can connect to WiFi and bluetooth. And there is a graphical user interface. Now the tweaking can start (first thing that comes to mind is powersaving). I really created this guide for myself, but I'd be happy to know if anyone else has interest in this topic.
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes