summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsrc/main.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/main.c b/src/main.c
index 816aa96..0e93eb6 100755
--- a/src/main.c
+++ b/src/main.c
@@ -19,12 +19,18 @@
#include "os/os.h"
#include "bsp/bsp.h"
#include "hal/hal_gpio.h"
+#include "hal/hal_flash.h"
+#include "hal/flash_map.h"
#include <assert.h>
#include <string.h>
#ifdef ARCH_sim
#include <mcu/mcu_sim.h>
#endif
+#define BOOT_IMG_MAGIC 0x12344321
+/* We could calculate this also, but for now let's do like this */
+#define BOOT_IMAGE_TRAILER_ADDR 0x0007BFF8
+
/* Init all tasks */
volatile int tasks_initialized;
int init_tasks(void);
@@ -36,6 +42,7 @@ int init_tasks(void);
struct os_task blinky_task;
os_stack_t blinky_stack[BLINKY_STACK_SIZE];
static volatile int g_task1_loops;
+static volatile int bit __attribute__ ((section (".bit"))) __attribute__ ((__used__));
/* For LED toggling */
int g_led_pin;
@@ -55,7 +62,7 @@ blinky_task_handler(void *arg)
++g_task1_loops;
/* Wait one second */
- os_time_delay(1000);
+ os_time_delay(200);
/* Toggle the LED */
hal_gpio_toggle(g_led_pin);
@@ -94,6 +101,8 @@ int
main(int argc, char **argv)
{
int rc;
+ uint32_t boot_magic = BOOT_IMG_MAGIC;
+
#ifdef ARCH_sim
mcu_sim_parse_args(argc, argv);
@@ -102,6 +111,7 @@ main(int argc, char **argv)
os_init();
rc = init_tasks();
+ hal_flash_write(0, BOOT_IMAGE_TRAILER_ADDR, &boot_magic, sizeof(boot_magic));
os_start();
/* os start should never return. If it does, this should be an error */