Building Debian AM3352 SOM

You should make sure that you have the tools needed for building the Linux Kernel.
You'd have to install them if you don’t have them already installed.
To install new software you should be logged to a user with super user rights on your Linux machine. Type in the terminal:

$ sudo su

You will be asked for your password and then your prompt will change to # which means you are now the super user, all future commands should be run in this mode.

This will install: GCC compiler used to compile the kernel, the kernel config menu uboot make image which is required to allow the SD card to boot into the Linux image,
Git that allows you to download from the github which holds source code for some of the system, Some other tools for building the kernel

The menuconfig changes a .config text file, which you can view/edit even with a text editor like vi,nano.
With this command you can add or remove different modules for the different peripherials in the kernel.
Be careful when you change these settings because the kernel can stop working properly.

3.2 Make kernel image (zImage) and dts file

dts file is Device Tree Source file where is described MCU pin multiplexing and other very important information. So be carefully if you make changes in this file.
In our case dts file is named am335x-olimex-som.dts and it is located in arch/arm/boot/dts/

First we have to make the correct card partitions, this is done with fdisk.

Plug SD card into your SD card reader and enter in the terminal

ls /dev/sd

Then press two times <TAB> you will see a list of your sd devices like sda sdb sdc note that some of these devices may be your hard disk so make sure you know which one is your sd card before you proceed as you can damage your HDD if you choose the wrong sd-device.
You can do this by unplugging your sd card reader - pay attention which "sd" device disappears from the list.

Once you know which one is your microSD (as sda#) use it instead of the sdX name in the references below:

fdisk /dev/sdX

then:

4.1. p

will list your partitions. If there are already partitions on your card do:

4.2. d enter 1

if you have more than one partitition press d while delete them all

4.3. create the first partition, starting from 2048

n -> press enter
p -> press enter
1 -> press enter enter enter

then you can check what you do with pressing p

if you did everything correctly on 4GB card you should see something like:

You should be in /home/user/AM3352-SOM-olimex/u-boot-2013.10-ti2013.12.01-am3352_som# directory

Note that you have to write MLO and u-boot.img files in /dev/sdX (not in sdX1)

Type:

dd if=MLO of=/dev/sdX count=1 seek=1 conv=notrunc bs=128k

dd if=u-boot.img of=/dev/sdX count=2 seek=1 conv=notrunc bs=384k

6. Debian rootfs

The Linux Kernel and Uboot are ready, now we have need from Linux distribution rootfs.

Basically the only difference between the different Linux distributions is the rootfs, so if you put Debian rootfs you will have Debian,
if you put Ubuntu rootfs it will be Ubuntu etc.

How to build one is a long topic, the good thing is that there are many already pre-built so we can just download one and use it ready.

Now leave the kernel directory

cd ..

Should be in the directory below

/home/user/AM3352-SOM-olimex

Download debian rootfs with the file name "am3352-debian-3_12_FS_release_3.tgz" , which is available only as a torrent.
You would need a torrent client for it (Azureus, uTorrent, qBittorrent, etc). The link to the torrent file is:

6.3 Now you have to replace the new generated kernel modules from /home/user/AM3352-SOM-olimex/linux-3.12.10-ti2013.12.01-am3352_som/out/lib/modules/
to the new Debian file system, but first remove the old modules:

rm -rf /mnt/sd/lib/modules/*

cp -rfv out/lib/modules/3.x.xx+/ /mnt/sd/lib/modules/

where x.xx is the kernel version

in our case:

cp -rfv out/lib/modules/3.12.10-gf709364-dirty/ /mnt/sd/lib/modules/

add the files from the generated /out/lib/firmware folder to /mnt/sd/lib/firmware folder on sd card

cp -rfv out/lib/firmware/* /mnt/sd/lib/firmware/

sync

umount /mnt/sdX1

at this point you have Debian on your SD card and you have an SD card ready to boot debian on AM3352-SOM

Connect USB-SERIAL-CABLE-F to UEXT Tx, Rx and GND, or connect a VGA screen(the default VGA resolution is 1024x768).
Put the SD-card apply power according to AM3352-SOM-olimex board type.You should see Uboot and then Kernel messages on the console