RWE: Ejabberd failed to start in Debian Wheezy

I had an old laptop that I decided would make a good toy for playing around with some lightweight server applications. It was a great candidate for several reasons. For one, I’m not using it for something else. Second, it was free. Third, it has a built in battery backup. Seemed like a win-win for me.

I’ve mentioned before that I am a member of SDF, the Super Dimensional Fortress (sdf.org), a free to the community Unix server that allows remote log in and numerous other goodies. Among those extras is the free jabber (XMPP) service for members. It’s really great, especially for free, but on several occaisions, it has been down for maintenance when I was waiting to receive a message to someone. That is a bit annoying. Obviously, server maintenance needs to happen, and I am really thankful to sdf.org for providing the service. I was just thinking that this would be a good excuse to try setting up my very own XMPP server.

Thus enter ejabberd. Ejabberd is an open source XMPP server that is available on most GNU/Linux distributions, including Debian Wheezy, which was already on my laptop. I looked up several tutorials on-line, and they all seemed to indicate that it would be super easy to set up, and I could get it up and running in a few minutes.

Screenshot_20171030-085330.png

Two days latter…..

I finally got it set up and running. No matter which tutorial I followed, none of them worked. It took hours of research (in between being a dad, husband, working person, etc.), but I finally figured out the problem. Not too many people are planning to set up their own XMPP server, and this problem is probably specific to Debian Wheezy, but I figured that I would show you the REAL steps to get this going.

The problem was that after installing ejabberd, even with the default settings, it would say:

starting service: ejabbered………………………………………………………..FAILED.

And there was no rhyme or reason why! I was only able to figure it out by running ejabberd live, so the output came to the terminal, and then I could see the issue.

# apt-get install ejabberd

If you are like me, it will fail after install.

# dpkg-reconfigure ejabberd

Set up your server name, admin, etc.

# ps axc|grep beam

# ps axc|grep epmd

Now kill both of those processes.

# nano /etc/default/ejabberd

Uncomment the ERLANG_NODE=ejabberd line, or add it if it does not exist. Save and exit that file. Not having this line caused my first failure.

Edit your  /etc/hosts file to look like this:
127.0.0.1 localhost

# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

Essentially, you need to delete any “extra” hosts in the file, just leave the localhost ones. Later, more can be added to the file once ejabberd is running, but for some reason, having extra hosts in this file cause my second failure.

Now you can start ejabberd. I recommend that the first time, you start it “live” so you can see what is happening under the hood:

# /etc/init.d/ejabberd live

But in the future, you can just start it with the usual services tags:

# service ejabberd restart

You should now have a running instance of ejabberd! Of course, now you need to add a user, if you didn’t already. Here is an example:

# ejabberdctl register userName xmppServerAddress.net superSecretPassword

And there we go! At least for me, that was enough to set up a fully functional XMPP server with ejabberd on Debian Wheezy. Of course, this still needs tuning and enabling features like blocking, encryption, etc., but hey, at least now you have something to work with!

Linux – keep it simple.

Advertisements

Geany: the little IDE that could!

geany_ide.png

Recently, while working with some older equipment, I needed a lightweight java IDE to compile some java projects. I really wasn’t looking for something quite as big as eclipse or netbeans, I just wanted a simple, one stop solution that would allow me to build java programs on an older laptop.

So, I rubbed a magic lamp, and out popped Geany!

Well, more specifically, the laptop is running Debian Wheezy, and had openJDK already installed. With that alone, I could have built java programs from the command line, but it can get a little tedious. So, I looked on the repositories for an IDE that wasn’t too large.

Thus enter Geany. I first used Geany a long time ago as a text editor on #! (CrunchBang) Linux, but revisiting the program revealed that I was not using it to it’s full potential. Specifically, you can compile, build, and run various program types from within Geany. Of course, it only outsources the commands for you, so you need a java jdk in order to compile java, or a c++ compiler to compile c++. Geany just does all the command line work for you.

What Geany does accomplish for you, however, is a great user interface with templates and the ability to organize projects or view code with different filters. As you can see in the picture, I was testing out Logic Crazy’s Alpha Beta Chess program.

As well as showing you the code, it can do parenthesis highlighting, colors for different code type, and a class and method tree on the side. It really is a great program if you need a lightweight IDE. I know that I’ll be putting it to good use.

Linux – keep it simple.

Porting Debian Linux to your cell phone part 3 of 3

If you are still with me, then you have already set up your phone to first boot Debian Linux, and then Linux will start Android in a chroot environment. Your phone is actually already running Debian Linux, just with Android being run and displayed on the screen. At any moment, you can actually stop or kill Android. At this point, you also have the power to mess Andriod up, so do be careful!

If you just tuned in, I recommend that you go back to the 1 of 3 for this post, as there is a lot of critical information you need.

Right now, you can SSH into your own Linux from the Android gui by using any ssh app to yourself as the local host, since our SSH deamon is running. What we want, though, is for your screen to display the Linux screen, instead of the Android that is running in a chroot environment.

A key part of all of this, is that Android, other than through services like SSH, does not know that Debian Linux exists and it does not have any control over the Linux system or functions. One problem with this is that Android may occaisionally crash due to memory problems, if your Linux environment is using too much RAM. Ironically, if you SSH into your Linux environment, you can use ps aux, or top to see all of Android’s running processes. Your Linux environment is now the ultimate root, because even Android doesn’t know it exists. You can log anything from Android and save it, you can stop any Android process. You have complete control over your Android system.

However, before making the “plunge” to a Linux only phone, you need a few details. The easiest way to get these is to do some research on your phone. Through SSH, run the ls command in your /dev folder, and look for “input”

[CODE]
$ cd /dev
$ ls |grep input

/dev/input
/dev/input/event7
/dev/input/event6
/dev/input/event5
/dev/input/event4
/dev/input/event3
/dev/input/event1
/dev/input/event0
/dev/input/event2
[/CODE]

