Skip to content

Commit

Permalink
Merge pull request #4 from PeakSat/hotfix-eqm
Browse files Browse the repository at this point in the history
fetch mram settings
  • Loading branch information
Sourland committed Jan 25, 2024
2 parents 089352d + 388ae8b commit a818ce8
Show file tree
Hide file tree
Showing 54 changed files with 3,559 additions and 249 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,4 @@ CMakeUserPresets.json

# These folders are cloned by conan, so there isn't a need to track them.
lib/atsam-component-drivers
lib/cross-platform-software
lib/cobs-c
4 changes: 0 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +0,0 @@
[submodule "lib/cobs-c"]
path = lib/cobs-c
url = [email protected]:cmcqueen/cobs-c.git

3 changes: 1 addition & 2 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

128 changes: 67 additions & 61 deletions AutoGenerated.X/nbproject/Makefile-default.mk

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions AutoGenerated.X/nbproject/Makefile-local-default.mk
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,24 @@
# You can invoke make with the values of the macros:
# $ makeMP_CC="/opt/microchip/mplabc30/v3.30c/bin/pic30-gcc" ...
#
PATH_TO_IDE_BIN=/opt/microchip/mplabx/v6.05/mplab_platform/platform/../mplab_ide/modules/../../bin/
PATH_TO_IDE_BIN=/opt/microchip/mplabx/v6.00/mplab_platform/platform/../mplab_ide/modules/../../bin/
# Adding MPLAB X bin directory to path.
PATH:=/opt/microchip/mplabx/v6.05/mplab_platform/platform/../mplab_ide/modules/../../bin/:$(PATH)
PATH:=/opt/microchip/mplabx/v6.00/mplab_platform/platform/../mplab_ide/modules/../../bin/:$(PATH)
# Path to java used to run MPLAB X when this makefile was created
MP_JAVA_PATH="/opt/microchip/mplabx/v6.05/sys/java/zulu8.64.0.19-ca-fx-jre8.0.345-linux_x64/bin/"
MP_JAVA_PATH="/opt/microchip/mplabx/v6.00/sys/java/zulu8.54.0.21-ca-fx-jre8.0.292-linux_x64/bin/"
OS_CURRENT="$(shell uname -s)"
MP_CC="/usr/bin/arm-none-eabi-gcc"
MP_CPPC="/usr/bin/arm-none-eabi-g++"
# MP_BC is not defined
MP_AS="/usr/bin/arm-none-eabi-as"
MP_LD="/usr/bin/arm-none-eabi-ld"
MP_AR="/usr/bin/arm-none-eabi-ar"
DEP_GEN=${MP_JAVA_PATH}java -jar "/opt/microchip/mplabx/v6.05/mplab_platform/platform/../mplab_ide/modules/../../bin/extractobjectdependencies.jar"
DEP_GEN=${MP_JAVA_PATH}java -jar "/opt/microchip/mplabx/v6.00/mplab_platform/platform/../mplab_ide/modules/../../bin/extractobjectdependencies.jar"
MP_CC_DIR="/usr/bin"
MP_CPPC_DIR="/usr/bin"
# MP_BC_DIR is not defined
MP_AS_DIR="/usr/bin"
MP_LD_DIR="/usr/bin"
MP_AR_DIR="/usr/bin"
DFP_DIR=/opt/microchip/mplabx/v6.05/packs/Microchip/SAMV71_DFP/4.9.117
CMSIS_DIR=/opt/microchip/mplabx/v6.05/packs/arm/CMSIS/5.4.0
# MP_BC_DIR is not defined
CMSIS_DIR=/opt/microchip/mplabx/v6.00/packs/arm/CMSIS/5.4.0
22 changes: 11 additions & 11 deletions AutoGenerated.X/nbproject/configurations.xml
Original file line number Diff line number Diff line change
Expand Up @@ -320,23 +320,23 @@
displayName="Important Files"
projectFiles="false">
<logicalFolder name="f1" displayName="default.mhc" projectFiles="true">
<itemPath>../src/config/default/default.mhc/settings.yml</itemPath>
<itemPath>../src/config/default/default.mhc/HarmonyCore.yml</itemPath>
<itemPath>../src/config/default/default.mhc/afec0.yml</itemPath>
<itemPath>../src/config/default/default.mhc/cmsis.yml</itemPath>
<itemPath>../src/config/default/default.mhc/smc.yml</itemPath>
<itemPath>../src/config/default/default.mhc/project.yml</itemPath>
<itemPath>../src/config/default/default.mhc/GraphSettings.yml</itemPath>
<itemPath>../src/config/default/default.mhc/uart0.yml</itemPath>
<itemPath>../src/config/default/default.mhc/core.yml</itemPath>
<itemPath>../src/config/default/default.mhc/mcan1.yml</itemPath>
<itemPath>../src/config/default/default.mhc/efc.yml</itemPath>
<itemPath>../src/config/default/default.mhc/dfp.yml</itemPath>
<itemPath>../src/config/default/default.mhc/sys_time.yml</itemPath>
<itemPath>../src/config/default/default.mhc/afec0.yml</itemPath>
<itemPath>../src/config/default/default.mhc/rtc.yml</itemPath>
<itemPath>../src/config/default/default.mhc/settings.yml</itemPath>
<itemPath>../src/config/default/default.mhc/twihs1.yml</itemPath>
<itemPath>../src/config/default/default.mhc/efc.yml</itemPath>
<itemPath>../src/config/default/default.mhc/smc.yml</itemPath>
<itemPath>../src/config/default/default.mhc/pwm0.yml</itemPath>
<itemPath>../src/config/default/default.mhc/core.yml</itemPath>
<itemPath>../src/config/default/default.mhc/uart0.yml</itemPath>
<itemPath>../src/config/default/default.mhc/GraphSettings.yml</itemPath>
<itemPath>../src/config/default/default.mhc/mcan0.yml</itemPath>
<itemPath>../src/config/default/default.mhc/twihs1.yml</itemPath>
<itemPath>../src/config/default/default.mhc/dfp.yml</itemPath>
<itemPath>../src/config/default/default.mhc/project.yml</itemPath>
<itemPath>../src/config/default/default.mhc/cmsis.yml</itemPath>
</logicalFolder>
<itemPath>Makefile</itemPath>
<itemPath>../src/config/default/harmony-manifest-success.yml</itemPath>
Expand Down
12 changes: 7 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ find_package(ecss-services CONFIG REQUIRED COMPONENTS common)

