Ultimate Edition enters the ARM world...

Source code I have written openly published for your viewing pleasure.


Ultimate Edition enters the ARM world...

Postby TheeMahn » Mon Dec 02, 2013 1:01 am

I don't expect many of you to know what ARM is, but I have began building an Operating System for arm based processors. I ordered the following item and have began building an operating system for it before it has even arrived:


The exact make and model I have purchased is a MK 809 III; $62.99 on ebay the specs:
Quad Core MK809III RK3188 Cortex A9 4.2 Androind MINI PC TV BOX Pre-installed XBMC 2GB/8GB
MK809 III RK3188 Quad Core Cortex A9 MINI Android 4.2 PC 2GB/ 8GB ROM 1.8GHz WIFI Bluetooth
Quad Core MK809III RK3188 Cortex A9

Features:
Operation System: Google Android 4.2.2
Wi-Fi Internet connection
HDMI Out 1080P
Adobe Flash 11.1 Support
Rockchip RK3188 1.8GHz Cortex A9 Quad Core+ Mali400 GPU Quad Core
2GB RAM 8GB ROM
Google Play, Thousands of apps available
Remote controller / Wireless Keyboard/mouse supported
YouTube, Hulu , Internet Radio, etc. Online video Playing
Facebook, Twitter, Picasa, Flicker, Google+ etc. Social Networking
Gmail , PDF Reader, e-Book Reader Office To Go

Supports multi-language: Arabic, English, French, Italian, German, Spanish, Portuguese, Greek, Dutch, Danish, Russian, Polish, Norwegian, Swedish, Czech, Turkish, Chinese, Korean, and Japanese ect .


I am unsure if I can make it dual boot at this point. I will update this post as I move along. Software I have currently written for the most part will work in arm as well. Exceptions being things like Ultimate Player or library / binary specific applications. Theming the OS should be a snap. You can learn how to build your own ARM based Operating System as I too learn. I will be looking into tools to backup the current rom or write my own application(s) before I even begin (I do not want to brick the device):
Building the ARM OS Ultimate Edition Style:
First we must obtain Super User status (password 3 times):
Code: Select all
sudo passwd
su

Set structure:
Code: Select all
root@JackHammer:/home/theemahn/mkdir -p wip/edit wip/extractcd/
root@JackHammer:/home/theemahn/cd wip
root@JackHammer:/home/theemahn/wip# debootstrap --arch=armel --foreign precise edit #--variant=minbase removed we are moving to a full system

The above command is quite different from other Operating Systems I have built:
arch=armel
The architecture for the target operating system the A9 Cortex uses ARM Technology
--foreign
Because I am currently building from a Foreign architecture in this case Ultimate Edition 4.0 X64
--variant=minbase
Basesystem
precise
The branch from which I am building, BTW there is no Raring, Quantal or Saucy for the arm tree.
edit
The destination for which files will be retrieved etc.

I: Retrieving Release
I: Retrieving Release.gpg
I: Checking Release signature
I: Valid Release signature (key id 630239CC130E1A7FD81A27B140976EAF437D05B5)
I: Validating Packages
I: Resolving dependencies of required packages...
I: Resolving dependencies of base packages...
I: Found additional base dependencies: gnupg gpgv libapt-pkg4.12 libreadline6 libstdc++6 libusb-0.1-4 readline-common ubuntu-keyring
I: Checking component main on http://ports.ubuntu.com/ubuntu-ports...
I: Validating adduser 3.113ubuntu2
I: Validating apt 0.8.16~exp12ubuntu10
...
I: Chosen extractor for .deb packages: dpkg-deb
I: Extracting adduser...
I: Extracting base-files...
...
I: Extracting zlib1g...
root@JackHammer:/home/theemahn/wip#


Attempting to enter the chroot will yield the following error:
root@JackHammer:/home/theemahn/wip# chroot edit/
chroot: failed to run command ‘/bin/bash’: Exec format error
root@JackHammer:/home/theemahn/wip#


