Forum Discussion
Altera_Forum
Honored Contributor
11 years agoNiosII memory reservation
Hello guys,
I have a system running a NiosII processor. In my Qsys system I have connected one port of a dual-port-onchipmem to the Nios data master port and the second port has been exported outside the Qsys so that I'am capable to write data from hw and read it within the NiosII proc. What's happening is that the increase of size of the NiosII software corrupts the data contents of that dual-port-ram (if I comment some portion of code that condition does not happen). So it seems that the niosII is using the dual port ram as an alternative storage device. By the way in the linker script tab of the niosII bsp editor I've set the [.bss ; .entry; .exceptions; .heap; .rodata; .rwdata; .stack; .text] regions to use the dedicated cpu onchip mem only. So I supposed the the NIosII could not use the dual port onchip as it wants to. I'm wrong ?? thank you for help ! Have a nice day !7 Replies
- Altera_Forum
Honored Contributor
No you are not wrong and your understanding is basically correct. So you'll need to debug some more to determine what/why your dual port RAM is being corrupted/affected by NIOS software size. Probably the easiest thing to change (and possibly get different crash symptom) would be to relocate the dual port RAM elsewhere in the address map, not near to where your on-chip memory is located.
- Altera_Forum
Honored Contributor
--- Quote Start --- No you are not wrong and your understanding is basically correct. So you'll need to debug some more to determine what/why your dual port RAM is being corrupted/affected by NIOS software size. Probably the easiest thing to change (and possibly get different crash symptom) would be to relocate the dual port RAM elsewhere in the address map, not near to where your on-chip memory is located. --- Quote End --- Thank you ted. Another possibility is to allocate the dual port ram memory region as a global array of uint8_t for example. So that this region can't be overwritten randomly for some reason. By the way it seems that it's not possible to allocate some memory given the starting address and the vector size. thank you ! - Altera_Forum
Honored Contributor
You don't want to "allocate" the dual port RAM - you most likely just want to refer to it through a pointer set to the corresponding xxx_BASE address that is automatically generated in the system.h file.
Something like:volatile uint8_t *my_dp_ram = (volatile uint8_t *)alt_remap_uncached(MY_DUAL_PORT_RAM_BASE, MY_DUAL_PORT_RAM_SIZE); - Altera_Forum
Honored Contributor
--- Quote Start --- You don't want to "allocate" the dual port RAM - you most likely just want to refer to it through a pointer set to the corresponding xxx_BASE address that is automatically generated in the system.h file. Something like:
--- Quote End --- Yes that is what I intended. Ty so much. I'll try it as soon as I can ! yep !volatile uint8_t *my_dp_ram = (volatile uint8_t *)alt_remap_uncached(MY_DUAL_PORT_RAM_BASE, MY_DUAL_PORT_RAM_SIZE); - Altera_Forum
Honored Contributor
So,
If I try to build the application I get this error on this function:#include <sys/alt_cache.h># include "system.h"# include <stdint.h> volatile uint8_t * dataset_ptr = (volatile uint8_t*) alt_remap_uncached(ONCHIP_DATASET_DP_RAM_BASE,ONCHIP_DATASET_DP_RAM_SIZE_VALUE);
What's wrong with that ?? It seems to be related to some C rules. If I put the alt_remap() into the main routine the error get solved. by the way I would prefer to have the dataset_ptr as a global variable. Is it possible ? Ty, have a nice day !Initializer element is not constant - Altera_Forum
Honored Contributor
Declare dataset_ptr as a global variable, as you have done, but initialize it from main().
e.g.volatile uint8_t * dataset_ptr; void main(void) { dataset_ptr = (volatile uint8_t*) alt_remap_uncached(ONCHIP_DATASET_DP_RAM_BASE,ONCHIP_DATASET_DP_RAM_SIZE_VALUE); } - Altera_Forum
Honored Contributor
--- Quote Start --- Declare dataset_ptr as a global variable, as you have done, but initialize it from main(). e.g.
--- Quote End --- By the way I've seent that in the bsp editor, under settings->advanced->hal, there is an option called "enable runtime stack checking". So it seems that is possibile if there is enaugh free memory at runtime. However I've not find yet a good tutorial/guide that explains clearly how to use this feature. Could someone help me ?? In the meantime I will try your solution. Have a nice day !!volatile uint8_t * dataset_ptr; void main(void) { dataset_ptr = (volatile uint8_t*) alt_remap_uncached(ONCHIP_DATASET_DP_RAM_BASE,ONCHIP_DATASET_DP_RAM_SIZE_VALUE); }