From 8bc2e8aa19d011f5c4ed24eafae84a27659cf234 Mon Sep 17 00:00:00 2001 From: devsaurus Date: Thu, 24 Mar 2016 00:06:09 +0100 Subject: [PATCH 1/2] Enable -std=gnu11 for user dir --- app/platform/flash_api.h | 2 ++ app/user/Makefile | 1 + app/user/user_exceptions.h | 1 + app/user/user_main.c | 3 ++- sdk-overrides/include/osapi.h | 2 ++ 5 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/platform/flash_api.h b/app/platform/flash_api.h index 32475361..20935b2f 100644 --- a/app/platform/flash_api.h +++ b/app/platform/flash_api.h @@ -86,6 +86,8 @@ typedef struct uint32_t segment_size; } ICACHE_STORE_TYPEDEF_ATTR SPIFlashInfo; +SpiFlashOpResult SPIRead(uint32_t src_addr, uint32_t *des_addr, uint32_t size); + uint32_t flash_detect_size_byte(void); uint32_t flash_safe_get_size_byte(void); uint16_t flash_safe_get_sec_num(void); diff --git a/app/user/Makefile b/app/user/Makefile index 3744f4ee..50da583a 100644 --- a/app/user/Makefile +++ b/app/user/Makefile @@ -15,6 +15,7 @@ ifndef PDIR GEN_LIBS = libuser.a endif +STD_CFLAGS=-std=gnu11 -Wimplicit ############################################################# # Configuration i.e. compile options etc. diff --git a/app/user/user_exceptions.h b/app/user/user_exceptions.h index ae9be64e..c1611a21 100644 --- a/app/user/user_exceptions.h +++ b/app/user/user_exceptions.h @@ -3,3 +3,4 @@ #include void load_non_32_wide_handler (struct exception_frame *ef, uint32_t cause) TEXT_SECTION_ATTR; +void __real__xtos_set_exception_handler (uint32_t cause, exception_handler_fn fn); diff --git a/app/user/user_main.c b/app/user/user_main.c index 520a9a1d..d34130a3 100644 --- a/app/user/user_main.c +++ b/app/user/user_main.c @@ -13,6 +13,7 @@ #include "c_string.h" #include "c_stdlib.h" #include "flash_fs.h" +#include "flash_api.h" #include "user_interface.h" #include "user_exceptions.h" #include "user_modules.h" @@ -69,7 +70,7 @@ void TEXT_SECTION_ATTR user_start_trampoline (void) * terse and not as readable as one might like. */ SPIFlashInfo sfi; - SPIRead (0, &sfi, sizeof (sfi)); // Cache read not enabled yet, safe to use + SPIRead (0, (uint32_t *)(&sfi), sizeof (sfi)); // Cache read not enabled yet, safe to use if (sfi.size < 2) // Compensate for out-of-order 4mbit vs 2mbit values sfi.size ^= 1; uint32_t flash_end_addr = (256 * 1024) << sfi.size; diff --git a/sdk-overrides/include/osapi.h b/sdk-overrides/include/osapi.h index 2b98729e..553cd549 100644 --- a/sdk-overrides/include/osapi.h +++ b/sdk-overrides/include/osapi.h @@ -10,6 +10,8 @@ int os_printf_plus(const char *format, ...) __attribute__ ((format (printf, 1, void NmiTimSetFunc(void (*func)(void)); +void call_user_start(void); + #include_next "osapi.h" #endif From 8e11e895f52f89f0f69f19689db5bdb3f4612499 Mon Sep 17 00:00:00 2001 From: devsaurus Date: Thu, 28 Apr 2016 21:26:55 +0200 Subject: [PATCH 2/2] move SPIRead to rom.h --- app/include/rom.h | 3 +++ app/platform/flash_api.h | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/include/rom.h b/app/include/rom.h index 409d2bbe..0a39194e 100644 --- a/app/include/rom.h +++ b/app/include/rom.h @@ -149,4 +149,7 @@ void srand(unsigned int); void uart_div_modify(int no, unsigned int freq); +/* Returns 0 on success, 1 on failure */ +uint8_t SPIRead(uint32_t src_addr, uint32_t *des_addr, uint32_t size); + #endif diff --git a/app/platform/flash_api.h b/app/platform/flash_api.h index 20935b2f..32475361 100644 --- a/app/platform/flash_api.h +++ b/app/platform/flash_api.h @@ -86,8 +86,6 @@ typedef struct uint32_t segment_size; } ICACHE_STORE_TYPEDEF_ATTR SPIFlashInfo; -SpiFlashOpResult SPIRead(uint32_t src_addr, uint32_t *des_addr, uint32_t size); - uint32_t flash_detect_size_byte(void); uint32_t flash_safe_get_size_byte(void); uint16_t flash_safe_get_sec_num(void);