2 Reasons for this:
  • Arm and X86 / X64 do NOT play well together.
  • Second stage of debootstrap has not been preformed.

Download QEMU SOURCE, no the qemu you have pre-installed will not cut it.
Assuming your download folder, crack open another terminal and enter the following:
Code: Select all
cd Downloads/
tar -xfv qemu-*
cd qemu-*
./configure --disable-kvm --target-list=arm-linux-user --static
make -j8

In the above we are compiling a static version of qemu binary for the arm architecture, the j8 is optional with the make command. I use it to utilize all 8 of my cores and get the job done quicker.

Let's take the time to verify we are on the same page and rocking ARM. Let's DOWNLOAD a static and simple Hello world Binary and test it. Once again assuming you downloaded it to your Downloads folder and are still running from the terminal above:
Code: Select all
theemahn@JackHammer:~/Downloads/qemu-1.7.0$ sudo chmod 755 ../hello_world-arm-static
[sudo] password for theemahn:
theemahn@JackHammer:~/Downloads/qemu-1.7.0$ arm-linux-user/qemu-arm ../hello_world-arm-static
Hello world!
theemahn@JackHammer:~/Downloads/qemu-1.7.0$

Fantastic, we can now run virtually ARM based executables, lets get this rolling natively, the powers of Super User must be invoked:
Code: Select all
theemahn@JackHammer:~/Downloads/qemu-1.7.0$ su
Password:
root@JackHammer:/home/theemahn/Downloads/qemu-1.7.0# cp arm-linux-user/qemu-arm /usr/local/bin/qemu-arm-static
root@JackHammer:/home/theemahn/Downloads/qemu-1.7.0# echo ':arm:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/local/bin/qemu-arm-static:' > /proc/sys/fs/binfmt_misc/register
root@JackHammer:/home/theemahn/Downloads/qemu-1.7.0#

The above will assign ARM architectures "SHEBANG" or header to the binfmt and register it as a filetype in laymans terms (pretty heavy stuff) :)
Verify we have done everything correctly by directly invoking the Hello World app (once again assuming you have not closed the terminal):
Code: Select all
root@JackHammer:/home/theemahn/Downloads/qemu-1.7.0# ../hello_world-arm-static
Hello world!
root@JackHammer:/home/theemahn/Downloads/qemu-1.7.0#

We can now close that terminal and move on back to the first terminal, we should not have to go through the QEMU building portion again thank god, perhaps I will debianize it later. Moving on once again. Now, we want to chroot in and begin building Ultimate Edition goodness. For that, we need to put the QEMU binary into the chroot, so that the target system can find it when starting /bin/bash inside the chroot. In this case provided you are following verbatum:
Code: Select all
root@JackHammer:/home/theemahn/wip# mkdir -p edit/usr/local/bin
root@JackHammer:/home/theemahn/wip# cp /usr/local/bin/qemu-arm-static edit/usr/local/bin
root@JackHammer:/home/theemahn/wip#

I am learning as we go along, trying to jump right in there and get to work yields yet another issue:
Code: Select all
root@JackHammer:/home/theemahn/wip# chroot edit/
/usr/bin/groups: cannot find name for group ID 0
I have no name!@JackHammer:/# exit
exit
root@JackHammer:/home/theemahn/wip#

Hmmm Google is your friend, let's see if I can resolve this issue, back in we have not ran the second stage:
Code: Select all
root@JackHammer:/home/theemahn/wip# chroot edit/
/usr/bin/groups: cannot find name for group ID 0
I have no name!@JackHammer:/# cd debootstrap/
I have no name!@JackHammer:/debootstrap# ./debootstrap --second-stage

