Skip to content

Commit

Permalink
Revert "rtt: Reserve memory for RTT buffers in memory map"
Browse files Browse the repository at this point in the history
This reverts commit c2e8bfe.
  • Loading branch information
jmaksymowicz committed Oct 1, 2024
1 parent ebd4d55 commit c14828f
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 63 deletions.
28 changes: 13 additions & 15 deletions devices/pipe-rtt/rtt.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,8 @@ struct rtt_desc {

static struct {
/* NOTE: each buffer must be aligned to cache line */
unsigned char tx[RTT_TXCHANNELS][1024] __attribute__((aligned(32)));
unsigned char rx[RTT_RXCHANNELS][1024] __attribute__((aligned(32)));
} rttBuffers __attribute__((section(".rttmem")));
unsigned char bytes[1024] __attribute__((aligned(32)));
} rttBufferPool[RTT_TXCHANNELS + RTT_RXCHANNELS];


static const char rtt_tagBackward[] = RTT_TAG_BACKWARD;
Expand Down Expand Up @@ -97,10 +96,10 @@ ssize_t rtt_read(int chan, void *buf, size_t count)
todo--;
}

hal_cpuDataMemoryBarrier();

rtt->rxChannel[chan].rd = rd;

hal_cpuDataMemoryBarrier();

return count - todo;
}

Expand All @@ -126,10 +125,10 @@ ssize_t rtt_write(int chan, const void *buf, size_t count)
todo--;
}

hal_cpuDataMemoryBarrier();

rtt->txChannel[chan].wr = wr;

hal_cpuDataMemoryBarrier();

return count - todo;
}

Expand Down Expand Up @@ -172,20 +171,19 @@ void rtt_init(void *addr)
rtt->txChannels = RTT_TXCHANNELS;
rtt->rxChannels = RTT_RXCHANNELS;

m = 0;
for (n = 0; n < rtt->txChannels; n++) {
rtt->txChannel[n].name = rtt_txName[n];
rtt->txChannel[n].ptr = rttBuffers.tx[n];
rtt->txChannel[n].sz = sizeof(rttBuffers.tx[n]);
rtt->txChannel[n].wr = 0;
rtt->txChannel[n].rd = 0;
rtt->txChannel[n].ptr = rttBufferPool[m].bytes;
rtt->txChannel[n].sz = sizeof(rttBufferPool[m].bytes);
m++;
}

for (n = 0; n < rtt->rxChannels; n++) {
rtt->rxChannel[n].name = rtt_rxName[n];
rtt->rxChannel[n].ptr = rttBuffers.rx[n];
rtt->rxChannel[n].sz = sizeof(rttBuffers.rx[n]);
rtt->rxChannel[n].wr = 0;
rtt->rxChannel[n].rd = 0;
rtt->rxChannel[n].ptr = rttBufferPool[m].bytes;
rtt->rxChannel[n].sz = sizeof(rttBufferPool[m].bytes);
m++;
}

n = 0;
Expand Down
2 changes: 1 addition & 1 deletion hal/armv7m/imxrt/10xx/105x/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ CFLAGS+= -mfloat-abi=soft
PLO_COMMANDS ?= alias app blob bridge call console copy devices dump echo erase go help kernel \
kernelimg map mem mpu otp phfs ptable reboot script stop wait

# pipe-rtt is disabled due to small amount of space in DTCM; RTT_ENABLED_PLO is not defined for this architecture
# pipe-rtt is disabled due to small amount of space in DTCM; RTT_ADDR is not defined for this architecture
PLO_ALLDEVICES := usbc-cdc uart-imxrt106x flash-imxrt

OBJS += $(addprefix $(PREFIX_O)hal/$(TARGET_SUFF)/imxrt/10xx/105x/, _init.o imxrt.o)
5 changes: 3 additions & 2 deletions hal/armv7m/imxrt/10xx/106x/peripherals.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@


/* DEBUG - RTT PIPE */
#ifndef RTT_ENABLED_PLO
#define RTT_ENABLED_PLO 1
#ifndef RTT_ADDR
/* RTT descriptors location, last 256 bytes of DTCM */
#define RTT_ADDR (0x20058000 - 0x100)
#endif


