summaryrefslogtreecommitdiffstatshomepage
path: root/stmhal/main.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-09-23 10:59:05 +0100
committerDamien George <damien.p.george@gmail.com>2014-09-23 10:59:05 +0100
commiteaaebf3291a12ff65ca5c7f16e0d486fbde10efa (patch)
treecbfa01bb3b66abb38f367d09754724f19cc64137 /stmhal/main.c
parent2c180f7ccc456e1768fd1cb9a86399808672a237 (diff)
downloadmicropython-eaaebf3291a12ff65ca5c7f16e0d486fbde10efa.tar.gz
micropython-eaaebf3291a12ff65ca5c7f16e0d486fbde10efa.zip
stmhal: Initialise stack pointer correctly.
Stack is full descending and must be 8-byte aligned. It must start off pointing to just above the last byte of RAM. Previously, stack started pointed to last byte of RAM (eg 0x2001ffff) and so was not 8-byte aligned. This caused a bug in combination with alloca. This patch also updates some debug printing code. Addresses issue #872 (among many other undiscovered issues).
Diffstat (limited to 'stmhal/main.c')
-rw-r--r--stmhal/main.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/stmhal/main.c b/stmhal/main.c
index 6aa7b082dd..05b097b7b3 100644
--- a/stmhal/main.c
+++ b/stmhal/main.c
@@ -174,9 +174,9 @@ static const char fresh_readme_txt[] =
int main(void) {
// TODO disable JTAG
- // Stack limit should be less than real stack size, so we
- // had chance to recover from limit hit.
- mp_stack_set_limit(&_ram_end - &_heap_end - 512);
+ // Stack limit should be less than real stack size, so we have a chance
+ // to recover from limit hit. (Limit is measured in bytes.)
+ mp_stack_set_limit((char*)&_ram_end - (char*)&_heap_end - 1024);
/* STM32F4xx HAL library initialization:
- Configure the Flash prefetch, instruction and Data caches