startup: Explicitly enable STKALIGN for all parts.
SCB.CCR.STKALIGN enables the automatic aligning of the stack pointer to 8 bytes on interrupt entry. Per ARM recommendations, and for AAPCS compliance, this bit should be enabled at all times. ARMv6M has this hardcoded to 1. Cortex M3 has this broken in rev 0, optional (default off) in rev 1, and optional (default on) in rev 2 and later. M4(f) has optional (default on) for all revisions, M7 has hardcoded to 1. See Section 2.3.3 in ARM document IHI0046B: http://infocenter.arm.com/help/topic/com.arm.doc.ihi0046b/IHI0046B_ABI_Advisory_1.pdf To ensure that all parts behave correctly, we make sure that we hardcode the feature on, for all parts. While not _required_ for anything other than rev1 cm3, inserting it into the common reset handler ensures no-one gets any surprises. Fixes Github issue #516
This commit is contained in:
parent
4d315288cf
commit
4a21730bb6
|
@ -18,6 +18,7 @@
|
|||
* along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <libopencm3/cm3/scb.h>
|
||||
#include <libopencm3/cm3/vector.h>
|
||||
|
||||
/* load optional platform dependent initialization routines */
|
||||
|
@ -74,6 +75,10 @@ void WEAK __attribute__ ((naked)) reset_handler(void)
|
|||
*dest++ = 0;
|
||||
}
|
||||
|
||||
/* Ensure 8-byte alignment of stack pointer on interrupts */
|
||||
/* Enabled by default on most Cortex-M parts, but not M3 r1 */
|
||||
SCB_CCR |= SCB_CCR_STKALIGN;
|
||||
|
||||
/* might be provided by platform specific vector.c */
|
||||
pre_main();
|
||||
|
||||
|
|
Loading…
Reference in New Issue