Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DRAFT] LLEXT DRAM data #9721

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 28 additions & 14 deletions scripts/llext_link_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def main():
executable = []
writable = []
readonly = []
readonly_dram = []
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this will all be dumped when we build the target i.e. xkB hybrid RODATA in DRAM ?


text_found = False

Expand All @@ -101,10 +102,7 @@ def main():
if (s_flags & (SH_FLAGS.SHF_ALLOC | SH_FLAGS.SHF_EXECINSTR) ==
SH_FLAGS.SHF_ALLOC | SH_FLAGS.SHF_EXECINSTR and
s_type == 'SHT_PROGBITS'):
# An executable section, currently only a single .text is supported.
# In general additional executable sections are possible, e.g.
# .init. In the future support for arbitrary such sections can be
# added, similar to writable and read-only data below.
# An executable section.
if s_name == '.text':
text_found = True
text_addr = max_alignment(text_addr, 0x1000, s_alignment)
Expand All @@ -123,7 +121,10 @@ def main():

if s_type == 'SHT_PROGBITS' and s_flags & SH_FLAGS.SHF_ALLOC:
# .rodata or other read-only sections
readonly.append(section)
if '.dram' in s_name:
readonly_dram.append(section)
else:
readonly.append(section)

if not text_found:
raise RuntimeError('No .text section found in the object file')
Expand All @@ -136,24 +137,37 @@ def main():
# run at arbitrary memory locations. One of the use-cases is running
# parts of the module directly in DRAM - sacrificing performance but
# saving scarce SRAM. We achieve this by placing non-performance
# critical functions in a .text.dram ELF section. When compiling and
# linking such functions, an additional .literal.dram section is
# automatically created. Note, that for some reason the compiler also
# marks that section as executable.
# critical functions in a .text.dram ELF section, read-only data in a
# .rodata.dram ELF section, etc. When compiling and
# linking such functions, additional sections like .literal.dram are
# automatically created. Note, that for some reason for .text.dram the
# compiler also marks that section as executable.
# This script links those sections at address 0. We could hard-code
# section names, but so far we choose to only link .text the "original"
# way and all other executable sections we link at 0.
exe_addr = 0
# way and all other executable sections we link at 0. For data sections
# we accept any *.dram names.

dram_addr = 0

for section in executable:
s_alignment = section.header['sh_addralign']
s_name = section.name

exe_addr = align_up(exe_addr, s_alignment)
dram_addr = align_up(dram_addr, s_alignment)

command.append(f'-Wl,--section-start={s_name}=0x{dram_addr:x}')

dram_addr += section.header['sh_size']

for section in readonly_dram:
s_alignment = section.header['sh_addralign']
s_name = section.name

dram_addr = align_up(dram_addr, s_alignment)

command.append(f'-Wl,--section-start={s_name}=0x{exe_addr:x}')
command.append(f'-Wl,--section-start={s_name}=0x{dram_addr:x}')

exe_addr += section.header['sh_size']
dram_addr += section.header['sh_size']

start_addr = align_up(text_addr + text_size, 0x1000)

Expand Down
2 changes: 1 addition & 1 deletion src/audio/src/coef/src_ipc4_int32_10_21_2500_5000.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <stdint.h>

