Monthly Archives: September 2014

Real Time Linux (PREEMPT_RT / Xenomai)

Real-Time Linux Wiki
OSADL – Open Source Automation Development Lab eG

Wikipedia

Xenomai (en)
RTAI (Real Time Application Interface) (en)
RTAI (Real Time Application Interface) (de)
RTLinux (de)

Tutorial

Getting real (time) about embedded GNU/Linux
Realtime Linux für Debian
Introducing Xenomai 3
How fast is fast enough? Choosing between Xenomai and Linux for real-time applications (PDF)

Raspberry Pi

Raspberry Pi 4B: Real-Time System using Preempt-RT (kernel 4.19.y)
Raspberry Pi: Real Time System – Xenomai Patching Tutorial for Kernel 4.14.y
Real-Time Linux on the Raspberry Pi
Echtzeit mit dem Raspberry Pi und Linux PREEMPT_RT
github.com/claudioscordino/rpi3-xenomai

Eclipse Embedded for ARM

see blog.bachi.net mbed.org
see blog.bachi.net Regular Expression

  • Eclipse Neon (4.6)
  • Eclipse Mars (4.5)
  • Eclipse Luna (4.4)
  • Eclipse Kepler (4.3)
  • Eclipse Juno (4.2)

How to install the GNU ARM Eclipse plug-ins?
How to install the Windows Build Tools?
GNU ARM Eclipse plug-ins: Received fatal alert: handshake_failure

livius dot net – IT Design & Consulting – Creativity without borders

cross_make / cross_gcc not set

Invalid project path: Include path not found

Remove:
<entry kind="includePath" name="/${ProjName}/#undef __ARM_FP">
    <flag value="BUILTIN|READONLY|VALUE_WORKSPACE_PATH"/>
</entry>
<entry kind="includePath" name="/${ProjName}/#undef __ARM_FEATURE_FMA">
    <flag value="BUILTIN|READONLY|VALUE_WORKSPACE_PATH"/>
</entry>
<entry kind="includePath" name="/${ProjName}/#undef __ARM_NEON__">
    <flag value="BUILTIN|READONLY|VALUE_WORKSPACE_PATH"/>
</entry>
<entry kind="includePath" name="/${ProjName}/#undef __ARM_NEON">
    <flag value="BUILTIN|READONLY|VALUE_WORKSPACE_PATH"/>
</entry>

Add:
<language id="org.eclipse.cdt.core.gcc">
    <entry kind="includePath" name="C:/Program Files (x86)/GNU Tools ARM Embedded/6 2017-q1-update/lib/gcc/arm-none-eabi/6.3.1/include">
        <flag value="BUILTIN|READONLY"/>
    </entry>
    <entry kind="includePath" name="C:/Program Files (x86)/GNU Tools ARM Embedded/6 2017-q1-update/lib/gcc/arm-none-eabi/6.3.1/include-fixed">
        <flag value="BUILTIN|READONLY"/>
    </entry>
    <entry kind="includePath" name="C:/Program Files (x86)/GNU Tools ARM Embedded/6 2017-q1-update/arm-none-eabi/include">
        <flag value="BUILTIN|READONLY"/>
    </entry>
</language>
    
<language id="org.eclipse.cdt.core.g++">
    <entry kind="includePath" name="C:/Program Files (x86)/GNU Tools ARM Embedded/6 2017-q1-update/arm-none-eabi/include/c++/6.3.1">
        <flag value="BUILTIN|READONLY"/>
    </entry>
    <entry kind="includePath" name="C:/Program Files (x86)/GNU Tools ARM Embedded/6 2017-q1-update/arm-none-eabi/include/c++/6.3.1/arm-none-eabi/thumb/v8-m.main">
        <flag value="BUILTIN|READONLY"/>
    </entry>
    <entry kind="includePath" name="C:/Program Files (x86)/GNU Tools ARM Embedded/6 2017-q1-update/arm-none-eabi/include/c++/6.3.1/backward">
        <flag value="BUILTIN|READONLY"/>
    </entry>
    <entry kind="includePath" name="C:/Program Files (x86)/GNU Tools ARM Embedded/6 2017-q1-update/lib/gcc/arm-none-eabi/6.3.1/include">
        <flag value="BUILTIN|READONLY"/>
    </entry>
    <entry kind="includePath" name="C:/Program Files (x86)/GNU Tools ARM Embedded/6 2017-q1-update/lib/gcc/arm-none-eabi/6.3.1/include-fixed">
        <flag value="BUILTIN|READONLY"/>
    </entry>
    <entry kind="includePath" name="C:/Program Files (x86)/GNU Tools ARM Embedded/6 2017-q1-update/arm-none-eabi/include">
        <flag value="BUILTIN|READONLY"/>
    </entry>
</language>

Standards

mbed: CMSIS-DAP
mbed: CMSIS-DAP Interface Firmware
GitHub: mbedmicro/CMSIS-DAP
Keil: CMSIS-DAP

Tutorials

Installing Eclipse for use with FreeRTOS.org
ARM-Projects by Martin THOMAS

Plugins

GNU ARM Eclipse Plug-ins with J-Link Debugging Support
GNU ARM Eclipse Plug-ins
Welcome to the EmbSysRegView Project
Eclipse Embedded Systems Register View, displays special function Registers (SFRs) while debugging

undefined reference to `__real_main'

link: ROME2_P1_A4.elf
../mbed/TARGET_NUCLEO_F446RE/TOOLCHAIN_GCC_ARM/retarget.o: In function `__wrap_main':
retarget.cpp:(.text.__wrap_main+0xa): undefined reference to `__real_main'
collect2.exe: error: ld returned 1 exit status

Solution:
add "-Wl,--gc-sections" to LD_FLAGS and LD

PThread / POSIX Thread

  • synchronization
  • threads
  • barrier point
  • pthread_init()
  • sem_init()
  • pthread_barrier_init

“For real applications there are more polished libraries such as pthreads for kernel threads or GNU Portable Threads (Pth) for user space threads.”

“The GNU Pth (GNU Portable Threads) scheduling itself is done in a cooperative way, i.e., the threads are managed by a priority- and event-based non-preemptive scheduler. The intention is that this way one can achieve better portability and run-time performance than with preemptive scheduling. The event facility allows threads to wait until various types of events occur, including pending I/O on filedescriptors, asynchronous signals, elapsed timers, pending I/O on message ports, thread and process termination, and even customized callback functions.”

Oracle Multithreaded Programming Guide
POSIX Threads Programming
POSIX thread (pthread) libraries
POSIX thread (pthread) libraries
Linux-UNIX-Programmierung – Threads
Parallele Programmierung mit Threads
Introduction to Multi-Threaded Programming, 1999
Eine Einführung in die Programmierung von Threads unter Linux
Implementing a Thread Library on Linux
GNU Pth – The GNU Portable Threads, 2006
Linux Threads Frequently Asked Questions (FAQ), 1996

Joinable and Detached Threads

Oracle Multithreaded Programming Guide: Set Detach State
Joining and Detaching Threads
Joinable and Detached Threads
Pthread create as detached

Thread (computing)
Light-weight process
Fiber (computer science)
Green threads
Thread (Informatik)
User-Thread
Native POSIX Thread Library (NPTL)

Alle Fäden in der Hand – Thread Programmierung unter Linux in C und C++ (Teil 1)
Alle Fäden in der Hand – Thread Programmierung unter Linux in C und C++ (Teil 2)

The Linux compatibility thread!

Thread-Programmierung mit Java

Oracle Multithreaded Programming Guide – Avoiding Deadlock

Map / Reduce

The one line of C code that will make your program ten times faster

Barriere

Semaphore

The Little Book of Semaphores

Monitor

Wikipedia: Monitor

Level Shifter / Pegelwandler / Spannungswandler

Watterott Level-Shifter
I2C bi-directional level shifter
Bi-Directional Logic Level Converter Hookup Guide

mikrocontroller.net

Pegelwandler
Relais mit Logik ansteuern
MOSFET-Übersicht

Raspberry_PI: GPIO zu AVR

a

4-channel I2C-safe Bi-directional Logic Level Converter – BSS138
SparkFun Logic Level Converter – Bi-Directional
Bi-Directional Logic Level Converter Hookup Guide

Adafruit

74AHCT125 – Quad Level-Shifter (3V to 5V) – 74AHCT125
8-channel Bi-directional Logic Level Converter – TXB0108

PHP5

php5-5.4.20         PHP Scripting Language
php5-bz2-5.4.20     The bz2 shared extension for php
php5-ctype-5.4.20   The ctype shared extension for php
php5-dom-5.4.20     The dom shared extension for php
php5-exif-5.4.20    The exif shared extension for php
php5-fileinfo-5.4.20 The fileinfo shared extension for php
php5-filter-5.4.20  The filter shared extension for php
php5-gd-5.4.20      The gd shared extension for php
php5-hash-5.4.20    The hash shared extension for php
php5-iconv-5.4.20   The iconv shared extension for php
php5-json-5.4.20    The json shared extension for php
php5-mbstring-5.4.20 The mbstring shared extension for php
php5-mcrypt-5.4.20  The mcrypt shared extension for php
php5-mysql-5.4.20   The mysql shared extension for php
php5-openssl-5.4.20 The openssl shared extension for php
php5-pdo-5.4.20     The pdo shared extension for php
php5-pdo_mysql-5.4.20 The pdo_mysql shared extension for php
php5-posix-5.4.20   The posix shared extension for php
php5-session-5.4.20 The session shared extension for php
php5-simplexml-5.4.20 The simplexml shared extension for php
php5-snmp-5.4.20    The snmp shared extension for php
php5-xml-5.4.20     The xml shared extension for php
php5-zlib-5.4.20    The zlib shared extension for php
extension=mysql.so
extension=zlib.so
extension=bz2.so
extension=openssl.so
extension=mbstring.so
extension=json.so
extension=mcrypt.so
extension=xml.so
extension=session.so
extension=ctype.so
extension=gd.so
extension=fileinfo.so
extension=posix.so
extension=dom.so
extension=snmp.so
extension=simplexml.so
extension=iconv.so
extension=pdo.so
extension=pdo_mysql.so
extension=filter.so
extension=intl.so
extension=exif.so
extension=apc.so
extension=hash.so

Fatal error: Call to undefined function hash()

PHP5 Extensions

PHP 5.2.6 on FreeBSD with extensions

# /usr/local/bin/php -v
PHP 5.4.20 (cli) (built: Oct 13 2013 15:38:29)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
Segmentation fault: 11 (core dumped)

# gdb /usr/local/bin/php php.core
[...]
(gdb) bt
#0  0x0000000000000000 in ?? ()
#1  0x0000000806b33b1d in __do_global_dtors_aux () from /usr/local/lib/php/20100525/hash.so
#2  0x0000000806b46e25 in _fini () from /usr/local/lib/php/20100525/hash.so
#3  0x00007fffffffe9f0 in ?? ()
#4  0x00000008007f403a in find_symdef () from /libexec/ld-elf.so.1
#5  0x00000008007f48fe in dlclose () from /libexec/ld-elf.so.1
#6  0x00000000005c522d in module_destructor ()
#7  0x00000000005ce4b2 in zend_hash_apply_deleter ()
#8  0x00000000005ce60c in zend_hash_graceful_reverse_destroy ()
#9  0x00000000005bdf20 in zend_shutdown ()
#10 0x0000000000552fd5 in php_module_shutdown ()
#11 0x000000000066307a in main ()
(gdb)

GNU binutils (ld linker, objdump, readelf, strip)

GNU Binary Utilities

Dependencies

GNU Binutils
Binary File Descriptor library (BFD)
Instruction Set Architecture (ISA)

Object File Format (executable files, object code, shared libraries, and core dumps)

Deutsch

a.out
ELF
COFF
Fat Binary
Universal Binary

English

An object file is a file containing object code, meaning relocatable format machine code that is usually not directly executable. In addition to the object code itself, object files may contain metadata used for linking or debugging, including: information to resolve symbolic cross-references between different modules, relocation information, stack unwinding information, comments, program symbols, debugging or profiling information.

Executable
Object file
a.out
ELF
COFF
Mach-O

Debugging formats

GNU Debugger
Debugging formats DWARF and STAB
DWARF
stabs

Target Selection

Target Selection

$ objdump.exe -i
$ objdump.exe -H
supported targets (object file format):
pe-x86-64
pei-x86-64
pe-bigobj-x86-64
elf64-x86-64
elf64-l1om
elf64-k1om
pe-i386
pei-i386
elf32-i386
elf32-iamcu
elf64-little
elf64-big
elf32-little
elf32-big
plugin
srec
symbolsrec
verilog
tekhex
binary
ihex

supported architectures:
i386
i386:x86-64
i386:x64-32
i8086
i386:intel
i386:x86-64:intel
i386:x64-32:intel
i386:nacl
i386:x86-64:nacl
i386:x64-32:nacl
iamcu
iamcu:intel
l1om
l1om:intel
k1om
k1om:intel
plugin


$ arm-none-eabi-objdump.exe -i
$ arm-none-eabi-objdump.exe -H
supported targets (object file format):
elf32-littlearm
elf32-bigarm
elf32-little
elf32-big
plugin
srec
symbolsrec
verilog
tekhex
binary
ihex

supported architectures:
arm
armv2
armv2a
armv3
armv3m
armv4
armv4t
armv5
armv5t
armv5te
xscale
ep9312
iwmmxt
iwmmxt2
arm_any
plugin

ld

Option Purpose
-b input-format
--format=input-format
What input format is used. You may want to use this option if you are linking files with an unusual binary format. You can also use -b to switch formats explicitly. You can list the available binary formats with objdump -i
-r
--relocatable
Generate relocatable output—i.e., generate an output file that can in turn serve as input to ld. This is often called partial linking.
This option does the same thing as -i.
-i Perform an incremental link (same as option -r).
-o output
--output=output
Use output as the name for the program produced by ld; if this option is not specified, the name a.out is used by default.
-T scriptfile
--script=scriptfile
Use scriptfile as the linker script. This script replaces ld‘s default linker script (rather than adding to it), so commandfile must specify everything necessary to describe the output file. If scriptfile does not exist in the current directory, ld looks for it in the directories specified by any preceding -L options. Multiple -T options accumulate.

Linker Script

LD
LD: Linker Scripts
Linker Scripts
Linker Scripts

Red Hat Enterprise Linux 4: Using ld, the Gnu Linker – Linker Scripts

Chapter 4. Linker Scripts
4.2. Linker Script Format
4.3. Simple Linker Script Example
4.4. Simple Linker Script Commands
4.5. Assigning Values to Symbols
4.6. SECTIONS Command
4.7. MEMORY Command
4.8. PHDRS Command
4.9. VERSION Command
4.10. Expressions in Linker Scripts
4.11. Implicit Linker Scripts

objdump – displays information about one or more object files

man objdump

Linux Objdump Command Examples (Disassemble a Binary File)

objcopy – copies the contents of an object file to another

man objcopy

Option Purpose
-I bfdname
--input-target=bfdname
Consider the source file’s object format to be bfdname, rather than attempting to deduce (herleiten/rückschliessen) it.
-O bfdname
--output-target=bfdname
Write the output file using the object format bfdname.
-B bfdarch
--binary-architecture=bfdarch
Useful when transforming a architecture-less input file into an object file. In this case the output architecture can be set to bfdarch.
--rename-section oldname=newname[,flags] Rename a section from oldname to newname, optionally changing the section’s flags to flags in the process.
This option is particularly helpful when the input format is binary, since this will always create a section called .data. If for example, you wanted instead to create a section called .rodata containing binary data you could use a command line to achieve it.
objcopy              \
-I binary            \
-O <output_format>   \
-B <architecture>    \
--rename-section .data=.rodata,alloc,load,readonly,data,contents \
<input_binary_file>  \
<output_object_file>

nm – list symbols from object file

man nm

Example Scripts

bin2elf.sh

#!/bin/sh
# Convert a raw binary image into an ELF file suitable for loading into a disassembler

cat > raw$$.ld <<EOF
SECTIONS
{
EOF

echo " . = $3;" >> raw$$.ld

cat >> raw$$.ld <<EOF
  .text : { *(.text) }
}
EOF

CROSS_PREFIX=arm-none-eabi-

${CROSS_PREFIX}ld -b binary -r -o raw$$.elf $1
${CROSS_PREFIX}objcopy  --rename-section .data=.text \
                        --set-section-flags .data=alloc,code,load raw$$.elf
${CROSS_PREFIX}ld raw$$.elf -T raw$$.ld -o $2
${CROSS_PREFIX}strip -s $2

rm -rf raw$$.elf raw$$.ld