Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nxp/imxrt_common/main:Fix Breakage from a9962dc #23174

Merged
merged 4 commits into from
May 29, 2024
Merged
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
Binary file modified boards/px4/fmu-v6xrt/extras/px4_fmu-v6xrt_bootloader.bin
Binary file not shown.
1 change: 1 addition & 0 deletions boards/px4/fmu-v6xrt/nuttx-config/bootloader/defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ CONFIG_ARMV7M_ITCM=y
CONFIG_ARMV7M_MEMCPY=y
CONFIG_ARMV7M_USEBASEPRI=y
CONFIG_ARM_MPU=y
CONFIG_ARM_MPU_RESET=y
CONFIG_BOARDCTL=y
CONFIG_BOARDCTL_RESET=y
CONFIG_BOARD_ASSERT_RESET_VALUE=0
Expand Down
1 change: 1 addition & 0 deletions boards/px4/fmu-v6xrt/nuttx-config/nsh/defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ CONFIG_ARMV7M_ITCM=y
CONFIG_ARMV7M_MEMCPY=y
CONFIG_ARMV7M_USEBASEPRI=y
CONFIG_ARM_MPU=y
CONFIG_ARM_MPU_RESET=y
CONFIG_BOARDCTL_RESET=y
CONFIG_BOARD_ASSERT_RESET_VALUE=0
CONFIG_BOARD_BOOTLOADER_FIXUP=y
Expand Down
2 changes: 1 addition & 1 deletion platforms/nuttx/src/bootloader/common/bl.c
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ void
jump_to_app()
{
const uint32_t *app_base = (const uint32_t *)APP_LOAD_ADDRESS;
const uint32_t *vec_base = (const uint32_t *)app_base + APP_VECTOR_OFFSET;
const uint32_t *vec_base = (const uint32_t *)((const uint32_t)app_base + APP_VECTOR_OFFSET);

/*
* We refuse to program the first word of the app until the upload is marked
Expand Down
24 changes: 22 additions & 2 deletions platforms/nuttx/src/bootloader/nxp/imxrt_common/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "imxrt_clockconfig.h"

#include <nvic.h>
#include <mpu.h>
#include <lib/systick.h>
#include <lib/flash_cache.h>

Expand Down Expand Up @@ -396,7 +397,7 @@ flash_func_sector_size(unsigned sector)
}

/* imxRT uses Flash lib, not up_progmem so let's stub it here */
up_progmem_ispageerased(unsigned sector)
ssize_t up_progmem_ispageerased(unsigned sector)
{
const uint32_t bytes_per_sector = flash_func_sector_size(sector);
uint32_t *address = (uint32_t *)(IMXRT_FLEXSPI1_CIPHER_BASE + (sector * bytes_per_sector));
Expand Down Expand Up @@ -431,9 +432,13 @@ flash_func_erase_sector(unsigned sector, bool force)
return;
}

if (force || flash_func_is_sector_blank(sector) != 0) {
if (force || up_progmem_ispageerased(sector) != 0) {

struct flexspi_nor_config_s *pConfig = &g_bootConfig;

const uint32_t bytes_per_sector = flash_func_sector_size(sector);
uint32_t *address = (uint32_t *)(IMXRT_FLEXSPI1_CIPHER_BASE + (sector * bytes_per_sector));

uintptr_t offset = ((uintptr_t) address) - IMXRT_FLEXSPI1_CIPHER_BASE;
irqstate_t flags;
flags = enter_critical_section();
Expand Down Expand Up @@ -577,6 +582,21 @@ led_toggle(unsigned led)
void
arch_do_jump(const uint32_t *app_base)
{
/* The MPU configuration after booting has ITCM set to MPU_RASR_AP_RORO
* We add this overlaping region to allow the Application to copy code into
* the ITCM when it is booted. With CONFIG_ARM_MPU_RESET defined. The mpu
* init will clear any added regions (after the copy)
*/

mpu_configure_region(IMXRT_ITCM_BASE, 256 * 1024,
davids5 marked this conversation as resolved.
Show resolved Hide resolved
/* Instruction access Enabled */
MPU_RASR_AP_RWRW | /* P:RW U:RW */
MPU_RASR_TEX_NOR /* Normal */
/* Not Cacheable */
/* Not Bufferable */
/* Not Shareable */
/* No Subregion disable */
);

/* extract the stack and entrypoint from the app vector table and go */
uint32_t stacktop = app_base[APP_VECTOR_OFFSET_WORDS];
Expand Down
Loading