bootlin / training-materials

Bootlin embedded Linux and kernel training materials
https://bootlin.com/training/
Other
576 stars 174 forks source link

How to compile these materials

First, you may install the packages needed to compile the materials (example on Ubuntu 22.04):

sudo apt install --no-install-recommends git-core inkscape \ texlive-latex-base texlive-latex-extra texlive-font-utils dia \ python3-pygments texlive-fonts-recommended \ texlive-fonts-extra make texlive-xetex texlive-extra-utils \ fonts-inconsolata fonts-liberation \ xfonts-scalable lmodern texlive-science texlive-plain-generic \ texlive-lang-french ghostscript

Then, run 'make help' to see what available targets are.

For example:

make full-linux-kernel-slides.pdf make full-linux-kernel-labs.pdf

Compiling issues

Labs formatting guidelines

\subchapter{Bootloader – U-Boot}{Objectives: Set up serial communication, compile and install the X-Loader and U-Boot bootloaders, use basic U-Boot commands, set up TFTP communication with the development workstation.}

Blabla. Look in the \code{/usr/bin} directory. Blabla.

Note that the \code{} macro doesn't require escaping of $ or _ signs:

You can look for the \code{platform_device_register()} function in the \code{$HOME/linux/blabla.c} file.

This macro MUST be used instead of {\tt }, because \code{} provides proper line wrapping on dashes, slashes and so on, which helps in keeping the line of text within the width of the page.

Note that this macro cannot be used in section titles or chapter titles. In this case {\tt } needs to be used (and inside {\tt }, the _ or $ signs have to be escaped).

In order to build the kernel run:

\begin{verbatim} make blabla_defconfig make \end{verbatim}

Here as well, it does not require escaping of $ or _ signs.

\small \begin{verbatim} ... \end{verbatim} \normalsize

This must be used parsimoniously because changing the font size all the time is not very pretty. But since the verbatim environment does not do line wrapping, it may sometimes be necessary.

Note that in addition to \small, you can also use other sizes, see https://en.wikibooks.org/wiki/LaTeX/Fonts#Built-in_sizes .

Slides formatting guidelines

Syntax Highlighting

The LaTeX package minted is included to have a nice syntax highlighting and advanced code formatting features. It uses pygments as backend, so in order to use it, one needs to install the debian/Ubuntu package python-pygments.

A basic example for C code is:

\begin{minted}{c} .... \end{minted}

Of course, it can take a lot of options that you can find in the minted's documentation present at: http://mirrors.ctan.org/macros/latex/contrib/minted/minted.pdf

Emacs usage in LaTeX

Install the AUCTex package which contains an improved Emacs environment for editing LaTeX documents:

sudo apt install auctex

In your ~/.emacs.el file, add the following lines:

(load "auctex.el" nil t t) (require 'latex) (add-to-list 'LaTeX-verbatim-macros-with-braces "code") (add-to-list 'LaTeX-verbatim-macros-with-braces "url")

The important point here is that this tells Emacs to consider the \code{} and \url{} macros as a verbatim macro, so that even if special characters such as $, _ or % are not escaped inside these macros, Emacs text colorization will not go crazy.

Nice keyboard shortcuts with AUCTex:

Diagrams

The recommended program to do diagrams is Dia:

apt install dia

When saving a file, please make sure to unselect the "Compressed saved files" option, so that the .dia files are raw XML files, and not gzipped compressed files. Having raw XML files is much better for version control, and will allow, to some extent, merging .dia diagrams after conflicts.

The fonts to be used are "Latin Modern Sans" for normal text and "Inconsolata" for the code/paths.

Here are some suggested color couples you can use for the border and background of boxes and other elements. Using similar colors for all diagrams will make our training documents much more coherent and nice to look at.

If you want to easily add all these colors to Dia, add the following fragment to ~/.dia/persistence (or replace the existing role="color-menu" XML tag):

------------------8<-----------------8<-----------------------------

##5CACFF #ADD8E6 #D9CB2F #FFF8A8 #868686 #E5E5E5 #A34804 #FFD192 #2F004A #EFB9FF #6A8954 #C5E387 #CC1F1A #FFACAC# ------------------8<-----------------8<-----------------------------