COM iMX6 Linux: Difference between revisions
Ageisreiter (talk | contribs) |
|||
Line 125: | Line 125: | ||
=== I2C Interfaces === | === I2C Interfaces === | ||
dhcom3B = Hardware revision 300 | |||
:{| class="wikitable" style="width: 400px" | |||
||DHCOM I2C 1||<code>/dev/i2c-1</code> | |||
|- | |||
||DHCOM I2C 2 ||<code>/dev/i2c-0</code> | |||
|- | |||
||On Module Devices ||<code>/dev/i2c-2</code> | |||
|} | |||
old: dhcom2B = Hardware revision 200 | |||
:{| class="wikitable" style="width: 400px" | :{| class="wikitable" style="width: 400px" | ||
||DHCOM I2C 1||<code>/dev/i2c-0</code> | ||DHCOM I2C 1||<code>/dev/i2c-0</code> |
Revision as of 17:27, 25 November 2015
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:
ifconfig eth0 up
- 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.
export http_proxy=http://192.168.xxx.xxx:xxxx
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:
/etc/cron.hourly
/etc/cron.daily
/etc/cron.weekly
/etc/cron.monthly
For further information have a look at the general linux documentation.
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
- Get VMware player or VirtualBox
- Debian 9 "Stretch" VMware Image
Default password for devel user: devel
Default password for root user: root
- Remark: For security reasons, you must set your own password when starting the virtual machine for the first time:
- Enter default user devel password (devel)
- Enter default user devel password again (devel)
- Enter your own user devel password
- 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
- Get the VMware player
- Debian 8 "Jessie" VMware Image
Important info (Feb/2018): Don't update the system, because it will brake the cross compiler. If you are asked to upgrade, say NO!
Password for devel user: devel
Password for root user: root
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:
- open a terminal
- # for i.MX6: wget https://dl.dropboxusercontent.com/u/19433555/DHCOM/imx6/qmake-sysroot-mx6-crossarmhf_5.7.1-1.0_amd64.deb
- # for AM335x: wget https://dl.dropboxusercontent.com/u/19433555/DHCOM/am335x/qmake-sysroot-am33-crossarmhf_5.7.1-1.0_amd64.deb
- install the package
- # sudo dpkg -i qmake-sysroot-mx6-crossarmhf_5.7.1-1.0_amd64.deb
- now the sysroot and qmake is ready to use
- path to qmake is /work/qt5_mx6_armhf/sysroot/usr/local/qt5.7.1/bin/qmake
Build a Qt5 Application via console
- open a terminal
- navigate to your Qt5 sources
- # /work/qt5/sysroot/usr/local/qt5.5.1/bin/qmake your_own_app.pro
- # make
Qt Creator
- Start Qt Creator IDE
- Open demo project TwoLED: /work/qt5_Demos/TwoLED
- There you can find the configurations for your own project.
Debian 6 "Squeeze" VM image (for VMware)
Get the virtual machine
- Get the VMware player
- Debian Squeeze VMware Image (PW: dhelectronics)
Password for devel user: devel
Password for root user: root
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
- 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
- Install thf nfs server:
- 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
- Install a tftp server :
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:
- Execute ">File>Import ..."
- Navigate to ">General>Existing Projects into Workspace" within the import dialog
- 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
- For further documentation have a look at http://www.kernel.org/doc/Documentation/.
Building your own Kernel
Sources for the i.MX6 Kernel:
How to build a kernel:
1. Start the Console on Linux |
2. git clone https://github.com/dh-electronics/linux-imx6qdl.git |
3. cd linux-imx6qdl |
4. ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- make imx6_dhcom_defconfig |
5. ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- make menuconfig (optional: If you want to add/remove Kernel features) |
6. ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- make dtbs |
7. ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- make zImage |
- The built imx6xx-dheva01.dtb device tree files will you find in arch/arm/boot/dts
- The built zImage kernel file will you find in arch/arm/boot
Update the kernel with U-Boot
Please refere to the DHCOM Update Mechanism for i.MX6.
Update the kernel in running Linux
1. Copy the kernel zImage file to the path /boot |
Debian Rootfilesystem
Available Rootfilesystems
Please have a look at the iMX6 Downloads section.
Login
Debian GNU/Linux 8 dhcom ttymxc0 dhcom login: root |
Shutdown
# shutdown -h now |
Calibrating the touchscreen (only on Debian 6.0)
# ts_calibrate |
- Check the enviroment variable "TSLIB_TSDEVICE=/dev/input/event0" with printenv if an error occurs.
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 ext3, name="boot" (Primary partition: 100MiB) |
2. Untar the root file system to the "rootfs" partition of the microSD card (Don't copy the tar archive directly to the microSD card)
Start the Console on Linux |
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/ttymxc0
DHCOM (BT) UART 2 /dev/ttymxc4
DHCOM (STD) UART 3 /dev/ttymxc3
I2C Interfaces
dhcom3B = Hardware revision 300
DHCOM I2C 1 /dev/i2c-1
DHCOM I2C 2 /dev/i2c-0
On Module Devices /dev/i2c-2
old: dhcom2B = Hardware revision 200
DHCOM I2C 1 /dev/i2c-0
DHCOM I2C 2 /dev/i2c-1
On Module Devices /dev/i2c-2
SPI Interfaces
DHCOM SPI 1 /dev/spidev0.2
DHCOM SPI 2 /dev/spidev1.0
- Remark: DHCOM SPI1 interface doesn‘t work with DHCOM Premium Developer Kit (HD00013).
- Reason: At DHCOM Premium Developer Kit SPI 1 isn‘t connected, because otherwise i.MX6 doesn‘t boot with the current schematic.
MMC/SD/eMMC Interfaces
DHCOM SD-Interface /dev/mmcblk0pX
on module µSD Card /dev/mmcblk1pX
on module eMMC /dev/mmcblk2pX
- 'X' has to be replaced with the partition number
Control the display brightness
- Coming soon
Control GPIOs
DHCOM Name: alt. DHCOM Name: SO-DIMM Pin# Linux <GPIO#> GPIO A 154 2 GPIO B 156 4 GPIO C 162 5 GPIO D 163 163 GPIO E 164 101 GPIO F 165 116 GPIO G 167 91 GPIO H 173 103 GPIO I 175 104 CIF HSYNC GPIO J 74 174 CIF PCLK GPIO K 72 175 CIF MCLK GPIO L 70 105 CIF VSYNC GPIO M 68 192 CIF D9 GPIO N 66 193 CIF D8 GPIO O 64 149 CIF D7 GPIO P 62 205 CIF D6 GPIO Q 60 18 CIF D5 GPIO R 58 16 CIF D4 GPIO S 56 17 CIF D3 GPIO T 54 19 CIF D2 GPIO U 52 20 CIF D1 GPIO V 50 146 CIF D0 GPIO W 48 147
- 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.
- Remark: Have a look into
- 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:
Parallel Address- / Databus
- To use the 16-bit address / databus from Linux userspace you can use the UIO driver interface. To enable and configure the interface it is necessary to setup the i.MX6 WEIM controller with the device tree. See the documentation of the device tree bindings of weim here.
- Here is an example code which demonstrates how to do enable and configure the WEIM interface (parallel address- / databus):
&weim { pinctrl-names = "default"; pinctrl-0 = <&pinctrl_weim_dhcom_1 &pinctrl_weim_cs0_1>; #address-cells = <2>; #size-cells = <1>; /* it is necessary to setup 2x 64MB otherwise setting gpr fails */ ranges = <0 0 0x08000000 0x04000000>, // Chipselect A <1 0 0x0c000000 0x04000000>; // Chipselect B fsl,weim-cs-gpr = <&gpr>; status = "okay"; /* use CS 0 */ uio_pdrv_genirq@0,0 { compatible = "generic-uio"; reg = <0 0x00000000 0x02000000>, <0 0x02000000 0x02000000>; reg-names = "mem_cs0_first_map", "mem_cs0_second_map"; #address-cells = <1>; #size-cells = <1>; fsl,weim-cs-timing = <0x00610089 0x00001002 0x0F011061 0x00000000 0x0F068A31 0x00000000>; }; };
- We have already written some demo code at /arch/arm/boot/dts/imx6qdl-dhcom-weim.dtsi. It is easy to enable in the matching device-tree file:
- // #include "imx6qdl-dhcom-weim.dtsi" // enables WEIM example config with UIO-Driver, + #include "imx6qdl-dhcom-weim.dtsi" // enables WEIM example config with UIO-Driver
- To use the generic uio driver it has to be enabled in the kernel configuration (
make menuconfig
)- Device Drivers -> Userspace I/O Drivers -> Userspace I/O platform driver with generic IRQ handling
- The device-tree of_id of the uio driver has to be set via kernel command line
- Add "optargs='uio_pdrv_genirq.of_id=generic-uio'" to uLinuxEnv.txt
- Example for a UIO userspace driver:
- uio_access.cpp
- for further information have a look at the paper Userspace I/O drivers in a realtime context
Configure your own display
- To configure your own display you have to do the following steps:
- 1. Type in the display values into the device tree file
/arch/arm/boot/dts/imx6qdl-dheva01.dtsi
- Where in the file?
Parallel display: display@di0
LVDS display: &ldb
Remarks: If you don't want to use both interfaces comment the unwanted out! The frame buffer resolution depends on the higher display resolution of both displays
- How?
- Here is an example:
display-timings { DataImage_7inch_FG0700G3DSSW { clock-frequency = <33260000>; hactive = <800>; vactive = <480>; hback-porch = <86>; hfront-porch = <42>; vback-porch = <33>; vfront-porch = <10>; hsync-len = <128>; vsync-len = <2>; hsync-active = <0>; vsync-active = <0>; de-active = <1>; pixelclk-active = <1>; }; };
- 2. Build the device tree dtb files
ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- make dtbs
- 3. Copy the dtb files onto your boot partition
/dtbs
(SD, µSD or eMMC) - The built
imx6xx-dheva01.dtb
device tree files will you find inarch/arm/boot/dts