2021-05-01 17:48:08 +02:00
|
|
|
|
<img align="center" src="./images/bbb/beagleboard-logo.png" width="30%">
|
|
|
|
|
|
|
|
|
|
<sub><sup>Image taken from [Beagle Bone website](https://beagleboard.org/logo) and used in
|
|
|
|
|
accordance to their trademark rules.</sup></sub>
|
|
|
|
|
|
|
|
|
|
# Getting started on the Beagle Bone Black
|
|
|
|
|
|
|
|
|
|
The FSFW can be run on a Beagle Bone Black with the Linux OSAL, using
|
|
|
|
|
an ARM linux (cross) compiler. Instructions will be provided on how to do this.
|
|
|
|
|
|
|
|
|
|
## General Information
|
|
|
|
|
|
|
|
|
|
The following instructions will show how to build the example on the Beagle Bone Black directly.
|
|
|
|
|
It will also show how to cross-compile on a host machine and mirror the Beagle Bone sysroot folder
|
|
|
|
|
on the host machine so that the same libraries and headers used on the BBB are used
|
|
|
|
|
for the cross-compilation process.
|
|
|
|
|
|
|
|
|
|
Some Eclipse project files were provided as well to help with setting up the indexer in Eclipse
|
|
|
|
|
more quickly.
|
|
|
|
|
|
|
|
|
|
## Prerequisites for direct compilation and cross-compiling
|
|
|
|
|
|
|
|
|
|
1. SSH connection to the Beagle Bone Black working
|
|
|
|
|
2. Beagle Bone Black linux environment set up properly
|
|
|
|
|
3. `CMake` installed
|
|
|
|
|
|
|
|
|
|
## Setting up general prerequisites for Linux systems
|
|
|
|
|
|
|
|
|
|
1. Install CMake and rsync
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
sudo apt-get install cmake rsync
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
2. Configure the Beagle Bone Black Linux environment. The last section of the
|
|
|
|
|
[Linux README](README-linux.md#top) specifies how to set up a UNIX environment for the FSFW and
|
|
|
|
|
is also applicable to the Beagle Bone Black. SSH into the BBB and
|
|
|
|
|
follow the instructions in that section.
|
|
|
|
|
|
|
|
|
|
3. Install the `gpiod` library
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
sudo apt-get install gpiod libgpiod-dev
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Getting started on the Beagle Bone Black
|
|
|
|
|
|
|
|
|
|
Make sure to follow the steps above. Now you should be able to build the software on
|
|
|
|
|
the Beagle Bone Black. A ssh connection to the Raspberry Pi is assumed here
|
|
|
|
|
|
|
|
|
|
You can build the software with the following commands
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
mkdir build-Debug-BBB
|
|
|
|
|
cd build-Debug-BBB
|
|
|
|
|
cmake -DOS_FSFW=linux -DTGT_BSP=arm/beagleboneblack -DLINUX_CROSS_COMPILE=OFF -DCMAKE_BUILD_TYPE=Debug ..
|
|
|
|
|
cmake --build . -j2
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Prerequisites for cross-compiling
|
|
|
|
|
|
|
|
|
|
These prerequisites are valid for Linux as well as Windows hosts.
|
|
|
|
|
|
|
|
|
|
1. ARM Linux cross compiler installed
|
|
|
|
|
2. Beagle Bone Black sysroot folder mirrored on the host machine, using `rsync`
|
|
|
|
|
3. gdb-multiarch installed on host for remote debugging or `tcf-agent` running on the BBB
|
|
|
|
|
|
|
|
|
|
## Cross-Compiling on a Linux Host
|
|
|
|
|
|
|
|
|
|
### Setting up prerequisites for cross-compiling
|
|
|
|
|
|
|
|
|
|
## Cross-Compiling on a Windows Host
|
|
|
|
|
|
|
|
|
|
### Additional Prerequites
|
|
|
|
|
|
|
|
|
|
1. [MSYS2](https://www.msys2.org/) installed. All command line steps shown here
|
|
|
|
|
were performed in the MSYS2 MinGW64 shell (not the default MSYS2, use MinGW64!).
|
|
|
|
|
Replace `<UserName>` with respectively. It is recommended to set up
|
|
|
|
|
aliases in the `.bashrc` file to allow quick navigation to the `fsfw_example`
|
|
|
|
|
repository and to run `git config --global core.autocrlf true` for git in
|
|
|
|
|
MinGW64.
|
|
|
|
|
|
|
|
|
|
### Setting up prerequisites for Windows
|
|
|
|
|
|
|
|
|
|
1. Install CMake and rsync in MinGW64 after installing MSYS2
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
pacman -S mingw-w64-x86_64-cmake rsync
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
2. Configure the Beagle Bone Black linux environment. The last section of the
|
|
|
|
|
[Linux REAMDE](README-linux.md#top) specifies how to set up a UNIX environment
|
|
|
|
|
for the FSFW and isalso applicable to the Raspberry Pi. SSH into the
|
|
|
|
|
Beagle Bone Black and follow the instructions in that section.
|
|
|
|
|
|
2021-05-02 13:05:04 +02:00
|
|
|
|
3. Install the correct [ARM Linux cross-compile toolchain](https://releases.linaro.org/components/toolchain/binaries/latest-7/arm-linux-gnueabihf/).
|
2021-05-01 17:48:08 +02:00
|
|
|
|
provided by Linaro.
|
|
|
|
|
|
|
|
|
|
Test the toolchain by running:
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
arm-linux-gnueabihf-gcc --version
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
4. Set up a sysroot folder on the local host machine. Make sure the SSH connection to
|
2021-05-01 19:12:07 +02:00
|
|
|
|
the BBB is working without issues. Then perform the following steps
|
2021-05-01 17:48:08 +02:00
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
cd /c/Users/<UserName>
|
|
|
|
|
mkdir beaglebone
|
|
|
|
|
cd beaglebone
|
|
|
|
|
mkdir rootfs
|
|
|
|
|
cd rootfs
|
|
|
|
|
pwd
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Store the result of `pwd`, it is going to be used by `rsync` later.
|
|
|
|
|
|
2021-05-01 19:12:07 +02:00
|
|
|
|
Now use rsync to clone the BBB sysroot to the local host machine.
|
2021-05-01 17:48:08 +02:00
|
|
|
|
You can replace `<ip-address>` with `beaglebone.local` to use DNS.
|
|
|
|
|
Use the rootfs location stored from the previous steps as `<rootfs-path>`.
|
|
|
|
|
|
|
|
|
|
```sh
|
2021-05-02 13:05:04 +02:00
|
|
|
|
rsync -avHAXR --numeric-ids --info=progress2 <username>@<ip-address>:/{lib,usr} <rootfs-path>
|
2021-05-01 17:48:08 +02:00
|
|
|
|
```
|
2021-05-01 19:12:07 +02:00
|
|
|
|
|
|
|
|
|
Please note that `rsync` sometimes does not copy shared libraries or symlinks properly,
|
2021-05-02 13:05:04 +02:00
|
|
|
|
which might result in errors when cross-compiling and cross-linking. It is recommended to run
|
|
|
|
|
the following commands in addition to the `rsync` command:
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
scp <user_name>@<ip-address>:/lib/arm-linux-gnueabihf/{libc.so.6,ld-linux-armhf.so.3,libm.so.6} <rootfs_path>/lib/arm-linux-gnueabihf
|
|
|
|
|
scp <user_name>@<ip-address>:/usr/lib/arm-linux-gnueabihf/{libpthread.so,libc.so,librt.so} <rootfs_path>/usr/lib/arm-linux-gnueabihf
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
See the [troubleshooting](#troubleshooting) section for more details if the compilation process
|
|
|
|
|
is problematic.
|
2021-05-01 19:12:07 +02:00
|
|
|
|
|
|
|
|
|
5. It is recommended to install `gdb-multiarch`. This tool will allow remote debugging on the host
|
|
|
|
|
computer. Replace `x86_64` with the correct processor architecture for other architectures.
|
|
|
|
|
This is not required if the `tcf-agent` is used.
|
|
|
|
|
|
2021-05-01 17:48:08 +02:00
|
|
|
|
```sh
|
|
|
|
|
pacman -S mingw-w64-x86_64-gdb-multiarch
|
|
|
|
|
```
|
|
|
|
|
|
2021-05-01 19:12:07 +02:00
|
|
|
|
6. Perform the steps [in the following chapter](#cross-test) to build the
|
|
|
|
|
software for the BBB and test it.
|
2021-05-01 17:48:08 +02:00
|
|
|
|
|
|
|
|
|
## <a id="cross-test"></a> Testing the cross-compilation
|
|
|
|
|
|
|
|
|
|
It is recommended to set the following environmental variables for the CMake build:
|
|
|
|
|
- `CROSS_COMPILE`: Explicitely specify the name of the cross compiler
|
2021-05-01 18:30:59 +02:00
|
|
|
|
- `BBB_ROOTFS`: Explicitely set the path to the local BBB rootfs
|
2021-05-01 17:48:08 +02:00
|
|
|
|
|
|
|
|
|
For example with the following commands
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
export CROSS_COMPILE="arm-linux-gnueabihf"
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
It is recommended to test whether the environmental variables were set correctly,
|
|
|
|
|
for example by running
|
|
|
|
|
|
|
|
|
|
```sh
|
2021-05-01 18:30:59 +02:00
|
|
|
|
echo $BBB_ROOTFS
|
2021-05-01 17:48:08 +02:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
These variables can either be set every time before a debugging session to
|
|
|
|
|
keep the environment clean (should be done before starting Eclipse)
|
|
|
|
|
or permanently by adding the `export` commands to system files.
|
|
|
|
|
|
|
|
|
|
A helper script has been provided in `cmake/scripts/BBB` to perform
|
|
|
|
|
setting up the environment. The scripts need to be `source`d instead of
|
|
|
|
|
being run like regular shell scripts.
|
|
|
|
|
|
|
|
|
|
You can also set up the environmental variables permanently by adding the
|
|
|
|
|
export commands to the `.profile` or `.bashrc` file in the `$HOME` folder.
|
|
|
|
|
On Windows, MinGW64 was used to set up the build system, so you can use the
|
|
|
|
|
MinGW64 `.bashrc` file to do this. If you are using Eclipse to build
|
|
|
|
|
the software, Eclipse will have the system variables from Windows,
|
|
|
|
|
so it is recommended to either permanently set the three environmental
|
|
|
|
|
variables in the Windows system environmental variables or add them in
|
|
|
|
|
Eclipse. See the [Eclipse README](README-eclipse.md#top) for more information.
|
|
|
|
|
|
|
|
|
|
Now we can test whether everything was set up properly by compiling the example
|
|
|
|
|
and running it on the BBB via command line. Navigate into the `fsfw_example` folder first.
|
|
|
|
|
|
|
|
|
|
1. Build the software locally to test the cross-compilation process.
|
|
|
|
|
A debug build directory is created first.
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
mkdir build-Debug-BBB
|
|
|
|
|
cd build-Debug-BBB
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
2. Configure the build system. On Linux, run the following command:
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
cmake -G "Unix Makefiles" -DOS_FSFW=linux -DTGT_BSP=arm/beagleboneblack -DLINUX_CROSS_COMPILE=ON -DCMAKE_BUILD_TYPE=Debug ..
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
On Windows, replace `-G "Unix Makefiles"` with `-G "MinGW Makefiles"`.
|
|
|
|
|
|
|
|
|
|
Alternatively, you can use the helper shell scripts located inside `cmake/scripts/BBB/crosscompile`
|
|
|
|
|
or the Python helper script `cmake_build_config.py` inside the `cmake/scripts` folder.
|
|
|
|
|
The `BBB` folder also contains template shell files which can be `source`d
|
|
|
|
|
to quickly set up the environmental variables if you want to keep the system path clean.
|
|
|
|
|
|
|
|
|
|
3. Run the binary to test it
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
scp fsfw_example <username>@beaglebone.local:/home/fsfw_example
|
|
|
|
|
ssh <username>@beaglebone.local
|
|
|
|
|
./fsfw_example
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Setting up Eclipse for a BBB remote target
|
|
|
|
|
|
|
|
|
|
It is recommended to use the provided Eclipse project files and
|
|
|
|
|
launch configurations to have a starting point. See the specific section in
|
|
|
|
|
the [Eclipse README](README-eclipse.md#top) for information how to do this.
|
|
|
|
|
|
|
|
|
|
#### Windows
|
|
|
|
|
|
|
|
|
|
There are some additional steps necessary on Windows: The cross-compiler by
|
|
|
|
|
default is configured to look for the cross-compiler in `/opt/cross-pi-gcc/bin`.
|
|
|
|
|
The toolchain path needs to be corrected, for example like shown in the following image:
|
|
|
|
|
|
|
|
|
|
<img align="center" src="./images/eclipse/eclipse-cross-compile-win.png" width="50%">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Setting up the TCF agent on the BBB
|
|
|
|
|
|
|
|
|
|
It is recommended to set up a [TCF agent](https://wiki.eclipse.org/TCF) for comfortable
|
|
|
|
|
Eclipse remote debugging. The following steps show how to setup the TCF agent
|
|
|
|
|
on the Raspberry Pi and add it to the auto-startup applications. The steps are taken
|
|
|
|
|
from [this guide](https://wiki.eclipse.org/TCF/Raspberry_Pi)
|
|
|
|
|
|
|
|
|
|
1. Install required packages on the RPi
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
sudo apt-get install git uuid uuid-dev libssl-dev
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
2. Clone the repository and perform some preparation steps
|
|
|
|
|
```sh
|
|
|
|
|
git clone git://git.eclipse.org/gitroot/tcf/org.eclipse.tcf.agent.git
|
|
|
|
|
cd org.eclipse.tcf.agent.git/agent
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
3. Build the TCF agent
|
|
|
|
|
```sh
|
|
|
|
|
make
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
and then test it by running
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
obj/GNU/Linux/arm/Debug/agent –S
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
4. Finally install the agent for auto-start with the following steps. And set it up for
|
|
|
|
|
auto-start.
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
cd org.eclipse.tcf.agent/agent
|
|
|
|
|
make install
|
|
|
|
|
sudo make install INSTALLROOT=
|
|
|
|
|
sudo update-rc.d tcf-agent defaults
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
The [Eclipse README](README-eclipse.md#top) specifies how to perform remote
|
|
|
|
|
debugging using the TCF agent.
|
2021-05-01 19:12:07 +02:00
|
|
|
|
|
|
|
|
|
# <a id="troubleshooting"></a> Troubleshooting
|
|
|
|
|
|
2021-05-02 13:05:04 +02:00
|
|
|
|
## Cloning the root filesystem
|
2021-05-01 19:12:07 +02:00
|
|
|
|
|
|
|
|
|
There might be some issues with the pthread symbolic links.
|
|
|
|
|
Navigate to the folder containing the symlinks
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
cd /c/User/<UserName>/beaglebone/rootfs/usr/lib/arm-linux-gnueabihf
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Type `more libpthread`, press `TAB` and check whether the symbolic
|
|
|
|
|
link `libpthread.so` is shown. If it is not, we are going to set it up
|
|
|
|
|
manually to avoid issues when linking against `pthread` later.
|
|
|
|
|
|
|
|
|
|
Run the following command to create a symlink to `libpthread.so.0`
|
|
|
|
|
|
|
|
|
|
```sh
|
2021-05-02 13:05:04 +02:00
|
|
|
|
scp <user_name>@<ip-address>:/usr/lib/arm-linux-gnueabihf/libpthread.so .
|
2021-05-01 19:12:07 +02:00
|
|
|
|
```
|
|
|
|
|
|
2021-05-02 13:05:04 +02:00
|
|
|
|
Alternatively, you can also create the symlink pointing to the correct library with
|
2021-05-01 19:12:07 +02:00
|
|
|
|
|
|
|
|
|
```sh
|
2021-05-02 13:05:04 +02:00
|
|
|
|
ln -s ../../../lib/arm-linux-gnueabihf/libpthread.so.0 libpthread.so
|
2021-05-01 19:12:07 +02:00
|
|
|
|
```
|
|
|
|
|
|
2021-05-02 13:05:04 +02:00
|
|
|
|
If there are issues with the cross-compilation process, manually copying the following
|
|
|
|
|
symlinks can help:
|
2021-05-01 19:12:07 +02:00
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
scp <user_name>@<ip-address>:/usr/lib/arm-linux-gnueabihf/libc.so <rootfs_path>/usr/lib/arm-linux-gnueabihf
|
|
|
|
|
scp <user_name>@<ip-address>:/usr/lib/arm-linux-gnueabihf/libc.a <rootfs_path>/usr/lib/arm-linux-gnueabihf
|
|
|
|
|
|
|
|
|
|
scp <user_name>@<ip-address>:/usr/lib/arm-linux-gnueabihf/librt.a <rootfs_path>/usr/lib/arm-linux-gnueabihf
|
|
|
|
|
scp <user_name>@<ip-address>:/usr/lib/arm-linux-gnueabihf/librt.so <rootfs_path>/usr/lib/arm-linux-gnueabihf
|
|
|
|
|
|
|
|
|
|
scp <user_name>@<ip-address>:/lib/arm-linux-gnueabihf/librt.so.1 <rootfs_path>/lib/arm-linux-gnueabihf
|
|
|
|
|
scp <user_name>@<ip-address>:/lib/arm-linux-gnueabihf/libpthread.so.0 <rootfs_path>/lib/arm-linux-gnueabihf
|
|
|
|
|
scp <user_name>@<ip-address>:/lib/arm-linux-gnueabihf/ld-linux-armhf.so.3 <rootfs_path>/lib/arm-linux-gnueabihf
|
|
|
|
|
scp <user_name>@<ip-address>:/lib/arm-linux-gnueabihf/libc.so.6 <rootfs_path>/lib/arm-linux-gnueabihf
|
2021-05-02 13:05:04 +02:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
If any custom libraries are used which rely on symlinks, it might be necessary to copy them
|
|
|
|
|
or create them manually as well.
|