Skip to content

Commit

Permalink
v6x-rt: Add reboot into isp bootloader mode
Browse files Browse the repository at this point in the history
  • Loading branch information
PetervdPerk-NXP committed Jan 2, 2024
1 parent 1e0b6d9 commit 7a890af
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
2 changes: 2 additions & 0 deletions boards/px4/fmu-v6xrt/src/board_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,8 @@

/* This board provides the board_on_reset interface */

#define BOARD_HAS_ISP_BOOTLOADER 1

#define BOARD_HAS_ON_RESET 1

#define PX4_GPIO_INIT_LIST { \
Expand Down
2 changes: 2 additions & 0 deletions platforms/nuttx/src/px4/nxp/imxrt/board_reset/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ px4_add_library(arch_board_reset
board_reset.cpp
)

target_link_libraries(arch_board_reset PRIVATE arch_board_romapi)

# up_systemreset
if (NOT DEFINED CONFIG_BUILD_FLAT)
target_link_libraries(arch_board_reset PRIVATE nuttx_karch)
Expand Down
9 changes: 9 additions & 0 deletions platforms/nuttx/src/px4/nxp/imxrt/board_reset/board_reset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@
#include <arm_internal.h>
#include <hardware/rt117x/imxrt117x_snvs.h>


#include <px4_arch/imxrt_flexspi_nor_flash.h>
#include <px4_arch/imxrt_romapi.h>

#define BOOT_RTC_SIGNATURE 0xb007b007
#define PX4_IMXRT_RTC_REBOOT_REG 3
#define PX4_IMXRT_RTC_REBOOT_REG_ADDRESS IMXRT_SNVS_LPGPR3
Expand All @@ -63,6 +67,11 @@ int board_reset(int status)
{
if (status == 1) {
board_reset_enter_bootloader();

} else if (status == 2) {
uint32_t arg = 0xeb100000;
ROM_API_Init();
ROM_RunBootloader(&arg);
}

#if defined(BOARD_HAS_ON_RESET)
Expand Down
13 changes: 12 additions & 1 deletion src/systemcmds/reboot/reboot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,17 @@
#include <px4_platform_common/module.h>
#include <px4_platform_common/shutdown.h>
#include <string.h>
#include <board_config.h>

static void print_usage()
{
PRINT_MODULE_DESCRIPTION("Reboot the system");

PRINT_MODULE_USAGE_NAME_SIMPLE("reboot", "command");
PRINT_MODULE_USAGE_PARAM_FLAG('b', "Reboot into bootloader", true);
#ifdef BOARD_HAS_ISP_BOOTLOADER
PRINT_MODULE_USAGE_PARAM_FLAG('i', "Reboot into ISP (1st stage bootloader)", true);
#endif

PRINT_MODULE_USAGE_ARG("lock|unlock", "Take/release the shutdown lock (for testing)", true);
}
Expand All @@ -63,12 +67,19 @@ extern "C" __EXPORT int reboot_main(int argc, char *argv[])
int myoptind = 1;
const char *myoptarg = nullptr;

while ((ch = px4_getopt(argc, argv, "b", &myoptind, &myoptarg)) != -1) {
while ((ch = px4_getopt(argc, argv, "bi", &myoptind, &myoptarg)) != -1) {
switch (ch) {
case 'b':
to_bootloader = true;
break;

#ifdef BOARD_HAS_ISP_BOOTLOADER

case 'i':
board_reset(2);
break;
#endif

default:
print_usage();
return 1;
Expand Down

0 comments on commit 7a890af

Please sign in to comment.