diff --git a/tt_metal/hw/firmware/src/erisck.cc b/tt_metal/hw/firmware/src/erisck.cc index 54d9ab9b958..e98d2a444a7 100644 --- a/tt_metal/hw/firmware/src/erisck.cc +++ b/tt_metal/hw/firmware/src/erisck.cc @@ -23,7 +23,7 @@ CBInterface cb_interface[NUM_CIRCULAR_BUFFERS]; -void kernel_launch(uint32_t) { +extern "C" [[gnu::section(".start")]] void _start(uint32_t) { DeviceZoneScopedMainChildN("ERISC-KERNEL"); rtos_context_switch_ptr = (void (*)())RtosTable[0]; diff --git a/tt_metal/hw/toolchain/sections.ld b/tt_metal/hw/toolchain/sections.ld index 17162f235c8..457ac6fe99a 100644 --- a/tt_metal/hw/toolchain/sections.ld +++ b/tt_metal/hw/toolchain/sections.ld @@ -86,7 +86,9 @@ SECTIONS __kernel_init_local_l1_base = .; #endif +#if defined(TYPE_FIRMWARE) PROVIDE(__global_pointer$ = ORIGIN(REGION_DATA) + 0x7f0); +#endif .data DATA_START : ALIGN(4) { . = .; /* Force section emission. */ diff --git a/tt_metal/hw/toolchain/tmu-crt0k.S b/tt_metal/hw/toolchain/tmu-crt0k.S index 177d79cdb84..1e2f5bc6939 100644 --- a/tt_metal/hw/toolchain/tmu-crt0k.S +++ b/tt_metal/hw/toolchain/tmu-crt0k.S @@ -3,5 +3,8 @@ .type _start, @function _start: + // kernel_launch is responsible for the rest of crt -- clear bss, copy data image, run global constructors + // Enable GPREL optimizations + .reloc _start, R_RISCV_NONE, __global_pointer$ tail _Z13kernel_launchm .size _start, .-_start diff --git a/tt_metal/jit_build/build.cpp b/tt_metal/jit_build/build.cpp index 1d6fadcd9c9..8438ef88c05 100644 --- a/tt_metal/jit_build/build.cpp +++ b/tt_metal/jit_build/build.cpp @@ -188,7 +188,9 @@ void JitBuildState::finish_init() { this->link_objs_ += build_dir + "ncrisc-halt.o "; } } else { - this->link_objs_ += build_dir + "tmu-crt0k.o "; + if (this->target_name_ != "erisc") { + this->link_objs_ += build_dir + "tmu-crt0k.o "; + } } if (this->target_name_ == "brisc" or this->target_name_ == "idle_erisc") { this->link_objs_ += build_dir + "noc.o "; @@ -600,7 +602,7 @@ void JitBuildState::weaken(const string& log_file, const string& out_dir) const ll_api::ElfFile elf; elf.ReadImage(pathname_in); - static std::string_view const strong_names[] = {"__fw_export_*"}; + static std::string_view const strong_names[] = {"__fw_export_*", "__global_pointer$"}; elf.WeakenDataSymbols(strong_names); elf.WriteImage(pathname_out); }