include_directories(.)
include_directories(inc)
include_directories(inc/Platform)
include_directories(inc/FreeRTOSTasks)
include_directories(inc/Platform)
include_directories(inc/Platform/Parameters)
include_directories(inc/Platform/CAN)
include_directories(inc/Helpers)
include_directories(src)
include_directories(src/config)
Expand Down Expand Up @@ -65,18 +66,19 @@ include_directories(lib/atsam-component-drivers/SMC/inc)
include_directories(lib/atsam-component-drivers/MRAM/inc)
include_directories(lib/atsam-component-drivers/LCL/inc)
include_directories(lib/atsam-component-drivers/NANDFlash/inc)
include_directories(lib/cross-platform-software)
add_subdirectory(lib/cross-platform-software)
include_directories(lib/atsam-component-drivers/NANDFlash/MT29F_Nand_Driver_Micron)
include_directories(lib/atsam-component-drivers/NANDFlash/src)
include_directories(lib/cobs-c)

file(GLOB_RECURSE DRIVER_SOURCES "lib/atsam-component-drivers/MCP9808/*.cpp" "lib/atsam-component-drivers/LCL/*.cpp"
"lib/atsam-component-drivers/NANDFlash/*.cpp")
file(GLOB_RECURSE SOURCES "src/*.c" "src/*.cpp" "lib/SEGGER/RTT/*.c" "AutoGenerated.X/*.c")
file(GLOB_RECURSE FREERTOS_SOURCES "lib/FreeRTOS/*.c")
file(GLOB_RECURSE EXTRA_SOURCES "lib/cobs-c/cobs.c" "lib/cobs-c/cobsr.c")

