How to make a bootable SD card for AM3352-SOM with kernel 3.12 and Linux Debian file system
1. Setup of the toolchain
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.
Next update apt-get links by typing:
- apt-get update
Next install the toolchain by typing the following:
- apt-get install gcc-4.7-arm-linux-gnueabihf ncurses-dev uboot-mkimage build-essential git
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
Note that if you use debian may be you will need to add:
deb http://www.emdebian.org/debian squeeze main
in the file below:
You would also need a torrent client. It is needed to be able to download the file system.
Any torrent that suits your needs would do the job, as long as it can load torrent files it is fine.
Now you have all important tools to make your very own AM3352-SOM-olimex kernel image!
2. Building Uboot
First let's make the directory where we would build the AM3352-SOM-olimex:
- mkdir AM3352-SOM-olimex
- cd AM3352-SOM-olimex
Then let’s download the uboot sources from GitHub repository. The u-boot is tested with the next branch:
- git rev-parse --verify HEAD 60be958867aacb41b669c456977db88e7d178346
Download u-boot sourses:
- git clone https://github.com/hehopmajieh/u-boot-2013.10-ti2013.12.01-am3352_som
After the download you should have a new directory
- cd u-boot-2013.10-ti2013.12.01-am3352_som/
With the following commands you have to configure the uboot for the different boards, use only the make command for your board:
- make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- am335x_evm_config
Now type the following command for u-boot building
- make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j4
At the end of the process you can check if everything is OK by
- ls MLO u-boot.img
If you got these files everything is complete, well done so far
- cd ..
You should be in the following directory:
3. Building kernel sources for AM3352-SOM-olimex boards
Kernel sources for AM3352-SOM-olimex are available on GitHub. Note that the following building is made with the revision below:
- git rev-parse --verify HEAD a64ba6c3babeb078f890706407e91b54e99fb5ca
You can download the kernel sources using the following command:
- git clone https://github.com/hehopmajieh/linux-3.12.10-ti2013.12.01-am3352_som
After the download go to the kernel directory:
- cd linux-3.12.10-ti2013.12.01-am3352_som/
3.1 Make defconfig
- make ARCH=arm am3352_som_defconfig
The result should be:
configuration written to .config
If you wish to make your changes in the kernel configuration do:
- make ARCH=arm menuconfig
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/
- make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j4 zImage dtbs
If everything is OK the result should be:
Kernel: arch/arm/boot/Image is ready
Kernel: arch/arm/boot/zImage is ready
Now you will have zImage file located in arch/arm/boot/
and am335x-olimex-som.dtb file in arch/arm/boot/dts/
3.3 The next step is kernel modules building:
- make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j4 INSTALL_MOD_PATH=out modules
- make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j4 INSTALL_MOD_PATH=out modules_install
DONE! At this point you have uboot and kernel modules.
The kernel modules are located in
where 3.xx.xx is kernel version.
4. Format and setup the SD-card
We suggest class 10 microSD card with memory capacity greater than 2GB. We haven't tested microSD cards bigger than 16GB.
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
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:
Command (m for help): p
Disk /dev/sde: 3980 MB, 3980394496 bytes
123 heads, 62 sectors/track, 1019 cylinders, total 7774208 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x6f20736b
Device Boot Start End Blocks Id System
/dev/sde1 2048 7774207 3886080 83 Linux
4.5. write changes to sd card
The partition table has been altered!
Calling ioctl() to re-read partition table.
Now we have to format the file system on the card :
- mkfs.ext4 /dev/sdX1
5. Write the Uboot on sd card
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)
- 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
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:
!!!!!!!!!!!!!!!!!!!!! need a link !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Now mount the microSD card EXT4 FS partition:
- mkdir /mnt/sd
- mount /dev/sdX1 /mnt/sd
and unarchive the rootfs
- tar am3352-debian-3_12_FS_release_3.tgz -C /mnt/sd
- ls /mnt/sd
The correct result should be:
bin/ dev/ home/ lost+found/ mnt/ proc/ run/ srv/ tmp/ usr/
boot/ etc/ lib/ media/ opt/ root/ sbin/ sys/ uEnv.txt var/
6.1. Write kernel zImage you built to the SD-card
You should in /home/user/AM3352-SOM-olimex/linux-3.12.10-ti2013.12.01-am3352_som directory
copy the Kernel zImage to boot directory in the first partition
- cp arch/arm/boot/zImage /mnt/sd/boot/
6.2. Write am335x-olimex-som.dtb file
am335x-olimex-som.dtb is a file with very important configuration parameters like port GPIO assignments, LCD, VGA resolution and etc,
Copy the am335x-olimex-som.dtb file to the mounted first partition of the SD card
- cp arch/arm/boot/dts/am335x-olimex-som.dtb /mnt/sd/boot/am335x-olimex-som.dtb
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/
- 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
default username/password is : olimex / olimex