User:DenisB
Misc 1 : Qemu launching
1) A script to make qemu launching automatic
Sometimes, the list of commands one has to type as host can be very long and tedious; and forgetting to type one of them leads to unpleasant results (ex : a mounted image should be unmounted before being used by qemu)
a bash script like this one, once adapted, might give ideas to avoid errors..
echo " image pour qemu : ${NOM_IMAGE:=armadeus-qemu.img}
montee dans ${NOM_DIR_MNT:=qemu-mnt} "
echo -e " repertoire de transit : ${TFTBOOT:=tftboot}
rafraichissement ${rafraichir:=no}
options -rw ou ro- : ${OPTION:=rw}
RAM :${RAMSIZE:=96M} DISQUE: ${DISKSIZE:=160}
image de boot :${VMBOOT:=./vmlinuz-2.6.29.6-versatile-armadeus}
"
# sets sudo options (if one is not sudoer, one might launch this script as root)
#
SUDO=
udo=`sudo echo alut`
[ s${udo} == "salut" ] && SUDO=sudo
#
[ -f ${NOM_IMAGE} ] || rafraichir=oui_evidemment
[ -d $TFTBOOT ] || mkdir $TFTBOOT
[ -d ${NOM_DIR_MNT} ] || mkdir ${NOM_DIR_MNT}
make shell_env && source armadeus_env.sh
export PATH=${ARMADEUS_TOOLCHAIN_PATH}/../bin/:${PATH}
# fixes armadeus-4.0 $ARMADEUS_ROOTFS_TAR gets the right name
tempo=
ls $ARMADEUS_ROOTFS_DIR
[ -f $ARMADEUS_ROOTFS_TAR ] || tempo=`echo $ARMADEUS_ROOTFS_TAR | sed -e "s/\.arm\././"`
[ z$tempo != "z" ] && ARMADEUS_ROOTFS_TAR=$tempo
# ls -al $ARMADEUS_ROOTFS_TAR
if [ $rafraichir = no ]
then
echo pas de rafraichissement
else
# destroys and creates an new image
\rm $NOM_IMAGE
dd if=/dev/zero of=${NOM_IMAGE} bs=1MB count=${DISKSIZE}
$SUDO /sbin/mke2fs -F -m 0 -b 1024 ${NOM_IMAGE}
fi
# for old versions of life CDs, where, sometimes, there are not enough mount points
# mknod /dev/loop/333 b 7 333
# losetup /dev/loop/333 ${NOM_IMAGE}
# mount /dev/loop/333 ${NOM_DIR_MNT}
$SUDO mount -t ext2 -o loop $NOM_IMAGE ${NOM_DIR_MNT}
$SUDO tar xf $ARMADEUS_ROOTFS_TAR -C ${NOM_DIR_MNT}/
[ -f ${NOM_DIR_MNT}/usr/local/bin ] && $SUDO \rm ${NOM_DIR_MNT}/usr/local/bin
# comments lines with tty (else, initialisation endlessly loops under qemu)
# sudo vi ${NOM_DIR_MNT}/etc/inittab
# editing can be tedious if one does it every time: has been automated wwith sed
$SUDO sed --in-place -e "s/^ttySMX/#ttySMX/" ${NOM_DIR_MNT}/etc/inittab
# creates a french (and german) keyboard layout launcher and puts it in a temporary dir
$SUDO echo "loadkmap</etc/i18n/fr.kmap" > ${TFTBOOT}/kfr
$SUDO echo "loadkmap</etc/i18n/de.kmap" > ${TFTBOOT}/kde
$SUDO chmod +x ${TFTBOOT}/k*
# prepares other softs
for monmac in qemu/Makefile makefilua # myoscillo/Makefile
do
[ -f $monmac ] && make -f $monmac && make -f $monmac install
done
TSTDIR=/usr/local/armadeus-4.0/myoscillo # places where one has some code to test
opwd=`pwd`
[ -d ${TSTDIR} ] && cd ${TSTDIR} && make && make install
[ -d ${opwd}/fontes ] && cd ${opwd}/fontes && make && make install
cd $opwd
# sleep 8 # you have some time to admire make at work
#
# puts everything one wants to download (from the temporary folder) in to
# what will become, in the emulated board, /usr/local/bin (is in the PATH) ....
set -vx
[ -d ${NOM_DIR_MNT}/usr/local/bin ] || $SUDO mkdir -p ${NOM_DIR_MNT}/usr/local/bin
$SUDO cp -rpuv ${TFTBOOT}"/"* ${NOM_DIR_MNT}/usr/local/bin/.
#
# one **must** unmount the qemu image before qemu can use it
$SUDO umount ${NOM_DIR_MNT}
#
qemu-system-arm -M versatilepb -kernel ${VMBOOT} -hda ${NOM_IMAGE} -append "root=/dev/sda mem=${RAMSIZE} ${OPTION}"
Nota : this script has been tested and run with some satisfaction for more than one month on Scientific Linux - 5.7 (a Red Hat clone, able to mount NTFS partitions and having a live DVD),Fedora 16 and a Mageia-1: emulated cards were apf9328 and apf27. The only flaw I could notice with SL-5.x was the absence of qemu on their live DVD (it is difficult to have a package manager add stuff on a RO media...) , which could be recompiled from source in a RW part of a disk with little trouble.
Nota : Some things are very unstandard : using /usr/local as a working directory on ones host is a consequence of lazy mounts on a Scientific Linux live DVD.... The size of the disks and the RAM do not need to be realistic, as it is meant for some tests (and lacking 500 K of disk , without tools to test it, might be frustrating)
Nota : copies which are made on an emulated image wo not appear on real hardware....
Misc 2
Adding a text editor:
Natively, armadeus is shipped with nano, a very simple version of vi (not like vim) and uemacs. If one needs some features like syntax highlighting (for shell/lua scripting) , noone of them is satisfying (and a full version of vim can be installed, but is space-consuming). A light solution can be found with joe [1], which offers syntax-highlighting (I noticed that 10% of my errors could be avoided with such a feature). The easiest solution is to compile it from source, test it and train oneself with it, and to modify the make invocation to use Armadeus's cross compiler instead of gcc, which leads to the following script one should execute on ones PC:
JOEROOT=/usr/local/ # in both the PC and the (emulated) Armadeus card tomake things simple....
cd /usr/local/armadeus-4.0/# both these lines depend on your installation and should be adapted
cd ~/armadeus-4.0/
cd joe-3.7/ # joe's source tree is located here
ici=`pwd`
make clean # first, removes everything (might be arm's binaries)
./configure --disable-termcap --prefix=${JOEROOT}
make && sudo make install
cd ..
# now, to arms
make shell_env && source armadeus_env.sh
export PATH=${ARMADEUS_TOOLCHAIN_PATH}/../bin/:${PATH}
cd ${ici}
# one removes x86 binaries, then one builds for arm
make clean && make CC=arm-linux-gcc
# some tests
echo "unstripped joe " > joestrip.txt
cp joe ../tftboot/unstrippedjoe
ls -l joe >> joestrip.txt
echo "stripped joe " >> joestrip.txt
arm-linux-strip joe
ls -l joe >> joestrip.txt
cp joe ../tftboot/. # it is ready to be shiped to an emulated card..
mkdir .././tftboot/usrlocalshare
cp -rpvf ${JOERROT}/share/joe .././tftboot/usrlocalshare/.
mkdir .././tftboot/usrlocaletc
cp -rpvf ${JOERROT}/etc/joe .././tftboot/usrlocaletc/.
# history >joestory
In this configuration, joe can be activated from an emulated card, its help appears but there is no syntax highligting. The ressource files/folders necessary to syntax highlight , however, have been shipped (they are ASCII files, valid on a x86 and an arm) but need to be on the right place. This can be achievd by executing, under an emulated board, a script like that:
[ -d /usr/local/share ] || mkdir /usr/local/share
[ -d /usr/local/etc ] || mkdir /usr/local/etc
mv /usr/local/bin/usrlocalshare/joe /usr/local/share/.
\mv /usr/local/bin/usrlocalshare/joe /usr/local/share/.
After this installation (there are better ones, based on tar files, say as tar exists wth the busy box, but this way can give opportunities of removing language syntax files, if they are unuseful), syntx highlight works...