add_executable(${PROJECT_NAME}.elf ${SOURCES} ${LINKER_SCRIPT} ${FREERTOS_SOURCES} ${DRIVER_SOURCES})
add_executable(${PROJECT_NAME}.elf ${SOURCES} ${LINKER_SCRIPT} ${FREERTOS_SOURCES} ${DRIVER_SOURCES} ${EXTRA_SOURCES})

target_link_libraries(${PROJECT_NAME}.elf PRIVATE common common_cross etl log_common)
target_link_libraries(${PROJECT_NAME}.elf PRIVATE common etl log_common)

set(CMAKE_EXE_LINKER_FLAGS
"${CMAKE_EXE_LINKER_FLAGS_INIT} -Wl,-Map=${PROJECT_BINARY_DIR}/${PROJECT_NAME}.map")
Expand Down
153 changes: 114 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,75 @@
# OBC Software Repository
# OBC Software EQM Repository

In this repository is where all of the OBC Software is housed. This is the final version that will be used on the satellite.
In this repository is where all of the OBC EQM Software is housed. This is the final version that will be used on the satellite.
The software runs on the Microchip ATSAMV71Q21B Microcontroller Unit, which is a 32-bit ARM Cortex-M7 core.
We use FreeRTOS to handle the tasking of the MCU.
More information regarding OBC can be found [here](https://gitlab.com/groups/acubesat/obc/-/wikis/home).

There is the `env-tests` branch that contains the test code, to be used in the Environmental Tests campaign.

## Build
The `eqm` repository can be built without any access to specialised hardware. We provide build
instructions for Linux (or WSL) command-line, and the CLion IDE.

The dependencies of this repository are managed through the [conan](https://conan.io/) package manager, with repositories
from [ConanCenter](https://conan.io/center/) and [SpaceDot's packages](https://artifactory.spacedot.gr).

For more detailed installation instructions, including how to integrate with a microcontroller, visit the
[corresponding documentation page](https://acubesat.gitlab.io/obc/ecss-services/docs/md_docs_installation.html).

### From the Command Line (CLI)

1. Install a modern C++ compiler, CMake, and Conan.
CMake >= 3.23 and Conan >= 2.0 are recommended.
<details>
<summary>Getting conan</summary>

You can install [conan](https://conan.io/) following the instructions [from here](https://docs.conan.io/2/installation.html).
</details>
2. Clone the repository and enter the directory:
```shell
git clone [email protected]:acubesat/obc/environmental-campaign/obc-eqm-software.git
cd obc-eqm-software
```
3. (If you haven't already) create a conan profile for your system:
```shell
conan profile detect
```
4. (If you haven't already) add the SpaceDot repository to conan:
```shell
conan remote add spacedot https://artifactory.spacedot.gr/artifactory/api/conan/conan
```
5. Download all dependencies and build the project through conan:
```shell
conan install . --output-folder=cmake-build-debug --build="*" -u -pr conan-arm-profile
```
6. Download all submodules:
```shell
conan source .
```
7. Add CMake flags:
```shell
cmake -B cmake-build-debug/build/Debug -DCMAKE_TOOLCHAIN_FILE=cmake-build-debug/build/Debug/generators/conan_toolchain.cmake -DCMAKE_CXX_COMPILER="/usr/bin/arm-none-eabi-g++" -DCMAKE_C_COMPILER="/usr/bin/arm-none-eabi-gcc" -DCMAKE_BUILD_TYPE=Debug .
```
8. Build the project:
```shell
cd cmake-build-debug/build/Debug
make
```
### From CLion

CLion will automatically try to set up a CMake project for you. However, without the conan packages installed, this
will quickly fail. Follow these steps to set up the conan project:

1. Follow steps 1-6 from the CLI instructions above.
2. Add the following to the CMake Options (File -> Settings -> Build, Execution, Deployment -> CMake -> CMake Options):
```
-DCMAKE_TOOLCHAIN_FILE=cmake-build-debug/build/Debug/generators/conan_toolchain.cmake -DCMAKE_CXX_COMPILER="/usr/bin/arm-none-eabi-g++" -DCMAKE_C_COMPILER="/usr/bin/arm-none-eabi-gcc"
```
3. If your CMake project doesn't reload automatically, reload it manually (Tools -> CMake -> Reload CMake Project).
We do not recommend using a Conan plugin for your IDE, as it may tamper with the default configuration for this repository.
After cloning the repo, run the command `conan source .` to clone the needed repositories, which currently are:
- [cross-platform-software](https://gitlab.com/acubesat/obc/cross-platform-software)
- [atsam-component-drivers](https://gitlab.com/acubesat/obc/atsam-component-drivers)
If cloning `COBS` throws a permission/access error, setup an SSH key in GitHub to fix it.

If you're using CLion, you need to add in CMake options (File -> Settings -> Build, Execution, Deployment -> CMake ->
CMake Options) this `-DCMAKE_TOOLCHAIN_FILE=cmake-build-debug/build/Debug/generators/conan_toolchain.cmake -DCMAKE_CXX_COMPILER="/usr/bin/arm-none-eabi-g++" -DCMAKE_C_COMPILER="/usr/bin/arm-none-eabi-gcc"`.

If you just cmake from cli, just add the same flags in your command.

To be able to build, however, you need to install the required `conan` packages. See the `Conan` section for more info.

### Conan
This repository uses [conan 2.0](https://conan.io/) to manage dependencies.

#### AcubeSAT Conan Packages
Some of the Conan packages ([logger](https://gitlab.com/acubesat/obc/logger) and [ecss-services](https://gitlab.com/acubesat/obc/ecss-services)) are hosted on a private repository, so you
need to either:
- have access to the [repository](https://artifactory.spacedot.gr) (if you're already on GitLab, it's the same
credentials, and you should login at least once) and add the
remote to your conan remotes. To do that run the following two commands
`conan remote add conan https://artifactory.spacedot.gr/artifactory/api/conan/conan` and
`conan remote login conan $YOUR_USERNAME`, which will prompt you to add your password.
- or, clone the repo on your own, and package it locally use `conan create . --build=missing` in the root of the repo. This way, you don't need to add the remote repository, as conan will add it in local cache.
- or, clone the repo on your own and add it as a submodule in the `lib` folder, and make the necessary CMakeLists.
txt changes to include it in the build.

To install the necessary packages, you need to follow these steps:
- Make sure you performed one of the `AcubeSAT Conan Packages` sections teps
- Run `conan profile detect --force`: Generates default profile detecting GCC. However, for this project, you need to set up
the correct architecture. Find where `conan` sets up profiles (probably `~/.conan2/profiles`) and run `cp conan-arm-profile ~/.conan2/profiles` (or another directory if conan2 stores the profiles elsewhere) in this project's folder.
- Then run `conan install . --output-folder=cmake-build-debug --build="*" -u -pr conan-arm-profile`. If you're using CLion and don't see `cmake-build-debug`, you have to `Reload CMake project` to have it generated.
After you've run `conan install...` you can `Reload CMake project` and build as per usual.
- Make sure you followed the steps under the `Build` section
- If the *Imported target "common" included non-existent path* appears, just delete the `cmake-build-debug` folder and redo the `conan install...` command
<details>
<summary>Getting conan</summary>
Expand All @@ -52,7 +78,6 @@ You can install [conan](https://conan.io/) following the instructions from
[here](https://docs.conan.io/2/installation.html).:
</details>

## Implemented Software
Prototypes of ECSS Services
Expand All @@ -69,7 +94,57 @@ Peripherals:
- UART with DMA
- Parameter updating of ST[20]

## Note
## Using Minicom to monitor the U(S)ART of ATSAM

#### Downloading Minicom

`minicom` is found in almost all package managers for Linux and macOS. For Linux you can use:

For Pop/Ubuntu/Debian derivatives
```shell
sudo apt install minicom
```

For Fedora
```shell
sudo dnf install minicom
```

For Arch
```shell
sudo pacman -S minicom
```

#### Running minicom

`minicom` is a program that displays the serial input of a port on your computer. To run it, you must specify such a port.

On Linux systems, the serial ports for connected embedded devices are `/dev/ttyACMX`, where X is a number. The first device you connect will start at 0, and each new device increases the number by 1. Note that removing a device "frees" the port, so if you have two devices connnected and you remove the first, `/dev/ttyACM0` will be disconnected while `/dev/ttyACM1` will be connected to the remaining target device. When using `UART-to-USB` devices such as an `FTDI`, the naming scheme changes and the devices will be at `/dev/ttyUSBX`, however the above scheme remains the same.

You can use the command `ls /dev/ttyACM*` to view all connected devices on the `/dev/ttyACMX` spectrum.
If a device is connected to port `/dev/ttyACM0`, you can use:
```shell
minicom -D /dev/ttyACM0
```
to get its ouput.

#### Using minicom

All actions inside the program require pressing the `Meta` key first. If you want to exit the program, you need to press `Meta`, then `x`. On Linux the `Meta` key is `CTRL+A`, while on macOS it is `Escape`. You can use `Meta`, then `z` to view a list of shortcuts.

#### Line Feeds

Our embedded devices send only a `\n` delimiter on the end of each log message. Thus, when you open the `minicom` instance, you will see that each line starts at the end of the previous line. After a couple of log messages, the new lines will start at the right edge of the screen and the messages will be invisible. To control this, you can press `Meta`, then `u` to toggle interpreting `\n` as `\r\n`. Each new message will now start at the beginning of the next line.

#### Saving output to file

In case you need to save the output of a session to a file, use the option `-C filename.txt` when opening the program. For example:
```shell
minicom -D /dev/ttyACM0 -C output.txt
```
will save the logs to the file `output.txt` in your current directory.

## Watchdog

The internal watchdog has been disabled for debugging reasons.

Expand Down
3 changes: 1 addition & 2 deletions atmel_samv71_xplained_ultra.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
set CHIPNAME samv71

source [find interface/stlink.cfg]
source [find target/atsamv.cfg]

source [find target/atsamv.cfg]
14 changes: 6 additions & 8 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@


class EQMSoftwareRecipe(ConanFile):
name = "obc-adcs-eqm-sw"
name = "obc-eqm-sw"
version = "1.0"
revision_mode = "scm"

# Optional metadata
license = "MIT"
author = "SpaceDot - AcubeSAT, [email protected]"
url = "https://gitlab.com/acubesat/obc/environmental-campaign/obc-eqm-software/"
description = "EQM Software for OBC-ADCS campaign test"
topics = ("satellite", "acubesat", "obc", "obc-software")
url = "https://github.com/PeakSat/OBC-EQM-Software"
description = "EQM Software for OBCcampaign test"
topics = ("satellite", "peaksat", "obc", "obc-software")

# Binary configuration
settings = "os", "compiler", "build_type", "arch"
Expand All @@ -34,12 +34,10 @@ def config_options(self):

def source(self):
git = Git(self)
git.clone(url="[email protected]:acubesat/obc/cross-platform-software.git", target=join(str(self.source_folder), "lib/cross-platform-software"))
self.run("cd lib/cross-platform-software && git submodule update --init --recursive")
self.run("cd lib/cross-platform-software && git checkout campaign-obc")
git.clone(url="[email protected]:cmcqueen/cobs-c.git", target=join(str(self.source_folder), "lib/cobs-c"))
git = Git(self)
git.clone(url="[email protected]:acubesat/obc/atsam-component-drivers.git", target=join(str(self.source_folder), "lib/atsam-component-drivers"))
self.run("cd lib/atsam-component-drivers && git checkout NAND-implementation")
self.run("cd lib/atsam-component-drivers && git checkout NAND-partial-implementation")

def layout(self):
cmake_layout(self)
Expand Down
Loading

0 comments on commit a818ce8

Please sign in to comment.