diff --git a/open_esplibs/component.mk b/open_esplibs/component.mk index 26fa5ad..23c8b6a 100644 --- a/open_esplibs/component.mk +++ b/open_esplibs/component.mk @@ -1,11 +1,15 @@ -# Component makefile for "open sdk libs" +# Component makefile for "open Espressif libs" + +INC_DIRS += $(open_esplibs_ROOT)include + +$(eval $(call component_compile_rules,open_esplibs)) # args for passing into compile rule generation -opensdk_libmain_ROOT = $(opensdk_libmain_DEFAULT_ROOT)libmain -opensdk_libmain_INC_DIR = -opensdk_libmain_SRC_DIR = $(opensdk_libmain_ROOT) -opensdk_libmain_EXTRA_SRC_FILES = +open_esplibs_libmain_ROOT = $(open_esplibs_libmain_DEFAULT_ROOT)libmain +open_esplibs_libmain_INC_DIR = +open_esplibs_libmain_SRC_DIR = $(open_esplibs_libmain_ROOT) +open_esplibs_libmain_EXTRA_SRC_FILES = -opensdk_libmain_CFLAGS = $(CFLAGS) +open_esplibs_libmain_CFLAGS = $(CFLAGS) -$(eval $(call component_compile_rules,opensdk_libmain)) +$(eval $(call component_compile_rules,open_esplibs_libmain)) diff --git a/open_esplibs/include/open_esplibs.h b/open_esplibs/include/open_esplibs.h new file mode 100644 index 0000000..5443fef --- /dev/null +++ b/open_esplibs/include/open_esplibs.h @@ -0,0 +1,36 @@ +#ifndef _OPEN_ESPLIBS_H +#define _OPEN_ESPLIBS_H + +// This header includes conditional defines to control which bits of the +// Open-Source libraries get built when building esp-open-rtos. This can be +// useful for quickly troubleshooting whether a bug is due to the +// reimplementation of Espressif libraries, or something else. + +#ifndef OPEN_ESPLIBS +#define OPEN_ESPLIBS 1 +#endif + +#ifndef OPEN_LIBMAIN +#define OPEN_LIBMAIN (OPEN_ESPLIBS) +#endif + +#ifndef OPEN_LIBMAIN_MISC +#define OPEN_LIBMAIN_MISC (OPEN_LIBMAIN) +#endif +#ifndef OPEN_LIBMAIN_OS_CPU_A +#define OPEN_LIBMAIN_OS_CPU_A (OPEN_LIBMAIN) +#endif +#ifndef OPEN_LIBMAIN_SPI_FLASH +#define OPEN_LIBMAIN_SPI_FLASH (OPEN_LIBMAIN) +#endif +#ifndef OPEN_LIBMAIN_TIMERS +#define OPEN_LIBMAIN_TIMERS (OPEN_LIBMAIN) +#endif +#ifndef OPEN_LIBMAIN_UART +#define OPEN_LIBMAIN_UART (OPEN_LIBMAIN) +#endif +#ifndef OPEN_LIBMAIN_XTENSA_CONTEXT +#define OPEN_LIBMAIN_XTENSA_CONTEXT (OPEN_LIBMAIN) +#endif + +#endif /* _OPEN_ESPLIBS_H */ diff --git a/open_esplibs/libmain/misc.c b/open_esplibs/libmain/misc.c index 8973f82..3c1cd02 100644 --- a/open_esplibs/libmain/misc.c +++ b/open_esplibs/libmain/misc.c @@ -1,3 +1,7 @@ +#include "open_esplibs.h" +#if OPEN_LIBMAIN_MISC +// The contents of this file are only built if OPEN_LIBMAIN_MISC is set to true + #include "espressif/esp_misc.h" #include "esp/gpio_regs.h" #include "esp/rtc_regs.h" @@ -57,3 +61,5 @@ uint8_t sdk_rtc_get_reset_reason(void) { RTC.RESET_REASON0 &= ~RTC_RESET_REASON0_BIT21; return reason; } + +#endif /* OPEN_LIBMAIN_MISC */ diff --git a/open_esplibs/libmain/os_cpu_a.c b/open_esplibs/libmain/os_cpu_a.c index 4841ebe..7908b6f 100644 --- a/open_esplibs/libmain/os_cpu_a.c +++ b/open_esplibs/libmain/os_cpu_a.c @@ -1,3 +1,7 @@ +#include "open_esplibs.h" +#if OPEN_LIBMAIN_OS_CPU_A +// The contents of this file are only built if OPEN_LIBMAIN_OS_CPU_A is set to true + #include "esp/types.h" #include "FreeRTOS.h" #include "task.h" @@ -119,3 +123,4 @@ void IRAM sdk__xt_clear_ints(uint32_t mask) { WSR(mask, intclear); } +#endif /* OPEN_LIBMAIN_OS_CPU_A */ diff --git a/open_esplibs/libmain/spi_flash.c b/open_esplibs/libmain/spi_flash.c index 2915c79..ee2d2f4 100644 --- a/open_esplibs/libmain/spi_flash.c +++ b/open_esplibs/libmain/spi_flash.c @@ -1,3 +1,7 @@ +#include "open_esplibs.h" +#if OPEN_LIBMAIN_SPI_FLASH +// The contents of this file are only built if OPEN_LIBMAIN_SPI_FLASH is set to true + #include "FreeRTOS.h" #include "common_macros.h" #include "esp/spi_regs.h" @@ -181,3 +185,4 @@ sdk_SpiFlashOpResult IRAM sdk_spi_flash_read(uint32_t src_addr, uint32_t *des_ad return result; } +#endif /* OPEN_LIBMAIN_SPI_FLASH */ diff --git a/open_esplibs/libmain/timers.c b/open_esplibs/libmain/timers.c index 1e2a920..d460088 100644 --- a/open_esplibs/libmain/timers.c +++ b/open_esplibs/libmain/timers.c @@ -1,3 +1,7 @@ +#include "open_esplibs.h" +#if OPEN_LIBMAIN_TIMERS +// The contents of this file are only built if OPEN_LIBMAIN_TIMERS is set to true + #include "etstimer.h" #include "stdio.h" @@ -88,3 +92,4 @@ void sdk_os_timer_disarm(ETSTimer *ptimer) { } } +#endif /* OPEN_LIBMAIN_TIMERS */ diff --git a/open_esplibs/libmain/uart.c b/open_esplibs/libmain/uart.c index 25ae961..5ee2699 100644 --- a/open_esplibs/libmain/uart.c +++ b/open_esplibs/libmain/uart.c @@ -1,3 +1,7 @@ +#include "open_esplibs.h" +#if OPEN_LIBMAIN_UART +// The contents of this file are only built if OPEN_LIBMAIN_UART is set to true + #include "espressif/sdk_private.h" #include "esp/uart_regs.h" @@ -15,3 +19,4 @@ void sdk_Uart_Init(void) { /* No-Op */ } +#endif /* OPEN_LIBMAIN_UART */ diff --git a/open_esplibs/libmain/xtensa_context.S b/open_esplibs/libmain/xtensa_context.S index 511877e..139d5db 100644 --- a/open_esplibs/libmain/xtensa_context.S +++ b/open_esplibs/libmain/xtensa_context.S @@ -1,3 +1,7 @@ +#include "open_esplibs.h" +#if OPEN_LIBMAIN_XTENSA_CONTEXT +// The contents of this file are only built if OPEN_LIBMAIN_XTENSA_CONTEXT is set to true + .section .iram1.text, "ax", @progbits .balign 4 @@ -39,3 +43,4 @@ sdk__xt_context_restore: l32i a13, sp, 64 ret +#endif /* OPEN_LIBMAIN_XTENSA_CONTEXT */