Difference between revisions of "AM335x"
m (→Debian 8) |
m |
||
Line 74: | Line 74: | ||
==Kernel== | ==Kernel== | ||
− | === | + | |
+ | We are going to use kernel 4.4 from TI. | ||
+ | |||
+ | ===Getting the sources=== | ||
+ | |||
+ | Clone into repository: | ||
+ | $ git clone git://git.ti.com/ti-linux-kernel/ti-linux-kernel.git | ||
+ | $ cd ti-linux-kernel | ||
+ | |||
+ | Get 4.4.y remote branch: | ||
+ | $ git checkout linux-4.4.y -b linux-4.4 | ||
+ | |||
+ | |||
+ | Make omap2plus default defconfig: | ||
+ | $ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- omap2plus_defconfig | ||
+ | |||
+ | Make some modifications: | ||
+ | $ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- omap2plus_defconfig | ||
+ | |||
+ | * Enable SPIDEV | ||
+ | |||
+ | Device Drivers ---> | ||
+ | [*] SPI support ---> | ||
+ | <M> User mode SPI device driver support | ||
+ | |||
+ | * Enable DRM | ||
+ | |||
+ | Device Drivers ---> | ||
+ | Graphics support ---> | ||
+ | <M> Direct Rendering Manager (XFree86 4.1.0 and higher DRI support) ---> | ||
+ | <M> DRM Support for TI LCDC Display Controller | ||
+ | [*] Support device tree blobs using TI LCDC Slave binding (NEW) | ||
+ | |||
+ | * Enable SHAM and AES | ||
+ | |||
+ | -*- Cryptographic API ---> | ||
+ | [*] Hardware crypto devices ---> | ||
+ | <M> Support for OMAP MD5/SHA1/SHA2 hw accelerator | ||
+ | <M> Support for OMAP AES hw engine | ||
+ | |||
+ | Build kernel and modules: | ||
+ | $ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- zImage modules | ||
+ | |||
+ | Install modules to target directory: | ||
+ | $ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=output modules_install | ||
+ | |||
+ | Patch kernel tree to get our device-tree blobs: | ||
+ | $ git apply 0001-Add-support-for-OLIMEX-dtbs.patch | ||
+ | |||
+ | If patch fail, you can reset the tree: | ||
+ | $ git reset --hard 65fd19fc2bac06ae7e66cc3d6450c9d6dd034311 | ||
+ | |||
+ | Build dtbs: | ||
+ | $ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- dtbs | ||
+ | |||
+ | This will produce lot of .dtb files. The interesting ones are: | ||
+ | * '''am335x-olimex-som.dtb''' - The minimum configuration for AM335x-SOM to run. | ||
+ | * '''am335x-olimex-som-nand.dtb''' - Same as above, but with enabled nand. | ||
+ | * '''am335x-olimex-som-evb.dtb''' - Support for AM335x-SOM-EVB. Use this one, if there isn't intalled nand on AM335x-SOM | ||
+ | * '''am335x-olimex-som-evb-nand.dtb''' - Save above, without dual ethernet and enabled nand. | ||
Line 98: | Line 157: | ||
# export LANG=C | # export LANG=C | ||
− | # /debootstrap/debootstrap --second-stage | + | # /debootstrap/debootstrap --second-stage |
Set apt sources.list: | Set apt sources.list: | ||
Line 117: | Line 176: | ||
__EOF__ | __EOF__ | ||
− | '''Note:''' The list is generated using [https://debgen.simplylinux.ch/generate.php this] tool, so feel free modify it. | + | '''Note:''' The list is generated using [https://debgen.simplylinux.ch/generate.php this] tool, |
+ | so feel free modify it. | ||
+ | |||
+ | Set hostname: | ||
+ | # echo "AM335x" > /etc/hostname | ||
+ | |||
+ | Install some packages: | ||
+ | # apt-get install locales dialog sudo openssh | ||
+ | |||
+ | Set locales: | ||
+ | # dpkg-reconfigure locales | ||
+ | |||
+ | |||
+ | Set root password: | ||
+ | # passwd | ||
+ | |||
+ | Add olimex user: | ||
+ | # adduser olimex | ||
+ | |||
+ | ====Enable serial port on USB-OTG==== | ||
+ | |||
+ | Make script that initialize serial gadget: | ||
+ | # cat << __EOF__ > /usb/bin/usb_serial.sh | ||
+ | #/bin/sh | ||
+ | |||
+ | # variables and strings | ||
+ | CONFIGS_DIR="/configs" | ||
+ | MANUFACTURER="Olimex Ltd." # manufacturer attribute | ||
+ | SERIAL=$(ifconfig eth0 | head -n1 | awk -F" " '{print $5}' | sed 's/://g') | ||
+ | IDPRODUCT="0x003e" # hex product ID, issued by USB Group | ||
+ | IDVENDOR="0x15ba" # hex vendor ID, assigned by USB Group | ||
+ | PRODUCT="AM335x Serial Gadget" # cleartext product description | ||
+ | CONFIG_NAME="Configuration 1" # name of this configuration | ||
+ | UDC=musb-hdrc.0.auto # name of the UDC driver to use (found in /sys/class/udc/) | ||
+ | |||
+ | # Load modules | ||
+ | ! lsmod | grep "libcomposite" > /dev/null 2>&1 && modprobe libcomposite | ||
+ | ! lsmod | grep "usb_f_acm" > /dev/null 2>&1 && modprobe usb_f_acm | ||
+ | |||
+ | # Mount confgsfs | ||
+ | [ ! -d $CONFIGS_DIR ] && mkdir $CONFIGS_DIR | ||
+ | mount none $CONFIGS_DIR -t configfs | ||
+ | |||
+ | # Create gadget | ||
+ | mkdir -p $CONFIGS_DIR/usb_gadget/serial | ||
+ | cd $CONFIGS_DIR/usb_gadget/serial | ||
+ | |||
+ | # Set VID and PID | ||
+ | echo $IDVENDOR > idVendor | ||
+ | echo $IDPRODUCT > idProduct | ||
+ | |||
+ | # Set strings | ||
+ | mkdir strings/0x409 | ||
+ | echo $SERIAL > strings/0x409/serialnumber | ||
+ | echo $MANUFACTURER > strings/0x409/manufacturer | ||
+ | echo $PRODUCT > strings/0x409/product | ||
+ | |||
+ | # Create configuration | ||
+ | mkdir configs/c.1 | ||
+ | mkdir configs/c.1/strings/0x409 | ||
+ | echo "120" > configs/c.1/MaxPower | ||
+ | echo $CONFIG_NAME > configs/c.1/strings/0x409/configuration | ||
+ | |||
+ | # Creating functions | ||
+ | mkdir functions/acm.usb0 | ||
+ | |||
+ | # Associate function with comfiguration | ||
+ | ln -s functions/acm.usb0 configs/c.1 | ||
+ | |||
+ | # Enable UDC | ||
+ | echo $UDC > UDC | ||
+ | __EOF__ | ||
+ | # chmod +x /usb/bin/usb_serial.sh | ||
+ | |||
+ | Add startup service: | ||
+ | # cat << _EOF__ > /lib/systemd/system/usb-serial.service | ||
+ | [Unit] | ||
+ | Description=Serial console on USB-OTG | ||
+ | ConditionPathExists=/sys/devices/platform/ocp/47400000.usb/47401300.usb-phy/ | ||
+ | |||
+ | |||
+ | [Service] | ||
+ | Type=oneshot | ||
+ | ExecStart=/bin/bash -c "/usr/bin/usb_serial.sh" | ||
+ | RemainAfterExit=yes | ||
+ | |||
+ | [Install] | ||
+ | WantedBy=getty.target | ||
+ | __EOF__ | ||
+ | |||
+ | Enable login on ttyGS0: | ||
+ | # cp -v /lib/systemd/system/serial-getty\@.service | ||
+ | # nano /lib/systemd/system/serial-getty\@ttyGS0.service | ||
+ | Add following in [Unit] section: | ||
+ | Requires=usb-serial.service | ||
+ | # systemctl enable serial-getty\@ttyGS0.service |
Revision as of 23:15, 21 September 2016
Contents
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
We are going to use kernel 4.4 from TI.
Getting the sources
Clone into repository:
$ git clone git://git.ti.com/ti-linux-kernel/ti-linux-kernel.git $ cd ti-linux-kernel
Get 4.4.y remote branch:
$ git checkout linux-4.4.y -b linux-4.4
Make omap2plus default defconfig:
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- omap2plus_defconfig
Make some modifications:
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- omap2plus_defconfig
- Enable SPIDEV
Device Drivers ---> [*] SPI support ---> <M> User mode SPI device driver support
- Enable DRM
Device Drivers ---> Graphics support ---> <M> Direct Rendering Manager (XFree86 4.1.0 and higher DRI support) ---> <M> DRM Support for TI LCDC Display Controller [*] Support device tree blobs using TI LCDC Slave binding (NEW)
- Enable SHAM and AES
-*- Cryptographic API ---> [*] Hardware crypto devices ---> <M> Support for OMAP MD5/SHA1/SHA2 hw accelerator <M> Support for OMAP AES hw engine
Build kernel and modules:
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- zImage modules
Install modules to target directory:
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=output modules_install
Patch kernel tree to get our device-tree blobs:
$ git apply 0001-Add-support-for-OLIMEX-dtbs.patch
If patch fail, you can reset the tree:
$ git reset --hard 65fd19fc2bac06ae7e66cc3d6450c9d6dd034311
Build dtbs:
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- dtbs
This will produce lot of .dtb files. The interesting ones are:
- am335x-olimex-som.dtb - The minimum configuration for AM335x-SOM to run.
- am335x-olimex-som-nand.dtb - Same as above, but with enabled nand.
- am335x-olimex-som-evb.dtb - Support for AM335x-SOM-EVB. Use this one, if there isn't intalled nand on AM335x-SOM
- am335x-olimex-som-evb-nand.dtb - Save above, without dual ethernet and enabled nand.
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.
Set hostname:
# echo "AM335x" > /etc/hostname
Install some packages:
# apt-get install locales dialog sudo openssh
Set locales:
# dpkg-reconfigure locales
Set root password:
# passwd
Add olimex user:
# adduser olimex
Enable serial port on USB-OTG
Make script that initialize serial gadget:
# cat << __EOF__ > /usb/bin/usb_serial.sh #/bin/sh
# variables and strings CONFIGS_DIR="/configs" MANUFACTURER="Olimex Ltd." # manufacturer attribute SERIAL=$(ifconfig eth0 | head -n1 | awk -F" " '{print $5}' | sed 's/://g') IDPRODUCT="0x003e" # hex product ID, issued by USB Group IDVENDOR="0x15ba" # hex vendor ID, assigned by USB Group PRODUCT="AM335x Serial Gadget" # cleartext product description CONFIG_NAME="Configuration 1" # name of this configuration UDC=musb-hdrc.0.auto # name of the UDC driver to use (found in /sys/class/udc/) # Load modules ! lsmod | grep "libcomposite" > /dev/null 2>&1 && modprobe libcomposite ! lsmod | grep "usb_f_acm" > /dev/null 2>&1 && modprobe usb_f_acm
# Mount confgsfs [ ! -d $CONFIGS_DIR ] && mkdir $CONFIGS_DIR mount none $CONFIGS_DIR -t configfs # Create gadget mkdir -p $CONFIGS_DIR/usb_gadget/serial cd $CONFIGS_DIR/usb_gadget/serial # Set VID and PID echo $IDVENDOR > idVendor echo $IDPRODUCT > idProduct # Set strings mkdir strings/0x409 echo $SERIAL > strings/0x409/serialnumber echo $MANUFACTURER > strings/0x409/manufacturer echo $PRODUCT > strings/0x409/product # Create configuration mkdir configs/c.1 mkdir configs/c.1/strings/0x409 echo "120" > configs/c.1/MaxPower echo $CONFIG_NAME > configs/c.1/strings/0x409/configuration # Creating functions mkdir functions/acm.usb0 # Associate function with comfiguration ln -s functions/acm.usb0 configs/c.1 # Enable UDC echo $UDC > UDC __EOF__ # chmod +x /usb/bin/usb_serial.sh
Add startup service:
# cat << _EOF__ > /lib/systemd/system/usb-serial.service [Unit] Description=Serial console on USB-OTG ConditionPathExists=/sys/devices/platform/ocp/47400000.usb/47401300.usb-phy/ [email protected] [Service] Type=oneshot ExecStart=/bin/bash -c "/usr/bin/usb_serial.sh" RemainAfterExit=yes [Install] WantedBy=getty.target __EOF__
Enable login on ttyGS0:
# cp -v /lib/systemd/system/serial-getty\@.service # nano /lib/systemd/system/serial-getty\@ttyGS0.service
Add following in [Unit] section:
Requires=usb-serial.service # systemctl enable serial-getty\@ttyGS0.service