<Error message:
'onchip_memory' overflowed
If you want to avoid this problem by only using software settings without changing the FPGA design, and if you write code only in C (no C++ language), you can reduce the code size by turning off the check of enable_c_pluse_pluse hal.enable_c_pluse_pluse and then Generate -> Build to reduce code size.
Otherwise, if you do not plan to use printf, use hello_world_small in New Project in the project template to use a limited version of the library and reduce code size.
The option name for BSP in this template is enable_small_library.
If you are using printf, you will need about 64K of RAM. If not, 32KB or less is sufficient.
Even with this configuration, simple string output and hexadecimal display can be done, as shown below, with a prototype in BSP/HAL/sys/alt_stdio.h.
int alt_getchar();
int alt_putchar(int c);
int alt_putstr(const char* str);
void alt_printf(const char *fmt, ...); // hex only, no decimal
Since the code size of the printf family is large, especially if floats are used, small_library is recommended for simple test programs.
To calculate the code size, please refer to the following message displayed at the end of the Console screen after building.
Info: (test.elf) 119 KBytes program size (code + initialized data).
Info: 8824 Bytes free for stack + heap.
Info: Creating test.objdump
nios2-elf- objdump --disassemble --syms --all-header --source test.elf >test.objdump
[test build complete]
--------------------
Category: Nios® II
Tools: Nios® II EDS
Devices: -