Thread: DIY - KeK
View Single Post
Old 08-14-2012, 11:26 AM   #262
knc1
Going Viral
knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.
 
knc1's Avatar
 
Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
Q&D (e)glibc development environment for Aboriginal Linux

Make the location of the AL files the current directory.
Check that you have at least 4Gbytes of free disk space:
Code:
core2quad armv6l $ df -h .
Filesystem            Size  Used Avail Use% Mounted on
/dev/md126             37G   21G   15G  60% /
Create a new, sparse, file for the emu /home file system:
Code:
core2quad armv6l $ dd if=/dev/zero of=hdb2.img bs=1024 seek=$[1024*1024*4] count=1
core2quad armv6l $ mke2fs -q -b 1024 -i 4096 -F hdb2.img
  warning: Unable to get device geometry for hdb2.img
core2quad armv6l $ tune2fs -j -c 0 -i 0 hdb2.img
  tune2fs 1.41.14 (22-Dec-2010)
  Setting maximal mount count to -1
  Setting interval between checks to 0 seconds
  Creating journal inode: done
  This filesystem will be automatically checked every -1 mounts or
  0 days, whichever comes first.  Use tune2fs -c or -i to override.
When run as the /home directory of the emulator, we want a (e)glibc
development environment, rooted at /home/emd, that can be run as a
chroot.

That development environment should be tailored for the purpose it will
be used for, such as one modeled on a Kindle's filesystem.
For this document, the Ubuntu-core, rootfs image is used.
Code:
core2quad armv6l $ wget http://drpbox.knetconnect.com/KeK/ubuntu-core-12.04-core-armel.tar.gz
Make a mount point for our empty system image file and mount it:
Code:
core2quad armv6l $ sudo mkdir /mnt/hdb2
core2quad armv6l $ sudo mount hdb2.img /mnt/hdb2
Running within the emulator, our /mnt/hdb2 location is known as /home.
Make the emd sub-directory and populate it with the Ubuntu-core files:
These two steps MUST be done as 'root' to get the image correct!
Code:
core2quad armv6l $ sudo mkdir /mnt/hdb2/emd
core2quad armv6l $ sudo tar -C /mnt/hdb2/emd -xf ubuntu-core-12.04-core-armel.tar.gz
Since it is expected that relatively large jobs will be done within this
chroot, build a swap file for the emulator to use:
NOTE: This must NOT be a sparse file.
Code:
core2quad armv6l $ cd /mnt/hdb2
core2quad hdb2 $ sudo dd if=/dev/zero of=swapf bs=$[1024*1024] count=512
  (wait for it)
core2quad hdb2 $ sudo mkswap swapf
  Setting up swapspace version 1, size = 524284 KiB
  no label, UUID=a352dd5b-2dce-424e-a158-7e4901e5744f
core2quad hdb2 $ cd -
Unmount the new file system, turn it into a device and run e2fsck on it:
Code:
core2quad armv6l $ sudo umount /mnt/hdb2
core2quad armv6l $ sudo losetup -f
  /dev/loop0
core2quad armv6l $ sudo losetup /dev/loop0 hdb2.img
core2quad armv6l $ sudo e2fsck -f /dev/loop0
  e2fsck 1.41.14 (22-Dec-2010)
  Pass 1: Checking inodes, blocks, and sizes
  Pass 2: Checking directory structure
  Pass 3: Checking directory connectivity
  Pass 4: Checking reference counts
  Pass 5: Checking group summary information
  /dev/loop0: 8347/1048576 files (0.5% non-contiguous), 908743/4194304 blocks
core2quad armv6l $ sudo losetup -d /dev/loop0
Next, modify the Aboriginal Linux scripts for the new name(s).
Only two are shown here, make a similar change to native-build.sh if you
are using that script.

Code:
core2quad armv6l $ cp -a dev-environment.sh dev-ucore.sh
core2quad armv6l $ cp -a run-emulator.sh run-ucore.sh
Edit the dev-ucore.sh script to change the two lines shown:
Code:
core2quad armv6l $ diff -u dev-environment.sh dev-ucore.sh
--- dev-environment.sh    2012-07-14 08:57:55.000000000 -0500
+++ dev-ucore.sh    2012-08-14 09:44:41.000000000 -0500
@@ -46,7 +46,7 @@
   [ $? -ne 0 ] && exit 1
 }
 
-source ./run-emulator.sh --norun || exit 1
+source ./run-ucore.sh --norun || exit 1
 
 [ -z "$QEMU_MEMORY" ] && QEMU_MEMORY=256
 QEMU_EXTRA="-m $QEMU_MEMORY $QEMU_EXTRA"
@@ -55,7 +55,7 @@
 
 if [ "$HDBMEGS" != "0" ]
 then
-  [ -z "$HDB" ] && HDB=hdb.img
+  [ -z "$HDB" ] && HDB=hdb2.img
   if [ ! -e "$HDB" ]
   then
Fire the little turkey up and see what three hours of typing this how-to
has done to our emulator environment:
Code:
core2quad system-image-armv6l $ . pset.sh
core2quad system-image-armv6l $ ./dev-ucore.sh
- - - -
Not using distcc.
Type exit when done.
(armv6l:1) /home # ls
  emd         lost+found  swapf
(armv6l:1) /home # ls emd
  bin      etc      media    proc     sbin     sys      var
  boot     home     mnt      root     selinux  tmp
  dev      lib      opt      run      srv      usr
All bow down and say "Thank you Rob":
Code:
(armv6l:1) /home # swapon swapf
  /bin/ash: swapon: not found
To make up for that lack, move the swap file inside of the chroot tree.
It would be better to leave it where it is and start it before doing the
following tmpfs assignments but that would take building swapon/swapoff.
Code:
(armv6l:1) /home # mv swapf emd
Setup the chroot dynamic filesystems:
Code:
(armv6l:1) /home # mount -t tmpfs tmpfs /home/emd/tmp
(armv6l:1) /home # mount -t tmpfs tmpfs /home/emd/var/tmp
(armv6l:1) /home # mount -t sysfs sysfs /home/emd/sys
(armv6l:1) /home # mount -t proc proc /home/emd/proc
(armv6l:1) /home # mount -o rbind /dev /home/emd/dev
Try to enter the new chroot and then say: "Thank you Rob":
Code:
(armv6l:1) /home # chroot /home/emd /bin/sh
  Segmentation fault
Well, this bright idea isn't going to work as-is.
Need to (at least) build swapon/swapoff/chroot for the emulation environment.
Once that is done, then this method should work for (e)glibc development.

For now, just shutdown the chroot dynamic filesystems and exit:
Code:
(armv6l:1) /home # umount /home/emd/dev/pts
(armv6l:1) /home # umount /home/emd/dev
(armv6l:1) /home # umount /home/emd/proc
(armv6l:1) /home # umount /home/emd/sys
(armv6l:1) /home # umount /home/emd/var/tmp
(armv6l:1) /home # umount /home/emd/tmp
(armv6l:1) /home # cd /root
(armv6l:1) /root # umount /home
(armv6l:1) /root # exit
Restarting system.
core2quad armv6l $ 

NOTE:  Whatever became of /dev/shm Rob?  Could this be part of the problem?
Once the chroot is entered for the first time, this Ubuntu-core image will need the few site-local files setup.
Things like creating a regular user name, tweaking the sudoers file, . . . .

Last edited by knc1; 08-15-2012 at 09:15 AM.
knc1 is offline   Reply With Quote