AM335x

Revision as of 22:57, 18 September 2016 by StefanM (talk | contribs) (Debian 8)

Prepare card

To make sure everything will run without problem wipe all data on the MMC:

$ sudo dd if=/dev/zero of=/dev/sdx bs=1k count=1024

Format the disk:

$ sudo fdisk /dev/sdx << __EOF__
> n
> 
> 
> 
> 
> w
> __EOF__

Make ext4 filesystem

$ sudo mkfs.ext4 -F -O ^metadata_csum,^64bit /dev/sdx1

NOTE: You MUST replace /dev/sdx with your device, e.g. /dev/sdc.


U-Boot

Building U-Boot

Make sure you have cross compiler:

$ arm-linux-gnueabihf-gcc --version
arm-linux-gnueabihf-gcc (Debian 5.4.0-6) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE
   

If you don't have run:

$ sudo apt-get install gcc-5-arm-linux-gnueabihf

Get sources:

$ git clone git://git.denx.de/u-boot.git
$ cd u-boot

The patch is built against specific commit, so reset repository:

$ git reset --hard b89dfcfd926b8224edd24608065eb9bb601c0d3b

Get and apply patch:

$ wget <patch name>
$ git apply <patch name>

Build image, where <board_defconfig> is am335x_olimex_som_defconfig or am335x_olimex_som_nandboot_defconfig:

$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- <board_defconfig>

This will produce two files:

  • MLO
  • u-boot.img


Writing U-Boot

Writing to MMC

Insert your card and write MLO and u-boot.img:

$ sudo dd if=MLO of=/dev/sdx count=1 seek=1 bs=128k
$ sudo dd if=u-boot.img of=/dev/sdx count=2 seek=1 bs=384k 


Kernel

Building linux kernel

File system

Debian 8

Install required tools:

$ sudo apt-get install qemu-user-static debootstrap binfmt-support 

Make target directory:

$ mkdir rootfs
$ sudo debootstrap --arch=armhf --foreign jessie rootfs 

Copy qemu and resolvonf:

$ sudo cp /usr/bin/qemu-arm-static rootfs/usr/bin/
$ sudo cp /etc/resolv.conf rootfs/etc 

Go into the new file system:

$ sudo chroot rootfs 

Inside the new file system do:

# export LANG=C
# /debootstrap/debootstrap --second-stage 

Set apt sources.list:

# cat << __EOF__ > /etc/apt/sources.list
#------------------------------------------------------------------------------#
#                   OFFICIAL DEBIAN REPOS                    
#------------------------------------------------------------------------------#

###### Debian Main Repos
deb http://ftp.bg.debian.org/debian/ jessie main contrib non-free 
deb-src http://ftp.bg.debian.org/debian/ jessie main contrib non-free 

###### Debian Update Repos
deb http://security.debian.org/ jessie/updates main contrib non-free 
deb http://ftp.bg.debian.org/debian/ jessie-proposed-updates main contrib non-free 
deb-src http://security.debian.org/ jessie/updates main contrib non-free 
deb-src http://ftp.bg.debian.org/debian/ jessie-proposed-updates main contrib non-free 
__EOF__

Note: The list is generated using this tool, so feel free modify it.