[Galaxy Tab 3 10.1 Android Development] r2d23cpo:
jdean2k6

I did wrote a nice tutorial and my PC crash and lost it!! Boy what a life.

First I been on bed sick. To many issues. You do not want to know.

As every one does around, Need help that requires a lot of work and time, but provides to little information.. Bad boy!

You new it should not work as it comes for many reasons,. Now the problem is to find out what? Solution may be just that you need to install the Google Market Apk that enable Internet communication thou Ethernet Adapter instead of wifi!!

How do you know driver is not the problem?

Do you know it is really " ASIX AX88xxx Based" ?

Any way. jdean2k6 You have told us :

You plan to use the TAB3 as a development tool!

From know on to simplify I will be using "Ubuntu" as a general label for any Linux distribution you may be using, like Kali or Debian, etc. Also You told us you are a Software Engineer!! So it should mean that you should know all this! But I will explain as if you are just a student.

So First question you need to answer me is:

Have you all ready install Ubuntu or Kali Linux chroot in your TAb3?

I strongly suggest you to get your self a nice 64Gig Hi speed SDCARD. Create 2 partition on it. You need 1 small VFAT to make happy Android. And have the rest as a EXT3 or EXT4 Ubuntu partition.

For me, I guess, this is the basic. You require to have a FULL Linux development environment to be able to some work. Lets be clear you will not have a X-Window Gui, I have not got to cross that bridge my self.

But the Ubuntu environment will allow you to have all the needed tools to work. Now I know you will tell me latter to talk about having Ubuntu running in your Android Tab3 as a chroot operating system. To me I just have a script that fire up Ubuntu in a terminal window.

So as we spoke you need your [IMG="Samsung OTG"]http://thumbs4.ebaystatic.com/d/l225/m/m0ND9kIAnqj_mbykTCo8yvA.jpg[/IMG]

Micro USB Host Cable Male to USB Female OTG Adapter For Samsung LG HTC Nexus 7

Now Open a Terminal. Your logging prompt should look like "shell@android:/ $" if you do not have root privilege. Then you need to do "su" and you will get "root@android:/ # "

shell@android:/ $ su
root@android:/ #

As an example I will show you how I do Fire up Ubuntu in the TAB. So if you do not have Ubuntu in your TAB 3 then use a Ubuntu PC Desktop to test.

In my case I have a linux script that I called "/system/xbin/mubuntu" that mount my second partition "/dev/block/mmcblk1p2" in "/data/local/mnt/ubuntu". it contains:

#!/system/xbin/busybox ash
busybox mount -t ext4 /dev/block/mmcblk1p2 /data/local/mnt/ubuntu

So yes I have a folder called "/data/local/mnt/ubuntu "

So if I look in that folder before mounting it should be empty.

root@android:/ # ls /data/local/mnt/ubuntu

Empty

Now lets mount

As you see it does

busybox mount -t ext4 /dev/block/mmcblk1p2 /data/local/mnt/ubuntu

and look again

root@android:/ # ls /data/local/mnt/ubuntu
android
bin
boot
boot_mounts.txt
dev
etc
external_sd
home
init.sh
kexecboot
lib
media
mnt
opt
proc
root
run
sbin
sdcard
srv
sys
tmp
ubuntu14.04-002-basic.tar.gz
usr
var
$

Yes my ubuntu files show now.

Now I will run ubuntu in a chroot mode. To do this I have another script. I called this "/system/xbin/ubuntu1". And it contains

###########################################
# Linux boot script V8 for Android pre 4.3#
# Built by Zachary Powell (zacthespack) #
# and Martin Møller (Tuxling) #
# Thanks to: #
# Johan Vromans #
# Marshall Levin #
# and to everyone at XDA! #
# Feel free to edit/use this script as you#
# like but credit Linuxonandroid.org #
###########################################
# $ver: V8 #
###########################################
## Edited for booting from sdcard installation by David Heisnam ###

###########################################
# This is a function we use to stop the #
# script in case of errors #
###########################################
error_exit() {
echo "Error: $1"
exit 1
}

###########################################
# Set up variables #
###########################################
if [ -f /data/data/com.zpwebsites.linuxonandroid/files/busybox ]; then
export bbox=/data/data/com.zpwebsites.linuxonandroid/files/busybox
elif [ -f /data/data/com.zpwebsites.linuxonandroid.opensource/files/busybox ]; then
export bbox=/data/data/com.zpwebsites.linuxonandroid.opensource/files/busybox
else
export bbox=/system/xbin/busybox
fi

