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 b7b2e6b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
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
7 changes: 6 additions & 1 deletion src/systemcmds/reboot/reboot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ static void print_usage()

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

PRINT_MODULE_USAGE_ARG("lock|unlock", "Take/release the shutdown lock (for testing)", true);
}
Expand All @@ -63,12 +64,16 @@ 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;

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

default:
print_usage();
return 1;
Expand Down

0 comments on commit b7b2e6b

Please sign in to comment.