COM AM35 Linux: Difference between revisions

From Wiki-DB
Jump to navigationJump to search
Lzenz (talk | contribs)
Lzenz (talk | contribs)
No edit summary
Line 1: Line 1:
==<br/>FAQ ==
=== Ethernet does not work ===
Check if the line "allow-hotplug eth0" in the file "/etc/network/interfaces" is activated. You can activate the ethernet interface on a running system with the command:
:{| class="wikitable"
|<code>''ifconfig eth0 up''</code>
|}
:'''Remark:''' To work with a nfs-rootfilesystem you have to disable the line "allow-hotplug eth0" in the file "/etc/network/interfaces". Maybe the system was prepared for this method for development and nobody did change it back.
=== How to set a Linux environment variable? ===
This example shows you how to configure the system to use a proxy-server with a environment variable.
:{| class="wikitable"
|<code>''export http_proxy=http://192.168.xxx.xxx:xxxx</code>
|}
=== How to schedule jobs to run periodically at certain times or dates? ===
You can use the cron daemon and/or anacron. To use anacron you have to copy or link your program or script into one of the the following folders:
:{| class="wikitable"
|<code>/etc/cron.hourly</code>
|-
|<code>/etc/cron.daily</code>
|-
|<code>/etc/cron.weekly</code>
|-
|<code>/etc/cron.monthly</code>
|}
For further information have a look at the general linux documentation.
== Linux virtual machine for development ==
== Linux virtual machine for development ==
{{DebianVM Development}}
{{DebianVM Development}}

Revision as of 11:49, 22 March 2016

Linux virtual machine for development

Introduction

For cross developing of applications we provide virtual machines with preinstalled toolchains. Choose the virtual machine which fits to your DHCOM target (Debian 8 on target -> Debian 8 virtual machine). Debian 8 does include support for architecture armhf and armel (Debian 6 only armel). By default Debian 8 is configured for armhf. The sections Code Examples for Userspace-Applications to Access SPI, I2C, GPIOs, and more and Booting via NFS apply for Debian 6 and Debian 8.

Debian 9 "Stretch" VM image (for VMware and VirtualBox)

Get the virtual machine

Remark: For security reasons, you must set your own password when starting the virtual machine for the first time:
  1. Enter default user devel password (devel)
  2. Enter default user devel password again (devel)
  3. Enter your own user devel password
  4. Enter your own user devel password again
Version: File: Changes:
v2.1.Vx Debian Stretch v2.1.Vx.zip - Add Docker
- Python updated to version 3.6.9
- Add ARMv7 Cross-Compiler gcc v10.2
- Enable Copy & Paste and Drag & Drop for files
v2.0.Vx Debian Stretch v2.0.Vx.zip - First release version of Debian 9 VM

Installed Toolchains

  • Used for building the Linux Kernel for our ARMv7 DHCOM devices.
  • ARM GCC 10.2 (available since v2.1.Vx)
armhf: CROSS_COMPILE=/opt/gcc-arm-10.2-2020.11-x86_64-arm-none-linux-gnueabihf/bin/arm-none-linux-gnueabihf-
  • ARM GCC 8.3
armhf: CROSS_COMPILE=/opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/arm-linux-gnueabihf-
  • Linaro GCC 7.4
armhf: CROSS_COMPILE=/opt/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-
  • Linaro GCC 6.3
armhf: CROSS_COMPILE=/opt/gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-
  • Linaro GCC 4.9
armhf: CROSS_COMPILE=/opt/gcc-linaro-4.9-2014.11-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-
  • Used for building the Linux Kernel for our ARMv5 DHCOM devices.
  • CodeSourcery GCC 4.5
armel: CROSS_COMPILE=/opt/CodeSourcery-2011.03-41/bin/arm-none-linux-gnueabi-

Yocto Builds

Note (only concerning v2.0.Vx): If you are going to set up any DH electronics Yocto project by using the repo tool, you need to install Python version 3.6 or later.

This versions are not provided by official Debian Stretch package repositories. To manually install Python 3.6.9 , please follow the instructions:

$: sudo apt install libsqlite3-dev
$: wget https://www.python.org/ftp/python/3.6.9/Python-3.6.9.tgz
$: tar xvf Python-3.6.9.tgz
$: cd Python-3.6.9
$: ./configure --enable-optimizations --enable-shared
$: make -j8
$: sudo make install
$: sudo /sbin/ldconfig -v

Debian 8 "Jessie" VM image (for VMware)

Get the virtual machine

Version: File: Changes:
v1.3 Debian Jessie v1.3.zip - Debian Security updates
- Compatibility VMware player 5.0
- Ready for yocto build
- Build environment for DHCOM i.MX6 Qt5.7.1 / Qt5.9.1
- Add some useful tools
v1.2 Debian Jessie v1.2.zip - Debian Security updates
- Qt Creator + Support for imx6 modules + Demos
- Update elbe to v1.0
- Add some tools / editors
v1.1 Debian Jessie v1.1.zip - Compatibility VMware player 6.0
v1.0 Debian Jessie v1.0.zip - New Debian 8 VM

Installed Toolchains

  • Used for building the Linux Kernel for our ARMv7 DHCOM devices.
  • Debian Multiarch Cross Toolchain GCC 4.9
armhf: CROSS_COMPILE=arm-linux-gnueabihf-
The Cross Toolchains is preinstalled. They should be used for cross development of native Linux applications. They are downloaded and installed with the Debian Package Manager.
Install directory is /usr/bin/. Please have a look at the preconfigured Examples for cross development using the Eclipse IDE.
  • Linaro GCC 4.9
armhf: CROSS_COMPILE=/opt/gcc-linaro-4.9-2014.11-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-
  • Used for building the Linux Kernel for our ARMv5 DHCOM devices.
  • Debian Multiarch Cross Toolchain
armel: CROSS_COMPILE=arm-linux-gnueabi-
The Cross Toolchains is preinstalled. They should be used for cross development of native Linux applications. They are downloaded and installed with the Debian Package Manager.
Install directory is /usr/bin/. Please have a look at the preconfigured Examples for cross development using the Eclipse IDE.
  • CodeSourcery GCC 4.5
armel: CROSS_COMPILE=/opt/CodeSourcery-2011.03-41/bin/arm-none-linux-gnueabi-

Qt5 Development

Qt5.5.1 prebuilt and preinstalled

We provide the prebuilt Qt5.5.1 libraries including WebEngine (only QtQuick) and WebKit in /work/qt5/sysroot/. This directory contains a Debian 8 based rootfilesystem which is prepared for DHCOM i.MX6, the matching sysroot (*-dev packages), and the Qt5.5.1 libraries installed.

Qt5.7.1

We support the latest Qt5.7.1 on our DHCOM i.MX6 and DHCOM am335x. Please download and install the qmake-sysroot-mx6-crossarmhf_5.7.1-1.0 or qmake-sysroot-am33-crossarmhf_5.7.1-1.0 package to the DebianVM:

  1. open a terminal
  2. # for i.MX6: wget https://dl.dropboxusercontent.com/u/19433555/DHCOM/imx6/qmake-sysroot-mx6-crossarmhf_5.7.1-1.0_amd64.deb
  3. # for AM335x: wget https://dl.dropboxusercontent.com/u/19433555/DHCOM/am335x/qmake-sysroot-am33-crossarmhf_5.7.1-1.0_amd64.deb
  4. install the package
  5. # sudo dpkg -i qmake-sysroot-mx6-crossarmhf_5.7.1-1.0_amd64.deb
  6. now the sysroot and qmake is ready to use
  7. path to qmake is /work/qt5_mx6_armhf/sysroot/usr/local/qt5.7.1/bin/qmake

Build a Qt5 Application via console

  1. open a terminal
  2. navigate to your Qt5 sources
  3. # /work/qt5/sysroot/usr/local/qt5.5.1/bin/qmake your_own_app.pro
  4. # make

Qt Creator

  1. Start Qt Creator IDE
  2. Open demo project TwoLED: /work/qt5_Demos/TwoLED
  3. There you can find the configurations for your own project.

Debian 6 "Squeeze" VM image (for VMware)

Get the virtual machine

Version: File: Changes:
v1.5 Debian Squeeze v1.5pw.zip - Update VMware Tools
- DH UBI-Tools
- Language: English
- System updates
v1.4 Debian Squeeze v1.4pw.zip - ELBE v0.3.1
- ELDK 4.2
- Qt Creator 2.6.1 + Qt target libs 4.7.2
- System updates
v1.3 Debian Squeeze v1.3.zipx - Mono 2.10
- mtd-utils
- System updates
v1.2 Debian Squeeze v1.2.zipx - Emdebian Toolchain gcc 4.3 / g++ 4.3 (arm-linux-gnueabi-...)
- TortoiseHg + TortoiseHg for Nautilus
- Add Plugin "REST Client" in Iceweasel
v1.1 Debian Squeeze v1.1.zipx - Update Eclipse Indigo with CDT 8.0
- Add demo project "crosshelloworld"
v1.0 Debian Squeeze.zipx - First Release
- CodeSourcery Toolchain (arm-none-linux-gnueabi-...)
- Eclipse Helios & Indigo

