Skip to content

What is the role of detached section? #10602

Closed

Description

@dbaluta

I'm having this issue on imx8mp with M7 core where ITCM section is not copied in the final .rimage because the corresponding section is marked as detached.

Here is the memory map for A53/M7 cores for ITCM:

Image

It looks like SOF marks any sections that's between this two limits:

define SOF_MODULE_DRAM_LINK_START»     0
#define SOF_MODULE_DRAM_LINK_END»       0x08000000

as detached and not copied in the final rimage.

So, what is the purpose of this detached section? Is there a way we can easily make this work? Would it make sense to add a per platform option named ignore_detached ?

Cc: @lyakh @lgirdwood

Pinned by dbaluta

Activity

  1. lgirdwood commented on Mar 5, 2026

    @lgirdwood
    Member

    Oh, thats a good question our architecture is NUMA. I've no objection, but I would have expected rimage to deal with multiple detached sections

  2. lyakh commented on Mar 6, 2026

    @lyakh
    Collaborator

    @dbaluta the purpose of "detached" sections is to implement "cold" data and text on Intel ADSP platforms. Those "cold" sections are then kept and used directly in DRAM without being copied to SRAM. So, firstly cold sections definitely do get copied to the rimage in Intel builds, so maybe you could do the same for your platform. But I'm not sure I understand - from your section map above it looks like all the 3 sections (OCRAM, DTCM, ITCM) are below SOF_MODULE_DRAM_LINK_END so there should be no difference between them?

  3. lgirdwood commented on Mar 6, 2026

    @lgirdwood
    Member

    @lyakh I'm thinking this should be supported but never tried for IMX given that we have cache, uncache and DRAM regions which are all detached from each other, I suspect the Intel arch could maybe be baked into some rimage assumptions as IIUC rimage should obey the linker sections.

  4. dbaluta commented on Mar 6, 2026

    @dbaluta
    CollaboratorAuthor

    @dbaluta the purpose of "detached" sections is to implement "cold" data and text on Intel ADSP platforms. Those "cold" sections are then kept and used directly in DRAM without being copied to SRAM. So, firstly cold sections definitely do get copied to the rimage in Intel builds, so maybe you could do the same for your platform. But I'm not sure I understand - from your section map above it looks like all the 3 sections (OCRAM, DTCM, ITCM) are below SOF_MODULE_DRAM_LINK_END so there should be no difference between them?

    OCRAM and DTCM would be in the same situation yes! But we only use ITCM for jumpstart code then everything is executed from DRAM.

    If we decide in the future that we would want to use OCRAM and DTCM they would also be marked as detached as per rimage implementation.

  5. dbaluta commented on Mar 6, 2026

    @dbaluta
    CollaboratorAuthor

    @dbaluta the purpose of "detached" sections is to implement "cold" data and text on Intel ADSP platforms. Those "cold" sections are then kept and used directly in DRAM without being copied to SRAM. So, firstly cold sections definitely do get copied to the rimage in Intel builds, so maybe you could do the same for your platform. But I'm not sure I understand - from your section map above it looks like all the 3 sections (OCRAM, DTCM, ITCM) are below SOF_MODULE_DRAM_LINK_END so there should be no difference between them?

    Any idea where this Intel cold sections are copied in the rimage?

    later edit

    Maybe I'm missing something but ROM and detached looks like are not copied:

        »       if (out_section->detached) {                                                                                                                                                  
    »       »       »       /* Detached sections are copied as is and don't contribute to metadata */
    »       »       »       fprintf(stdout, " detached");
    »       »       } else if (out_section->rom) {
    »       »       »       /* ROM sections aren't included in the output image */
    »       »       »       fprintf(stdout, " ROM");
    »       »       } else {
    »       »       »       /* Add section to list */
    »       »       »       if (info)
    »       »       »       »       sections_info_add(info, out_section);
    »       »       }
    

    I mean I thought that sections are copied to rimage only if they are added to the section list. I will continue investigation because what you say makes sense and it looks like it should work even if the section is marked as detached.

  6. lyakh commented on Mar 6, 2026

    @lyakh
    Collaborator

    @dbaluta

    at the moment the only type of "detached" sections, supported by SOF are "cold" (text and data) sections:

    if (out_section->detached)
    cold_data_size += out_section->size;
    if (out_section->detached)
    cold_text_size += out_section->size;

    When the base module is built those sections are then linked into a separate "cold.mod" module: https://github.com/thesofproject/sof/actions/runs/22758903606/job/66010318688?pr=10599#step:8:1129 which is then linked into the final zephyr.ri https://github.com/thesofproject/sof/actions/runs/22758903606/job/66010318688?pr=10599#step:8:1039

    With LLEXT modules this is a bit different - there all sections (hot and cold) are linked into the same module.

    Maybe we could define SOF_MODULE_DRAM_LINK_END per platform and if it's 0 all sections will be treated as SRAM?

  7. dbaluta commented on Mar 6, 2026

    @dbaluta
    CollaboratorAuthor

    I see. Thanks! Yes having a per platform SOF_MODULE_DRAM_LINK_END would work. Will send a patch.

  8. github-actions commented on May 10, 2026

    @github-actions

    This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time.

  9. added
    staleIssue/PR marked as stale and will be closed after 14 days if there is no activity.
    on May 10, 2026
  10. lgirdwood commented on May 25, 2026

    @lgirdwood
    Member

    @lyakh just hit this as well when loading llext unit test modules using the shell. i.e. they are not audio modules, but I have a command to call the ctor which would fail unless this was applied: zephyrproject-rtos/zephyr@main...lgirdwood:zephyr:topic/llext_plt
    Not sure if you came across this during your llext dev re detached sections though ?
    @dbaluta not sure if this helps you ?

  11. removed
    staleIssue/PR marked as stale and will be closed after 14 days if there is no activity.
    on May 26, 2026
  12. lyakh commented on May 26, 2026

    @lyakh
    Collaborator

    @lgirdwood are you sure your problem is the same as the original one here? The original one is about "cold" sections not being "copied in the final rimage" and it had nothing to do with LLEXT. Maybe your problem needs a separate "issue"

  13. lgirdwood commented on May 26, 2026

    @lgirdwood
    Member

    @lgirdwood are you sure your problem is the same as the original one here? The original one is about "cold" sections not being "copied in the final rimage" and it had nothing to do with LLEXT. Maybe your problem needs a separate "issue"

    @lyakh Sorry I mean in general did you encounter any issues with detached sections when working on llext ? I'm asking as I want to know whether detached sections are always handled correctly within the build system (not just for llext) or do we have gaps here (in build commands or rimage) that need recorded or fixed. I do remember the silent linkage cmd line flags that xt-cc would accept and do nothing. If your happy there is no gaps, we can close.

  14. lyakh commented on May 27, 2026

    @lyakh
    Collaborator

    @lgirdwood are you sure your problem is the same as the original one here? The original one is about "cold" sections not being "copied in the final rimage" and it had nothing to do with LLEXT. Maybe your problem needs a separate "issue"

    @lyakh Sorry I mean in general did you encounter any issues with detached sections when working on llext ? I'm asking as I want to know whether detached sections are always handled correctly within the build system (not just for llext) or do we have gaps here (in build commands or rimage) that need recorded or fixed. I do remember the silent linkage cmd line flags that xt-cc would accept and do nothing. If your happy there is no gaps, we can close.

    @lgirdwood don't remember any current issues with the present "main" off the top of my head. If and when any such issues are discovered then by all means we should document and get to fixing them. I'm not aware of any failing tests in that area either..

  15. dbaluta commented on May 27, 2026

    @dbaluta
    CollaboratorAuthor

    @lgirdwood i managed to go over this "issue" by adding an option to ignore the "detached" section.

    See: #10624

  16. lgirdwood commented on May 27, 2026

    @lgirdwood
    Member

    Thanks @lyakh and @dbaluta - will close this one as resolved. I've got another fix brewing for detached sections and llext.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working as expected

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions