eenurkka commented on code in PR #12353: URL: https://github.com/apache/nuttx/pull/12353#discussion_r1602650342
########## arch/arm64/src/imx9/imx9_boot.c: ########## @@ -44,19 +44,39 @@ #include "imx9_gpio.h" #include "imx9_lowputc.h" +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC 1700000000 + /**************************************************************************** * Private Data ****************************************************************************/ +#ifdef CONFIG_IMX9_BOOTLOADER +extern uint8_t _szbootloader[]; +#endif + static const struct arm_mmu_region g_mmu_regions[] = { - MMU_REGION_FLAT_ENTRY("DEVICE_REGION", - CONFIG_DEVICEIO_BASEADDR, CONFIG_DEVICEIO_SIZE, - MT_DEVICE_NGNRNE | MT_RW | MT_SECURE), + MMU_REGION_FLAT_ENTRY("DEVICE_REGION", + CONFIG_DEVICEIO_BASEADDR, CONFIG_DEVICEIO_SIZE, + MT_DEVICE_NGNRNE | MT_RW | MT_SECURE), + + MMU_REGION_FLAT_ENTRY("DRAM0_S0", + CONFIG_RAMBANK1_ADDR, CONFIG_RAMBANK1_SIZE, + MT_NORMAL | MT_RW | MT_SECURE), +#ifdef CONFIG_IMX9_BOOTLOADER + /* OCRAM secure region protection keeps the binary at RO mode, + * overriding any MMU settings. However, data and heap accesses + * beyond the binary require RW access. + */ - MMU_REGION_FLAT_ENTRY("DRAM0_S0", - CONFIG_RAMBANK1_ADDR, CONFIG_RAMBANK1_SIZE, - MT_NORMAL | MT_RW | MT_SECURE), + MMU_REGION_FLAT_ENTRY("BOOTLOADER", + (uint64_t)_stext, (uint64_t)_szbootloader, + MT_NORMAL | MT_RW | MT_SECURE), Review Comment: The build fails due to lacking rwx section check of something.. will do something ########## arch/arm64/src/imx9/imx9_boot.c: ########## @@ -44,19 +44,39 @@ #include "imx9_gpio.h" #include "imx9_lowputc.h" +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC 1700000000 Review Comment: Made it Kconfig:able ########## boards/arm64/imx9/imx93-evk/scripts/Make.defs: ########## @@ -20,9 +20,14 @@ include $(TOPDIR)/.config include $(TOPDIR)/tools/Config.mk +include $(TOPDIR)/tools/imx9/Config.mk Review Comment: Missing, yes, will add ########## arch/arm64/src/imx9/imx9_boot.c: ########## @@ -44,19 +44,39 @@ #include "imx9_gpio.h" #include "imx9_lowputc.h" +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC 1700000000 + /**************************************************************************** * Private Data ****************************************************************************/ +#ifdef CONFIG_IMX9_BOOTLOADER +extern uint8_t _szbootloader[]; +#endif + static const struct arm_mmu_region g_mmu_regions[] = { - MMU_REGION_FLAT_ENTRY("DEVICE_REGION", - CONFIG_DEVICEIO_BASEADDR, CONFIG_DEVICEIO_SIZE, - MT_DEVICE_NGNRNE | MT_RW | MT_SECURE), + MMU_REGION_FLAT_ENTRY("DEVICE_REGION", + CONFIG_DEVICEIO_BASEADDR, CONFIG_DEVICEIO_SIZE, + MT_DEVICE_NGNRNE | MT_RW | MT_SECURE), + + MMU_REGION_FLAT_ENTRY("DRAM0_S0", + CONFIG_RAMBANK1_ADDR, CONFIG_RAMBANK1_SIZE, + MT_NORMAL | MT_RW | MT_SECURE), +#ifdef CONFIG_IMX9_BOOTLOADER + /* OCRAM secure region protection keeps the binary at RO mode, + * overriding any MMU settings. However, data and heap accesses + * beyond the binary require RW access. + */ - MMU_REGION_FLAT_ENTRY("DRAM0_S0", - CONFIG_RAMBANK1_ADDR, CONFIG_RAMBANK1_SIZE, - MT_NORMAL | MT_RW | MT_SECURE), + MMU_REGION_FLAT_ENTRY("BOOTLOADER", + (uint64_t)_stext, (uint64_t)_szbootloader, + MT_NORMAL | MT_RW | MT_SECURE), Review Comment: Yes, the code is still RX, overriding any MMU values. Perhaps this could start from _etext, but then it would need to be aligned. Maybe it could be sorted out later? If I did align _etext / _srodata: 00000000204c57ec T _etext 00000000204c57f0 A _srodata , it starts extending and overlapping with a always-zero section, which makes the code useless. But yes, somehow this could be done in a better way. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org