Skip to content

Commit

Permalink
#11789: Fix firmware/kernel padding/alignment
Browse files Browse the repository at this point in the history
  • Loading branch information
pgkeller committed Oct 3, 2024
1 parent f52272a commit 0d5f488
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 23 deletions.
9 changes: 3 additions & 6 deletions tt_metal/hw/inc/blackhole/dev_mem_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,6 @@
#define MEM_TRISC1_STACK_BASE (MEM_LOCAL_BASE + MEM_TRISC_LOCAL_SIZE - MEM_TRISC1_STACK_SIZE)
#define MEM_TRISC2_STACK_BASE (MEM_LOCAL_BASE + MEM_TRISC_LOCAL_SIZE - MEM_TRISC2_STACK_SIZE)

/////////////
// Padding/alignment restrictions needed in linker scripts
// Note we pad then align so, for example, erisc can keep space between fw/kernels
#define MEM_TENSIX_KERNEL_PAD 12


/////////////
// IERISC memory map
Expand All @@ -115,4 +110,6 @@
#define MEM_IERISC_STACK_SIZE 1024
#define MEM_IERISC_STACK_BASE (MEM_LOCAL_BASE + MEM_IERISC_LOCAL_SIZE - MEM_IERISC_STACK_SIZE)

#define MEM_IERISC_KERNEL_PAD 28
/////////////
// Padding/alignment restriction needed in linker scripts for erisc
#define MEM_IERISC_KERNEL_PAD 32
5 changes: 0 additions & 5 deletions tt_metal/hw/inc/grayskull/dev_mem_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,6 @@
#define MEM_TRISC1_STACK_BASE (MEM_LOCAL_BASE + MEM_TRISC_LOCAL_SIZE - MEM_TRISC1_STACK_SIZE)
#define MEM_TRISC2_STACK_BASE (MEM_LOCAL_BASE + MEM_TRISC_LOCAL_SIZE - MEM_TRISC2_STACK_SIZE)

/////////////
// Padding/alignment restrictions needed in linker scripts
// Note we pad then align so, for example, erisc can keep space between fw/kernels
#define MEM_TENSIX_KERNEL_PAD 12


/////////////
// IERISC memory map
Expand Down
9 changes: 3 additions & 6 deletions tt_metal/hw/inc/wormhole/dev_mem_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,6 @@
#define MEM_TRISC1_STACK_BASE (MEM_LOCAL_BASE + MEM_TRISC_LOCAL_SIZE - MEM_TRISC1_STACK_SIZE)
#define MEM_TRISC2_STACK_BASE (MEM_LOCAL_BASE + MEM_TRISC_LOCAL_SIZE - MEM_TRISC2_STACK_SIZE)

/////////////
// Padding/alignment restrictions needed in linker scripts
// Note we pad then align so, for example, erisc can keep space between fw/kernels
#define MEM_TENSIX_KERNEL_PAD 12


/////////////
// IERISC memory map
Expand All @@ -125,4 +120,6 @@
#define MEM_IERISC_STACK_SIZE 1024
#define MEM_IERISC_STACK_BASE (MEM_LOCAL_BASE + MEM_IERISC_LOCAL_SIZE - MEM_IERISC_STACK_SIZE)

#define MEM_IERISC_KERNEL_PAD 28
/////////////
// Padding/alignment restriction needed in linker scripts for erisc
#define MEM_IERISC_KERNEL_PAD 32
11 changes: 5 additions & 6 deletions tt_metal/hw/toolchain/sections.ld
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@
#if defined(TARGET_IERISC)
#define MEM_PAD MEM_IERISC_KERNEL_PAD
#else
#define MEM_PAD MEM_TENSIX_KERNEL_PAD
#define MEM_PAD 0
#endif
/* FW must align to 16 byte boundary so kernel begins aligned to meet noc alignment constraints */
#define MEM_ALIGN 16
#else
#define MEM_PAD 0
#define MEM_ALIGN 4
#endif

#define MEM_ALIGN (MEM_PAD + 4)

OUTPUT_FORMAT("elf32-littleriscv", "elf32-littleriscv",
"elf32-littleriscv")
OUTPUT_ARCH(riscv)
Expand Down Expand Up @@ -144,9 +145,7 @@ SECTIONS
} > REGION_DATA

#ifdef TYPE_FIRMWARE
/* FW must align to 16 byte boundary so Kernel begins aligned to meet noc
alignment constraints */
. = ALIGN(16);
. = ALIGN(MEM_ALIGN);
__fw_export_ldm_end = .;
#endif

Expand Down

0 comments on commit 0d5f488

Please sign in to comment.