SD Card, Scratch Buffer and README updates #52

Merged
meierj merged 41 commits from mueller/first-sd-tests into develop 2021-07-09 22:02:31 +02:00
2 changed files with 133 additions and 129 deletions
Showing only changes of commit afbd70b7fe - Show all commits

232
README.md
View File

@ -1,6 +1,7 @@
# <a id="top"></a> <a name="linux"></a> EIVE On-Board Software
<a id="top"></a> <a name="linux"></a> EIVE On-Board Software
======
## General information
# General information
Target systems:
@ -28,9 +29,9 @@ The CMake build system can be used to generate build systems as well (see helper
- Linux Host: Uses the `bsp_hosted` BSP folder and the CMake Unix Makefiles generator.
- Windows Host: Uses the `bsp_hosted` BSP folder, the CMake MinGW Makefiles generator and MSYS2.
## Setting up development environment
# Setting up development environment
### Installing Vivado the the Xilinx development tools
## Installing Vivado the the Xilinx development tools
It's also possible to perform debugging with a normal Eclipse installation by installing
the TCF plugin and downloading the cross-compiler as specified in the section below.
@ -40,18 +41,19 @@ the TCF plugin and downloading the cross-compiler as specified in the section be
* Install settings. In the Devices selection, it is sufficient to pick SoC &rarr; Zynq-7000: <br>
<img src="https://egit.irs.uni-stuttgart.de/eive/eive-obsw/src/branch/develop/doc/img/vivado-edition.png" width="50%"> <br>
<img src="./doc/img/vivado-edition.png" width="50%"> <br>
<img src="https://egit.irs.uni-stuttgart.de/eive/eive-obsw/src/branch/develop/doc/img/vivado-hl-design.png" width="50%"> <br>
<img src="./doc/img/vivado-hl-design.png" width="50%"> <br>
<img src="https://egit.irs.uni-stuttgart.de/eive/eive-obsw/src/branch/develop/doc/img/xilinx-install.PNG" width="50%"> <br>
<img src="./doc/img/xilinx-install.PNG" width="50%"> <br>
* For supported OS refer to https://www.xilinx.com/support/documentation/sw_manuals/xilinx2018_2/ug973-vivado-release-notes-install-license.pdf
* Add path of linux cross-compiler to permanent environment variables (`.profile` file in Linux):
* For supported OS refer to https://www.xilinx.com/support/documentation/sw_manuals/xilinx2018_2/ug973-vivado-release-notes-install-license.pdf .
Installation was tested on Windows and Ubuntu 21.04.
* Add path of linux cross-compiler to permanent environment variables (`.bashrc` file in Linux):
`<XilinxInstallation>\SDK\2018.2\gnu\aarch32\nt\gcc-arm-linux-gnueabi\bin`
or set up path each time before debugging.
### Installing toolchain without Vivado
## Installing toolchain without Vivado
You can download the toolchains for Windows and Linux
[from the EIVE cloud](https://eive-cloud.irs.uni-stuttgart.de/index.php/apps/files?dir=/EIVE_IRS/Software/tools&fileid=831898).
@ -69,7 +71,7 @@ or the following command for Linux (could be useful for CI/CD)
wget https://eive-cloud.irs.uni-stuttgart.de/index.php/s/2Fp2ag6NGnbtAsK/download/gcc-arm-linux-gnueabi.tar.gz
```
### Installing CMake and MSYS2 on Windows
## Installing CMake and MSYS2 on Windows
1. Install [MSYS2](https://www.msys2.org/) and [CMake](https://cmake.org/download/) first.
@ -94,7 +96,7 @@ wget https://eive-cloud.irs.uni-stuttgart.de/index.php/s/2Fp2ag6NGnbtAsK/downloa
pacman -S mingw-w64-x86_64-cmake mingw-w64-x86_64-make mingw-w64-x86_64-gcc mingw-w64-x86_64-gdb python3
```
### Installing CMake on Linux
## Installing CMake on Linux
1. Run the following command
@ -117,7 +119,7 @@ wget https://eive-cloud.irs.uni-stuttgart.de/index.php/s/agnJGYeRf6fw2ci/downloa
Then, create a new environmental variables `Q7S_SYSROOT` and set it to the local system root path.
## Building the software with CMake
# Building the software with CMake
When using Windows, run theses steps in MSYS2.
@ -153,7 +155,7 @@ When using Windows, run theses steps in MSYS2.
```sh
cd cmake/scripts/Q7S
./create_cmake_debug.sh
./make_debug_cfg.sh
cd ../../..
```
@ -230,7 +232,7 @@ IP address and path settings differ from machine to machine.
You can run it manually there. To perform auto-start on boot, have a look at the start-up
application section.
## Debugging the software via Flatsat PC
# Debugging the software via Flatsat PC
Open SSH connection to flatsat PC:
@ -269,7 +271,8 @@ the process using it with `q7s_kill`.
You can use `AltGr` + `X` to exit the picocom session.
To debug an application, first make sure a static IP address is assigned to the Q7S. Run ifconfig on the Q7S serial console.
To debug an application, first make sure a static IP address is assigned to the Q7S. Run ifconfig
on the Q7S serial console.
```sh
ifconfig
@ -289,12 +292,14 @@ To launch application from Xilinx SDK setup port fowarding on the development ma
ssh -L 1534:192.168.133.10:1534 eive@2001:7c0:2018:1099:babe:0:e1fe:f1a5 -t bash
```
This forwards any requests to localhost:1534 to the port 1534 of the Q7S with the IP address 192.168.133.10.
This forwards any requests to localhost:1534 to the port 1534 of the Q7S with the IP address
192.168.133.10.
This needs to be done every time, so it is recommended to create an alias to do this quickly.
Note: When now setting up a debug session in the Xilinx SDK, the host must be set to localhost instead of the IP address of the Q7S.
Note: When now setting up a debug session in the Xilinx SDK or Eclipse, the host must be set
to localhost instead of the IP address of the Q7S.
## Transfering files via SCP
# Transfering files via SCP
To transfer files from the local machine to the Q7S, use port forwarding
@ -318,11 +323,11 @@ From a windows machine files can be copied with putty tools (note: use IPv4 addr
pscp -scp -P 22 eive@192.168.199.227:</directory-to-example-file/>/example-file </windows-machine-path/>
````
## Launching an application at start-up
# Launching an application at start-up
Load the root partiton from the flash memory (there are to nor-flash memories and each flash holds two xdi images).
Note: It is not possible to modify the currently loaded root partition, e.g. creating directories. To do this,
the parition needs to be mounted.
Load the root partiton from the flash memory (there are to nor-flash memories and each flash holds
two xdi images). Note: It is not possible to modify the currently loaded root partition, e.g.
creating directories. To do this, the parition needs to be mounted.
1. Disable write protection of the desired root partition
@ -340,11 +345,13 @@ the parition needs to be mounted.
3. Copy the executable to `/usr/bin`
4. Make sure the permissions to execute the application are set
```sh
chmod +x application
```
5. Create systemd service in /lib/systemd/system. The following shows an example service.
```sh
cat > example.service
[Unit]
@ -361,8 +368,8 @@ the parition needs to be mounted.
[Install]
WantedBy=multi-user.target
```
6. Enable the service. This is normally done with systemctl enable. However, this is not possible when the service is
created for a mounted root partition. Therefore create a symlink as follows.
6. Enable the service. This is normally done with systemctl enable. However, this is not possible
when the service is created for a mounted root partition. Therefore create a symlink as follows.
```sh
ln -s '/tmp/the-mounted-xdi-image/lib/systemd/system/example.service' '/tmp/the-mounted-xdi-image/etc/systemd/system/multi-user.target.wants/example.service'
```
@ -380,37 +387,14 @@ the parition needs to be mounted.
```sh
systemctl status example
```
More detailed information about the used q7s commands can be found in the Q7S user manual.
### Bringing up CAN
```sh
ip link set can0 down
ip link set can0 type can loopback off
ip link set can0 up type can bitrate 1000000
```
Following command sends 8 bytes to device with id 99 (for petalinux)
````
cansend can0 -i99 99 88 77 11 33 11 22 99
````
For Q7S use this:
````
cansend can0 5A1#11.22.33.44.55.66.77.88
````
Turn loopback mode on:
````
ip link set can0 type can bitrate 1000000 loopback on
````
Reading data from CAN:
````
candump can0
````
## Setting up UNIX environment for real-time functionalities
Please note that on most UNIX environments (e.g. Ubuntu), the real time functionalities
used by the UNIX pthread module are restricted, which will lead to permission errors when creating these tasks
and configuring real-time properites like scheduling priorities.
used by the UNIX pthread module are restricted, which will lead to permission errors when creating
these tasks and configuring real-time properites like scheduling priorities.
To solve this issues, try following steps:
@ -435,13 +419,16 @@ required for some framework components. The recommended values for the new messa
length is 130.
2. Edit the /etc/sysctl.conf file
```sh
sudo nano /etc/sysctl.conf
```
Append at end:
```sh
fs/mqueue/msg_max = <newMsgMaxLen>
```
Apply changes with:
```sh
sudo sysctl -p
@ -451,42 +438,8 @@ A possible solution which only persists for the current session is
```sh
echo <newMsgMax> | sudo tee /proc/sys/fs/mqueue/msg_max
```
or running the `unlockRealtime` script.
3. Run the shell script inside the linux folder
```sh
./unlockRealtime
```
This script executes the `sudo setcap 'cap_sys_nice=eip' \<application\>`
command on the binaries, increases the soft real time limit of the current
session and increases the maximum number of message queues by setting
`/proc/sys/fs/mqueue/msg_max`.
All changes are only applied for the current session (read 2. and 3. for
a permanent solution). If running the script before executing the binary does
not help or an warning is issue that the soft real time value is invalid,
the hard real-time limit of the system might not be high enough (see step 1).
## Flight Software Framework (FSFW)
An EIVE fork of the FSFW is submodules into this repository.
To add the master upstream branch and merge changes and updates from it
into the fork, run the following command in the fsfw folder first:
```sh
git remote add upstream https://egit.irs.uni-stuttgart.de/fsfw/fsfw.git
git remote update --prune
```
After that, an update can be merged by running
```sh
git merge upstream/master
```
Alternatively, changes from other upstreams (forks) and branches can be merged like that in
the same way.
## PCDU
# PCDU
Connect to serial console of P60 Dock
````
@ -511,10 +464,11 @@ p60-dock # param get out_en[0]
GET out_en[0] = 1
````
## Debugging the software (when workstation is directly conncected to Q7S)
# Debugging the software (when workstation is directly conncected to Q7S)
1. Assign static IP address to Q7S
* Open serial console of Q7S (Accessible via the micro-USB of the PIM, see also Q7S user maunal chapter 10.3)
* Open serial console of Q7S (Accessible via the micro-USB of the PIM, see also Q7S user
manual chapter 10.3)
* Baudrate 115200
* Login to Q7S:
* user: root
@ -562,10 +516,10 @@ GET out_en[0] = 1
11. Test connection (This ensures the TCF Agent is running on the Q7S)
12. Select Application tab
* Project Name: eive_obsw
* Local File Path: Path to eiveobsw-linux.elf (in _bin\linux\devel)
* Remote File Path: /tmp/eive_obsw.elf
* Local File Path: Path to eiveobsw-linux.elf (in `_bin\linux\devel`)
* Remote File Path: `/tmp/eive_obsw.elf`
## Running cppcheck on the Software
# Running cppcheck on the Software
Static code analysis can be useful to find bugs.
`cppcheck` can be used for this purpose. On Windows you can use MinGW64 to do this.
@ -597,6 +551,15 @@ Finally, you can convert the generated `.xml` file to HTML with the following co
cppcheck-htmlreport --file=report.xml --report-dir=cppcheck --source-dir=..
```
# Special notes on Eclipse
When using Eclipse, there are two special build variables in the project properties
&rarr; C/C++ Build &rarr; Build Variables called `Q7S_SYSROOT` or `RPI_SYSROOT`. You can set
the sysroot path in those variables to get any additional includes like `gpiod.h` in the
Eclipse indexer.
# Q7S Utilities
## Libgpiod
Detect all gpio device files:
@ -626,7 +589,54 @@ gpioget <gpiogroup> <offset>
Example to get state:
gpioget gpiochip7 14
## Running the EIVE OBSW on a Raspberry Pi
## Xilinx UARTLIE
Get info about ttyUL* devices
````
cat /proc/tty/driver
````
## I2C
Getting information about I2C device
````
ls /sys/class/i2c-dev/i2c-0/device/device/driver
````
This shows the memory mapping of /dev/i2c-0
## CAN
```sh
ip link set can0 down
ip link set can0 type can loopback off
ip link set can0 up type can bitrate 1000000
```
Following command sends 8 bytes to device with id 99 (for petalinux)
````
cansend can0 -i99 99 88 77 11 33 11 22 99
````
For Q7S use this:
````
cansend can0 5A1#11.22.33.44.55.66.77.88
````
Turn loopback mode on:
````
ip link set can0 type can bitrate 1000000 loopback on
````
Reading data from CAN:
````
candump can0
````
## Useful Q7S Linux Commands
Rebooting currently running image:
````
xsc_boot_copy -r
````
# Running the EIVE OBSW on a Raspberry Pi
Special section for running the EIVE OBSW on the Raspberry Pi.
The Raspberry Pi build uses the `bsp_rpi` BSP folder, and a very similar cross-compiler.
@ -642,28 +652,22 @@ sudo apt-get install gpiod libgpiod-dev
to install the required GPIO libraries before cloning the system root folder.
## Special notes on Eclipse
# Flight Software Framework (FSFW)
When using Eclipse, there are two special build variables in the project properties
&rarr; C/C++ Build &rarr; Build Variables called `Q7S_SYSROOT` or `RPI_SYSROOT`. You can set
the sysroot path in those variables to get any additional includes like `gpiod.h` in the
Eclipse indexer.
An EIVE fork of the FSFW is submodules into this repository.
To add the master upstream branch and merge changes and updates from it
into the fork, run the following command in the fsfw folder first:
## Xilinx UARTLIE
Get info about ttyUL* devices
````
cat /proc/tty/driver
````
```sh
git remote add upstream https://egit.irs.uni-stuttgart.de/fsfw/fsfw.git
git remote update --prune
```
## I2C
Getting information about I2C device
````
ls /sys/class/i2c-dev/i2c-0/device/device/driver
````
This shows the memory mapping of /dev/i2c-0
After that, an update can be merged by running
## Useful Q7S Linux Commands
Rebooting currently running image:
````
xsc_boot_copy -r
````
```sh
git merge upstream/master
```
Alternatively, changes from other upstreams (forks) and branches can be merged like that in
the same way.

View File

@ -6,8 +6,8 @@
FileSystemTest::FileSystemTest() {
using namespace std;
SdCard sdCard = SdCard::SDC0;
cout << "SD Card Test for SD card qg" << static_cast<int>(sdCard) << std::endl;
std::system("echo Hello World");
cout << "SD Card Test for SD card " << static_cast<int>(sdCard) << std::endl;
//std::system("echo Hello World");
}
FileSystemTest::~FileSystemTest() {