[hemmerling] Linux 8/8 - Useful Commands & Tricks

Machine-specific Programming on Linux

uio Framework

  • The “uio framework” is suitable to avoid Linux license problems for Linux applications with simple, but machines-specific i/o - You may access any memory-mapped hardware by user applications, but you must not provide your source code for any drivers, as there is just a standard Linux mainline driver “mmap” :-).
  • You may not access legacy and classical PC hardware ( e.g. printer port,.. ) which is connected to the special Intel i/o hardware ports.
  • There is a special patch available at Git repository of DENX Software Engineering for Linux kernel 3.8 to allow the necessary device tree binding by command line commands - this was “missing link” before. It is expected that this option becomes a standard feature of Linux Kernel 3.10, hopefully :-).

Select() / Poll() Framework

  • “include <sys/select.h>”.
  • Poll() is a variation of Select().
  • Suitable to work with the “uio framework” and it's “mmap” function, to provide interrupt-driven data transfer with any memory-mapped hardware, without the need for thread programming, and it's overhead.
  • Loop operation:
    1. Select() expects an array of file selectors as input.
    2. It will got to sleep.
    3. In case of a change of the contents linked with the file descriptors, Select() wakes up again.
    4. The application which uses Select() has to explore and find out, which file descriptor contents changed.
    5. The application handels the file descriptor ( read or writes data,.. ).
    6. End-of-loop.

Gpio on Lemonboard

  • On the Lemonboard with Ubuntu Linux / Linux, show Gpio Pins:
cat /sys/kernel/debug/gpio
  • Set Gpioi LED Value:
echo "1" > /sys/class/gpio/gpio203/value
echo "0" > /sys/class/gpio/gpio2/value
  • Additionally, there is a small application “gpioin”. Config the GPIO CSI0_DAT12 to INPUT:
echo in > /sys/class/gpio/gpio158/direction
echo 1 > /sys/class/gpio/gpio158/active_low
echo falling > /sys/class/gpio/gpio128/edge
./gpioin /sys/class/gpio/gpio158/value

The Effect

  • You may now control hardware, even interrupt-driven hardware, from your Linux applications written in high-level language, e.g. C/C++, Python, Perl, Java, running on a standard Linux Kernel 3.10 ( or patched Linux Kernel 3.8 ).
  • For comparison,, with Python and “Raspberry Pi” platform, you need a special Python library...

LInux Commands for Embedded Linux Boards

  • “cat /proc/cpuinfo”.
  • “ls - l /proc/cpuinfo”.
  • “file hello-world”.
  • “printenv”.
  • For successful use of aa remote NFS filesystem as “root” filesystem, the Linux server option “no_root_squash” is necessary. By this, “root” is not handled as unprivileged user, but the server believes that a true “root” wants to access.
  • For cross-compilation, add a variable ( e.g. $Cross_compile ) to your makefiles, and define $Cross_compile as environment variable on your host. So that you may use the same makefile to compile both on host and target, but just use a environment variable to create the name of the cross-compiler from the name of the native compiler. So no if-then-else with different compiler calls, but the name of the called compiler is modified to meet the requirements of host and target compilers.

Some other useful Linux Commands

Forgotten root Password

"su" vs. "sudo"

Some other Tips & Tricks

Appropriate OpenDirectory Directory Pages

en/linux08.html.txt · Last modified: 2017/06/26 06:35 (external edit) · []
Recent changes RSS feed Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki