Compare commits

...

2 Commits

Author SHA1 Message Date
Thomas Klaehn
6088c8eb2a wip 2016-12-08 11:05:11 +01:00
Thomas Klaehn
6161624546 bootloader howto 2016-10-14 15:22:03 +02:00
3 changed files with 182 additions and 204 deletions

View File

@ -20,8 +20,11 @@ citecolor = black]{hyperref}%
\usepackage{amsfonts}% \usepackage{amsfonts}%
\usepackage{mathrsfs}% \usepackage{mathrsfs}%
\usepackage{hyperref}% \usepackage{hyperref}%
\usepackage{xcolor}% \usepackage[dvipsnames]{xcolor}%
\usepackage{scrpage2}% \usepackage{scrpage2}%
\usepackage{multido}
\usepackage{pstricks}
\usepackage{colortbl}
\newcommand*\euler{\mathrm{e}} \newcommand*\euler{\mathrm{e}}
\input{title.tex} \input{title.tex}

View File

@ -1,241 +1,216 @@
\section{Installation} \section{Bootloader}
\subsection{SD card preparation} To build a bootloader for the project \textit{moray white 2} you have to do the
\subsubsection{Partitions} following steps:\\
Format the SD card with two new partitions:
\lstsetbash
\begin{lstlisting}
fdisk /dev/mmcblk0
\end{lstlisting}
\begin{enumerate} \begin{enumerate}
\item Type \textbf{o} to erase all former partitions \item check/edit build job file
\item Type \textbf{p} to list all existing partitions \item check/edit configuration file
\item Type \textbf{n}, then \textbf{p} to create the boot partition. Press \item create release tag in gitlab
\textbf{RETURN} to accept the first sector, then \textbf{+100M} for the
last sector
\item Type \textbf{t}, then \textbf{c} to set the partition type to FAT32
\item Type \textbf{n}, then \textbf{p} to create the root partition. Press
\textbf{RETURN} to accept the first sector, then \textbf{RETURN} for the
last sector
\item Type \textbf{w} to write the new partition table
\end{enumerate} \end{enumerate}
\subsubsection{File systems} \subsection{Build job file}
Create the file systems for the new partitions: The build job file (\texttt{.gitlab-ci.yml}) could be found in the root
\begin{lstlisting} directory of the repository. Here only the build configuration is done. In the
mkfs.vfat /dev/mmcblk0p1 \texttt{variables} Section the variable \texttt{PROJECT} contains the current
mkfs.ext4 /dev/mmcblk0p2 build configuration.\\
\end{lstlisting} Possible build configurations:
Create mount points and mount the new partitions:
\begin{lstlisting}
mkdir boot
mkdir root
mount /dev/mmcblk0p1 boot
mount /dev/mmcblk0p2 root
\end{lstlisting}
\subsubsection{Download and extract root file system} \captionof{table}{Values for build configutation}
\begin{lstlisting} \label{tab:var_build_confs}
wget http://archlinuxarm.org/os/\
ArchLinuxARM-rpi-2-latest.tar.gz
bsdtar -xpf ArchLinuxARM-rpi-2-latest.tar.gz -C root
sync
mv root/boot/* boot
\end{lstlisting}
Enable ssh root login:
\begin{lstlisting}
vim root/etc/ssh/sshd\_config
\end{lstlisting}
Find \texttt{\#PermitRootLogin yes} and uncommend it
\begin{lstlisting}
PermitRootLogin yes
\end{lstlisting}
Unmount both partitions
\begin{lstlisting}
umount boot root
\end{lstlisting}
\section{Configuration}
\subsection{User management}
\subsubsection{Create new user}
\begin{lstlisting}
useradd -m -g users -G wheel -s /bin/bash tkl
\end{lstlisting}
\begin{tabular}{l l} \begin{tabular}{l l}
\texttt{-m} & create user name home directory\\ \cellcolor{black}\color{white}build config & \cellcolor{black}\color{white}meaning \\
\texttt{-g} & initial login group\\ white2-dbg & use the debug configuration to build the release\\
\texttt{-G} & list of supplementary groups - comma separated\\ white2-rel & use the release configuration to build the release\\\\
\texttt{-s} & path and file name of default login shell\\ \end{tabular}
\end{tabular}\\
Set password for the new user: \textbf{Example}
\lstsetbash
\begin{lstlisting} \begin{lstlisting}
passwd tkl variables:
PROJECT: "white2-dbg"
...
\end{lstlisting} \end{lstlisting}
Enable wheel group members as sudoers:
\begin{lstlisting} \begin{lstlisting}
EDITOR=vim visudo variables:
\end{lstlisting} PROJECT: "white2-rel"
Uncomment: ...
\begin{lstlisting}
%wheel ALL=(ALL) ALL
\end{lstlisting} \end{lstlisting}
\subsection{Aliasing} \subsection{Configuration file}
The configuration file (\texttt{configuration.xml}) depends on the build
configuration (\texttt{white2-dbg} or \texttt{white2-rel}) and could be found
in following folder (relative to the repositories root folder):\\
\begin{lstlisting} \begin{lstlisting}
cd ~ moray/config/<build_config>/
vi .bashrc
\end{lstlisting} \end{lstlisting}
Add:\\ Amongst others informations regarding version numbers, deploy file names and
\texttt{alias vi='vim'} deploy locations are encapsulated in the \texttt{postlink} target.
\subsection{Customize vim} \captionof{table}{Release relevant attributes in configuration file}
Edit \texttt{.vimrc}: \label{tab:conf_vars}
\begin{tabular}{l l}
\cellcolor{black}\color{white}attributes & \cellcolor{black}\color{white}meaning \\
OUT\_EXECUTABLE\_NAME & file name for the bootloader executable\\
REL\_VERSION & version numbering scheme\\
OUT\_DEPLOY\_PATH & subversion link to deploy the release to\\\\
\end{tabular}
It's usually enough to change \texttt{OUT\_EXECUTABLE\_NAME} and
\texttt{REL\_VERSION} according to the release numbering scheme.\\\\
\textbf{Example}
\begin{lstlisting} \begin{lstlisting}
syntax on "Syntax highlightning ...
set number "Line numbering <attribute name="OUT_EXECUTABLE_NAME"
value="MO_BL_42_3.0.6_dbg.S19"/>
<attribute name="REL_VERSION"
value="42.3.0.6"/>
<attribute name="OUT_DEPLOY_PATH"
value="http://dabsvn01.internal.novero.com/svn/\
0_31X_P0521_moray_white2/trunk/development/\
software/releases/WTC/"/>
...
\end{lstlisting}
\subsection{Create release tag in gitlab}
To create a release candidate a tag in gitlab has to be created. Of course this
could be done either locally (don't forget to push the tag) or by using the
gitlab ui.
\subsubsection{Release candidate}
To create a release candidate the tag name must match the following regular
expression:
\begin{lstlisting}
^release/white2/MO_BL_42_[0-9]+\.[0-9]+\.[0-9]+_RC[0-9]+
\end{lstlisting} \end{lstlisting}
\subsection{Wifi} \textbf{Example}
Configure wifi network:
\begin{lstlisting} \begin{lstlisting}
wifi-menu release/white2/MO_BL_42_0.0.0_RC0
\end{lstlisting} release/white2/MO_BL_42_255.255.255_RC255
Enable wifi network permanent:
\begin{lstlisting}
netctl enable wlan0-<network_name>
\end{lstlisting}
\subsubsection{Deactivate wifi device sleep mode}
\begin{lstlisting}
pacman -S iw
echo ACTION=="add", SUBSYSTEM=="net", KERNEL=="wlan*", \
RUN+="/usr/bin/iw dev \%k set power\_save off\" \
> etc/udev/rules.d/70-wifi-powersave.rules
\end{lstlisting} \end{lstlisting}
\subsection{Ssh key login} \subsubsection{Release}
\begin{itemize} To create a release the tag name must match the following regular expression:
\item Create \texttt{.ssh/} folder in users home directory
\item Copy public key file (i.e. \texttt{id\_rsa.pub}) into \texttt{.ssh}
folder
\item Authorize public key:
\begin{lstlisting} \begin{lstlisting}
cat id_rsa.pub >> authorized_keys ^release/white2/MO_BL_42_[0-9]+\.[0-9]+\.[0-9]+
\end{lstlisting}
\end{itemize}
\subsection{Interfaces}
\subsubsection{I2C}
To enable i2c interface edit \texttt{/boot/config.txt}. \\
Uncomment \texttt{\#device\_tree\_param=i2c\_arm=on}\\
Load i2c modules while boot:
\begin{lstlisting}
/etc/modules-load.d/raspberry.conf
i2c-dev
i2c-bcm2708
\end{lstlisting}
Install package \texttt{i2c-tools}
Test i2c bus after reboot:
\begin{lstlisting}
i2cdetect -y 1
\end{lstlisting}
Set permissions for i2c device access:
\begin{lstlisting}
/etc/udev/rules.d/99-i2c.rules
KERNEL=="i2c-1", MODE="0777"
\end{lstlisting} \end{lstlisting}
\subsubsection{SPI} \textbf{Example}
To enable spi interface edit \texttt{/boot/config.txt}. \\
Uncomment \texttt{\#device\_tree\_param=spi=on}
\subsubsection{GPIO}
Create an udev rule to enable others than root accessing the gpio files:
\begin{lstlisting} \begin{lstlisting}
/etc/udev/rules.d/98-gpio.rules release/white2/MO_BL_42_0.0.0
release/white2/MO_BL_42_255.255.255
SUBSYSTEM=="gpio*", PROGRAM="/bin/sh -c 'chown -R root:gpio\
/sys/class/gpio; chmod -R 0777 /sys/class/gpio; chown -R \
root:gpio /sys/devices/virtual/gpio; chmod -R 0777 \
/sys/devices/virtual/gpio'"
\end{lstlisting} \end{lstlisting}
\subsection{tools} \textbf{Note:} Any tag which shouldn't trigger a release build must not match
\begin{itemize} these regular expression rules.
\item \texttt{fakeroot}
\item \texttt{gcc} \section{Application}
\item \texttt{git} For application building in the project \textit{moray white 2} the same steps as
\item \texttt{make} for bootloader building are necessary:\\
\item \texttt{patch} \begin{enumerate}
\item \texttt{python2, python2-pip} \item check/edit build job file
\item \texttt{wget} \item check/edit configuration file
\end{itemize} \item create release tag in gitlab
\subsection{Hostname} \end{enumerate}
\subsection{Build job file}
The build job file (\texttt{.gitlab-ci.yml}) could be found in the root
directory of the repository. Here only the build configuration is done. In the
\texttt{variables} Section the variable \texttt{PROJECT} contains the current
build configuration.\\
Possible build configurations:
\captionof{table}{Values for build configutation}
\label{tab:var_build_confs}
\begin{tabular}{l l}
\cellcolor{black}\color{white}build config & \cellcolor{black}\color{white}meaning \\
white2-dbg & use the debug configuration to build the release\\
white2-rel & use the release configuration to build the release\\\\
\end{tabular}
\textbf{Example}
\lstsetbash
\begin{lstlisting} \begin{lstlisting}
echo "hostname" > /etc/hostname variables:
PROJECT: "white2-dbg"
...
\end{lstlisting}
\begin{lstlisting}
variables:
PROJECT: "white2-rel"
...
\end{lstlisting} \end{lstlisting}
\section{Applications} \subsection{Configuration file}
\subsection{I2C-OLED} The configuration file (\texttt{configuration.xml}) depends on the build
\subsubsection{Oled Test application} configuration (\texttt{white2-dbg} or \texttt{white2-rel}) and could be found
Clone test application: in following folder (relative to the repositories root folder):\\
\begin{lstlisting} \begin{lstlisting}
git clone git@dabgit01.internal.novero.com:raspberry/\ config/<build_config>/
oledpi.git
\end{lstlisting} \end{lstlisting}
\subsubsection{Install driver} Amongst others informations regarding version numbers, bootloader location,
Clone oled driver: deploy file names and deploy locations are encapsulated in the \texttt{postlink}
\begin{lstlisting} target.
git clone https://github.com/rm-hull/ssd1306.git
\end{lstlisting}
Install it:
\begin{lstlisting}
python2 setup.py install
\end{lstlisting}
\subsubsection{Dependencies}
\begin{itemize}
\item \texttt{python-smbus/python2-smbus} (AUR)
\item \texttt{i2c-tool-git} (AUR)
\item \texttt{libjpeg-turbo}
\item \texttt{pillow} install using pip \texttt{(pip/pip2 install pillow)}
\end{itemize}
\subsection{Weatherpi} \captionof{table}{Release relevant attributes in configuration file}
\subsubsection{Usb weatherstation test application} \label{tab:conf_vars}
Clone test application: \begin{tabular}{l l}
\cellcolor{black}\color{white}attributes & \cellcolor{black}\color{white}meaning \\
OUT\_EXECUTABLE\_NAME & file name for the bootloader executable\\
REL\_VERSION & version numbering scheme\\
IN\_BOOTLOADER\_URL & path to the bootloader url containing the\\
& regarding bootloader executable\\
OUT\_DEPLOY\_PATH & subversion link to deploy the release to\\\\
\end{tabular}
It's usually enough to change \texttt{OUT\_EXECUTABLE\_NAME} and
\texttt{REL\_VERSION} according to the release numbering scheme. Only in case of
a changed bootloader the \texttt{IN\_BOOTLOADER\_URL} has to be changed.\\\\
\textbf{Example}
\begin{lstlisting} \begin{lstlisting}
git clone git@dabgit01.internal.novero.com:raspberry/\ ...
weatherpi.git <attribute name="OUT_EXECUTABLE_NAME"
value="MO_BL_42_3.0.6_dbg.S19"/>
<attribute name="REL_VERSION"
value="42.3.0.6"/>
<attribute name="IN_BOOTLOADER_URL" value="http://\
dabsvn01/svn/0_31X_P0521_moray_white2/trunk/\
development/software/releases/WTC/Bootloader/\
MO_BL_42_3.1.6.S19"/>
<attribute name="OUT_DEPLOY_PATH"
value="http://dabsvn01.internal.novero.com/svn/\
0_31X_P0521_moray_white2/trunk/development/\
software/releases/WTC/"/>
...
\end{lstlisting}
\subsection{Create release tag in gitlab}
To create a release candidate a tag in gitlab has to be created. Of course this
could be done either locally (don't forget to push the tag) or by using the
gitlab ui.
\subsubsection{Release candidate}
To create a release candidate the tag name must match the following regular
expression:
\begin{lstlisting}
^release/white2/MO_WC_42_[0-9]+\.[0-9]+\.[0-9]+_RC[0-9]+
\end{lstlisting} \end{lstlisting}
\subsubsection{Dependencies} \textbf{Example}
\begin{itemize} \begin{lstlisting}
\item \texttt{python2-pyusb} (AUR) (edit \texttt{PKGBUILD} and add release/white2/MO_WC_42_0.0.0_RC0
\texttt{'armv7h'} to \texttt{arch}) release/white2/MO_WC_42_255.255.255_RC255
\item \texttt{libusb-compat} \end{lstlisting}
\end{itemize}
\subsection{MQTT Broker} \subsubsection{Release}
Install mosquitto (AUR)\\ To create a release the tag name must match the following regular expression:
Install paho-mqtt client library:\\
\begin{lstlisting} \begin{lstlisting}
pip2 install paho-mqtt ^release/white2/MO_WC_42_[0-9]+\.[0-9]+\.[0-9]+
\end{lstlisting} \end{lstlisting}
Create config file:
\textbf{Example}
\begin{lstlisting} \begin{lstlisting}
cp /etc/mosquitto.conf.example /etc/mosquitto.conf release/white2/MO_WC_42_0.0.0
\end{lstlisting} release/white2/MO_WC_42_255.255.255
Start mosquitto broker service:
\begin{lstlisting}
systemctl enable mosquitto.service
systemctl start mosquitto.service
\end{lstlisting}
\subsubsection{Test}
Subscribe to a topic:
\begin{lstlisting}
mosquitto_sub -t "topic/path"
\end{lstlisting}
Populate a message:
\begin{lstlisting}
mosquitto_pub -t "topic/path" -m "message payload"
\end{lstlisting} \end{lstlisting}
\textbf{Note:} Any tag which shouldn't trigger a release build must not match
these regular expression rules.

View File

@ -1,4 +1,4 @@
\newcommand{\docname}{HowTo} \newcommand{\docname}{Create release}
\newcommand{\prjname}{arch linux on raspberry pi} \newcommand{\prjname}{moray white2}
\newcommand{\docversion}{0.1} \newcommand{\docversion}{0.1}
\newcommand{\docauthor}{Thomas Klaehn} \newcommand{\docauthor}{Thomas Klaehn}