diff --git a/Makefile b/Makefile index ef51d690794..b532f99f750 100644 --- a/Makefile +++ b/Makefile @@ -78,13 +78,6 @@ test/packed_fs.c: Makefile src/ssi.h test/fuzz.c test/data/a.txt $(CC) $(CFLAGS) test/pack.c -o pack $(RUN) ./pack Makefile src/ssi.h test/fuzz.c test/data/a.txt test/data/range.txt > $@ -DIR ?= test/data -OUT ?= packed_fs.c -mkfs: - $(CC) $(CFLAGS) test/pack.c -o pack - $(RUN) ./pack -s $(DIR) `find $(DIR) -type f` > $(OUT) -# find $(DIR) -type f | sed -e s,^$(DIR),,g -e s,^/,,g - # Check that all external (exported) symbols have "mg_" prefix mg_prefix: mongoose.c mongoose.h $(CC) mongoose.c $(CFLAGS) -c -o /tmp/x.o && nm /tmp/x.o | grep ' T ' | grep -v 'mg_' ; test $$? = 1 @@ -165,17 +158,26 @@ arduino: ENV = -v $(CWD)/arduino:/root arduino: curl -sL http://downloads.arduino.cc/arduino-1.8.19-linux64.tar.xz | unxz | tar -xf - mv arduino-* $@ + +arduino-xiao-board: $(DOCKER) mdashnet/cc2 ./arduino/arduino --pref "boardsmanager.additional.urls=https://files.seeedstudio.com/arduino/package_seeeduino_boards_index.json" --save-prefs $(DOCKER) mdashnet/cc2 ./arduino/arduino --pref "compiler.warning_level=all" --save-prefs $(DOCKER) mdashnet/cc2 ./arduino/arduino --install-boards Seeeduino:samd arduino-xiao: ENV = -v $(CWD)/arduino:/root -arduino-xiao: arduino +arduino-xiao: arduino arduino-xiao-board rm -rf tmp; mkdir tmp cp examples/arduino/w5500/w5500.ino tmp/tmp.ino cp mongoose.c mongoose.h examples/arduino/w5500/mongoose_custom.h tmp/ $(DOCKER) mdashnet/cc2 ./arduino/arduino --verbose --verify --board Seeeduino:samd:seeed_XIAO_m0 tmp/tmp.ino +arduino-nano: ENV = -v $(CWD)/arduino:/root +arduino-nano: arduino + rm -rf tmp; mkdir tmp + cp examples/arduino/w5500/w5500.ino tmp/tmp.ino + cp mongoose.c mongoose.h examples/arduino/w5500/mongoose_custom.h tmp/ + $(DOCKER) mdashnet/cc2 ./arduino/arduino --verbose --verify --board arduino:avr:nano tmp/tmp.ino + mingw++: Makefile mongoose.h $(SRCS) $(DOCKER) mdashnet/mingw x86_64-w64-mingw32-g++ $(SRCS) -W -Wall -Werror -I. $(DEFS) -lwsock32 -o $@.exe diff --git a/examples/arduino/w5500/mongoose_custom.h b/examples/arduino/w5500/mongoose_custom.h index aee5dfc06ce..550cba6ca98 100644 --- a/examples/arduino/w5500/mongoose_custom.h +++ b/examples/arduino/w5500/mongoose_custom.h @@ -11,4 +11,6 @@ #define MG_ENABLE_SOCKET 0 #define MG_ENABLE_TCPIP 1 #define mkdir(a, b) (-1) +#define MG_IO_SIZE 128 +#define MG_ENABLE_DRIVER_STM32 0 //#define MG_ENABLE_LOG 0 diff --git a/examples/stm32/nucleo-f429zi-cube-baremetal/Core/Inc/mongoose_custom.h b/examples/stm32/nucleo-f429zi-cube-baremetal/Core/Inc/mongoose_custom.h index 0c7a28d59cb..d8355cb6733 100644 --- a/examples/stm32/nucleo-f429zi-cube-baremetal/Core/Inc/mongoose_custom.h +++ b/examples/stm32/nucleo-f429zi-cube-baremetal/Core/Inc/mongoose_custom.h @@ -8,20 +8,16 @@ #endif #define MG_ENABLE_PACKED_FS 1 - #define MG_ENABLE_CUSTOM_MILLIS 1 - #define MG_ENABLE_MBEDTLS 0 - #define MG_ARCH MG_STMPACK_ARCH - #define MG_STMPACK_NET 0 - #define MG_ENABLE_CUSTOM_RANDOM 1 // Translate to Mongoose macros #if MG_CMSISPACK_NET == 0 #define MG_ENABLE_TCPIP 1 +#define MG_ENABLE_DRIVER_STM32 1 #elif MG_CMSISPACK_NET == 1 #define MG_ENABLE_LWIP 1 #elif MG_CMSISPACK_NET == 2 diff --git a/examples/stm32/nucleo-f429zi-cube-freertos-lwip/Core/Inc/mongoose_custom.h b/examples/stm32/nucleo-f429zi-cube-freertos-lwip/Core/Inc/mongoose_custom.h index 3fb26f33434..96a2532dd93 100644 --- a/examples/stm32/nucleo-f429zi-cube-freertos-lwip/Core/Inc/mongoose_custom.h +++ b/examples/stm32/nucleo-f429zi-cube-freertos-lwip/Core/Inc/mongoose_custom.h @@ -8,20 +8,16 @@ #endif #define MG_ENABLE_PACKED_FS 1 - #define MG_ENABLE_CUSTOM_MILLIS 0 - #define MG_ENABLE_MBEDTLS 0 - #define MG_ARCH MG_ARCH_FREERTOS - #define MG_STMPACK_NET 1 - #define MG_ENABLE_CUSTOM_RANDOM 1 // Translate to Mongoose macros #if MG_STMPACK_NET == 0 #define MG_ENABLE_TCPIP 1 +#define MG_ENABLE_DRIVER_STM32 1 #elif MG_STMPACK_NET == 1 #define MG_ENABLE_LWIP 1 #elif MG_STMPACK_NET == 2 diff --git a/examples/stm32/nucleo-f429zi-cube-freertos/Core/Inc/mongoose_custom.h b/examples/stm32/nucleo-f429zi-cube-freertos/Core/Inc/mongoose_custom.h index d104a91bec5..d9b2f8c7003 100644 --- a/examples/stm32/nucleo-f429zi-cube-freertos/Core/Inc/mongoose_custom.h +++ b/examples/stm32/nucleo-f429zi-cube-freertos/Core/Inc/mongoose_custom.h @@ -8,20 +8,16 @@ #endif #define MG_ENABLE_PACKED_FS 1 - #define MG_ENABLE_CUSTOM_MILLIS 0 - #define MG_ENABLE_MBEDTLS 0 - #define MG_ARCH MG_ARCH_CMSIS_RTOS2 - #define MG_STMPACK_NET 0 - #define MG_ENABLE_CUSTOM_RANDOM 1 // Translate to Mongoose macros #if MG_STMPACK_NET == 0 #define MG_ENABLE_TCPIP 1 +#define MG_ENABLE_DRIVER_STM32 1 #elif MG_STMPACK_NET == 1 #define MG_ENABLE_LWIP 1 #elif MG_STMPACK_NET == 2 diff --git a/examples/stm32/nucleo-f429zi-freertos/Makefile b/examples/stm32/nucleo-f429zi-freertos/Makefile index 87f204bccda..0fd2cdf84b1 100644 --- a/examples/stm32/nucleo-f429zi-freertos/Makefile +++ b/examples/stm32/nucleo-f429zi-freertos/Makefile @@ -15,7 +15,7 @@ CFLAGS += -IFreeRTOS-Kernel/include CFLAGS += -IFreeRTOS-Kernel/portable/GCC/ARM_CM4F -Wno-conversion SOURCES += mongoose.c net.c packed_fs.c -CFLAGS += $(CFLAGS_EXTRA) # Mongoose options are defined in mongoose_custom.h +CFLAGS += -DMG_ENABLE_DRIVER_STM32=1 $(CFLAGS_EXTRA) # Mongoose options are defined in mongoose_custom.h # Example specific build options. See README.md CFLAGS += -DHTTP_URL=\"http://0.0.0.0/\" diff --git a/examples/stm32/nucleo-f429zi-freertos/mongoose_custom.h b/examples/stm32/nucleo-f429zi-freertos/mongoose_custom.h index 6f0df4ff308..22def7938c4 100644 --- a/examples/stm32/nucleo-f429zi-freertos/mongoose_custom.h +++ b/examples/stm32/nucleo-f429zi-freertos/mongoose_custom.h @@ -3,6 +3,7 @@ // See https://mongoose.ws/documentation/#build-options #define MG_ARCH MG_ARCH_FREERTOS #define MG_ENABLE_TCPIP 1 +#define MG_ENABLE_DRIVER_STM32 1 #define MG_IO_SIZE 256 #define MG_ENABLE_CUSTOM_RANDOM 1 #define MG_ENABLE_PACKED_FS 1 diff --git a/examples/stm32/nucleo-f429zi-make-baremetal-builtin/Makefile b/examples/stm32/nucleo-f429zi-make-baremetal-builtin/Makefile index 213971abcb3..607f68e6208 100644 --- a/examples/stm32/nucleo-f429zi-make-baremetal-builtin/Makefile +++ b/examples/stm32/nucleo-f429zi-make-baremetal-builtin/Makefile @@ -11,7 +11,7 @@ SOURCES += cmsis_f4/Source/Templates/gcc/startup_stm32f429xx.s # ST startup file # Mongoose-specific source code files and build options. See https://mongoose.ws/documentation/#build-options SOURCES += mongoose.c net.c packed_fs.c CFLAGS += -DMG_ENABLE_TCPIP=1 -DMG_ARCH=MG_ARCH_NEWLIB -DMG_ENABLE_CUSTOM_MILLIS=1 -CFLAGS += -DMG_ENABLE_CUSTOM_RANDOM=1 -DMG_ENABLE_PACKED_FS=1 $(CFLAGS_EXTRA) +CFLAGS += -DMG_ENABLE_CUSTOM_RANDOM=1 -DMG_ENABLE_PACKED_FS=1 -DMG_ENABLE_DRIVER_STM32=1 $(CFLAGS_EXTRA) # Example specific build options. See README.md CFLAGS += -DHTTP_URL=\"http://0.0.0.0/\" diff --git a/examples/stm32/nucleo-f429zi-rndis/Makefile b/examples/stm32/nucleo-f429zi-rndis/Makefile index 157f2688baf..f6531fb152d 100644 --- a/examples/stm32/nucleo-f429zi-rndis/Makefile +++ b/examples/stm32/nucleo-f429zi-rndis/Makefile @@ -25,7 +25,7 @@ CFLAGS += -Wno-conversion -Wno-sign-conversion # Mongoose-specific. See https://mongoose.ws/documentation/#build-options SOURCES += mongoose.c CFLAGS += -DMG_ENABLE_TCPIP=1 -DMG_ARCH=MG_ARCH_NEWLIB -DMG_ENABLE_CUSTOM_MILLIS=1 -CFLAGS += -DMG_ENABLE_CUSTOM_RANDOM=1 -DMG_IO_SIZE=512 $(CFLAGS_EXTRA) +CFLAGS += -DMG_ENABLE_CUSTOM_RANDOM=1 -DMG_IO_SIZE=512 -DMG_ENABLE_DRIVER_STM32=1 $(CFLAGS_EXTRA) ifeq ($(OS),Windows_NT) RM = cmd /C del /Q /F /S diff --git a/examples/stm32/nucleo-f746zg-cube-baremetal/Core/Inc/mongoose_custom.h b/examples/stm32/nucleo-f746zg-cube-baremetal/Core/Inc/mongoose_custom.h index 0c7a28d59cb..d8355cb6733 100644 --- a/examples/stm32/nucleo-f746zg-cube-baremetal/Core/Inc/mongoose_custom.h +++ b/examples/stm32/nucleo-f746zg-cube-baremetal/Core/Inc/mongoose_custom.h @@ -8,20 +8,16 @@ #endif #define MG_ENABLE_PACKED_FS 1 - #define MG_ENABLE_CUSTOM_MILLIS 1 - #define MG_ENABLE_MBEDTLS 0 - #define MG_ARCH MG_STMPACK_ARCH - #define MG_STMPACK_NET 0 - #define MG_ENABLE_CUSTOM_RANDOM 1 // Translate to Mongoose macros #if MG_CMSISPACK_NET == 0 #define MG_ENABLE_TCPIP 1 +#define MG_ENABLE_DRIVER_STM32 1 #elif MG_CMSISPACK_NET == 1 #define MG_ENABLE_LWIP 1 #elif MG_CMSISPACK_NET == 2 diff --git a/examples/stm32/nucleo-f746zg-cube-freertos-lwip/Core/Inc/mongoose_custom.h b/examples/stm32/nucleo-f746zg-cube-freertos-lwip/Core/Inc/mongoose_custom.h index 3fb26f33434..96a2532dd93 100644 --- a/examples/stm32/nucleo-f746zg-cube-freertos-lwip/Core/Inc/mongoose_custom.h +++ b/examples/stm32/nucleo-f746zg-cube-freertos-lwip/Core/Inc/mongoose_custom.h @@ -8,20 +8,16 @@ #endif #define MG_ENABLE_PACKED_FS 1 - #define MG_ENABLE_CUSTOM_MILLIS 0 - #define MG_ENABLE_MBEDTLS 0 - #define MG_ARCH MG_ARCH_FREERTOS - #define MG_STMPACK_NET 1 - #define MG_ENABLE_CUSTOM_RANDOM 1 // Translate to Mongoose macros #if MG_STMPACK_NET == 0 #define MG_ENABLE_TCPIP 1 +#define MG_ENABLE_DRIVER_STM32 1 #elif MG_STMPACK_NET == 1 #define MG_ENABLE_LWIP 1 #elif MG_STMPACK_NET == 2 diff --git a/examples/stm32/nucleo-f746zg-cube-freertos/Core/Inc/mongoose_custom.h b/examples/stm32/nucleo-f746zg-cube-freertos/Core/Inc/mongoose_custom.h index d104a91bec5..d9b2f8c7003 100644 --- a/examples/stm32/nucleo-f746zg-cube-freertos/Core/Inc/mongoose_custom.h +++ b/examples/stm32/nucleo-f746zg-cube-freertos/Core/Inc/mongoose_custom.h @@ -8,20 +8,16 @@ #endif #define MG_ENABLE_PACKED_FS 1 - #define MG_ENABLE_CUSTOM_MILLIS 0 - #define MG_ENABLE_MBEDTLS 0 - #define MG_ARCH MG_ARCH_CMSIS_RTOS2 - #define MG_STMPACK_NET 0 - #define MG_ENABLE_CUSTOM_RANDOM 1 // Translate to Mongoose macros #if MG_STMPACK_NET == 0 #define MG_ENABLE_TCPIP 1 +#define MG_ENABLE_DRIVER_STM32 1 #elif MG_STMPACK_NET == 1 #define MG_ENABLE_LWIP 1 #elif MG_STMPACK_NET == 2 diff --git a/examples/stm32/nucleo-f746zg-freertos-tcp/Makefile b/examples/stm32/nucleo-f746zg-freertos-tcp/Makefile index 98f49536596..99d700955bd 100644 --- a/examples/stm32/nucleo-f746zg-freertos-tcp/Makefile +++ b/examples/stm32/nucleo-f746zg-freertos-tcp/Makefile @@ -29,7 +29,7 @@ CFLAGS += -DSTM32F7xx -Wno-unused-parameter CFLAGS += -DSTM32F746xx -Wno-sign-compare -Wno-undef -Wno-shadow -Wno-array-bounds -Wno-error SOURCES += mongoose.c net.c packed_fs.c -CFLAGS += $(CFLAGS_EXTRA) # Mongoose options are defined in mongoose_custom.h +CFLAGS += -DMG_ENABLE_DRIVER_STM32=1 $(CFLAGS_EXTRA) # Mongoose options are defined in mongoose_custom.h # Example specific build options. See README.md CFLAGS += -DHTTP_URL=\"http://0.0.0.0/\" diff --git a/examples/stm32/nucleo-f746zg-freertos-tcp/mongoose_custom.h b/examples/stm32/nucleo-f746zg-freertos-tcp/mongoose_custom.h index 08e7eff913f..047eb45036e 100644 --- a/examples/stm32/nucleo-f746zg-freertos-tcp/mongoose_custom.h +++ b/examples/stm32/nucleo-f746zg-freertos-tcp/mongoose_custom.h @@ -3,6 +3,7 @@ // See https://mongoose.ws/documentation/#build-options #define MG_ARCH MG_ARCH_FREERTOS #define MG_ENABLE_FREERTOS_TCP 1 +#define MG_ENABLE_DRIVER_STM32 1 #define MG_ENABLE_CUSTOM_RANDOM 1 #define MG_ENABLE_PACKED_FS 1 diff --git a/examples/stm32/nucleo-f746zg-freertos/Makefile b/examples/stm32/nucleo-f746zg-freertos/Makefile index cb817dab404..f3bbc911912 100644 --- a/examples/stm32/nucleo-f746zg-freertos/Makefile +++ b/examples/stm32/nucleo-f746zg-freertos/Makefile @@ -15,7 +15,7 @@ CFLAGS += -IFreeRTOS-Kernel/include CFLAGS += -IFreeRTOS-Kernel/portable/GCC/ARM_CM7/r0p1 -Wno-conversion SOURCES += mongoose.c net.c packed_fs.c -CFLAGS += $(CFLAGS_EXTRA) # Mongoose options are defined in mongoose_custom.h +CFLAGS += -DMG_ENABLE_DRIVER_STM32=1 $(CFLAGS_EXTRA) # Mongoose options are defined in mongoose_custom.h # Example specific build options. See README.md CFLAGS += -DHTTP_URL=\"http://0.0.0.0/\" diff --git a/examples/stm32/nucleo-f746zg-freertos/mongoose_custom.h b/examples/stm32/nucleo-f746zg-freertos/mongoose_custom.h index 6f0df4ff308..22def7938c4 100644 --- a/examples/stm32/nucleo-f746zg-freertos/mongoose_custom.h +++ b/examples/stm32/nucleo-f746zg-freertos/mongoose_custom.h @@ -3,6 +3,7 @@ // See https://mongoose.ws/documentation/#build-options #define MG_ARCH MG_ARCH_FREERTOS #define MG_ENABLE_TCPIP 1 +#define MG_ENABLE_DRIVER_STM32 1 #define MG_IO_SIZE 256 #define MG_ENABLE_CUSTOM_RANDOM 1 #define MG_ENABLE_PACKED_FS 1 diff --git a/examples/stm32/nucleo-f746zg-keil-baremetal/mongoose_custom.h b/examples/stm32/nucleo-f746zg-keil-baremetal/mongoose_custom.h index 9ca06da81cb..2a4a222fd6c 100644 --- a/examples/stm32/nucleo-f746zg-keil-baremetal/mongoose_custom.h +++ b/examples/stm32/nucleo-f746zg-keil-baremetal/mongoose_custom.h @@ -65,6 +65,7 @@ #endif #if MG_CMSISPACK_NET == 0 #define MG_ENABLE_TCPIP 1 +#define MG_ENABLE_DRIVER_STM32 1 #elif MG_CMSISPACK_NET == 1 #define MG_ENABLE_LWIP 1 #elif MG_CMSISPACK_NET == 2 diff --git a/examples/stm32/nucleo-f746zg-keil-freertos-lwip/mongoose_custom.h b/examples/stm32/nucleo-f746zg-keil-freertos-lwip/mongoose_custom.h index a036f806015..f9cea591f12 100644 --- a/examples/stm32/nucleo-f746zg-keil-freertos-lwip/mongoose_custom.h +++ b/examples/stm32/nucleo-f746zg-keil-freertos-lwip/mongoose_custom.h @@ -65,6 +65,7 @@ #endif #if MG_CMSISPACK_NET == 0 #define MG_ENABLE_TCPIP 1 +#define MG_ENABLE_DRIVER_STM32 1 #elif MG_CMSISPACK_NET == 1 #define MG_ENABLE_LWIP 1 #elif MG_CMSISPACK_NET == 2 diff --git a/examples/stm32/nucleo-f746zg-keil-freertos-tcp/mongoose_custom.h b/examples/stm32/nucleo-f746zg-keil-freertos-tcp/mongoose_custom.h index e3e00c7a453..2efd9df3a33 100644 --- a/examples/stm32/nucleo-f746zg-keil-freertos-tcp/mongoose_custom.h +++ b/examples/stm32/nucleo-f746zg-keil-freertos-tcp/mongoose_custom.h @@ -65,6 +65,7 @@ #endif #if MG_CMSISPACK_NET == 0 #define MG_ENABLE_TCPIP 1 +#define MG_ENABLE_DRIVER_STM32 1 #elif MG_CMSISPACK_NET == 1 #define MG_ENABLE_LWIP 1 #elif MG_CMSISPACK_NET == 2 diff --git a/examples/stm32/nucleo-f746zg-keil-freertos/mongoose_custom.h b/examples/stm32/nucleo-f746zg-keil-freertos/mongoose_custom.h index 6726972594d..b361b5fe070 100644 --- a/examples/stm32/nucleo-f746zg-keil-freertos/mongoose_custom.h +++ b/examples/stm32/nucleo-f746zg-keil-freertos/mongoose_custom.h @@ -65,6 +65,7 @@ #endif #if MG_CMSISPACK_NET == 0 #define MG_ENABLE_TCPIP 1 +#define MG_ENABLE_DRIVER_STM32 1 #elif MG_CMSISPACK_NET == 1 #define MG_ENABLE_LWIP 1 #elif MG_CMSISPACK_NET == 2 diff --git a/examples/stm32/nucleo-f746zg-keil-freertos_cmsis2-lwip/mongoose_custom.h b/examples/stm32/nucleo-f746zg-keil-freertos_cmsis2-lwip/mongoose_custom.h index a415a6d0e51..b3b39123259 100644 --- a/examples/stm32/nucleo-f746zg-keil-freertos_cmsis2-lwip/mongoose_custom.h +++ b/examples/stm32/nucleo-f746zg-keil-freertos_cmsis2-lwip/mongoose_custom.h @@ -65,6 +65,7 @@ #endif #if MG_CMSISPACK_NET == 0 #define MG_ENABLE_TCPIP 1 +#define MG_ENABLE_DRIVER_STM32 1 #elif MG_CMSISPACK_NET == 1 #define MG_ENABLE_LWIP 1 #elif MG_CMSISPACK_NET == 2 diff --git a/examples/stm32/nucleo-f746zg-keil-freertos_cmsis2/mongoose_custom.h b/examples/stm32/nucleo-f746zg-keil-freertos_cmsis2/mongoose_custom.h index 6e5c4ceae43..6b538531731 100644 --- a/examples/stm32/nucleo-f746zg-keil-freertos_cmsis2/mongoose_custom.h +++ b/examples/stm32/nucleo-f746zg-keil-freertos_cmsis2/mongoose_custom.h @@ -65,6 +65,7 @@ #endif #if MG_CMSISPACK_NET == 0 #define MG_ENABLE_TCPIP 1 +#define MG_ENABLE_DRIVER_STM32 1 #elif MG_CMSISPACK_NET == 1 #define MG_ENABLE_LWIP 1 #elif MG_CMSISPACK_NET == 2 diff --git a/examples/stm32/nucleo-f746zg-keil-rtx-mdk/mongoose_custom.h b/examples/stm32/nucleo-f746zg-keil-rtx-mdk/mongoose_custom.h index 503f0c22edd..a6e40a6cea7 100644 --- a/examples/stm32/nucleo-f746zg-keil-rtx-mdk/mongoose_custom.h +++ b/examples/stm32/nucleo-f746zg-keil-rtx-mdk/mongoose_custom.h @@ -65,6 +65,7 @@ #endif #if MG_CMSISPACK_NET == 0 #define MG_ENABLE_TCPIP 1 +#define MG_ENABLE_DRIVER_STM32 1 #elif MG_CMSISPACK_NET == 1 #define MG_ENABLE_LWIP 1 #elif MG_CMSISPACK_NET == 2 diff --git a/examples/stm32/nucleo-f746zg-keil-rtx/mongoose_custom.h b/examples/stm32/nucleo-f746zg-keil-rtx/mongoose_custom.h index 2934901382a..20f795645c6 100644 --- a/examples/stm32/nucleo-f746zg-keil-rtx/mongoose_custom.h +++ b/examples/stm32/nucleo-f746zg-keil-rtx/mongoose_custom.h @@ -65,6 +65,7 @@ #endif #if MG_CMSISPACK_NET == 0 #define MG_ENABLE_TCPIP 1 +#define MG_ENABLE_DRIVER_STM32 1 #elif MG_CMSISPACK_NET == 1 #define MG_ENABLE_LWIP 1 #elif MG_CMSISPACK_NET == 2 diff --git a/examples/stm32/nucleo-f746zg-keil-rtx5-lwip/mongoose_custom.h b/examples/stm32/nucleo-f746zg-keil-rtx5-lwip/mongoose_custom.h index a415a6d0e51..b3b39123259 100644 --- a/examples/stm32/nucleo-f746zg-keil-rtx5-lwip/mongoose_custom.h +++ b/examples/stm32/nucleo-f746zg-keil-rtx5-lwip/mongoose_custom.h @@ -65,6 +65,7 @@ #endif #if MG_CMSISPACK_NET == 0 #define MG_ENABLE_TCPIP 1 +#define MG_ENABLE_DRIVER_STM32 1 #elif MG_CMSISPACK_NET == 1 #define MG_ENABLE_LWIP 1 #elif MG_CMSISPACK_NET == 2 diff --git a/examples/stm32/nucleo-f746zg-keil-rtx5-mdk/mongoose_custom.h b/examples/stm32/nucleo-f746zg-keil-rtx5-mdk/mongoose_custom.h index cfecebebd86..292eda1c633 100644 --- a/examples/stm32/nucleo-f746zg-keil-rtx5-mdk/mongoose_custom.h +++ b/examples/stm32/nucleo-f746zg-keil-rtx5-mdk/mongoose_custom.h @@ -65,6 +65,7 @@ #endif #if MG_CMSISPACK_NET == 0 #define MG_ENABLE_TCPIP 1 +#define MG_ENABLE_DRIVER_STM32 1 #elif MG_CMSISPACK_NET == 1 #define MG_ENABLE_LWIP 1 #elif MG_CMSISPACK_NET == 2 diff --git a/examples/stm32/nucleo-f746zg-keil-rtx5/mongoose_custom.h b/examples/stm32/nucleo-f746zg-keil-rtx5/mongoose_custom.h index c02b5ff2b9f..1ebd7fbd85a 100644 --- a/examples/stm32/nucleo-f746zg-keil-rtx5/mongoose_custom.h +++ b/examples/stm32/nucleo-f746zg-keil-rtx5/mongoose_custom.h @@ -65,6 +65,7 @@ #endif #if MG_CMSISPACK_NET == 0 #define MG_ENABLE_TCPIP 1 +#define MG_ENABLE_DRIVER_STM32 1 #elif MG_CMSISPACK_NET == 1 #define MG_ENABLE_LWIP 1 #elif MG_CMSISPACK_NET == 2 diff --git a/examples/stm32/nucleo-f746zg-make-baremetal-builtin/Makefile b/examples/stm32/nucleo-f746zg-make-baremetal-builtin/Makefile index 36726779d55..043605845b2 100644 --- a/examples/stm32/nucleo-f746zg-make-baremetal-builtin/Makefile +++ b/examples/stm32/nucleo-f746zg-make-baremetal-builtin/Makefile @@ -11,7 +11,7 @@ SOURCES += cmsis_f7/Source/Templates/gcc/startup_stm32f746xx.s # ST startup file # Mongoose-specific. See https://mongoose.ws/documentation/#build-options SOURCES += mongoose.c net.c packed_fs.c CFLAGS += -DMG_ENABLE_TCPIP=1 -DMG_ARCH=MG_ARCH_NEWLIB -DMG_ENABLE_CUSTOM_MILLIS=1 -CFLAGS += -DMG_ENABLE_CUSTOM_RANDOM=1 -DMG_ENABLE_PACKED_FS=1 $(CFLAGS_EXTRA) +CFLAGS += -DMG_ENABLE_CUSTOM_RANDOM=1 -DMG_ENABLE_PACKED_FS=1 -DMG_ENABLE_DRIVER_STM32=1 $(CFLAGS_EXTRA) # Example specific build options. See README.md CFLAGS += -DHTTP_URL=\"http://0.0.0.0/\" -DHTTPS_URL=\"https://0.0.0.0/\" diff --git a/examples/stm32/nucleo-f746zg-rndis/Makefile b/examples/stm32/nucleo-f746zg-rndis/Makefile index 5730053cd28..8f25ac9ebba 100644 --- a/examples/stm32/nucleo-f746zg-rndis/Makefile +++ b/examples/stm32/nucleo-f746zg-rndis/Makefile @@ -25,7 +25,7 @@ CFLAGS += -Wno-conversion -Wno-sign-conversion # Mongoose-specific. See https://mongoose.ws/documentation/#build-options SOURCES += mongoose.c CFLAGS += -DMG_ENABLE_TCPIP=1 -DMG_ARCH=MG_ARCH_NEWLIB -DMG_ENABLE_CUSTOM_MILLIS=1 -CFLAGS += -DMG_ENABLE_CUSTOM_RANDOM=1 -DMG_IO_SIZE=512 $(CFLAGS_EXTRA) +CFLAGS += -DMG_ENABLE_CUSTOM_RANDOM=1 -DMG_IO_SIZE=512 -DMG_ENABLE_DRIVER_STM32=1 $(CFLAGS_EXTRA) ifeq ($(OS),Windows_NT) RM = cmd /C del /Q /F /S diff --git a/examples/stm32/nucleo-h743zi-cube-baremetal/Core/Inc/mongoose_custom.h b/examples/stm32/nucleo-h743zi-cube-baremetal/Core/Inc/mongoose_custom.h index 0c7a28d59cb..d8355cb6733 100644 --- a/examples/stm32/nucleo-h743zi-cube-baremetal/Core/Inc/mongoose_custom.h +++ b/examples/stm32/nucleo-h743zi-cube-baremetal/Core/Inc/mongoose_custom.h @@ -8,20 +8,16 @@ #endif #define MG_ENABLE_PACKED_FS 1 - #define MG_ENABLE_CUSTOM_MILLIS 1 - #define MG_ENABLE_MBEDTLS 0 - #define MG_ARCH MG_STMPACK_ARCH - #define MG_STMPACK_NET 0 - #define MG_ENABLE_CUSTOM_RANDOM 1 // Translate to Mongoose macros #if MG_CMSISPACK_NET == 0 #define MG_ENABLE_TCPIP 1 +#define MG_ENABLE_DRIVER_STM32 1 #elif MG_CMSISPACK_NET == 1 #define MG_ENABLE_LWIP 1 #elif MG_CMSISPACK_NET == 2 diff --git a/examples/stm32/nucleo-h743zi-cube-freertos/Core/Inc/mongoose_custom.h b/examples/stm32/nucleo-h743zi-cube-freertos/Core/Inc/mongoose_custom.h index d104a91bec5..d9b2f8c7003 100644 --- a/examples/stm32/nucleo-h743zi-cube-freertos/Core/Inc/mongoose_custom.h +++ b/examples/stm32/nucleo-h743zi-cube-freertos/Core/Inc/mongoose_custom.h @@ -8,20 +8,16 @@ #endif #define MG_ENABLE_PACKED_FS 1 - #define MG_ENABLE_CUSTOM_MILLIS 0 - #define MG_ENABLE_MBEDTLS 0 - #define MG_ARCH MG_ARCH_CMSIS_RTOS2 - #define MG_STMPACK_NET 0 - #define MG_ENABLE_CUSTOM_RANDOM 1 // Translate to Mongoose macros #if MG_STMPACK_NET == 0 #define MG_ENABLE_TCPIP 1 +#define MG_ENABLE_DRIVER_STM32 1 #elif MG_STMPACK_NET == 1 #define MG_ENABLE_LWIP 1 #elif MG_STMPACK_NET == 2 diff --git a/examples/stm32/nucleo-h743zi-make-baremetal-builtin/Makefile b/examples/stm32/nucleo-h743zi-make-baremetal-builtin/Makefile index 25f6d308e02..3d621962e50 100644 --- a/examples/stm32/nucleo-h743zi-make-baremetal-builtin/Makefile +++ b/examples/stm32/nucleo-h743zi-make-baremetal-builtin/Makefile @@ -12,7 +12,7 @@ SOURCES += cmsis_h7/Source/Templates/gcc/startup_stm32h743xx.s # ST startup file SOURCES += mongoose.c net.c packed_fs.c CFLAGS += -DMG_ENABLE_TCPIP=1 -DMG_ARCH=MG_ARCH_NEWLIB -DMG_ENABLE_PACKED_FS=1 CFLAGS += -DMG_ENABLE_CUSTOM_RANDOM=1 -DMG_ENABLE_CUSTOM_MILLIS=1 -CFLAGS += -DMG_ENABLE_DRIVER_STM32H=1 $(CFLAGS_EXTRA) +CFLAGS += -DMG_ENABLE_DRIVER_STM32H=1 -DMG_ENABLE_DRIVER_STM32=1 $(CFLAGS_EXTRA) # Example specific build options. See README.md CFLAGS += -DHTTP_URL=\"http://0.0.0.0/\" diff --git a/mongoose.c b/mongoose.c index 7cbb4f8bd59..0148f269486 100644 --- a/mongoose.c +++ b/mongoose.c @@ -6702,7 +6702,7 @@ struct mg_tcpip_driver mg_tcpip_driver_imxrt1020 = { #endif -#if MG_ENABLE_TCPIP && MG_ENABLE_DRIVER_STM32 +#if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_STM32) && MG_ENABLE_DRIVER_STM32 struct stm32_eth { volatile uint32_t MACCR, MACFFR, MACHTHR, MACHTLR, MACMIIAR, MACMIIDR, MACFCR, MACVLANTR, RESERVED0[2], MACRWUFFR, MACPMTCSR, RESERVED1, MACDBGR, MACSR, @@ -8144,8 +8144,9 @@ static void read_conn(struct mg_connection *c, struct pkt *pkt) { uint32_t rem_ip; memcpy(&rem_ip, c->rem.ip, sizeof(uint32_t)); MG_DEBUG(("SEQ != ACK: %x %x %x", seq, s->ack, ack)); - tx_tcp((struct mg_tcpip_if *) c->mgr->priv, s->mac, rem_ip, TH_ACK, c->loc.port, - c->rem.port, mg_htonl(s->seq), mg_htonl(s->ack), "", 0); + tx_tcp((struct mg_tcpip_if *) c->mgr->priv, s->mac, rem_ip, TH_ACK, + c->loc.port, c->rem.port, mg_htonl(s->seq), mg_htonl(s->ack), "", + 0); } } else if (io->size - io->len < pkt->pay.len && !mg_iobuf_resize(io, io->len + pkt->pay.len)) { @@ -8371,7 +8372,7 @@ static void mg_tcpip_poll(struct mg_tcpip_if *ifp, uint64_t uptime_ms) { if (ifp->now >= ifp->lease_expire) { ifp->state = MG_TCPIP_STATE_UP, ifp->ip = 0; // expired, release IP onstatechange(ifp); - } else if (ifp->now + 30 * 60 * 1000 > ifp->lease_expire && + } else if (ifp->now + 30UL * 60UL * 1000UL > ifp->lease_expire && ((ifp->now / 1000) % 60) == 0) { // hack: 30 min before deadline, try to rebind (4.3.6) every min tx_dhcp_request_re(ifp, (uint8_t *) broadcast, ifp->ip, 0xffffffff); diff --git a/mongoose.h b/mongoose.h index e8d84f218df..92ea0fbab47 100644 --- a/mongoose.h +++ b/mongoose.h @@ -755,7 +755,7 @@ struct timeval { #endif #ifndef MG_MAX_RECV_SIZE -#define MG_MAX_RECV_SIZE (3 * 1024 * 1024) // Maximum recv IO buffer size +#define MG_MAX_RECV_SIZE (3UL * 1024UL * 1024UL) // Maximum recv IO buffer size #endif #ifndef MG_DATA_SIZE @@ -1630,7 +1630,7 @@ void mg_rpc_list(struct mg_rpc_req *r); -struct mg_tcpip_if; // MIP network interface +struct mg_tcpip_if; // Mongoose TCP/IP network interface struct mg_tcpip_driver { bool (*init)(struct mg_tcpip_if *); // Init driver @@ -1646,8 +1646,8 @@ struct mg_tcpip_if { struct mg_str tx; // Output (TX) buffer bool enable_dhcp_client; // Enable DCHP client bool enable_dhcp_server; // Enable DCHP server - bool enable_crc32_check; // Do a CRC check on rx frames and strip it - bool enable_mac_check; // Do a MAC check on rx frames + bool enable_crc32_check; // Do a CRC check on RX frames and strip it + bool enable_mac_check; // Do a MAC check on RX frames struct mg_tcpip_driver *driver; // Low level driver void *driver_data; // Driver-specific data struct mg_mgr *mgr; // Mongoose event manager @@ -1687,12 +1687,6 @@ struct mg_tcpip_spi { void (*end)(void *); // SPI end: slave select high uint8_t (*txn)(void *, uint8_t); // SPI transaction: write 1 byte, read reply }; - -#if !defined(MG_ENABLE_DRIVER_STM32H) && !defined(MG_ENABLE_DRIVER_TM4C) -#define MG_ENABLE_DRIVER_STM32 1 -#else -#define MG_ENABLE_DRIVER_STM32 0 -#endif #endif diff --git a/src/config.h b/src/config.h index 80012f4707d..7a99eb9c1e5 100644 --- a/src/config.h +++ b/src/config.h @@ -90,7 +90,7 @@ #endif #ifndef MG_MAX_RECV_SIZE -#define MG_MAX_RECV_SIZE (3 * 1024 * 1024) // Maximum recv IO buffer size +#define MG_MAX_RECV_SIZE (3UL * 1024UL * 1024UL) // Maximum recv IO buffer size #endif #ifndef MG_DATA_SIZE diff --git a/src/tcpip/driver_stm32.c b/src/tcpip/driver_stm32.c index 4135cb8b788..3a216ed9c76 100644 --- a/src/tcpip/driver_stm32.c +++ b/src/tcpip/driver_stm32.c @@ -1,6 +1,6 @@ #include "tcpip.h" -#if MG_ENABLE_TCPIP && MG_ENABLE_DRIVER_STM32 +#if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_STM32) && MG_ENABLE_DRIVER_STM32 struct stm32_eth { volatile uint32_t MACCR, MACFFR, MACHTHR, MACHTLR, MACMIIAR, MACMIIDR, MACFCR, MACVLANTR, RESERVED0[2], MACRWUFFR, MACPMTCSR, RESERVED1, MACDBGR, MACSR, diff --git a/src/tcpip/tcpip.c b/src/tcpip/tcpip.c index f96b8597307..c500709da10 100644 --- a/src/tcpip/tcpip.c +++ b/src/tcpip/tcpip.c @@ -582,8 +582,9 @@ static void read_conn(struct mg_connection *c, struct pkt *pkt) { uint32_t rem_ip; memcpy(&rem_ip, c->rem.ip, sizeof(uint32_t)); MG_DEBUG(("SEQ != ACK: %x %x %x", seq, s->ack, ack)); - tx_tcp((struct mg_tcpip_if *) c->mgr->priv, s->mac, rem_ip, TH_ACK, c->loc.port, - c->rem.port, mg_htonl(s->seq), mg_htonl(s->ack), "", 0); + tx_tcp((struct mg_tcpip_if *) c->mgr->priv, s->mac, rem_ip, TH_ACK, + c->loc.port, c->rem.port, mg_htonl(s->seq), mg_htonl(s->ack), "", + 0); } } else if (io->size - io->len < pkt->pay.len && !mg_iobuf_resize(io, io->len + pkt->pay.len)) { @@ -809,7 +810,7 @@ static void mg_tcpip_poll(struct mg_tcpip_if *ifp, uint64_t uptime_ms) { if (ifp->now >= ifp->lease_expire) { ifp->state = MG_TCPIP_STATE_UP, ifp->ip = 0; // expired, release IP onstatechange(ifp); - } else if (ifp->now + 30 * 60 * 1000 > ifp->lease_expire && + } else if (ifp->now + 30UL * 60UL * 1000UL > ifp->lease_expire && ((ifp->now / 1000) % 60) == 0) { // hack: 30 min before deadline, try to rebind (4.3.6) every min tx_dhcp_request_re(ifp, (uint8_t *) broadcast, ifp->ip, 0xffffffff); diff --git a/src/tcpip/tcpip.h b/src/tcpip/tcpip.h index 93780ac6468..c7aed96418f 100644 --- a/src/tcpip/tcpip.h +++ b/src/tcpip/tcpip.h @@ -5,7 +5,7 @@ #include "net.h" #include "queue.h" -struct mg_tcpip_if; // MIP network interface +struct mg_tcpip_if; // Mongoose TCP/IP network interface struct mg_tcpip_driver { bool (*init)(struct mg_tcpip_if *); // Init driver @@ -21,8 +21,8 @@ struct mg_tcpip_if { struct mg_str tx; // Output (TX) buffer bool enable_dhcp_client; // Enable DCHP client bool enable_dhcp_server; // Enable DCHP server - bool enable_crc32_check; // Do a CRC check on rx frames and strip it - bool enable_mac_check; // Do a MAC check on rx frames + bool enable_crc32_check; // Do a CRC check on RX frames and strip it + bool enable_mac_check; // Do a MAC check on RX frames struct mg_tcpip_driver *driver; // Low level driver void *driver_data; // Driver-specific data struct mg_mgr *mgr; // Mongoose event manager @@ -62,10 +62,4 @@ struct mg_tcpip_spi { void (*end)(void *); // SPI end: slave select high uint8_t (*txn)(void *, uint8_t); // SPI transaction: write 1 byte, read reply }; - -#if !defined(MG_ENABLE_DRIVER_STM32H) && !defined(MG_ENABLE_DRIVER_TM4C) -#define MG_ENABLE_DRIVER_STM32 1 -#else -#define MG_ENABLE_DRIVER_STM32 0 -#endif #endif