Replies: 1 comment 2 replies
-
Hey @agamez. Ok, this is a challenging setup as I am no software/C expert at all... 😅 Did you also modify the linker script (adding your new section there)? If not then cropping out the Why do you need a special section for your data? You could also use a "sub-section" of a default section like However, I made some simple tests with a custom section that is not defined in the linker script. It works - surprisingly. #include <neorv32.h>
extern char __crt0_bss_start[];
extern char __crt0_bss_end[];
extern char __crt0_copy_data_dst_begin[];
extern char __crt0_copy_data_dst_end[];
volatile uint32_t var_bss __attribute__((__section__(".bss")));
volatile uint32_t var_data __attribute__((__section__(".data")));
volatile uint32_t var_cust __attribute__((__section__(".custom")));
int main() {
neorv32_rte_setup();
neorv32_uart0_setup(19200, 0);
neorv32_uart0_printf("\n#725\n\n");
neorv32_uart0_printf("DATA start = 0x%x\n", (uint32_t)__crt0_copy_data_dst_begin);
neorv32_uart0_printf("DATA end = 0x%x\n", (uint32_t)__crt0_copy_data_dst_end);
neorv32_uart0_printf("BSS start = 0x%x\n", (uint32_t)__crt0_bss_start);
neorv32_uart0_printf("BSS end = 0x%x\n\n", (uint32_t)__crt0_bss_end);
var_bss = 0xaabbccdd;
neorv32_uart0_printf("&var_bss = 0x%x\n", &var_bss);
neorv32_uart0_printf(" var_bss = 0x%x\n\n", var_bss);
var_data = 0x12345678;
neorv32_uart0_printf("&var_data = 0x%x\n", &var_data);
neorv32_uart0_printf(" var_data = 0x%x\n\n", var_data);
var_cust = 0xffffffff;
neorv32_uart0_printf("&var_cust = 0x%x\n", &var_cust);
neorv32_uart0_printf(" var_cust = 0x%x\n\n", var_cust);
neorv32_uart_printf(NEORV32_UART0, "Program completed.\n");
return 0;
}
As you can see from the program output the new section survived linking and was mapped right between
However, this will not work for pre-initialized variables being mapped to |
Beta Was this translation helpful? Give feedback.
-
Hi!
I'm building a modular system that will communicate through RS232 and will impersonate different interfaces (binary, interactive/human, proprietary ascii commands such as those used in motor controller devices, etc). The idea is to have a small FPGA running neorv32 that can simulate different hardware devices, such as the motor controller I mentioned, but can also switch to an interactive human mode to inspect registers and the like.
To keep the system modular I want to use the custom ELF section strategy and so I have the following code:
I saw that
common.mk
removes all sections beyond .text, .rodata and .data, so I just modified it to include custompersonalities
section:I keep the .bin files so I can inspect personalities.bin:
This matches with the contents of make elf_info output:
So it looks like there exists
struct personality *_personality_personality_machine
poiting topersonality_human
andstruct personality *_personality_personality_human
pointing topersonality_human
which is exactly what the REGISTER_PERSONALITY macro was supposed to do.Now, here lies the problem. I created a couple of #defines to replace neorv32_uart0_printf with simply printf so I can run the exact same code compiled for linux on my PC instead of as a standalone executable, and the code above runs like this on my computer:
If I allow the commented out strcmp line to work, it will find the proper pointer to personality_machine. However, when I run this exact same code on neorv32, this is what I see:
So, for some reason, even of START and STOP pointers do match with the start of
_personality_personality_machine
and end of_personality_personality_machine
andpersonalities.bin
seem to properly point to 0x00002bd0 and 0x00002b2c, when the code is run, it doesn't match at all, so trying to access the .name struct member to execute the strcmp function, it fails with Load access faults or simply doesn't really find the string it's supposed to.I have no doubt this is all due to my tinkering with the object file, but I don't know the reason, because elf_info shows that the personalities section is indeed placed after the ones it already had, so I believe it should've worked:
So this has been the end of my investigation, as I don't know what else should I check/modify to get this working. I'd appreciate any help.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions