Skip to content

Commit d1b1502

Browse files
authored
add BootloaderTrigger component (#32)
1 parent 1885213 commit d1b1502

File tree

8 files changed

+206
-1
lines changed

8 files changed

+206
-1
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// ======================================================================
2+
// \title BootloaderTrigger.cpp
3+
// \author aychar
4+
// \brief cpp file for BootloaderTrigger component implementation class
5+
// ======================================================================
6+
7+
#include "FprimeZephyrReference/Components/BootloaderTrigger/BootloaderTrigger.hpp"
8+
9+
#include <pico/bootrom.h>
10+
11+
namespace Components {
12+
13+
// ----------------------------------------------------------------------
14+
// Component construction and destruction
15+
// ----------------------------------------------------------------------
16+
17+
BootloaderTrigger ::BootloaderTrigger(const char* const compName) : BootloaderTriggerComponentBase(compName) {}
18+
19+
BootloaderTrigger ::~BootloaderTrigger() {}
20+
21+
// In the future this command/component should either be removed entirely, or some kind of protection
22+
// should be added to ensure this can't be ran when the satellite is in space
23+
void BootloaderTrigger ::TRIGGER_BOOTLOADER_cmdHandler(FwOpcodeType opCode, U32 cmdSeq) {
24+
reset_usb_boot(0, 0);
25+
}
26+
27+
} // namespace Components
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
module Components {
2+
@ Used to trigger bootloader mode to install board firmware for integration testing. (DO NOT USE IN SPACE VERY BAD!!!!)
3+
passive component BootloaderTrigger {
4+
5+
@ Restarts board and puts it in bootloader mode. (Only should be used for integration testing)
6+
sync command TRIGGER_BOOTLOADER(
7+
)
8+
9+
###############################################################################
10+
# Standard AC Ports: Required for Channels, Events, Commands, and Parameters #
11+
###############################################################################
12+
@ Port for requesting the current time
13+
time get port timeCaller
14+
15+
@ Port for sending command registrations
16+
command reg port cmdRegOut
17+
18+
@ Port for receiving commands
19+
command recv port cmdIn
20+
21+
@ Port for sending command responses
22+
command resp port cmdResponseOut
23+
24+
}
25+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// ======================================================================
2+
// \title BootloaderTrigger.hpp
3+
// \author aychar
4+
// \brief hpp file for BootloaderTrigger component implementation class
5+
// ======================================================================
6+
7+
#ifndef Components_BootloaderTrigger_HPP
8+
#define Components_BootloaderTrigger_HPP
9+
10+
#include "FprimeZephyrReference/Components/BootloaderTrigger/BootloaderTriggerComponentAc.hpp"
11+
12+
namespace Components {
13+
14+
class BootloaderTrigger final : public BootloaderTriggerComponentBase {
15+
public:
16+
// ----------------------------------------------------------------------
17+
// Component construction and destruction
18+
// ----------------------------------------------------------------------
19+
20+
//! Construct BootloaderTrigger object
21+
BootloaderTrigger(const char* const compName //!< The component name
22+
);
23+
24+
//! Destroy BootloaderTrigger object
25+
~BootloaderTrigger();
26+
27+
private:
28+
void TRIGGER_BOOTLOADER_cmdHandler(FwOpcodeType opCode, //!< The opcode
29+
U32 cmdSeq //!< The command sequence number
30+
) override;
31+
};
32+
33+
} // namespace Components
34+
35+
#endif
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
####
2+
# F Prime CMakeLists.txt:
3+
#
4+
# SOURCES: list of source files (to be compiled)
5+
# AUTOCODER_INPUTS: list of files to be passed to the autocoders
6+
# DEPENDS: list of libraries that this module depends on
7+
#
8+
# More information in the F´ CMake API documentation:
9+
# https://fprime.jpl.nasa.gov/latest/docs/reference/api/cmake/API/
10+
#
11+
####
12+
13+
# Module names are derived from the path from the nearest project/library/framework
14+
# root when not specifically overridden by the developer. i.e. The module defined by
15+
# `Ref/SignalGen/CMakeLists.txt` will be named `Ref_SignalGen`.
16+
17+
register_fprime_library(
18+
AUTOCODER_INPUTS
19+
"${CMAKE_CURRENT_LIST_DIR}/BootloaderTrigger.fpp"
20+
SOURCES
21+
"${CMAKE_CURRENT_LIST_DIR}/BootloaderTrigger.cpp"
22+
# DEPENDS
23+
# MyPackage_MyOtherModule
24+
)
25+
26+
### Unit Tests ###
27+
# register_fprime_ut(
28+
# AUTOCODER_INPUTS
29+
# "${CMAKE_CURRENT_LIST_DIR}/BootloaderTrigger.fpp"
30+
# SOURCES
31+
# "${CMAKE_CURRENT_LIST_DIR}/test/ut/BootloaderTriggerTestMain.cpp"
32+
# "${CMAKE_CURRENT_LIST_DIR}/test/ut/BootloaderTriggerTester.cpp"
33+
# DEPENDS
34+
# STest # For rules-based testing
35+
# UT_AUTO_HELPERS
36+
# )
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Components::BootloaderTrigger
2+
3+
The BootloaderTrigger component provides a command interface to reset the board into bootloader mode for firmware installation during integration testing. **WARNING: This component should NOT be used in production or flight configurations.**
4+
5+
## Usage Examples
6+
7+
The BootloaderTrigger component is designed to facilitate firmware updates during ground testing and integration. It operates as a passive component that responds to commands.
8+
9+
### Typical Usage
10+
11+
1. The component is instantiated during system startup
12+
2. During integration testing, when firmware needs to be updated:
13+
- The `TRIGGER_BOOTLOADER` command is sent to the component
14+
- The board immediately resets into bootloader mode
15+
- Firmware can then be uploaded via USB
16+
17+
**IMPORTANT:** This component should be removed or disabled for flight builds to prevent accidental activation in space.
18+
19+
## Class Diagram
20+
21+
```mermaid
22+
classDiagram
23+
namespace Components {
24+
class BootloaderTriggerComponentBase {
25+
<<Auto-generated>>
26+
}
27+
class BootloaderTrigger {
28+
+ BootloaderTrigger(const char* compName)
29+
+ ~BootloaderTrigger()
30+
- TRIGGER_BOOTLOADER_cmdHandler(FwOpcodeType opCode, U32 cmdSeq)
31+
}
32+
}
33+
BootloaderTriggerComponentBase <|-- BootloaderTrigger : inherits
34+
```
35+
36+
## Port Descriptions
37+
38+
| Name | Type | Description |
39+
| -------------- | ------------ | -------------------------------------- |
40+
| cmdIn | command recv | Port for receiving commands |
41+
| cmdResponseOut | command resp | Port for sending command responses |
42+
| cmdRegOut | command reg | Port for sending command registrations |
43+
| timeCaller | time get | Port for requesting the current time |
44+
45+
## Sequence Diagrams
46+
47+
```mermaid
48+
sequenceDiagram
49+
participant Ground System
50+
participant Command Dispatcher
51+
participant BootloaderTrigger
52+
participant Pico Bootrom
53+
54+
Ground System->>Command Dispatcher: Send TRIGGER_BOOTLOADER command
55+
Command Dispatcher->>BootloaderTrigger: cmdIn(TRIGGER_BOOTLOADER)
56+
BootloaderTrigger->>Pico Bootrom: reset_usb_boot(0, 0)
57+
Note over BootloaderTrigger,Pico Bootrom: Board resets into bootloader mode
58+
Note over Ground System: Board now accepts firmware upload via USB
59+
```
60+
61+
## Commands
62+
63+
| Name | Description |
64+
| ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
65+
| TRIGGER_BOOTLOADER | Restarts the board and puts it into bootloader mode. This is a synchronous command that triggers an immediate reset. Should only be used during integration testing. |
66+
67+
## Requirements
68+
69+
| Name | Description | Validation |
70+
| --------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
71+
| TRIGGER_BOOTLOADER Command | The component shall provide a command interface to reset the board into bootloader mode using the Pico bootrom API | Verify that sending the command causes the board to reset and enter bootloader mode, allowing firmware upload |
72+
| Safety Warning | The component shall include clear documentation warnings that it must not be used in flight configurations | Documentation review and code review process |
73+
| Integration Testing Support | The component shall enable firmware updates during ground integration testing without requiring physical access to boot pins | Verify successful firmware updates can be performed remotely during testing |
74+
75+
## Change Log
76+
77+
| Date | Description |
78+
| ---------- | ------------- |
79+
| 2025-10-01 | Initial Draft |

FprimeZephyrReference/Components/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Drv/")
44
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/FatalHandler")
55
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/ImuManager/")
66
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Watchdog")
7+
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/BootloaderTrigger/")

FprimeZephyrReference/ReferenceDeployment/Top/instances.fpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,6 @@ module ReferenceDeployment {
6868
instance lis2mdlManager: Drv.Lis2mdlManager base id 0x10018000
6969

7070
instance lsm6dsoManager: Drv.Lsm6dsoManager base id 0x10019000
71+
72+
instance bootloaderTrigger: Components.BootloaderTrigger base id 0x10020000
7173
}

FprimeZephyrReference/ReferenceDeployment/Top/topology.fpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ module ReferenceDeployment {
3232
instance imuManager
3333
instance lis2mdlManager
3434
instance lsm6dsoManager
35-
35+
instance bootloaderTrigger
3636
# ----------------------------------------------------------------------
3737
# Pattern graph specifiers
3838
# ----------------------------------------------------------------------

0 commit comments

Comments
 (0)