Difference between revisions of "i.MX53 SODIMM PC Debian"

From Voipac Wiki
Jump to navigation Jump to search
(Created page with "Category:i.MX53 SODIMM PC - Development kit <!-- --> <div style="float:right">__TOC__</div> Altering and building Debiam filesytem suitable for i.MX53 SODIMM PC - Develop...")
 
 
(10 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[Category:i.MX53 SODIMM PC - Development kit]]
+
[[Category:i.MX53 SODIMM PC - Development Kit]]
 
<!-- -->
 
<!-- -->
 
<div style="float:right">__TOC__</div>
 
<div style="float:right">__TOC__</div>
  
Altering and building Debiam filesytem suitable for i.MX53 SODIMM PC - Development kit is shown here. Debian is a free operating system suitable for embedded solutions. An operating system is the set of basic programs and utilities that make the board run. More information about the Debian project can be found in [https://www.debian.org/ the official website].
+
Altering and building Debian filesytem suitable for i.MX53 SODIMM PC - Development Kit is shown in this section. Debian is a free operating system and an excellent choice for embedded solutions. More information about Debian project can be found on [https://www.debian.org/ the official website].
  
 
== Initial steps ==
 
== Initial steps ==
Line 13: Line 13:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
=== Download instalation files ===
+
=== Download installation files ===
 +
As the official Debian server does not contain these important files anymore, an alternate source can be used instead:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
wget http://ftp.debian.org/debian/dists/stable/main/installer-armhf/current/images/vexpress/netboot/initrd.gz
+
wget https://github.com/PhilipDeegan/qemu/raw/master/arm/os/debian/initrd.gz
wget http://ftp.debian.org/debian/dists/stable/main/installer-armhf/current/images/vexpress/netboot/vmlinuz-3.2.0-4-vexpress
+
wget https://github.com/PhilipDeegan/qemu/raw/master/arm/os/debian/vmlinuz-3.2.0-4-vexpress
 
</syntaxhighlight>
 
</syntaxhighlight>
  
In case of official Debian server does not store the files anymore, an alternate source can be used:
+
The original path where these files were located on Debian server:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
wget https://github.com/PhilipDeegan/qemu/blob/master/arm/os/debian/initrd.gz
+
# wget http://ftp.debian.org/debian/dists/stable/main/installer-armhf/current/images/vexpress/netboot/initrd.gz
wget https://github.com/PhilipDeegan/qemu/blob/master/arm/os/debian/vmlinuz-3.2.0-4-vexpress
+
# wget http://ftp.debian.org/debian/dists/stable/main/installer-armhf/current/images/vexpress/netboot/vmlinuz-3.2.0-4-vexpress
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Line 117: Line 118:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 +
=== Add Voipac logo ===
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
cat << EOF > rootfs-debian7/etc/logo.sh
 
cat << EOF > rootfs-debian7/etc/logo.sh

Latest revision as of 14:08, 24 April 2022

Altering and building Debian filesytem suitable for i.MX53 SODIMM PC - Development Kit is shown in this section. Debian is a free operating system and an excellent choice for embedded solutions. More information about Debian project can be found on the official website.

Initial steps

Create working directory

mkdir -pv ~/workdir/vmx53/rootfs/debian7
cd ~/workdir/vmx53/rootfs/debian7

Download installation files

As the official Debian server does not contain these important files anymore, an alternate source can be used instead:

wget https://github.com/PhilipDeegan/qemu/raw/master/arm/os/debian/initrd.gz
wget https://github.com/PhilipDeegan/qemu/raw/master/arm/os/debian/vmlinuz-3.2.0-4-vexpress

The original path where these files were located on Debian server:

# wget http://ftp.debian.org/debian/dists/stable/main/installer-armhf/current/images/vexpress/netboot/initrd.gz
# wget http://ftp.debian.org/debian/dists/stable/main/installer-armhf/current/images/vexpress/netboot/vmlinuz-3.2.0-4-vexpress

Install Debian into emulated machine

Create virtual HDD

qemu-img create -f raw ramdisk.img 2G

Install Debian

qemu-system-arm -m 256 -machine vexpress-a9 \
        -kernel vmlinuz-3.2.0-4-vexpress \
        -initrd initrd.gz \
        -sd ramdisk.img -append "root=/dev/ram"

Extract installed filesystem

Find partition start offset

hexdump -C ramdisk.img | less

00000000  fa b8 00 10 8e d0 bc 00  b0 b8 00 00 8e d8 8e c0  |................|
00000010  fb be 00 7c bf 00 06 b9  00 02 f3 a4 ea 21 06 00  |...|.........!..|
00000020  00 be be 07 38 04 75 0b  83 c6 10 81 fe fe 07 75  |....8.u........u|
00000030  f3 eb 16 b4 02 b0 01 bb  00 7c b2 80 8a 74 01 8b  |.........|...t..|
00000040  4c 02 cd 13 ea 00 7c 00  00 eb fe 00 00 00 00 00  |L.....|.........|
00000050  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
000001b0  00 00 00 00 00 00 00 00  d2 63 00 00 00 00 80 20  |.........c..... |
000001c0  21 00 83 f3 6f 04 00 08  00 00 00 f0 3f 00 00 00  |!...o.......?...|
000001d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
00000200  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00100000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................| << here starts first partition
*
00100400  00 00 02 00 00 fe 07 00  4c 66 00 00 70 e9 05 00  |........Lf..p...|
00100410  fb 98 01 00 00 00 00 00  02 00 00 00 02 00 00 00  |................|

Copy the filesystem

mkdir -pv mount
mkdir -pv rootfs-debian7    
sudo chown root:root  rootfs-debian7
sudo mount -t ext4 -o loop,offset=1048576 ramdisk.img mount/
sudo cp -arvpf mount/* rootfs-debian7/
sudo umount mount/

Modifications

Remove persistent rules

#sudo rm rootfs-debian7/etc/udev/rules.d/70-persistent*
sudo sed -i '/^#/!d' rootfs-debian7/etc/fstab
#sudo sed -i 's/iface eth0/#iface eth0/g' rootfs-debian7/etc/network/interfaces

Enable serial console

sudo su

cat >> rootfs-debian7/etc/inittab << EOF
# VMX53 serial console
T0:2345:respawn:/sbin/getty -L ttymxc0 115200 vt100
EOF

exit

Add valid nameservers

sudo su

cat > rootfs-debian7/etc/resolv.conf << EOF
domain example.org
search example.org
nameserver 8.8.8.8
nameserver 8.8.4.4
EOF

exit

Disable some services

sudo su

#sed -i 's/^test -x \/usr\/lib\/exim4\/exim4/test ! -x \/usr\/lib\/exim4\/exim4/' rootfs-debian7/etc/init.d/exim4

exit

cat << EOF > rootfs-debian7/etc/logo.sh
sudo su

#!/bin/sh

NORMAL="
\\033[0;39m"         # Standard console grey
SUCCESS="
\\033[1;32m"        # Success is green
WARNING="
\\033[1;33m"        # Warnings are yellow
FAILURE="
\\033[1;31m"        # Failures are red
INFO="
\\033[1;36m"           # Information is light cyan
BRACKET="
\\033[1;34m"        # Brackets are blue

ramt=\$(cat /proc/meminfo | grep MemTotal | awk '{print \$2}')
ramt=\$((ramt/1024))
ramf=\$(cat /proc/meminfo | grep MemFree  | awk '{print \$2}')
ramf=\$((ramf/1024))

romt=\$(df -h | grep root | head -n1 | awk '{print \$2"B"}')
romf=\$(df -h | grep root | head -n1 | awk '{print \$4"B"}')

root=\$(mount | grep -v '^rootfs' | grep root | awk '{print \$5}')
ipaddr=\$(ifconfig eth0 | grep "inet addr" | cut -d ":" -f2 | cut -d " " -f1)

echo "             _                    "
echo -n "            :_;                   "
echo "  \$(cat /proc/cpuinfo | grep -i 'Hardware' | awk '{print \$1": "\$3" "\$4}')"
echo ".-..-. .--. .-..---.  .--.   .--. "
echo -n ": 
\`; :' .; :: :: .; 
\`' .; ; '  ..'"
printf "  RAM:%06sMB FREE:%06sMB\n" \${ramt} \${ramf}
echo -n "
\`.__.'
\`.__.':_;: ._.'
\`.__,_;
\`.__.'"
printf "  ROM:%08s FREE:%08s\n" \${romt} \${romf}
echo -n "               : :                "
echo "  ROOT: \${SUCCESS}\${root}\${NORMAL}"
echo -n "               :_;                "
echo "  IP:   \${ipaddr}"
EOF
chmod a+x rootfs-debian7/etc/logo.sh
sed -i '/^exit/d' rootfs-debian7/etc/rc.local
cat << EOF >> rootfs-debian7/etc/rc.local
# Voipac logo
. /etc/logo.sh
exit 0
EOF

exit

Strip down filesystem even more

sudo apt-get install qemu-user-static
sudo cp -arvp rootfs-debian7 rootfs-debian7-tiny
sudo apt-get install qemu-user-static
sudo cp /usr/bin/qemu-arm-static rootfs-debian7-tiny/usr/bin
sudo chroot rootfs-debian7-tiny apt-get install localepurge
sudo chroot rootfs-debian7-tiny localepurge
#sudo chroot rootfs-debian7-tiny dpkg --get-selections
sudo chroot rootfs-debian7-tiny apt-get purge linux-image-vexpress
sudo chroot rootfs-debian7-tiny apt-get purge linux-image-3.2.0-4-vexpress

Final filesystem packages

NFS

sudo cp -arvpf rootfs-debian7/ /srv/nfs/rootfs-debian7-vmx53
/srv/nfs/rootfs-debian7-vmx53 *(rw,no_root_squash,no_all_squash,no_subtree_check,sync)
sudo exportfs -ra

TAR

cd rootfs-debian7-tiny/
sudo tar cvJpf ../rootfs-debian7-nfs_vmx53_$(date "+%Y%m%d").tar.xz *

UBIFS

NAND Flash up to 512MB

export fs_direcotry=/home/marek/workdir/vmx53/rootfs/debian7/rootfs-debian7-tiny/
export fs_ubifs_image=rootfs-debian7-ubifs-m2k-e128k-512M_vmx53_$(date "+%Y%m%d").bin
sudo mkfs.ubifs -m 2048 -e 129024 -c 4080 -r ${fs_direcotry} -o ${fs_ubifs_image}
cp -av ${fs_ubifs_image} /srv/tftp/vmx53/

NAND Flash 1GB

export fs_direcotry=/home/marek/workdir/vmx53/rootfs/debian7/rootfs-debian7-tiny/
export fs_ubifs_image=rootfs-debian7-ubifs-m4k-e512k-1G_vmx53_$(date "+%Y%m%d").bin
sudo mkfs.ubifs -m 4096 -e 520192 -c 2000 -r ${fs_direcotry} -o ${fs_ubifs_image}
cp -av ${fs_ubifs_image} /srv/tftp/vmx53/

NAND Flash 4GB

export fs_direcotry=/home/marek/workdir/vmx53/rootfs/debian7/rootfs-debian7-tiny/
export fs_ubifs_image=rootfs-debian7-ubifs-m4k-e1M-4G_vmx53_$(date "+%Y%m%d").bin
sudo mkfs.ubifs -m 4096 -e 1040384 -c 4080 -r ${fs_direcotry} -o ${fs_ubifs_image}
cp -av ${fs_ubifs_image} /srv/tftp/vmx53/