Skip to content

fix(Build): Share multi core data 7800x when using RISCV_LOAD#1568

Open
perkinsmg wants to merge 1 commit into
analogdevicesinc:mainfrom
perkinsmg:fix/really-share-multi-core-data-7800x
Open

fix(Build): Share multi core data 7800x when using RISCV_LOAD#1568
perkinsmg wants to merge 1 commit into
analogdevicesinc:mainfrom
perkinsmg:fix/really-share-multi-core-data-7800x

Conversation

@perkinsmg

Copy link
Copy Markdown
Contributor

Description

The SystemCoreClock variable, placed into the .shared section, was only placed at identical addresses in the Cortex and RISC-V projects when using the _arm.ld and _rv ld scripts together. When using the max7800x.ld script and the RISCV_LOAD mechanism, the variable was placed at different addresses in both executables.

Fix this, by creating a SHARED memory region and placing the data there.

Note that there is a subtlety with how I do this: in CFS, we remove the MEMORY command from these .ld scripts and CFS provides it. Since old CFS projects won't have the SHARED memory region, we would get a link error if we map to that directly. So instead, define a symbol to that address, and map to that address instead. Use an assertion to check the data fits. Then, for old projects, we'll map the variable right to the end of memory if SHARED is not defined, otherwise CFS will provide the symbols with the address of the SHARED region defined there.

Checklist Before Requesting Review

  • PR Title follows correct guidelines.
  • Description of changes and all other relevant information.
  • (Optional) Link any related GitHub issues using a keyword
  • (Optional) Provide info on any relevant functional testing/validation. For API changes or significant features, this is not optional.

@github-actions github-actions Bot added MAX78000 Related to the MAX78000 (AI85) MAX78002 Related to the MAX78002 (AI87) labels Jun 2, 2026
@perkinsmg perkinsmg requested a review from ttmut June 2, 2026 07:23
Comment thread Libraries/CMSIS/Device/Maxim/MAX78002/Source/GCC/max78002_arm.ld
@ttmut ttmut requested a review from petejohanson-adi June 3, 2026 11:50
@perkinsmg perkinsmg force-pushed the fix/really-share-multi-core-data-7800x branch from 84f4169 to 2ca8804 Compare June 4, 2026 13:55
@perkinsmg perkinsmg marked this pull request as draft June 4, 2026 21:24
The .shared section correctly shared data when using _arm/_riscv ld scripts.
But it didn't work when use the max7800x.ld script with RISCV_LOAD=1.
As a result, SystemCoreClock on the RISC-V side got uninitialised values.
This meant that peripheral configuration could compute wrong divisors etc.
Create a SHARED section that is defined for both ARM and RISC-V and place
the .shared section there. I've also moved it to the end of the memory block
to avoid wasting space, but I keep it by default in a location that doesn't
get used for ICC1.

Old CFS projects don't have the SHARED section defined, and replace the
MEMORY command in the ld script with one that doesn't have SHARED.
So we can't map to SHARED directly. Instead, place at the symbol value
and add an assert that the mapped data fits in the region to force an error
if not.
If CFS doesn't provide SHARED, place the data at the very end of the
memory and hope there's no conflict. Note that for multi-core projects,
this location might conflict with ICC1, but old CFS projects would have been
broken anyway so it doesn't matter too much.

Signed-off-by: Michael Perkins <Michael.Perkins@analog.com>
@perkinsmg perkinsmg force-pushed the fix/really-share-multi-core-data-7800x branch from 2ca8804 to 71af644 Compare June 5, 2026 06:38
@perkinsmg perkinsmg marked this pull request as ready for review June 5, 2026 14:51
@petejohanson-adi

Copy link
Copy Markdown
Collaborator

No objections, but might be nice to find someone who's more familiar with the bare metal / MSDK bits to validate as well, since my experience with the linking details is more limited, since our Zephyr integration doesn't use the MSDK linker scripts.

SRAM2 (rwx) : ORIGIN = 0x20010000, LENGTH = 0x0000C000 /* 48kB SRAM2 - RV Data */
SRAM2 (rwx) : ORIGIN = 0x20010000, LENGTH = 0x0000BFF8 /* ~48kB SRAM2 - RV Data */

SHARED (rw) : ORIGIN = 0x2001BFF8, LENGTH = 0x00000008 /* 8B Shared - ARM, RV Data */

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Could use the symbols defined above here, to ensure consistency. (The values here can also be expressions.)

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

Labels

MAX78000 Related to the MAX78000 (AI85) MAX78002 Related to the MAX78002 (AI87)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants