Author Archives: te-bachi

Raspberry Pi

Rasberry Pi – An ARM GNU/Linux box for $25
Embedded Linux mit dem Raspberry Pi
Raspberry Pi: the modder’s dream machine?
RaspberryPi (Model B) SketchUp Model
RPi Verified Peripherals

raspi-config
Step01 – Bare Metal Programming in C Pt1

WiFi & DHCP

DHCP-Server auf dem Raspberry Pi einrichten
RasPi als DHCP- und DNS-Server
Raspberry PI als DHCP Server – Kleiner Eingriff, große Wirku

Mounting Holes

Mechanical Drawings
Raspberry Pi Mounting Hole Positions and Template
adafruit Mounting Holes
CASEplate Assembly – Pi-Plates

Raspian

Raspbian Jessie Download

Debian

RaspberryPi

  • Can I put Debian on my Raspberry Pi?
  • Should I buy a Raspberry Pi?
  • Raspberry Pi issues

Software Packages

How to add a repository

$ sudo apt-get install python-software-properties
Paketlisten werden gelesen... Fertig
Abhängigkeitsbaum wird aufgebaut.        
Statusinformationen werden eingelesen.... Fertig
Die folgenden zusätzlichen Pakete werden installiert:
  lsb-release python-apt python-apt-common python-gnupginterface python-pycurl unattended-upgrades
Vorgeschlagene Pakete:
  lsb python-apt-dbg python-gtk2 python-vte python-apt-doc libcurl4-gnutls-dev python-pycurl-dbg bsd-mailx mail-transport-agent
Die folgenden NEUEN Pakete werden installiert:
  lsb-release python-apt python-apt-common python-gnupginterface python-pycurl python-software-properties unattended-upgrades
0 aktualisiert, 7 neu installiert, 0 zu entfernen und 15 nicht aktualisiert.
Es müssen 689 kB an Archiven heruntergeladen werden.
Nach dieser Operation werden 2'516 kB Plattenplatz zusätzlich benutzt.
Möchten Sie fortfahren [J/n]? j

GNU ARM Embedded Toolchain

$ sudo add-apt-repository ppa:terry.guo/gcc-arm-embedded

$ grep -r ppa /etc/apt/sources.list.d
/etc/apt/sources.list.d/terry_guo-gcc-arm-embedded-wheezy.list:deb http://ppa.launchpad.net/terry.guo/gcc-arm-embedded/ubuntu wheezy main
/etc/apt/sources.list.d/terry_guo-gcc-arm-embedded-wheezy.list:deb-src http://ppa.launchpad.net/terry.guo/gcc-arm-embedded/ubuntu wheezy main

$ sudo vi /etc/apt/sources.list.d/terry_guo-gcc-arm-embedded-wheezy.list
deb http://ppa.launchpad.net/terry.guo/gcc-arm-embedded/ubuntu trusty main
deb-src http://ppa.launchpad.net/terry.guo/gcc-arm-embedded/ubuntu trusty main

$ sudo apt-get update
$ sudo apt-get install gcc-arm-none-eabi=4-8-2014q2-0trusty10
Paketlisten werden gelesen... Fertig
Abhängigkeitsbaum wird aufgebaut.        
Statusinformationen werden eingelesen.... Fertig
Einige Pakete konnten nicht installiert werden. Das kann bedeuten, dass
Sie eine unmögliche Situation angefordert haben oder, wenn Sie die
Unstable-Distribution verwenden, dass einige erforderliche Pakete noch
nicht erstellt wurden oder Incoming noch nicht verlassen haben.
Die folgenden Informationen helfen Ihnen vielleicht, die Situation zu lösen:

Die folgenden Pakete haben unerfüllte Abhängigkeiten:
 gcc-arm-none-eabi : Hängt ab von: libmpfr4 (>= 3.1.2) aber 3.1.0-5 soll installiert werden
