From 157f87f01a95a63aa2dc3667e182c09ad5970d17 Mon Sep 17 00:00:00 2001 From: "Sergio R. Caprile" Date: Thu, 18 Apr 2024 17:28:40 -0300 Subject: [PATCH] remove arch autodetection for embedded --- .../device-dashboard/main/mongoose_config.h | 1 + .../micropython/mongoose/mongoose_config.h | 1 - .../esp32/uart-bridge/main/mongoose_config.h | 1 + .../http-client-server/src/main/component.mk | 1 - .../http-client-server/src/main/mongoose.h | 1 + .../src/main/mongoose_config.h | 2 ++ examples/rp2040/pico-rmii/CMakeLists.txt | 5 ----- examples/rp2040/pico-rmii/mongoose_config.h | 5 +++++ .../rp2040/pico-rndis-dashboard/CMakeLists.txt | 7 +------ .../pico-rndis-dashboard/mongoose_config.h | 6 ++++++ .../rp2040/pico-rndis-device/CMakeLists.txt | 5 +---- .../rp2040/pico-rndis-device/mongoose_config.h | 6 ++++++ examples/rp2040/pico-w5500/CMakeLists.txt | 7 +------ examples/rp2040/pico-w5500/mongoose_config.h | 8 ++++++++ examples/zephyr/device-dashboard/CMakeLists.txt | 1 - .../device-dashboard/src/mongoose_config.h | 4 ++++ examples/zephyr/http-client/CMakeLists.txt | 2 -- .../zephyr/http-client/src/mongoose_config.h | 4 ++++ examples/zephyr/http-server/CMakeLists.txt | 1 - .../zephyr/http-server/src/mongoose_config.h | 4 ++++ examples/zephyr/mqtt-aws-client/CMakeLists.txt | 2 -- .../mqtt-aws-client/src/mongoose_config.h | 4 ++++ examples/zephyr/websocket-server/CMakeLists.txt | 2 -- .../websocket-server/src/mongoose_config.h | 4 ++++ mongoose.h | 17 +---------------- src/arch.h | 17 +---------------- 26 files changed, 55 insertions(+), 63 deletions(-) create mode 100644 examples/esp32/device-dashboard/main/mongoose_config.h create mode 100644 examples/esp32/uart-bridge/main/mongoose_config.h create mode 120000 examples/esp8266/http-client-server/src/main/mongoose.h create mode 100644 examples/esp8266/http-client-server/src/main/mongoose_config.h create mode 100644 examples/rp2040/pico-rmii/mongoose_config.h create mode 100644 examples/rp2040/pico-rndis-dashboard/mongoose_config.h create mode 100644 examples/rp2040/pico-rndis-device/mongoose_config.h create mode 100644 examples/rp2040/pico-w5500/mongoose_config.h create mode 100644 examples/zephyr/device-dashboard/src/mongoose_config.h create mode 100644 examples/zephyr/http-client/src/mongoose_config.h create mode 100644 examples/zephyr/http-server/src/mongoose_config.h create mode 100644 examples/zephyr/mqtt-aws-client/src/mongoose_config.h create mode 100644 examples/zephyr/websocket-server/src/mongoose_config.h diff --git a/examples/esp32/device-dashboard/main/mongoose_config.h b/examples/esp32/device-dashboard/main/mongoose_config.h new file mode 100644 index 0000000000..910630d470 --- /dev/null +++ b/examples/esp32/device-dashboard/main/mongoose_config.h @@ -0,0 +1 @@ +#define MG_ARCH MG_ARCH_ESP32 diff --git a/examples/esp32/micropython/mongoose/mongoose_config.h b/examples/esp32/micropython/mongoose/mongoose_config.h index d5b597a6c1..910630d470 100644 --- a/examples/esp32/micropython/mongoose/mongoose_config.h +++ b/examples/esp32/micropython/mongoose/mongoose_config.h @@ -1,2 +1 @@ -// For some reason, IDF detection at build time does not work here #define MG_ARCH MG_ARCH_ESP32 diff --git a/examples/esp32/uart-bridge/main/mongoose_config.h b/examples/esp32/uart-bridge/main/mongoose_config.h new file mode 100644 index 0000000000..910630d470 --- /dev/null +++ b/examples/esp32/uart-bridge/main/mongoose_config.h @@ -0,0 +1 @@ +#define MG_ARCH MG_ARCH_ESP32 diff --git a/examples/esp8266/http-client-server/src/main/component.mk b/examples/esp8266/http-client-server/src/main/component.mk index 511c3470ee..cc264afa3e 100644 --- a/examples/esp8266/http-client-server/src/main/component.mk +++ b/examples/esp8266/http-client-server/src/main/component.mk @@ -7,4 +7,3 @@ # please read the ESP-IDF documents if you need to do this. # -COMPONENT_INCLUDES += ../../../../../.. diff --git a/examples/esp8266/http-client-server/src/main/mongoose.h b/examples/esp8266/http-client-server/src/main/mongoose.h new file mode 120000 index 0000000000..4cd6a2b4ca --- /dev/null +++ b/examples/esp8266/http-client-server/src/main/mongoose.h @@ -0,0 +1 @@ +../../../../../mongoose.h \ No newline at end of file diff --git a/examples/esp8266/http-client-server/src/main/mongoose_config.h b/examples/esp8266/http-client-server/src/main/mongoose_config.h new file mode 100644 index 0000000000..e659bf6026 --- /dev/null +++ b/examples/esp8266/http-client-server/src/main/mongoose_config.h @@ -0,0 +1,2 @@ +#define MG_ARCH MG_ARCH_ESP8266 + diff --git a/examples/rp2040/pico-rmii/CMakeLists.txt b/examples/rp2040/pico-rmii/CMakeLists.txt index b45c77fd6f..05df73022f 100644 --- a/examples/rp2040/pico-rmii/CMakeLists.txt +++ b/examples/rp2040/pico-rmii/CMakeLists.txt @@ -17,8 +17,3 @@ pico_add_extra_outputs(firmware) # create map/bin/hex file etc. pico_enable_stdio_usb(firmware 1) # Route stdio pico_enable_stdio_uart(firmware 0) # to USB - -# Mongoose build flags -add_definitions(-DMG_ENABLE_TCPIP=1) -add_definitions(-DMG_ENABLE_TCPIP_DRIVER_INIT=0) -add_definitions(-DMG_ENABLE_PACKED_FS=1) diff --git a/examples/rp2040/pico-rmii/mongoose_config.h b/examples/rp2040/pico-rmii/mongoose_config.h new file mode 100644 index 0000000000..25ac94af06 --- /dev/null +++ b/examples/rp2040/pico-rmii/mongoose_config.h @@ -0,0 +1,5 @@ +#define MG_ARCH MG_ARCH_RP2040 + +#define MG_ENABLE_TCPIP 1 +#define MG_ENABLE_TCPIP_DRIVER_INIT 0 +#define MG_ENABLE_PACKED_FS 1 diff --git a/examples/rp2040/pico-rndis-dashboard/CMakeLists.txt b/examples/rp2040/pico-rndis-dashboard/CMakeLists.txt index 8a7c0b67d3..d2cdb555bc 100644 --- a/examples/rp2040/pico-rndis-dashboard/CMakeLists.txt +++ b/examples/rp2040/pico-rndis-dashboard/CMakeLists.txt @@ -23,12 +23,7 @@ pico_add_extra_outputs(firmware) # create map/bin/hex file etc. pico_enable_stdio_usb(firmware 0) # Route stdio pico_enable_stdio_uart(firmware 1) # to the UART -# Mongoose build flags -add_definitions(-DMG_ENABLE_TCPIP=1) -add_definitions(-DMG_ENABLE_PACKED_FS=1) -add_definitions(-DMG_ENABLE_TCPIP_DRIVER_INIT=0) -add_definitions(-DMG_ENABLE_POSIX_FS=0) -add_definitions(-DDISABLE_ROUTING=1) +# Mongoose build flags in mongoose_config.h # Example build options add_definitions(-DHTTP_URL="http://0.0.0.0/") diff --git a/examples/rp2040/pico-rndis-dashboard/mongoose_config.h b/examples/rp2040/pico-rndis-dashboard/mongoose_config.h new file mode 100644 index 0000000000..85fdf38882 --- /dev/null +++ b/examples/rp2040/pico-rndis-dashboard/mongoose_config.h @@ -0,0 +1,6 @@ +#define MG_ARCH MG_ARCH_RP2040 + +#define MG_ENABLE_TCPIP 1 +#define MG_ENABLE_TCPIP_DRIVER_INIT 0 +#define MG_ENABLE_PACKED_FS 1 +#define MG_ENABLE_POSIX_FS 0 diff --git a/examples/rp2040/pico-rndis-device/CMakeLists.txt b/examples/rp2040/pico-rndis-device/CMakeLists.txt index 88631158b6..b3fc0ebf76 100644 --- a/examples/rp2040/pico-rndis-device/CMakeLists.txt +++ b/examples/rp2040/pico-rndis-device/CMakeLists.txt @@ -21,9 +21,6 @@ pico_add_extra_outputs(firmware) # create map/bin/hex file etc. pico_enable_stdio_usb(firmware 0) # Route stdio pico_enable_stdio_uart(firmware 1) # to the UART -# Mongoose build flags -add_definitions(-DMG_ENABLE_TCPIP=1) -add_definitions(-DMG_ENABLE_TCPIP_DRIVER_INIT=0) -add_definitions(-DMG_ENABLE_POSIX_FS=0) +# Mongoose build flags in mongoose_config.h # Example build options diff --git a/examples/rp2040/pico-rndis-device/mongoose_config.h b/examples/rp2040/pico-rndis-device/mongoose_config.h new file mode 100644 index 0000000000..85fdf38882 --- /dev/null +++ b/examples/rp2040/pico-rndis-device/mongoose_config.h @@ -0,0 +1,6 @@ +#define MG_ARCH MG_ARCH_RP2040 + +#define MG_ENABLE_TCPIP 1 +#define MG_ENABLE_TCPIP_DRIVER_INIT 0 +#define MG_ENABLE_PACKED_FS 1 +#define MG_ENABLE_POSIX_FS 0 diff --git a/examples/rp2040/pico-w5500/CMakeLists.txt b/examples/rp2040/pico-w5500/CMakeLists.txt index ea693c8b76..d2fe3a5059 100644 --- a/examples/rp2040/pico-w5500/CMakeLists.txt +++ b/examples/rp2040/pico-w5500/CMakeLists.txt @@ -12,12 +12,7 @@ pico_add_extra_outputs(firmware) # create map/bin/hex file etc. pico_enable_stdio_usb(firmware 0) # Route stdio pico_enable_stdio_uart(firmware 1) # to the UART, for remote testing -# Mongoose build flags -add_definitions(-DMG_ENABLE_TCPIP=1) -add_definitions(-DMG_ENABLE_DRIVER_W5500=1) -add_definitions(-DMG_ENABLE_PACKED_FS=1) -add_definitions(-DMG_ENABLE_CUSTOM_RANDOM=1) -add_definitions(-DMG_ENABLE_POSIX_FS=0) +# Mongoose build flags in mongoose_config.h # Example build options add_definitions(-DHTTP_URL="http://0.0.0.0/") diff --git a/examples/rp2040/pico-w5500/mongoose_config.h b/examples/rp2040/pico-w5500/mongoose_config.h new file mode 100644 index 0000000000..122f28578b --- /dev/null +++ b/examples/rp2040/pico-w5500/mongoose_config.h @@ -0,0 +1,8 @@ +#define MG_ARCH MG_ARCH_RP2040 + +#define MG_ENABLE_TCPIP 1 +#define MG_ENABLE_TCPIP_DRIVER_INIT 0 +#define MG_ENABLE_DRIVER_W5500 1 +#define MG_ENABLE_CUSTOM_RANDOM 1 +#define MG_ENABLE_PACKED_FS 1 +#define MG_ENABLE_POSIX_FS 0 diff --git a/examples/zephyr/device-dashboard/CMakeLists.txt b/examples/zephyr/device-dashboard/CMakeLists.txt index 6027c10c4f..883369e942 100644 --- a/examples/zephyr/device-dashboard/CMakeLists.txt +++ b/examples/zephyr/device-dashboard/CMakeLists.txt @@ -6,5 +6,4 @@ cmake_minimum_required(VERSION 3.20.0) find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) project(device_dashboard) -add_definitions(-DMG_ENABLE_PACKED_FS=1) target_sources(app PRIVATE src/main.c src/mongoose.c src/net.c src/packed_fs.c) diff --git a/examples/zephyr/device-dashboard/src/mongoose_config.h b/examples/zephyr/device-dashboard/src/mongoose_config.h new file mode 100644 index 0000000000..bc04f8a4d5 --- /dev/null +++ b/examples/zephyr/device-dashboard/src/mongoose_config.h @@ -0,0 +1,4 @@ +#define MG_ARCH MG_ARCH_ZEPHYR + +#define MG_ENABLE_PACKED_FS 1 +#define MG_TLS MG_TLS_MBED diff --git a/examples/zephyr/http-client/CMakeLists.txt b/examples/zephyr/http-client/CMakeLists.txt index 75174f0e3f..797ed4e803 100644 --- a/examples/zephyr/http-client/CMakeLists.txt +++ b/examples/zephyr/http-client/CMakeLists.txt @@ -6,6 +6,4 @@ cmake_minimum_required(VERSION 3.20.0) find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) project(http_client) -#add_definitions(-DMG_ENABLE_LINES=1) -add_definitions(-DMG_TLS=MG_TLS_MBED -DMG_MBEDTLS_DEBUG_LEVEL=4) target_sources(app PRIVATE src/main.c src/mongoose.c) diff --git a/examples/zephyr/http-client/src/mongoose_config.h b/examples/zephyr/http-client/src/mongoose_config.h new file mode 100644 index 0000000000..bc04f8a4d5 --- /dev/null +++ b/examples/zephyr/http-client/src/mongoose_config.h @@ -0,0 +1,4 @@ +#define MG_ARCH MG_ARCH_ZEPHYR + +#define MG_ENABLE_PACKED_FS 1 +#define MG_TLS MG_TLS_MBED diff --git a/examples/zephyr/http-server/CMakeLists.txt b/examples/zephyr/http-server/CMakeLists.txt index 312d514ace..595d6c96ca 100644 --- a/examples/zephyr/http-server/CMakeLists.txt +++ b/examples/zephyr/http-server/CMakeLists.txt @@ -6,5 +6,4 @@ cmake_minimum_required(VERSION 3.20.0) find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) project(http_server) -add_definitions(-DMG_TLS=MG_TLS_MBED) target_sources(app PRIVATE src/main.c src/mongoose.c) diff --git a/examples/zephyr/http-server/src/mongoose_config.h b/examples/zephyr/http-server/src/mongoose_config.h new file mode 100644 index 0000000000..bc04f8a4d5 --- /dev/null +++ b/examples/zephyr/http-server/src/mongoose_config.h @@ -0,0 +1,4 @@ +#define MG_ARCH MG_ARCH_ZEPHYR + +#define MG_ENABLE_PACKED_FS 1 +#define MG_TLS MG_TLS_MBED diff --git a/examples/zephyr/mqtt-aws-client/CMakeLists.txt b/examples/zephyr/mqtt-aws-client/CMakeLists.txt index f9cf91ae9d..1bf83b5ff5 100644 --- a/examples/zephyr/mqtt-aws-client/CMakeLists.txt +++ b/examples/zephyr/mqtt-aws-client/CMakeLists.txt @@ -6,6 +6,4 @@ cmake_minimum_required(VERSION 3.20.0) find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) project(mqtt_aws_client) -#add_definitions(-DMG_ENABLE_LINES=1) -add_definitions(-DMG_TLS=MG_TLS_MBED -DMG_MBEDTLS_DEBUG_LEVEL=4) target_sources(app PRIVATE src/main.c src/mongoose.c) diff --git a/examples/zephyr/mqtt-aws-client/src/mongoose_config.h b/examples/zephyr/mqtt-aws-client/src/mongoose_config.h new file mode 100644 index 0000000000..bc04f8a4d5 --- /dev/null +++ b/examples/zephyr/mqtt-aws-client/src/mongoose_config.h @@ -0,0 +1,4 @@ +#define MG_ARCH MG_ARCH_ZEPHYR + +#define MG_ENABLE_PACKED_FS 1 +#define MG_TLS MG_TLS_MBED diff --git a/examples/zephyr/websocket-server/CMakeLists.txt b/examples/zephyr/websocket-server/CMakeLists.txt index 317f8bb588..1d14a96355 100644 --- a/examples/zephyr/websocket-server/CMakeLists.txt +++ b/examples/zephyr/websocket-server/CMakeLists.txt @@ -6,6 +6,4 @@ cmake_minimum_required(VERSION 3.20.0) find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) project(websocket_server) -#add_definitions(-DMG_ENABLE_LINES=1) -add_definitions(-DMG_TLS=MG_TLS_MBED) target_sources(app PRIVATE src/main.c src/mongoose.c) diff --git a/examples/zephyr/websocket-server/src/mongoose_config.h b/examples/zephyr/websocket-server/src/mongoose_config.h new file mode 100644 index 0000000000..bc04f8a4d5 --- /dev/null +++ b/examples/zephyr/websocket-server/src/mongoose_config.h @@ -0,0 +1,4 @@ +#define MG_ARCH MG_ARCH_ZEPHYR + +#define MG_ENABLE_PACKED_FS 1 +#define MG_TLS MG_TLS_MBED diff --git a/mongoose.h b/mongoose.h index 1cbfb414ea..2011b7644f 100644 --- a/mongoose.h +++ b/mongoose.h @@ -48,21 +48,6 @@ extern "C" { #define MG_ARCH MG_ARCH_UNIX #elif defined(_WIN32) #define MG_ARCH MG_ARCH_WIN32 -#elif defined(ICACHE_FLASH) || defined(ICACHE_RAM_ATTR) -#define MG_ARCH MG_ARCH_ESP8266 -#elif defined(__ZEPHYR__) -#define MG_ARCH MG_ARCH_ZEPHYR -#elif defined(ESP_PLATFORM) -#define MG_ARCH MG_ARCH_ESP32 -#elif defined(FREERTOS_IP_H) -#define MG_ARCH MG_ARCH_FREERTOS -#define MG_ENABLE_FREERTOS_TCP 1 -#elif defined(AZURE_RTOS_THREADX) -#define MG_ARCH MG_ARCH_AZURERTOS -#elif defined(PICO_TARGET_NAME) -#define MG_ARCH MG_ARCH_RP2040 -#elif defined(__RTTHREAD__) -#define MG_ARCH MG_ARCH_RTTHREAD #endif #endif // !defined(MG_ARCH) @@ -71,7 +56,7 @@ extern "C" { #endif #if !defined(MG_ARCH) -#error "MG_ARCH is not specified and we couldn't guess it. Set -D MG_ARCH=..." +#error "MG_ARCH is not specified and we couldn't guess it. Define MG_ARCH=... in your compiler" #endif // http://esr.ibiblio.org/?p=5095 diff --git a/src/arch.h b/src/arch.h index ac0282901e..f01ca6bb6a 100644 --- a/src/arch.h +++ b/src/arch.h @@ -21,21 +21,6 @@ #define MG_ARCH MG_ARCH_UNIX #elif defined(_WIN32) #define MG_ARCH MG_ARCH_WIN32 -#elif defined(ICACHE_FLASH) || defined(ICACHE_RAM_ATTR) -#define MG_ARCH MG_ARCH_ESP8266 -#elif defined(__ZEPHYR__) -#define MG_ARCH MG_ARCH_ZEPHYR -#elif defined(ESP_PLATFORM) -#define MG_ARCH MG_ARCH_ESP32 -#elif defined(FREERTOS_IP_H) -#define MG_ARCH MG_ARCH_FREERTOS -#define MG_ENABLE_FREERTOS_TCP 1 -#elif defined(AZURE_RTOS_THREADX) -#define MG_ARCH MG_ARCH_AZURERTOS -#elif defined(PICO_TARGET_NAME) -#define MG_ARCH MG_ARCH_RP2040 -#elif defined(__RTTHREAD__) -#define MG_ARCH MG_ARCH_RTTHREAD #endif #endif // !defined(MG_ARCH) @@ -44,7 +29,7 @@ #endif #if !defined(MG_ARCH) -#error "MG_ARCH is not specified and we couldn't guess it. Set -D MG_ARCH=..." +#error "MG_ARCH is not specified and we couldn't guess it. Define MG_ARCH=... in your compiler" #endif // http://esr.ibiblio.org/?p=5095