Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This is a root filesystem builder for i.MX6 devices for R. Feranec of imx6rex.com
#!/bin/bash
# i.MX6 filesystem builder for R. Feranec
# Sam Nazarko - 20141028
echo -e "i.MX6 filesystem generator"
echo -e "For best results run this on the latest Ubuntu build"
hasRefreshed=0
function checkPackage()
{
dpkg -l | grep -q $1
if [ $? == 0 ]
then
echo "Package ${1} is already installed"
else
echo "Package ${1} is not installed. We need to grab it"
if [ "${hasRefreshed}" -ne 1 ]
then
echo "Need to update apt cache"
echo "Please be patient"
apt-get update > /dev/null 2>&1
hasRefreshed=1
fi
apt-get -y install ${1}
fi
}
checkPackage "debootstrap"
checkPackage "qemu-user-static"
clear
echo -e "Please specify the distribution you would like to build. Examples:\ntrusty (Ubuntu 14.04)\nprecise (Ubuntu 12.04)\nwheezy (Debian 7.0)"
read dist
clear
echo -e "What packages would you like to install? Examples:\napache2\nopenssh-server\n\nFor a list of packages, or to properly determine the package name, Google 'packagename in ${dist}'\n\nType 'END' when you have selected all your packages"
while [ "$packagename" != "END" ]
do
read packagename
if [ "$packagename" != "END" ]
then
echo -e "Added package ${packagename}"
packages+="${packagename} "
fi
done
clear
if [ -d rootfs ]
then
echo -e "Deleting old root filesystem"
fi
echo -e "Debootstrapping"
debootstrap --foreign --arch=armhf --include="${packages}" ${dist} rootfs
clear
echo -e "Using emulator to finish install"
cp /usr/bin/qemu-arm-static rootfs/usr/bin
chroot rootfs/ /debootstrap/debootstrap --second-stage
clear
echo -e "Please set a root password"
chroot rootfs/ passwd
# Clean up ARM
rm rootfs/usr/bin/qemu-arm-static
clear
echo -e "Enabling network support on eth0"
echo "
# The loopback network interface
auto lo eth0
iface lo inet loopback
# The primary network interface
iface eth0 inet dhcp" > rootfs/etc/network/interfaces
clear
echo -e "Configuring hostname, what would you like?"
read hostname
echo -e ${hostname} > rootfs/etc/hostname
clear
echo -e "Creating tarball"
TAR="root-filesystem-imx6"
cd rootfs
tar -czvf ${TAR}.tar.gz *
md5sum ${TAR}.tar.gz > ${TAR}.md5
mv ${TAR}* ../
cd ../
clear
echo -e "Build completed successfully"
@alexdcg

This comment has been minimized.

Copy link

@alexdcg alexdcg commented Dec 5, 2014

If no package is added the build fails.

Consider a patch like this: http://pastebin.com/373wwC4a

@aneeshkr03-git

This comment has been minimized.

Copy link

@aneeshkr03-git aneeshkr03-git commented Jan 20, 2021

We are currently using MY-IMX6-CB140-6Y2D-512M-4G module in a custom board with kernel 4.1.15. But I am not getting the login option to the console. I have selected trusty/manjaro as distribution. Both having the same issue. Could you please help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment