diff --git a/CMakePresets.json b/CMakePresets.json index ba50b3ba..685b8a2a 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -3,18 +3,18 @@ { "binaryDir": "${sourceDir}/build-fprime-automatic-zephyr", "cacheVariables": { - "BOARD": "teensy41", + "BOARD": "proves_flight_control_board_v5c/rp2350a/m33", "CMAKE_BUILD_TYPE": "Release", "CMAKE_EXPORT_COMPILE_COMMANDS": "ON" }, "description": "F\u00b4 release build using local fprime-venv", - "displayName": "F\u00b4 Zephyr (teensy41)", + "displayName": "F\u00b4 FPrime Zephyr PROVES", "environment": { "PATH": "$env{VIRTUAL_ENV}/bin:$penv{PATH}", "VIRTUAL_ENV": "${fileDir}/fprime-venv" }, "generator": "Ninja", - "name": "fprime-zephyr-teensy41", + "name": "fprime-zephyr-proves", "toolchainFile": "${fileDir}/lib/fprime-zephyr/cmake/toolchain/zephyr.cmake" } ], diff --git a/FprimeZephyrReference/Components/CMakeLists.txt b/FprimeZephyrReference/Components/CMakeLists.txt index 2a88e633..dce20754 100644 --- a/FprimeZephyrReference/Components/CMakeLists.txt +++ b/FprimeZephyrReference/Components/CMakeLists.txt @@ -3,4 +3,5 @@ add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/FatalHandler") add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Watchdog") add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Imu/") +add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/lms6dsoDriver/") add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Lis2mdlDriver/") diff --git a/FprimeZephyrReference/Components/Imu/Imu.cpp b/FprimeZephyrReference/Components/Imu/Imu.cpp index 5cbcc3d7..a9a2b1fe 100644 --- a/FprimeZephyrReference/Components/Imu/Imu.cpp +++ b/FprimeZephyrReference/Components/Imu/Imu.cpp @@ -13,16 +13,7 @@ namespace Components { // Component construction and destruction // ---------------------------------------------------------------------- -Imu ::Imu(const char* const compName) : ImuComponentBase(compName) { - // Initialize the LSM6DSO sensor - lsm6dso = DEVICE_DT_GET_ONE(st_lsm6dso); - FW_ASSERT(device_is_ready(lsm6dso)); - - // Configure the LSM6DSO sensor - struct sensor_value odr = {.val1 = 12, .val2 = 500000}; // 12.5 Hz - FW_ASSERT(sensor_attr_set(lsm6dso, SENSOR_CHAN_ACCEL_XYZ, SENSOR_ATTR_SAMPLING_FREQUENCY, &odr) == 0); - FW_ASSERT(sensor_attr_set(lsm6dso, SENSOR_CHAN_GYRO_XYZ, SENSOR_ATTR_SAMPLING_FREQUENCY, &odr) == 0); -} +Imu ::Imu(const char* const compName) : ImuComponentBase(compName) {} Imu ::~Imu() {} @@ -31,53 +22,10 @@ Imu ::~Imu() {} // ---------------------------------------------------------------------- void Imu ::run_handler(FwIndexType portNum, U32 context) { - // Fetch new data samples from the sensors - sensor_sample_fetch_chan(lsm6dso, SENSOR_CHAN_ACCEL_XYZ); - sensor_sample_fetch_chan(lsm6dso, SENSOR_CHAN_GYRO_XYZ); - sensor_sample_fetch_chan(lsm6dso, SENSOR_CHAN_DIE_TEMP); - - // Output sensor values via telemetry - this->tlmWrite_Acceleration(this->get_acceleration()); - this->tlmWrite_AngularVelocity(this->get_angular_velocity()); + this->tlmWrite_Acceleration(this->readAcceleration_out(0)); + this->tlmWrite_AngularVelocity(this->readAngularVelocity_out(0)); this->tlmWrite_MagneticField(this->readMagneticField_out(0)); - this->tlmWrite_Temperature(this->get_temperature()); -} - -F64 Imu ::sensor_value_to_f64(const struct sensor_value& val) { - return val.val1 + val.val2 / 1000000.0f; -} - -Components::Imu_Acceleration Imu ::get_acceleration() { - struct sensor_value x; - struct sensor_value y; - struct sensor_value z; - - sensor_channel_get(lsm6dso, SENSOR_CHAN_ACCEL_X, &x); - sensor_channel_get(lsm6dso, SENSOR_CHAN_ACCEL_Y, &y); - sensor_channel_get(lsm6dso, SENSOR_CHAN_ACCEL_Z, &z); - - return Components::Imu_Acceleration(this->sensor_value_to_f64(x), this->sensor_value_to_f64(y), - this->sensor_value_to_f64(z)); -} - -Components::Imu_AngularVelocity Imu ::get_angular_velocity() { - struct sensor_value x; - struct sensor_value y; - struct sensor_value z; - - sensor_channel_get(lsm6dso, SENSOR_CHAN_GYRO_X, &x); - sensor_channel_get(lsm6dso, SENSOR_CHAN_GYRO_Y, &y); - sensor_channel_get(lsm6dso, SENSOR_CHAN_GYRO_Z, &z); - - return Components::Imu_AngularVelocity(this->sensor_value_to_f64(x), this->sensor_value_to_f64(y), - this->sensor_value_to_f64(z)); + this->tlmWrite_Temperature(this->readTemperature_out(0)); } -F64 Imu ::get_temperature() { - struct sensor_value temp; - - sensor_channel_get(lsm6dso, SENSOR_CHAN_DIE_TEMP, &temp); - - return this->sensor_value_to_f64(temp); -} } // namespace Components diff --git a/FprimeZephyrReference/Components/Imu/Imu.fpp b/FprimeZephyrReference/Components/Imu/Imu.fpp index 30a46fa5..22446d9a 100644 --- a/FprimeZephyrReference/Components/Imu/Imu.fpp +++ b/FprimeZephyrReference/Components/Imu/Imu.fpp @@ -3,31 +3,20 @@ module Components { passive component Imu { sync input port run: Svc.Sched + output port readAcceleration: AccelerationRead + output port readAngularVelocity: AngularVelocityRead output port readMagneticField: MagneticFieldRead + output port readTemperature: TemperatureRead - @ Acceleration reading in m/s^2 - struct Acceleration { - x: F64 - y: F64 - z: F64 - } + @Telemetry channel for angular velocity + telemetry AngularVelocity: AngularVelocity - @ Telemetry channel for acceleration + @ Telemetry channel for Acceleration telemetry Acceleration: Acceleration @ Telemetry channel for magnetic field telemetry MagneticField: MagneticField - @ Angular velocity reading in rad/s - struct AngularVelocity { - x: F64 - y: F64 - z: F64 - } - - @ Telemetry channel for angular velocity - telemetry AngularVelocity: AngularVelocity - @ Telemetry channel for temperature in degrees Celsius telemetry Temperature: F64 diff --git a/FprimeZephyrReference/Components/Imu/Imu.hpp b/FprimeZephyrReference/Components/Imu/Imu.hpp index 43ca3738..c6384251 100644 --- a/FprimeZephyrReference/Components/Imu/Imu.hpp +++ b/FprimeZephyrReference/Components/Imu/Imu.hpp @@ -8,10 +8,6 @@ #include "FprimeZephyrReference/Components/Imu/ImuComponentAc.hpp" -#include -#include -#include - namespace Components { class Imu final : public ImuComponentBase { @@ -35,33 +31,6 @@ class Imu final : public ImuComponentBase { void run_handler(FwIndexType portNum, //!< The port number U32 context //!< The call order ) override; - - // ---------------------------------------------------------------------- - // Helper methods - // ---------------------------------------------------------------------- - - //! Convert a Zephyr sensor_value to an Fprime F64 - F64 sensor_value_to_f64(const struct sensor_value& val); - - // ---------------------------------------------------------------------- - // IMU access methods - // ---------------------------------------------------------------------- - - //! Get the acceleration reading from the IMU - Components::Imu_Acceleration get_acceleration(); - - //! Get the angular velocity reading from the IMU - Components::Imu_AngularVelocity get_angular_velocity(); - - //! Get the temperature reading from the IMU - F64 get_temperature(); - - // ---------------------------------------------------------------------- - // Member variables - // ---------------------------------------------------------------------- - - //! Zephyr device stores the initialized LSM6DSO sensor - const struct device* lsm6dso; }; } // namespace Components diff --git a/FprimeZephyrReference/Components/lms6dsoDriver/CMakeLists.txt b/FprimeZephyrReference/Components/lms6dsoDriver/CMakeLists.txt new file mode 100644 index 00000000..d87a2502 --- /dev/null +++ b/FprimeZephyrReference/Components/lms6dsoDriver/CMakeLists.txt @@ -0,0 +1,36 @@ +#### +# F Prime CMakeLists.txt: +# +# SOURCES: list of source files (to be compiled) +# AUTOCODER_INPUTS: list of files to be passed to the autocoders +# DEPENDS: list of libraries that this module depends on +# +# More information in the F´ CMake API documentation: +# https://fprime.jpl.nasa.gov/latest/docs/reference/api/cmake/API/ +# +#### + +# Module names are derived from the path from the nearest project/library/framework +# root when not specifically overridden by the developer. i.e. The module defined by +# `Ref/SignalGen/CMakeLists.txt` will be named `Ref_SignalGen`. + +register_fprime_library( + AUTOCODER_INPUTS + "${CMAKE_CURRENT_LIST_DIR}/lms6dsoDriver.fpp" + SOURCES + "${CMAKE_CURRENT_LIST_DIR}/lms6dsoDriver.cpp" +# DEPENDS +# MyPackage_MyOtherModule +) + +### Unit Tests ### +# register_fprime_ut( +# AUTOCODER_INPUTS +# "${CMAKE_CURRENT_LIST_DIR}/lms6dsoDriver.fpp" +# SOURCES +# "${CMAKE_CURRENT_LIST_DIR}/test/ut/lms6dsoDriverTestMain.cpp" +# "${CMAKE_CURRENT_LIST_DIR}/test/ut/lms6dsoDriverTester.cpp" +# DEPENDS +# STest # For rules-based testing +# UT_AUTO_HELPERS +# ) diff --git a/FprimeZephyrReference/Components/lms6dsoDriver/docs/sdd.md b/FprimeZephyrReference/Components/lms6dsoDriver/docs/sdd.md new file mode 100644 index 00000000..f36d6cf2 --- /dev/null +++ b/FprimeZephyrReference/Components/lms6dsoDriver/docs/sdd.md @@ -0,0 +1,66 @@ +# Components::lms6dsoDriver + +Initialize and control operation of the lms6dso device + +## Usage Examples +Add usage examples here + +### Diagrams +Add diagrams here + +### Typical Usage +And the typical usage of the component here + +## Class Diagram +Add a class diagram here + +## Port Descriptions +| Name | Description | +|---|---| +|---|---| + +## Component States +Add component states in the chart below +| Name | Description | +|---|---| +|---|---| + +## Sequence Diagrams +Add sequence diagrams here + +## Parameters +| Name | Description | +|---|---| +|---|---| + +## Commands +| Name | Description | +|---|---| +|---|---| + +## Events +| Name | Description | +|---|---| +|---|---| + +## Telemetry +| Name | Description | +|---|---| +|---|---| + +## Unit Tests +Add unit test descriptions in the chart below +| Name | Description | Output | Coverage | +|---|---|---|---| +|---|---|---|---| + +## Requirements +Add requirements in the chart below +| Name | Description | Validation | +|---|---|---| +|---|---|---| + +## Change Log +| Date | Description | +|---|---| +|---| Initial Draft | \ No newline at end of file diff --git a/FprimeZephyrReference/Components/lms6dsoDriver/lms6dsoDriver.cpp b/FprimeZephyrReference/Components/lms6dsoDriver/lms6dsoDriver.cpp new file mode 100644 index 00000000..9d4819f1 --- /dev/null +++ b/FprimeZephyrReference/Components/lms6dsoDriver/lms6dsoDriver.cpp @@ -0,0 +1,71 @@ +// ====================================================================== +// \title lms6dsoDriver.cpp +// \author aaron +// \brief cpp file for lms6dsoDriver component implementation class +// ====================================================================== + +#include "FprimeZephyrReference/Components/lms6dsoDriver/lms6dsoDriver.hpp" + +namespace Components { + +// ---------------------------------------------------------------------- +// Component construction and destruction +// ---------------------------------------------------------------------- + +lms6dsoDriver ::lms6dsoDriver(const char* const compName) : lms6dsoDriverComponentBase(compName) { + // Initialize the LSM6DSO sensor + lsm6dso = DEVICE_DT_GET_ONE(st_lsm6dso); + FW_ASSERT(device_is_ready(lsm6dso)); + // Configure the LSM6DSO sensor + struct sensor_value odr = {.val1 = 12, .val2 = 500000}; // 12.5 Hz + sensor_attr_set(lsm6dso, SENSOR_CHAN_ACCEL_XYZ, SENSOR_ATTR_SAMPLING_FREQUENCY, &odr); + sensor_attr_set(lsm6dso, SENSOR_CHAN_GYRO_XYZ, SENSOR_ATTR_SAMPLING_FREQUENCY, &odr); +} + +lms6dsoDriver ::~lms6dsoDriver() {} + +// ---------------------------------------------------------------------- +// Handler implementations for typed input ports +// ---------------------------------------------------------------------- + +Components::Acceleration lms6dsoDriver::getAcceleration_handler(FwIndexType portNum) { + struct sensor_value x; + struct sensor_value y; + struct sensor_value z; + sensor_sample_fetch_chan(lsm6dso, SENSOR_CHAN_ACCEL_XYZ); + + sensor_channel_get(lsm6dso, SENSOR_CHAN_ACCEL_X, &x); + sensor_channel_get(lsm6dso, SENSOR_CHAN_ACCEL_Y, &y); + sensor_channel_get(lsm6dso, SENSOR_CHAN_ACCEL_Z, &z); + + return Components::Acceleration(this->sensor_value_to_f64(x),this->sensor_value_to_f64(y), this->sensor_value_to_f64(z)); +} + +Components::AngularVelocity lms6dsoDriver::getAngularVelocity_handler(FwIndexType portNum) { + struct sensor_value x; + struct sensor_value y; + struct sensor_value z; + sensor_sample_fetch_chan(lsm6dso, SENSOR_CHAN_GYRO_XYZ); + + sensor_channel_get(lsm6dso, SENSOR_CHAN_GYRO_X, &x); + sensor_channel_get(lsm6dso, SENSOR_CHAN_GYRO_Y, &y); + sensor_channel_get(lsm6dso, SENSOR_CHAN_GYRO_Z, &z); + + return Components::AngularVelocity(this->sensor_value_to_f64(x),this->sensor_value_to_f64(y), this->sensor_value_to_f64(z)); +} + + +F64 lms6dsoDriver::getTemperature_handler(FwIndexType portNum) { + struct sensor_value temp; + + sensor_sample_fetch_chan(lsm6dso, SENSOR_CHAN_DIE_TEMP); + sensor_channel_get(lsm6dso, SENSOR_CHAN_DIE_TEMP, &temp); + + return this->sensor_value_to_f64(temp); +} + +F64 lms6dsoDriver::sensor_value_to_f64(const struct sensor_value& val) { + return val.val1 + val.val2 / 1000000.0f; +} + +} // namespace Components diff --git a/FprimeZephyrReference/Components/lms6dsoDriver/lms6dsoDriver.fpp b/FprimeZephyrReference/Components/lms6dsoDriver/lms6dsoDriver.fpp new file mode 100644 index 00000000..fc635010 --- /dev/null +++ b/FprimeZephyrReference/Components/lms6dsoDriver/lms6dsoDriver.fpp @@ -0,0 +1,39 @@ +module Components { + + @ Acceleration Reading in m/s^2 + struct Acceleration { + x: F64 + y: F64 + z: F64 + } + + @ Angular velocity reading in rad/s + struct AngularVelocity { + x: F64 + y: F64 + z: F64 + } + + port AccelerationRead() -> Acceleration + port AngularVelocityRead() -> AngularVelocity + port TemperatureRead() -> F64 + + @ Initialize and control operation of the lms6dso device + passive component lms6dsoDriver { + + @ Port for synchronously retrieving data + sync input port getAcceleration: AccelerationRead + sync input port getAngularVelocity: AngularVelocityRead + sync input port getTemperature: TemperatureRead + + ############################################################################### + # Standard AC Ports: Required for Channels, Events, Commands, and Parameters # + ############################################################################### + @ Port for requesting the current time + time get port timeCaller + + + + + } +} \ No newline at end of file diff --git a/FprimeZephyrReference/Components/lms6dsoDriver/lms6dsoDriver.hpp b/FprimeZephyrReference/Components/lms6dsoDriver/lms6dsoDriver.hpp new file mode 100644 index 00000000..b9c9fc46 --- /dev/null +++ b/FprimeZephyrReference/Components/lms6dsoDriver/lms6dsoDriver.hpp @@ -0,0 +1,53 @@ +// ====================================================================== +// \title lms6dsoDriver.hpp +// \author aaron +// \brief hpp file for lms6dsoDriver component implementation class +// ====================================================================== + +#ifndef Components_lms6dsoDriver_HPP +#define Components_lms6dsoDriver_HPP + +#include "FprimeZephyrReference/Components/lms6dsoDriver/lms6dsoDriverComponentAc.hpp" + + +#include +#include +#include + +namespace Components { + +class lms6dsoDriver final : public lms6dsoDriverComponentBase { + public: + // ---------------------------------------------------------------------- + // Component construction and destruction + // ---------------------------------------------------------------------- + + //! Construct lms6dsoDriver object + lms6dsoDriver(const char* const compName //!< The component name + ); + + //! Destroy lms6dsoDriver object + ~lms6dsoDriver(); + + private: + + // ---------------------------------------------------------------------- + // Handler implementations for typed input ports + // ---------------------------------------------------------------------- + Acceleration getAcceleration_handler(FwIndexType portNum) override; + + AngularVelocity getAngularVelocity_handler(FwIndexType portNum) override; + + F64 getTemperature_handler(FwIndexType portNum) override; + + F64 sensor_value_to_f64(const struct sensor_value &val); + + //! Zephyr device stores the initialized LSM6DSO sensor + const struct device* lsm6dso; + + +}; + +} // namespace Components + +#endif diff --git a/FprimeZephyrReference/ReferenceDeployment/Top/instances.fpp b/FprimeZephyrReference/ReferenceDeployment/Top/instances.fpp index ca5f9bfe..42c57dc4 100644 --- a/FprimeZephyrReference/ReferenceDeployment/Top/instances.fpp +++ b/FprimeZephyrReference/ReferenceDeployment/Top/instances.fpp @@ -67,4 +67,6 @@ module ReferenceDeployment { instance imu: Components.Imu base id 0x10017000 instance lis2mdlDriver: Components.Lis2mdlDriver base id 0x10018000 + + instance lms6dsoDriver: Components.lms6dsoDriver base id 0x10019000 } diff --git a/FprimeZephyrReference/ReferenceDeployment/Top/topology.fpp b/FprimeZephyrReference/ReferenceDeployment/Top/topology.fpp index e286f22e..4b0cb04c 100644 --- a/FprimeZephyrReference/ReferenceDeployment/Top/topology.fpp +++ b/FprimeZephyrReference/ReferenceDeployment/Top/topology.fpp @@ -31,6 +31,7 @@ module ReferenceDeployment { instance prmDb instance imu instance lis2mdlDriver + instance lms6dsoDriver # ---------------------------------------------------------------------- # Pattern graph specifiers @@ -102,7 +103,10 @@ module ReferenceDeployment { } connections Imu { + imu.readAcceleration -> lms6dsoDriver.getAcceleration + imu.readAngularVelocity -> lms6dsoDriver.getAngularVelocity imu.readMagneticField -> lis2mdlDriver.getMagneticField + imu.readTemperature -> lms6dsoDriver.getTemperature } connections ReferenceDeployment { diff --git a/Makefile b/Makefile index 542c0f43..1e9d030c 100644 --- a/Makefile +++ b/Makefile @@ -13,15 +13,14 @@ submodules: ## Initialize and update git submodules git submodule update --init --recursive export VIRTUAL_ENV ?= $(shell pwd)/fprime-venv -fprime-venv: uv ## Create a virtual environment - @test -s $(VIRTUAL_ENV) || { \ - echo "Creating virtual environment..."; \ - $(UV) venv fprime-venv; \ - $(UV) pip install --requirement requirements.txt; \ - } +fprime-venv: ## Create a virtual environment + @$(MAKE) uv + @echo "Creating virtual environment..." + @$(UV) venv fprime-venv + @$(UV) pip install --requirement requirements.txt .PHONY: zephyr-setup -zephyr-setup: uv ## Set up Zephyr environment +zephyr-setup: fprime-venv ## Set up Zephyr environment @test -s lib/zephyr-workspace/tools/edtt/.gitignore || { \ echo "Setting up Zephyr environment..."; \ cd lib/zephyr-workspace && \ @@ -34,18 +33,17 @@ zephyr-setup: uv ## Set up Zephyr environment ##@ Development .PHONY: pre-commit-install -pre-commit-install: uv - @echo "Installing pre-commit hooks..." +pre-commit-install: uv ## Install pre-commit hooks @$(UVX) pre-commit install > /dev/null .PHONY: fmt fmt: pre-commit-install ## Lint and format files - $(UVX) pre-commit run --all-files + @$(UVX) pre-commit run --all-files .PHONY: generate generate: submodules fprime-venv zephyr-setup ## Generate FPrime-Zephyr Proves Core Reference @echo "Generating FPrime-Zephyr Proves Core Reference..." - $(UV) run fprime-util generate --force + @$(UV) run fprime-util generate --force .PHONY: generate-if-needed BUILD_DIR ?= $(shell pwd)/build-fprime-automatic-zephyr @@ -53,26 +51,16 @@ generate-if-needed: @test -s $(BUILD_DIR) || $(MAKE) generate .PHONY: build -build: generate-if-needed ## Build FPrime-Zephyr Proves Core Reference - @echo "Building FPrime code..." +build: submodules zephyr-setup fprime-venv generate-if-needed ## Build FPrime-Zephyr Proves Core Reference + @echo "Building..." @$(UV) run fprime-util build -.PHONY: list-tty -list-tty: arduino-cli ## List available TTY ports - @echo "TTY ports:" - @$(ARDUINO_CLI) board list | grep "USB" | awk '{print $$1}' - -.PHONY: install -UF2 ?= $(BUILD_DIR)/zephyr/zephyr.uf2 -install: arduino-cli build ## Install the zephyr firmware onto a connected PROVES Kit, requires BOARD_DIR=[path-to-your-board] - @$(ARDUINO_CLI) config init || true - @$(ARDUINO_CLI) config add board_manager.additional_urls https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json - @$(ARDUINO_CLI) core install rp2040:rp2040@4.1.1 - @$(ARDUINO_CLI) upload -v -b 115200 --fqbn rp2040:rp2040:rpipico -p $(BOARD_DIR) -i $(UF2) - .PHONY: clean clean: ## Remove all gitignored files git clean -dfX + +.PHONY: clean-zephyr +clean-zephyr: ## Remove all Zephyr build files rm -rf lib/zephyr-workspace/bootloader lib/zephyr-workspace/modules lib/zephyr-workspace/tools ##@ Operations @@ -98,9 +86,3 @@ UVX ?= $(UV_DIR)/uvx uv: $(UV) ## Download uv $(UV): $(BIN_DIR) @test -s $(UV) || { mkdir -p $(UV_DIR); curl -LsSf https://astral.sh/uv/$(UV_VERSION)/install.sh | UV_INSTALL_DIR=$(UV_DIR) sh > /dev/null; } - -ARDUINO_CLI ?= $(BIN_DIR)/arduino-cli -.PHONY: arduino-cli -arduino-cli: $(ARDUINO_CLI) ## Download arduino-cli -$(ARDUINO_CLI): $(BIN_DIR) - @test -s $(ARDUINO_CLI) || curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR=$(BIN_DIR) sh > /dev/null diff --git a/README.md b/README.md index 74d41fb3..7b591df2 100644 --- a/README.md +++ b/README.md @@ -36,14 +36,7 @@ make build ### Find the path to your board -Next, plug in your board! If you have previously installed a firmware on your board you may not see it show up as a drive. In that case you'll want to find it's `tty` port. - -To do this, run the following command -```shell -make list-tty -``` - -Otherwise, you want to find the location of the board on your computer. It should be called something like RP2350 but you want to find the path to it +Next, plug in your board! If you have previously installed a firmware on your board you may not see it show up as a drive. In that case you'll want to put the board into boot loader mode. Then you'll be able to find the location of the board on your computer. It should be called something like RP2350 but you want to find the path to it For Mac: ```shell @@ -63,6 +56,13 @@ Now you want to install the firmware to the board. make install BOARD_DIR=[path-to-your-board] ``` +or +``` +cp build-fprime-automatic-zephyr/zephyr/zephyr.uf2 [path-to-your-board] +``` +to copy the uf2 if the make install isn't working + + Finally, run the fprime-gds. ```shell make gds diff --git a/boards/bronco_space/proves_flight_control_board_v5/Kconfig.defconfig b/boards/bronco_space/proves_flight_control_board_v5/Kconfig.defconfig new file mode 100644 index 00000000..53c0c734 --- /dev/null +++ b/boards/bronco_space/proves_flight_control_board_v5/Kconfig.defconfig @@ -0,0 +1,12 @@ +config SOC_RP2350A_M33 + bool "Enable Arm cores" + default y + +config USB_SELF_POWERED + default n + +config USB_CDC_ACM_LOG_LEVEL + default 0 + +config USB_DEVICE_LOG_LEVEL + default 1 diff --git a/boards/bronco_space/proves_flight_control_board_v5/proves_flight_control_board_v5-pinctrl.dtsi b/boards/bronco_space/proves_flight_control_board_v5/proves_flight_control_board_v5-pinctrl.dtsi new file mode 100644 index 00000000..012ca613 --- /dev/null +++ b/boards/bronco_space/proves_flight_control_board_v5/proves_flight_control_board_v5-pinctrl.dtsi @@ -0,0 +1,20 @@ +#include + +&pinctrl { + spi1_default: spi1_default { + group1 { + pinmux = , ; + }; + + group2 { + pinmux = ; + input-enable; + }; + }; + i2c1_default: i2c1_default { + group1 { + pinmux = , ; + input-enable; + }; + }; +}; diff --git a/boards/bronco_space/proves_flight_control_board_v5/proves_flight_control_board_v5.dtsi b/boards/bronco_space/proves_flight_control_board_v5/proves_flight_control_board_v5.dtsi new file mode 100644 index 00000000..cc25572f --- /dev/null +++ b/boards/bronco_space/proves_flight_control_board_v5/proves_flight_control_board_v5.dtsi @@ -0,0 +1,132 @@ +#include + +#include +#include + +#include "proves_flight_control_board_v5-pinctrl.dtsi" + +/ { + chosen { + zephyr,sram = &sram0; + zephyr,flash = &flash0; + zephyr,console = &cdc_acm_uart0; + zephyr,shell-uart = &cdc_acm_uart0; + zephyr,code-partition = &code_partition; + }; + + aliases { + watchdog0 = &wdt0; + }; + + leds { + compatible = "gpio-leds"; + led0: led0 { + gpios = <&gpio0 24 GPIO_ACTIVE_HIGH>; + label = "User LED GPIO24"; + }; + }; +}; + +zephyr_udc0: &usbd { + status = "okay"; +}; + +&zephyr_udc0 { + cdc_acm_uart0: cdc_acm_uart0 { + compatible = "zephyr,cdc-acm-uart"; + label = "CDC_ACM_0"; + }; +}; + +&flash0 { + reg = <0x10000000 DT_SIZE_M(4)>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + /* Reserved memory for an image definition block. The block is much + * smaller than 256 bytes, but in practice the linker places the vector + * table at a much larger alignment offset. + */ + image_def: partition@0 { + label = "image_def"; + reg = <0x00000000 0x100>; + read-only; + }; + + /* + * Usable flash. Starts at 0x100, after the image definition block. + * The partition size is 4MB minus the 0x100 bytes taken by the + * image definition. + */ + code_partition: partition@100 { + label = "code-partition"; + reg = <0x100 (DT_SIZE_M(4) - 0x100)>; + read-only; + }; + }; +}; + +&timer0 { + status = "okay"; +}; + +&wdt0 { + status = "okay"; +}; + +&gpio0 { + status = "okay"; +}; + +&spi1 { + status = "okay"; + cs-gpios = <&gpio0 9 GPIO_ACTIVE_LOW>; + pinctrl-0 = <&spi1_default>; + pinctrl-names = "default"; + + lora0: sx1276@0 { + compatible = "semtech,sx1276"; + reg = <0>; + spi-max-frequency = <125000>; + dio-gpios = <&gpio0 13 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>,<&gpio0 12 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>; + reset-gpios = <&gpio0 6 GPIO_ACTIVE_LOW>; + power-amplifier-output = "pa-boost"; + label = "HOPE_RF"; + }; +}; + +&i2c1 { + status = "okay"; + pinctrl-0 = <&i2c1_default>; + pinctrl-names = "default"; + clock-frequency = <100000>; + + lsm6dso0: lsm6dso0@6b { + compatible = "st,lsm6dso"; + reg = <0x6b>; + label = "LSM6DSO"; + }; + + lis2mdl: lis2mdl@1e { + compatible = "st,lis2mdl"; + reg = <0x1e>; + label = "LIS2MDL"; + }; + rv3028: rv3028@52 { + compatible = "microcrystal,rv3028"; + reg = <0x52>; + int-gpios = <&gpio0 27 GPIO_ACTIVE_HIGH>; + backup-switch-mode = "level"; + label = "RV3028"; + }; + ina219: ina219@40 { + compatible = "ti,ina219"; + reg = <0x40>; + shunt-milliohm = <2>; + lsb-microamp = <100>; + label = "INA219"; + }; +}; diff --git a/boards/bronco_space/proves_flight_control_board_v5c/Kconfig.proves_flight_control_board_v5c b/boards/bronco_space/proves_flight_control_board_v5c/Kconfig.proves_flight_control_board_v5c index 805f5070..ce2e6e17 100644 --- a/boards/bronco_space/proves_flight_control_board_v5c/Kconfig.proves_flight_control_board_v5c +++ b/boards/bronco_space/proves_flight_control_board_v5c/Kconfig.proves_flight_control_board_v5c @@ -1,5 +1 @@ -# Copyright (c) 2024 Andrew Featherstone -# SPDX-License-Identifier: Apache-2.0 - -config BOARD_PROVES_FLIGHT_CONTROL_BOARD_V5C - select SOC_RP2350A_M33 if BOARD_PROVES_FLIGHT_CONTROL_BOARD_V5C_RP2350A_M33 +source "../../../boards/bronco_space/proves_flight_control_board_v5/Kconfig.defconfig" diff --git a/boards/bronco_space/proves_flight_control_board_v5c/proves_flight_control_board_v5c_rp2350a_m33.dts b/boards/bronco_space/proves_flight_control_board_v5c/proves_flight_control_board_v5c_rp2350a_m33.dts index dc57761a..e4290dd6 100644 --- a/boards/bronco_space/proves_flight_control_board_v5c/proves_flight_control_board_v5c_rp2350a_m33.dts +++ b/boards/bronco_space/proves_flight_control_board_v5c/proves_flight_control_board_v5c_rp2350a_m33.dts @@ -16,4 +16,4 @@ #include #include -#include "proves_flight_control_board_v5c.dtsi" +#include "../proves_flight_control_board_v5/proves_flight_control_board_v5.dtsi" diff --git a/boards/bronco_space/proves_flight_control_board_v5c/proves_flight_control_board_v5c_rp2350a_m33_defconfig b/boards/bronco_space/proves_flight_control_board_v5c/proves_flight_control_board_v5c_rp2350a_m33_defconfig index ff74ead6..02bb4603 100644 --- a/boards/bronco_space/proves_flight_control_board_v5c/proves_flight_control_board_v5c_rp2350a_m33_defconfig +++ b/boards/bronco_space/proves_flight_control_board_v5c/proves_flight_control_board_v5c_rp2350a_m33_defconfig @@ -11,3 +11,17 @@ CONFIG_USE_DT_CODE_PARTITION=y CONFIG_USB_DEVICE_STACK=y CONFIG_USB_DEVICE_PRODUCT="PROVES Flight Control Board v5c" CONFIG_USB_DEVICE_VID=0x0028 + +# Sensors +CONFIG_LSM6DSO=y +CONFIG_LSM6DSO_ENABLE_TEMP=y +CONFIG_LIS2MDL=y +CONFIG_INA219=y + +# Radio +CONFIG_LORA=y +CONFIG_LORA_SX127X=y + +# RTC +CONFIG_RTC=y +CONFIG_RTC_RV3028=y diff --git a/boards/bronco_space/proves_flight_control_board_v5d/Kconfig.proves_flight_control_board_v5d b/boards/bronco_space/proves_flight_control_board_v5d/Kconfig.proves_flight_control_board_v5d new file mode 100644 index 00000000..b3bd39fa --- /dev/null +++ b/boards/bronco_space/proves_flight_control_board_v5d/Kconfig.proves_flight_control_board_v5d @@ -0,0 +1,5 @@ +config BOARD_PROVES_FLIGHT_CONTROL_BOARD_V5D + bool "PROVES Flight Control Board v5d" + default y + +source "../../../boards/bronco_space/proves_flight_control_board_v5/Kconfig.defconfig" diff --git a/boards/bronco_space/proves_flight_control_board_v5d/board.cmake b/boards/bronco_space/proves_flight_control_board_v5d/board.cmake new file mode 100644 index 00000000..dc6406b4 --- /dev/null +++ b/boards/bronco_space/proves_flight_control_board_v5d/board.cmake @@ -0,0 +1,20 @@ +# SPDX-License-Identifier: Apache-2.0 + +if("${RPI_PICO_DEBUG_ADAPTER}" STREQUAL "") + set(RPI_PICO_DEBUG_ADAPTER "cmsis-dap") +endif() + +board_runner_args(openocd --cmd-pre-init "source [find interface/${RPI_PICO_DEBUG_ADAPTER}.cfg]") +board_runner_args(openocd --cmd-pre-init "source [find target/rp2350.cfg]") + +# The adapter speed is expected to be set by interface configuration. +# The Raspberry Pi's OpenOCD fork doesn't, so match their documentation at +# https://www.raspberrypi.com/documentation/microcontrollers/debug-probe.html#debugging-with-swd +board_runner_args(openocd --cmd-pre-init "set_adapter_speed_if_not_set 5000") + +board_runner_args(jlink "--device=RP2350_M33_0") +board_runner_args(uf2 "--board-id=RP2350") + +include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake) +include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake) +include(${ZEPHYR_BASE}/boards/common/uf2.board.cmake) diff --git a/boards/bronco_space/proves_flight_control_board_v5d/board.yml b/boards/bronco_space/proves_flight_control_board_v5d/board.yml new file mode 100644 index 00000000..32c6ada0 --- /dev/null +++ b/boards/bronco_space/proves_flight_control_board_v5d/board.yml @@ -0,0 +1,6 @@ +board: + name: proves_flight_control_board_v5d + full_name: PROVES Flight Control Board v5d + vendor: Bronco Space + socs: + - name: rp2350a diff --git a/boards/bronco_space/proves_flight_control_board_v5d/proves_flight_control_board_v5d_rp2350a_m33.dts b/boards/bronco_space/proves_flight_control_board_v5d/proves_flight_control_board_v5d_rp2350a_m33.dts new file mode 100644 index 00000000..e265d05f --- /dev/null +++ b/boards/bronco_space/proves_flight_control_board_v5d/proves_flight_control_board_v5d_rp2350a_m33.dts @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 Andrew Featherstone + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; + +/* The build system assumes that there's a cpucluster-specific file. + * + * This file provides composition of the device tree: + * 1. The common features of the SoC + * 2. Core-specific configuration. + * 3. Board-specific configuration. + */ +#include +#include + +#include "../proves_flight_control_board_v5/proves_flight_control_board_v5.dtsi" + +&led0 { + gpios = <&gpio0 23 GPIO_ACTIVE_HIGH>; + label = "User LED GPIO23"; +}; diff --git a/boards/bronco_space/proves_flight_control_board_v5d/proves_flight_control_board_v5d_rp2350a_m33.yaml b/boards/bronco_space/proves_flight_control_board_v5d/proves_flight_control_board_v5d_rp2350a_m33.yaml new file mode 100644 index 00000000..6880c0c1 --- /dev/null +++ b/boards/bronco_space/proves_flight_control_board_v5d/proves_flight_control_board_v5d_rp2350a_m33.yaml @@ -0,0 +1,22 @@ +identifier: proves_flight_control_board_v5d/rp2350a/m33 +name: PROVES Flight Control Board v5d (RP2350, Cortex-M33) +type: mcu +arch: arm +flash: 4096 +ram: 520 +toolchain: + - zephyr + - gnuarmemb +supported: + - adc + - clock + - counter + - dma + - gpio + - hwinfo + - i2c + - pwm + - spi + - uart + - usbd + - watchdog diff --git a/boards/bronco_space/proves_flight_control_board_v5d/proves_flight_control_board_v5d_rp2350a_m33_defconfig b/boards/bronco_space/proves_flight_control_board_v5d/proves_flight_control_board_v5d_rp2350a_m33_defconfig new file mode 100644 index 00000000..fccf5b0f --- /dev/null +++ b/boards/bronco_space/proves_flight_control_board_v5d/proves_flight_control_board_v5d_rp2350a_m33_defconfig @@ -0,0 +1,27 @@ +CONFIG_BUILD_OUTPUT_HEX=y +CONFIG_BUILD_OUTPUT_UF2=y +CONFIG_CLOCK_CONTROL=y +CONFIG_CONSOLE=y +CONFIG_GPIO=y +CONFIG_RESET=y +CONFIG_SERIAL=y +CONFIG_UART_CONSOLE=y +CONFIG_UART_INTERRUPT_DRIVEN=y +CONFIG_USE_DT_CODE_PARTITION=y +CONFIG_USB_DEVICE_STACK=y +CONFIG_USB_DEVICE_PRODUCT="PROVES Flight Control Board v5d" +CONFIG_USB_DEVICE_VID=0x0028 + +# Sensors +CONFIG_LSM6DSO=y +CONFIG_LSM6DSO_ENABLE_TEMP=y +CONFIG_LIS2MDL=y +CONFIG_INA219=y + +# Radio +CONFIG_LORA=y +CONFIG_LORA_SX127X=y + +# RTC +CONFIG_RTC=y +CONFIG_RTC_RV3028=y diff --git a/boards/bronco_space/proves_flight_control_board_v5d/support/openocd.cfg b/boards/bronco_space/proves_flight_control_board_v5d/support/openocd.cfg new file mode 100644 index 00000000..82666bb5 --- /dev/null +++ b/boards/bronco_space/proves_flight_control_board_v5d/support/openocd.cfg @@ -0,0 +1,11 @@ +# Copyright (c) 2024 TOKITA Hiroshi +# SPDX-License-Identifier: Apache-2.0 + +# Checking and set 'adapter speed'. +# Set the adaptor speed, if unset, and given as an argument. +proc set_adapter_speed_if_not_set { speed } { + puts "checking adapter speed..." + if { [catch {adapter speed} ret] } { + adapter speed $speed + } +} diff --git a/prj.conf b/prj.conf index a6ec0633..96d07ad7 100644 --- a/prj.conf +++ b/prj.conf @@ -1,17 +1,9 @@ #### Configure Device VID and PID --> Uncomment the desired device definitions #### -#### From Teensy41 USB definitions #### -# CONFIG_USB_DEVICE_VID=0x16C0 -# CONFIG_USB_DEVICE_PID=0x0483 - #### From Raspberry Pi Pico2 USB Definitions #### CONFIG_USB_DEVICE_PID=0x000F CONFIG_USB_DEVICE_VID=0x2E8A -#### From Raspberry Pi Pico USB Definitions #### -# CONFIG_USB_DEVICE_PID=0x0003 -# CONFIG_USB_DEVICE_VID=0x2E8A - #### F Prime C++ Dependencies #### CONFIG_CPP=y CONFIG_REQUIRES_FULL_LIBCPP=y @@ -56,31 +48,9 @@ CONFIG_PRINTK=y CONFIG_UART_CONSOLE=y CONFIG_COMMON_LIBC_MALLOC=y -# Sensors CONFIG_SENSOR=y -CONFIG_LSM6DSO=y -CONFIG_LSM6DSO_ENABLE_TEMP=y -CONFIG_LIS2MDL=y -CONFIG_INA219=y - -# Zbus -# CONFIG_ZBUS=y -# CONFIG_ZBUS_CHANNEL_NAME=y -# CONFIG_ZBUS_OBSERVER_NAME=y -# CONFIG_ZBUS_MSG_SUBSCRIBER=y -# CONFIG_ZBUS_LOG_LEVEL_DBG=n -# CONFIG_ZBUS_LOG_LEVEL_INF=y -# Lora -CONFIG_LORA=y -CONFIG_LORA_SX127X=y - -# RTC -CONFIG_RTC=y -CONFIG_RTC_RV3028=y - -# Logging CONFIG_LOG=y CONFIG_LOG_DEFAULT_LEVEL=3 -# Compiler settings + CONFIG_CBPRINTF_FP_SUPPORT=y