Installed Toolchains

  • Used for building the Linux Kernel for our ARMv5 DHCOM devices.
  • Debian Multiarch Cross Toolchain GCC 4.3
armel: CROSS_COMPILE=arm-linux-gnueabi-
The Cross Toolchains is preinstalled. They should be used for cross development of native Linux applications. They are downloaded and installed with the Debian Package Manager.
Install directory is /usr/bin/. Please have a look at the preconfigured Examples for cross development using the Eclipse IDE.
  • CodeSourcery GCC 4.5
armel: CROSS_COMPILE=/opt/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-linux-gnueabi-

Setting up a Eclipse Cross Executable Project:

  • Use Eclipse Indigo (version 3.7.1) for your project.
  • Create a new C++ Project and choose as Executable Project type Cross-Compile Project and as Toolchains Cross GCC
  • Click the Button "Next" and specify under Tool command path the Toolchain path.
  • CodeSourcery:
Folder "/opt/CodeSourcery/Sourcery_G++_Lite/bin"
Prefix type "arm-none-linux-gnueabi-"
  • Emdebian Toolchain:
Folder "/usr/bin"
Prefix type "arm-linux-gnueabi-"

Use Virtualbox instead of VMware Player/Workstation

VMware Maschine mit VirtualBox starten (German)

Booting via TFTP/NFS

Prepare the virtual machine

  1. Setup nfs-kernel-server
    • Install thf nfs server: $ sudo apt-get install nfs-kernel-server
    • Create a nfsservice directory: $ mkdir /work/nfsroot
    • Place the root file system in the folder $ cd /work/nfsroot; sudo tar xf jessie....tar.gz
    • Remove network config from rootfs $ rm /work/nfsroot/etc/systemd/network/wired-dhcp.network
    • Check whether the line below is part of the /etc/exports file
    • /work/nfsroot X.X.X.0/255.255.255.0(rw,no_root_squash,no_subtree_check,insecure)
      • The X must be substituted by our network settings
    • Restart the nfs-server with 4 /etc/init.d/nfs-kernel-server restart
  2. Setup tftp-hpa server
    • Install a tftp server : $ sudo apt-get install tftpd-hpa
    • Create a tftp service directory: $ mkdir /work/tftp
    • Edit config: $ sudo vi /etc/default/tftpd-hpa
      • Take care that TFTP_DIRECTORY points to your tftp service directory, for example '/work/tftp'
    • Copy Kernel and DeviceTree into the tftp service directory
    • Restart the tftp-server with $ /etc/init.d/tftp-hpa restart

Setup the DHCOM Module for TFTP/NFS Boot

This example works with static IP addresses and is tested with DHCOM i.MX6 U-Boot 2015.10 and Kernle 4.4.38. It is possible to work with DHCP, too. For further information see https://www.kernel.org/doc/Documentation/filesystems/nfs/nfsroot.txt

  • Enter U-Boot console by pressing DEL/BACKSPACE on a RS232 terminal while switching on the power supply of the target
  • Set IP addresses
# env set serverip 192.168.178.90
# env set ipaddr 192.168.178.91
  • bootargs for nfs root (up to Debian Jessie)
# env set rootfs 'root=/dev/nfs nfsroot=192.168.178.90:/work/nfsroot/ ip=192.168.178.91:192.168.178.90::255.255.255.0:dhcom:eth0:none'
  • bootargs for nfs root (since Debian Stretch)
# env set rootfs 'root=/dev/nfs nfsroot=192.168.178.90:/work/nfsroot/,nfsvers=3 ip=192.168.178.91:192.168.178.90::255.255.255.0:dhcom:eth0:none'
  • load Linux kernel and devicetree with tftp (change filename and path to match you setup)
# tftp ${loadaddr} zImage
# tftp ${fdt_addr} dtbs/imx6dl-dhcom3B-pdk2.dtb
  • set bootargs and boot
# run linuxargs
# bootz ${loadaddr} - ${fdt_addr}
  • optional: save it to be permanent
# env set bootcmd 'tftp ${loadaddr} zImage; tftp ${fdt_addr} dtbs/imx6dl-dhcom3B-pdk2.dtb; run linuxargs; bootz ${loadaddr} - ${fdt_addr}
# env save