This is a very slow process compared to building other O/S's as it is being emulated, makes me wonder if I enabled KVM when compiling above if it would accelerate the process.
I have no name!@JackHammer:/debootstrap# ./debootstrap --second-stage
I: Installing core packages...
I: Unpacking required packages...
I: Unpacking adduser...
...
I: Unpacking zlib1g...
I: Configuring required packages...
I: Configuring ncurses-base...
...
I: Configuring initramfs-tools...
I: Unpacking the base system...
I: Unpacking apt...
...
I: Unpacking xkb-data...
I: Configuring the base system...
I: Configuring sudo...
...
I: Configuring initramfs-tools...
I: Base system installed successfully.
I have no name!@JackHammer:/debootstrap#

Not looking good, I see I have no name, lets remedy this by exiting the chroot environment and re-entering.
Code: Select all
I have no name!@JackHammer:/debootstrap# exit
exit
root@JackHammer:/home/theemahn/wip# chroot edit
root@JackHammer:/# apt-get update
Reading package lists... Done
root@JackHammer:/#

Much better ;) Hmm, no sources.list. I have already been down this road and about an hour spent horsing arround with Google to learn Ubuntu ARM uses their own seperate servers for packages, let's rectify:
Code: Select all
root@JackHammer:/# echo 'deb [arch=armel] http://ports.ubuntu.com/ precise main universe restricted multiverse' >/etc/apt/sources.list
root@JackHammer:/# apt-get update
Ign http://ports.ubuntu.com precise InRelease
Get:1 http://ports.ubuntu.com precise Release.gpg [198 B]
Get:2 http://ports.ubuntu.com precise Release [49.6 kB]
Get:3 http://ports.ubuntu.com precise/main armel Packages [1257 kB]
Get:4 http://ports.ubuntu.com precise/universe armel Packages [4667 kB]     
Get:5 http://ports.ubuntu.com precise/restricted armel Packages [14 B]                                                                                                                                                                       
Get:6 http://ports.ubuntu.com precise/multiverse armel Packages [107 kB]                                                                                                                                                                     
Get:7 http://ports.ubuntu.com precise/main TranslationIndex [3706 B]                                                                                                                                                                         
Get:8 http://ports.ubuntu.com precise/multiverse TranslationIndex [2676 B]                                                                                                                                                                   
Get:9 http://ports.ubuntu.com precise/restricted TranslationIndex [2596 B]                                                                                                                                                                   
Get:10 http://ports.ubuntu.com precise/universe TranslationIndex [2922 B]                                                                                                                                                                   
Get:11 http://ports.ubuntu.com precise/main Translation-en [726 kB]                                                                                                                                                                         
Get:12 http://ports.ubuntu.com precise/multiverse Translation-en [93.4 kB]                                                                                                                                                                   
Get:13 http://ports.ubuntu.com precise/restricted Translation-en [2395 B]                                                                                                                                                                   
Get:14 http://ports.ubuntu.com precise/universe Translation-en [3341 kB]                                                                                                                                                                     
Fetched 10.3 MB in 23s (433 kB/s)                                                                                                                                                                                                           
Reading package lists... Done
root@JackHammer:/#

Apps I have already written seem to install fine:
Setting up bc (1.06.95-2) ...
Setting up ultimate-edition-keysnatcher (1.0.0) ...
root@JackHammer:/tmp# apt-get install -f
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
root@JackHammer:/tmp# uname -a
Linux JackHammer 3.11.0-13-generic #20-Ubuntu SMP Wed Oct 23 07:38:26 UTC 2013 armv7l armv7l armv7l GNU/Linux

Note the arm in the kernel architecture.

The biggest thing is yet to come choice of DE (Desktop Environment) a limited choice, not all DE's are ported to ARM.

Working the ANDROID SIDE OF THINGS:
I have in the past created an Android based O/S system which was never released to the public due to google apps being Copywritten. I have written custom APK's to customise the Operating System. The APK's are also not being provided as I no longer possess them. The following information was collected from my wip (Work In Progress) it is being posted here now for reference and perhaps may help someone else do the same:
Code: Select all
#DROID
su
mkdir edit
mkdir extract-cd
mkdir mnt
mkdir squashfs
mkdir system
#mount & extract
mount -o loop android*.iso mnt/
rsync --exclude=/system.sfs -a mnt/ extract-cd
mount -t squashfs -o loop mnt/system.sfs squashfs
cp -a squashfs/* system/
umount $PWD/squashfs
umount $PWD/mnt
mount -o loop system/system.img system
#cp -a squashfs/* edit/
#

#MAKE ALL MODIFICATIONS

#Stamping
sed -i "s/ro.build.date=.*/ro.build.date=`date`/g" system/build.prop
sed -i "s/ro.product.model=.*/ro.product.model=Ultimate Android/g" system/build.prop