E: Probleme können nicht korrigiert werden, Sie haben zurückgehaltene defekte Pakete.

How to Downgrade a Package via apt-get?
“mpfr4” package in Ubuntu
libmpfr4 3.1.2-1 (armhf binary) in ubuntu trusty
libmpfr4 3.1.2-1 (armhf binary) in ubuntu utopic

$ sudo dpkg -i Downloads/libmpfr4_3.1.2-1_armhf.deb 
(Reading database ... 73631 files and directories currently installed.)
Preparing to replace libmpfr4:armhf 3.1.0-5 (using .../libmpfr4_3.1.2-1_armhf.deb) ...
Unpacking replacement libmpfr4:armhf ...
Setting up libmpfr4:armhf (3.1.2-1) ...
Fehl http://ppa.launchpad.net wheezy/main Sources                                                                                
  404  Not Found
Fehl http://ppa.launchpad.net wheezy/main armhf Packages                                                                            
  404  Not Found
Ign http://ppa.launchpad.net wheezy/main Translation-de_CH                                                                          
Ign http://ppa.launchpad.net wheezy/main Translation-de                                                                             
W: Fehlschlag beim Holen von http://ppa.launchpad.net/terry.guo/gcc-arm-embedded/ubuntu/dists/wheezy/main/source/Sources  404  Not Found
W: Fehlschlag beim Holen von http://ppa.launchpad.net/terry.guo/gcc-arm-embedded/ubuntu/dists/wheezy/main/binary-armhf/Packages  404  Not Found
E: Einige Indexdateien konnten nicht heruntergeladen werden. Sie wurden ignoriert oder alte an ihrer Stelle benutzt.
Holen: 1 http://ppa.launchpad.net trusty Release.gpg [316 B]                                                 
Holen: 2 http://ppa.launchpad.net trusty Release [14.0 kB]                                                                          
Holen: 3 http://ppa.launchpad.net trusty/main Sources [927 B]                                                                                                                  
Holen: 4 http://ppa.launchpad.net trusty/main armhf Packages [601 B]                                                                 
Ign http://ppa.launchpad.net trusty/main Translation-de_CH                                          
Ign http://ppa.launchpad.net trusty/main Translation-de                     
Ign http://ppa.launchpad.net trusty/main Translation-en
$ sudo apt-get install \
apt-src gawk gzip perl autoconf m4 \
automake libtool libncurses5-dev \
gettext gperf dejagnu expect tcl \
autogen guile-1.6 flex flip bison \
tofrodos libgmp3-dev libmpfr-dev debhelper 
/bin/bash ./libtool --tag=CC   --mode=link arm-linux-gnueabihf-gcc -Wall -fomit-frame-pointer -g -O2  -L/home/pi/Downloads/gcc-arm-none-eabi-4_7-2014q2-20140408/build-native/host-libs/usr/lib -L/home/pi/Downloads/gcc-arm-none-eabi-4_7-2014q2-20140408/build-native/host-libs/usr/lib  -o cloog cloog.o libcloog.la -lgmp -lppl_c -lppl -lgmpxx -lstdc++
libtool: link: arm-linux-gnueabihf-gcc -Wall -fomit-frame-pointer -g -O2 -o cloog cloog.o  -L/home/pi/Downloads/gcc-arm-none-eabi-4_7-2014q2-20140408/build-native/host-libs/usr/lib ./.libs/libcloog.a /home/pi/Downloads/gcc-arm-none-eabi-4_7-2014q2-20140408/build-native/host-libs/usr/lib/libppl_c.a /home/pi/Downloads/gcc-arm-none-eabi-4_7-2014q2-20140408/build-native/host-libs/usr/lib/libpwl.a /home/pi/Downloads/gcc-arm-none-eabi-4_7-2014q2-20140408/build-native/host-libs/usr/lib/libppl.a /home/pi/Downloads/gcc-arm-none-eabi-4_7-2014q2-20140408/build-native/host-libs/usr/lib/libgmpxx.a /home/pi/Downloads/gcc-arm-none-eabi-4_7-2014q2-20140408/build-native/host-libs/usr/lib/libgmp.a -lstdc++
/usr/bin/ld: /home/pi/Downloads/gcc-arm-none-eabi-4_7-2014q2-20140408/build-native/host-libs/usr/lib/libppl.a(MIP_Problem.o): undefined reference to symbol 'sqrt@@GLIBC_2.4'
//lib/arm-linux-gnueabihf/libm.so.6: error adding symbols: DSO missing from command line
collect2: ld returned 1 exit status
Makefile:504: recipe for target 'cloog' failed
make[1]: *** [cloog] Error 1
make[1]: Leaving directory '/home/pi/Downloads/gcc-arm-none-eabi-4_7-2014q2-20140408/build-native/cloog'
Makefile:674: recipe for target 'all-recursive' failed
make: *** [all-recursive] Error 1
arm-linux-gnueabihf-gcc -Wall -fomit-frame-pointer -g -O2 -o cloog cloog.o  -L/home/pi/Downloads/gcc-arm-none-eabi-4_7-2014q2-20140408/build-native/host-libs/usr/lib ./.libs/libcloog.a /home/pi/Downloads/gcc-arm-none-eabi-4_7-2014q2-20140408/build-native/host-libs/usr/lib/libppl_c.a /home/pi/Downloads/gcc-arm-none-eabi-4_7-2014q2-20140408/build-native/host-libs/usr/lib/libpwl.a /home/pi/Downloads/gcc-arm-none-eabi-4_7-2014q2-20140408/build-native/host-libs/usr/lib/libppl.a /home/pi/Downloads/gcc-arm-none-eabi-4_7-2014q2-20140408/build-native/host-libs/usr/lib/libgmpxx.a /home/pi/Downloads/gcc-arm-none-eabi-4_7-2014q2-20140408/build-native/host-libs/usr/lib/libgmp.a -lstdc++ -lm

