Difference between revisions of "SAM9-L9260"

m (Preparing rootfs)
m (Preparing rootfs)
 
(24 intermediate revisions by the same user not shown)
Line 30: Line 30:
  
 
Get the sources:
 
Get the sources:
 +
git clone --depth 1 --branch linux-5.0.y git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
  
    git clone --depth 1 --branch linux-5.0.y git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
+
Get the patches:
 +
cd linux
 +
wget -O- https://raw.githubusercontent.com/OLIMEX/SAM9-L9260-Linux/master/0001-Update-SAM9-L9260-dts.patch | git am
 +
wget -O- https://raw.githubusercontent.com/OLIMEX/SAM9-L9260-Linux/master/0002-Add-Olimex-SAM9-L9260-defconfig.patch | git am
 +
wget -O- https://raw.githubusercontent.com/OLIMEX/SAM9-L9260-Linux/master/0003-Fix-subpage-writes-and-cs-deselect.patch | git am
 +
 
 +
Compile kernel and dtb:
 +
make ARCH=arm olimex_sam9_l9260_defconfig
 +
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- zImage dtbs
  
 
=== Preparing rootfs ===
 
=== Preparing rootfs ===
Line 39: Line 48:
 
Install required packages:
 
Install required packages:
  
    sudo apt-get update
+
sudo apt-get update
    sudo apt install -y debootstrap qemu-arm-static mtd-utils
+
sudo apt install -y debootstrap qemu-arm-static mtd-utils
  
 
Create empty directory, which will contain the new rootfs:
 
Create empty directory, which will contain the new rootfs:
  
    mkdir armel-lenny
+
mkdir armel-lenny
  
 
Run debootstrap and wait to finish:
 
Run debootstrap and wait to finish:
  
    sudo qemu-debootstrap --arch armel lenny ./armel-lenny
+
sudo qemu-debootstrap --arch armel lenny ./armel-lenny
 +
 
 +
Login into the new rootfs with:
 +
 
 +
sudo chroot ./armel-lenny
 +
 
 +
Set hostname and password:
 +
 
 +
echo 'sam9-l9260' > /etc/hostname
 +
passwd
 +
 
 +
Set locales:
 +
 
 +
apt-get install locales
 +
dpkg-reconfigure locales
 +
 
 +
Configure login console:
 +
 
 +
sed -i "s/.*T0:.*/T0:2345:respawn:\/sbin\/getty\ -L\ ttyS0\ 115200\ vt100/g" /etc/inittab
 +
 
 +
Install some additional packages:
 +
apt-get install autoconf autotools-dev bash-completion bind9-host binutils busybox cpp ethtool ftp initramfs-tools less lsof m4 mime-support mtd-utils ntp openssh-client python telnet texinfo udev usbutils whois
 +
 
 +
Configure fstab:
 +
 
 +
cat > /etc/fstab << __EOF__
 +
# /etc/fstab: static file system information.
 +
#
 +
# <file system> <mount point>  <type>  <options>      <dump>  <pass>
 +
proc            /proc          proc    defaults        0      0
 +
rootfs          /              jffs2  rw              0      0
 +
 
 +
__EOF__
 +
 
 +
Create missing /dev/shm folder:
 +
 
 +
sed -i '36i\\t[ ! -d /dev/shm ] && mkdir --mode=755 /dev/shm' /etc/init.d/mountdevsubfs.sh
 +
 
 +
Configure networking:
 +
 
 +
cat >> /etc/network/interfaces << __EOF__
 +
# The loopback network interface
 +
auto lo
 +
iface lo inet loopback
 +
 +
# The primary network interface
 +
allow-hotplug eth0
 +
iface eth0 inet dhcp
 +
 +
__EOF__
 +
 
 +
Exit from chroot:
 +
 
 +
exit
 +
 
 +
==== Generate JFFS2 image ====
 +
 
 +
Run:
 +
 
 +
sudo mkfs.jffs2 -r armel-lenny/ -o lenny.jffs2 -e 128 -s 512 -p -n
 +
 
 +
Where:
 +
* -e 128 - 128KiB of erase block
 +
* -s 512 - 512B page size
 +
* -p - pad the output to match erase block size
 +
* -n - do not write cleanmarkers
 +
 
 +
==== Generate UBIFS image ====
 +
 
 +
Before creating image some NAND parameters must be known. The shown default values are for '''K9F4G08U0F''' chip.
 +
 
 +
* '''PEB''' -> Physical erase block, default: 128KiB (131072)
 +
* '''LEB''' -> Logical erase block, default : 124KiB (126976)
 +
* '''min. I/O size''' -> Page size, default : 2048
 +
* '''sub-page size''' -> Subpage size, default : 2048
 +
* '''LEB count''' -> Number of LEBs in the rootfs mtd partition, default: 4031
 +
 
 +
Create ubifs volume:
 +
 
 +
sudo mkfs.ubifs -d armel-lenny -o lenny.ubifs -m 2048 -e 126976 -c 4024
  