Code Examples for Userspace-Applications to Access SPI, I2C, GPIOs, and more

  • The following code samples are designed to get you started quickly with the device interfaces to SPI, I2C, GPIOs and more in Linux userspace applications.
  • Within Eclipse you can Import the provided projects:
  1. Execute ">File>Import ..."
  2. Navigate to ">General>Existing Projects into Workspace" within the import dialog
  3. Follow the dialog until you have finished.

Download Code Examples SPI, I2C, GPIOs and more

Included Demos:

  • SPI
  • I2C
  • GPIO
  • RTC
  • UART
  • Watchdog
  • ADC (only for i.MX25)

Download C++ HAL class library for SPI, I2C, GPIO, UART and physical address space access

Building your own Kernel

Sources for the AM35x Linux Kernel v3.2.12

How to build a kernel

Get sources from Github and build the linux kernel using 5 threads and a build directory

1. Start a terminal on Linux
2. # git clone https://github.com/dh-electronics/linux-am35x.git
3. # mkdir build
4. # cd linux-am35x
5. # ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- make O=../build/ dhcm3517_defconfig
6. # ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- make -j5 O=../build/ uImage
  • Your new uImage file is available in ../build/arch/arm/boot

Remark:

  • On linux-am35x.git we use the git branch "master".

Sources older than April 2014

Sources for the AM35 Kernel based on 3.2.12 Mainline

  • latest changes: 2013-12-05 -> 2014-04-23
- Add DH touch support
- Add Boardfile to use LCD-Interface with GPIO-functionality (DHpicoITX)
  • latest changes: 2013-06-17 -> 2013-12-05
- USB-OTG: Fixed mass storage operation (depends on latest kernel configuration, too)
- BUG-Fix: Set rtc default values to a valid status
  • latest changes: 2013-05-22 -> 2013-06-17
- (Minor) Customizations for 1 GByte Spansion NAND-Flash
  • latest changes: 2013-04-04 -> 2013-05-22
- (Minor) BUG-Fix: Initialization of DHCOM GPIO_E pad fixed
  • latest changes: 2012-12-14 -> 2013-04-04
- SPI BUG-Fix: Disabled "Turbo-Mode" to avoid wrong additional byte-reads (If used: Kernel-Update recommended)
- I2C BUG-Fix: AM35x Errata 1.1.26 (If used: Kernel-Update recommended)
- enabled ETH_VIO_GPIO (necessary for DHCOM pico-ITX) to supply ethernet transformer
- FF UART support added
- DHCOM (CAM) GPIO Padconfigurations changed to GPIO-Mode on default.
- removed USB-OTG-POWER-GPIO (Use kernel-argument [u-boot env bootargs] 'dheva01_version=200' to activate it again)
- backlight PWM default is now 205 (80%)
  • 2012-11-08 -> 2012-12-14
- /dev/spidev1.1 is now /dev/spidev1.0
- watchdog driver support for magic close added
  • 2012-08-29 -> 2012-11-08
- added audio support
- changed partitionsize of linux-kernel

How to build a kernel

1. Start a terminal on Linux
2. Copy the above mentioned source files (linux-3.x.y.tar.bz2, .config, *.patch) into our work_path
3. # cd work_path
4. # tar xfjv linux-3.2.12.tar.bz2
5. # cd work_path/linux-3.2.12
6. # patch -p1 < ../dh-linux-am35x_xxxxxxxx.patch
7. # cp ../dh-linux-am35x_xxxxxxxx.config .config'
8. # ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- make uImage
  • Your new uImage file is available in work_path/linux-3.2.12/arch/arm/boot

Update the kernel with U-Boot

The linux kernel will be updated by the U-Boot flash update.
1. Copy the uImage and uImage.env file onto a microSD card with a FAT file system (you can use the 1st partition on the microSD card)
2. Insert the microSD card and start the system
3. Go to the U-Boot console by pressing BACKSPACE/DEL on a RS232 terminal (during startup)
4. update linux

Debian Rootfilesystem

Available Rootfilesystems

Please have a look at the AM35x Downloads section.

External Documentation

Login

Debian GNU/Linux 6.0 dhcom ttyO0

dhcom login: root
Password: foo

Shutdown

# shutdown -h now

Calibrating the touchscreen

# ts_calibrate
  • Check the enviroment variable "TSLIB_TSDEVICE=/dev/input/event0" with printenv if an error occurs.

Running Qt Demos

# cd /usr/qt/demos/demoname
# ./demoname -qws
  • For the Qt-Browser change demoname to browser
  • If the touchscreen does not work please check the enviroment variable "QWS_MOUSE_PROTO=Tslib:/dev/input/event0" with printenv.

Run Qt demos with powerVR (3d acceleration) support

# cd /usr/qt/demos/embedded/demoname
# ./demoname -qws

Run Qt demos with usb mouse input device

# cd /usr/qt/demos/demoname
# export QWS_MOUSE_PROTO=Auto:/dev/input/mice
# ./demoname -qws

Remark: Just remember that you need to run the Qt demos with the options -qws. Omitting -qws results in the app waiting to connect to the QWS Server, which is not running.

How to create a microSD-card with a rootfilesystem on it

1. Format a microSD card like following (in linux e.g. gparted, palimpsest) with Master Boot Record partition scheme

P1 FAT (Primary partition: 100MB)
P2 ext3 (Primary partition: Residual space)

2. Untar the root file system to the ext3 partition of the microSD card (Don't copy the tar archive directly to the microSD card)

Start the Console on Linux
# su
# chmod 755 /path/of/the/microSD_card
# cd /path/of/the/microSD_card
# tar xfjv path/to/RootFS/Name_of_RootFS_file.tar.bz2

Remark: If you got a *.tar.gz file so type tar xfzv ... to extract the rootfilesystem.

Kernel Userspace Interfaces to Access Hardware

Serial (UART) Interfaces

DHCOM (FF) UART 1 /dev/ttyO0
DHCOM (BT) UART 2 /dev/ttyO2
DHCOM (STD) UART 3 /dev/ttyO1

I2C Interfaces

DHCOM I2C 1 /dev/i2c-3
DHCOM I2C 2 /dev/i2c-2
On Module Devices /dev/i2c-1

SPI Interfaces

DHCOM SPI 1 /dev/spidev1.0
DHCOM SPI 2 /dev/spidev2.0

Control the display brightness

echo <value> >/sys/class/backlight/omap-pwm-backlight/brightness
value range: 0..255

Control GPIOs

DHCOM Name: alt. DHCOM Name: SO-DIMM Pin# Linux <GPIO#>
GPIO A 154 116
GPIO B 156 117
GPIO C 162 118
GPIO D 163 119
GPIO E 164 125
GPIO F 165 140
GPIO G 167 141
GPIO H 173 155
GPIO I 175 152
CIF HSYNC GPIO J 74 96
CIF PCLK GPIO K 72 94
CIF MCLK GPIO L 70 58
CIF VSYNC GPIO M 68 97
CIF D9 GPIO N 66 98
CIF D8 GPIO O 64 95
CIF D7 GPIO P 62 106
CIF D6 GPIO Q 60 105
CIF D5 GPIO R 58 104
CIF D4 GPIO S 56 103
CIF D3 GPIO T 54 102
CIF D2 GPIO U 52 101
CIF D1 GPIO V 50 100
CIF D0 GPIO W 48 99
Remark: Depending on your board configuration some of the additional gpios shared with the camera interface are not available on your system.
Export
echo <GPIO#> >/sys/class/gpio/export
Remark: Have a look into /sys/class/gpio/ for already configured gpios.
Set direction
echo in >/sys/class/gpio/gpio<GPIO#>/direction
echo out >/sys/class/gpio/gpio<GPIO#>/direction
Set state
echo 0 >/sys/class/gpio/gpio<GPIO#>/value
echo 1 >/sys/class/gpio/gpio<GPIO#>/value

Initialize and Test CAN Interface

Initialize:
ip link set can0 up type can bitrate 500000
Send test message via cansend (part of can-utils):
cansend can0 100#11.2233.44556677.88
Receive can messages (part of can-utils):
candump can0
Get can-utils:

Testing display / framebuffer

In most common cases the "Display Bits" should be "8"
With "fb" you select the number of the framebuffer device (e.g. /dev/fb0)
fb_1Colorfill Fills the framebuffer device with a given RGB color
fb_1Colorfill [fb (0..31)] [Display Bits (1..8)] [Red value (0..255)] [Green value (0..255)] [Blue value (0..255)]
fb_fb2BMP Copies the framebuffer device data into a 24Bit BMP-File
fb_fb2BMP [fb (0..31)] [24-Bit BMP-File]
fb_LoadBMP Loads a 24Bit BMP-file into a 32Bit framebuffer device
fb_LoadBMP [fb (0..31)] [24-Bit BMP-File] [Display Bits (1..8)] [Transparency (0..100)]
Get DH farmebuffer tools:

Additional Information