static const int32_t src_int32_10_21_2500_5000_fir[480] = {
__cold_data static const int32_t src_int32_10_21_2500_5000_fir[480] = {
176197,
283398,
-489527,
Expand Down
2 changes: 1 addition & 1 deletion src/audio/src/coef/src_ipc4_int32_10_21_3455_5000.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <stdint.h>

static const int32_t src_int32_10_21_3455_5000_fir[640] = {
__cold_data static const int32_t src_int32_10_21_3455_5000_fir[640] = {
110400,
517669,
162088,
Expand Down
2 changes: 1 addition & 1 deletion src/audio/src/coef/src_ipc4_int32_10_21_4535_5000.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <stdint.h>

static const int32_t src_int32_10_21_4535_5000_fir[2320] = {
__cold_data static const int32_t src_int32_10_21_4535_5000_fir[2320] = {
26554,
22041,
-35569,
Expand Down
2 changes: 1 addition & 1 deletion src/audio/src/coef/src_ipc4_int32_10_9_4535_5000.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <stdint.h>

static const int32_t src_int32_10_9_4535_5000_fir[1080] = {
__cold_data static const int32_t src_int32_10_9_4535_5000_fir[1080] = {
-35695,
60551,
-91611,
Expand Down
2 changes: 1 addition & 1 deletion src/audio/src/coef/src_ipc4_int32_16_21_4319_5000.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <stdint.h>

static const int32_t src_int32_16_21_4319_5000_fir[1472] = {
__cold_data static const int32_t src_int32_16_21_4319_5000_fir[1472] = {
69743,
-28255,
-123867,
Expand Down
2 changes: 1 addition & 1 deletion src/audio/src/coef/src_ipc4_int32_16_21_4535_5000.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <stdint.h>

static const int32_t src_int32_16_21_4535_5000_fir[2048] = {
__cold_data static const int32_t src_int32_16_21_4535_5000_fir[2048] = {
66387,
-68365,
-7975,
Expand Down
2 changes: 1 addition & 1 deletion src/audio/src/coef/src_ipc4_int32_16_7_4082_5000.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <stdint.h>

static const int32_t src_int32_16_7_4082_5000_fir[896] = {
__cold_data static const int32_t src_int32_16_7_4082_5000_fir[896] = {
-71000,
181977,
-339747,
Expand Down
2 changes: 1 addition & 1 deletion src/audio/src/coef/src_ipc4_int32_1_2_2268_5000.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/** \cond GENERATED_BY_TOOLS_TUNE_SRC */
#include <stdint.h>

static const int32_t src_int32_1_2_2268_5000_fir[36] = {
__cold_data static const int32_t src_int32_1_2_2268_5000_fir[36] = {
1065827,
-37924,
-4976218,
Expand Down
2 changes: 1 addition & 1 deletion src/audio/src/coef/src_ipc4_int32_1_2_2500_5000.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <stdint.h>

static const int32_t src_int32_1_2_2500_5000_fir[40] = {
__cold_data static const int32_t src_int32_1_2_2500_5000_fir[40] = {
-879692,
460291,
4237437,
Expand Down
2 changes: 1 addition & 1 deletion src/audio/src/coef/src_ipc4_int32_1_2_2721_5000.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <stdint.h>

static const int32_t src_int32_1_2_2721_5000_fir[44] = {
__cold_data static const int32_t src_int32_1_2_2721_5000_fir[44] = {
776925,
-535235,
-3522824,
Expand Down
2 changes: 1 addition & 1 deletion src/audio/src/coef/src_ipc4_int32_1_2_3401_5000.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <stdint.h>

static const int32_t src_int32_1_2_3401_5000_fir[60] = {
__cold_data static const int32_t src_int32_1_2_3401_5000_fir[60] = {
483288,
-83413,
-1522435,
Expand Down
2 changes: 1 addition & 1 deletion src/audio/src/coef/src_ipc4_int32_1_2_3887_5000.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <stdint.h>

static const int32_t src_int32_1_2_3887_5000_fir[84] = {
__cold_data static const int32_t src_int32_1_2_3887_5000_fir[84] = {
488732,
-7737,
-1049640,
Expand Down
2 changes: 1 addition & 1 deletion src/audio/src/coef/src_ipc4_int32_1_2_4535_5000.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <stdint.h>

static const int32_t src_int32_1_2_4535_5000_fir[192] = {
__cold_data static const int32_t src_int32_1_2_4535_5000_fir[192] = {
-215107,
-43725,
301513,
Expand Down
2 changes: 1 addition & 1 deletion src/audio/src/coef/src_ipc4_int32_1_3_2268_5000.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <stdint.h>

static const int32_t src_int32_1_3_2268_5000_fir[52] = {
__cold_data static const int32_t src_int32_1_3_2268_5000_fir[52] = {
856478,
-618891,
-4156030,
Expand Down
2 changes: 1 addition & 1 deletion src/audio/src/coef/src_ipc4_int32_1_3_4535_5000.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <stdint.h>

static const int32_t src_int32_1_3_4535_5000_fir[260] = {
__cold_data static const int32_t src_int32_1_3_4535_5000_fir[260] = {
-76785,
87265,
208768,
Expand Down
2 changes: 1 addition & 1 deletion src/audio/src/coef/src_ipc4_int32_1_4_1512_5000.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <stdint.h>

static const int32_t src_int32_1_4_1512_5000_fir[52] = {
__cold_data static const int32_t src_int32_1_4_1512_5000_fir[52] = {
740488,
-111252,
-2633435,
Expand Down
2 changes: 1 addition & 1 deletion src/audio/src/coef/src_ipc4_int32_1_4_2268_5000.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <stdint.h>

static const int32_t src_int32_1_4_2268_5000_fir[60] = {
__cold_data static const int32_t src_int32_1_4_2268_5000_fir[60] = {
-1265010,
-1300023,
42822,
Expand Down
2 changes: 1 addition & 1 deletion src/audio/src/coef/src_ipc4_int32_1_4_4535_5000.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <stdint.h>

static const int32_t src_int32_1_4_4535_5000_fir[332] = {
__cold_data static const int32_t src_int32_1_4_4535_5000_fir[332] = {
-246503,
-173077,
24381,
Expand Down
2 changes: 1 addition & 1 deletion src/audio/src/coef/src_ipc4_int32_1_6_1134_5000.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <stdint.h>

static const int32_t src_int32_1_6_1134_5000_fir[68] = {
__cold_data static const int32_t src_int32_1_6_1134_5000_fir[68] = {
-2393808,
-3445469,
-3907601,
Expand Down
2 changes: 1 addition & 1 deletion src/audio/src/coef/src_ipc4_int32_20_21_1250_5000.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <stdint.h>

static const int32_t src_int32_20_21_1250_5000_fir[320] = {
__cold_data static const int32_t src_int32_20_21_1250_5000_fir[320] = {
134710,
1035873,
-9174506,
Expand Down
2 changes: 1 addition & 1 deletion src/audio/src/coef/src_ipc4_int32_20_21_2500_5000.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <stdint.h>

static const int32_t src_int32_20_21_2500_5000_fir[560] = {
__cold_data static const int32_t src_int32_20_21_2500_5000_fir[560] = {
-5217,
-381011,
1487277,
Expand Down
2 changes: 1 addition & 1 deletion src/audio/src/coef/src_ipc4_int32_20_21_3125_5000.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <stdint.h>

static const int32_t src_int32_20_21_3125_5000_fir[640] = {
__cold_data static const int32_t src_int32_20_21_3125_5000_fir[640] = {
81905,
-392860,
605436,
Expand Down
2 changes: 1 addition & 1 deletion src/audio/src/coef/src_ipc4_int32_20_21_4167_5000.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <stdint.h>

static const int32_t src_int32_20_21_4167_5000_fir[1200] = {
__cold_data static const int32_t src_int32_20_21_4167_5000_fir[1200] = {
54594,
-184742,
399571,
Expand Down
2 changes: 1 addition & 1 deletion src/audio/src/coef/src_ipc4_int32_20_21_4535_5000.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <stdint.h>

static const int32_t src_int32_20_21_4535_5000_fir[2080] = {
__cold_data static const int32_t src_int32_20_21_4535_5000_fir[2080] = {
-39854,
85177,
-146854,
Expand Down
2 changes: 1 addition & 1 deletion src/audio/src/coef/src_ipc4_int32_20_7_2976_5000.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <stdint.h>

static const int32_t src_int32_20_7_2976_5000_fir[560] = {
__cold_data static const int32_t src_int32_20_7_2976_5000_fir[560] = {
-33375,
393038,
-1331352,
Expand Down
2 changes: 1 addition & 1 deletion src/audio/src/coef/src_ipc4_int32_21_10_2500_5000.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <stdint.h>

static const int32_t src_int32_21_10_2500_5000_fir[504] = {
__cold_data static const int32_t src_int32_21_10_2500_5000_fir[504] = {
7704,
568453,
-2657822,
Expand Down
2 changes: 1 addition & 1 deletion src/audio/src/coef/src_ipc4_int32_21_10_3455_5000.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <stdint.h>

static const int32_t src_int32_21_10_3455_5000_fir[756] = {
__cold_data static const int32_t src_int32_21_10_3455_5000_fir[756] = {
-37222,
240677,
-698458,
Expand Down
2 changes: 1 addition & 1 deletion src/audio/src/coef/src_ipc4_int32_21_10_4535_5000.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <stdint.h>

static const int32_t src_int32_21_10_4535_5000_fir[2520] = {
__cold_data static const int32_t src_int32_21_10_4535_5000_fir[2520] = {
-9118,
18975,
-33943,
Expand Down
2 changes: 1 addition & 1 deletion src/audio/src/coef/src_ipc4_int32_21_16_4319_5000.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <stdint.h>

static const int32_t src_int32_21_16_4319_5000_fir[1596] = {
__cold_data static const int32_t src_int32_21_16_4319_5000_fir[1596] = {
-50136,
105527,
-181643,
Expand Down
2 changes: 1 addition & 1 deletion src/audio/src/coef/src_ipc4_int32_21_16_4535_5000.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <stdint.h>

static const int32_t src_int32_21_16_4535_5000_fir[2436] = {
__cold_data static const int32_t src_int32_21_16_4535_5000_fir[2436] = {
-15208,
29050,
-48628,
Expand Down
2 changes: 1 addition & 1 deletion src/audio/src/coef/src_ipc4_int32_21_20_1250_5000.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <stdint.h>

static const int32_t src_int32_21_20_1250_5000_fir[420] = {
__cold_data static const int32_t src_int32_21_20_1250_5000_fir[420] = {
94664,
-1133291,
202774,
Expand Down
2 changes: 1 addition & 1 deletion src/audio/src/coef/src_ipc4_int32_21_20_2500_5000.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <stdint.h>

static const int32_t src_int32_21_20_2500_5000_fir[504] = {
__cold_data static const int32_t src_int32_21_20_2500_5000_fir[504] = {
8116,
587965,
-2725209,
Expand Down
2 changes: 1 addition & 1 deletion src/audio/src/coef/src_ipc4_int32_21_20_3125_5000.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <stdint.h>

static const int32_t src_int32_21_20_3125_5000_fir[672] = {
__cold_data static const int32_t src_int32_21_20_3125_5000_fir[672] = {
4928,
190845,
-929522,
Expand Down
2 changes: 1 addition & 1 deletion src/audio/src/coef/src_ipc4_int32_21_20_4167_5000.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <stdint.h>

static const int32_t src_int32_21_20_4167_5000_fir[1260] = {
__cold_data static const int32_t src_int32_21_20_4167_5000_fir[1260] = {
-79259,
176349,
-298364,
Expand Down
2 changes: 1 addition & 1 deletion src/audio/src/coef/src_ipc4_int32_21_20_4535_5000.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <stdint.h>

static const int32_t src_int32_21_20_4535_5000_fir[2268] = {
__cold_data static const int32_t src_int32_21_20_4535_5000_fir[2268] = {
-37260,
62223,
-92794,
Expand Down
Loading
Loading