The real-time operating system for Brown Space Engineering’s second satellite, Perovskite Visuals and Degredation eXperiment (PVDX).
Project Setup and Toolchain Installation Guide
Building and Running:
Note: If you’re using a factory-new devboard that you’ve just unboxed, please follow these instructions first before continuing. If you’ve received a working devboard from another team member, you can continue.
Start the SEGGER GDB Server:
run JLinkGDBServer from the SEGGER folder containing all the J-Link tools.
Before clicking ‘OK’, make sure the target is set to ATSAMD51P20A, and the interface is set to SWD
WINDOWS/WSL ONLY: The “Localhost Only” checkbox must be unchecked.
Ensure the J-Link server is on port 2331 for GDB connections.
Build the Project:
Execute make to build the project.
Flash the Bootloader:
If you’re using a brand-new devboard, you must flash the bootloader. This is done by running make flash_bootloader. Once GDB starts up successfully, you can exit gdb.
If you’re using a devboard that has already been set up, you can usually skip this step, but it never hurts!
If/When the bootloader gets an update, you can update it by running make flash_bootloader again.
Connect and Run:
Use make connect to connect to the board and auto-flash/run the program.
The code will automatically pause at the top of the ‘main’ function. Set any breakpoints you need, and then continue running the program with ‘c’
To connect to the PVDXos Shell, use Telnet to establish a connection to localhost:19021. You can use PuTTY for this on Windows, or nc localhost 19021 to connect with netcat on a Mac/Linux terminal
If using PuTTY, go to ‘Terminal’ and check the box for ‘Implicit CR in every LF’ so that line endings work correctly
Log output can be viewed by running python3 scripts/rtt_logs.py in a separate terminal window. This will also record logs to the /logs folder.
If the script fails to run, you may need to install ‘pylink-square’ (pip install pylink-square)
Alternatively, you can try running python3 scripts/rtt_splitscreen.py for both the PVDXos Shell and log output in the same terminal window, but this might not work!
Run wsl --install in PowerShell (as Administrator).
Follow prompts and restart your computer as required.
Clone the repository into the WSL filesystem. This is important for performance during compilation.
Install ARM toolchain for Linux:
sudo apt install gcc-arm-none-eabi
Install GDB Multiarch and other build tools:
sudo apt install gdb-multiarch
sudo apt install build-essential
sudo apt install clang-format
(Optional) Configure VSCode to use clang-format for formatting:
Install the clang-format extension in VSCode.
In VSCode properties, set the default formatter to clang-format.
Enable ‘format on save’ in the settings.
Set ‘format on save mode’ to ‘modifications’.
Mac/Linux (Geared towards Mac)
Note: Skip to step 5 if you have a Mac with an Intel processor.
Edit the ~/.zshrc file:
You can use nano ~/.zshrc to edit this file. Use CTRL+X, then Y, then Enter to quit and save.
Add these lines to the bottom of the file:
alias arm="env /usr/bin/arch -arm64 /bin/zsh --login"
alias intel="env /usr/bin/arch -x86_64 /bin/zsh --login"
Run source ~/.zshrc.
This should enable the arm and intel commands in your terminal. Test this out by running intel and checking that the result of running arch is i386. Then run arm and check that the result of arch is arm64.
Switch into an intel terminal by running the intel command you just created, and verify that the arch command returns i386
Install brew in the intel terminal by running the script at https://brew.sh/ and following the prompts
Note: After the Brew installation is complete, it will prompt you to run two other commands. Remember to copy/paste them into the terminal and run these as well.
IMPORTANT: Remember to replace <VersionNumber> with the version number of the toolchain you downloaded. It should be something like ‘13.2.Rel1’
Install other build tools:
brew install gnu-sed (if on mac)
brew install clang-format
(Optional) Configure VSCode to use clang-format for formatting:
Install the clang-format extension in VSCode.
In VSCode properties, set the default formatter to clang-format.
Enable ‘format on save’ in the settings.
Set ‘format on save mode’ to ‘modifications’.
Setting Up a Brand New Metro M4 Grand Central Devboard
The Grand Central runs on an Atmel SAMD51P20A, which has a BOOTPROT fuse protecting the flash area of the bootloader. If you have a factory-new board, you will need to clear the BOOTPROT fuse to allow your J-Link to flash code onto the board.
PVDXos
The real-time operating system for Brown Space Engineering’s second satellite, Perovskite Visuals and Degredation eXperiment (PVDX).
Project Setup and Toolchain Installation Guide
Building and Running:
Start the SEGGER GDB Server:
JLinkGDBServer
from the SEGGER folder containing all the J-Link tools.ATSAMD51P20A
, and the interface is set toSWD
Build the Project:
make
to build the project.Flash the Bootloader:
make flash_bootloader
. Once GDB starts up successfully, you can exit gdb.make flash_bootloader
again.Connect and Run:
make connect
to connect to the board and auto-flash/run the program.nc localhost 19021
to connect with netcat on a Mac/Linux terminalpython3 scripts/rtt_logs.py
in a separate terminal window. This will also record logs to the/logs
folder.pip install pylink-square
)python3 scripts/rtt_splitscreen.py
for both the PVDXos Shell and log output in the same terminal window, but this might not work!Toolchain Installation
All Platforms (Initial Step)
Windows
Install Windows Subsystem for Linux (WSL):
wsl --install
in PowerShell (as Administrator).Clone the repository into the WSL filesystem. This is important for performance during compilation.
Install ARM toolchain for Linux:
sudo apt install gcc-arm-none-eabi
Install GDB Multiarch and other build tools:
sudo apt install gdb-multiarch
sudo apt install build-essential
sudo apt install clang-format
(Optional) Configure VSCode to use clang-format for formatting:
clang-format
extension in VSCode.clang-format
.Mac/Linux (Geared towards Mac)
Edit the
~/.zshrc
file:nano ~/.zshrc
to edit this file. UseCTRL
+X
, thenY
, thenEnter
to quit and save.Run
source ~/.zshrc
.arm
andintel
commands in your terminal. Test this out by runningintel
and checking that the result of runningarch
isi386
. Then runarm
and check that the result ofarch
isarm64
.Switch into an intel terminal by running the
intel
command you just created, and verify that thearch
command returnsi386
Install brew in the intel terminal by running the script at https://brew.sh/ and following the prompts
Install gdb:
brew install gdb
Download Arm Developer Tools:
Add the Arm Developer Tools to your path by adding the following line to the bottom of the
~/.zshrc
(or~/.bash_profile
) file, similar to step 1<VersionNumber>
with the version number of the toolchain you downloaded. It should be something like ‘13.2.Rel1’Install other build tools:
brew install gnu-sed
(if on mac)brew install clang-format
(Optional) Configure VSCode to use clang-format for formatting:
clang-format
extension in VSCode.clang-format
.Setting Up a Brand New Metro M4 Grand Central Devboard
The Grand Central runs on an Atmel SAMD51P20A, which has a
BOOTPROT
fuse protecting the flash area of the bootloader. If you have a factory-new board, you will need to clear theBOOTPROT
fuse to allow your J-Link to flash code onto the board.Tools > Device Programming
.Tool > J-Link
,Device > ATSAMD51P20
, andInterface > SWD
. ClickApply
.Read
. The empty fields for ‘Device Signature’ and ‘Target Voltage’ will populate.Fuses
.USER_WORD_0.NVMCTRL_BOOTPROT
to0x0F
or0 kbytes
(whichever shows up).Program
and thenVerify
to make sure the fuse has been set correctly.That should be it. The J-Link GDB Server should now work as expected. Congrats on setting up your brand-new devboard!
Adding a New File to the Project
Take 30 full seconds to think about the scope and name of this file:
Modify the
Makefile
to add the new file to the list of objects to be compiled:If anything gives you trouble, run a quick
make clean
to clear out any old object filesHow to Update the ASF Library:
atmel_start_config.atstart
file in the root of this repository to import the project.ASF.atzip
. Do not change this name.ASF.atzip
file in the root of this repository.make update_asf
to update the ASF library. This will completely wipe the ASF folder, so be careful!make update_asf
completes. Try tomake clean
andmake
to verify it all works.