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

⚠️ [linker script] simplify memory configuration #375

Merged
merged 7 commits into from
Jul 26, 2022

Conversation

stnolting
Copy link
Owner

@stnolting stnolting commented Jul 25, 2022

This PR changes the default linker script in order to provide a more flexible memory/section/region configuration.

⚠️ The linker script (sw/common/neorv32.ld) now uses variables to define the section sizes and base addresses:

/* Default rom/ram (IMEM/DMEM) sizes */
__neorv32_rom_size = DEFINED(__neorv32_rom_size) ? __neorv32_rom_size : 2048M;
__neorv32_ram_size = DEFINED(__neorv32_ram_size) ? __neorv32_ram_size : 8K;

/* Default HEAP size (= 0; no heap at all) */
__neorv32_heap_size = DEFINED(__neorv32_heap_size) ? __neorv32_heap_size : 0;

/* Default section base addresses - do not change this unless the hardware-defined address space layout is changed! */
__neorv32_rom_base = DEFINED(__neorv32_rom_base) ? __neorv32_rom_base : 0x00000000; /* = VHDL package's "ispace_base_c" */
__neorv32_ram_base = DEFINED(__neorv32_ram_base) ? __neorv32_ram_base : 0x80000000; /* = VHDL package's "dspace_base_c" */

The actual linker script's MEMORY section must not (!!!) be altered any longer.

✨ By having variables for the sizes and base addresses, the setup-specific configuration can be made much simpler by just passing arguments to the application makefile.

Example to set the RAM section (DMEM) to 16kB during invocation of make:

$ make USER_FLAGS+="-Wl,--defsym,__neorv32_rom_size=16k" clean_all exe

This allows to keep to code base clean (no need to change the linker script). All project-related configurations (ISA extensions, optimization, tuning flags, ...) including the memory layout can now be configured by a single project-local makefile of shell script.

@stnolting stnolting added enhancement New feature or request SW Software-related labels Jul 25, 2022
@stnolting stnolting self-assigned this Jul 25, 2022
@stnolting stnolting marked this pull request as ready for review July 25, 2022 16:57
define max heap size via makefile
:warning: define USER_FLAGS in console _before_ invoking make
@stnolting stnolting merged commit 29bb766 into main Jul 26, 2022
@stnolting stnolting deleted the ld_script_rework branch July 26, 2022 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request SW Software-related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant