Skip to content

Commit

Permalink
Commit Info for Bootloaders (#1263)
Browse files Browse the repository at this point in the history
### Changelist 
<!-- Give a list of the changes covered in this PR. This will help both
you and the reviewer keep this PR within scope. -->
- Adds commit info message to bootloader.
- Generates JSONCAN for bootloader
- GraphVIZ configs for CMake

### Testing Done
<!-- Outline the testing that was done to demonstrate the changes are
solid. This could be unit tests, integration tests, testing on the car,
etc. Include relevant code snippets, screenshots, etc as needed. -->

### Resolved Tickets
<!-- Link any tickets that this PR resolves. -->
  • Loading branch information
Lucien950 authored May 21, 2024
1 parent 9772f87 commit 9426dba
Show file tree
Hide file tree
Showing 13 changed files with 511 additions and 498 deletions.
1 change: 1 addition & 0 deletions CMakeGraphVizOptions.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
set(GRAPHVIZ_CUSTOM_TARGETS TRUE)
142 changes: 89 additions & 53 deletions can_bus/quadruna/Boot/Boot_tx.json
Original file line number Diff line number Diff line change
@@ -1,56 +1,92 @@
{
"VC": {
"msg_id": 1219,
"cycle_time": 100,
"signals": {
"VC_Status": {
"enum": "BootStatus"
}
"VC": {
"msg_id": 1219,
"cycle_time": 100,
"signals": {
"VC_Hash": {
"bits": 32
},
"VC_Clean": {
"bits": 1
},
"VC_Status": {
"enum": "BootStatus"
}
}
},
"BMS": {
"msg_id": 1209,
"cycle_time": 100,
"signals": {
"BMS_Hash": {
"bits": 32
},
"BMS_Clean": {
"bits": 1
},
"BMS_Status": {
"enum": "BootStatus"
}
}
},
"RSM": {
"msg_id": 1239,
"cycle_time": 100,
"signals": {
"RSM_Hash": {
"bits": 32
},
"RSM_Clean": {
"bits": 1
},
"RSM_Status": {
"enum": "BootStatus"
}
}
},
"FSM": {
"msg_id": 1229,
"cycle_time": 100,
"signals": {
"FSM_Hash": {
"bits": 32
},
"FSM_Clean": {
"bits": 1
},
"FSM_Status": {
"enum": "BootStatus"
}
}
},
"CRIT": {
"msg_id": 1249,
"cycle_time": 100,
"signals": {
"CRIT_Hash": {
"bits": 32
},
"CRIT_Clean": {
"bits": 1
},
"CRIT_Status": {
"enum": "BootStatus"
}
}
},
"H7Dev": {
"msg_id": 1309,
"cycle_time": 100,
"signals": {
"H7Dev_Hash": {
"bits": 32
},
"H7Dev_Clean": {
"bits": 1
},
"H7Dev_Status": {
"enum": "BootStatus"
}
}
}
},
"BMS": {
"msg_id": 1209,
"cycle_time": 100,
"signals": {
"BMS_Status": {
"enum": "BootStatus"
}
}
},
"RSM": {
"msg_id": 1239,
"cycle_time": 100,
"signals": {
"RSM_Status": {
"enum": "BootStatus"
}
}
},
"FSM": {
"msg_id": 1229,
"cycle_time": 100,
"signals": {
"FSM_Status": {
"enum": "BootStatus"
}
}
},
"CRIT": {
"msg_id": 1249,
"cycle_time": 100,
"signals": {
"CRIT_Status": {
"enum": "BootStatus"
}
}
},
"H7Dev": {
"msg_id": 1309,
"cycle_time": 100,
"signals": {
"H7Dev_Status": {
"enum": "BootStatus"
}
}
}
}
3 changes: 2 additions & 1 deletion can_bus/quadruna/VC/VC_rx.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"INVR_InternalStates",
"INVR_MotorPositionInfo",
"INVR_Temperatures3",
"RSM_Vitals"
"RSM_Vitals",
"Boot_VC"
]
}
9 changes: 7 additions & 2 deletions firmware/boot/bootloader.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "hw_crc.h"
#include "main.h"
#include "hw_gpio.h"
#include "app_commitInfo.h"

extern CRC_HandleTypeDef hcrc;
extern TIM_HandleTypeDef htim6;
Expand Down Expand Up @@ -235,8 +236,12 @@ _Noreturn void bootloader_runTickTask(void)
for (;;)
{
// Broadcast a message at 1Hz so we can check status over CAN.
CanMsg status_msg = { .std_id = STATUS_10HZ_ID, .dlc = 1 };
status_msg.data[0] = (uint8_t)verifyAppCodeChecksum();
CanMsg status_msg = { .std_id = STATUS_10HZ_ID, .dlc = 5 };
status_msg.data[0] = (uint8_t)((0x000000ff & GIT_COMMIT_HASH) >> 0);
status_msg.data[1] = (uint8_t)((0x0000ff00 & GIT_COMMIT_HASH) >> 8);
status_msg.data[2] = (uint8_t)((0x00ff0000 & GIT_COMMIT_HASH) >> 16);
status_msg.data[3] = (uint8_t)((0xff000000 & GIT_COMMIT_HASH) >> 24);
status_msg.data[4] = (uint8_t)(verifyAppCodeChecksum() << 1) | GIT_COMMIT_CLEAN;
io_can_pushTxMsgToQueue(&status_msg);

bootloader_boardSpecific_tick();
Expand Down
32 changes: 32 additions & 0 deletions firmware/cmake/shared.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ function(commit_info_library
"${ARM_CORE}"
FALSE
)
target_include_directories("${LIB_NAME}" PUBLIC "${COMMIT_INFO_INCLUDE_DIR}")
elseif("${TARGET}" STREQUAL "test")
get_filename_component(HEADER_DIR "${HEADER_OUTPUT_PATH}" DIRECTORY)
add_library(
Expand All @@ -35,4 +36,35 @@ function(commit_info_library
)
target_include_directories("${LIB_NAME}" PUBLIC "${HEADER_DIR}")
endif()
endfunction()

# Generates library ${CAR}_${BOARD}_jsoncan
function(jsoncan_embedded_library BOARD CAR JSONCAN_DIR ARM_CORE)
jsoncan_sources(
${BOARD}
${JSONCAN_DIR}
TRUE
${CAR}
)
embedded_library(
"${CAR}_${BOARD}_jsoncan"
"${CAN_SRCS}"
"${CAN_INCLUDE_DIRS}"
"${ARM_CORE}"
TRUE
)
endfunction()

function(jsoncan_library BOARD CAR JSONCAN_DIR)
jsoncan_sources(
${BOARD}
"${JSONCAN_DIR}"
FALSE
${CAR}
)
add_library(
"${CAR}_${BOARD}_jsoncan" STATIC
"${CAN_SRCS}"
)
target_include_directories("${CAR}_${BOARD}_jsoncan" PUBLIC "${CAN_INCLUDE_DIRS}")
endfunction()
Loading

0 comments on commit 9426dba

Please sign in to comment.