Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions boards/tfh/diamond_main/diamond_main.dts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@

// for gpio based tachometer (coarse estimation)
fan-main-tach-gpios = <&gpiod 7 GPIO_ACTIVE_HIGH>;

// request security MCU reboot
exp-mcu-rst-rqst-gpios = <&gpio_exp1 11 GPIO_ACTIVE_HIGH>;
};

buttons {
Expand Down
15 changes: 15 additions & 0 deletions main_board/src/cli/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,20 @@ execute_date(const struct shell *sh, size_t argc, char **argv)
}

#ifdef CONFIG_BOARD_DIAMOND_MAIN
static int
execute_reboot_sec_mcu(const struct shell *sh, size_t argc, char **argv)
{
UNUSED_PARAMETER(argc);
UNUSED_PARAMETER(argv);

orb_mcu_main_JetsonToMcu message = {
.which_payload = orb_mcu_main_JetsonToMcu_reboot_security_mcu_tag,
};

shell_print(sh, "Requesting security MCU reboot");
return runner_handle_new_cli(&message);
}

static int
execute_white_leds(const struct shell *sh, size_t argc, char **argv)
{
Expand Down Expand Up @@ -825,6 +839,7 @@ SHELL_STATIC_SUBCMD_SET_CREATE(
#ifdef CONFIG_BOARD_DIAMOND_MAIN
SHELL_CMD(white_leds, NULL, "Control white LEDs", execute_white_leds),
SHELL_CMD(polarizer, NULL, "Control polarizer wheel", execute_polarizer),
SHELL_CMD(reboot_sec, NULL, "Reboot security MCU", execute_reboot_sec_mcu),
#endif
SHELL_CMD(stats, NULL, "Show runner statistics", execute_runner_stats),
SHELL_CMD(ping_sec, NULL, "Send ping to security MCU", execute_ping_sec),
Expand Down
50 changes: 49 additions & 1 deletion main_board/src/runner/runner.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,15 @@
#include <stdlib.h>
#include <uart_messaging.h>
#include <ui/rgb_leds/front_leds/front_leds.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/kernel.h>

#if defined(CONFIG_BOARD_DIAMOND_MAIN)
#include "ui/rgb_leds/cone_leds/cone_leds.h"
#include "ui/white_leds/white_leds.h"

static const struct gpio_dt_spec exp_mcu_rst_rqst_gpio_spec =
GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), exp_mcu_rst_rqst_gpios);
#endif

#if defined(CONFIG_MEMFAULT_METRICS_CONNECTIVITY_CONNECTED_TIME)
Expand Down Expand Up @@ -1168,6 +1172,48 @@ handle_power_cycle(job_t *job)
}

#ifdef CONFIG_BOARD_DIAMOND_MAIN
static void
handle_reboot_security_mcu(job_t *job)
{
orb_mcu_main_JetsonToMcu *msg = &job->message.jetson_cmd;
MAKE_ASSERTS(orb_mcu_main_JetsonToMcu_reboot_security_mcu_tag);

int ret;

if (!gpio_is_ready_dt(&exp_mcu_rst_rqst_gpio_spec)) {
LOG_ERR("GPIO for security MCU reset request not ready");
job_ack(orb_mcu_Ack_ErrorCode_FAIL, job);
return;
}

ret = gpio_pin_configure_dt(&exp_mcu_rst_rqst_gpio_spec,
GPIO_OUTPUT_INACTIVE);
if (ret != 0) {
LOG_ERR("Failed to configure GPIO: %d", ret);
job_ack(orb_mcu_Ack_ErrorCode_FAIL, job);
return;
}

ret = gpio_pin_set_dt(&exp_mcu_rst_rqst_gpio_spec, 1);
if (ret != 0) {
LOG_ERR("Failed to set GPIO high: %d", ret);
job_ack(orb_mcu_Ack_ErrorCode_FAIL, job);
return;
}

k_msleep(100);

ret = gpio_pin_set_dt(&exp_mcu_rst_rqst_gpio_spec, 0);
if (ret != 0) {
LOG_ERR("Failed to set GPIO low: %d", ret);
job_ack(orb_mcu_Ack_ErrorCode_FAIL, job);
return;
}

LOG_INF("Security MCU reboot requested");
job_ack(orb_mcu_Ack_ErrorCode_SUCCESS, job);
}

static void
handle_polarizer(job_t *job)
{
Expand Down Expand Up @@ -1805,6 +1851,8 @@ static const hm_callback handle_message_callbacks[] = {
[orb_mcu_main_JetsonToMcu_polarizer_tag] = handle_polarizer,
[orb_mcu_main_JetsonToMcu_polarizer_wheel_settings_tag] =
handle_polarizer_wheel_settings,
[orb_mcu_main_JetsonToMcu_reboot_security_mcu_tag] =
handle_reboot_security_mcu,
#elif defined(CONFIG_BOARD_PEARL_MAIN)
[orb_mcu_main_JetsonToMcu_cone_leds_sequence_tag] = handle_not_supported,
[orb_mcu_main_JetsonToMcu_cone_leds_pattern_tag] = handle_not_supported,
Expand All @@ -1814,7 +1862,7 @@ static const hm_callback handle_message_callbacks[] = {
#endif
};

BUILD_ASSERT((ARRAY_SIZE(handle_message_callbacks) <= 56),
BUILD_ASSERT((ARRAY_SIZE(handle_message_callbacks) <= 57),
"It seems like the `handle_message_callbacks` array is too large");

_Noreturn static void
Expand Down
2 changes: 1 addition & 1 deletion west.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ manifest:
remote: memfault
revision: 1.31.0
- name: orb-messages
revision: cac4f26ae09ca75ca2e2911376e5273be8454a52
revision: 3644a0635cd3c8304536de1a166785ff46c8b63f
path: modules/orb-messages/public
- name: priv-orb-messages
revision: 0da6bab271385e952813bfcbef9ce9bf38b0f27a
Expand Down