export usermounts=android	# Base folder all user mounts are done in, should be moved to app later
#export ubuntu=/mnt/ubuntu # Your Ubuntu sdcard partition mount point
export ubuntu=/data/local/mnt/ubuntu
### export mnt=/data/local/mnt No longer needed #####
###David Heisnam......This... ###
export imgfile=$(dirname $0)/ubuntu.img
##....is kept for the usermounts feature that I don't use or know anything about ##
export bin=/system/bin
export USER=root
export PATH=$bin:/usr/bin:/usr/local/bin:/usr/sbin:/bin:/usr/local/sbin:/usr/games:$PATH
export TERM=xterm
#linux
export HOME=/root
DISPLAY=:0 xterm &,
################################
# Find and read config file #
# or use defaults if not found #
################################
######## David Heisnam #########
## The config file is now the default one
## in /mnt/ubuntu/root/cfg/
## and not the one generated in the same
## directory as the linux image
## Since we are no longer booting from an image
cfgfile=$ubuntu/root/cfg/linux.config # Default config file if not specified

if [ -f $cfgfile ]; then
source $cfgfile
fi
###########################################
# Set Swap up if wanted #
# #
###########################################
### David Heisnam ######
### This portion has been edited to work with our new configuration ###
# Please note: The code below generates
#a swap file inside the second sdcard partition#
# If your second partition is not large enough #
# This could cause problems#
# You can change the swap file location here if you want #
use_swap=no
if [ $use_swap == yes ]; then
if [ -f $ubuntu/ubuntu.swap ]; then
echo "Swap file found, using file"
echo "Turning on swap (if it errors here you do not have swap support"
swapon $ubuntu/ubuntu.swap

else
echo "Creating Swap file"
dd if=/dev/zero of=$ubuntu/ubuntu.swap bs=1048576 count=256
### swap file size reduced to 256 MB###
mkswap $ubuntu/ubuntu.swap
echo "Turning on swap (if it errors here you do not have swap support"
swapon $ubuntu/ubuntu.swap

fi
fi
###########################################
# Set up loop device and mount image
#### REMOVED #######
# No need to set up loop device
# to mount second sdcard partition

###########################################
# Mount all required partitions #
###########################################

$bbox mount -t proc proc $ubuntu/proc
if [ $? -ne 0 ];then error_exit "Unable to mount $ubuntu/proc!"; fi
$bbox mount -t sysfs sysfs $ubuntu/sys
if [ $? -ne 0 ];then error_exit "Unable to mount $ubuntu/sys!"; fi

#$bbox sleep 1
$bbox sysctl -w kernel.hotplug=/sbin/mdev
# Populate /dev
#$bbox mdev -s
#$bbox mount -t devpts devpts $ubuntu/dev/pts
#if [ $? -ne 0 ];then error_exit "Unable to mount $ubuntu/dev/pts!"; fi

# Mount /dev from the Android world
$bbox mount -o bind /dev $ubuntu/dev
if [ $? -ne 0 ];then error_exit "Unable to bind $ubuntu/dev!"; fi
$bbox mount -o bind /dev/pts $ubuntu/dev/pts
if [ $? -ne 0 ];then error_exit "Unable to bind $ubuntu/dev/pts!"; fi
$bbox mount -o bind /dev/socket $ubuntu/dev/socket
if [ $? -ne 0 ];then error_exit "Unable to bind $ubuntu/dev/socket!"; fi

$bbox mount -o bind /sdcard $ubuntu/sdcard
if [ $? -ne 0 ];then error_exit "Unable to bind $ubuntu/sdcard!"; fi

if [[ ! -d $ubuntu/root/cfg ]]; then mkdir $ubuntu/root/cfg; fi
##### David Heisnam ######
# # No need for this now ### Commented off ###
# $bbox mount -o bind $(dirname $imgfile) $ubuntu/root/cfg
### The config file location is no longer that of the image file ###
### Because we no longer use image ##

###########################################
# Checks if you have a external sdcard #
# and mounts it if you do #
###########################################
if [ -d /sdcard/external_sd ]; then
$bbox mount -o bind /sdcard/external_sd $ubuntu/external_sd
fi
if [ -d /Removable/MicroSD ]; then
$bbox mount -o bind /Removable/MicroSD $ubuntu/external_sd
fi

# This is for Galaxy Tab3
if [ -d /storage/extSdCard ]; then
$bbox mount -o bind /storage/extSdCard $ubuntu/external_sd
else
# This is for the HD version of the Archos 70 internet tablet, may be the same for the SD card edition but i dont know.
if [ -d /storage ]; then
$bbox mount -o bind /storage $ubuntu/external_sd
fi

fi

###########################################
# Mount all user defined mounts if any #
###########################################
if [ -f $imgfile.mounts ]; then
olddir=$(pwd)
echo "Mounting user mounts"

cd $ubuntu
if [[ ! -d $ubuntu/$usermounts ]]; then $bbox mkdir -p $usermounts; fi