umount $PWD/system
#Build
#scrap old squashfs we are going to build a new one
rm extract-cd/system.sfs

#build new squashfs grab some beer, chips & disks are now choked
mksquashfs system/system.img system.sfs
#mksquashfs squashfs-root/system.img system.sfs
mv system.sfs extract-cd/

#build final iso - root overwrites ;)
cd extract-cd/
mkisofs -r -V "Ultimate Android" -p TheeMahn -P "Ultimate Edition Team" -cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o ../ultimate-android-`date +"%Y%m%d"`-i386.iso .
cd ..

#SET USB
isohybrid ultimate*.iso

#Thumbit
#dd if=ultimate-android-`date +"%Y%m%d"`-i386.iso of=/dev/sdg

#Test
#copy blank Testing.img created with qemulator to wip folder
cd ..
kvm -m 2047 -smp 8 -usb -boot d -cdrom ultimate-android-`date +"%Y%m%d"`-i386.iso -name Ultimate

#Take 2 -- apt-get install bsdtar
#Extract and mount
mkdir android-image
bsdtar -C android-image -xf android*.iso
cd android-image
unsquashfs system.sfs
mkdir /mnt/iso
mount ./squashfs-root/system.img /mnt/iso  -o loop

cd ..
mkdir boot/
mv android-image/isolinux boot/

mksquashfs squashfs-root/system.img system.sfs
$ cd ..
$ genisoimage -vJURT -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -input-charset utf-8 -V "Android-x86 LiveCD" -o android-image.iso ~/Temp/boot/ android-image/ramdisk.img android-image/initrd.img anndroid-image/initrd.img android-image/install.img android-image/system.sfs android-image/kernel

genisoimage -vJURT -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -input-charset utf-8 -V "Ultimate Android" -p TheeMahn -P "Ultimate Edition Team" -o ultimate-android-`date +"%Y%m%d"`-i386.iso  ramdisk.img initrd.img initrd.img install.img system.sfs kernel

#Resizing img files:
dd if=/dev/zero bs=1M count=SIZE_IN_MB >> system.img

#Verify integrity
e2fsck -f system.img
resize2fs system.img
e2fsck -f system.img


Please stay tuned...

New tools are inbound, borrowed some code from Ian Morrison & Thumbos. Waiting for him so say weather his orignal code is GPL. I have enhanced it substantially:
loading.png

theemahn@JackHammer:~/Videos/ultimate-edition-android-tools-1.0.1/bin$ sudo ./mkfs.android -?
Code: Select all
mkfs.android 1.0, 12/03/2013
GNU mkfs.android home page: <http://ultimateedition.info/>.
E-mail bug reports to: <theemahn@ultimateedition.info>.
Be sure to include the word mkfs.android somewhere in the Subject: field.

Usage: mkfs.android -<-COMMAND>
  Mandatory arguments to long options are identical for short options.
  possible commands...

  -l   --load  loads images to sdcard in Android filesystem.
  -f   --format   format sdcard in Android filesystem.
  -h   --help  this help message
  -v   --version   dump version info

mkfs.android --help [COMMAND] for further information.
theemahn@JackHammer:~/Videos/ultimate-edition-android-tools-1.0.1/bin$