Expand Down
5 changes: 3 additions & 2 deletions hal/armv7m/imxrt/117x/peripherals.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@

/* DEBUG - RTT PIPE */

#ifndef RTT_ENABLED_PLO
#define RTT_ENABLED_PLO 1
#ifndef RTT_ADDR
/* RTT descriptors location, last 256 bytes of DTCM */
#define RTT_ADDR (0x20040000 - 0x100)
#endif


Expand Down
7 changes: 2 additions & 5 deletions hal/armv7m/imxrt/hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ extern char __data_start[], __data_end[];
extern char __bss_start[], __bss_end[];
extern char __heap_base[], __heap_limit[];
extern char __stack_top[], __stack_limit[];
#if RTT_ENABLED_PLO
extern char __rttmem_rttcb[];
#endif

/* Timer */
extern void timer_init(void);
Expand Down Expand Up @@ -61,8 +58,8 @@ void hal_init(void)
timer_init();
otp_init();

#if RTT_ENABLED_PLO
rtt_init(__rttmem_rttcb);
#ifdef RTT_ADDR
rtt_init((void *)RTT_ADDR);
#endif

console_init();
Expand Down
7 changes: 2 additions & 5 deletions hal/armv7m/stm32/hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ extern char __data_start[], __data_end[];
extern char __bss_start[], __bss_end[];
extern char __heap_base[], __heap_limit[];
extern char __stack_top[], __stack_limit[];
#if RTT_ENABLED_PLO
extern char __rttmem_rttcb[];
#endif

/* Timer */
extern void timer_init(void);
Expand Down Expand Up @@ -63,8 +60,8 @@ void hal_init(void)
mpu_init();
timer_init();

#if RTT_ENABLED_PLO
rtt_init(__rttmem_rttcb);
#ifdef RTT_ADDR
rtt_init((void *)RTT_ADDR);
#endif

console_init();
Expand Down
8 changes: 1 addition & 7 deletions ld/armv7m4-stm32l4x6.ldt
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,13 @@
/* Space reserved for kernel data */
#define AREA_KERNEL 0x10000

/* Space reserved for RTT control block and buffers */
#define SIZE_RTTMEM (2 * 2 * 0x400 + 256)


#if defined(__LINKER__)

/* Memory map setup */
MEMORY
{
m_sram (rwx) : ORIGIN = RAM_ADDR + AREA_KERNEL, LENGTH = (256k + 64k) - AREA_KERNEL - SIZE_RTTMEM
m_rttmem (rw) : ORIGIN = RAM_ADDR + (256k + 64k) - SIZE_RTTMEM, LENGTH = SIZE_RTTMEM
m_sram (rwx) : ORIGIN = RAM_ADDR + AREA_KERNEL, LENGTH = (256k + 64k) - AREA_KERNEL
m_flash2 (rx) : ORIGIN = FLASH_PROGRAM_2_ADDR, LENGTH = 512k
m_flash1 (rx) : ORIGIN = FLASH_PROGRAM_1_ADDR, LENGTH = 512k
}
Expand All @@ -55,10 +51,8 @@ REGION_ALIAS("DATA", m_sram);
REGION_ALIAS("BSS", m_sram);
REGION_ALIAS("HEAP", m_sram);
REGION_ALIAS("STACK", m_sram);
REGION_ALIAS("RTTMEM", m_rttmem);

#include "common/plo-arm.lds"
#include "common/plo-rtt.lds"

#endif /* end of __LINKER__ */

Expand Down
8 changes: 1 addition & 7 deletions ld/armv7m7-imxrt106x.ldt
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@
/* Space reserved for kernel data */
#define AREA_KERNEL 0x2000

/* Space reserved for RTT control block and buffers */
#define SIZE_RTTMEM (2 * 2 * 0x400 + 256)


#if defined(__LINKER__)

