Skip to content

Commit

Permalink
imxrt: move all required code to noxip
Browse files Browse the repository at this point in the history
JIRA: RTOS-???
  • Loading branch information
badochov committed Oct 2, 2024
1 parent b5a0f8f commit 803aa7b
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 30 deletions.
8 changes: 6 additions & 2 deletions _startc.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,12 @@ void _startc(int argc, char **argv, char **env)
size_t i, size;

/* Load .fastram.text, .data and .rodata sections */
if (__ramtext_start != __ramtext_load)
hal_memcpy(__ramtext_start, __ramtext_load, __ramtext_end - __ramtext_start);
if (__ramtext_start != __ramtext_load) {
/* hal_memcpy may reside in fastram. */
for (i = 0; i <= __ramtext_end - __ramtext_start; i++) {
__ramtext_start[i] = __ramtext_load[i];
}
}

if (__data_start != __data_load)
hal_memcpy(__data_start, __data_load, __data_end - __data_start);
Expand Down
4 changes: 2 additions & 2 deletions devices/flash-imxrt/fspi/fspi_rt105x.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ enum { mcr0 = 0, mcr1, mcr2, ahbcr, inten, intr, lutkey, lutcr, ahbrxbuf0cr0, ah
#define AHBRXBUF_CNT 4


static inline addr_t flexspi_ahbAddr(int instance)
__attribute__((section(".noxip"))) static inline addr_t flexspi_ahbAddr(int instance)
{
return (instance == flexspi_instance1) ? 0x60000000 : 0;
}

static inline void *flexspi_getBase(int instance)
__attribute__((section(".noxip"))) static inline void *flexspi_getBase(int instance)
{
return instance == flexspi_instance1 ? (void *)0x402a8000 : NULL;
}
Expand Down
4 changes: 2 additions & 2 deletions devices/flash-imxrt/fspi/fspi_rt106x.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ enum { mcr0 = 0, mcr1, mcr2, ahbcr, inten, intr, lutkey, lutcr, ahbrxbuf0cr0, ah
#define AHBRXBUF_CNT 4


static addr_t flexspi_ahbAddr(int instance)
__attribute__((section(".noxip"))) static addr_t flexspi_ahbAddr(int instance)
{
switch (instance) {
case flexspi_instance1: return 0x60000000;
Expand All @@ -40,7 +40,7 @@ static addr_t flexspi_ahbAddr(int instance)
}


static void *flexspi_getBase(int instance)
__attribute__((section(".noxip"))) static void *flexspi_getBase(int instance)
{
switch (instance) {
case flexspi_instance1: return (void *)0x402a8000;
Expand Down
4 changes: 2 additions & 2 deletions devices/flash-imxrt/fspi/fspi_rt117x.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ enum { mcr0 = 0, mcr1, mcr2, ahbcr, inten, intr, lutkey, lutcr, ahbrxbuf0cr0, ah
#define AHBRXBUF_CNT 8


static addr_t flexspi_ahbAddr(int instance)
__attribute__((section(".noxip"))) static addr_t flexspi_ahbAddr(int instance)
{
switch (instance) {
case flexspi_instance1: return 0x30000000;
Expand All @@ -43,7 +43,7 @@ static addr_t flexspi_ahbAddr(int instance)
}


static void *flexspi_getBase(int instance)
__attribute__((section(".noxip"))) static void *flexspi_getBase(int instance)
{
switch (instance) {
case flexspi_instance1: return (void *)0x400cc000;
Expand Down
2 changes: 1 addition & 1 deletion hal/armv7m/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ unsigned int hal_cpuID(void)
}


void hal_cpuReboot(void)
__attribute__((section(".noxip"))) void hal_cpuReboot(void)
{
hal_cpuDataSyncBarrier();
*(cpu_common.scb + scb_aircr) = ((0x5fa << 16) | (*(cpu_common.scb + scb_aircr) & (0x700)) | (1 << 0x02));
Expand Down
21 changes: 5 additions & 16 deletions hal/armv7m/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,17 @@
#include <hal/hal.h>


static inline void hal_cpuDataMemoryBarrier(void)
{
__asm__ volatile ("dmb");
}
/* NOTE: defined as macros to make sure there are no calls to code in flash in .noxip sections. */
#define hal_cpuDataMemoryBarrier() do { __asm__ volatile ("dmb"); } while(0)


static inline void hal_cpuDataSyncBarrier(void)
{
__asm__ volatile ("dsb");
}
#define hal_cpuDataSyncBarrier() do { __asm__ volatile ("dsb"); } while(0)


static inline void hal_cpuInstrBarrier(void)
{
__asm__ volatile ("isb");
}
#define hal_cpuInstrBarrier() do { __asm__ volatile ("isb"); } while(0)


static inline void hal_cpuHalt(void)
{
__asm__ volatile ("wfi");
}
#define hal_cpuHalt() do { __asm__ volatile ("wfi"); } while(0)


extern void hal_scbSetPriorityGrouping(u32 group);
Expand Down
2 changes: 1 addition & 1 deletion hal/armv7m/imxrt/10xx/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void hal_consoleSetHooks(ssize_t (*writeHook)(int, const void *, size_t))
}


void hal_consolePrint(const char *s)
__attribute__((section(".noxip"))) void hal_consolePrint(const char *s)
{
const char *ptr;

Expand Down
8 changes: 4 additions & 4 deletions hal/armv7m/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <hal/string.h>


void *hal_memcpy(void *dst, const void *src, size_t l)
__attribute__((section(".noxip"))) void *hal_memcpy(void *dst, const void *src, size_t l)
{
void *ret = dst;

Expand Down Expand Up @@ -105,7 +105,7 @@ void hal_memset(void *dst, int v, size_t l)
}


size_t hal_strlen(const char *s)
__attribute__((section(".noxip"))) size_t hal_strlen(const char *s)
{
size_t k = 0;

Expand Down Expand Up @@ -186,7 +186,7 @@ int hal_strncmp(const char *s1, const char *s2, size_t count)
}


char *hal_strcpy(char *dest, const char *src)
__attribute__((section(".noxip"))) char *hal_strcpy(char *dest, const char *src)
{
char *p = dest;

Expand Down Expand Up @@ -240,7 +240,7 @@ char *hal_strchr(const char *s, int c)
}


int hal_i2s(char *prefix, char *s, unsigned int i, unsigned char b, char zero)
__attribute__((section(".noxip"))) int hal_i2s(char *prefix, char *s, unsigned int i, unsigned char b, char zero)
{
static const char digits[] = "0123456789abcdef";
char c;
Expand Down

0 comments on commit 803aa7b

Please sign in to comment.