On my Samsung Captivate Glide, these are all the available inputs. But what are they? Well, there are several tools to check this. The easiest way, however, is to SSH into Linux, start x11vnc in Linux, and use an app like bvncfree in Android to bring up a visual screen to work with. How you need to do this is a bit tough to describe, because it is so dependent upon your phone and setup. However, if you are using my files, the user trondroid should have a shell script in the home folder for starting jwm in this fashion.

Another way is to start the XserverXDSL app in Android, and then startx in Linux through SSH. That should get you to the same place.

Either way, you should see something similar to this (although this screenshot was taken when I was using Debian Squeeze, rather than the new files, which are Debian Jessie) :

phone

Once you have established a “visual” screen, you now should open up a terminal in your Linux screen. Remember, all input commands that you input right now are from the Android app you are using. That means the “mouse”, “click”, and “keyboard” are all virtual. You need to set up your real screen as a mouse, for motion and clicking. You also need to set up your physical buttons from your phone, and your keyboard if you have one. With your terminal open, use evtest, like so:

[CODE]
$ sudo evtest
No device specified, trying to scan all of /dev/input/event*
Available devices:
/dev/input/event0: STMPE_keypad
/dev/input/event1: mpu-accel
/dev/input/event2: sec_key
/dev/input/event3: sec_touchscreen
/dev/input/event4: proximity_sensor
/dev/input/event5: light_sensor
/dev/input/event6: HALL
/dev/input/event7: sec_touchkey
/dev/input/event8: compass_sensor
[/CODE]

This even works on your home computer. For instance, here is my laptop:

[CODE]
$ sudo evtest
No device specified, trying to scan all of /dev/input/event*
Available devices:
/dev/input/event0: Sleep Button
/dev/input/event1: Lid Switch
/dev/input/event2: Power Button
/dev/input/event3: AT Translated Set 2 keyboard
/dev/input/event4: Logitech USB Optical Mouse
/dev/input/event5: SynPS/2 Synaptics TouchPad
/dev/input/event6: Video Bus
/dev/input/event7: ST LIS3LV02DL Accelerometer
/dev/input/event8: HDA ATI SB Mic
/dev/input/event9: HDA ATI SB Line
/dev/input/event10: HDA ATI SB Headphone
/dev/input/event11: HP WMI hotkeys
Select the device event number [0-11]:
[/CODE]

But we will focus on the phone. Great! Now we know what event is what input! For instance, event3 is the touchscreen. Now we have something to work with. In my case, event0 is the physical keyboard, but those are rare these days.

You can also test those inputs, by choosing a number for the device, and then using that function. Here you can see me test the “menu key” on the keyboard:

[CODE]
Menu Key on keyboard
Event: time 25170.575766, type 4 (EV_MSC), code 4 (MSC_SCAN), value 8b
Event: time 25170.575844, type 1 (EV_KEY), code 139 (KEY_MENU), value 0
Event: time 25170.575854, ————– EV_SYN ————
[/CODE]

Another great tool is called xev, again, open up a terminal and use it like this:

[CODE]
$ xev

ButtonRelease event, serial 33, synthetic NO, window 0x1e00001,
root 0x26f, subw 0x0, time 156984900, (175,123), root:(228,195),
state 0x100, button 1, same_screen YES

MotionNotify event, serial 33, synthetic NO, window 0x1e00001,
root 0x26f, subw 0x0, time 156985076, (177,123), root:(230,195),
state 0x0, is_hint 0, same_screen YES
[/CODE]

There is also xinput, here is an output from my computer:

[CODE]
$ xinput test-xi2
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ Logitech USB Optical Mouse id=9 [slave pointer (2)]
⎜ ↳ SynPS/2 Synaptics TouchPad id=11 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ Power Button id=6 [slave keyboard (3)]
↳ Video Bus id=7 [slave keyboard (3)]
↳ Sleep Button id=8 [slave keyboard (3)]
↳ AT Translated Set 2 keyboard id=10 [slave keyboard (3)]
↳ HP WMI hotkeys id=12 [slave keyboard (3)]
EVENT type 13 (RawKeyPress)
device: 3 (10)
detail: 54
valuators:

cEVENT type 14 (RawKeyRelease)
device: 3 (10)
detail: 54
valuators:

EVENT type 13 (RawKeyPress)
device: 3 (10)
detail: 40
valuators:
[/CODE]

The overall idea, though, is that you need to open up an x session, so you can then see what x inputs are matched to which event. Once you have all of this information, you can edit the /etc/X11/xorg.conf file to match. Here is the one I made for the Samsung Captivate Glide:

[CODE]
Section “ServerLayout”
Identifier “Layout0”
Screen “Screen0”
InputDevice “touchscreen” “CorePointer”
InputDevice “keyboard”
InputDevice “mediakeys”
InputDevice “frontkeys”
EndSection

Section “Monitor”
Identifier “Monitor0”
ModelName “Monitor Model”
DisplaySize 800 480
EndSection

Section “InputDevice”
Identifier “touchscreen”
Driver “evdrv”
Option “Device” “/dev/input/event3”
Driver “multitouch”
EndSection

Section “InputDevice”
Identifier “keyboard”
Driver “evdev”
Option “Device” “/dev/input/event0”
Option “CoreKeyboard”
Option “XkbRules” “xorg”
Option “XkbModel” “pc105”
Option “XkbLayout” “us”
EndSection

Section “InputDevice”
Identifier “keyboard”
Driver “evdev”
Option “Device” “/dev/input/event8”
Option “XkbRules” “xorg”
Option “XkbModel” “pc105”
Option “XkbLayout” “us”
EndSection

Section “InputDevice”
Identifier “mediakeys”
Driver “evdev”
Option “Device” “/dev/input/event2”
EndSection

Section “InputDevice”
Identifier “frontkeys”
Driver “evdev”
Option “Device” “/dev/input/event7”
EndSection