Expand All @@ -54,8 +51,7 @@ MEMORY
/* TODO: use FLEXRAM_CONFIG value to setup ocram/itcm/dtcm partitioning (*32k) */
m_itcm (rwx) : ORIGIN = 0x00000000, LENGTH = FLEXRAM_ITCM_AREA
m_itext (rwx) : ORIGIN = FLEXRAM_ITEXT_ADDR, LENGTH = FLEXRAM_ITEXT_AREA
m_dtcm (rw) : ORIGIN = 0x20000000 + AREA_KERNEL, LENGTH = FLEXRAM_DTCM_AREA - AREA_KERNEL - SIZE_RTTMEM
m_rttmem (rw) : ORIGIN = 0x20000000 + FLEXRAM_DTCM_AREA - SIZE_RTTMEM, LENGTH = SIZE_RTTMEM
m_dtcm (rw) : ORIGIN = 0x20000000 + AREA_KERNEL, LENGTH = FLEXRAM_DTCM_AREA - AREA_KERNEL
m_ocram (rwx) : ORIGIN = 0x20200000, LENGTH = 0 * 32k
m_flash (rx) : ORIGIN = 0x70000000, LENGTH = 128k /* Not actual flash size. Initial flash size to be put into FCB block for imxrt BootROM init procedure only */
}
Expand All @@ -82,10 +78,8 @@ REGION_ALIAS("TCM_TEXT", m_itext);
REGION_ALIAS("BSS", m_dtcm);
REGION_ALIAS("HEAP", m_dtcm);
REGION_ALIAS("STACK", m_dtcm);
REGION_ALIAS("RTTMEM", m_rttmem);

#include "common/plo-arm.lds"
#include "common/plo-rtt.lds"

#endif /* end of __LINKER__ */

Expand Down
8 changes: 1 addition & 7 deletions ld/armv7m7-imxrt117x.ldt
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@
/* Space reserved for bootloader */
#define AREA_BOOTLOADER 0x10000

/* Space reserved for RTT control block and buffers */
#define SIZE_RTTMEM (2 * 2 * 0x400 + 256)


#if defined(__LINKER__)

Expand All @@ -56,8 +53,7 @@ MEMORY
{
m_itcm (rwx) : ORIGIN = 0x00000000, LENGTH = FLEXRAM_ITCM_AREA
m_itext (rwx) : ORIGIN = 0x00000000 + FLEXRAM_ITEXT_ADDR, LENGTH = FLEXRAM_ITEXT_AREA
m_dtcm (rw) : ORIGIN = 0x20000000 + AREA_KERNEL, LENGTH = FLEXRAM_DTCM_AREA - AREA_KERNEL - SIZE_RTTMEM
m_rttmem (rw) : ORIGIN = 0x20000000 + FLEXRAM_DTCM_AREA - SIZE_RTTMEM, LENGTH = SIZE_RTTMEM
m_dtcm (rw) : ORIGIN = 0x20000000 + AREA_KERNEL, LENGTH = FLEXRAM_DTCM_AREA - AREA_KERNEL
m_ocram1 (rwx) : ORIGIN = 0x20240000 + AREA_BOOTLOADER, LENGTH = (8 * 32k) - AREA_BOOTLOADER
m_ocram2 (rwx) : ORIGIN = 0x202c0000, LENGTH = 512k
m_flash (rx) : ORIGIN = 0x30000000, LENGTH = 128k /* Not actual flash size. Initial flash size to be put into FCB block for imxrt BootROM init procedure only */
Expand Down Expand Up @@ -85,10 +81,8 @@ REGION_ALIAS("TCM_TEXT", m_itext);
REGION_ALIAS("BSS", m_dtcm);
REGION_ALIAS("HEAP", m_dtcm);
REGION_ALIAS("STACK", m_dtcm);
REGION_ALIAS("RTTMEM", m_rttmem);

#include "common/plo-arm.lds"
#include "common/plo-rtt.lds"

#endif /* end of __LINKER__ */

Expand Down
12 changes: 0 additions & 12 deletions ld/common/plo-rtt.lds

This file was deleted.

0 comments on commit c14828f

Please sign in to comment.