I intend to add him to the credits, once I have a fully functioning tool. I intend to determine the size of the image file and adjust partition sizes smartly. Bash auto-completion. Funny how a programmer will spend 10 hours of additional coding just to save 10 minutes when using a tool they have designed.
The tool does btw handle both Linux and Android formatting:
theemahn@JackHammer:~/Videos/ultimate-edition-android-tools-1.0.1/bin$ sudo ./mkfs.android --help format
Code: Select all
mkfs.android 1.0, 12/03/2013
GNU mkfs.android home page: <http://ultimateedition.info/>.
E-mail bug reports to: <theemahn@ultimateedition.info>.
Be sure to include the word mkfs.android somewhere in the Subject: field.

Usage format;
  mkfs.android -f <TYPE> <DEVICE>
  Formats <DEVICE> in <TYPE> sdcard in Android or Linux format and exits.
  Example: mkfs.android -f android sdg
  Note: Partition number is unecessary as the entire drive will be utilized.
theemahn@JackHammer:~/Videos/ultimate-edition-android-tools-1.0.1/bin$


Tool in action:
Code: Select all
theemahn@JackHammer:~/Videos/ultimate-edition-android-tools-1.0.1/bin$ sudo ./mkfs.android --load linuxium-ubuntu1304-xubuntu-desktop-rfs.img sdi
mkfs.android 1.0, 12/03/2013
GNU mkfs.android home page: <http://ultimateedition.info/>.
E-mail bug reports to: <theemahn@ultimateedition.info>.
Be sure to include the word mkfs.android somewhere in the Subject: field.

IMAGE: linuxium-ubuntu1304-xubuntu-desktop-rfs.img | LABEL: linuxium-ubuntu1304-xubuntu-desktop-rfs.img: Linux rev 1.0 ext4 filesystem data, UUID=d766be10-da8f-429e-a329-7b70bf88d10f, volume name "linuxroot" (extents) (large files) (huge files) | BOOTABLE: NO

Error: linuxium-ubuntu1304-xubuntu-desktop-rfs.img is not bootable. Proceeding as instructed.
Number of SDCard(s) detected: 2
# DEV VENDOR          LABEL                     TYPE       SIZE
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 sdi                                           dos        15.50 GB
2 sdh MUSHKIN         Ultimate Edition MK809III iso9660    31.62 GB
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Testing write permissions to device /dev/sdi: Granted.
Preform the following actions?
1. Partion sdcard: /dev/sdi
2. Load: linuxium-ubuntu1304-xubuntu-desktop-rfs.img image to sdcard?
================================================================================
WARNING: this will destroy all content on device /dev/sdi. (Y/N)? Y