echo "# Script to unmount user defined mounts, do not delete or edit!" > $imgfile.shutdown
echo "cd $ubuntu/$usermounts" > $imgfile.shutdown

cd $ubuntu/$usermounts
for entry in $(cat "$imgfile.mounts"); do
ANDROID=${entry%;*}
LINUX=${entry#*;}

if [[ -d $ANDROID ]]; then
echo -n "Mounting $ANDROID to $usermounts/$LINUX... "
if [[ ! -d $ubuntu/$usermounts/$LINUX ]]; then $bbox mkdir -p $LINUX; fi
$bbox mount -o bind $ANDROID $ubuntu/$usermounts/$LINUX &> /dev/null
if [ $? -ne 0 ];then
echo FAIL
if [[ -d $ubuntu/$usermounts/$LINUX ]]; then $bbox rmdir -p $LINUX; fi
else
echo OK
echo "$bbox umount $ubuntu/$usermounts/$LINUX" >> $imgfile.shutdown
echo "$bbox rmdir -p $LINUX" >> $imgfile.shutdown
fi
else
echo "Android folder not found: $ANDROID"
fi
done
echo "cd $ubuntu" >> $imgfile.shutdown
echo "$bbox rmdir -p $usermounts" >> $imgfile.shutdown
cd $olddir

else
echo "No user defined mount points"
fi

###########################################
# Sets up network forwarding #
###########################################
$bbox sysctl -w net.ipv4.ip_forward=1
if [ $? -ne 0 ];then error_exit "Unable to forward network!"; fi

# If NOT $ubuntu/root/DONOTDELETE.txt exists we setup hosts and resolv.conf now
if [ ! -f $ubuntu/root/DONOTDELETE.txt ]; then
echo "nameserver 8.8.8.8" > $ubuntu/etc/resolv.conf
if [ $? -ne 0 ];then error_exit "Unable to write resolv.conf file!"; fi
echo "nameserver 8.8.4.4" >> $ubuntu/etc/resolv.conf
echo "127.0.0.1 localhost" > $ubuntu/etc/hosts
if [ $? -ne 0 ];then error_exit "Unable to write hosts file!"; fi
fi

###########################################
# Chroot into ubuntu #
###########################################
$bbox chroot $ubuntu /etc/init.sh
#No need to pass $(basename $imgfile) argument #

###########################################
# Shut down ubuntu #
###########################################
echo "Shutting down Linux ARM"
#for pid in `lsof | grep $ubuntu | sed -e's/ / /g' | cut -d' ' -f2`; do kill -9 $pid >/dev/null 2>&1; done
for pid in `$bbox lsof | $bbox grep $ubuntu | $bbox sed -e's/ / /g' | $bbox cut -d' ' -f2`; do $bbox kill -9 $pid >/dev/null 2>&1; done
sleep 5

###########################################
# Unmount all user defined mounts if any #
###########################################
if [ -f $imgfile.shutdown ]; then
echo "Unmounting user defined mounts"
sh $imgfile.shutdown
rm $imgfile.shutdown
fi

## Not needed $bbox umount $ubuntu/root/cfg ##
$bbox umount $ubuntu/sdcard
$bbox umount $ubuntu/external_sd
$bbox umount $ubuntu/dev/pts
## No need for
###$bbox umount $ubuntu/dev
# It'll throw an error
$bbox umount $ubuntu/proc
$bbox umount $ubuntu/sys
root@android:/ #

So I do in terminal

root@android:/ # ubuntu1
/system/xbin/ubuntu1[50]: ,: not found
/system/xbin/ubuntu1[50]: xterm: not found
kernel.hotplug = /sbin/mdev
No user defined mount points
net.ipv4.ip_forward = 1
Config file loaded
-su: vncserver: command not found

If you see the message 'New 'X' Desktop is localhost:0' then you are ready to VNC into your ubuntu OS..

If connection from a different machine on the same network as the android device use the address below:
192.168.3.33

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)
* Starting OpenBSD Secure Shell server sshd [ OK ]

To shut down the Linux environment, just enter 'exit' at this terminal - and WAIT for all shutdown routines to finish!

[COLOR="Red"]root@localhost:/# [/COLOR]

So now I am running Ubuntu in a chroot enviroment. Look at my new promt root@localhost:/#

In fact I have setup a shh server that can allow me to tun ubuntu in VNC from a desktop. Or just use a ssh command. Lets say I use my PC or phone termional and do:

$ ssh ubuntu@192.168.3.33
ubuntu@192.168.3.33's password:
Welcome to Ubuntu 14.04 LTS (GNU/Linux 3.4.34-850131 i686)

* Documentation: https://help.ubuntu.com/
ubuntu@localhost:~$

Yes I created a user ubuntu in my TAB3 chrooted ubuntu. I know using "ubuntu" as a user show lake of imagination!! Sorry.

Next part in a new post