summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDawsyn Schraiber <[email protected]>2023-11-12 01:06:57 -0500
committerGitHub <[email protected]>2023-11-12 01:06:57 -0500
commitd695dce1a7ea28433db8e893025d1ec66fb077b2 (patch)
tree4089cbc79e9a50b0775ab33e002de03a6f23e77d
parent1b8af4198f7f18ccbfb336709f20a88e26e2b195 (diff)
downloadactive-drag-system-d695dce1a7ea28433db8e893025d1ec66fb077b2.tar.gz
active-drag-system-d695dce1a7ea28433db8e893025d1ec66fb077b2.tar.bz2
active-drag-system-d695dce1a7ea28433db8e893025d1ec66fb077b2.zip
Header styles and file naming conventions; CMake ARM Linux musl Compiler
Co-authored-by: Gregory Wainer <[email protected]>
-rw-r--r--.gitignore17
-rw-r--r--CMakeLists.txt52
-rw-r--r--LICENSE2
-rw-r--r--README.md56
-rw-r--r--Vagrantfile31
-rwxr-xr-xbbb_setup.sh33
-rw-r--r--src/CMakeLists.txt15
-rw-r--r--src/active-drag-system.cpp7
-rw-r--r--src/active_drag_system.cpp32
-rw-r--r--src/pru1/sensors.cpp12
-rw-r--r--src/pru2/servos.cpp11
11 files changed, 241 insertions, 27 deletions
diff --git a/.gitignore b/.gitignore
index 3c243f0..18c75b1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,15 @@
-build/*
-Testing/*
+Testing/*
+.DS_Store
+.vagrant/*
+.idea/
+
+CMakeFiles/
+cmake_install.cmake
+CMakeCache.txt
+Makefile
+
+src/CMakeFiles
+src/cmake_install.cmake
+src/Makefile
+
+build/*
diff --git a/CMakeLists.txt b/CMakeLists.txt
index afe6539..5e3ed90 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,23 +1,49 @@
cmake_minimum_required(VERSION 3.14)
+set(CMAKE_SYSTEM_NAME Linux)
+set(CMAKE_SYSTEM_PROCESSOR ARM)
+set(CMAKE_BUILD_TYPE Debug)
+set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)
+
+# Set the cross-compiler for ARM32
+if(CMAKE_HOST_APPLE)
+ message(STATUS "Running on an Apple system")
+
+ # Apple Settings
+ # Musl has many targets, must select one
+ set(CMAKE_C_COMPILER /opt/homebrew/bin/arm-linux-musleabihf-gcc)
+ set(CMAKE_CXX_COMPILER /opt/homebrew/bin/arm-linux-musleabihf-g++)
+elseif(UNIX)
+ message(STATUS "Running on an Linux system")
+
+ # Linux Settings
+ # (arm-linux-musleabihf- is 32 bit, aarch64-linux... is the 64 bit version)
+ set(CMAKE_C_COMPILER arm-linux-musleabihf-gcc)
+ set(CMAKE_CXX_COMPILER arm-linux-musleabihf-g++)
+endif()
+
+# Set the architecture and flags
+set(CMAKE_C_FLAGS "-march=armv7-a+fp")
+set(CMAKE_CXX_FLAGS "-march=armv7-a+fp")
+
project(Active-Drag-System CXX)
-set(CMAKE_CXX_STANDARD 14)
-set(CMAKE_CXX_STANDARD_REQUIRED ON)
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror")
-include(CTest)
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/out")
add_subdirectory(src)
+
if(BUILD_TESTING)
+ include(CTest)
+
add_subdirectory(test)
-endif()
-include(FetchContent)
-FetchContent_Declare(
- googletest
- URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
-)
+ include(FetchContent)
+ FetchContent_Declare(
+ googletest
+ URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
+ )
-# For Windows: Prevent overriding the parent project's compiler/linker settings
-set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
-FetchContent_MakeAvailable(googletest)
+ # For Windows: Prevent overriding the parent project's compiler/linker settings
+ set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
+ FetchContent_MakeAvailable(googletest)
+endif()
diff --git a/LICENSE b/LICENSE
index a91bb02..13031c7 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
MIT License
-Copyright (c) 2023 Rocketry@VT
+Copyright (c) 2023 Rocketry at Virginia Tech
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/README.md b/README.md
index eb36387..18ec6bc 100644
--- a/README.md
+++ b/README.md
@@ -1,13 +1,63 @@
# Active Drag System (ADS)
-This is the main codebase for Rocketry at Virginia Tech's Active Drag System, also known coloquially as the ADS, for the 2023-2024 competition year. It runs primarily on a BeagleBone Black, and its goal is to autonomously control the ADS' deployment during flight.
+This is the main codebase for Rocketry at Virginia Tech's Active Drag System, also known colloquially as the ADS, for the 2023-2024 competition year. It runs primarily on a BeagleBone Black, and its goal is to autonomously control the ADS' deployment during flight.
## BUILD
+```shell
+vagrant up
+vagrant ssh
+cmake /vagrant
+cmake --build .
+```
+
+## BUILD Alternative (Windows)
+Enable WSL2 in windows
+Install Ubuntu 22 LTS from Windows Store
+```shell
+sudo apt update && upgrade
+sudo apt install build-essential cmake valgrind crossbuild-essential-armhf
+sudo apt install musl musl-tools
+```
+Then to actually build:
+```shell
cmake -B build
cmake --build build/
+```
+
+## BUILD Alternative (Mac)
+```shell
+brew install arm-linux-gnueabihf-binutils
+# This installs just the arm library, you can remove x86_64 if you want those too
+brew install FiloSottile/musl-cross/musl-cross --without-x86_64 --with-arm-hf
+```
+To check if installed correctly run:
+```shell
+ls /opt/homebrew/bin | grep "musl"
+```
+you should see:
+```shell
+arm-linux-musleabihf-gcc
+arm-linux-musleabihf-g++
+```
## RUN
-cd build && src/ads
+```shell
+scp -r src/ads [email protected]:~/
+./ads
+```
## TEST
-cd build && ctest
+```shell
+scp -r test/test_ads [email protected]:~/
+./test_ads
+```
+
+## GPIO Pins
+The GPIO number is calculated by taking the GPIO chip
+number, multiplying it by 32, and then adding the offset. For example,
+GPIO1_12 = (1 × 32) + 12 = GPIO 44.
+```shell
+/sys/class/gpio/gpio44 = GPIO1_12
+``` \ No newline at end of file
diff --git a/Vagrantfile b/Vagrantfile
new file mode 100644
index 0000000..7f542e1
--- /dev/null
+++ b/Vagrantfile
@@ -0,0 +1,31 @@
+#-----------------------------------------------------------------------
+$bootstrap = <<BOOTSTRAP
+export DEBIAN_FRONTEND=noninteractive
+apt-get update && apt-get upgrade
+
+# install base development tools
+apt-get -y install build-essential
+apt-get -y install cmake valgrind
+apt-get -y install crossbuild-essential-armhf
+apt-get -y install libboost-all-dev
+apt-get -y install libasio-dev
+wget https://musl.cc/arm-linux-musleabihf-cross.tgz
+tar -xzvf arm-linux-musleabihf-cross.tgz
+echo 'export PATH="\$PATH:/home/vagrant/arm-linux-musleabihf-cross/bin"' >> .bashrc
+rm -r arm-linux-musleabihf-cross.tgz
+
+BOOTSTRAP
+#-----------------------------------------------------------------------
+
+
+# Configuration
+Vagrant.configure("2") do |config|
+ config.vm.box = "debian/bullseye64"
+ config.vm.box_version = "11.20230615.1"
+
+ # (default timeout is 300 s)
+ config.vm.boot_timeout = 600
+
+ # set up the VM
+ config.vm.provision "shell", inline: $bootstrap
+end
diff --git a/bbb_setup.sh b/bbb_setup.sh
new file mode 100755
index 0000000..42e008d
--- /dev/null
+++ b/bbb_setup.sh
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+# Change based upon device specifics
+IFACE_BB=enp0s20f0u5
+IFACE_SELF=wlan0
+EXE=ads
+
+echo "Compiling Executeables"
+vagrant up
+vagrant ssh << EOF
+ cmake /vagrant;
+ cmake --build .;
+ mkdir -p build
+ cp -r out/* /vagrant/build/
+EOF
+
+echo "Forwarding Traffic to Beaglebone"
+# Forwards all internet traffic requested by beaglebone to proper interface
+sudo sh -c "ip link set $IFACE_BB"
+sudo sh -c "dhclient $IFACE_BB"
+
+sudo sh -c "iptables --table nat --append POSTROUTING --out-interface $IFACE_SELF -j MASQUERADE"
+sudo sh -c "iptables --append FORWARD --in-interface $IFACE_BB -j ACCEPT"
+sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
+
+echo "Copying Executeables to Beaglebone"
+scp -r build/* [email protected]:~/;
+rm -r build
+
+echo "Running Main Program"
+ssh [email protected] /bin/bash << EOF
+ ./$EXE;
+EOF
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 95d2f15..ea820ce 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1 +1,14 @@
-add_executable (ads active-drag-system.cpp)
+add_executable(ads
+ active_drag_system.cpp
+)
+
+add_executable(pru1
+ pru1/sensors.cpp
+)
+
+add_executable(pru2
+ pru2/servos.cpp
+)
+
+target_link_options(pru1 PRIVATE -static)
+target_link_options(pru2 PRIVATE -static)
diff --git a/src/active-drag-system.cpp b/src/active-drag-system.cpp
deleted file mode 100644
index 2b76215..0000000
--- a/src/active-drag-system.cpp
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <cstdlib>
-#include <iostream>
-
-int main() {
- std::cout << "ADS Deployed!" << std::endl;
- return EXIT_SUCCESS;
-}
diff --git a/src/active_drag_system.cpp b/src/active_drag_system.cpp
new file mode 100644
index 0000000..dce4f86
--- /dev/null
+++ b/src/active_drag_system.cpp
@@ -0,0 +1,32 @@
+/*
+ * Author: Dawsyn Schraiber <[email protected]>
+ * Date: 09/02/2023
+ *
+ * MIT License
+ *
+ * Copyright (c) 2023 Rocketry at Virginia Tech
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <iostream>
+
+int main(int argc, char *argv[]) {
+ std::cout << "ADS" << std::endl;
+}
diff --git a/src/pru1/sensors.cpp b/src/pru1/sensors.cpp
new file mode 100644
index 0000000..508387e
--- /dev/null
+++ b/src/pru1/sensors.cpp
@@ -0,0 +1,12 @@
+/*
+ * Author: Gregory Wainer <[email protected]>
+ * Date: 10/14/2023
+ *
+ */
+
+#include <iostream>
+#include <string>
+
+int main(int argc, char *argv[]) {
+ std::cout << "PRU1" << std::endl;
+}
diff --git a/src/pru2/servos.cpp b/src/pru2/servos.cpp
new file mode 100644
index 0000000..ba71ce2
--- /dev/null
+++ b/src/pru2/servos.cpp
@@ -0,0 +1,11 @@
+/*
+ * Author: Gregory Wainer <[email protected]>
+ * Date: 10/14/2023
+ *
+ */
+
+#include <iostream>
+
+int main(int argc, char* argv[]) {
+ std::cout << "PRU2" << std::endl;
+}