Partitioning sdi thumbdrive...
mkfs.android: Formatting SD card '/dev/sdi' ...
Error: Partition(s) on /dev/sdi are being used.
Error: You requested a partition from 2048s to 30281727s.
The closest location we can manage is 2047s to 2047s.
mke2fs 1.42.8 (20-Jun-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
946560 inodes, 3784960 blocks
189248 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=3879731200
116 block groups
32768 blocks per group, 32768 fragments per group
8160 inodes per group
Superblock backups stored on blocks:
   32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208

Allocating group tables: done                           
Writing inode tables: done                           
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done   

Successfully loaded linuxium-ubuntu1304-xubuntu-desktop-rfs.img to /dev/sdi.
theemahn@JackHammer:~/Videos/ultimate-edition-android-tools-1.0.1/bin$


TheeMahn
Attachments
arm.png
Loading out to thumbdrive, now waiting on device.
Home of Ultimate Edition. Got a question? Please review the F.A.Q. Browse the How to section.

Main O/S: Builder of O/S Guess.
Mainboard: ASUS Hero VI (AM4)
CPU: AMD 1700X water cooled (Deepcool Captain Genome Cooling tower)
Ram: 16 GB GSkill Trident RGB Series Dual Channel DDR4 3200
Video: MSI RX470 8GB Gaming card.
Hard Disks: MASSIVE on the network.(10 Gigabit, 48 port, multiple servers)
Monitors: 4K Samsung 28", HannsG HH281, Various others
750 Watt modular PSU (Rosswell)
1100 Watt Amp & 4 X 600 Watt speakers

Servers in the basement.
User avatar
TheeMahn
Site Admin
 
Posts: 4199
Joined: Fri Oct 12, 2007 10:02 am
Location: U.S.A.
Age: 47
Operating System: Ultimate Edition Developer



Re: Ultimate Edition enters the ARM world...

Postby necromonger » Tue Dec 03, 2013 2:13 pm

I still don't know how you do it. this is great!
asus p6x58 prem. mb
intel i7 3.4
ati 6970 hd vid
12 gig kingston hyper x 1600
lg dvd burner
asus 24 inch hd monitor
sda samsung 120 gig hd ultimate 3.5.2 boot drive
sdb samsung 250 gig hd ultimate 3.4.1
sdc seagate 1 tb drive mint 15
necromonger
U.E. Knowledgable
U.E. Knowledgable
 
Posts: 29
Joined: Thu Oct 28, 2010 3:06 pm
Location: West virginia
Age: 54
Operating System: Ultimate Edition 3.5 64 BIT



Re: Ultimate Edition enters the ARM world...

Postby TheeMahn » Tue Dec 03, 2013 11:40 pm

Thanks, I have been drinking mass amounts of Java and pouring out code with the quickness. We will soon be one helluva ARM wrestler lol
Home of Ultimate Edition. Got a question? Please review the F.A.Q. Browse the How to section.

Main O/S: Builder of O/S Guess.
Mainboard: ASUS Hero VI (AM4)
CPU: AMD 1700X water cooled (Deepcool Captain Genome Cooling tower)
Ram: 16 GB GSkill Trident RGB Series Dual Channel DDR4 3200
Video: MSI RX470 8GB Gaming card.
Hard Disks: MASSIVE on the network.(10 Gigabit, 48 port, multiple servers)
Monitors: 4K Samsung 28", HannsG HH281, Various others
750 Watt modular PSU (Rosswell)
1100 Watt Amp & 4 X 600 Watt speakers

Servers in the basement.
User avatar
TheeMahn
Site Admin
 
Posts: 4199
Joined: Fri Oct 12, 2007 10:02 am
Location: U.S.A.
Age: 47
Operating System: Ultimate Edition Developer



Re: Ultimate Edition enters the ARM world...

Postby TheeMahn » Mon Dec 23, 2013 9:04 pm

Blackened from metallica I listen to. Using the tool of destruction. I have written both Linux as well as Android. Who wins? I listened to the people say to me they want droid, while I have in the past an droid based is. I have 0 intention of walking on Googles balls. Let's get this out openly they would sue me. Please take the time to think as I do. Linux is a world I can not only open you of a world of non Google confronting your life. I can reach in and make your life better. I go out of my way to help you. Even the best can't see my intentions. Google, while I utilize their results is not the only search results I can place in your palms.

Please fill in your thoughts. I can not build an iso to your liking Android wise. The only reason I get away with it, the tool of destruction came from China. They do not have to adhere to laws in the US. If it makes you feel better I wrote software for m$ windows quite a few years ago.
Home of Ultimate Edition. Got a question? Please review the F.A.Q. Browse the How to section.

Main O/S: Builder of O/S Guess.
Mainboard: ASUS Hero VI (AM4)
CPU: AMD 1700X water cooled (Deepcool Captain Genome Cooling tower)
Ram: 16 GB GSkill Trident RGB Series Dual Channel DDR4 3200
Video: MSI RX470 8GB Gaming card.
Hard Disks: MASSIVE on the network.(10 Gigabit, 48 port, multiple servers)
Monitors: 4K Samsung 28", HannsG HH281, Various others
750 Watt modular PSU (Rosswell)
1100 Watt Amp & 4 X 600 Watt speakers

Servers in the basement.
User avatar
TheeMahn
Site Admin
 
Posts: 4199
Joined: Fri Oct 12, 2007 10:02 am
Location: U.S.A.
Age: 47
Operating System: Ultimate Edition Developer


Return to Programming

Who is online

Users browsing this forum: No registered users and 1 guest

cron