Make some rootfs modifications:
+
Generate ubifs image:
  
    sudo chroot ./armel-lenny
+
cat > ubinize.ini << __EOF__
 +
[rootfs_volume]
 +
mode=ubi
 +
image=lenny.ubifs
 +
vol_id=1
 +
vol_type=dynamic
 +
vol_name=rootfs
 +
vol_alignment=1
 +
vol_flags=autoresize
 +
__EOF__
 +
ubinize -vv -o lenny.img -m 2048 -p 128KiB ubinize.ini -s 512
  
 
== Projects ==
 
== Projects ==

Latest revision as of 06:48, 22 March 2019

Documents

Under construction

Hardware

Under construction

Software

Building at91bootstrap

Get the sources with:

   git clone -b olimex https://github.com/OLIMEX/at91bootstrap.git

Go to the cloned folder and select SAM9-L9260 configuration:

   cd at91bootstrap
   make sam9_l9260_uboot_defconfig

Compile the sources with:

   make CROSS_COMPILE=arm-linux-gnueabi-

The bootstrap file can be found at:

   binaries/sam9_l9260-dataflashcardboot--3.8.11.bin

Building kernel

Get the sources:

git clone --depth 1 --branch linux-5.0.y git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git

Get the patches:

cd linux
wget -O- https://raw.githubusercontent.com/OLIMEX/SAM9-L9260-Linux/master/0001-Update-SAM9-L9260-dts.patch | git am
wget -O- https://raw.githubusercontent.com/OLIMEX/SAM9-L9260-Linux/master/0002-Add-Olimex-SAM9-L9260-defconfig.patch | git am
wget -O- https://raw.githubusercontent.com/OLIMEX/SAM9-L9260-Linux/master/0003-Fix-subpage-writes-and-cs-deselect.patch | git am

Compile kernel and dtb:

make ARCH=arm olimex_sam9_l9260_defconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- zImage dtbs

Preparing rootfs

In this tutorial Debian Lenny will be used. The build process may vary, depending on host PC system. The following instructions are tested on Ubuntu 18.04.

Install required packages:

sudo apt-get update
sudo apt install -y debootstrap qemu-arm-static mtd-utils

Create empty directory, which will contain the new rootfs:

mkdir armel-lenny

Run debootstrap and wait to finish:

sudo qemu-debootstrap --arch armel lenny ./armel-lenny

Login into the new rootfs with:

sudo chroot ./armel-lenny

Set hostname and password:

echo 'sam9-l9260' > /etc/hostname
passwd

Set locales:

apt-get install locales
dpkg-reconfigure locales

Configure login console:

sed -i "s/.*T0:.*/T0:2345:respawn:\/sbin\/getty\ -L\ ttyS0\ 115200\ vt100/g" /etc/inittab

Install some additional packages:

apt-get install autoconf autotools-dev bash-completion bind9-host binutils busybox cpp ethtool ftp initramfs-tools less lsof m4 mime-support mtd-utils ntp openssh-client python telnet texinfo udev usbutils whois

Configure fstab:

cat > /etc/fstab << __EOF__
# /etc/fstab: static file system information.
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    defaults        0       0
rootfs          /               jffs2   rw              0       0
__EOF__

Create missing /dev/shm folder:

sed -i '36i\\t[ ! -d /dev/shm ] && mkdir --mode=755 /dev/shm' /etc/init.d/mountdevsubfs.sh

Configure networking:

cat >> /etc/network/interfaces << __EOF__
# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug eth0
iface eth0 inet dhcp

__EOF__

Exit from chroot:

exit

Generate JFFS2 image

Run:

sudo mkfs.jffs2 -r armel-lenny/ -o lenny.jffs2 -e 128 -s 512 -p -n

Where:

  • -e 128 - 128KiB of erase block
  • -s 512 - 512B page size
  • -p - pad the output to match erase block size
  • -n - do not write cleanmarkers

Generate UBIFS image

Before creating image some NAND parameters must be known. The shown default values are for K9F4G08U0F chip.

  • PEB -> Physical erase block, default: 128KiB (131072)
  • LEB -> Logical erase block, default : 124KiB (126976)
  • min. I/O size -> Page size, default : 2048
  • sub-page size -> Subpage size, default : 2048
  • LEB count -> Number of LEBs in the rootfs mtd partition, default: 4031

Create ubifs volume:

sudo mkfs.ubifs -d armel-lenny -o lenny.ubifs -m 2048 -e 126976 -c 4024

Generate ubifs image:

cat > ubinize.ini << __EOF__
[rootfs_volume]
mode=ubi
image=lenny.ubifs
vol_id=1
vol_type=dynamic
vol_name=rootfs
vol_alignment=1
vol_flags=autoresize
__EOF__
ubinize -vv -o lenny.img -m 2048 -p 128KiB ubinize.ini -s 512

Projects

Under construction

FAQ

Under construction