Section “Device”
Identifier “Card0”
Driver “fbdev”
Option “fbdev” “/dev/graphics/fb0”
Option “Rotate” “left”
Option “VertRefresh” “60”
EndSection

Section “Screen”
Identifier “Screen0”
Device “Card0”
DefaultDepth 16
SubSection “Display”
Depth 16
EndSubSection
EndSection
[/CODE]

Notice how you must declare a screen, a monitor, and then the card that controls it. /dev/graphics/fb0 is the framebuffer that you got the other day, if you were following along with these posts. You will also notice, that for each section, a driver is declared. The drivers used here are generic drivers. You may have different hardware, and use different drivers. So, if one doesn’t work, google the xorg.conf section and the word drivers to see some of the different drivers available. You may even need proprietary drivers specific for your device. Like I said though, these generic drivers worked great for me. So I would try those first.

Once you have your drivers and xorg.conf file all set, it is time to take the plung. Be sure to back up your system first. Remember, TWRP or CWM are your freinds, as they work outside of all of the other work you are doing. So you can always start over or go back to something else.

Now, go back to your /etc/rc.local file. It should say:

[CODE]
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will “exit 0” on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

# Start the ssh client, in the event you need it.
/etc/init.d/hostname.sh start
/etc/init.d/ssh start

# Clean up bad crash before starting x server.
# /sbin/busybox mkdir -p /tmp/.X11-unix/remove
# /sbin/busybox rmdir /tmp/.X11-unix/remove
# /sbin/busybox rmdir /tmp/.X11-unix/

# Start the x server, warning, if the touchscreen or keypad doesn’t work
# then you cannot escape without killing power!
#/usr/bin/startx &
#export USER=root
#vncserver :5000

exit 0
[/CODE]

And change the last part to say this:

[CODE]
# Start the x server, warning, if the touchscreen or keypad doesn’t work
# then you cannot escape without killing power!
/usr/bin/startx &
#export USER=root
#vncserver :5000

exit 0
[/CODE]

Now you have told it to startx on the next startup. If all goes well, reboot your phone, and you should see the XFCE desktop. If not, then you need to figure out how to edit the xorg.conf file to make it work right. You may also need to uncomment the lines about rmdir /tmp/.X11-unix, and the other lines like it, if your xserver ever crashes.

I have noticed several variants, especially on Android 4.4 and newer, that it will startx, but also start Android. You will see one normally, and then a small, pink version of the other overlayed on part of the screen. Almost like a picture in picture TV, but very dificult to understand or use. In these cases, you may need to add a command to kill surfaceflinger, or stop zygote to get Android to “clear out”. You actually could just skip Android altogether, but having the chrooted Android is great for playing with making phone calls, etc, as I do not know how to do that from Linux yet.

If you made this work then you do have some pretty good Linux skills, if I may be so bold. This is not an easy task, and not for the faint of heart. So great job! Now it is up to you to improve upon this and make it useful. Who knows, you might be giving Ubuntu Touch a run for the money!

Linux – keep it simple.

 

Porting Debian Linux to your cell phone part 2 of 3

If you are following along from the previous post: great! Good work. I’m glad that you are still with me! Today’s changes are actually all you need to do to have a dual phone, where you start Linux first, and then Linux turns on Android. With this setup, you actually have the ultimate rooted phone, because you can SSH into your own Linux, which is the boss of your Android ROM. Linux, being the head honcho, can do amazing things, such as change the size of your Android partitions! With this great power, however, comes great responsibility. So handle with care!

Now for today’s steps:

#1. Download:
Debian system (WARNING – this is almost 700 mb!)
[url]http://www.mediafire.com/download/88r6sr3u33bs532/20151106.tar.gz[/url]
Very tiny busybox (1.06 mb)
[url]http://www.mediafire.com/download/4uhu93prdtlqdmr/busybox[/url]

NOTE: These files will get you started. Later, you can build your own busybox and Linux root file system if you want, these worked for me, so I think it is best to start by using a known working source.

#2. Partition your sdcard:
I use a computer to do this, but there are many phone tools available also. You can later transfer all of this internally, and do this without an sdcard, but this is the best way to get started, as you learn, you can move it all to the phone.

My computer has an sdcard slot, you may use an adapter, or use your phone, it really doesn’t matter. The sizes here are a suggestion, but you will need 2 partitions on the card. I am using an 8 GB card as my example.

Partition Type Size Notes
1 fat32/vfat 2 GB (or more if your card is bigger)
2 ext4 6 GB (or the remainder)

Now, the first partition will be “seen” by Android. The second partition will not typically be seen by Android.

#3. Unzip the Debian system.
First, make a folder in your playgroup folder called sdcard. (~/playgroup/sdcard)
Right clicking on it will most likely work, depending on your distribution, but if you use the terminal, the command unzip should do it. When you unzip the file, it may error after completing the task, that is usually okay. It is a difference in zip endings for Linux/Windows. All the 97151 files should be there, you can right click on the folder to verify. It will be in a folder called 20151106, in that folder, you will see a bunch of folders, such as android, proc, lib, etc, and so on. Copy all of those files to your ~/playgroup/sdcard folder.

Now you have a basic Debian Linux system with an XFCE desktop and a user all ready to go. We will need to change a few things that are specific to your phone though to make this work right.

#4. Copy the original boot stuff to your sdcard folder.
In that ~/playgroup/sdcard folder, is a folder called android (~/playgroup/sdcard/android). This folder currently contains all of the ramdisk for the Cranium Kernel on an i927. You will go ahead and delete everything in the ~/playgroup/sdcard/android folder. It is useless to you.

When you broke down your boot.img file, you were given a new folder called “./boot.img-ramdisk/” this is the contents of your ramdisk for your kernel. Copy all of the files in the boot.img-ramdisk folder to the android folder. Make sure you copy, not move, you will need the other copy for modification shortly.

#5. Gather some information.
Install CM11 to your phone, if you have not already done so. Insert your sdcard. Turn on your phone. Once done, we need to get some information from it. Install a terminal app and give it root permission, or use adb shell from you computer, either way works. Now gather the following information:

[CODE]
$ su
# mount

…..info you need…..
[/CODE]

Write down, copy, or screenshot all of this information.

[CODE]
$ su
# ls /dev
…..info you need…..
# ls /dev/input
…..info you need…..
# ls /dev/graphic <—–(or graphics depending on your phone)
…..info you need…..
[/CODE]

Write down, copy, or screenshot all of this information. You may need some of it later.
WHY:
We will need the partition details and the frame buffer details.

Turn off your phone and remove the sdcard.

#6. Make some changes to init.stage2 file.
There should be a file called init.stage2 in the etc folder: ~/playgroup/sdcard/etc/init.stage2
Open that file with a text editor. Line 43 should say this:

[CODE]
export FRAMEBUFFER=/dev/graphics/fb1
[/CODE]

Change the last part “fb1” to be the earliest fb you wrote down from step 5: “# ls /dev/graphic”. So if you have an fb0, put that here. If it starts at fb1, put that here. save the file. You can close that now.
WHY:
Currently, it was set to the frame buffer I was using. We need the frame buffer (screen) for your phone.

#7. Edit your rc.local file.

Open the ~/playgroup/sdcard/etc/rc.local file.

NOTE: There is also an ~/playgroup/sdcard/etc/init.d/rc.local file, that is not the file you want.

It should say:

[CODE]
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will “exit 0” on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

# Start the ssh client, in the event you need it.
/etc/init.d/hostname.sh start
/etc/init.d/ssh start

# Clean up bad crash before starting x server.
# /sbin/busybox mkdir -p /tmp/.X11-unix/remove
# /sbin/busybox rmdir /tmp/.X11-unix/remove
# /sbin/busybox rmdir /tmp/.X11-unix/

# Start the x server, warning, if the touchscreen or keypad doesn’t work
# then you cannot escape without killing power!
/usr/bin/startx &
#export USER=root
#vncserver :5000

exit 0
[/CODE]

At this time, change it to say:

[CODE]
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will “exit 0” on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

# Start the ssh client, in the event you need it.
/etc/init.d/hostname.sh start
/etc/init.d/ssh start

# Clean up bad crash before starting x server.
# /sbin/busybox mkdir -p /tmp/.X11-unix/remove
# /sbin/busybox rmdir /tmp/.X11-unix/remove
# /sbin/busybox rmdir /tmp/.X11-unix/

# Start the x server, warning, if the touchscreen or keypad doesn’t work
# then you cannot escape without killing power!
#/usr/bin/startx &
#export USER=root
#vncserver :5000

exit 0
[/CODE]

Save the file, and you may now close that window.
WHY:
Currently, it was set to start the openssh server, then the x server. We want to only start the ssh server so we can get the proper information for the x server. We will change this file back later when we have the information.
#8. Put Debian Linux on the sdcard’s second partition:
Here is where things will differ for you and me. I don’t know where your card will mount, your system may auto-mount your sdcard when you put it in, but here is what you need to do:

-Mount the second partition to /mnt, or figure out where it is mounted.

[CODE]
$ cd ~/playgroup/sdcard/
$ sudo su
<enter your password>
# cp -Rav ./* /mnt
# sync
# exit
$ exit
[/CODE]
WHY:
If you drag and drop, some files will not copy right. We need all files to have the proper permissions and the proper file attributes.
Now you can un-mount the partitions and remove the sdcard from the computer/adapter.

#9. Prep your new boot image.
Okay, here is where rubber meets the road. Follow close, because this is really important.
The

[CODE]<—[/CODE]

are my comments, don’t type those (obviously).

[CODE]
$ cd ~/playgroup/bootimage/boot.img-ramdisk/ <—to get to the right place.
$ rm -rf * <—to empty out the ramdisk
$ mkdir data
$ mkdir dev
$ mkdir mnt
$ mkdir proc
$ mkdir sbin
$ mkdir sys
$ mkdir system
$ touch init
$ mkdir ./mnt/root
[/CODE]
WHY:
This makes the empty directory that you need. Most of this will be populated when the phone starts by busybox.

Remember that busybox file you downloaded? copy it into the sbin folder. This busybox will actually be the heart and soul of your computer/phone during startup. The Kernel will only interface with it at first.

Now open the init file with gedit or some other text editor, and fill it in with this:

[CODE]
#!/sbin/busybox sh

# initramfs pre-boot init script

# Mount the /proc and /sys filesystems
/sbin/busybox mount -t proc none /proc
/sbin/busybox mount -t sysfs none /sys
/sbin/busybox mount -t tmpfs none /dev

# System needs a few cycles here
/sbin/busybox sleep 1

# Populate /dev
/sbin/busybox mdev -s

# Mount the root filesystem, second partition on micro SDcard
/sbin/busybox mount -t ext4 -o noatime,nodiratime,errors=panic /dev/mmcblk1p2 /mnt/root

# Clean up
/sbin/busybox umount /proc
/sbin/busybox umount /sys
/sbin/busybox umount /dev

# Transfer root to SDcard
exec /sbin/busybox switch_root /mnt/root /etc/init
[/CODE]

Save the file and close it. Now, this only works if your step 5: “ls /dev” has /dev/mmcblk1p1 and /dev/mmcblk1p2, and no higher /dev/mmcblk1p* numbers. There should also be a bunch of /dev/mmcblk0p* numbers, that is okay, that is your phone’s internal storage. This should be correct, but if you do not have that in step 5, then let me know and we will look at your output from step 5.

Next, we will create the boot image. REMINDER: the mkbootimg line below was for the Samsung Galaxy Core 2 SM-G355HN! Put your boot parameters in that you got from the previous posts instructions on how to “break down” the boot image with unmkbootimg!

[CODE]
$ cd ~/playgroup/bootimage
$ rm initramfs.cpio.gz
$ cd ./boot.img-ramdisk/
$ sudo su
<enter your password>
# chmod a+x ./init
# chmod a+x ./sbin/busybox
# find . | cpio –quiet -H newc -o | gzip > ../initramfs.cpio.gz
# cd ..
# mkbootimg –kernel zImage –ramdisk initramfs.cpio.gz –base 0x0 –cmdline ‘console=ttyS1,115200n8 androidboot.selinux=permissive’ -o new_boot.img
[/CODE]

-With fastboot, heimdall, heimdall-frontend, or Odin, flash the new_boot.img to the boot partition of your phone. Make sure you already have your prepared sdcard in your phone. If it auto rebooted, proceed to step 10. If not, power off when done, then power on and go to the next step.

#10. Reboot your phone.
So, make sure your prepared sdcard is in the phone. Your phone probably rebooted when you flashed the new boot image. For the most part, if this worked, boot up will look normal. If it did not work. It should not have booted. CM11 will start and you will have no idea that anything is different. However, if it booted, there is a difference now, and there are a few easy ways to see it.

Install an ssh app on your phone from the play store or with adb. Remember in step 7, we left the openssh server running. This is your ticket “in” to the Linux that is actually in charge of your phone.

open-ssh is installed and running, so using the ssh app, set it for: trondroid@localhost
username is trondroid, password is trondroid

If successful, it should log into the command line of your Debian Linux powered phone! A couple things to remember:
root user has a password of root.
me has a password of me.
trondroid has a password of trondroid. trondroid also has sudo permission.

If you turn on the WiFi in Android, and your computer is on the same network, you can run this in your computer’s terminal to access the phone:
ssh trondroid@xxx.xxx.xxx.xxx (The IP address of your phone, get it from your settings menu.)

Debian actually is CM11’s boss. Debian can delete/move/modify anything in CM11’s world. BE CAREFUL! This is the ultimate root! You can even re-size CM11’s partitions from here. SO BE CAREFUL!

Apt-get works to download any Debian programs you want. We will hopefully get into the graphical stuff in the next few posts. Congratulations! You made it work. Now we just have to set up the buttons, keys, xorg.config, and sound for the Debian part, which we will do next. Let me know how it went, and if you have any trouble! Play around and have fun! Technically, you can stop here if you only want text/console based applications. If you want more, like graphics, you are now 2/3 of the way there! You have successfully put Debian Linux on your phone! Now we just need to finish setting up, so you can have full access and the Graphical User Interface!

Linux – keep it simple.

 

Porting Debian Linux to your cell phone part 1 of 3

First and formost, I would like to clear the air. This is not a set of instructions on how to put Linux on your phone, as you would do with apps like Linux Deploy. This is also not for the faint of heart. This is a step by step tutorial on how to turn your phone FROM Android TO Debian Linux.

As we saw in my earlier posts, this was successful on a Samsung Captivate Glide (i927), here are some screenshots:

Warning: This will either be successful, or you will never be able to use your phone again. Perhaps there are some happy mediums in between. In either event, please read carefully, and tailor the instructions to your device and needs. These instructions were originally posted by me on this forum at XDA: http://forum.xda-developers.com/showpost.php?p=67713159&postcount=20&nocache=1&z=9396170606494306

In this post, I am trying to assist a user to change my original work, which was for the i927, Samsung Captivate Glide, to his phone, the Samsung Galaxy Core 2 SM-G355HN. Available to him was CM11. So, to follow these instructions on another phone, download the appropriate rom for your phone. The older the rom the better, as they typically have less stringent controls and more available ram.

Okay, so first things first, STEP 1: downloads!

Download these things:
[url]http://www.mediafire.com/download/zl80gh0t310trla/unpack-bootimg.pl[/url]

[url]http://www.mediafire.com/download/xdmd278n17gm58h/unmkbootimg[/url]

[url]http://www.mediafire.com/download/byf0tw4ga2mqtw0/repack-bootimg.pl[/url]

[url]http://www.mediafire.com/download/7cmi548pzetc6c4/mkbootimg[/url]

And download CM11, if you have not already. (Download the rom appropriate for your phone!)

I am using Linux, Ubuntu 14.04. I did this previously from Debian Wheezy, so any Linux should work. You can also use a VM, virtualbox, etc. if you are on a Windows computer.

STEP 2: Unzip!
Go ahead and unzip the CM11 that you downloaded. Preferably in its very own folder. For my work, I made a folder called “playground” in my home directory to play around in. I will reference the “playground” meaning the main folder with everything in it. Now, in the playground, make a new folder called “bootimage”. In the playground folder, copy the boot.img file to the bootimage folder.

STEP 3: Tools setup!
Copy the downloaded above tools into a new folder called “tools” in the playground folder. Open a terminal here and give these files executable permissions and copy them again to the bootimage folder:

[CODE]
$ cd ~/playground/tools
$ chmod 777 ./*
$ cp ./ ../bootimage
[/CODE]

We copy this twice so we have backups of the tools in case we delete them accidentally.

STEP 4: Unpack the boot image!
Open a terminal and go to the bootimage folder, and start typing:

[CODE]
$ cd ~/playground/bootimage
$ ./unmkbootimg ./bootimage
[/CODE]

You will see some output in the terminal that looks *kind of* like this:

[CODE]
$ ./unmkbootimg ./boot.img
unmkbootimg version 1.2 – Mikael Q Kuisma <kuisma@ping.se>
Kernel size 2992704
Kernel address 0x10008000
Ramdisk size 2196028
Ramdisk address 0x11000000
Secondary size 0
Secondary address 0x10f00000
Kernel tags address 0x10000100
Flash page size 2048
Board name is “”
Command line “”
This image is built using standard mkbootimg
Extracting kernel to file zImage …
Extracting root filesystem to file initramfs.cpio.gz …
All done.
—————
To recompile this image, use:
mkbootimg –kernel zImage –ramdisk initramfs.cpio.gz -o new_boot.img
—————
[/CODE]

Whatever it says, copy and paste it, hand type it, screenshot, whatever it takes, write the output down, because this is the key to re-making your boot image! I recommend that you post the output here on XDA so we can look at it together.

Then, unpack it like so:

[CODE]
$ ./unpack-bootimg.pl ./boot.img
[/CODE]

You should see something *like* this:

[CODE]
$ ./unpack-bootimg.pl ./boot.img
kernel written to ./boot.img-kernel.gz
ramdisk written to ./boot.img-ramdisk.cpio.gz
7607 blocks

extracted ramdisk contents to directory ./boot.img-ramdisk/
[/CODE]

You will now have folders and files to play with. In the next post, we will make our init script and continue on. You are 1/3 of the way there!

Linux – keep it simple.

 

Optional instructions: Adding repositories to your i927 as a Debian “Chatter” Phone

I have adapted some work that I did a while back on the Samsung Captivate Glide (i927), the official post, etc, can be found here: http://forum.xda-developers.com/captivate-glide/general/samsung-captivate-glide-debian-chatter-t3233807

I also made a post about this earlier, which you can read here:

So, if you read the post the other day, and downloaded and turned your i927 into a Debian Linux computer, you probably want to know how you can add the Debian repositories to your sdcard, since it is difficult to connect to the internet. These instructions are optional, but highly recommended….

If you want to, head over to the Debian Jessie download page and download the arm version of the DVD’s 1 and/or 2. In this post I describe how you can rip these cd’s to set up a personal repository, one that you can strictly control all of the packages, which may be useful at this time.

Here are the links for the DVD’s:

[url]http://cdimage.debian.org/debian-cd/8.2.0/armhf/iso-dvd/debian-8.2.0-armhf-DVD-1.iso[/url]
[url]http://cdimage.debian.org/debian-cd/8.2.0/armhf/iso-dvd/debian-update-8.2.0-armhf-DVD-1.iso[/url]

Then, on your computer:

[CODE]~$ cd {to your download directory}
~$ mkdir disk1
~$ mkdir disk2
~$ sudo mount ./debian-8.2.0-armhf-DVD-1.iso ./disk1
~$ sudo mount ./debian-update-8.2.0-armhf-DVD-1.iso ./disk2
~$ mkdir repo1
~$ mkdir repo2
~$ cd disk1
~$ find . -name *deb -exec mv ‘{}’ ../repo1/ \;
~$ cd ..
~$ cd disk2
~$ find . -name *deb -exec mv ‘{}’ ../repo2/ \;
~$ cd ..
~$ sudo umount ./disk1
~$ sudo umount ./disk2
~$ rmdir ./disk1
~$ rmdir ./disk2
~$ cd repo1
~$ sudo dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz
~$ cd ..
~$ cd repo2
~$ sudo dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz
~$ cd ..[/CODE]

Now you can copy these files to your external sdcard, mount it on your Debian Linux i927, and add these custom repositories to your /etc/apt/sources.list.

Now that we have all the information of what we did to the i927, we can turn our focus on how to do this for other Android devices.

Linux – keep it simple.

Follow up: Using your i927 as a Debian “Chatter” Phone

I have adapted some work that I did a while back on the Samsung Captivate Glide (i927), the official post, etc, can be found here: http://forum.xda-developers.com/captivate-glide/general/samsung-captivate-glide-debian-chatter-t3233807

I also made a post about this earlier, which you can read here:

So, if you read the post the other day, and downloaded and turned your i927 into a Debian Linux computer, you probably need to know some of these things below. These are some things that were still a work in progress that need to be addressed on the i927 Debian “Chatter” phone….

Phone specific things to do: (Wow this is a big list!)

GPS – I have put FoxtrotGPS and gpsd in the image. I know that /dev/ttyHS0 is the GPS output, but it appears that the GPS is of course off, because it has not been started yet. I either need to echo the appropriate digits into the /sys files, or tell the chrooted Android to turn it on. I also found that it relies on gpsd, and uses standard output to it, which is a huge plus for a Linux phone.

Phone calls/text messaging/radio control – I have not even started on that. My goal was to run a chrooted Android environment and “tell it” from Debian to make a phone call or send and receive messages.

Bluetooth – The module for the bluetooth is already loaded, and I have put the bluez and other bluetooth tools on the phone, I just cannot figure out how to connect to it. It may be powered off also.

Wifi – The modules for this are in the /android/lib/modules directory, but once I insmod them, it does not appear as a connection. I believe that I need to do some sort of mknod to create a node or socket to connect to it, or have the chrooted Android turn it on.

Camera – I have not even looked at this yet.

Accelerometer/compass – I have not even looked at this yet.

Slide switch – I am hoping to use xranr and event input to rotate the screen and change the resolution if you slide out the keyboard.

[CODE]Available devices:
/dev/input/event0: STMPE_keypad – The physical keyboard.
/dev/input/event1: mpu-accel
/dev/input/event2: sec_key – Physical keys – Volume +/- and power.
/dev/input/event3: sec_touchscreen – The touchscreen input.
/dev/input/event4: proximity_sensor – Sensor that turns off the screen when your face is against it.
/dev/input/event5: light_sensor – Ambient light sensor to control screen brightness and keyboard lights.
/dev/input/event6: HALL – Opening the slide out keyboard.
/dev/input/event7: sec_touchkey – front face soft keys – home, back, search, menu.
/dev/input/event8: compass_sensor[/CODE]

Linux specific things to do: (Wow, this is also a big list!)

lspci – lspci does not work, which hampers the ability to figure out control of some of the devices. This is a problem (I think) with the kernel / arm hardware and the way the arm ARCH is set up. It uses AMBA.

lsusb – Fixed!
– I also got an OTG cable and can plug stuff in and see it show up with lsusb!

Audio – Pulse audio fails, so I replaced it with alsa. While alsa does work, it has the uniqe problem of turning off the path to device when there is no sound playing. Currently, if you want to listen to music, you open a music player, start the music, open the alsa volume mixer, set the path to SPK_HP, and adjust the volume as desired. Once the song or play list is done, pressing play again will yield no sound until you go to the volume mixer and choose SPK_HP again.

Init – Systemd is the standard init for Debian Jessie, but it causes too many problems on the phone. It either needs to be redone, or replaced. Currently, I am using the rc.local script to start some selected services, as a userspace init, so to speak.

Dbus – dbus can be started after you enter the X window environment, e.g. after the chrooted Android is done starting. I don’t know that it is working properly.

Graphics – Currently Debian is just drawing straight to the frame buffer, it would be nice to get the nVidia drivers working for 3d acceleration.

Chrooted Android specific problems: (Not as big of a list.)

ADB – Fixed, ADB now works to connect to the chrooted Android from your computer using ADB as usual.

AM – The activity manager cannot start because we have stolen /dev/graphics/fb0 for the Debian x-server, so you cannot access the AM. If the AM can get up and running, then it would be possible to script orders to it, such as make phone calls, start wifi, etc.

SurfaceFlinger – SF is waiting for the /dev/graphics/fb0 to become available. It would be beneficial to have it “start” without it, perhaps to a virtual frame buffer, which requires a new kernel, or user-space tools like xvfb.

If you have any ideas or thoughts on how to do these things, or if you would like to tackle one of these projects, please let me know! I’d be happy to post your work and let everyone know that you came up with the solution!

As with any project, it starts somewhere, and I want to take the time to thank the following individuals for their prior work that I used as the basis of this project. These individuals may not know that their tools were used here, but I would like to thank them for posting their knowledge and or files or programs for people like me to be able to read and use:

XDA developer bubor – Seriously, this person has a lot of great material on XDA. I borrowed their TWRP recovery.img.
XDA developer mdubb2341 – I used this person’s Bio360Rom as the chrooted Android environment, due to it’s small size and resource requirements (e.g. no zRam).
Mikael Q Kuisma – [url]http://whiteboard.ping.se/Android/Debian[/url] – This guy helped tremendously with the breakdown of the boot.img and hijacking init to do what I want instead. He explains how to start Linux then Android, and use your Android phone with Linux underneath.
Eryk Wdowiak – [url]http://www.wdowiak.me/anX11phone/[/url] – This gentleman had some great material on starting Linux after starting Android and running Linux on top of Android.
Ivan Davidov – [url]http://minimal.linux-bg.org/[/url] – The tutorials on setting up minimalistic Linux environments and boot script examples were priceless.

I think tomorrow, or the next day, I will post about how to add the repositories to your phone. After that, hopefully I can start presenting how you can do this to any Android phone.

Linux – keep it simple.

Using your i927 as a Debian “Chatter” Phone

I have adapted some work that I did a while back on the Samsung Captivate Glide (i927), the official post, etc, can be found here: http://forum.xda-developers.com/captivate-glide/general/samsung-captivate-glide-debian-chatter-t3233807

A Debian phone. Not run as a tack on, not emulated, not on top of Android, but standalone. That’s my goal. That’s what I’ve was working on. Turning an old Glide into a computer. After some careful thought, I figured some other people might be interested in that too, so I thought I’d post it here. By God’s grace, it even worked as a computer. Cell phone service is still beyond my reach, but perhaps others can pick up where I left off.

Why Debian “Chatter”? Well, all Debian versions are given a name from a toy in the Pixar film Toy Story. Chatter happens to be the toy telephone in Toy Story 3. I put Chatter in quotes because it actually is not an official release. Technically, I am using Debian Jessie. Since becoming a release of Debian would be nearly impossible to spearhead from the ground level, it would most likely become an offshoot of Debian.

What I have done so far is utilize the internal “sdcard” partition as the root file system for Debian Jessie.

What’s working:
– Standard Linux functions (mostly)
– Boot up to the X server (XFCE window manager currently)
– Screen, orientation and display
– Physical keyboard (Only the qwerty part)
– Touch-screen as a touch pad to move the mouse pointer
– Battery indication including if it is charging or not
– Audio with ALSA.
– Volume buttons
– Front soft keys

Flashing instructions if your Captivate Glide already has TWRP.
[url]http://www.mediafire.com/download/z9fzrw68rio8sq9/recoveryTWRP.img[/url]
1. Download my TWRP backup, and put under the /TWRP/BACKUPS/<SERIALNUMBER>/ folder.
[url]https://www.mediafire.com/folder/9vifxpouh9voc/2015-10-20[/url]
2. Restore the image through the Restore function in TWRP.
3. Download my tar.gz file to your computer and extract it.
[url]http://www.mediafire.com/download/716x1oxcglythhk/20151102.tar.gz[/url]
Or,
[URL=”http://www.mediafire.com/download/88r6sr3u33bs532/20151106.tar.gz”%5Dhttp://www.mediafire.com/download/88r6sr3u33bs532/20151106.tar.gz%5B/URL%5D
4. Put your phone into the TWRP recovery, and choose the Mount option and select “sdcard”
5. Place the extracted contents of the dated folder onto the sdcard partition, but not the dated folder itself, just what is in it.
6. Reboot your phone into the ODIN download mode.
7. Download my 2ndboot.img file and i927.pit file.
[url]http://www.mediafire.com/download/mudjm3j3304vt77/2nboot.img[/url]
[url]http://www.mediafire.com/download/793j89i277rggpa/i927.pit[/url]
8. Using Heimdall-frontend, select the pit file, and flash the LNX partition with the 2ndboot.img file.
9. Reboot and Linux on!

Flashing instructions if your Captivate Glide already has Clockworkmod.
[url]http://www.mediafire.com/download/f64i073d65e0ug1/recoverycwm.img[/url]
1. Download my copy of Bio360Rom.zip and move it to your phones sdcard.
[url]http://www.mediafire.com/download/1u2v6aac19fzh97/Bio360ROM.zip[/url]
2. Reboot into recovery mode (Clockworkmod) and install the Bio360Rom.zip
3. Reboot your phone into the ODIN download mode.
4. Download my 2ndboot.img file, my recovery.img file, and i927.pit file.
[url]http://www.mediafire.com/download/mudjm3j3304vt77/2nboot.img[/url]
[url]http://www.mediafire.com/download/z9fzrw68rio8sq9/recoveryTWRP.img[/url]
[url]http://www.mediafire.com/download/793j89i277rggpa/i927.pit[/url]
5. Using Heimdall-frontend, select the pit file, and flash the LNX partition with the 2ndboot.img file.
6. Again using Heimdall-frontend, select the pit file, and flash the SOS partition with the recovery.img file.
7. Put your phone into the TWRP recovery, and choose the Mount option and select “sdcard”
8. Download my tar.gz file to your computer and extract it. Place the extracted contents of the dated folder onto the sdcard partition, but not the dated folder itself, just what is in it.
[url]http://www.mediafire.com/download/716x1oxcglythhk/20151102.tar.gz[/url]
Or,
[URL=”http://www.mediafire.com/download/88r6sr3u33bs532/20151106.tar.gz”%5Dhttp://www.mediafire.com/download/88r6sr3u33bs532/20151106.tar.gz%5B/URL%5D
9. Reboot and Linux on!

Optional instructions:
If you want to, head over to the Debian Jessie download page and download the arm version of the DVD’s 1 and/or 2. In the following posts I describe how you can rip these cd’s to set up a personal repository, one that you can strictly control all of the packages, which may be useful at this time.

Changelog:

[CODE]
Changelog – Debian “Chatter” using Canium Kernel

20151106
– Added shutdown.sh and reboot.sh to launcher for *better* handling of shutdown.

20151102
– Mapped soft keys: search – xfce-appfinder
– Mapped soft keys: back – xfce-next workspace
– Mapped soft keys: home – xfce showdesktop
– Mapped soft keys: menu – xfce-showmenu
– Mapped volume up/down to amixer Master +/- 5db.
– Added “event2” to xorg.conf. Volume buttons and power button are recognized and can now be mapped to an action.
– Added “event7” to xorg.conf. front soft keys are recognized and can now be mapped to an action.
– Enabled xfce splash screen (like a boot animation.) Also enabled text update of status during start of xfce.

20151101
– Edited xfce panel and options for display of information.

20151020-2
– Moved entire system off of sdcard and onto mmcblk0p4, the “internal sdcard” of the phone.

20151020
– Due to errors with Pulseaudio, removed pavucontrol/pulseaudio. Installed all Alsa controls.
– Installed LXMusic/xmms2 for mp3 player.
– Mixer and alsa mixer can properly set volume to path SPK_HP (the speaker or headphone) and adjust the volume. However, it will mute after a few moments of inactivity. A work in progress.

20151019 Continuing the current fork of Cranium Kernel.
– Udevd is not working due to lack of devtmpfs support in kernel. Added mdev support for hotplug items by editing init.stage2 with:
/sbin/busybox echo /sbin/busybox mdev > /proc/sys/kernel/hotplug

20151018
– Backed up entire system, forking to other kernels. This backup will remain with all that is done so far. The fork has a seperate changelog.

20151016
– Enabled usb0 as a network interface in /etc/network/interfaces, can start with ~# ifup usb0.
-On receiving computer, ensure that you insmod “mii.ko” and “usbnet.ko” if not already built into your kernel. -cannot figure out how to attach to it!
^– I now realize that I would need to recompile my desktop computer kernel to support this endevour. This would distract from the process at hand. Scrapped.
– Added second armhf dvd from Debian Jessie to my local repository, and edited /etc/apt/sources to match.

20151015
– Edited xbattbar.sh script to accurately reflect if the phone is plugged in or not. – Put into 20151014 folder.

20151014
– Needed battery indicator. Added xbattbar as it is the only battery indicator with user scriptable inputs.
– Wrote script for xbattbar to work, now accurately reflects battery capacity.
– Put xbattbar in .xsession and removed xclock from .xsession

20151013
– Added XFCE4 and set as default for root in /root/.xsession file with xclock on startup for fun.

20151010
– Added local repository under folder /repo/all
– Used dpkg-scan to create Packages.gz
– Added local repository to /etc/apt/sources.list

20151008
– Added Keyboard to xorg.conf, some keys work, some do not.

20151005
– Added touchscreen to xorg.conf as “corepointer”, works to move mouse.

20150924
– Created new initramfs.cpio.gz
– Created new_boot.img
– Copied another init script and init.stage2 script onto sdcard and edited for my purposes.
– Originally booted to Linux, then started Android, and Android was what you saw.
– Edited init and init.stage2 script so that it now boots Linux, and you see Linux. Android is running in chroot env. but cannot start fully due to /dev/graphics/fb0 is in use.

20150921
– Started with debootstrap base image of Debian Jessie
– Added openssh, vnc, lxde, jwm, and some other programs through emulator.
– Broke down Biorom kernel and initramfs. Using Cranium Kernel.
[/CODE]

If you are interested in working on this project as well, please feel free to work on it! You can work independently or with me on this if you would like. You are welcome to post here, or to contact me through XDA’s message service, or post on XDA.

The current passwords are:
root = root
trondroid = trondroid
me = me

In the next few days, I plan to post some more info, and how you can port this to any Android phone, so stay tuned!

Linux – keep it simple