Very strange linker behavior

Making pdf in doc
make[3]: Entering directory '/home/pi/Downloads/gcc-arm-none-eabi-4_8-2014q2-20140609/build-native/binutils/bfd/doc'
TEXINPUTS="/home/pi/Downloads/gcc-arm-none-eabi-4_8-2014q2-20140609/src/binutils/bfd/../texinfo:$TEXINPUTS" \
MAKEINFO='makeinfo --split-size=5000000 --split-size=5000000   -I /home/pi/Downloads/gcc-arm-none-eabi-4_8-2014q2-20140609/src/binutils/bfd/doc' \
`if test -f /home/pi/Downloads/gcc-arm-none-eabi-4_8-2014q2-20140609/src/binutils/bfd/../texinfo/util/texi2dvi; then echo /home/pi/Downloads/gcc-arm-none-eabi-4_8-2014q2-20140609/src/binutils/bfd/../texinfo/util/texi2dvi; else echo texi2dvi; fi` --pdf --batch -o bfd.pdf `test -f 'bfd.texinfo' || echo '/home/pi/Downloads/gcc-arm-none-eabi-4_8-2014q2-20140609/src/binutils/bfd/doc/'`bfd.texinfo
You don't have a working TeX binary installed, but the texi2dvi script
can't proceed without it. If you want to use this script, you have to
install some kind of TeX, for example TeX Live Debian packages. You can do
that with this command:
       apt-get install texlive
