Forum Discussion
Altera_Forum
Honored Contributor
8 years agoNios - II memory alignment issue while accessing integer from non word align location
- Using Nios-II with eclipse. While accessing integer(32 bit) form non word align location getting incorrect value as described in below example. - Tested with eclipse version 13 and 16, both are...
Altera_Forum
Honored Contributor
8 years agoI'm afraid you will have to go through the LUFA code and change all the places where unaligned pointers are used. To help you, you can use the -Wcast-align option in gcc and it will generate a warning each time it thinks an unaligned transfer can happen.
IIRC unaligned transfers trigger a bus error on some ARM architectures also so it's really not good practise when making portable code. GCC for ARM has a -mno-unaligned-access option that will automatically convert unaligned accesses into multiple byte accesses, but unfortunately it doesn't seem that this option is available for the Nios II architecture.