I have observed an attempted store to an unaligned address in
thread_create that causes a hard_fault.
In thread_create: tcb_address will be aligned on 32-bit boundary but stackp
not. If a threads stack is placed not aligned in memory then
*stackp = (unsignedint)stackp;
causes a hard_fault on cortex-m0.
I can bypass the problem with:
char stack [STACK_SIZE] __attribute__ ((aligned(32)));
I think gcc can't see 32-bit access in thread_create and places stack
unaligned.
thanks for your report of the bug. I just got my cortex-m0 port up and I
stumbled across the exactly same error. I am not quite sure about the
best solution for a fix, but the aligned attribute fixes it at least for
the short term. I'll let you know about my solution once I find one...
there is a useful gcc option -Wcast-align:
"Warn whenever a pointer is cast such that the required alignment of the target
is increased. For example, warn if a char * is cast to an int * on machines
where integers can only be accessed at two- or four-byte boundaries."
-- source gcc-docu