Makefile:444: recipe for target 'bfd.pdf' failed
make[3]: *** [bfd.pdf] Error 1
make[3]: Leaving directory '/home/pi/Downloads/gcc-arm-none-eabi-4_8-2014q2-20140609/build-native/binutils/bfd/doc'
Making pdf in po
make[3]: Entering directory '/home/pi/Downloads/gcc-arm-none-eabi-4_8-2014q2-20140609/build-native/binutils/bfd/po'
make[3]: Nothing to be done for 'pdf'.
make[3]: Leaving directory '/home/pi/Downloads/gcc-arm-none-eabi-4_8-2014q2-20140609/build-native/binutils/bfd/po'
make[3]: Entering directory '/home/pi/Downloads/gcc-arm-none-eabi-4_8-2014q2-20140609/build-native/binutils/bfd'
make[3]: Nothing to be done for 'pdf-am'.
make[3]: Leaving directory '/home/pi/Downloads/gcc-arm-none-eabi-4_8-2014q2-20140609/build-native/binutils/bfd'
Makefile:1618: recipe for target 'pdf-recursive' failed
make[2]: *** [pdf-recursive] Error 1
make[2]: Leaving directory '/home/pi/Downloads/gcc-arm-none-eabi-4_8-2014q2-20140609/build-native/binutils/bfd'
Makefile:2646: recipe for target 'pdf-bfd' failed
make[1]: *** [pdf-bfd] Error 1
make[1]: Leaving directory '/home/pi/Downloads/gcc-arm-none-eabi-4_8-2014q2-20140609/build-native/binutils'
Makefile:1374: recipe for target 'do-install-pdf' failed
make: *** [do-install-pdf] Error 2

Raspberry PI and FreeBSD

Progress on Raspberry Pi

UART

Raspberry Pi and Arduino via GPIO UART
RPi Serial Connection
Raspberry Pi GPIO How-To
How to use GPIOs on raspberry pi (Simple I/O, PWM and UART)

Kernel Debugging

Preparing Raspberry PI for JTAG Debugging

Embedded Pi

Embest: Schematic for Embedded Pi
Schematic for Embedded Pi

Using a Raspberry Pi as a JTAG Dongle
How to program the Embedded Pi with Raspberry Pi
How to program the Embedded Pi with Raspberry Pi
Getting Started with the Embedded Pi and Raspbian
The Embedded Pi: good hardware but how to use?
Getting Started with the Embedded Pi and Raspbian
Add ADC Functionality to RPi with EPi
Wikipedia: Bit-Banging
OpenOCD FT2232H based JTAG Adapter(s) with UART
Inexpensive Ethernet JTAG Adapter with Raspberry Pi and OpenOCD
stm32flash – Open source cross platform flash program for the STM32 bootloader

Crowdfunding

Das leise Sterben der Crowdfunding-Plattformen

6 Crowdinvesting-Plattformen im Vergleich
5 weitere Crowdinvesting-Plattformen im Vergleich


Crowdfunding – Der Schwarm sammelt lieber in Amerika

Schwarmfinanzierung: Krautfunder warten auf den Kickstarter-Effekt
“Crowdfunding verzeichnet in der Schweiz ein beeindruckendes Wachstum”
Start der Crowdfunding-Plattform c-crowd
c-crowd: Crowdfunding professionalisiert
Crowdfunding Da kommt eine ganze Menge zusammen

C Integer Power / Integer Potenz

#include <math.h>
double pow(double x, double y);

period = pow(2, log_inter_message_period);
rate   = 1 / period;

printf("every %lg seconds", period);

Wikipedia

Potenz

stackoverflow

Why is my power operator (^) not working?
power of an integer in c++
Integer power in c
The most efficient way to implement an integer based power function pow(int, int)

Divers

Bit Twiddling Hacks – Determining if an integer is a power of 2

RegEx: Regular Expression

regexr
regex101
regextester

A Practical Guide to Regular Expressions – Learn RegEx with Real Life Examples

abc         Letters
123         Digits
\.          Period

[abc]       Only a, b, or c
[^abc]      Not a, b, nor c
[a-z]       Characters a to z
[0-9]       Numbers 0 to 9

{m}         m Repetitions
{m,n}       m to n Repetitions
*           Zero or more repetitions
+           One or more repetitions
?           Optional character
.           Any Character

