Merge pull request #2242 from openmv/gc_blocks

misc: Add common linker script, and misc board config updates.
This commit is contained in:
Ibrahim Abdelkader 2024-06-30 18:46:43 +02:00 committed by GitHub
commit 57215d10e9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
29 changed files with 577 additions and 827 deletions

View File

@ -47,23 +47,23 @@ union block {
(((block_t *) ptr) - 1)
// Initialize the first block in a block chain.
#define INIT_BLOCK_CHAIN(D) \
({ \
block_t *block = (block_t *) DMA_MEMORY_##D; \
block->used = false; \
block->size = OMV_DMA_MEMORY_ ##D ##_SIZE - sizeof(block_t); \
block->next = NULL; \
block->periph = NULL; \
#define INIT_BLOCK_CHAIN(D) \
({ \
block_t *block = (block_t *) DMA_MEMORY_##D; \
block->used = false; \
block->size = OMV_DMA_ALLOC_ ##D ##_SIZE - sizeof(block_t); \
block->next = NULL; \
block->periph = NULL; \
})
#if defined(OMV_DMA_MEMORY_D1)
static uint8_t OMV_ATTR_SECTION(OMV_ATTR_ALIGNED(DMA_MEMORY_D1[OMV_DMA_MEMORY_D1_SIZE], 16), ".d1_dma_buffer");
#if defined(OMV_DMA_ALLOC_D1_SIZE)
static uint8_t OMV_ATTR_SECTION(OMV_ATTR_ALIGNED(DMA_MEMORY_D1[OMV_DMA_ALLOC_D1_SIZE], 16), ".d1_dma_buffer");
#endif
#if defined(OMV_DMA_MEMORY_D2)
static uint8_t OMV_ATTR_SECTION(OMV_ATTR_ALIGNED(DMA_MEMORY_D2[OMV_DMA_MEMORY_D2_SIZE], 16), ".d2_dma_buffer");
#if defined(OMV_DMA_ALLOC_D2_SIZE)
static uint8_t OMV_ATTR_SECTION(OMV_ATTR_ALIGNED(DMA_MEMORY_D2[OMV_DMA_ALLOC_D2_SIZE], 16), ".d2_dma_buffer");
#endif
#if defined(OMV_DMA_MEMORY_D3)
static uint8_t OMV_ATTR_SECTION(OMV_ATTR_ALIGNED(DMA_MEMORY_D3[OMV_DMA_MEMORY_D3_SIZE], 16), ".d3_dma_buffer");
#if defined(OMV_DMA_ALLOC_D3_SIZE)
static uint8_t OMV_ATTR_SECTION(OMV_ATTR_ALIGNED(DMA_MEMORY_D3[OMV_DMA_ALLOC_D3_SIZE], 16), ".d3_dma_buffer");
#endif
NORETURN static void dma_alloc_fail(uint32_t size) {
@ -73,13 +73,13 @@ NORETURN static void dma_alloc_fail(uint32_t size) {
void dma_alloc_init0() {
// Initialize the first block in each DMA buffer.
#if defined(OMV_DMA_MEMORY_D1)
#if defined(OMV_DMA_ALLOC_D1_SIZE)
INIT_BLOCK_CHAIN(D1);
#endif
#if defined(OMV_DMA_MEMORY_D2)
#if defined(OMV_DMA_ALLOC_D2_SIZE)
INIT_BLOCK_CHAIN(D2);
#endif
#if defined(OMV_DMA_MEMORY_D3)
#if defined(OMV_DMA_ALLOC_D3_SIZE)
INIT_BLOCK_CHAIN(D3);
#endif
}
@ -89,19 +89,19 @@ static int periph_to_domain(void *periph) {
uint32_t base = ((uint32_t) periph) & 0xFFFF0000;
switch (base) {
#if defined(OMV_DMA_MEMORY_D1)
#if defined(OMV_DMA_ALLOC_D1_SIZE)
case D1_APB1PERIPH_BASE:
case D1_AHB1PERIPH_BASE:
return 1;
#endif
#if defined(OMV_DMA_MEMORY_D2)
#if defined(OMV_DMA_ALLOC_D2_SIZE)
case D2_APB1PERIPH_BASE:
case D2_APB2PERIPH_BASE:
case D2_AHB1PERIPH_BASE:
case D2_AHB2PERIPH_BASE:
return 2;
#endif
#if defined(OMV_DMA_MEMORY_D3)
#if defined(OMV_DMA_ALLOC_D3_SIZE)
case D3_APB1PERIPH_BASE:
case D3_AHB1PERIPH_BASE:
return 3;
@ -116,22 +116,22 @@ static void block_chain_from_domain(void *periph, void **start, void **end) {
int domain = periph_to_domain(periph);
switch (domain) {
#if defined(OMV_DMA_MEMORY_D1)
#if defined(OMV_DMA_ALLOC_D1_SIZE)
case 1:
*start = DMA_MEMORY_D1;
*end = (DMA_MEMORY_D1 + OMV_DMA_MEMORY_D1_SIZE);
*end = (DMA_MEMORY_D1 + OMV_DMA_ALLOC_D1_SIZE);
break;
#endif
#if defined(OMV_DMA_MEMORY_D2)
#if defined(OMV_DMA_ALLOC_D2_SIZE)
case 2:
*start = DMA_MEMORY_D2;
*end = (DMA_MEMORY_D2 + OMV_DMA_MEMORY_D2_SIZE);
*end = (DMA_MEMORY_D2 + OMV_DMA_ALLOC_D2_SIZE);
break;
#endif
#if defined(OMV_DMA_MEMORY_D3)
#if defined(OMV_DMA_ALLOC_D3_SIZE)
case 3:
*start = DMA_MEMORY_D3;
*end = (DMA_MEMORY_D3 + OMV_DMA_MEMORY_D3_SIZE);
*end = (DMA_MEMORY_D3 + OMV_DMA_ALLOC_D3_SIZE);
break;
#endif
default:

View File

@ -108,26 +108,29 @@
// Note: fb_alloc is a stack-based, dynamically allocated memory on FB.
// The maximum available fb_alloc memory = FB_ALLOC_SIZE + FB_SIZE - (w*h*bpp).
#define OMV_MAIN_MEMORY SRAM1 // Data, BSS memory.
#define OMV_HEAP_MEMORY SRAM1 // Heap memory.
#define OMV_HEAP_SIZE (198K)
#define OMV_STACK_MEMORY DTCM // stack memory
#define OMV_STACK_SIZE (64K)
#define OMV_FB_MEMORY DRAM // Framebuffer, fb_alloc
#define OMV_FB_SIZE (3M) // FB memory: header + VGA/GS image
#define OMV_FB_ALLOC_SIZE (2M) // minimum fb alloc size
#define OMV_JPEG_MEMORY DRAM // JPEG buffer memory buffer.
#define OMV_JPEG_BUF_SIZE (1024 * 1024) // IDE JPEG buffer (header + data).
#define OMV_VOSPI_MEMORY SRAM4 // VoSPI buffer memory.
#define OMV_VOSPI_MEMORY_OFFSET (20K) // SRAM4 reserves 16K for CM4 + 4K D3 DMA buffers.
#define OMV_FB_OVERLAY_MEMORY AXI_SRAM // Fast fb_alloc memory.
#define OMV_FB_OVERLAY_SIZE (480K) // Fast fb_alloc memory size.
#define OMV_GC_BLOCK0_MEMORY DRAM // Extra GC block 0.
#define OMV_GC_BLOCK0_SIZE (2M)
#define OMV_DMA_MEMORY SRAM3 // DMA buffers memory.
#define OMV_JPEG_MEMORY DRAM // JPEG buffer memory buffer.
#define OMV_JPEG_SIZE (1024 * 1024) // IDE JPEG buffer (header + data).
#define OMV_VOSPI_MEMORY SRAM4 // VoSPI buffer memory.
#define OMV_VOSPI_SIZE (38K)
#define OMV_DMA_MEMORY SRAM3 // Misc DMA buffers memory.
#define OMV_DMA_MEMORY_D1 AXI_SRAM // Domain 1 DMA buffers.
#define OMV_DMA_MEMORY_D2 SRAM3 // Domain 2 DMA buffers.
#define OMV_DMA_MEMORY_D3 SRAM4 // Domain 3 DMA buffers.
#define OMV_GC_BLOCK0_MEMORY SRAM1 // Main GC block.
#define OMV_GC_BLOCK0_SIZE (198K)
#define OMV_GC_BLOCK1_MEMORY DRAM // Extra GC block 1.
#define OMV_GC_BLOCK1_SIZE (2M)
#define OMV_MSC_BUF_SIZE (2K) // USB MSC bot data
#define OMV_VFS_BUF_SIZE (1K) // VFS struct + FATFS file buffer (624 bytes)
#define OMV_SDRAM_SIZE (8 * 1024 * 1024) // This needs to be here for UVC firmware.
#define OMV_LINE_BUF_SIZE (11 * 1024) // Image line buffer round(2592 * 2BPP * 2 buffers).
#define OMV_SDRAM_SIZE (8 * 1024 * 1024) // This needs to be here for UVC firmware.
#define OMV_LINE_BUF_SIZE (11 * 1024) // Image line buffer round(2592 * 2BPP * 2 buffers).
// Memory map.
#define OMV_FLASH_ORIGIN 0x08000000
@ -157,24 +160,6 @@
#define OMV_CM4_FLASH_ORIGIN 0x08020000
#define OMV_CM4_FLASH_LENGTH 128K
// Domain 1 DMA buffers region.
#define OMV_DMA_MEMORY_D1 AXI_SRAM
#define OMV_DMA_MEMORY_D1_SIZE (8 * 1024) // Reserved memory for DMA buffers
#define OMV_DMA_REGION_D1_BASE (OMV_AXI_SRAM_ORIGIN + OMV_FB_OVERLAY_SIZE)
#define OMV_DMA_REGION_D1_SIZE MPU_REGION_SIZE_32KB
// Domain 2 DMA buffers region.
#define OMV_DMA_MEMORY_D2 SRAM3
#define OMV_DMA_MEMORY_D2_SIZE (4 * 1024) // Reserved memory for DMA buffers
#define OMV_DMA_REGION_D2_BASE (OMV_SRAM3_ORIGIN + (0 * 1024))
#define OMV_DMA_REGION_D2_SIZE MPU_REGION_SIZE_32KB
// Domain 3 DMA buffers region.
#define OMV_DMA_MEMORY_D3 SRAM4
#define OMV_DMA_MEMORY_D3_SIZE (4 * 1024) // Reserved memory for DMA buffers
#define OMV_DMA_REGION_D3_BASE (OMV_SRAM4_ORIGIN + (16 * 1024))
#define OMV_DMA_REGION_D3_SIZE MPU_REGION_SIZE_4KB
// MDMA configuration
#define OMV_MDMA_CHANNEL_DCMI_0 (0)
#define OMV_MDMA_CHANNEL_DCMI_1 (1)

View File

@ -48,14 +48,14 @@
// Linker script constants (see the linker script template port/x.ld.S).
#define OMV_MAIN_MEMORY SRAM // Data, BSS memory
#define OMV_HEAP_MEMORY SRAM // Heap memory
#define OMV_HEAP_SIZE (64K)
#define OMV_STACK_MEMORY SRAM // stack memory
#define OMV_STACK_SIZE (8K)
#define OMV_FB_MEMORY SRAM // Framebuffer, fb_alloc
#define OMV_FB_SIZE (128K) // FB memory: header + QVGA/GS image
#define OMV_FB_ALLOC_SIZE (16K) // minimum fb alloc size
#define OMV_JPEG_BUF_SIZE (16 * 1024) // IDE JPEG buffer (header + data).
#define OMV_FB_ALLOC_SIZE (16K) // minimum fb alloc size
#define OMV_GC_BLOCK0_MEMORY SRAM // Main GC block.
#define OMV_GC_BLOCK0_SIZE (64K)
#define OMV_JPEG_SIZE (16 * 1024) // IDE JPEG buffer (header + data).
#define OMV_TEXT_ORIGIN 0x00026000
#define OMV_FFS_LENGTH 64K

View File

@ -47,14 +47,14 @@ extern unsigned char *OMV_BOARD_UID_ADDR; // Unique address.
// Linker script constants (see the linker script template port/x.ld.S).
#define OMV_MAIN_MEMORY RAM // Data/BSS memory
#define OMV_HEAP_MEMORY RAM // Heap memory
#define OMV_HEAP_SIZE (60 * 1024) // MicroPython's heap
#define OMV_STACK_MEMORY RAM // stack memory
#define OMV_STACK_SIZE (16K)
#define OMV_FB_MEMORY RAM // Framebuffer, fb_alloc
#define OMV_FB_SIZE (100K) // FB memory
#define OMV_FB_ALLOC_SIZE (16K) // minimum fb alloc size
#define OMV_JPEG_BUF_SIZE (20 * 1024) // IDE JPEG buffer (header + data).
#define OMV_GC_BLOCK0_MEMORY RAM // Main GC block
#define OMV_GC_BLOCK0_SIZE (60 * 1024) // MicroPython's heap
#define OMV_JPEG_SIZE (20 * 1024) // IDE JPEG buffer (header + data).
// GP LED
#define OMV_LED_PIN (6)

View File

@ -101,20 +101,22 @@
// Note: fb_alloc is a stack-based, dynamically allocated memory on FB.
// The maximum available fb_alloc memory = FB_ALLOC_SIZE + FB_SIZE - (w*h*bpp).
#define OMV_MAIN_MEMORY DTCM // Data/BSS memory.
#define OMV_HEAP_MEMORY ITCM // Heap memory
#define OMV_HEAP_SIZE (64K)
#define OMV_STACK_MEMORY DTCM // stack memory
#define OMV_STACK_SIZE (32K)
#define OMV_FB_MEMORY AXI_SRAM // Framebuffer, fb_alloc
#define OMV_FB_SIZE (400K) // FB memory: header + VGA/GS image
#define OMV_FB_ALLOC_SIZE (100K) // minimum fb alloc size
#define OMV_JPEG_MEMORY SRAM4 // JPEG buffer memory buffer.
#define OMV_JPEG_BUF_SIZE (32 * 1024) // IDE JPEG buffer (header + data).
#define OMV_GC_BLOCK0_MEMORY SRAM1 // Extra GC block 0.
#define OMV_GC_BLOCK0_SIZE (276K)
#define OMV_GC_BLOCK1_MEMORY SRAM4 // Extra GC block 0.
#define OMV_GC_BLOCK1_SIZE (32K)
#define OMV_FB_ALLOC_SIZE (76K) // minimum fb alloc size
#define OMV_JPEG_MEMORY AXI_SRAM // JPEG buffer memory buffer.
#define OMV_JPEG_SIZE (32 * 1024) // IDE JPEG buffer (header + data).
#define OMV_DMA_MEMORY SRAM2 // DMA buffers memory.
#define OMV_DMA_MEMORY_D1 AXI_SRAM // Domain 1 DMA buffers.
#define OMV_DMA_MEMORY_D2 SRAM2 // Domain 2 DMA buffers.
#define OMV_GC_BLOCK0_MEMORY DTCM // Main GC block 0.
#define OMV_GC_BLOCK0_SIZE (32K)
#define OMV_GC_BLOCK1_MEMORY SRAM4 // Extra GC block 1.
#define OMV_GC_BLOCK1_SIZE (64K)
#define OMV_GC_BLOCK2_MEMORY SRAM1 // Extra GC block 2.
#define OMV_GC_BLOCK2_SIZE (276K)
#define OMV_MSC_BUF_SIZE (2K) // USB MSC bot data
#define OMV_VFS_BUF_SIZE (1K) // VFS struct + FATFS file buffer (624 bytes)
#define OMV_LINE_BUF_SIZE (3 * 1024) // Image line buffer round(640 * 2BPP * 2 buffers).
@ -147,24 +149,6 @@
#define OMV_CM4_FLASH_ORIGIN 0x08020000
#define OMV_CM4_FLASH_LENGTH 128K
// Domain 1 DMA buffers region.
#define OMV_DMA_MEMORY_D1 AXI_SRAM
#define OMV_DMA_MEMORY_D1_SIZE (8 * 1024) // Reserved memory for DMA buffers
#define OMV_DMA_REGION_D1_BASE (OMV_AXI_SRAM_ORIGIN + (500 * 1024))
#define OMV_DMA_REGION_D1_SIZE MPU_REGION_SIZE_8KB
// Domain 2 DMA buffers region.
#define OMV_DMA_MEMORY_D2 SRAM2
#define OMV_DMA_MEMORY_D2_SIZE (1 * 1024) // Reserved memory for DMA buffers
#define OMV_DMA_REGION_D2_BASE (OMV_SRAM2_ORIGIN + (0 * 1024))
#define OMV_DMA_REGION_D2_SIZE MPU_REGION_SIZE_16KB
// Domain 3 DMA buffers region.
// #define OMV_DMA_MEMORY_D3 SRAM4
// #define OMV_DMA_MEMORY_D3_SIZE (4 * 1024) // Reserved memory for DMA buffers
// #define OMV_DMA_REGION_D3_BASE (OMV_SRAM4_ORIGIN + (60 * 1024))
// #define OMV_DMA_REGION_D3_SIZE MPU_REGION_SIZE_4KB
// MDMA configuration
#define OMV_MDMA_CHANNEL_DCMI_0 (0)
#define OMV_MDMA_CHANNEL_DCMI_1 (1)

View File

@ -109,8 +109,6 @@
// Note: fb_alloc is a stack-based, dynamically allocated memory on FB.
// The maximum available fb_alloc memory = FB_ALLOC_SIZE + FB_SIZE - (w*h*bpp).
#define OMV_MAIN_MEMORY SRAM1 // Data/BSS memory
#define OMV_HEAP_MEMORY SRAM1 // Heap memory
#define OMV_HEAP_SIZE (160K)
#define OMV_STACK_MEMORY DTCM // stack memory
#define OMV_STACK_SIZE (64K)
#define OMV_FB_MEMORY DRAM // Framebuffer, fb_alloc
@ -119,11 +117,17 @@
#define OMV_FB_OVERLAY_MEMORY AXI_SRAM // Fast fb_alloc memory.
#define OMV_FB_OVERLAY_SIZE (480K) // Fast fb_alloc memory size.
#define OMV_JPEG_MEMORY DRAM // JPEG buffer memory buffer.
#define OMV_JPEG_BUF_SIZE (1024 * 1024) // IDE JPEG buffer (header + data).
#define OMV_GC_BLOCK0_MEMORY DRAM // Extra GC block 0.
#define OMV_GC_BLOCK0_SIZE (2M)
#define OMV_JPEG_SIZE (1024 * 1024) // IDE JPEG buffer (header + data).
#define OMV_VOSPI_MEMORY SRAM4 // VoSPI buffer memory.
#define OMV_DMA_MEMORY SRAM3 // DMA buffers memory.
#define OMV_VOSPI_SIZE (38K)
#define OMV_DMA_MEMORY SRAM3 // Misc DMA buffers memory.
#define OMV_DMA_MEMORY_D1 AXI_SRAM // Domain 1 DMA buffers.
#define OMV_DMA_MEMORY_D2 SRAM3 // Domain 2 DMA buffers.
#define OMV_DMA_MEMORY_D3 SRAM4 // Domain 3 DMA buffers.
#define OMV_GC_BLOCK0_MEMORY SRAM1 // Main GC block.
#define OMV_GC_BLOCK0_SIZE (160K)
#define OMV_GC_BLOCK1_MEMORY DRAM // Extra GC block 0.
#define OMV_GC_BLOCK1_SIZE (2M)
#define OMV_MSC_BUF_SIZE (2K) // USB MSC bot data
#define OMV_VFS_BUF_SIZE (1K) // VFS struct + FATFS file buffer (624 bytes)
#define OMV_SDRAM_SIZE (8 * 1024 * 1024) // This needs to be here for UVC firmware.
@ -157,24 +161,6 @@
#define OMV_FLASH_EXT_ORIGIN 0x90000000
#define OMV_FLASH_EXT_LENGTH 16M
// Domain 1 DMA buffers region.
#define OMV_DMA_MEMORY_D1 AXI_SRAM
#define OMV_DMA_MEMORY_D1_SIZE (16 * 1024) // Reserved memory for DMA buffers
#define OMV_DMA_REGION_D1_BASE (OMV_AXI_SRAM_ORIGIN + OMV_FB_OVERLAY_SIZE)
#define OMV_DMA_REGION_D1_SIZE MPU_REGION_SIZE_32KB
// Domain 2 DMA buffers region.
#define OMV_DMA_MEMORY_D2 SRAM3
#define OMV_DMA_MEMORY_D2_SIZE (1 * 1024) // Reserved memory for DMA buffers
#define OMV_DMA_REGION_D2_BASE (OMV_SRAM3_ORIGIN + (0 * 1024))
#define OMV_DMA_REGION_D2_SIZE MPU_REGION_SIZE_16KB
// Domain 3 DMA buffers region.
#define OMV_DMA_MEMORY_D3 SRAM4
#define OMV_DMA_MEMORY_D3_SIZE (32 * 1024) // Reserved memory for DMA buffers
#define OMV_DMA_REGION_D3_BASE (OMV_SRAM4_ORIGIN + (0 * 1024))
#define OMV_DMA_REGION_D3_SIZE MPU_REGION_SIZE_64KB
// MDMA configuration
#define OMV_MDMA_CHANNEL_DCMI_0 (0)
#define OMV_MDMA_CHANNEL_DCMI_1 (1)

View File

@ -63,15 +63,15 @@
// The maximum available fb_alloc memory = FB_ALLOC_SIZE + FB_SIZE - (w*h*bpp).
// Note: fb_alloc overwrites the line buffer which is only used during readout.
#define OMV_MAIN_MEMORY DTCM // Data/BSS memory
#define OMV_HEAP_MEMORY DTCM // Heap memory
#define OMV_HEAP_SIZE (46K)
#define OMV_STACK_MEMORY DTCM // stack memory
#define OMV_STACK_SIZE (8K)
#define OMV_FB_MEMORY SRAM1 // Framebuffer, fb_alloc
#define OMV_FB_SIZE (152K) // FB memory: header + QVGA/GS image
#define OMV_FB_SIZE (150K) // FB memory: header + QVGA/GS image
#define OMV_FB_ALLOC_SIZE (10K) // minimum fb alloc size
#define OMV_JPEG_BUF_SIZE (8 * 1024) // IDE JPEG buffer size (header + data).
#define OMV_DMA_MEMORY SRAM2 // Misc DMA buffers
#define OMV_GC_BLOCK0_MEMORY DTCM // Main GC block
#define OMV_GC_BLOCK0_SIZE (46K)
#define OMV_JPEG_SIZE (8 * 1024) // IDE JPEG buffer size (header + data).
#define OMV_MSC_BUF_SIZE (2K) // USB MSC bot data
#define OMV_VFS_BUF_SIZE (1K) // VFS struct + FATFS file buffer (624 bytes)
#define OMV_FFS_BUF_SIZE (16K) // Flash filesystem cache
@ -83,9 +83,9 @@
#define OMV_DTCM_ORIGIN 0x10000000
#define OMV_DTCM_LENGTH 64K
#define OMV_SRAM1_ORIGIN 0x20000000
#define OMV_SRAM1_LENGTH 162K
#define OMV_SRAM2_ORIGIN 0x20028800
#define OMV_SRAM2_LENGTH 30K
#define OMV_SRAM1_LENGTH 160K
#define OMV_SRAM2_ORIGIN 0x20028000
#define OMV_SRAM2_LENGTH 32K
// Flash configuration.
#define OMV_FLASH_FFS_ORIGIN 0x08004000

View File

@ -62,15 +62,15 @@
// Note: fb_alloc is a stack-based, dynamically allocated memory on FB.
// The maximum available fb_alloc memory = FB_ALLOC_SIZE + FB_SIZE - (w*h*bpp).
#define OMV_MAIN_MEMORY DTCM // Data/BSS memory
#define OMV_HEAP_MEMORY DTCM // Heap memory
#define OMV_HEAP_SIZE (55K)
#define OMV_STACK_MEMORY ITCM // stack memory
#define OMV_STACK_SIZE (16K)
#define OMV_DMA_MEMORY DTCM // Misc DMA buffers
#define OMV_FB_MEMORY SRAM1 // Framebuffer, fb_alloc
#define OMV_FB_SIZE (300K) // FB memory: header + VGA/GS image
#define OMV_FB_ALLOC_SIZE (84K) // minimum fb alloc size
#define OMV_JPEG_BUF_SIZE (22 * 1024) // IDE JPEG buffer (header + data).
#define OMV_DMA_MEMORY DTCM // Misc DMA buffers
#define OMV_GC_BLOCK0_MEMORY DTCM // Main GC block
#define OMV_GC_BLOCK0_SIZE (54K)
#define OMV_JPEG_SIZE (22 * 1024) // IDE JPEG buffer (header + data).
#define OMV_MSC_BUF_SIZE (2K) // USB MSC bot data
#define OMV_VFS_BUF_SIZE (1K) // VFS struct + FATFS file buffer (624 bytes)
#define OMV_FFS_BUF_SIZE (32K) // Flash filesystem cache

View File

@ -115,20 +115,21 @@
// Note: fb_alloc is a stack-based, dynamically allocated memory on FB.
// The maximum available fb_alloc memory = FB_ALLOC_SIZE + FB_SIZE - (w*h*bpp).
#define OMV_MAIN_MEMORY SRAM1 // Data/BSS memory
#define OMV_HEAP_MEMORY SRAM1 // Heap memory
#define OMV_HEAP_SIZE (230K)
#define OMV_FFS_MEMORY DTCM // Flash filesystem cache memory
#define OMV_STACK_MEMORY ITCM // stack memory
#define OMV_STACK_SIZE (64K)
#define OMV_FB_MEMORY AXI_SRAM // Framebuffer, fb_alloc
#define OMV_FB_SIZE (400K) // FB memory: header + VGA/GS image
#define OMV_FB_ALLOC_SIZE (50K) // minimum fb alloc size
#define OMV_JPEG_MEMORY SRAM3 // JPEG buffer memory.
#define OMV_JPEG_BUF_SIZE (32 * 1024) // IDE JPEG buffer (header + data).
#define OMV_GC_BLOCK0_MEMORY AXI_SRAM // Extra GC block 0.
#define OMV_GC_BLOCK0_SIZE (50K)
#define OMV_FB_ALLOC_SIZE (80K) // minimum fb alloc size
#define OMV_JPEG_MEMORY AXI_SRAM // JPEG buffer memory.
#define OMV_JPEG_SIZE (32 * 1024) // IDE JPEG buffer (header + data).
#define OMV_VOSPI_MEMORY SRAM4 // VoSPI buffer memory.
#define OMV_DMA_MEMORY SRAM2 // DMA buffers memory.
#define OMV_FFS_MEMORY DTCM // Flash filesystem cache memory
#define OMV_VOSPI_SIZE (38K)
#define OMV_DMA_MEMORY SRAM2 // Misc DMA buffers memory.
#define OMV_GC_BLOCK0_MEMORY SRAM4 // Main GC block.
#define OMV_GC_BLOCK0_SIZE (26K)
#define OMV_GC_BLOCK1_MEMORY SRAM1 // Extra GC block 0.
#define OMV_GC_BLOCK1_SIZE (267K)
#define OMV_MSC_BUF_SIZE (2K) // USB MSC bot data
#define OMV_VFS_BUF_SIZE (1K) // VFS struct + FATFS file buffer (624 bytes)
#define OMV_LINE_BUF_SIZE (3 * 1024) // Image line buffer round(640 * 2BPP * 2 buffers).
@ -141,11 +142,9 @@
#define OMV_ITCM_ORIGIN 0x00000000
#define OMV_ITCM_LENGTH 64K
#define OMV_SRAM1_ORIGIN 0x30000000
#define OMV_SRAM1_LENGTH 248K
#define OMV_SRAM2_ORIGIN 0x3003E000 // 16KB of SRAM1
#define OMV_SRAM1_LENGTH 280K
#define OMV_SRAM2_ORIGIN 0x30046000
#define OMV_SRAM2_LENGTH 8K
#define OMV_SRAM3_ORIGIN 0x30040000
#define OMV_SRAM3_LENGTH 32K
#define OMV_SRAM4_ORIGIN 0x38000000
#define OMV_SRAM4_LENGTH 64K
#define OMV_AXI_SRAM_ORIGIN 0x24000000
@ -157,23 +156,6 @@
#define OMV_FLASH_TXT_ORIGIN 0x08040000
#define OMV_FLASH_TXT_LENGTH 1792K
// Domain 1 DMA buffers region.
#define OMV_DMA_MEMORY_D1 AXI_SRAM
#define OMV_DMA_MEMORY_D1_SIZE (8 * 1024) // Reserved memory for DMA buffers
#define OMV_DMA_REGION_D1_BASE (OMV_AXI_SRAM_ORIGIN + (500 * 1024))
#define OMV_DMA_REGION_D1_SIZE MPU_REGION_SIZE_8KB
// Domain 2 DMA buffers region.
#define OMV_DMA_MEMORY_D2 SRAM2
#define OMV_DMA_MEMORY_D2_SIZE (1 * 1024) // Reserved memory for DMA buffers
#define OMV_DMA_REGION_D2_BASE (OMV_SRAM2_ORIGIN + (0 * 1024))
#define OMV_DMA_REGION_D2_SIZE MPU_REGION_SIZE_8KB
// Domain 3 DMA buffers region.
//#define OMV_DMA_MEMORY_D3 SRAM4
//#define OMV_DMA_REGION_D3_BASE (OMV_SRAM4_ORIGIN+(0*1024))
//#define OMV_DMA_REGION_D3_SIZE MPU_REGION_SIZE_64KB
// MDMA configuration
#define OMV_MDMA_CHANNEL_DCMI_0 (0)
#define OMV_MDMA_CHANNEL_DCMI_1 (1)

View File

@ -116,8 +116,6 @@
// Note: fb_alloc is a stack-based, dynamically allocated memory on FB.
// The maximum available fb_alloc memory = FB_ALLOC_SIZE + FB_SIZE - (w*h*bpp).
#define OMV_MAIN_MEMORY SRAM1 // Data/BSS memory
#define OMV_HEAP_MEMORY SRAM1 // Heap memory
#define OMV_HEAP_SIZE (239K)
#define OMV_STACK_MEMORY ITCM // stack memory
#define OMV_STACK_SIZE (64K)
#define OMV_FB_MEMORY DRAM // Framebuffer, fb_alloc
@ -126,11 +124,17 @@
#define OMV_FB_OVERLAY_MEMORY AXI_SRAM // Fast fb_alloc memory.
#define OMV_FB_OVERLAY_SIZE (496K) // Fast fb_alloc memory size.
#define OMV_JPEG_MEMORY DRAM // JPEG buffer memory buffer.
#define OMV_JPEG_BUF_SIZE (1024 * 1024) // IDE JPEG buffer (header + data).
#define OMV_DMA_MEMORY SRAM3 // Misc DMA buffers memory.
#define OMV_JPEG_SIZE (1024 * 1024) // IDE JPEG buffer (header + data).
#define OMV_VOSPI_MEMORY SRAM4 // VoSPI buffer memory.
#define OMV_GC_BLOCK0_MEMORY DRAM // Extra GC block 0.
#define OMV_GC_BLOCK0_SIZE (4M)
#define OMV_VOSPI_SIZE (38K)
#define OMV_DMA_MEMORY SRAM3 // Misc DMA buffers memory.
#define OMV_DMA_MEMORY_D1 AXI_SRAM // Domain 1 DMA buffers.
#define OMV_DMA_MEMORY_D2 SRAM3 // Domain 2 DMA buffers.
#define OMV_DMA_MEMORY_D3 SRAM4 // Domain 3 DMA buffers.
#define OMV_GC_BLOCK0_MEMORY SRAM1 // Main GC block
#define OMV_GC_BLOCK0_SIZE (239K)
#define OMV_GC_BLOCK1_MEMORY DRAM // Extra GC block 0.
#define OMV_GC_BLOCK1_SIZE (4M)
#define OMV_MSC_BUF_SIZE (2K) // USB MSC bot data
#define OMV_VFS_BUF_SIZE (1K) // VFS struct + FATFS file buffer (624 bytes)
#define OMV_SDRAM_SIZE (32 * 1024 * 1024) // This needs to be here for UVC firmware.
@ -160,24 +164,6 @@
#define OMV_FLASH_TXT_ORIGIN 0x08040000
#define OMV_FLASH_TXT_LENGTH 1792K
// Domain 1 DMA buffers region.
#define OMV_DMA_MEMORY_D1 AXI_SRAM
#define OMV_DMA_MEMORY_D1_SIZE (16 * 1024) // Reserved memory for DMA buffers
#define OMV_DMA_REGION_D1_BASE (OMV_AXI_SRAM_ORIGIN + OMV_FB_OVERLAY_SIZE)
#define OMV_DMA_REGION_D1_SIZE MPU_REGION_SIZE_16KB
// Domain 2 DMA buffers region.
#define OMV_DMA_MEMORY_D2 SRAM3
#define OMV_DMA_MEMORY_D2_SIZE (16 * 1024) // Reserved memory for DMA buffers
#define OMV_DMA_REGION_D2_BASE (OMV_SRAM3_ORIGIN + (0 * 1024))
#define OMV_DMA_REGION_D2_SIZE MPU_REGION_SIZE_32KB
// Domain 3 DMA buffers region.
#define OMV_DMA_MEMORY_D3 SRAM4
#define OMV_DMA_MEMORY_D3_SIZE (64 * 1024) // Reserved memory for DMA buffers
#define OMV_DMA_REGION_D3_BASE (OMV_SRAM4_ORIGIN + (0 * 1024))
#define OMV_DMA_REGION_D3_SIZE MPU_REGION_SIZE_64KB
// MDMA configuration
#define OMV_MDMA_CHANNEL_DCMI_0 (0)
#define OMV_MDMA_CHANNEL_DCMI_1 (1)

View File

@ -126,8 +126,6 @@
// Note: fb_alloc is a stack-based, dynamically allocated memory on FB.
// The maximum available fb_alloc memory = FB_ALLOC_SIZE + FB_SIZE - (w*h*bpp).
#define OMV_MAIN_MEMORY SRAM1 // Data/BSS memory
#define OMV_HEAP_MEMORY SRAM1 // Heap memory
#define OMV_HEAP_SIZE (196K)
#define OMV_STACK_MEMORY ITCM // stack memory
#define OMV_STACK_SIZE (64K)
#define OMV_FB_MEMORY DRAM // Framebuffer, fb_alloc
@ -136,12 +134,17 @@
#define OMV_FB_OVERLAY_MEMORY AXI_SRAM // Fast fb_alloc memory.
#define OMV_FB_OVERLAY_SIZE (496K) // Fast fb_alloc memory size.
#define OMV_JPEG_MEMORY DRAM // JPEG buffer memory buffer.
#define OMV_JPEG_BUF_SIZE (1024 * 1024) // IDE JPEG buffer (header + data).
#define OMV_DMA_MEMORY SRAM3 // Misc DMA buffers memory.
#define OMV_JPEG_SIZE (1024 * 1024) // IDE JPEG buffer (header + data).
#define OMV_VOSPI_MEMORY SRAM4 // VoSPI buffer memory.
#define OMV_VOSPI_MEMORY_OFFSET (4K) // First 4K reserved for D3 DMA buffers.
#define OMV_VOSPI_SIZE (38K)
#define OMV_DMA_MEMORY SRAM3 // Misc DMA buffers memory.
#define OMV_DMA_MEMORY_D1 AXI_SRAM // Domain 1 DMA buffers.
#define OMV_DMA_MEMORY_D2 SRAM3 // Domain 2 DMA buffers.
#define OMV_DMA_MEMORY_D3 SRAM4 // Domain 3 DMA buffers.
#define OMV_CYW43_MEMORY FLASH_EXT // CYW43 firmware in external flash mmap'd flash.
#define OMV_CYW43_MEMORY_OFFSET (0x90F00000)// Last Mbyte.
#define OMV_GC_BLOCK0_MEMORY SRAM1 // Main GC block.
#define OMV_GC_BLOCK0_SIZE (196K)
#define OMV_SDRAM_SIZE (32 * 1024 * 1024) // This needs to be here for UVC firmware.
#define OMV_MSC_BUF_SIZE (2K) // USB MSC bot data
#define OMV_VFS_BUF_SIZE (1K) // VFS struct + FATFS file buffer (624 bytes)
@ -174,24 +177,6 @@
#define OMV_FLASH_EXT_ORIGIN 0x90000000
#define OMV_FLASH_EXT_LENGTH 32M
// Domain 1 DMA buffers region.
#define OMV_DMA_MEMORY_D1 AXI_SRAM
#define OMV_DMA_MEMORY_D1_SIZE (8 * 1024) // Reserved memory for DMA buffers
#define OMV_DMA_REGION_D1_BASE (OMV_AXI_SRAM_ORIGIN + OMV_FB_OVERLAY_SIZE)
#define OMV_DMA_REGION_D1_SIZE MPU_REGION_SIZE_8KB
// Domain 2 DMA buffers region.
#define OMV_DMA_MEMORY_D2 SRAM3
#define OMV_DMA_MEMORY_D2_SIZE (8 * 1024) // Reserved memory for DMA buffers
#define OMV_DMA_REGION_D2_BASE (OMV_SRAM3_ORIGIN + (0 * 1024))
#define OMV_DMA_REGION_D2_SIZE MPU_REGION_SIZE_32KB
// Domain 3 DMA buffers region.
#define OMV_DMA_MEMORY_D3 SRAM4
#define OMV_DMA_MEMORY_D3_SIZE (4 * 1024) // Reserved memory for DMA buffers
#define OMV_DMA_REGION_D3_BASE (OMV_SRAM4_ORIGIN + (0 * 1024))
#define OMV_DMA_REGION_D3_SIZE MPU_REGION_SIZE_4KB
// MDMA configuration
#define OMV_MDMA_CHANNEL_DCMI_0 (0)
#define OMV_MDMA_CHANNEL_DCMI_1 (1)

View File

@ -108,8 +108,6 @@
// Note: fb_alloc is a stack-based, dynamically allocated memory on FB.
// The maximum available fb_alloc memory = FB_ALLOC_SIZE + FB_SIZE - (w*h*bpp).
#define OMV_MAIN_MEMORY SRAM1 // Data/BSS memory
#define OMV_HEAP_MEMORY SRAM1 // Heap memory
#define OMV_HEAP_SIZE (250K)
#define OMV_STACK_MEMORY ITCM // stack memory
#define OMV_STACK_SIZE (64K)
#define OMV_FB_MEMORY DRAM // Framebuffer, fb_alloc
@ -118,11 +116,17 @@
#define OMV_FB_OVERLAY_MEMORY AXI_SRAM // Fast fb_alloc memory.
#define OMV_FB_OVERLAY_SIZE (496K) // Fast fb_alloc memory size.
#define OMV_JPEG_MEMORY DRAM // JPEG buffer memory buffer.
#define OMV_JPEG_BUF_SIZE (1024 * 1024) // IDE JPEG buffer (header + data).
#define OMV_GC_BLOCK0_MEMORY DRAM // Extra GC block 0.
#define OMV_GC_BLOCK0_SIZE (8M)
#define OMV_DMA_MEMORY SRAM3 // DMA buffers memory.
#define OMV_JPEG_SIZE (1024 * 1024) // IDE JPEG buffer (header + data).
#define OMV_VOSPI_MEMORY SRAM4 // VoSPI buffer memory.
#define OMV_VOSPI_SIZE (38K)
#define OMV_DMA_MEMORY SRAM3 // DMA buffers memory.
#define OMV_DMA_MEMORY_D1 AXI_SRAM // Domain 1 DMA buffers.
#define OMV_DMA_MEMORY_D2 SRAM3 // Domain 2 DMA buffers.
#define OMV_DMA_MEMORY_D3 SRAM4 // Domain 3 DMA buffers.
#define OMV_GC_BLOCK0_MEMORY SRAM1 // Main GC block.
#define OMV_GC_BLOCK0_SIZE (250K)
#define OMV_GC_BLOCK1_MEMORY DRAM // Extra GC block 0.
#define OMV_GC_BLOCK1_SIZE (8M)
#define OMV_SDRAM_SIZE (64 * 1024 * 1024) // This needs to be here for UVC firmware.
#define OMV_MSC_BUF_SIZE (2K) // USB MSC bot data
#define OMV_VFS_BUF_SIZE (1K) // VFS struct + FATFS file buffer (624 bytes)
@ -152,24 +156,6 @@
#define OMV_FLASH_TXT_ORIGIN 0x08040000
#define OMV_FLASH_TXT_LENGTH 1792K
// Domain 1 DMA buffers region.
#define OMV_DMA_MEMORY_D1 AXI_SRAM
#define OMV_DMA_MEMORY_D1_SIZE (16 * 1024) // Reserved memory for DMA buffers
#define OMV_DMA_REGION_D1_BASE (OMV_AXI_SRAM_ORIGIN + OMV_FB_OVERLAY_SIZE)
#define OMV_DMA_REGION_D1_SIZE MPU_REGION_SIZE_16KB
// Domain 2 DMA buffers region.
#define OMV_DMA_MEMORY_D2 SRAM3
#define OMV_DMA_MEMORY_D2_SIZE (1 * 1024) // Reserved memory for DMA buffers
#define OMV_DMA_REGION_D2_BASE (OMV_SRAM3_ORIGIN + (0 * 1024))
#define OMV_DMA_REGION_D2_SIZE MPU_REGION_SIZE_16KB
// Domain 3 DMA buffers region.
#define OMV_DMA_MEMORY_D3 SRAM4
#define OMV_DMA_MEMORY_D3_SIZE (64 * 1024) // Reserved memory for DMA buffers
#define OMV_DMA_REGION_D3_BASE (OMV_SRAM4_ORIGIN + (0 * 1024))
#define OMV_DMA_REGION_D3_SIZE MPU_REGION_SIZE_64KB
// MDMA configuration
#define OMV_MDMA_CHANNEL_DCMI_0 (0)
#define OMV_MDMA_CHANNEL_DCMI_1 (1)

View File

@ -74,21 +74,24 @@
// Note: fb_alloc is a stack-based, dynamically allocated memory on FB.
// The maximum available fb_alloc memory = FB_ALLOC_SIZE + FB_SIZE - (w*h*bpp).
#define OMV_MAIN_MEMORY DTCM // Data/BSS memory
#define OMV_HEAP_MEMORY DTCM // Heap memory
#define OMV_HEAP_SIZE (284K)
#define OMV_STACK_MEMORY ITCM1 // stack memory
#define OMV_STACK_SIZE (32K)
#define OMV_JPEG_MEMORY DRAM // JPEG buffer memory buffer.
#define OMV_JPEG_BUF_SIZE (1024 * 1024) // IDE JPEG buffer (header + data).
#define OMV_JPEG_SIZE (1024 * 1024) // IDE JPEG buffer (header + data).
#define OMV_FB_MEMORY DRAM // Framebuffer, fb_alloc
#define OMV_FB_SIZE (16M) // FB memory: header + VGA/GS image
#define OMV_FB_ALLOC_SIZE (11M) // minimum fb alloc size
#define OMV_FB_SIZE (13M) // FB memory: header + VGA/GS image
#define OMV_FB_ALLOC_SIZE (10M) // minimum fb alloc size
#define OMV_FB_OVERLAY_MEMORY OCRM1 // Fast fb_alloc memory.
#define OMV_FB_OVERLAY_SIZE (512K)
#define OMV_GC_BLOCK0_MEMORY DRAM // Extra GC block 0.
#define OMV_GC_BLOCK0_SIZE (4M)
#define OMV_DMA_MEMORY DTCM // DMA buffers memory.
#define OMV_VOSPI_MEMORY OCRM2 // VoSPI buffer memory.
#define OMV_VOSPI_SIZE (38K)
#define OMV_DMA_MEMORY DTCM // Misc DMA buffers memory.
#define OMV_GC_BLOCK0_MEMORY OCRM2 // Extra GC block 0.
#define OMV_GC_BLOCK0_SIZE (26K)
#define OMV_GC_BLOCK1_MEMORY DTCM // Main GC block
#define OMV_GC_BLOCK1_SIZE (293K)
#define OMV_GC_BLOCK2_MEMORY DRAM // Extra GC block 1.
#define OMV_GC_BLOCK2_SIZE (8M)
#define OMV_RAMFUNC_MEMORY ITCM2 // RAM code memory.
#define OMV_LINE_BUF_SIZE (11 * 1024) // Image line buffer.

View File

@ -47,14 +47,14 @@ extern unsigned char *OMV_BOARD_UID_ADDR; // Unique ID address.
// Linker script constants (see the linker script template port/x.ld.S).
#define OMV_MAIN_MEMORY RAM // Data/BSS memory
#define OMV_HEAP_MEMORY RAM // Heap memory
#define OMV_HEAP_SIZE (32 * 1024) // MicroPython's heap
#define OMV_GC_BLOCK0_MEMORY RAM // Main GC block.
#define OMV_GC_BLOCK0_SIZE (32 * 1024)
#define OMV_STACK_MEMORY RAM // stack memory
#define OMV_STACK_SIZE (8K)
#define OMV_FB_MEMORY RAM // Framebuffer, fb_alloc
#define OMV_FB_SIZE (151K) // FB memory: header + QVGA/GS image
#define OMV_FB_ALLOC_SIZE (12K) // minimum fb alloc size
#define OMV_JPEG_BUF_SIZE (20 * 1024) // IDE JPEG buffer (header + data).
#define OMV_JPEG_SIZE (20 * 1024) // IDE JPEG buffer (header + data).
// GP LED
#define OMV_LED_PIN (25)

233
src/omv/common/common.ld.S Normal file
View File

@ -0,0 +1,233 @@
// NOTE this linker script is pre-processed using the CPP first before
// passing it to LD. It has access to the board config file, can define
// and use CPP macros, and it uses a lot of magic 🪄.
/* Adds a section to a table */
#define OMV_ADD_SECTION(s) \
LONG (ADDR(s)) \
LONG (SIZEOF(s) / 4)
/* Aligns a section to the next power of 2. */
#define OMV_ALIGN_DMA_SECTION(section) \
ALIGN(., 1 << LOG2CEIL(SIZEOF(section)))
/* Define a new GC block. */
#define OMV_GC_BLOCK_NEW(n) \
.gc.block##n (NOLOAD) : { \
. = ALIGN(4); \
. += OMV_GC_BLOCK##n##_SIZE; \
. = ALIGN(4); \
} >OMV_GC_BLOCK##n##_MEMORY \
/* Define a new DMA buffer region. */
#define OMV_DMA_MEMORY_NEW(X) \
.dma.memory##X (NOLOAD) : ALIGN(16) \
{ \
*(.d##X##_dma_buffer) \
. = OMV_ALIGN_DMA_SECTION(.dma.memory##X); \
} >OMV_DMA_MEMORY_D##X
/* Main GC heap for MicroPython */
#if defined(OMV_GC_BLOCK0_MEMORY)
.gc.block0 (NOLOAD) : ALIGN(4)
{
_heap_start = .;
. = . + OMV_GC_BLOCK0_SIZE;
. = ALIGN(4);
_heap_end = .;
} >OMV_GC_BLOCK0_MEMORY
#endif
/* Additional GC heap blocks */
#if defined(OMV_GC_BLOCK1_MEMORY)
OMV_GC_BLOCK_NEW(1)
#endif
#if defined(OMV_GC_BLOCK2_MEMORY)
OMV_GC_BLOCK_NEW(2)
#endif
#if defined(OMV_GC_BLOCK3_MEMORY)
OMV_GC_BLOCK_NEW(3)
#endif
#if defined(OMV_GC_BLOCK4_MEMORY)
OMV_GC_BLOCK_NEW(4)
#endif
/* Additional GC heap blocks table */
#if defined(OMV_GC_BLOCK1_MEMORY)
.gc.blocks.table (READONLY) :
{
. = ALIGN(4);
_gc_blocks_table_start = .;
OMV_ADD_SECTION(.gc.block1)
#if defined(OMV_GC_BLOCK2_MEMORY)
OMV_ADD_SECTION(.gc.block2)
#endif
#if defined(OMV_GC_BLOCK3_MEMORY)
OMV_ADD_SECTION(.gc.block3)
#endif
#if defined(OMV_GC_BLOCK4_MEMORY)
OMV_ADD_SECTION(.gc.block4)
#endif
_gc_blocks_table_end = .;
. = ALIGN(4);
} > FLASH_TEXT
#endif
/* Heap memfor libc malloc/sbrk */
#if defined(OMV_HEAP_MEMORY)
.heap (NOLOAD) : ALIGN(4)
{
__end__ = .;
PROVIDE(end = .);
. = . + OMV_HEAP_SIZE;
. = ALIGN(4);
_heap_limit = .;
} > OMV_MAIN_MEMORY
#endif
/* Stack memory */
#if defined(OMV_STACK_MEMORY)
.stack (NOLOAD) : ALIGN(8)
{
_sstack = .;
__StackLimit = .;
. = . + OMV_STACK_SIZE;
. = ALIGN(8);
_estack = .;
__StackTop = .;
} > OMV_STACK_MEMORY
PROVIDE(__stack = __StackTop);
#endif
/* JPEG framebuffer memory */
#if defined(OMV_JPEG_MEMORY)
.jpeg_memory (NOLOAD) :
{
. = ALIGN(4);
_jpeg_buf = .;
. = . + OMV_JPEG_SIZE;
. = ALIGN(4);
} >OMV_JPEG_MEMORY
#endif
/* VOSPI framebuffer memory */
#if defined(OMV_VOSPI_MEMORY)
.vospi_memory (NOLOAD) :
{
. = ALIGN(4);
_vospi_buf = .;
. = . + OMV_VOSPI_SIZE;
. = ALIGN(4);
} >OMV_VOSPI_MEMORY
#endif
/* Main framebuffer memory */
#if defined(OMV_FB_MEMORY)
.fb_memory (NOLOAD) :
{
. = ALIGN(4);
_fb_base = .;
. += OMV_FB_SIZE;
_fb_end = .;
. += OMV_FB_ALLOC_SIZE;
. = ALIGN(4);
_fballoc = .;
. = ALIGN(4);
} >OMV_FB_MEMORY
#endif
/* Main framebuffer fast memory */
#if defined(OMV_FB_OVERLAY_MEMORY)
.fb_overlay_memory (NOLOAD) :
{
. = ALIGN(4);
_fballoc_overlay_start = .;
. = . + OMV_FB_OVERLAY_SIZE;
_fballoc_overlay_end = .;
} >OMV_FB_OVERLAY_MEMORY
#endif
/* Misc DMA buffers section */
.dma.memory0 (NOLOAD) : ALIGN(16)
{
/* Image line buffer. */
#if defined(OMV_LINE_BUF_SIZE)
. = ALIGN(16);
_line_buf = .;
. = . + OMV_LINE_BUF_SIZE;
#endif
/* USB MSC bot data (2K) */
#if defined(OMV_MSC_BUF_SIZE)
. = ALIGN(16);
_msc_buf = .;
. = . + OMV_MSC_BUF_SIZE;
#endif
/* VFS + FATFS buffer */
#if defined(OMV_VFS_BUF_SIZE)
. = ALIGN(16);
_vfs_buf = .;
. = . + OMV_VFS_BUF_SIZE;
#endif
#if !defined(OMV_JPEG_MEMORY)
. = ALIGN(16);
_jpeg_buf = .; // IDE JPEG buffer
. = . + OMV_JPEG_SIZE;
#endif
/* FFS (internal) filesystem buffer */
#if defined(OMV_FFS_BUF_SIZE)
. = ALIGN(16);
_micropy_hw_internal_flash_storage_ram_cache_start = .;
. = . + OMV_FFS_BUF_SIZE;
_micropy_hw_internal_flash_storage_ram_cache_end = .;
#endif
. = ALIGN(16);
*(.dma_buffer)
. = ALIGN(16);
*(NonCacheable)
. = OMV_ALIGN_DMA_SECTION(.dma.memory0);
#if defined(OMV_DMA_MEMORY)
} >OMV_DMA_MEMORY
#else
} >OMV_MAIN_MEMORY
#endif
/* Additional DMA memory buffers */
#if defined(OMV_DMA_MEMORY_D1)
OMV_DMA_MEMORY_NEW(1)
#endif
#if defined(OMV_DMA_MEMORY_D2)
OMV_DMA_MEMORY_NEW(2)
#endif
#if defined(OMV_DMA_MEMORY_D3)
OMV_DMA_MEMORY_NEW(3)
#endif
/* Additional DMA memory tables */
.dma.memory.table (READONLY) :
{
. = ALIGN(4);
_dma_memory_table_start = .;
OMV_ADD_SECTION(.dma.memory0)
#if defined(OMV_DMA_MEMORY_D1)
OMV_ADD_SECTION(.dma.memory1)
#endif
#if defined(OMV_DMA_MEMORY_D2)
OMV_ADD_SECTION(.dma.memory2)
#endif
#if defined(OMV_DMA_MEMORY_D3)
OMV_ADD_SECTION(.dma.memory3)
#endif
_dma_memory_table_end = .;
. = ALIGN(4);
} > FLASH_TEXT
.ARM.attributes 0 : { *(.ARM.attributes) }

View File

@ -133,7 +133,7 @@ void mp_init_gc_stack(void *sstack, void *estack, void *heap_start, void *heap_e
gc_init(heap_start, heap_end);
// Add GC blocks (if enabled).
#ifdef OMV_GC_BLOCK0_MEMORY
#ifdef OMV_GC_BLOCK1_MEMORY
typedef struct {
uint32_t *addr;
uint32_t size;

View File

@ -15,7 +15,7 @@
#define FB_ALIGN_SIZE_ROUND_DOWN(x) (((x) / FRAMEBUFFER_ALIGNMENT) * FRAMEBUFFER_ALIGNMENT)
#define FB_ALIGN_SIZE_ROUND_UP(x) FB_ALIGN_SIZE_ROUND_DOWN(((x) + FRAMEBUFFER_ALIGNMENT - 1))
#define CONSERVATIVE_JPEG_BUF_SIZE (OMV_JPEG_BUF_SIZE - 64)
#define CONSERVATIVE_JPEG_BUF_SIZE (OMV_JPEG_SIZE - 64)
extern char _fb_base;
extern char _fb_end;

View File

@ -57,30 +57,6 @@ __iomux_gpr16_adr = 0x400AC040;
__iomux_gpr17_adr = 0x400AC044;
__iomux_gpr17_value = OMV_FLEXRAM_CONFIG;
#if defined(OMV_VOSPI_MEMORY)
#if !defined(OMV_VOSPI_MEMORY_OFFSET)
#define OMV_VOSPI_MEMORY_OFFSET (0)
#endif
_vospi_buf = ORIGIN(OMV_VOSPI_MEMORY) + OMV_VOSPI_MEMORY_OFFSET;
#endif
// Location of filesystem flash storage
// Not used in MIMXRT port.
// _micropy_hw_internal_flash_storage_start = ORIGIN(FLASH_FFS);
// _micropy_hw_internal_flash_storage_end = ORIGIN(FLASH_FFS) + LENGTH(FLASH_FFS);
#define OMV_DEFINE_GC_BLOCK(n) \
.gc_block##n (NOLOAD) : \
{ \
. = ALIGN(4); \
. += OMV_GC_BLOCK##n##_SIZE; \
. = ALIGN(4); \
} >OMV_GC_BLOCK##n##_MEMORY \
#define OMV_ADD_GC_BLOCK(n) \
LONG (ADDR(.gc_block##n)) \
LONG (SIZEOF(.gc_block##n) / 4)
/* Define output sections */
SECTIONS
{
@ -126,33 +102,42 @@ SECTIONS
. = ALIGN(4);
} > FLASH_TEXT
.ARM :
{
__exidx_start = .;
*(.ARM.exidx*)
__exidx_end = .;
} > FLASH_TEXT
/* The address used as the source for copying the initialized data section. */
__etext = LOADADDR(.data);
__etext = LOADADDR(.data); /* define a global symbol at end of code */
/* Initialized data sections */
.data :
/* Initialized data sections */
.data : ALIGN(4)
{
. = ALIGN(4);
_ram_start = .;
__DATA_RAM = .;
__data_start__ = .; /* create a global symbol at data start */
__data_start__ = .; // Used by the startup to initialize the data section
*(m_usb_dma_init_data)
*(.data) /* .data sections */
*(.data*) /* .data* sections */
. = ALIGN(4);
*(.data) // .data sections */
. = ALIGN(4);
*(.data*) // .data* sections */
KEEP(*(.jcr*))
. = ALIGN(4);
__data_end__ = .; /* define a global symbol at data end */
__data_end__ = .; // Define a global symbol at data end
} > OMV_MAIN_MEMORY AT> FLASH_TEXT
.ram_function :
/* Uninitialized data section */
.bss (NOLOAD) : ALIGN(4)
{
__bss_start__ = .; // Used by the startup to initialize the .bss section
*(m_usb_dma_noninit_data)
. = ALIGN(4);
*(.bss)
. = ALIGN(4);
*(.bss*)
. = ALIGN(4);
*(COMMON)
. = ALIGN(4);
_ebss = .;
__bss_end__ = .;
} > OMV_MAIN_MEMORY
.ram_function : ALIGN(4)
{
__ram_function_start__ = .;
*(.ram_functions*)
*(.text*)
@ -160,123 +145,5 @@ SECTIONS
__ram_function_end__ = .;
} > OMV_RAMFUNC_MEMORY AT> FLASH_TEXT
/* Uninitialized data section */
.bss (NOLOAD) :
{
/* This is used by the startup in order to initialize the .bss section */
. = ALIGN(4);
__START_BSS = .;
__bss_start__ = .;
*(m_usb_dma_noninit_data)
*(.bss)
*(.bss*)
*(COMMON)
. = ALIGN(4);
_ebss = .;
__bss_end__ = .;
__END_BSS = .;
} > OMV_MAIN_MEMORY
._heap (NOLOAD) :
{
. = ALIGN(4);
_heap_start = .;
. = . + OMV_HEAP_SIZE;
. = ALIGN(4);
_heap_end = .;
} >OMV_HEAP_MEMORY
._stack (NOLOAD) :
{
. = ALIGN(8);
_sstack = .;
. = . + OMV_STACK_SIZE;
. = ALIGN(8);
_estack = .;
__stack = .;
} >OMV_STACK_MEMORY
#if defined(OMV_GC_BLOCK0_MEMORY)
OMV_DEFINE_GC_BLOCK(0)
#endif
#if defined(OMV_GC_BLOCK1_MEMORY)
OMV_DEFINE_GC_BLOCK(1)
#endif
#if defined(OMV_GC_BLOCK2_MEMORY)
OMV_DEFINE_GC_BLOCK(2)
#endif
.gc_blocks_table (READONLY) :
{
. = ALIGN(4);
_gc_blocks_table_start = .;
#if defined(OMV_GC_BLOCK0_MEMORY)
OMV_ADD_GC_BLOCK(0)
#endif
#if defined(OMV_GC_BLOCK1_MEMORY)
OMV_ADD_GC_BLOCK(1)
#endif
#if defined(OMV_GC_BLOCK2_MEMORY)
OMV_ADD_GC_BLOCK(2)
#endif
_gc_blocks_table_end = .;
. = ALIGN(4);
} > FLASH_TEXT
/* Main framebuffer memory */
.fb_memory (NOLOAD) :
{
. = ALIGN(4);
_fb_base = .;
. += OMV_FB_SIZE;
. = ALIGN(4);
_fb_end = .;
. += OMV_FB_ALLOC_SIZE;
. = ALIGN(4);
_fballoc = .;
} >OMV_FB_MEMORY
#if defined(OMV_FB_OVERLAY_MEMORY)
.fb_overlay_memory (NOLOAD) :
{
. = ALIGN(4);
_fballoc_overlay_start = .;
. = . + OMV_FB_OVERLAY_SIZE;
_fballoc_overlay_end = .;
} >OMV_FB_OVERLAY_MEMORY
#endif
#if defined(OMV_JPEG_MEMORY)
/* JPEG framebuffer memory */
.jpeg_memory (NOLOAD) :
{
. = ALIGN(4);
_jpeg_buf = .; // IDE JPEG buffer
. = . + OMV_JPEG_BUF_SIZE;
. = ALIGN(4);
} >OMV_JPEG_MEMORY
#endif
/* Misc DMA buffers section */
.dma_memory (NOLOAD) :
{
. = ALIGN(8);
_line_buf = .; // Image line buffer.
. = . + OMV_LINE_BUF_SIZE;
#if !defined(OMV_JPEG_MEMORY)
. = ALIGN(16);
_jpeg_buf = .; // IDE JPEG buffer
. = . + OMV_JPEG_BUF_SIZE;
#endif
. = ALIGN(16);
*(.dma_buffer)
} >OMV_DMA_MEMORY
.ARM.attributes 0 : { *(.ARM.attributes) }
#include "common.ld.S"
}

View File

@ -48,9 +48,10 @@ LDFLAGS = -mthumb \
-mabi=aapcs-linux \
-Wl,--print-memory-usage \
-Wl,--gc-sections \
-Wl,-T$(BUILD)/$(LDSCRIPT).lds \
-Wl,--wrap=tud_cdc_rx_cb \
-Wl,--wrap=mp_hal_stdout_tx_strn
-Wl,--wrap=mp_hal_stdout_tx_strn \
-Wl,-T$(BUILD)/$(LDSCRIPT).lds \
-Wl,-Map=$(BUILD)/$(FIRMWARE).map
HAL_CFLAGS += -I$(TOP_DIR)/$(CMSIS_DIR)/include/
HAL_CFLAGS += -I$(TOP_DIR)/$(CMSIS_DIR)/include/mimxrt
@ -517,8 +518,8 @@ endif
# This target generates the main/app firmware image located at 0x08010000
$(FIRMWARE): FIRMWARE_OBJS
$(CPP) -P -E -DLINKER_SCRIPT -I$(OMV_BOARD_CONFIG_DIR) \
$(OMV_DIR)/ports/$(PORT)/$(LDSCRIPT).ld.S > $(BUILD)/$(LDSCRIPT).lds
$(CPP) -P -E -DLINKER_SCRIPT -I$(OMV_COMMON_DIR) -I$(OMV_BOARD_CONFIG_DIR) \
$(OMV_DIR)/ports/$(PORT)/$(LDSCRIPT).ld.S > $(BUILD)/$(LDSCRIPT).lds
$(CC) $(LDFLAGS) $(FIRM_OBJ) -o $(FW_DIR)/$(FIRMWARE).elf $(LIBS) -lm
$(OBJCOPY) -Obinary -R .big_const* $(FW_DIR)/$(FIRMWARE).elf $(FW_DIR)/$(FIRMWARE).bin

View File

@ -17,14 +17,15 @@ ENTRY(Reset_Handler)
/* Specify the memory areas */
MEMORY
{
SRAM (xrw) : ORIGIN = OMV_SRAM_ORIGIN, LENGTH = OMV_SRAM_LENGTH
FLASH_TEXT (rx) : ORIGIN = OMV_TEXT_ORIGIN, LENGTH = OMV_TEXT_LENGTH
SRAM (xrw) : ORIGIN = OMV_SRAM_ORIGIN, LENGTH = OMV_SRAM_LENGTH
FLASH_TEXT (rx) : ORIGIN = OMV_TEXT_ORIGIN, LENGTH = OMV_TEXT_LENGTH
}
_heap_size = OMV_HEAP_SIZE; /* required amount of heap */
_stack_size = OMV_STACK_SIZE; /* minimum amount of stack */
_fs_start = OMV_TEXT_ORIGIN + OMV_TEXT_LENGTH;
_fs_end = OMV_TEXT_ORIGIN + OMV_TEXT_LENGTH + OMV_FFS_LENGTH;
_ram_start = ORIGIN(SRAM);
_ram_end = ORIGIN(SRAM) + LENGTH(SRAM);
_fs_start = ORIGIN(FLASH_TEXT) + LENGTH(FLASH_TEXT);
_fs_end = ORIGIN(FLASH_TEXT) + LENGTH(FLASH_TEXT) + OMV_FFS_LENGTH;
/* define output sections */
SECTIONS
@ -33,94 +34,49 @@ SECTIONS
.text :
{
. = ALIGN(4);
KEEP(*(.isr_vector)) /* Startup code */
*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
*(.rodata) /* .rodata sections (constants, strings, etc.) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
KEEP(*(.isr_vector)) // ISR table
. = ALIGN(4);
_etext = .; /* define a global symbol at end of code */
*(.text) // .text sections (code)
. = ALIGN(4);
*(.text*) // .text* sections (code)
. = ALIGN(4);
*(.rodata) // .rodata sections (constants, strings, etc.)
. = ALIGN(4);
*(.rodata*) // .rodata sections (constants, strings, etc.)
. = ALIGN(4);
_etext = .;
_unused_flash_start = .;
} >FLASH_TEXT
/* used by the startup to initialize data */
/* The address used as the source for copying the initialized data section. */
_sidata = LOADADDR(.data);
/* This is the initialized data section
The program executes knowing that the data is in the RAM
but the loader puts the initial values in the FLASH (inidata).
It is one task of the startup to copy the initial values from FLASH to RAM. */
/* Initialized data sections */
.data :
{
. = ALIGN(4); // Used by the startup to initialize the data section
_sdata = .;
*(.data) // .data sections
. = ALIGN(4);
_sdata = .; /* create a global symbol at data start; used by startup code to initialise the .data section in RAM */
_ram_start = .; /* create a global symbol at ram start for garbage collector */
*(.data) /* .data sections */
*(.data*) /* .data* sections */
*(.data*) // .data sections
. = ALIGN(4);
_edata = .; /* define a global symbol at data end; used by startup code to initialise the .data section in RAM */
_edata = .;
} >SRAM AT>FLASH_TEXT
/* Uninitialized data section */
.bss :
{
. = ALIGN(4);
_sbss = .; /* define a global symbol at bss start; used by startup code */
_sbss = .; // Used by the startup to initialize the .bss section
*(.bss)
. = ALIGN(4);
*(.bss*)
*(COMMON)
. = ALIGN(4);
_ebss = .; /* define a global symbol at bss end; used by startup code and GC */
_ebss = .; // define a global symbol at bss end
} >SRAM
/* Reserve heap memory */
._heap (NOLOAD) :
{
. = ALIGN(4);
_heap_start = .;
. = . + _heap_size;
. = ALIGN(4);
_heap_end = .;
} >OMV_MAIN_MEMORY
/* Reserve stack memory */
._stack (NOLOAD) :
{
. = ALIGN(4);
_sstack = .;
. = . + _stack_size;
. = ALIGN(4);
_estack = .;
_ram_end = .;
} >OMV_STACK_MEMORY
/* Main framebuffer memory */
.fb_memory (NOLOAD) :
{
. = ALIGN(4);
_fb_base = .;
. += OMV_FB_SIZE;
_fb_end = .;
. += OMV_FB_ALLOC_SIZE;
. = ALIGN(4);
_fballoc = .;
. = ALIGN(4);
#if !defined(OMV_JPEG_MEMORY)
_jpeg_buf = .; // IDE JPEG buffer
. = . + OMV_JPEG_BUF_SIZE;
. = ALIGN(4);
#endif
} >OMV_FB_MEMORY
.ARM.attributes 0 : { *(.ARM.attributes) }
#include "common.ld.S"
}
_unused_flash_len = (ORIGIN(FLASH_TEXT) + LENGTH(FLASH_TEXT)) - _unused_flash_start;

View File

@ -395,7 +395,8 @@ FIRMWARE_OBJS: | $(BUILD) $(FW_DIR)
$(MAKE) -C $(OMV_DIR) BUILD=$(BUILD)/$(OMV_DIR) CFLAGS="$(CFLAGS) -MMD"
$(FIRMWARE): FIRMWARE_OBJS
$(CPP) -P -E -I$(OMV_BOARD_CONFIG_DIR) $(OMV_DIR)/ports/$(PORT)/$(LDSCRIPT).ld.S > $(BUILD)/$(LDSCRIPT).lds
$(CPP) -P -E -I$(OMV_COMMON_DIR) -I$(OMV_BOARD_CONFIG_DIR) \
$(OMV_DIR)/ports/$(PORT)/$(LDSCRIPT).ld.S > $(BUILD)/$(LDSCRIPT).lds
$(CC) $(LDFLAGS) $(FIRM_OBJ) -o $(FW_DIR)/$(FIRMWARE).elf $(LIBS) -lgcc
$(OBJCOPY) -Oihex $(FW_DIR)/$(FIRMWARE).elf $(FW_DIR)/$(FIRMWARE).hex
$(OBJCOPY) -Obinary $(FW_DIR)/$(FIRMWARE).elf $(FW_DIR)/$(FIRMWARE).bin

View File

@ -74,7 +74,7 @@
extern void pendsv_init(void);
extern uint8_t __StackTop, __StackBottom;
static char OMV_ATTR_SECTION(OMV_ATTR_ALIGNED(gc_heap[OMV_HEAP_SIZE], 4), ".heap");
static char OMV_ATTR_SECTION(OMV_ATTR_ALIGNED(gc_heap[OMV_GC_BLOCK0_SIZE], 4), ".heap");
uint8_t *OMV_BOARD_UID_ADDR;
static pico_unique_board_id_t OMV_ATTR_ALIGNED(pico_unique_id, 4);

View File

@ -199,7 +199,7 @@ SECTIONS
#if !defined(OMV_JPEG_MEMORY)
_jpeg_buf = .; // IDE JPEG buffer
. = . + OMV_JPEG_BUF_SIZE;
. = . + OMV_JPEG_SIZE;
. = ALIGN(4);
#endif
} >OMV_FB_MEMORY

View File

@ -173,3 +173,92 @@ int dma_utils_set_irq_descr(DMA_Stream_TypeDef *dma_channel, DMA_HandleTypeDef *
}
return -1;
}
uint8_t dma_utils_mpu_region_size(uint32_t size) {
switch (size) {
case 0x00000020U: {
return MPU_REGION_SIZE_32B;
}
case 0x00000040U: {
return MPU_REGION_SIZE_64B;
}
case 0x00000080U: {
return MPU_REGION_SIZE_128B;
}
case 0x00000100U: {
return MPU_REGION_SIZE_256B;
}
case 0x00000200U: {
return MPU_REGION_SIZE_512B;
}
case 0x00000400U: {
return MPU_REGION_SIZE_1KB;
}
case 0x00000800U: {
return MPU_REGION_SIZE_2KB;
}
case 0x00001000U: {
return MPU_REGION_SIZE_4KB;
}
case 0x00002000U: {
return MPU_REGION_SIZE_8KB;
}
case 0x00004000U: {
return MPU_REGION_SIZE_16KB;
}
case 0x00008000U: {
return MPU_REGION_SIZE_32KB;
}
case 0x00010000U: {
return MPU_REGION_SIZE_64KB;
}
case 0x00020000U: {
return MPU_REGION_SIZE_128KB;
}
case 0x00040000U: {
return MPU_REGION_SIZE_256KB;
}
case 0x00080000U: {
return MPU_REGION_SIZE_512KB;
}
case 0x00100000U: {
return MPU_REGION_SIZE_1MB;
}
case 0x00200000U: {
return MPU_REGION_SIZE_2MB;
}
case 0x00400000U: {
return MPU_REGION_SIZE_4MB;
}
case 0x00800000U: {
return MPU_REGION_SIZE_8MB;
}
case 0x01000000U: {
return MPU_REGION_SIZE_16MB;
}
case 0x02000000U: {
return MPU_REGION_SIZE_32MB;
}
case 0x04000000U: {
return MPU_REGION_SIZE_64MB;
}
case 0x08000000U: {
return MPU_REGION_SIZE_128MB;
}
case 0x10000000U: {
return MPU_REGION_SIZE_256MB;
}
case 0x20000000U: {
return MPU_REGION_SIZE_512MB;
}
case 0x40000000U: {
return MPU_REGION_SIZE_1GB;
}
case 0x80000000U: {
return MPU_REGION_SIZE_2GB;
}
default: {
return MPU_REGION_SIZE_4GB;
}
}
}

View File

@ -19,4 +19,5 @@
uint8_t dma_utils_channel_to_irqn(DMA_Stream_TypeDef *dma_channel);
uint8_t dma_utils_channel_to_id(DMA_Stream_TypeDef *dma_channel);
int dma_utils_set_irq_descr(DMA_Stream_TypeDef *dma_channel, DMA_HandleTypeDef *dma_descr);
uint8_t dma_utils_mpu_region_size(uint32_t size);
#endif // __DMA_UTILS_H__

View File

@ -43,7 +43,8 @@ LDFLAGS = -mcpu=$(CPU) \
-mfloat-abi=hard \
-Wl,--gc-sections \
-Wl,--print-memory-usage \
-Wl,-T$(BUILD)/$(LDSCRIPT).lds
-Wl,-T$(BUILD)/$(LDSCRIPT).lds \
-Wl,-Map=$(BUILD)/$(FIRMWARE).map
HAL_CFLAGS += -I$(TOP_DIR)/$(CMSIS_DIR)/include/
HAL_CFLAGS += -I$(TOP_DIR)/$(CMSIS_DIR)/include/st
@ -732,7 +733,8 @@ endif
# This target generates the main/app firmware image located at 0x08010000
$(FIRMWARE): FIRMWARE_OBJS
$(CPP) -P -E -I$(OMV_BOARD_CONFIG_DIR) $(OMV_DIR)/ports/$(PORT)/$(LDSCRIPT).ld.S > $(BUILD)/$(LDSCRIPT).lds
$(CPP) -P -E -I$(OMV_COMMON_DIR) -I$(OMV_BOARD_CONFIG_DIR) \
$(OMV_DIR)/ports/$(PORT)/$(LDSCRIPT).ld.S > $(BUILD)/$(LDSCRIPT).lds
$(CC) $(LDFLAGS) $(FIRM_OBJ) -o $(FW_DIR)/$(FIRMWARE).elf $(LIBS) -lm
$(OBJCOPY) -Obinary $(FW_DIR)/$(FIRMWARE).elf $(FW_DIR)/$(FIRMWARE).bin
$(PYTHON) $(MKDFU) -D $(DFU_DEVICE) -b $(MAIN_APP_ADDR):$(FW_DIR)/$(FIRMWARE).bin $(FW_DIR)/$(FIRMWARE).dfu
@ -740,7 +742,8 @@ $(FIRMWARE): FIRMWARE_OBJS
ifeq ($(OMV_ENABLE_BL), 1)
# This target generates the bootloader.
$(BOOTLOADER): FIRMWARE_OBJS BOOTLOADER_OBJS
$(CPP) -P -E -I$(OMV_BOARD_CONFIG_DIR) $(BOOTLDR_DIR)/stm32fxxx.ld.S > $(BUILD)/$(BOOTLDR_DIR)/stm32fxxx.lds
$(CPP) -P -E -I$(OMV_COMMON_DIR) -I$(OMV_BOARD_CONFIG_DIR) \
$(BOOTLDR_DIR)/stm32fxxx.ld.S > $(BUILD)/$(BOOTLDR_DIR)/stm32fxxx.lds
$(CC) $(BL_LDFLAGS) $(BOOT_OBJ) -o $(FW_DIR)/$(BOOTLOADER).elf
$(OBJCOPY) -Obinary $(FW_DIR)/$(BOOTLOADER).elf $(FW_DIR)/$(BOOTLOADER).bin
$(PYTHON) $(MKDFU) -D $(DFU_DEVICE) -b 0x08000000:$(FW_DIR)/$(BOOTLOADER).bin $(FW_DIR)/$(BOOTLOADER).dfu
@ -749,7 +752,8 @@ endif
ifeq ($(OMV_ENABLE_UVC), 1)
# This target generates the UVC firmware.
$(UVC): FIRMWARE_OBJS UVC_OBJS
$(CPP) -P -E -I$(OMV_BOARD_CONFIG_DIR) $(UVC_DIR)/stm32fxxx.ld.S > $(BUILD)/$(UVC_DIR)/stm32fxxx.lds
$(CPP) -P -E -I$(OMV_COMMON_DIR) -I$(OMV_BOARD_CONFIG_DIR) \
$(UVC_DIR)/stm32fxxx.ld.S > $(BUILD)/$(UVC_DIR)/stm32fxxx.lds
$(CC) $(UVC_LDFLAGS) $(UVC_OBJ) -o $(FW_DIR)/$(UVC).elf -lgcc
$(OBJCOPY) -Obinary $(FW_DIR)/$(UVC).elf $(FW_DIR)/$(UVC).bin
$(PYTHON) $(MKDFU) -D $(DFU_DEVICE) -b $(MAIN_APP_ADDR):$(FW_DIR)/$(UVC).bin $(FW_DIR)/$(UVC).dfu

View File

@ -49,20 +49,13 @@ MEMORY
#endif
}
_heap_size = OMV_HEAP_SIZE; /* required amount of heap */
_stack_size = OMV_STACK_SIZE; /* minimum amount of stack */
_ram_start = ORIGIN(OMV_MAIN_MEMORY);
_ram_end = ORIGIN(OMV_MAIN_MEMORY) + LENGTH(OMV_MAIN_MEMORY);
#if defined(OMV_CM4_RAM_ORIGIN)
_cm4_ram_start = ORIGIN(CM4_SRAM);
#endif
#if defined(OMV_VOSPI_MEMORY)
#if !defined(OMV_VOSPI_MEMORY_OFFSET)
#define OMV_VOSPI_MEMORY_OFFSET (0)
#endif
_vospi_buf = ORIGIN(OMV_VOSPI_MEMORY) + OMV_VOSPI_MEMORY_OFFSET;
#endif
// Location of filesystem flash storage
_micropy_hw_internal_flash_storage_start = ORIGIN(FLASH_FFS);
_micropy_hw_internal_flash_storage_end = ORIGIN(FLASH_FFS) + LENGTH(FLASH_FFS);
@ -76,25 +69,12 @@ _micropy_hw_internal_flash_storage_ram_cache_start = ORIGIN(OMV_FFS_MEMORY) + OM
_micropy_hw_internal_flash_storage_ram_cache_end = LENGTH(OMV_FFS_MEMORY);
#endif
#define OMV_DEFINE_GC_BLOCK(n) \
.gc_block##n (NOLOAD) : \
{ \
. = ALIGN(4); \
. += OMV_GC_BLOCK##n##_SIZE; \
. = ALIGN(4); \
} >OMV_GC_BLOCK##n##_MEMORY \
#define OMV_ADD_GC_BLOCK(n) \
LONG (ADDR(.gc_block##n)) \
LONG (SIZEOF(.gc_block##n) / 4)
/* Define output sections */
SECTIONS
{
/* The program code and other data goes into FLASH */
.text :
.text : ALIGN(4)
{
. = ALIGN(4);
KEEP(*(.isr_vector))// ISR table
. = ALIGN(4);
*(.text) // .text sections (code)
@ -105,188 +85,38 @@ SECTIONS
. = ALIGN(4);
*(.rodata*) // .rodata* sections (constants, strings, etc.)
. = ALIGN(4);
_etext = .; // define a global symbols at end of code
} >FLASH_TEXT
.ARM.exidx :
{
*(.ARM.exidx*)
} > FLASH_TEXT
/* used by the startup to initialize data */
/* The address used as the source for copying the initialized data section. */
_sidata = LOADADDR(.data);
#if defined(OMV_GC_BLOCK0_MEMORY)
OMV_DEFINE_GC_BLOCK(0)
#endif
#if defined(OMV_GC_BLOCK1_MEMORY)
OMV_DEFINE_GC_BLOCK(1)
#endif
#if defined(OMV_GC_BLOCK2_MEMORY)
OMV_DEFINE_GC_BLOCK(2)
#endif
.gc_blocks_table (READONLY) :
{
. = ALIGN(4);
_gc_blocks_table_start = .;
#if defined(OMV_GC_BLOCK0_MEMORY)
OMV_ADD_GC_BLOCK(0)
#endif
#if defined(OMV_GC_BLOCK1_MEMORY)
OMV_ADD_GC_BLOCK(1)
#endif
#if defined(OMV_GC_BLOCK2_MEMORY)
OMV_ADD_GC_BLOCK(2)
#endif
_gc_blocks_table_end = .;
. = ALIGN(4);
} > FLASH_TEXT
/* Main framebuffer memory */
.fb_memory (NOLOAD) :
{
. = ALIGN(4);
_fb_base = .;
. += OMV_FB_SIZE;
_fb_end = .;
. += OMV_FB_ALLOC_SIZE;
. = ALIGN(4);
_fballoc = .;
. = ALIGN(4);
} >OMV_FB_MEMORY
#if defined(OMV_FB_OVERLAY_MEMORY)
.fb_overlay_memory (NOLOAD) :
{
. = ALIGN(4);
_fballoc_overlay_start = .;
. = . + OMV_FB_OVERLAY_SIZE;
_fballoc_overlay_end = .;
} >OMV_FB_OVERLAY_MEMORY
#endif
#if defined(OMV_JPEG_MEMORY)
/* JPEG framebuffer memory */
.jpeg_memory (NOLOAD) :
{
. = ALIGN(4);
_jpeg_buf = .; // IDE JPEG buffer
. = . + OMV_JPEG_BUF_SIZE;
. = ALIGN(4);
} >OMV_JPEG_MEMORY
#endif
/* Misc DMA buffers section */
.dma_memory (NOLOAD) :
{
. = ALIGN(16);
_line_buf = .; // Image line buffer.
. = . + OMV_LINE_BUF_SIZE;
. = ALIGN(16);
_msc_buf = .; // USB MSC bot data (2K)
. = . + OMV_MSC_BUF_SIZE;
. = ALIGN(16);
_vfs_buf = .; // VFS struct + FATFS file buffer (around 624 bytes)
. = . + OMV_VFS_BUF_SIZE;
#if defined(OMV_FFS_BUF_SIZE)
. = ALIGN(16);
_micropy_hw_internal_flash_storage_ram_cache_start = .;
. = . + OMV_FFS_BUF_SIZE;
_micropy_hw_internal_flash_storage_ram_cache_end = .;
#endif
#if !defined(OMV_JPEG_MEMORY)
. = ALIGN(16);
_jpeg_buf = .; // IDE JPEG buffer
. = . + OMV_JPEG_BUF_SIZE;
#endif
. = ALIGN(16);
*(.dma_buffer)
} >OMV_DMA_MEMORY
/* Domain 1 DMA buffers. */
#if defined(OMV_DMA_MEMORY_D1)
.d1_dma_memory (NOLOAD) :
{
. = ALIGN(16);
*(.d1_dma_buffer)
} >OMV_DMA_MEMORY_D1
#endif
/* Domain 2 DMA buffers. */
#if defined(OMV_DMA_MEMORY_D2)
.d2_dma_memory (NOLOAD) :
{
. = ALIGN(16);
*(.d2_dma_buffer)
} >OMV_DMA_MEMORY_D2
#endif
/* Domain 3 DMA buffers. */
#if defined(OMV_DMA_MEMORY_D3)
.d3_dma_memory (NOLOAD) :
{
. = ALIGN(16);
*(.d3_dma_buffer)
} >OMV_DMA_MEMORY_D3
#endif
/* Initialized data sections */
.data :
.data : ALIGN(4)
{
. = ALIGN(4);
_sdata = .; // Create a global symbol at data start
_ram_start = .;
_sdata = .; // Used by the startup to initialize the data section
*(.data) // .data sections
. = ALIGN(4);
*(.data*) // .data* sections
. = ALIGN(4);
_edata = .; // define a global symbol at data end
_edata = .; // Define a global symbol at data end
} >OMV_MAIN_MEMORY AT> FLASH_TEXT
/* Uninitialized data section */
. = ALIGN(4);
.bss (NOLOAD) :
.bss (NOLOAD) : ALIGN(4)
{
. = ALIGN(4);
_sbss = .; // Used by the startup to initialize the .bss section
. = ALIGN(4);
*(.bss*)
. = ALIGN(4);
*(COMMON)
. = ALIGN(4);
_ebss = .; // define a global symbol at bss end
_ebss = .; // Define a global symbol at bss end
} >OMV_MAIN_MEMORY
._heap (NOLOAD) :
#include "common.ld.S"
.mp_etext :
{
. = ALIGN(4);
_heap_start = .;
. = . + _heap_size;
. = ALIGN(4);
_heap_end = .;
} >OMV_HEAP_MEMORY
/* Make sure there is enough ram for the stack */
._stack (NOLOAD) :
{
. = ALIGN(8);
_sstack = .;
. = . + _stack_size;
. = ALIGN(8);
_estack = .;
} >OMV_STACK_MEMORY
.ARM.attributes 0 : { *(.ARM.attributes) }
_etext = .; // This is for stm modmachine, and not used for anything else.
} > FLASH_TEXT
}

View File

@ -17,6 +17,13 @@
// Define pin objects in this file.
#define OMV_GPIO_DEFINE_PINS (1)
#include "omv_gpio.h"
#include "dma_utils.h"
#if defined(MPU_REGION_NUMBER15)
#define MPU_REGION_NUMBER_MAX (MPU_REGION_NUMBER15)
#else
#define MPU_REGION_NUMBER_MAX (MPU_REGION_NUMBER7)
#endif
extern void SystemClock_Config(void);
extern uint32_t omv_exti_get_gpio(uint32_t line);
@ -25,10 +32,7 @@ void HAL_MspInit(void) {
/* Set the system clock */
SystemClock_Config();
#if defined(OMV_DMA_REGION_D1_BASE) \
|| defined(OMV_DMA_REGION_D2_BASE) \
|| defined(OMV_DMA_REGION_D3_BASE)
__DSB(); __ISB();
#if (__DCACHE_PRESENT == 1) && defined(OMV_DMA_MEMORY)
HAL_MPU_Disable();
// Configure the MPU attributes to disable caching DMA buffers.
@ -42,38 +46,35 @@ void HAL_MspInit(void) {
MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE;
// Disable all regions.
for (int i = MPU_REGION_NUMBER0; i < MPU_REGION_NUMBER15; i++) {
for (int i = MPU_REGION_NUMBER0; i <= MPU_REGION_NUMBER_MAX; i++) {
MPU_InitStruct.Number = i;
MPU_InitStruct.Enable = MPU_REGION_DISABLE;
HAL_MPU_ConfigRegion(&MPU_InitStruct);
}
MPU_InitStruct.Enable = MPU_REGION_ENABLE;
#if defined(OMV_DMA_REGION_D1_BASE)
MPU_InitStruct.Number = MPU_REGION_NUMBER15;
MPU_InitStruct.BaseAddress = OMV_DMA_REGION_D1_BASE;
MPU_InitStruct.Size = OMV_DMA_REGION_D1_SIZE;
HAL_MPU_ConfigRegion(&MPU_InitStruct);
#endif // defined(OMV_DMA_REGION_D1_BASE)
typedef struct {
uint32_t *addr;
uint32_t size;
} dma_memory_table_t;
#if defined(OMV_DMA_REGION_D2_BASE)
MPU_InitStruct.Number = MPU_REGION_NUMBER14;
MPU_InitStruct.BaseAddress = OMV_DMA_REGION_D2_BASE;
MPU_InitStruct.Size = OMV_DMA_REGION_D2_SIZE;
HAL_MPU_ConfigRegion(&MPU_InitStruct);
#endif // defined(OMV_DMA_REGION_D2_BASE)
uint8_t region_number = MPU_REGION_NUMBER_MAX;
extern const dma_memory_table_t _dma_memory_table_start;
extern const dma_memory_table_t _dma_memory_table_end;
#if defined(OMV_DMA_REGION_D3_BASE)
MPU_InitStruct.Number = MPU_REGION_NUMBER13;
MPU_InitStruct.BaseAddress = OMV_DMA_REGION_D3_BASE;
MPU_InitStruct.Size = OMV_DMA_REGION_D3_SIZE;
HAL_MPU_ConfigRegion(&MPU_InitStruct);
#endif // defined(OMV_DMA_REGION_D3_BASE)
for (dma_memory_table_t const *buf = &_dma_memory_table_start; buf < &_dma_memory_table_end; buf++) {
if (buf->size >= 32) {
MPU_InitStruct.Number = region_number--;
MPU_InitStruct.Enable = MPU_REGION_ENABLE;
MPU_InitStruct.BaseAddress = *(buf->addr);
MPU_InitStruct.Size = dma_utils_mpu_region_size(buf->size);
HAL_MPU_ConfigRegion(&MPU_InitStruct);
}
}
// Enable the MPU.
HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT);
__DSB(); __ISB();
#endif // defined(OMV_DMA_REGION_D1_BASE || OMV_DMA_REGION_D2_BASE || OMV_DMA_REGION_D3_BASE)
#endif // defined(OMV_DMA_MEMORY)
// Enable I/D cache.
#if defined(MCU_SERIES_F7) || defined(MCU_SERIES_H7)

View File

@ -40,8 +40,6 @@ MEMORY
FLASH_TEXT (rx) : ORIGIN = OMV_FLASH_TXT_ORIGIN, LENGTH = OMV_FLASH_TXT_LENGTH
}
_heap_size = OMV_HEAP_SIZE; /* required amount of heap */
_stack_size = OMV_STACK_SIZE; /* minimum amount of stack */
_ram_end = ORIGIN(OMV_MAIN_MEMORY) + LENGTH(OMV_MAIN_MEMORY);
#if defined(OMV_FFS_MEMORY)
@ -51,13 +49,6 @@ _ram_end = ORIGIN(OMV_MAIN_MEMORY) + LENGTH(OMV_MAIN_MEMORY);
_ffs_cache = ORIGIN(OMV_FFS_MEMORY) + OMV_FFS_MEMORY_OFFSET;
#endif
#if defined(OMV_VOSPI_MEMORY)
#if !defined(OMV_VOSPI_MEMORY_OFFSET)
#define OMV_VOSPI_MEMORY_OFFSET (0)
#endif
_vospi_buf = ORIGIN(OMV_VOSPI_MEMORY) + OMV_VOSPI_MEMORY_OFFSET;
#endif
/* Define output sections */
SECTIONS
{
@ -78,152 +69,31 @@ SECTIONS
_etext = .; // define a global symbols at end of code
} >FLASH_TEXT
/* used by the startup to initialize data */
/* The address used as the source for copying the initialized data section. */
_sidata = LOADADDR(.data);
/* Main framebuffer memory */
.fb_memory (NOLOAD) :
{
. = ALIGN(4);
_fb_base = .;
. += OMV_FB_SIZE;
_fb_end = .;
. += OMV_FB_ALLOC_SIZE;
. = ALIGN(4);
_fballoc = .;
. = ALIGN(4);
} >OMV_FB_MEMORY
#if defined(OMV_FB_OVERLAY_MEMORY)
.fb_overlay_memory (NOLOAD) :
{
. = ALIGN(4);
_fballoc_overlay_start = .;
. = . + OMV_FB_OVERLAY_SIZE;
_fballoc_overlay_end = .;
} >OMV_FB_OVERLAY_MEMORY
#endif
#if defined(OMV_JPEG_MEMORY)
/* JPEG framebuffer memory */
.jpeg_memory (NOLOAD) :
{
. = ALIGN(4);
_jpeg_buf = .; // IDE JPEG buffer
. = . + OMV_JPEG_BUF_SIZE;
. = ALIGN(4);
} >OMV_JPEG_MEMORY
#endif
/* Misc DMA buffers section */
.dma_memory (NOLOAD) :
{
. = ALIGN(16);
_line_buf = .; // Image line buffer.
. = . + OMV_LINE_BUF_SIZE;
. = ALIGN(16);
_msc_buf = .; // USB MSC bot data (2K)
. = . + OMV_MSC_BUF_SIZE;
. = ALIGN(16);
_vfs_buf = .; // VFS struct + FATFS file buffer (around 624 bytes)
. = . + OMV_VFS_BUF_SIZE;
#if defined(OMV_FFS_BUF_SIZE)
. = ALIGN(16);
_ffs_cache = .; // Flash filesystem cache
. = . + OMV_FFS_BUF_SIZE;
#endif
#if !defined(OMV_JPEG_MEMORY)
. = ALIGN(16);
_jpeg_buf = .; // IDE JPEG buffer
. = . + OMV_JPEG_BUF_SIZE;
#endif
. = ALIGN(16);
*(.dma_buffer)
} >OMV_DMA_MEMORY
/* Domain 1 DMA buffers. */
#if defined(OMV_DMA_MEMORY_D1)
.d1_dma_memory (NOLOAD) :
{
. = ALIGN(16);
*(.d1_dma_buffer)
} >OMV_DMA_MEMORY_D1
#endif
/* Domain 2 DMA buffers. */
#if defined(OMV_DMA_MEMORY_D2)
.d2_dma_memory (NOLOAD) :
{
. = ALIGN(16);
*(.d2_dma_buffer)
} >OMV_DMA_MEMORY_D2
#endif
/* Domain 3 DMA buffers. */
#if defined(OMV_DMA_MEMORY_D3)
.d3_dma_memory (NOLOAD) :
{
. = ALIGN(16);
*(.d3_dma_buffer)
} >OMV_DMA_MEMORY_D3
#endif
/* Initialized data sections */
.data :
.data : ALIGN(4)
{
. = ALIGN(4);
_sdata = .; // Create a global symbol at data start
_ram_start = .;
_sdata = .; // Used by the startup to initialize the data section
*(.data) // .data sections
. = ALIGN(4);
*(.data*) // .data* sections
. = ALIGN(4);
_edata = .; // define a global symbol at data end
_edata = .; // Define a global symbol at data end
} >OMV_MAIN_MEMORY AT> FLASH_TEXT
/* Uninitialized data section */
. = ALIGN(4);
.bss (NOLOAD) :
.bss (NOLOAD) : ALIGN(4)
{
. = ALIGN(4);
_sbss = .; // Used by the startup to initialize the .bss secion
_sbss = .; // Used by the startup to initialize the .bss section
. = ALIGN(4);
*(.bss*)
. = ALIGN(4);
*(COMMON)
. = ALIGN(4);
_ebss = .; // define a global symbol at bss end
_ebss = .; // Define a global symbol at bss end
} >OMV_MAIN_MEMORY
._heap (NOLOAD) :
{
. = ALIGN(4);
_heap_start = .;
. = . + _heap_size;
. = ALIGN(4);
_heap_end = .;
} >OMV_HEAP_MEMORY
/* Make sure there is enough ram for the stack */
._stack (NOLOAD) :
{
. = ALIGN(8);
_sstack = .;
. = . + _stack_size;
. = ALIGN(8);
_estack = .;
} >OMV_STACK_MEMORY
.ARM.attributes 0 : { *(.ARM.attributes) }
#include "common.ld.S"
}