From d726f2e6c3524c2ad96b2bdc048aa1eb32bbc960 Mon Sep 17 00:00:00 2001 From: Sergiusz Bazanski <q3k@q3k.org> Date: Sat, 27 Jul 2019 01:45:48 +0200 Subject: [PATCH] epicardium: load l0dable when present, for testing --- epicardium/main.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/epicardium/main.c b/epicardium/main.c index a44f73d8..384ee3db 100644 --- a/epicardium/main.c +++ b/epicardium/main.c @@ -1,6 +1,8 @@ #include <stdio.h> #include <stdlib.h> +#include <ff.h> + #include "max32665.h" #include "uart.h" #include "cdcacm.h" @@ -100,17 +102,28 @@ int main(void) LOG_INFO("startup", "Initializing dispatcher ..."); api_dispatcher_init(); - LOG_INFO("startup", "Testing l0der ..."); - struct l0dable_info info; - int res = l0der_load_path("blinky.elf", &info); - if (res != 0) { - LOG_ERR("startup", "l0der failed: %d\n", res); + /* + * See if there's a l0dable.elf to run. If not, run pycardium. + * This is temporary until epicardium gets a l0dable API from pycardium. + */ + const char *l0dable = "l0dable.elf"; + if (f_stat(l0dable, NULL) == FR_OK) { + LOG_INFO("startup", "Running %s ...", l0dable); + struct l0dable_info info; + int res = l0der_load_path(l0dable, &info); + if (res != 0) { + LOG_ERR("startup", "l0der failed: %d\n", res); + } else { + LOG_INFO("startup", "Starting %s on core1 ...", l0dable); + core1_start(info.isr_vector); + } } else { - LOG_INFO("startup", "Starting core1 payload ..."); - core1_start(info.isr_vector); + LOG_INFO("startup", "Starting pycardium on core1 ..."); + core1_start((void *)0x10080000); } + LOG_INFO("startup", "Starting FreeRTOS ..."); vTaskStartScheduler(); -- GitLab