^…$         Starts and ends
(…)         Capture Group
(a(bc))     Capture Sub-group
(.*)        Capture all
(abc|def)   Matches abc or def

\s          Any Whitespace
[ ]         Whitespace
\S          Any Non-whitespace character
\d          Any Digit
\D          Any Non-digit character
\w          Any Alphanumeric character [a-zA-Z_0-9]
\W          Any Non-alphanumeric character

Non-capturing group:
(?:expression)

Look-around assertions:
(?<=expression) = positive look-behind assertion
(?=expression)  = positive look-ahead assertion

Capture Groups

Capturing Groups and Backreferences
What is a non-capturing group in regular expressions?

The only difference between capture groups and non-capture groups is that the former captures the matched character sequences for possible later re-use with a numbered back reference while a non-capture group does not.

RegexOne – with Exercises

Lesson 11: Match groups / Capture group

Exercise

List of single characters

File:
hat
tut
cat
blue
red
zat
bet
tat
met
mat

RegEx:
[htm]at => matches "hat", "tat", "mat"

RegEx:
[^htm]at => matches ".at" except "hat", "tat", "mat"
Result: "cat", "zat"

Whitespace at the beginning or end of a line

^[ \t]+|[ \t]+$

Explanation:
^   Start of line
[ ] List of single characters: Space and Tab
+   One or more occurrences
|   OR
$   End of line

Remove newlines

File:
aaa
bbb
ccc

RegEx: '(?<=^.+)\n'

Result:
aaabbbccc

Cut out only define name

#define DEFAULT_CLOCK_BLA                      MAC_ADD_HEAD_1,0xff,0xfe,MAC_ADD_HEAD_2,SR_NR

Remove #define:

DEFAULT_CLOCK_BLA                      MAC_ADD_HEAD_1,0xff,0xfe,MAC_ADD_HEAD_2,SR_NR
Search:  '(?<=(^[\w]+))[\s]*[\w\,]*(?=($))'
Replace: ''
DEFAULT_CLOCK_BLA

Append parameter list

default_clock_bla
Search:  '(?<=(^[\w]+))\s*(?=($))'
Replace: '(void);'
default_clock_bla(void);

Trim to only have one space

bool                            default_clock_bla(void);
Search:  '(?<=(^[\w]+))\s+'
Replace: ' '
bool default_clock_bla(void);

Separate result type from function name

bool default_clock_bla(void);
Search:  '(?<=(^[\w]+))\s'
Replace: '\n'
bool
default_clock_bla(void);

Add curly brackets

bool
default_clock_bla(void);
Search:  ';(?=($))'
Replace: '\n{\n    \n}\n'
bool
default_clock_bla(void)
{
    
}

Add to every line

DEVICE_I2CSLAVE=1
TARGET_LIKE_MBED
DEVICE_PORTOUT=1
DEVICE_PORTINOUT=1
TARGET_RTOS_M4_M7
Search:  '(?<=.*)^'
Replace: '<name>'

Search:  '=1$'
Replace: '</name><value>1</value>'
<name>DEVICE_I2CSLAVE</name><value>1</value>
<name>TARGET_LIKE_MBED
<name>DEVICE_PORTOUT</name><value>1</value>
<name>DEVICE_PORTINOUT</name><value>1</value>
<name>TARGET_RTOS_M4_M7

Add suffix if line-end is NOT “>”

<name>DEVICE_I2CSLAVE</name><value>1</value>
<name>TARGET_LIKE_MBED
<name>DEVICE_PORTOUT</name><value>1</value>
<name>DEVICE_PORTINOUT</name><value>1</value>
<name>TARGET_RTOS_M4_M7
Search:  '(?<=[^>]$)'
Replace: '</name><value/>'
<name>DEVICE_I2CSLAVE</name><value>1</value>
<name>TARGET_LIKE_MBED</name><value/>
<name>DEVICE_PORTOUT</name><value>1</value>
<name>DEVICE_PORTINOUT</name><value>1</value>
<name>TARGET_RTOS_M4_M7</name><value/>

Embrace lines

<name>DEVICE_I2CSLAVE</name><value>1</value>
<name>TARGET_LIKE_MBED</name><value/>
<name>DEVICE_PORTOUT</name><value>1</value>
<name>DEVICE_PORTINOUT</name><value>1</value>
<name>TARGET_RTOS_M4_M7</name><value/>
Search:  '^(?=<name>.*)'
Replace: '<macro>\n'

Search:  '(?<=.*</value>|<value/>)'
Replace: '\n</macro>'
<macro>
<name>DEVICE_I2CSLAVE</name><value>1</value>
</macro>
<macro>
<name>TARGET_LIKE_MBED</name><value/>
</macro>
<macro>
<name>DEVICE_PORTOUT</name><value>1</value>
</macro>
<macro>
<name>DEVICE_PORTINOUT</name><value>1</value>
</macro>
<macro>
<name>TARGET_RTOS_M4_M7</name><value/>
</macro>

Table to SQL

Adding Quotation marks around string with regex

Joy F 11 51.3 50.5
Jane F 12 59.8 84.5
Jim M 12 57.3 83.0
Alice F 13 56.5 84.0
Jeff M 13 62.5 84.0
Bob M 14 64.2 90.0
Philip M 16 72.0 150.0
Search:  '[ ]'
Replace: ', '

Search:  '([^\s,.0-9]+)'
Replace: ''$1''
'Joy', 'F', 11, 51.3, 50.5
'Jane', 'F', 12, 59.8, 84.5
'Jim', 'M', 12, 57.3, 83.0
'Alice', 'F', 13, 56.5, 84.0
'Jeff', 'M', 13, 62.5, 84.0
'Bob', 'M', 14, 64.2, 90.0
'Philip', 'M', 16, 72.0, 150.0
Search:  '(?<=^)'
Replace: ') ,(\n    '
) ,(
    'Joy', 'F', 11, 51.3, 50.5
) ,(
    'Jane', 'F', 12, 59.8, 84.5
) ,(
    'Jim', 'M', 12, 57.3, 83.0
) ,(
    'Alice', 'F', 13, 56.5, 84.0
) ,(
    'Jeff', 'M', 13, 62.5, 84.0
) ,(
    'Bob', 'M', 14, 64.2, 90.0
) ,(
    'Philip', 'M', 16, 72.0, 150.0

Strip CC, only use source file

One-Liner

Original: CC -m64 -instances=global   -c -fast -g0 -I/opt/include -o build/testGlobals.o ../app/testGlobals.cpp
Search:   ^.* (.*)$
Replace:  $1
Result:   ../app/testGlobals.cpp

Multi-Liner

mkdir -p build/x86_Release 
CC  -c -fast -g0  -I/opt/include -o build/x86_Release/dynamoGlobals.o dynamoGlobals.cpp
CC: Warning: -xchip=native detection failed, falling back to -xchip=generic
mkdir -p build/x86_Release /_ext/710760585
CC  -c -fast -g0  -I/opt/include   -o build/x86_Release/_ext/710760585/TValueList.o ../dynamo_base/TValueList.cpp
CC: Warning: -xchip=native detection failed, falling back to -xchip=generic
mkdir -p build/x86_Release /_ext/710760585
CC  -c -fast -g0  -I/opt/include   -o build/x86_Release/_ext/710760585/UProductConstructor.o ../dynamo_base/UProductConstructor.cpp
CC: Warning: -xchip=native detection failed, falling back to -xchip=generic
mkdir -p build/x86_Release /_ext/710760585
Search:  '^(?!CC ).*$\n?'
Replace: ''

Search:  '^.* (.*)$'
Replace: '$1'
dynamoGlobals.cpp
../dynamo_base/TValueList.cpp
../dynamo_base/UProductConstructor.cpp