From baa4f009aab081dae0fae14bc8a156951a5c0dd4 Mon Sep 17 00:00:00 2001 From: mikee47 Date: Thu, 25 Apr 2019 17:16:08 +0100 Subject: [PATCH 01/22] Initial restructure to support multiple platforms Rearrange files and fix #includes * `Platform` -> `Platform/Esp8266/Platform` * Create `Platform/Common` for shared headers and code * `custom_heap` -> `Platform/Esp8266/System/components/custom_heap` * `compiler` -> `Platform/Esp8266/Compiler` * `appspecific/ * `tools` -> `Platform/Esp8266/Tools` * Esp8266-specific modules from `SmingCore` -> `Platform/Esp2866/Core' * `SmingCore/Network/rBootHttpUpdate*` -> `Platform/Esp2866/Core/Network` * Fix gdb paths - use `gdb/` for always-build, `gdbstub/` for internal * Rename `system` directory to `System` Create Esp8266 system components and group with related submodules * Move Esp8266-specific files from `system` into `Platform/Esp8266/System/components/esp8266` * `appinit/user_main.cpp` -> `Platform/Esp8266/System/components/esp8266/startup.cpp` * `gdb` -> `Platform/Esp8266/System/components/gdbstub` * `appspecific/gdb` -> `Platform/Esp8266/System/components/gdbstub/appcode` * `Services/FATFS` -> `Platform/Esp8266/System/components/fatfs` * third-party libraries: `rBoot`, `new-pwm`, `axtls-8266`, `umm_malloc`, `esp-open-lwip`, `lwip2` * Move `.patch` file moved into submodule parent directory * `system/include/rboot-integration.h`, `appspecific/rboot/overrides.c` -> `Platform/Esp8266/System/components/rboot/appcode` * `Services/SpifFS` -> `Platform/Esp8266/System/components/spiffs` Makefile revisions * Remove `Makefile-project.mk` * Rename `Makefile-rboot.mk` -> `Makefile-app.mk`, but retain `Makefile-rboot.mk` for backward compatibility * Move common environment setup into `build.mk` and add platform-specific directory definitions * Move common target creation code into `modules.mk` * Put ESP8266-specific script into `Platform/Esp8266/` makefiles: `build.mk`, `sming.mk`, `app.mk` and `flash.mk` * Pull related variable definitions and rules together in makefiles * Define macros to replace repetitive script * Ignore errors in all clean operations * Use `TOOLS`, `TOOLS_CLEAN` and `CLEAN` variables containing pre-requisites for `tools`, `tools-clean` and `clean` targets * Remove `include` directory, move `user_config.h` into `Platform/$PLATFORM/System` folder * Distribute PHONY declarations * Add `PLATFORM_TOOLS` path, adjust locations for memanalyzer in host makefiles * Simplify user library building by adding to `LIBS`, each library gets an additional shorthand make target e.g. `make axtls`. * Add `SUBMODULES` variable to identify submodule directories - they're now not all in third-party directory * Use `.submodule` file to simplify reloading * Make `ARDUINO_LIBRARIES` a public variable to optionally restrict which libraries get loaded and built Add `building.md` Fixes: * Add `libpwm_open` to `CUSTOM_TARGETS` so it builds with framework Bugs found: * Testing with `ENABLE_CUSTOM_LWIP=0` fails because of static definitions in `mem_manager.h` - also happens with existing build --- .gitmodules | 38 +- Sming/Libraries/SDCard/SDCard.cpp | 2 +- Sming/Makefile | 626 +++++----------- Sming/Makefile-app.mk | 79 ++ Sming/Makefile-bsd.mk | 2 +- Sming/Makefile-linux.mk | 2 +- Sming/Makefile-macos.mk | 2 +- Sming/Makefile-project.mk | 602 --------------- Sming/Makefile-rboot.mk | 707 +----------------- Sming/Makefile-windows.mk | 2 +- .../Common}/Platform/AccessPoint.h | 0 .../Common}/Platform/OsMessageInterceptor.cpp | 2 +- .../Common}/Platform/OsMessageInterceptor.h | 0 .../Common}/Platform/RTC.h | 2 +- .../Common}/Platform/Station.h | 0 .../Common}/Platform/System.h | 0 .../Common}/Platform/WDT.h | 0 .../Common}/Platform/WifiEvents.h | 6 +- .../Common}/Platform/WifiSniffer.h | 0 .../Esp8266/Compiler}/data/blankfs.bin | 0 .../Esp8266/Compiler}/ld/common.ld | 0 .../Esp8266/Compiler}/ld/rboot.rom0.ld | 0 .../Esp8266/Compiler}/ld/standalone.rom.ld | 0 .../Esp8266/Compiler}/lib/.gitignore | 0 .../Esp8266/Compiler}/lib/libmicroc.a | Bin .../Esp8266/Compiler}/lib/libmicrogcc.a | Bin .../Esp8266/Core}/Clock.cpp | 0 .../Esp8266/Core}/Digital.cpp | 1 + .../Esp8266/Core}/ESP8266EX.cpp | 0 .../Esp8266/Core}/ESP8266EX.h | 0 .../Esp8266/Core}/HardwarePWM.cpp | 1 + .../Esp8266/Core}/HardwareSerial.cpp | 2 +- .../Esp8266/Core}/HardwareTimer.cpp | 0 .../Esp8266/Core}/Interrupts.cpp | 2 +- .../Esp8266/Core}/Network/rBootHttpUpdate.cpp | 0 .../Esp8266/Core}/Network/rBootHttpUpdate.h | 2 +- .../Esp8266/Core}/SPI.cpp | 0 .../Esp8266/Core}/SPISoft.cpp | 0 .../Esp8266/Core}/core_esp8266_si2c.cpp | 2 + .../Esp8266/Core}/pins_arduino.h | 0 .../Esp8266}/Platform/AccessPoint.cpp | 2 +- .../Esp8266}/Platform/RTC.cpp | 2 +- .../Esp8266}/Platform/Station.cpp | 2 +- .../Esp8266}/Platform/System.cpp | 2 +- .../Esp8266}/Platform/WDT.cpp | 2 +- .../Esp8266}/Platform/WifiEvents.cpp | 2 +- .../Esp8266}/Platform/WifiSniffer.cpp | 2 +- .../System/components/axtls-8266}/axtls-8266 | 0 .../components/axtls-8266}/axtls-8266.patch | 0 .../System/components}/custom_heap/heap.c | 0 .../System/components/custom_heap}/umm_malloc | 0 .../components/custom_heap}/umm_malloc.patch | 0 .../components/driver/include/driver}/uart.h | 0 .../System/components/driver}/uart.cpp | 2 +- .../System/components}/esp-lwip/arch/cc.h | 0 .../System/components}/esp-lwip/arch/perf.h | 0 .../components}/esp-lwip/arch/sys_arch.h | 0 .../components/esp-lwip/include}/lwip/api.h | 0 .../esp-lwip/include}/lwip/api_msg.h | 0 .../esp-lwip/include}/lwip/app/dhcpserver.h | 0 .../esp-lwip/include}/lwip/app/espconn.h | 0 .../esp-lwip/include}/lwip/app/espconn_tcp.h | 0 .../esp-lwip/include}/lwip/app/espconn_udp.h | 0 .../esp-lwip/include}/lwip/app/ping.h | 0 .../components/esp-lwip/include}/lwip/arch.h | 0 .../esp-lwip/include}/lwip/autoip.h | 0 .../components/esp-lwip/include}/lwip/debug.h | 0 .../components/esp-lwip/include}/lwip/def.h | 0 .../components/esp-lwip/include}/lwip/dhcp.h | 0 .../components/esp-lwip/include}/lwip/dns.h | 0 .../components/esp-lwip/include}/lwip/err.h | 0 .../components/esp-lwip/include}/lwip/icmp.h | 0 .../components/esp-lwip/include}/lwip/igmp.h | 0 .../components/esp-lwip/include}/lwip/inet.h | 0 .../esp-lwip/include}/lwip/inet_chksum.h | 0 .../components/esp-lwip/include}/lwip/init.h | 0 .../components/esp-lwip/include}/lwip/ip.h | 0 .../esp-lwip/include}/lwip/ip_addr.h | 0 .../esp-lwip/include}/lwip/ip_frag.h | 0 .../components/esp-lwip/include}/lwip/mem.h | 0 .../components/esp-lwip/include}/lwip/memp.h | 0 .../esp-lwip/include}/lwip/memp_std.h | 0 .../esp-lwip/include}/lwip/netbuf.h | 0 .../components/esp-lwip/include}/lwip/netdb.h | 0 .../components/esp-lwip/include}/lwip/netif.h | 0 .../esp-lwip/include}/lwip/netifapi.h | 0 .../components/esp-lwip/include}/lwip/opt.h | 0 .../components/esp-lwip/include}/lwip/pbuf.h | 0 .../components/esp-lwip/include}/lwip/raw.h | 0 .../components/esp-lwip/include}/lwip/sio.h | 0 .../components/esp-lwip/include}/lwip/snmp.h | 0 .../esp-lwip/include}/lwip/snmp_asn1.h | 0 .../esp-lwip/include}/lwip/snmp_msg.h | 0 .../esp-lwip/include}/lwip/snmp_structs.h | 0 .../esp-lwip/include}/lwip/sockets.h | 0 .../components/esp-lwip/include}/lwip/stats.h | 0 .../components/esp-lwip/include}/lwip/sys.h | 0 .../components/esp-lwip/include}/lwip/tcp.h | 0 .../esp-lwip/include}/lwip/tcp_impl.h | 0 .../components/esp-lwip/include}/lwip/tcpip.h | 0 .../esp-lwip/include}/lwip/timers.h | 0 .../components/esp-lwip/include}/lwip/udp.h | 0 .../System/components}/esp-lwip/lwipopts.h | 0 .../System/components/esp-lwip}/mem_manager.h | 0 .../components/esp-open-lwip}/esp-open-lwip | 0 .../esp-open-lwip}/esp-open-lwip.patch | 0 .../components/esp8266}/crash_handler.c | 2 +- .../components/esp8266}/esp_cplusplus.cpp | 4 +- .../System/components/esp8266}/flashmem.c | 0 .../esp8266}/include/esp_cplusplus.h | 0 .../esp8266}/include/esp_systemapi.h | 0 .../esp8266}/include/esp_wifi_sniffer.h | 0 .../include/espinc/c_types_compatible.h | 0 .../esp8266}/include/espinc/lwip_includes.h | 0 .../components/esp8266}/include/espinc/peri.h | 0 .../esp8266}/include/espinc/spi_register.h | 0 .../esp8266}/include/espinc/uart_register.h | 0 .../components/esp8266}/include/flashmem.h | 0 .../System/components/esp8266}/irq_check.s | 0 .../System/components/esp8266/startup.cpp} | 4 +- .../components/esp8266}/xt_interrupts.cpp | 0 .../Esp8266/System/components/fatfs}/diskio.h | 0 .../Esp8266/System/components/fatfs}/ff.c | 0 .../Esp8266/System/components/fatfs}/ff.h | 0 .../Esp8266/System/components/fatfs}/ffconf.h | 0 .../System/components/fatfs}/integer.h | 0 .../System/components/gdbstub}/GdbPacket.cpp | 0 .../System/components/gdbstub}/GdbPacket.h | 0 .../components/gdbstub/appcode}/gdb_hooks.cpp | 14 +- .../gdbstub/appcode}/gdbstub-entry.S | 2 +- .../System/components/gdbstub}/exceptions.h | 0 .../components/gdbstub}/gdb/registers.h | 0 .../components/gdbstub}/gdb/signals.def | 0 .../System/components/gdbstub}/gdb/signals.h | 0 .../System/components/gdbstub}/gdbcmds | 0 .../System/components/gdbstub}/gdbhostio.cpp | 0 .../System/components/gdbstub}/gdbhostio.h | 0 .../System/components/gdbstub}/gdbstub-cfg.h | 0 .../components/gdbstub}/gdbstub-entry.h | 0 .../components/gdbstub}/gdbstub-internal.h | 0 .../System/components/gdbstub}/gdbstub.cpp | 2 +- .../System/components/gdbstub}/gdbstub.h | 2 +- .../System/components/gdbstub}/gdbsyscall.cpp | 2 +- .../System/components/gdbstub}/gdbsyscall.h | 0 .../System/components/gdbstub}/gdbuart.cpp | 2 +- .../System/components/gdbstub}/gdbuart.h | 0 .../System/components/gdbstub}/readme.md | 0 .../components/gdbstub}/symbols/bootrom.elf | Bin .../gdbstub}/xtensa/xtruntime-frames.h | 0 .../Esp8266/System/components/lwip2}/lwip2 | 0 .../System/components/lwip2}/lwip2.patch | 0 .../Esp8266/System/components/pwm/new-pwm} | 0 .../System/components/pwm/new-pwm.patch} | 0 .../rboot/appcode}/rboot-integration.h | 0 .../rboot/appcode/rboot-overrides.c} | 0 .../Esp8266/System/components/rboot}/rboot | 0 .../System/components/rboot}/rboot.patch | 0 .../System/components/spiffs}/spiffs_config.h | 0 .../System/components/spiffs}/spiffs_sming.c | 0 .../System/components/spiffs}/spiffs_sming.h | 0 .../System/components/spiffs}/spiffy_host.h | 0 .../Esp8266/System}/include/user_config.h | 0 .../Esp8266/Tools}/decode-stacktrace.py | 0 .../Platform/Esp8266/Tools}/esptool2 | 0 .../Platform/Esp8266/Tools}/memanalyzer.py | 0 .../Platform/Esp8266/Tools}/spiffy/.gitignore | 0 .../Platform/Esp8266/Tools}/spiffy/Makefile | 4 +- .../Platform/Esp8266/Tools}/spiffy/spiffy.c | 0 Sming/Platform/Esp8266/app.mk | 430 +++++++++++ Sming/Platform/Esp8266/build.mk | 70 ++ Sming/Platform/Esp8266/flash.mk | 57 ++ Sming/Platform/Esp8266/sming.mk | 179 +++++ .../CommandProcessing/CommandDelegate.h | 2 +- .../CommandProcessing/CommandHandler.h | 4 +- Sming/Services/Yeelight/YeelightBulb.h | 8 +- .../Data/Stream/Base64OutputStream.h | 2 +- Sming/SmingCore/Data/Stream/GdbFileStream.cpp | 2 +- .../SmingCore/Data/Stream/JsonObjectStream.h | 2 +- Sming/SmingCore/Debug.h | 2 +- Sming/SmingCore/Digital.h | 3 +- Sming/SmingCore/FileSystem.h | 2 +- Sming/SmingCore/HardwarePWM.h | 1 - Sming/SmingCore/HardwareSerial.h | 2 +- Sming/SmingCore/Network/Http/HttpCommon.h | 2 +- Sming/SmingCore/Network/Http/HttpParams.cpp | 4 +- .../Network/Http/HttpRequestAuth.cpp | 2 +- .../Http/Websocket/WebsocketConnection.cpp | 4 +- .../Http/Websocket/WebsocketConnection.h | 2 +- .../Http/Websocket/WsCommandHandlerResource.h | 2 +- .../Network/Mqtt/MqttPayloadParser.h | 2 +- Sming/SmingCore/Network/MqttClient.cpp | 2 +- Sming/SmingCore/Network/MqttClient.h | 6 +- Sming/SmingCore/Network/SmtpClient.cpp | 2 +- Sming/SmingCore/Network/TcpConnection.h | 2 +- Sming/SmingCore/Network/TelnetServer.h | 2 +- Sming/SmingCore/Network/Url.cpp | 4 +- Sming/SmingCore/Network/WebsocketClient.cpp | 4 +- Sming/SmingCore/SmingCore.h | 7 +- Sming/SmingCore/twi.h | 1 - .../include/debug_progmem.h | 0 .../include/gdb}/gdb_hooks.h | 0 .../include/gdb}/gdb_syscall.h | 0 Sming/{system => System}/include/m_printf.h | 0 .../include/stringconversion.h | 0 Sming/{system => System}/include/stringutil.h | 0 Sming/{system => System}/m_printf.cpp | 0 Sming/{system => System}/stringconversion.cpp | 0 Sming/{system => System}/stringutil.cpp | 0 Sming/Wiring/Arduino.h | 8 +- Sming/Wiring/WConstants.h | 2 +- Sming/Wiring/WHashMap.h | 2 +- Sming/Wiring/WShift.cpp | 4 +- Sming/Wiring/WiringFrameworkDependencies.h | 6 +- Sming/apptest/apptest.cpp | 2 +- Sming/build.mk | 148 ++++ Sming/building.md | 179 +++++ Sming/modules.mk | 72 ++ Sming/third-party/.patches/esp-gdbstub.patch | 56 -- samples/LiveDebug/app/application.cpp | 2 +- 219 files changed, 1500 insertions(+), 1931 deletions(-) create mode 100644 Sming/Makefile-app.mk delete mode 100644 Sming/Makefile-project.mk rename Sming/{SmingCore => Platform/Common}/Platform/AccessPoint.h (100%) rename Sming/{SmingCore => Platform/Common}/Platform/OsMessageInterceptor.cpp (90%) rename Sming/{SmingCore => Platform/Common}/Platform/OsMessageInterceptor.h (100%) rename Sming/{SmingCore => Platform/Common}/Platform/RTC.h (97%) rename Sming/{SmingCore => Platform/Common}/Platform/Station.h (100%) rename Sming/{SmingCore => Platform/Common}/Platform/System.h (100%) rename Sming/{SmingCore => Platform/Common}/Platform/WDT.h (100%) rename Sming/{SmingCore => Platform/Common}/Platform/WifiEvents.h (95%) rename Sming/{SmingCore => Platform/Common}/Platform/WifiSniffer.h (100%) rename Sming/{compiler => Platform/Esp8266/Compiler}/data/blankfs.bin (100%) rename Sming/{compiler => Platform/Esp8266/Compiler}/ld/common.ld (100%) rename Sming/{compiler => Platform/Esp8266/Compiler}/ld/rboot.rom0.ld (100%) rename Sming/{compiler => Platform/Esp8266/Compiler}/ld/standalone.rom.ld (100%) rename Sming/{compiler => Platform/Esp8266/Compiler}/lib/.gitignore (100%) rename Sming/{compiler => Platform/Esp8266/Compiler}/lib/libmicroc.a (100%) rename Sming/{compiler => Platform/Esp8266/Compiler}/lib/libmicrogcc.a (100%) rename Sming/{SmingCore => Platform/Esp8266/Core}/Clock.cpp (100%) rename Sming/{SmingCore => Platform/Esp8266/Core}/Digital.cpp (99%) rename Sming/{SmingCore => Platform/Esp8266/Core}/ESP8266EX.cpp (100%) rename Sming/{SmingCore => Platform/Esp8266/Core}/ESP8266EX.h (100%) rename Sming/{SmingCore => Platform/Esp8266/Core}/HardwarePWM.cpp (99%) rename Sming/{SmingCore => Platform/Esp8266/Core}/HardwareSerial.cpp (99%) rename Sming/{SmingCore => Platform/Esp8266/Core}/HardwareTimer.cpp (100%) rename Sming/{SmingCore => Platform/Esp8266/Core}/Interrupts.cpp (99%) rename Sming/{SmingCore => Platform/Esp8266/Core}/Network/rBootHttpUpdate.cpp (100%) rename Sming/{SmingCore => Platform/Esp8266/Core}/Network/rBootHttpUpdate.h (98%) rename Sming/{SmingCore => Platform/Esp8266/Core}/SPI.cpp (100%) rename Sming/{SmingCore => Platform/Esp8266/Core}/SPISoft.cpp (100%) rename Sming/{SmingCore => Platform/Esp8266/Core}/core_esp8266_si2c.cpp (99%) rename Sming/{SmingCore => Platform/Esp8266/Core}/pins_arduino.h (100%) rename Sming/{SmingCore => Platform/Esp8266}/Platform/AccessPoint.cpp (99%) rename Sming/{SmingCore => Platform/Esp8266}/Platform/RTC.cpp (95%) rename Sming/{SmingCore => Platform/Esp8266}/Platform/Station.cpp (99%) rename Sming/{SmingCore => Platform/Esp8266}/Platform/System.cpp (99%) rename Sming/{SmingCore => Platform/Esp8266}/Platform/WDT.cpp (96%) rename Sming/{SmingCore => Platform/Esp8266}/Platform/WifiEvents.cpp (99%) rename Sming/{SmingCore => Platform/Esp8266}/Platform/WifiSniffer.cpp (95%) rename Sming/{third-party => Platform/Esp8266/System/components/axtls-8266}/axtls-8266 (100%) rename Sming/{third-party/.patches => Platform/Esp8266/System/components/axtls-8266}/axtls-8266.patch (100%) rename Sming/{ => Platform/Esp8266/System/components}/custom_heap/heap.c (100%) rename Sming/{third-party => Platform/Esp8266/System/components/custom_heap}/umm_malloc (100%) rename Sming/{third-party/.patches => Platform/Esp8266/System/components/custom_heap}/umm_malloc.patch (100%) rename Sming/{system/include/espinc => Platform/Esp8266/System/components/driver/include/driver}/uart.h (100%) rename Sming/{system => Platform/Esp8266/System/components/driver}/uart.cpp (99%) rename Sming/{system => Platform/Esp8266/System/components}/esp-lwip/arch/cc.h (100%) rename Sming/{system => Platform/Esp8266/System/components}/esp-lwip/arch/perf.h (100%) rename Sming/{system => Platform/Esp8266/System/components}/esp-lwip/arch/sys_arch.h (100%) rename Sming/{system/esp-lwip => Platform/Esp8266/System/components/esp-lwip/include}/lwip/api.h (100%) rename Sming/{system/esp-lwip => Platform/Esp8266/System/components/esp-lwip/include}/lwip/api_msg.h (100%) rename Sming/{system/esp-lwip => Platform/Esp8266/System/components/esp-lwip/include}/lwip/app/dhcpserver.h (100%) rename Sming/{system/esp-lwip => Platform/Esp8266/System/components/esp-lwip/include}/lwip/app/espconn.h (100%) rename Sming/{system/esp-lwip => Platform/Esp8266/System/components/esp-lwip/include}/lwip/app/espconn_tcp.h (100%) rename Sming/{system/esp-lwip => Platform/Esp8266/System/components/esp-lwip/include}/lwip/app/espconn_udp.h (100%) rename Sming/{system/esp-lwip => Platform/Esp8266/System/components/esp-lwip/include}/lwip/app/ping.h (100%) rename Sming/{system/esp-lwip => Platform/Esp8266/System/components/esp-lwip/include}/lwip/arch.h (100%) rename Sming/{system/esp-lwip => Platform/Esp8266/System/components/esp-lwip/include}/lwip/autoip.h (100%) rename Sming/{system/esp-lwip => Platform/Esp8266/System/components/esp-lwip/include}/lwip/debug.h (100%) rename Sming/{system/esp-lwip => Platform/Esp8266/System/components/esp-lwip/include}/lwip/def.h (100%) rename Sming/{system/esp-lwip => Platform/Esp8266/System/components/esp-lwip/include}/lwip/dhcp.h (100%) rename Sming/{system/esp-lwip => Platform/Esp8266/System/components/esp-lwip/include}/lwip/dns.h (100%) rename Sming/{system/esp-lwip => Platform/Esp8266/System/components/esp-lwip/include}/lwip/err.h (100%) rename Sming/{system/esp-lwip => Platform/Esp8266/System/components/esp-lwip/include}/lwip/icmp.h (100%) rename Sming/{system/esp-lwip => Platform/Esp8266/System/components/esp-lwip/include}/lwip/igmp.h (100%) rename Sming/{system/esp-lwip => Platform/Esp8266/System/components/esp-lwip/include}/lwip/inet.h (100%) rename Sming/{system/esp-lwip => Platform/Esp8266/System/components/esp-lwip/include}/lwip/inet_chksum.h (100%) rename Sming/{system/esp-lwip => Platform/Esp8266/System/components/esp-lwip/include}/lwip/init.h (100%) rename Sming/{system/esp-lwip => Platform/Esp8266/System/components/esp-lwip/include}/lwip/ip.h (100%) rename Sming/{system/esp-lwip => Platform/Esp8266/System/components/esp-lwip/include}/lwip/ip_addr.h (100%) rename Sming/{system/esp-lwip => Platform/Esp8266/System/components/esp-lwip/include}/lwip/ip_frag.h (100%) rename Sming/{system/esp-lwip => Platform/Esp8266/System/components/esp-lwip/include}/lwip/mem.h (100%) rename Sming/{system/esp-lwip => Platform/Esp8266/System/components/esp-lwip/include}/lwip/memp.h (100%) rename Sming/{system/esp-lwip => Platform/Esp8266/System/components/esp-lwip/include}/lwip/memp_std.h (100%) rename Sming/{system/esp-lwip => Platform/Esp8266/System/components/esp-lwip/include}/lwip/netbuf.h (100%) rename Sming/{system/esp-lwip => Platform/Esp8266/System/components/esp-lwip/include}/lwip/netdb.h (100%) rename Sming/{system/esp-lwip => Platform/Esp8266/System/components/esp-lwip/include}/lwip/netif.h (100%) rename Sming/{system/esp-lwip => Platform/Esp8266/System/components/esp-lwip/include}/lwip/netifapi.h (100%) rename Sming/{system/esp-lwip => Platform/Esp8266/System/components/esp-lwip/include}/lwip/opt.h (100%) rename Sming/{system/esp-lwip => Platform/Esp8266/System/components/esp-lwip/include}/lwip/pbuf.h (100%) rename Sming/{system/esp-lwip => Platform/Esp8266/System/components/esp-lwip/include}/lwip/raw.h (100%) rename Sming/{system/esp-lwip => Platform/Esp8266/System/components/esp-lwip/include}/lwip/sio.h (100%) rename Sming/{system/esp-lwip => Platform/Esp8266/System/components/esp-lwip/include}/lwip/snmp.h (100%) rename Sming/{system/esp-lwip => Platform/Esp8266/System/components/esp-lwip/include}/lwip/snmp_asn1.h (100%) rename Sming/{system/esp-lwip => Platform/Esp8266/System/components/esp-lwip/include}/lwip/snmp_msg.h (100%) rename Sming/{system/esp-lwip => Platform/Esp8266/System/components/esp-lwip/include}/lwip/snmp_structs.h (100%) rename Sming/{system/esp-lwip => Platform/Esp8266/System/components/esp-lwip/include}/lwip/sockets.h (100%) rename Sming/{system/esp-lwip => Platform/Esp8266/System/components/esp-lwip/include}/lwip/stats.h (100%) rename Sming/{system/esp-lwip => Platform/Esp8266/System/components/esp-lwip/include}/lwip/sys.h (100%) rename Sming/{system/esp-lwip => Platform/Esp8266/System/components/esp-lwip/include}/lwip/tcp.h (100%) rename Sming/{system/esp-lwip => Platform/Esp8266/System/components/esp-lwip/include}/lwip/tcp_impl.h (100%) rename Sming/{system/esp-lwip => Platform/Esp8266/System/components/esp-lwip/include}/lwip/tcpip.h (100%) rename Sming/{system/esp-lwip => Platform/Esp8266/System/components/esp-lwip/include}/lwip/timers.h (100%) rename Sming/{system/esp-lwip => Platform/Esp8266/System/components/esp-lwip/include}/lwip/udp.h (100%) rename Sming/{system => Platform/Esp8266/System/components}/esp-lwip/lwipopts.h (100%) rename Sming/{system/include => Platform/Esp8266/System/components/esp-lwip}/mem_manager.h (100%) rename Sming/{third-party => Platform/Esp8266/System/components/esp-open-lwip}/esp-open-lwip (100%) rename Sming/{third-party/.patches => Platform/Esp8266/System/components/esp-open-lwip}/esp-open-lwip.patch (100%) rename Sming/{system => Platform/Esp8266/System/components/esp8266}/crash_handler.c (98%) rename Sming/{system => Platform/Esp8266/System/components/esp8266}/esp_cplusplus.cpp (93%) rename Sming/{system => Platform/Esp8266/System/components/esp8266}/flashmem.c (100%) rename Sming/{system => Platform/Esp8266/System/components/esp8266}/include/esp_cplusplus.h (100%) rename Sming/{system => Platform/Esp8266/System/components/esp8266}/include/esp_systemapi.h (100%) rename Sming/{system => Platform/Esp8266/System/components/esp8266}/include/esp_wifi_sniffer.h (100%) rename Sming/{system => Platform/Esp8266/System/components/esp8266}/include/espinc/c_types_compatible.h (100%) rename Sming/{system => Platform/Esp8266/System/components/esp8266}/include/espinc/lwip_includes.h (100%) rename Sming/{system => Platform/Esp8266/System/components/esp8266}/include/espinc/peri.h (100%) rename Sming/{system => Platform/Esp8266/System/components/esp8266}/include/espinc/spi_register.h (100%) rename Sming/{system => Platform/Esp8266/System/components/esp8266}/include/espinc/uart_register.h (100%) rename Sming/{system => Platform/Esp8266/System/components/esp8266}/include/flashmem.h (100%) rename Sming/{system => Platform/Esp8266/System/components/esp8266}/irq_check.s (100%) rename Sming/{appinit/user_main.cpp => Platform/Esp8266/System/components/esp8266/startup.cpp} (98%) rename Sming/{system => Platform/Esp8266/System/components/esp8266}/xt_interrupts.cpp (100%) rename Sming/{Services/FATFS => Platform/Esp8266/System/components/fatfs}/diskio.h (100%) rename Sming/{Services/FATFS => Platform/Esp8266/System/components/fatfs}/ff.c (100%) rename Sming/{Services/FATFS => Platform/Esp8266/System/components/fatfs}/ff.h (100%) rename Sming/{Services/FATFS => Platform/Esp8266/System/components/fatfs}/ffconf.h (100%) rename Sming/{Services/FATFS => Platform/Esp8266/System/components/fatfs}/integer.h (100%) rename Sming/{gdb => Platform/Esp8266/System/components/gdbstub}/GdbPacket.cpp (100%) rename Sming/{gdb => Platform/Esp8266/System/components/gdbstub}/GdbPacket.h (100%) rename Sming/{appspecific/gdb => Platform/Esp8266/System/components/gdbstub/appcode}/gdb_hooks.cpp (93%) rename Sming/{appspecific/gdb => Platform/Esp8266/System/components/gdbstub/appcode}/gdbstub-entry.S (99%) rename Sming/{gdb => Platform/Esp8266/System/components/gdbstub}/exceptions.h (100%) rename Sming/{gdb => Platform/Esp8266/System/components/gdbstub}/gdb/registers.h (100%) rename Sming/{gdb => Platform/Esp8266/System/components/gdbstub}/gdb/signals.def (100%) rename Sming/{gdb => Platform/Esp8266/System/components/gdbstub}/gdb/signals.h (100%) rename Sming/{gdb => Platform/Esp8266/System/components/gdbstub}/gdbcmds (100%) rename Sming/{gdb => Platform/Esp8266/System/components/gdbstub}/gdbhostio.cpp (100%) rename Sming/{gdb => Platform/Esp8266/System/components/gdbstub}/gdbhostio.h (100%) rename Sming/{gdb => Platform/Esp8266/System/components/gdbstub}/gdbstub-cfg.h (100%) rename Sming/{gdb => Platform/Esp8266/System/components/gdbstub}/gdbstub-entry.h (100%) rename Sming/{gdb => Platform/Esp8266/System/components/gdbstub}/gdbstub-internal.h (100%) rename Sming/{gdb => Platform/Esp8266/System/components/gdbstub}/gdbstub.cpp (99%) rename Sming/{gdb => Platform/Esp8266/System/components/gdbstub}/gdbstub.h (96%) rename Sming/{gdb => Platform/Esp8266/System/components/gdbstub}/gdbsyscall.cpp (95%) rename Sming/{gdb => Platform/Esp8266/System/components/gdbstub}/gdbsyscall.h (100%) rename Sming/{gdb => Platform/Esp8266/System/components/gdbstub}/gdbuart.cpp (95%) rename Sming/{gdb => Platform/Esp8266/System/components/gdbstub}/gdbuart.h (100%) rename Sming/{gdb => Platform/Esp8266/System/components/gdbstub}/readme.md (100%) rename Sming/{gdb => Platform/Esp8266/System/components/gdbstub}/symbols/bootrom.elf (100%) rename Sming/{gdb => Platform/Esp8266/System/components/gdbstub}/xtensa/xtruntime-frames.h (100%) rename Sming/{third-party => Platform/Esp8266/System/components/lwip2}/lwip2 (100%) rename Sming/{third-party/.patches => Platform/Esp8266/System/components/lwip2}/lwip2.patch (100%) rename Sming/{third-party/pwm => Platform/Esp8266/System/components/pwm/new-pwm} (100%) rename Sming/{third-party/.patches/pwm.patch => Platform/Esp8266/System/components/pwm/new-pwm.patch} (100%) rename Sming/{system/include => Platform/Esp8266/System/components/rboot/appcode}/rboot-integration.h (100%) rename Sming/{appspecific/rboot/overrides.c => Platform/Esp8266/System/components/rboot/appcode/rboot-overrides.c} (100%) rename Sming/{third-party => Platform/Esp8266/System/components/rboot}/rboot (100%) rename Sming/{third-party/.patches => Platform/Esp8266/System/components/rboot}/rboot.patch (100%) rename Sming/{Services/SpifFS => Platform/Esp8266/System/components/spiffs}/spiffs_config.h (100%) rename Sming/{Services/SpifFS => Platform/Esp8266/System/components/spiffs}/spiffs_sming.c (100%) rename Sming/{Services/SpifFS => Platform/Esp8266/System/components/spiffs}/spiffs_sming.h (100%) rename Sming/{Services/SpifFS => Platform/Esp8266/System/components/spiffs}/spiffy_host.h (100%) rename Sming/{ => Platform/Esp8266/System}/include/user_config.h (100%) rename {tools => Sming/Platform/Esp8266/Tools}/decode-stacktrace.py (100%) mode change 100755 => 100644 rename {tools => Sming/Platform/Esp8266/Tools}/esptool2 (100%) rename {tools => Sming/Platform/Esp8266/Tools}/memanalyzer.py (100%) rename {tools => Sming/Platform/Esp8266/Tools}/spiffy/.gitignore (100%) rename {tools => Sming/Platform/Esp8266/Tools}/spiffy/Makefile (84%) rename {tools => Sming/Platform/Esp8266/Tools}/spiffy/spiffy.c (100%) create mode 100644 Sming/Platform/Esp8266/app.mk create mode 100644 Sming/Platform/Esp8266/build.mk create mode 100644 Sming/Platform/Esp8266/flash.mk create mode 100644 Sming/Platform/Esp8266/sming.mk rename Sming/{system => System}/include/debug_progmem.h (100%) rename Sming/{system/include => System/include/gdb}/gdb_hooks.h (100%) rename Sming/{system/include => System/include/gdb}/gdb_syscall.h (100%) rename Sming/{system => System}/include/m_printf.h (100%) rename Sming/{system => System}/include/stringconversion.h (100%) rename Sming/{system => System}/include/stringutil.h (100%) rename Sming/{system => System}/m_printf.cpp (100%) rename Sming/{system => System}/stringconversion.cpp (100%) rename Sming/{system => System}/stringutil.cpp (100%) create mode 100644 Sming/build.mk create mode 100644 Sming/building.md create mode 100644 Sming/modules.mk delete mode 100644 Sming/third-party/.patches/esp-gdbstub.patch diff --git a/.gitmodules b/.gitmodules index e6d068e36b..ef86d3d069 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,28 +1,29 @@ -[submodule "Sming/third-party/rboot"] - path = Sming/third-party/rboot +[submodule "ESP8266.rboot"] + path = Sming/Platform/Esp8266/System/components/rboot/rboot url = https://github.com/raburton/rboot.git - ignore = dirty + ignore = dirty [submodule "Sming.wiki"] path = docs/wiki url = https://github.com/SmingHub/Sming.wiki.git ignore = dirty -[submodule "Sming/third-party/pwm"] - path = Sming/third-party/pwm +[submodule "ESP8266.new-pwm"] + path = Sming/Platform/Esp8266/System/components/pwm/new-pwm url = https://github.com/StefanBruens/ESP8266_new_pwm.git - ignore = dirty -[submodule "Sming/third-party/axtls-8266"] - path = Sming/third-party/axtls-8266 + ignore = dirty +[submodule "ESP8266.axtls-8266"] + path = Sming/Platform/Esp8266/System/components/axtls-8266/axtls-8266 url = https://github.com/igrr/axtls-8266.git - ignore = dirty -[submodule "Sming/third-party/spiffs"] + ignore = dirty +[submodule "ESP8266.spiffs"] path = Sming/third-party/spiffs url = https://github.com/pellepl/spiffs.git -[submodule "Sming/third-party/umm_malloc"] - path = Sming/third-party/umm_malloc + ignore = dirty +[submodule "ESP8266.umm_malloc"] + path = Sming/Platform/Esp8266/System/components/custom_heap/umm_malloc url = https://github.com/rhempel/umm_malloc.git ignore = dirty -[submodule "Sming/third-party/esp-open-lwip"] - path = Sming/third-party/esp-open-lwip +[submodule "ESP8266.esp-open-lwip"] + path = Sming/Platform/Esp8266/System/components/esp-open-lwip/esp-open-lwip url = https://github.com/pfalcon/esp-open-lwip.git ignore = dirty [submodule "Sming/third-party/http-parser"] @@ -49,16 +50,16 @@ path = Sming/Libraries/Adafruit_Sensor url = https://github.com/adafruit/Adafruit_Sensor ignore = dirty -[submodule "Sming/third-party/lwip2"] - path = Sming/third-party/lwip2 +[submodule "ESP8266.lwip2"] + path = Sming/Platform/Esp8266/System/components/lwip2/lwip2 url = https://github.com/d-a-v/esp82xx-nonos-linklayer.git ignore = dirty [submodule "Sming/third-party/ESP8266_NONOS_SDK"] path = Sming/third-party/ESP8266_NONOS_SDK url = https://github.com/espressif/ESP8266_NONOS_SDK.git ignore = dirty -[submodule "tools/esptool2"] - path = tools/esptool2 +[submodule "ESP8266.esptool2"] + path = Sming/Platform/Esp8266/Tools/esptool2 url = https://github.com/raburton/esptool2.git ignore = dirty [submodule "Sming/Libraries/RingBufCPP"] @@ -92,3 +93,4 @@ [submodule "Sming/third-party/libyuarel"] path = Sming/third-party/libyuarel url = https://github.com/jacketizer/libyuarel.git + ignore = dirty diff --git a/Sming/Libraries/SDCard/SDCard.cpp b/Sming/Libraries/SDCard/SDCard.cpp index f8caea2bef..f86f8a78be 100644 --- a/Sming/Libraries/SDCard/SDCard.cpp +++ b/Sming/Libraries/SDCard/SDCard.cpp @@ -33,7 +33,7 @@ Descr: Low-level SDCard functions /-------------------------------------------------------------------------*/ #include "SDCard.h" -#include "diskio.h" /* Declarations of disk I/O functions */ +#include "fatfs/diskio.h" /* Declarations of disk I/O functions */ FATFS *pFatFs = NULL; /* FatFs work area needed for each volume */ SPIBase *SDCardSPI = NULL; diff --git a/Sming/Makefile b/Sming/Makefile index 602b617ebc..e0117f801f 100644 --- a/Sming/Makefile +++ b/Sming/Makefile @@ -6,14 +6,11 @@ # ############################################################# -## Defaults for Sming Core - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif +ifndef SMING_HOME +$(error SMING_HOME variable is not set to a valid directory.) +endif -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk +## Defaults for Sming Core ## SMING_HOME sets the path where Sming framework is located. ## Windows: @@ -22,407 +19,127 @@ # MacOS / Linux # SMING_HOME = /opt/esp-open-sdk -# Git command -GIT ?= git - -# Detect OS and build environment -UNAME := $(shell uname -s) - -ifeq ($(OS),Windows_NT) - # Convert Windows paths to POSIX paths - SMING_HOME := $(subst \,/,$(addprefix /,$(subst :,,$(SMING_HOME)))) - SMING_HOME := $(subst //,/,$(SMING_HOME)) - ESP_HOME := $(subst \,/,$(addprefix /,$(subst :,,$(ESP_HOME)))) - ESP_HOME := $(subst //,/,$(ESP_HOME)) -endif +.PHONY: all +all: checkdirs libsming tools -ifneq ($(filter MINGW32_NT%,$(UNAME)),) - UNAME := Windows -else ifneq ($(filter CYGWIN%,$(UNAME)),) - # Cygwin Detected - UNAME := Linux -else ifneq ($(filter CYGWIN%WOW,$(UNAME)),) - #Cygwin32 - UNAME := Linux -else ifneq ($(filter MSYS%WOW,$(UNAME)),) - #Msys32 - UNAME := Linux -else ifeq ($(UNAME), Linux) - #Linux -else ifeq ($(UNAME), Darwin) - #OS X -else ifeq ($(UNAME), Freebsd) - #BSD -endif - -# OS specific configuration -ifeq ($(UNAME),Windows) - # Windows detected - - # Default SMING_HOME. Can be overriden. - SMING_HOME ?= c:\tools\Sming\Sming - - # Default ESP_HOME. Can be overriden. - ESP_HOME ?= c:\Espressif - - include $(SMING_HOME)/Makefile-windows.mk -else - ifeq ($(UNAME),Darwin) - # MacOS Detected - UNAME := MacOS - - # Default SMING_HOME. Can be overriden. - SMING_HOME ?= /opt/sming/Sming - - # Default ESP_HOME. Can be overriden. - ESP_HOME ?= /opt/esp-open-sdk - - include Makefile-macos.mk - else ifeq ($(UNAME),Linux) - # Linux Detected - UNAME := Linux - - # Default SMING_HOME. Can be overriden. - SMING_HOME ?= /opt/sming/Sming - - # Default ESP_HOME. Can be overriden. - ESP_HOME ?= /opt/esp-open-sdk - include Makefile-linux.mk - else ifeq ($(UNAME),FreeBSD) - # Freebsd Detected - UNAME := FreeBSD - - # Default SMING_HOME. Can be overriden. - SMING_HOME ?= /usr/local/esp8266/Sming/Sming - - # Default ESP_HOME. Can be overriden. - ESP_HOME ?= /usr/local/esp8266/esp-open-sdk - include Makefile-bsd.mk - endif -endif +include $(SMING_HOME)/build.mk -export ESP_HOME -export SMING_HOME -export COMPILE := gcc -export PATH := $(ESP_HOME)/xtensa-lx106-elf/bin:$(PATH) -XTENSA_TOOLS_ROOT := $(ESP_HOME)/xtensa-lx106-elf/bin - -# select which tools to use as assembler, compiler, librarian and linker -AS := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-gcc -CC := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-gcc -CXX := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-g++ -AR := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-ar -LD := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-gcc -OBJCOPY := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-objcopy -OBJDUMP := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-objdump - -### Debug output parameters -# By default `debugf` does not print file name and line number. If you want this enabled set the directive below to 1 -DEBUG_PRINT_FILENAME_AND_LINE ?= 0 - -# Default debug verbose level is INFO, where DEBUG=3 INFO=2 WARNING=1 ERROR=0 -DEBUG_VERBOSE_LEVEL ?= 2 - -# Disable CommandExecutor functionality if not used and save some ROM and RAM -ENABLE_CMD_EXECUTOR ?= 1 +BUILD_BASE := $(PLATFORM_BASE)/out/build RELOAD_MKFILE = 0 -# Sming Framework Path -SMF = $(SMING_HOME) - -SPIFF_FILES = files - -BUILD_BASE = out/build -FW_BASE = out/firmware -USER_LIBDIR = compiler/lib - -LIBSMING = libsming +LIBSMING := libsming ifeq ($(ENABLE_SSL),1) - LIBSMING= libsmingssl + LIBSMING := libsmingssl endif - # name for the target project TARGET = app -CUSTOM_TARGETS ?= - -ARDUINO_LIBRARIES = $(shell git submodule status Libraries | cut -c2- | cut -f2 -d ' ' | sed -r 's/Libraries\/([^/]*)/Libraries\/\1\/library.properties/g' ) - -# which modules (subdirectories) of the project to include in compiling -MODULES = system system/helpers Wiring appinit \ - $(sort $(dir $(wildcard SmingCore/*/ SmingCore/*/*/ SmingCore/*/*/*/))) \ - $(filter %/, $(wildcard Services/*/)) \ - $(filter %/, $(wildcard Libraries/*/)) $(wildcard Libraries/*/src/) -EXTRA_INCDIR = include system/include Wiring Libraries SmingCore $(SDK_BASE)/../include - -# Place a file that should exist in a submodule that is fetched separately -# => rboot -THIRD_PARTY_DATA = third-party/rboot/Makefile -EXTRA_INCDIR += third-party/rboot third-party/rboot/appcode +# If specified, restrict importing and building to a specific list of libraries +ARDUINO_LIBRARIES ?= $(patsubst Libraries/%,%,$(wildcard Libraries/*/)) +ARDUINO_LIBRARIES := $(ARDUINO_LIBRARIES:/=) -# => spiffs -THIRD_PARTY_DATA += third-party/spiffs/makefile -MODULES += third-party/spiffs/src -EXTRA_INCDIR += third-party/spiffs/src +# List of directories containing source code to build +MODULES := -# => http-parser -THIRD_PARTY_DATA += third-party/http-parser/Makefile -MODULES += third-party/http-parser/ -EXTRA_INCDIR += third-party/http-parser/ - -# => websocket-parser -THIRD_PARTY_DATA += third-party/ws_parser/Makefile -MODULES += third-party/ws_parser/ -EXTRA_INCDIR += third-party/ws_parser/ +# List of dependent submodule directories which may require updating/patching +SUBMODULES := -# mqtt-codec in here... -THIRD_PARTY_DATA += third-party/mqtt-codec/Makefile -EXTRA_INCDIR += third-party/mqtt-codec/src -CUSTOM_TARGETS += $(USER_LIBDIR)/libmqttc.a +# Include directories additional to APPCODE / MODULES +EXTRA_INCDIR := -# => yuarel -THIRD_PARTY_DATA += third-party/libyuarel/Makefile -MODULES += third-party/libyuarel/ -EXTRA_INCDIR += third-party/libyuarel/ - -# => LOCALE -ifdef LOCALE - CFLAGS += -DLOCALE=$(LOCALE) -endif - -# => SDK -SDK_INTERNAL = 0 -ifneq (,$(findstring third-party/ESP8266_NONOS_SDK, $(SDK_BASE))) - THIRD_PARTY_DATA += third-party/ESP8266_NONOS_SDK/Makefile - CFLAGS += -DSDK_INTERNAL - SDK_INTERNAL = 1 -endif +# +SAMPLES_DIRS := $(shell ls -1 ../samples) +DOXYGEN := $(shell command -v doxygen 2> /dev/null) -# => umm_malloc (custom heap allocation) -ifeq ($(ENABLE_CUSTOM_HEAP), 1) - THIRD_PARTY_DATA += third-party/umm_malloc/Makefile - MODULES += custom_heap third-party/umm_malloc/src - EXTRA_INCDIR += third-party/umm_malloc/src third-party/umm_malloc/includes/c-helper-macros - CUSTOM_TARGETS += $(USER_LIBDIR)/libmainmm.a +# Flags for compatability with old versions (most of them should disappear with the next major release) +ifeq ($(MQTT_NO_COMPAT),1) + CFLAGS += -DMQTT_NO_COMPAT=1 endif -# => Open Source LWIP -LIBLWIP = lwip -ENABLE_CUSTOM_LWIP ?= 1 -ENABLE_ESPCONN ?= 0 -ifeq ($(ENABLE_CUSTOM_LWIP), 0) - EXTRA_INCDIR += system/esp-lwip -endif -ifeq ($(ENABLE_CUSTOM_LWIP), 1) - THIRD_PARTY_DATA += third-party/esp-open-lwip/Makefile.open - EXTRA_INCDIR += third-party/esp-open-lwip/include - LIBLWIP = lwip_open - LWIP_EXTRA_FLAGS = 1 -endif -ifeq ($(ENABLE_CUSTOM_LWIP), 2) - THIRD_PARTY_DATA += third-party/lwip2/Makefile.sming - EXTRA_INCDIR += third-party/lwip2/glue-esp/include-esp third-party/lwip2/include - LIBLWIP = lwip2 - LWIP_EXTRA_FLAGS = 1 +ifeq ($(ENABLE_WPS), 1) + CFLAGS += -DENABLE_WPS=1 endif -ifeq ($(LWIP_EXTRA_FLAGS),1) - EXTRA_CFLAGS_LWIP = -I../../system/include -I../../Wiring - ENABLE_LWIPDEBUG ?= 0 - ifeq ($(ENABLE_LWIPDEBUG), 1) - EXTRA_CFLAGS_LWIP += -DLWIP_DEBUG - endif - - ifeq ($(ENABLE_ESPCONN), 1) - LIBLWIP = lwip_full - endif - CUSTOM_TARGETS += $(USER_LIBDIR)/lib$(LIBLWIP).a -endif +# => http-parser +SUBMODULES += $(THIRD_PARTY_DIR)/http-parser +MODULES += $(THIRD_PARTY_DIR)/http-parser -# libraries used in this project, mainly provided by the SDK -LIBS = microc microgcc hal phy pp net80211 $(LIBLWIP) mqttc wpa main +# => websocket-parser +SUBMODULES += $(THIRD_PARTY_DIR)/ws_parser +MODULES += $(THIRD_PARTY_DIR)/ws_parser -ENABLE_CUSTOM_PWM ?= 1 -ifeq ($(ENABLE_CUSTOM_PWM), 1) - THIRD_PARTY_DATA += third-party/pwm/pwm.c - CFLAGS += -DSDK_PWM_PERIOD_COMPAT_MODE=1 -endif +# => mqtt-codec +SUBMODULES += $(THIRD_PARTY_DIR)/mqtt-codec +EXTRA_INCDIR += $(THIRD_PARTY_DIR)/mqtt-codec/src +LIBMQTTC := mqttc +LIBS += $(LIBMQTTC) +BUILD_MQTTC := $(MAKE) -C $(THIRD_PARTY_DIR)/mqtt-codec MQTT_ENABLE_SERVER=0 MQTT_ENABLE_CLIENT=1 CC=$(CC) AR=$(AR) \ + CFLAGS_EXTRA="-ISystem/include $(CFLAGS_COMMON)" \ + LIB_FOLDER="$(SMING_HOME)/$(USER_LIBDIR)" +CLEAN += mqttc-clean -MFORCE32 := $(shell $(CC) --help=target | grep mforce-l32) +$(call UserLibPath,$(LIBMQTTC)): + $(Q) $(BUILD_MQTTC) lib -CFLAGS_COMMON = -Wl,-EL -nostdlib -mlongcalls -mtext-section-literals -finline-functions -fdata-sections -ffunction-sections -# compiler flags using during compilation of source files. Add '-pg' for debugging -CFLAGS += -Wall -Wundef -Wpointer-arith -Wno-comment $(CFLAGS_COMMON) \ - -D__ets__ -DICACHE_FLASH -DUSE_OPTIMIZE_PRINTF -DARDUINO=106 -DENABLE_CMD_EXECUTOR=$(ENABLE_CMD_EXECUTOR) -DESP8266=1 -DSMING_INCLUDED=1 -ifneq ($(STRICT),1) -CFLAGS += -Werror -Wno-sign-compare -Wno-parentheses -Wno-unused-variable -Wno-unused-but-set-variable -Wno-strict-aliasing -Wno-return-type -Wno-maybe-uninitialized -endif +.PHONY: mqttc-clean +mqttc-clean: + -$(Q) $(BUILD_MQTTC) clean -ifeq ($(ENABLE_GDB), 1) - CFLAGS += -ggdb -DENABLE_GDB=1 -endif -ifeq ($(SMING_RELEASE),1) - # See: https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html - # for full list of optimization options - CFLAGS += -Os -DSMING_RELEASE=1 -DLWIP_NOASSERT -else ifeq ($(ENABLE_GDB), 1) - CFLAGS += -Og -else - CFLAGS += -Os -g -endif -ifneq ($(MFORCE32),) - # Your compiler supports the -mforce-l32 flag which means that - # constants can be stored in flash (program) memory instead of SRAM. - # See: https://www.arduino.cc/en/Reference/PROGMEM - CFLAGS += -DPROGMEM_L32="__attribute__((aligned(4))) __attribute__((section(\".irom.text\")))" -mforce-l32 -else - CFLAGS += -DPROGMEM_L32="" -endif +# => yuarel +SUBMODULES += $(THIRD_PARTY_DIR)/libyuarel +MODULES += $(THIRD_PARTY_DIR)/libyuarel -# Flags for compatability with old versions (most of them should disappear with the next major release) -ifeq ($(MQTT_NO_COMPAT),1) - CFLAGS += -DMQTT_NO_COMPAT=1 -endif +include $(PLATFORM_BASE)/sming.mk -#Append debug options -CFLAGS += -DCUST_FILE_BASE=$$* -DDEBUG_VERBOSE_LEVEL=$(DEBUG_VERBOSE_LEVEL) -DDEBUG_PRINT_FILENAME_AND_LINE=$(DEBUG_PRINT_FILENAME_AND_LINE) +# Get list of subdirectory paths +# $1 -> Root directory +define ScanModuleDirs + $(sort $(dir $(wildcard $1/*/ $1/*/*/ $1/*/*/*/))) +endef -CXXFLAGS = $(CFLAGS) -fno-rtti -fno-exceptions -std=c++11 -felide-constructors -ifneq ($(STRICT),1) -CXXFLAGS += -Wno-reorder -endif +# Identify which libraries have submodules +LIBRARY_SUBMODULES := $(shell git submodule status Libraries | cut -c2- | cut -f2 -d ' ') +LIBRARY_SUBMODULES := $(patsubst Libraries/%,%,$(LIBRARY_SUBMODULES)) +LIBRARY_SUBMODULES := $(filter $(LIBRARY_SUBMODULES), $(ARDUINO_LIBRARIES)) +# List of .submodule targets for any third-party Arduino libraries +LIBRARY_SUBMODULES := $(foreach lib,$(LIBRARY_SUBMODULES),Libraries/$(lib)/.submodule) -# various paths from the SDK used in this project -SDK_LIBDIR = lib -SDK_INCDIR = include include/json +# which modules (subdirectories) to include in compiling +SMING_MODULES := $(PLATFORM_CORE) $(PLATFORM_BASE)/Platform Platform/Common SmingCore +SMING_MODULES := $(foreach mod,$(SMING_MODULES),$(call ScanModuleDirs,$(mod))) +MODULES := System $(PLATFORM_SYS) Wiring $(SMING_MODULES) $(MODULES) +MODULES += $(wildcard Services/*/) +MODULES += $(foreach lib,$(ARDUINO_LIBRARIES),Libraries/$(lib) Libraries/$(lib)/src) +MODULES := $(MODULES:/=) -# SSL support using axTLS -ifeq ($(ENABLE_SSL),1) - THIRD_PARTY_DATA += third-party/axtls-8266/Makefile - LIBS += axtls - MODULES += third-party/axtls-8266/compat third-party/axtls-8266/replacements - EXTRA_INCDIR += third-party/axtls-8266 axtls-8266/ssl third-party/axtls-8266/crypto - AXTLS_FLAGS = -DLWIP_RAW=1 -DENABLE_SSL=1 - ifeq ($(SSL_DEBUG),1) # - AXTLS_FLAGS += -DSSL_DEBUG=1 -DDEBUG_TLS_MEM=1 -DAXL_DEBUG=1 - endif - CUSTOM_TARGETS += $(USER_LIBDIR)/libaxtls.a -# EXTRA_CFLAGS_AXTLS = -I../../system/include -I../../Wiring - CFLAGS += $(AXTLS_FLAGS) - CXXFLAGS += $(AXTLS_FLAGS) -endif +EXTRA_INCDIR := System/include Wiring Libraries SmingCore Platform/Common \ + $(PLATFORM_BASE) $(PLATFORM_SYS)/include $(PLATFORM_CORE) \ + $(THIRD_PARTY_DIR) . $(EXTRA_INCDIR) -ifeq ($(ENABLE_WPS), 1) - LIBS += wps - CFLAGS += -DENABLE_WPS=1 -endif +include $(SMING_HOME)/modules.mk -SRC_DIR := $(MODULES) -BUILD_DIR := $(addprefix $(BUILD_BASE)/,$(MODULES)) - -SDK_LIBDIR := $(addprefix $(SDK_BASE)/,$(SDK_LIBDIR)) -SDK_INCDIR := $(addprefix -I$(SDK_BASE)/,$(SDK_INCDIR)) - -AS_SRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.s)) -AS_SRC += $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.S)) -C_SRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.c)) -CXX_SRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.cpp)) -AS_OBJ := $(patsubst %.s,$(BUILD_BASE)/%.o,$(AS_SRC)) -AS_OBJ += $(patsubst %.S,$(BUILD_BASE)/%.o,$(AS_SRC)) -C_OBJ := $(patsubst %.c,$(BUILD_BASE)/%.o,$(C_SRC)) -CXX_OBJ := $(patsubst %.cpp,$(BUILD_BASE)/%.o,$(CXX_SRC)) -OBJ := $(AS_OBJ) $(C_OBJ) $(CXX_OBJ) -LIBS := $(addprefix -l,$(LIBS)) -APP_AR := $(addprefix $(BUILD_BASE)/,$(TARGET)_app.a) -TARGET_OUT := $(addprefix $(BUILD_BASE)/,$(TARGET).out) - -INCDIR := $(addprefix -I,$(SRC_DIR)) -EXTRA_INCDIR := $(addprefix -I,$(EXTRA_INCDIR)) -MODULE_INCDIR := $(addsuffix /include,$(INCDIR)) -SAMPLES_DIRS := $(shell ls -1 ../samples) -TOOLS_DIRS := $(shell ls -1 ../tools) -THIRD_PARTY_DIRS := $(shell ls -1 third-party ) -DOXYGEN := $(shell command -v doxygen 2> /dev/null) - -V ?= $(VERBOSE) -ifeq ("$(V)","1") -Q := -vecho := @true -else -Q := @ -vecho := @echo -endif +CUSTOM_TARGETS += $(LIBS) -vpath %.c $(SRC_DIR) -vpath %.cpp $(SRC_DIR) -vpath %.s $(SRC_DIR) -vpath %.S $(SRC_DIR) - -define compile-objects -$1/%.o: %.s - $(vecho) "AS $$<" - $(Q) $(AS) $(INCDIR) $(MODULE_INCDIR) $(EXTRA_INCDIR) $(SDK_INCDIR) $(CFLAGS) -c $$< -o $$@ -$1/%.o: %.S - $(vecho) "AS $$<" - $(Q) $(AS) $(INCDIR) $(MODULE_INCDIR) $(EXTRA_INCDIR) $(SDK_INCDIR) $(CFLAGS) -c $$< -o $$@ -$1/%.o: %.c $1/%.c.d - $(vecho) "CC $$<" - $(Q) $(CC) $(INCDIR) $(MODULE_INCDIR) $(EXTRA_INCDIR) $(SDK_INCDIR) $(CFLAGS) -c $$< -o $$@ -$1/%.o: %.cpp $1/%.cpp.d - $(vecho) "C+ $$<" - $(Q) $(CXX) $(INCDIR) $(MODULE_INCDIR) $(EXTRA_INCDIR) $(SDK_INCDIR) $(CXXFLAGS) -c $$< -o $$@ -$1/%.c.d: %.c - $(Q) $(CC) $(INCDIR) $(MODULE_INCDIR) $(EXTRA_INCDIR) $(SDK_INCDIR) $(CFLAGS) -MM -MT $1/$$*.o $$< -o $$@ -$1/%.cpp.d: %.cpp - $(Q) $(CXX) $(INCDIR) $(MODULE_INCDIR) $(EXTRA_INCDIR) $(SDK_INCDIR) $(CXXFLAGS) -MM -MT $1/$$*.o $$< -o $$@ - -.PRECIOUS: $1/%.c.d $1/%.cpp.d +# Define secondary pseudo-targets for all libraries +define UserLibrary +.PHONY $1: +$1: $(call UserLibPath,$1) endef +$(foreach lib,$(LIBS),$(eval $(call UserLibrary,$(lib)))) -.PHONY: all checkdirs clean tools $(TOOLS_DIRS) test samples-clean samples $(SAMPLES_DIRS) docs api wiki -all: checkdirs $(APP_AR) tools +# Target library (libsming) -ifeq ($(ENABLE_CUSTOM_PWM), 1) -$(USER_LIBDIR)/libpwm_open.a: third-party/pwm/pwm.c - $(Q) $(CC) $(INCDIR) $(MODULE_INCDIR) $(EXTRA_INCDIR) $(SDK_INCDIR) $(CFLAGS) -c $< -o $(dir $<)/pwm.o - $(Q) $(AR) rcs $@ $(dir $<)/pwm.o -endif - -ifeq ($(ENABLE_SSL), 1) -$(USER_LIBDIR)/libaxtls.a: - $(Q) $(MAKE) -C third-party/axtls-8266 -e V=$(V) BIN_DIR="$(SMING_HOME)/$(USER_LIBDIR)" CFLAGS_EXTRA="$(EXTRA_CFLAGS_AXTLS)" -endif - -ifeq ($(ENABLE_CUSTOM_HEAP), 1) -$(USER_LIBDIR)/libmainmm.a: $(addprefix $(SDK_LIBDIR)/,libmain.a) - $(vecho) "Enabling custom heap implementation" - $(Q) cp $^ $@ - $(Q) $(AR) -d $@ mem_manager.o -endif - -ifeq ($(ENABLE_CUSTOM_LWIP), 1) -$(USER_LIBDIR)/liblwip_%.a: third-party/esp-open-lwip/Makefile.open - $(Q) $(MAKE) -C third-party/esp-open-lwip/ -f Makefile.open ENABLE_ESPCONN=$(ENABLE_ESPCONN) SDK_BASE="$(SDK_BASE)" USER_LIBDIR="$(SMING_HOME)/$(USER_LIBDIR)/" CFLAGS_EXTRA="$(EXTRA_CFLAGS_LWIP) $(CFLAGS_COMMON)" all -endif -ifeq ($(ENABLE_CUSTOM_LWIP), 2) -$(USER_LIBDIR)/liblwip%.a: third-party/lwip2/Makefile.sming - $(Q) $(MAKE) -C third-party/lwip2/ -f Makefile.sming ENABLE_ESPCONN=$(ENABLE_ESPCONN) SDK_BASE="$(SDK_BASE)" SDK_INTERNAL="$(SDK_INTERNAL)" \ - USER_LIBDIR="$(SMING_HOME)/$(USER_LIBDIR)/" CFLAGS_EXTRA="$(EXTRA_CFLAGS_LWIP)" all -endif - -$(USER_LIBDIR)/libmqttc.a: - $(Q) $(MAKE) -C third-party/mqtt-codec MQTT_ENABLE_SERVER=0 MQTT_ENABLE_CLIENT=1 CC=$(CC) AR=$(AR) \ - CFLAGS_EXTRA="-Iinclude -I$(SDK_BASE)/include $(CFLAGS_COMMON)" \ - LIB_FOLDER="$(SMING_HOME)/$(USER_LIBDIR)/" lib +.PHONY: libsming +libsming: $(APP_AR) $(CUSTOM_TARGETS) $(APP_AR): $(OBJ) $(vecho) "AR $@" - $(Q) $(AR) cru $@ $^ + $(AR) cru $@ $^ $(vecho) "Installing $(LIBSMING)" ifeq ($(ENABLE_SSL), 1) $(vecho) "+ SSL support is enabled" @@ -432,139 +149,138 @@ endif $(Q) cp -r $(APP_AR) $(USER_LIBDIR)/$(LIBSMING).a $(vecho) "Done" -checkdirs: $(ARDUINO_LIBRARIES) $(THIRD_PARTY_DATA) reload $(BUILD_DIR) $(FW_BASE) $(CUSTOM_TARGETS) +.PHONY: checkdirs +checkdirs: libraries third-party reload | $(BUILD_DIR) $(BUILD_DIR): $(Q) mkdir -p $@ -$(FW_BASE): - $(Q) mkdir -p $@ - $(Q) mkdir -p $@/upgrade +.PHONY: dist-clean +dist-clean: clean samples-clean third-party-clean libraries-clean tools-clean user-lib-clean -clean: +.PHONY: clean +clean: $(CLEAN) $(Q) rm -f $(APP_AR) $(Q) rm -f $(TARGET_OUT) - $(Q) rm -rf $(BUILD_DIR) $(Q) rm -rf $(BUILD_BASE) - $(Q) rm -rf $(FW_BASE) -ifeq ($(ENABLE_SSL), 1) - $(Q) -$(MAKE) --no-print-directory -C third-party/axtls-8266 clean -e V=$(V) BIN_DIR="$(SMING_HOME)/$(USER_LIBDIR)" CFLAGS_EXTRA="$(EXTRA_CFLAGS_AXTLS)" -endif -ifeq ($(ENABLE_CUSTOM_LWIP), 1) - $(Q) -$(MAKE) -C third-party/esp-open-lwip/ -f Makefile.open ENABLE_ESPCONN=$(ENABLE_ESPCONN) SDK_BASE="$(SDK_BASE)" USER_LIBDIR="$(SMING_HOME)/$(USER_LIBDIR)/" CFLAGS_EXTRA="$(EXTRA_CFLAGS_LWIP)" clean -endif -ifeq ($(ENABLE_CUSTOM_LWIP), 2) - $(Q) -$(MAKE) -C third-party/lwip2/ -f Makefile.sming ENABLE_ESPCONN=$(ENABLE_ESPCONN) SDK_BASE="$(SDK_BASE)" USER_LIBDIR="$(SMING_HOME)/$(USER_LIBDIR)/" CFLAGS_EXTRA="$(EXTRA_CFLAGS_LWIP)" clean -endif +.PHONY: user-lib-clean +user-lib-clean: + -$(Q) rm -f $(wildcard $(USER_LIBDIR)/lib*.a) $(APP_AR) + $(Q) $(GIT) checkout $(USER_LIBDIR) + +.PHONY: test test: Basic_Blink Basic_rBoot Basic_Ssl Basic_HwPWM -docs/wiki/Home.md: + +# => Documentation +DOCS_DIR := ../docs + +.PHONY: wiki api docs +docs: wiki api +wiki: $(DOCS_DIR)/wiki/Home.md +api: $(DOCS_DIR)/api/sming/index.html + +$(DOCS_DIR)/wiki/Home.md: $(vecho) "No Wiki submodule found. Using git to fetch it..." - $(Q) $(GIT) submodule update --init ../docs/wiki + $(Q) $(GIT) submodule update --init $(DOCS_DIR)/wiki -docs/api/error.log: +$(DOCS_DIR)/api/error.log: ifndef DOXYGEN $(error doxygen not found - not building API docs) endif - $(Q) mkdir -p $(SMING_HOME)/../docs/api - $(Q) cd $(SMING_HOME)/../docs; doxygen 2>$(SMING_HOME)/../docs/api/stderr.log 1>$(SMING_HOME)/../docs/api/doxygen.log + $(Q) mkdir -p $(DOCS_DIR)/api + $(Q) cd $(DOCS_DIR); doxygen 2>api/stderr.log 1>api/doxygen.log -docs/api/sming/index.html: docs/api/error.log - $(vecho) "Undocumented compounds: $(shell grep "Compound.*is not documented" $(SMING_HOME)/../docs/api/error.log | wc -l)" - $(vecho) "Undocumented members: $(shell grep "Member.*is not documented" $(SMING_HOME)/../docs/api/error.log | wc -l) " - $(vecho) "Undocumented parameters: $(shell grep "The following parameters of .* are not documented" $(SMING_HOME)/../docs/api/error.log | wc -l) " - $(vecho) "Open in your browser: file://$(SMING_HOME)/../$@" +$(DOCS_DIR)/api/sming/index.html: $(DOCS_DIR)/api/error.log + $(vecho) "Undocumented compounds: $(shell grep "Compound.*is not documented" $(DOCS_DIR)/api/error.log | wc -l)" + $(vecho) "Undocumented members: $(shell grep "Member.*is not documented" $(DOCS_DIR)/api/error.log | wc -l) " + $(vecho) "Undocumented parameters: $(shell grep "The following parameters of .* are not documented" $(DOCS_DIR)/api/error.log | wc -l) " + $(vecho) "Open in your browser: file://$(abspath $@)" -wiki: docs/wiki/Home.md -api: docs/api/sming/index.html -docs: wiki api +# Apply patch to a submodule +# $1 -> patch file with relative path +define ApplyPatch + touch $1; \ + $(GIT) apply -v $1 --ignore-whitespace --whitespace=nowarn +endef -third-party/%: - $(vecho) "Fetching $(dir $@) ..." - $(Q) $(GIT) submodule update --init --recursive $(dir $@) - $(Q) if [ -f $(patsubst third-party/%/,third-party/.patches/%.patch, $(dir $@)) ]; then \ - touch $(patsubst third-party/%/,third-party/.patches/%.patch, $(dir $@)); \ - cd $(dir $@); $(GIT) apply -v $(patsubst third-party/%/,$(SMING_HOME)/third-party/.patches/%.patch, $(dir $@)) --ignore-whitespace --whitespace=nowarn; \ +# If there's a patch for this submodule, apply it +# We look for patch in .. and in ../.patches +# $1 -> submodule path +# $2 -> name of patch file +define TryApplyPatch + cd $1; \ + if [ -f ../$2 ]; then \ + $(call ApplyPatch,../$2); \ + elif [ -f ../.patches/$2 ]; then \ + $(call ApplyPatch,../.patches/$2); \ fi -# if the new submodule brings source code files that need to be compiled inside Sming -# then we need somehow to be able to "see" these new files. -# For now we solve this by "reloading" the makefile after fetching a module. +endef + +.PHONY: third-party third-party-clean +third-party: $(addsuffix /.submodule,$(SUBMODULES)) + +third-party-clean: + -$(Q) rm -rf $(SUBMODULES) + $(GIT) checkout third-party + +.PHONY: libraries libraries-clean +libraries: $(LIBRARY_SUBMODULES) + +libraries-clean: + -$(Q) rm -rf Libraries + -$(Q) rm -rf $(BUILD_BASE)/Libraries + $(GIT) checkout Libraries + +# Update and patch submodule +# Patch file is either in submodule parent directory itself or subdirectory .patches from there +%/.submodule: + $(vecho) "Fetching $(dir $@) ..." + $(Q) mkdir -p $(dir $@) + $(Q) $(GIT) submodule update --init --force --recursive $(dir $@) + $(Q) $(call TryApplyPatch,$(dir $@),$(notdir $(patsubst %/,%,$(dir $@))).patch) + $(Q) touch $@ RELOAD_MKFILE=1 -Libraries/%: - $(vecho) "Fetching Arduino Library $(dir $@) ..." - $(Q) $(GIT) submodule update --init --recursive $(dir $@) - $(Q) if [ -f $(patsubst Libraries/%/,Libraries/.patches/%.patch, $(dir $@)) ]; then \ - touch $(patsubst Libraries/%/,Libraries/.patches/%.patch, $(dir $@)); \ - cd $(dir $@); $(GIT) apply -v $(patsubst Libraries/%/,$(SMING_HOME)/Libraries/.patches/%.patch, $(dir $@)) --ignore-whitespace --whitespace=nowarn; \ - fi + # if the new submodule brings source code files that need to be compiled inside Sming # then we need somehow to be able to "see" these new files. # For now we solve this by "reloading" the makefile after fetching a module. - RELOAD_MKFILE=1 - +.PHONY: reload reload: $(Q) if [ $(RELOAD_MKFILE) -eq 1 ]; then \ + echo "Reloading..."; \ $(MAKE) -C $(SMING_HOME) $(MAKECMDGOALS) RELOAD_MKFILE=0; \ fi -samples: $(SAMPLES_DIRS) +.PHONY: samples $(SAMPLES_DIRS) samples-clean +samples: | $(SAMPLES_DIRS) $(SAMPLES_DIRS): $(Q) $(MAKE) -C $(SMING_HOME)/../samples/$@ samples-clean: - $(Q) for dir in $(SAMPLES_DIRS); do \ - $(MAKE) -C $(SMING_HOME)/../samples/$$dir clean; \ - done + -$(Q) for dir in $(SAMPLES_DIRS); do \ + $(MAKE) -C $(SMING_HOME)/../samples/$$dir clean; \ + done -third-party-clean: - $(Q) for dir in $(THIRD_PARTY_DIRS); do \ - rm -rf third-party/$$dir; \ - done - $(Q) $(GIT) checkout third-party - -libraries-clean: - $(Q) rm -rf Libraries - $(Q) $(GIT) checkout Libraries - -tools: third-party/spiffs/makefile $(TOOLS_DIRS) - -$(TOOLS_DIRS): - $(Q) if [ -d $(SMING_HOME)/../tools/$@ ]; then \ - echo "Making $@"; \ - if [ ! -e $(SMING_HOME)/../tools/$@/Makefile ]; then (cd $(SMING_HOME)/../; $(GIT) submodule update --init --recursive tools/$@/;); fi; \ - $(MAKE) --no-print-directory -C $(SMING_HOME)/../tools/$@ V=$(V); \ - fi - -tools-clean: - $(Q) for dir in $(TOOLS_DIRS); do \ - if [ ! -d $(SMING_HOME)/../tools/$$dir ]; then continue; fi; \ - $(MAKE) --no-print-directory -C $(SMING_HOME)/../tools/$$dir clean V=$(V); \ - done - -dist-clean: clean samples-clean third-party-clean libraries-clean tools-clean - $(Q) for file in $(shell ls $(USER_LIBDIR)/lib*.a ); do \ - rm $$file; \ - done - $(Q) $(GIT) checkout $(USER_LIBDIR) +.PHONY: tools tools-clean +tools: $(TOOLS) +tools-clean: $(TOOLS_CLEAN) # Recursive wildcard search +# $1 -> directory +# $2 -> file extensions rwildcard = $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d)) # Files that should follow our coding standards -CS_DIRS = SmingCore ../samples -CS_FILES := $(call rwildcard,$(patsubst %,%/*,$(CS_DIRS)),*.cpp *.h *.c) +CS_DIRS := SmingCore Platform/*/Core Platform/*/Platform ../samples +CS_FILES := $(call rwildcard,$(patsubst %,%/*,$(CS_DIRS)),*.cpp *.h *.c) +.PHONY: cs cs: $(Q) for FILE in $(CS_FILES); do \ clang-format -i -style=file $$FILE; \ done - - -$(foreach bdir,$(BUILD_DIR),$(eval $(call compile-objects,$(bdir)))) -$(foreach bdir,$(BUILD_DIR),$(eval include $(wildcard $(bdir)/*.c.d))) -$(foreach bdir,$(BUILD_DIR),$(eval include $(wildcard $(bdir)/*.cpp.d))) - diff --git a/Sming/Makefile-app.mk b/Sming/Makefile-app.mk new file mode 100644 index 0000000000..1f52225142 --- /dev/null +++ b/Sming/Makefile-app.mk @@ -0,0 +1,79 @@ +############################################################# +# +# Created by Espressif +# UDK modifications by CHERTS +# Cross platform compatability by kireevco +# +############################################################# + +### Defaults ### + +SERVER_OTA_PORT ?= 9999 + +## COM port parameters +# Default COM port speed (generic) +COM_SPEED ?= 115200 + +# Default COM port speed (used for flashing) +COM_SPEED_ESPTOOL ?= $(COM_SPEED) + +# Default COM port speed (used in code) +COM_SPEED_SERIAL ?= $(COM_SPEED) + +include $(SMING_HOME)/build.mk + +PLATFORM_BASE := $(SMING_HOME)/$(PLATFORM_BASE) +THIRD_PARTY_DIR := $(SMING_HOME)/$(THIRD_PARTY_DIR) + +BUILD_BASE := out/build +FW_BASE := out/firmware + +CURRENT_DIR := $(dir $(abspath $(firstword $(MAKEFILE_LIST)))) + +SPIFF_FILES ?= files + +#Firmware memory layout info files +FW_MEMINFO_NEW = $(FW_BASE)/fwMeminfo.new +FW_MEMINFO_OLD = $(FW_BASE)/fwMeminfo.old +FW_MEMINFO_SAVED = out/fwMeminfo + +# name for the target project +TARGET = app + +LIBSMING = sming +SMING_FEATURES = none +ifeq ($(ENABLE_SSL),1) + LIBSMING = smingssl + SMING_FEATURES = SSL +endif + +# which modules (subdirectories) of the project to include in compiling +# define your custom directories in the project's own Makefile before including this one +MODULES ?= app # default to app if not set by user +EXTRA_INCDIR ?= include # default to include if not set by user + +SMING_INCDIR := System/include Wiring Libraries SmingCore Platform/Common \ + Libraries/Adafruit_GFX Libraries/Adafruit_Sensor + +EXTRA_INCDIR += $(SMING_HOME) $(addprefix $(SMING_HOME)/,$(SMING_INCDIR)) \ + $(PLATFORM_BASE) $(PLATFORM_SYS)/include $(PLATFORM_CORE) \ + $(THIRD_PARTY_DIR) + +# we will use global WiFi settings from Eclipse Environment Variables, if possible +WIFI_SSID ?= "" +WIFI_PWD ?= "" +ifneq ($(WIFI_SSID), "") + CFLAGS += -DWIFI_SSID=\"$(WIFI_SSID)\" +endif +ifneq ($(WIFI_PWD), "") + CFLAGS += -DWIFI_PWD=\"$(WIFI_PWD)\" +endif +ifeq ($(DISABLE_SPIFFS), 1) + CFLAGS += -DDISABLE_SPIFFS=1 +endif + +# => Serial +CFLAGS += -DCOM_SPEED_SERIAL=$(COM_SPEED_SERIAL) $(USER_CFLAGS) + +include $(PLATFORM_BASE)/app.mk + diff --git a/Sming/Makefile-bsd.mk b/Sming/Makefile-bsd.mk index 3be07b2afa..ad5be5f834 100644 --- a/Sming/Makefile-bsd.mk +++ b/Sming/Makefile-bsd.mk @@ -13,4 +13,4 @@ ESPTOOL ?= $(ESP_HOME)/esptool/esptool.py KILL_TERM ?= pkill -9 -f "$(COM_PORT) $(COM_SPEED_SERIAL)" || exit 0 GET_FILESIZE ?= stat -f "%-15z" TERMINAL ?= python -m serial.tools.miniterm $(COM_PORT) $(COM_SPEED_SERIAL) $(COM_OPTS) -MEMANALYZER ?= python $(SMING_HOME)/../tools/memanalyzer.py $(OBJDUMP) \ No newline at end of file +MEMANALYZER ?= python $(PLATFORM_TOOLS)/memanalyzer.py $(OBJDUMP) \ No newline at end of file diff --git a/Sming/Makefile-linux.mk b/Sming/Makefile-linux.mk index 085878f7db..7177c820a4 100644 --- a/Sming/Makefile-linux.mk +++ b/Sming/Makefile-linux.mk @@ -13,4 +13,4 @@ ESPTOOL ?= $(ESP_HOME)/esptool/esptool.py KILL_TERM ?= pkill -9 -f "$(COM_PORT) $(COM_SPEED_SERIAL)" || exit 0 GET_FILESIZE ?= stat -c %s TERMINAL ?= python -m serial.tools.miniterm $(COM_PORT) $(COM_SPEED_SERIAL) $(COM_OPTS) -MEMANALYZER ?= python $(SMING_HOME)/../tools/memanalyzer.py $(OBJDUMP) \ No newline at end of file +MEMANALYZER ?= python $(PLATFORM_TOOLS)/memanalyzer.py $(OBJDUMP) \ No newline at end of file diff --git a/Sming/Makefile-macos.mk b/Sming/Makefile-macos.mk index 1257bcf4fa..d147abe545 100644 --- a/Sming/Makefile-macos.mk +++ b/Sming/Makefile-macos.mk @@ -13,4 +13,4 @@ ESPTOOL ?= $(ESP_HOME)/esptool/esptool.py KILL_TERM ?= pkill -9 -f "$(COM_PORT) $(COM_SPEED_SERIAL)" || exit 0 GET_FILESIZE ?= stat -L -f%z TERMINAL ?= python -m serial.tools.miniterm $(COM_PORT) $(COM_SPEED_SERIAL) $(COM_OPTS) -MEMANALYZER ?= python $(SMING_HOME)/../tools/memanalyzer.py $(OBJDUMP) \ No newline at end of file +MEMANALYZER ?= python $(PLATFORM_TOOLS)/memanalyzer.py $(OBJDUMP) \ No newline at end of file diff --git a/Sming/Makefile-project.mk b/Sming/Makefile-project.mk deleted file mode 100644 index 667a6b3223..0000000000 --- a/Sming/Makefile-project.mk +++ /dev/null @@ -1,602 +0,0 @@ -############################################################# -# -# Created by Espressif -# UDK modifications by CHERTS -# Cross platform compatability by kireevco -# -############################################################# - -$(warning !!!!======================= [ WARNING ] ====================!!!) -$(warning Non rBoot projects are deprecated and will be removed in the next releases) -$(warning If you see this warning make sure to modify your application Makefile-user.mk file and add the following line:) -$(warning RBOOT_ENABLED=1) -$(warning ========================================================================) - -### Defaults ### - -## COM port parameters -# Default COM port speed (generic) -COM_SPEED ?= 115200 - -# Default COM port speed (used for flashing) -COM_SPEED_ESPTOOL ?= $(COM_SPEED) - -# Default COM port speed (used in code) -COM_SPEED_SERIAL ?= $(COM_SPEED) - -# Disable CommandExecutor functionality if not used and save some ROM and RAM. -ENABLE_CMD_EXECUTOR ?= 1 - -## Flash parameters -# SPI_SPEED = 40, 26, 20, 80 -SPI_SPEED ?= 40 -# SPI_MODE: qio, qout, dio, dout -SPI_MODE ?= qio -# SPI_SIZE: 512K, 256K, 1M, 2M, 4M -SPI_SIZE ?= 512K - -### Debug output parameters -# By default `debugf` does not print file name and line number. If you want this enabled set the directive below to 1 -DEBUG_PRINT_FILENAME_AND_LINE ?= 0 - -# Defaut debug verbose level is INFO, where DEBUG=3 INFO=2 WARNING=1 ERROR=0 -DEBUG_VERBOSE_LEVEL ?= 2 - -# Path to spiffy -SPIFFY ?= $(SMING_HOME)/../tools/spiffy/spiffy - -#ESPTOOL2 config to generate rBootLESS images -IMAGE_MAIN ?= 0x00000.bin -IMAGE_SDK_OFFSET = $(shell printf '0x%x\n' $$(( ($$($(GET_FILESIZE) $(FW_BASE)/$(IMAGE_MAIN)) + 0x1000 + $(basename $(IMAGE_MAIN))) & (0xFFFFF000) )) ) -IMAGE_SDK ?= $(IMAGE_SDK_OFFSET).bin -IROM0_ORG0 = $(shell printf '0x%x\n' $$(( 0x40200000 + $(IMAGE_SDK_OFFSET))) ) - -INIT_BIN_ADDR = 0x7c000 -BLANK_BIN_ADDR = 0x4b000 - -# esptool2 path -ESPTOOL2 ?= $(SMING_HOME)/../tools/esptool2/esptool2 -# esptool2 parameters for rBootLESS images -ESPTOOL2_SECTS ?= .text .data .rodata -ESPTOOL2_MAIN_ARGS ?= -quiet -bin -boot0 -ESPTOOL2_SDK_ARGS ?= -quiet -lib - -# SED path -SED ?= sed - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -# MacOS / Linux -# SMING_HOME = /opt/esp-open-sdk - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -# MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -# Detect OS and build environment -UNAME := $(shell uname -s) - -ifeq ($(OS),Windows_NT) - # Convert Windows paths to POSIX paths - SMING_HOME := $(subst \,/,$(addprefix /,$(subst :,,$(SMING_HOME)))) - SMING_HOME := $(subst //,/,$(SMING_HOME)) - ESP_HOME := $(subst \,/,$(addprefix /,$(subst :,,$(ESP_HOME)))) - ESP_HOME := $(subst //,/,$(ESP_HOME)) -endif - -ifneq ($(filter MINGW32_NT%,$(UNAME)),) - UNAME := Windows -else ifneq ($(filter CYGWIN%,$(UNAME)),) - # Cygwin Detected - UNAME := Linux -else ifneq ($(filter CYGWIN%WOW,$(UNAME)),) - #Cygwin32 - UNAME := Linux -else ifneq ($(filter MSYS%WOW,$(UNAME)),) - #Msys32 - UNAME := Linux -else ifeq ($(UNAME), Linux) - #Linux -else ifeq ($(UNAME), Darwin) - #OS X -else ifeq ($(UNAME), Freebsd) - #BSD -endif - -# OS specific configuration -ifeq ($(UNAME),Windows) - # Windows detected - - # Default SMING_HOME. Can be overriden. - SMING_HOME ?= c:\tools\Sming\Sming - - # Default ESP_HOME. Can be overriden. - ESP_HOME ?= c:\Espressif - - include $(SMING_HOME)/Makefile-windows.mk -else - ifeq ($(UNAME),Darwin) - # MacOS Detected - UNAME := MacOS - - # Default SMING_HOME. Can be overriden. - SMING_HOME ?= /opt/sming/Sming - - # Default ESP_HOME. Can be overriden. - ESP_HOME ?= /opt/esp-open-sdk - - include $(SMING_HOME)/Makefile-macos.mk - endif - ifneq ($(filter CYGWIN%,$(UNAME)),) - # Cygwin Detected - UNAME := Linux - endif - ifeq ($(UNAME),Linux) - # Linux Detected - UNAME := Linux - - # Default SMING_HOME. Can be overriden. - SMING_HOME ?= /opt/sming/Sming - - # Default ESP_HOME. Can be overriden. - ESP_HOME ?= /opt/esp-open-sdk - include $(SMING_HOME)/Makefile-linux.mk - endif - ifeq ($(UNAME),FreeBSD) - # Freebsd Detected - UNAME := FreeBSD - - # Default SMING_HOME. Can be overriden. - SMING_HOME ?= /usr/local/esp8266/Sming/Sming - - # Default ESP_HOME. Can be overriden. - ESP_HOME ?= /usr/local/esp8266/esp-open-sdk - include $(SMING_HOME)/Makefile-bsd.mk - endif -endif - -export COMPILE := gcc -export PATH := $(ESP_HOME)/xtensa-lx106-elf/bin:$(PATH) -XTENSA_TOOLS_ROOT := $(ESP_HOME)/xtensa-lx106-elf/bin - -CURRENT_DIR := $(dir $(abspath $(firstword $(MAKEFILE_LIST)))) - -SPIFF_FILES ?= files - -BUILD_BASE = out/build -FW_BASE = out/firmware - -# The line below calculates the next available sector after the IMAGE_SDK ROM. -# The math is the following: next_available_sector_start = (( address + size ) + one_sector_size) & 0xFFFFF000 -# 0x01000 is the size of one sector -# IMAGE_SDK contains starting address of the irom0 section and its size -# 0xFFFF000 mask that is used to show the start of a sector -SPIFF_START_OFFSET = $(shell printf '0x%X\n' $$(( ($$($(GET_FILESIZE) $(FW_BASE)/$(IMAGE_SDK)) + 0x1000 + $(basename $(IMAGE_SDK))) & (0xFFFFF000) )) ) - -#Firmware memory layout info files -FW_MEMINFO_NEW = $(FW_BASE)/fwMeminfo.new -FW_MEMINFO_OLD = $(FW_BASE)/fwMeminfo.old -FW_MEMINFO_SAVED = out/fwMeminfo - -# name for the target project -TARGET = app - -THIRD_PARTY_DIR = $(SMING_HOME)/third-party - -SMING_FEATURES = none -LIBSMING = sming -ifeq ($(ENABLE_SSL),1) - LIBSMING = smingssl - SMING_FEATURES = SSL -endif - -# which modules (subdirectories) of the project to include in compiling -# define your custom directories in the project's own Makefile before including this one -MODULES ?= app # default to app if not set by user -EXTRA_INCDIR ?= include # default to include if not set by user -MODULES += $(SMING_HOME)/appspecific/gdb - -ENABLE_CUSTOM_LWIP ?= 1 -LWIP_INCDIR = $(SMING_HOME)/system/esp-lwip/lwip/include -ifeq ($(ENABLE_CUSTOM_LWIP), 1) - LWIP_INCDIR = $(SMING_HOME)/third-party/esp-open-lwip/include -else ifeq ($(ENABLE_CUSTOM_LWIP), 2) - LWIP_INCDIR = $(SMING_HOME)/third-party/lwip2/glue-esp/include-esp $(SMING_HOME)/third-party/lwip2/include -endif - -EXTRA_INCDIR += $(SMING_HOME)/include $(SMING_HOME)/ $(LWIP_INCDIR) $(SMING_HOME)/system/include \ - $(SMING_HOME)/Wiring $(SMING_HOME)/Libraries \ - $(SMING_HOME)/Libraries/Adafruit_GFX $(SMING_HOME)/Libraries/Adafruit_Sensor \ - $(SMING_HOME)/SmingCore $(SMING_HOME)/Services/SpifFS $(SDK_BASE)/../include \ - $(THIRD_PARTY_DIR)/rboot $(THIRD_PARTY_DIR)/rboot/appcode $(THIRD_PARTY_DIR)/spiffs/src - -ENABLE_CUSTOM_HEAP ?= 0 - -USER_LIBDIR = $(SMING_HOME)/compiler/lib/ - -LIBMAIN = main -ifeq ($(ENABLE_CUSTOM_HEAP),1) - LIBMAIN = mainmm -endif - -LIBLWIP = lwip -ifeq ($(ENABLE_CUSTOM_LWIP), 1) - LIBLWIP = lwip_open - ifeq ($(ENABLE_ESPCONN), 1) - LIBLWIP = lwip_full - endif - CUSTOM_TARGETS += $(USER_LIBDIR)/lib$(LIBLWIP).a -endif -ifeq ($(ENABLE_CUSTOM_LWIP), 2) - ifeq ($(ENABLE_ESPCONN), 1) -$(error LWIP2 does not support espconn_* functions. Make sure to set ENABLE_CUSTOM_LWIP to 0 or 1.) - endif - LIBLWIP = lwip2 - CUSTOM_TARGETS += $(USER_LIBDIR)/liblwip2.a -endif - -LIBPWM = pwm - -ENABLE_CUSTOM_PWM ?= 1 -ifeq ($(ENABLE_CUSTOM_PWM), 1) - LIBPWM = pwm_open - CUSTOM_TARGETS += $(USER_LIBDIR)/lib$(LIBPWM).a -endif - -# libraries used in this project, mainly provided by the SDK -LIBS = microc microgcc hal phy pp net80211 $(LIBLWIP) mqttc wpa $(LIBSMING) $(LIBMAIN) crypto $(LIBPWM) smartconfig $(EXTRA_LIBS) -ifeq ($(ENABLE_WPS),1) - LIBS += wps -endif - -# compiler flags using during compilation of source files -CFLAGS = -Wall -Wundef -Wpointer-arith -Wno-comment -Wl,-EL -nostdlib -mlongcalls -mtext-section-literals -finline-functions -fdata-sections -ffunction-sections \ - -D__ets__ -DICACHE_FLASH -DARDUINO=106 -DCOM_SPEED_SERIAL=$(COM_SPEED_SERIAL) $(USER_CFLAGS) -DENABLE_CMD_EXECUTOR=$(ENABLE_CMD_EXECUTOR) -DSMING_INCLUDED=1 -ifneq ($(STRICT),1) -CFLAGS += -Werror -Wno-sign-compare -Wno-parentheses -Wno-unused-variable -Wno-unused-but-set-variable -Wno-strict-aliasing -Wno-return-type -Wno-maybe-uninitialized -endif - -# => SDK -ifneq (,$(findstring third-party/ESP8266_NONOS_SDK, $(SDK_BASE))) - CFLAGS += -DSDK_INTERNAL -endif - -ifeq ($(ENABLE_GDB), 1) - CFLAGS += -ggdb -DENABLE_GDB=1 - MODULES += $(SMING_HOME)/gdb -endif - -ifeq ($(SMING_RELEASE),1) - # See: https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html - # for full list of optimization options - CFLAGS += -Os -DSMING_RELEASE=1 -else ifeq ($(ENABLE_GDB), 1) - CFLAGS += -Og -else - CFLAGS += -Os -g -endif - -ifeq ($(ENABLE_WPS),1) - CFLAGS += -DENABLE_WPS=1 -endif - -# Flags for compatability with old versions (most of them should disappear with the next major release) -ifdef MQTT_NO_COMPAT - CFLAGS += -DMQTT_NO_COMPAT=1 -endif - -#Append debug options -CFLAGS += -DCUST_FILE_BASE=$$* -DDEBUG_VERBOSE_LEVEL=$(DEBUG_VERBOSE_LEVEL) -DDEBUG_PRINT_FILENAME_AND_LINE=$(DEBUG_PRINT_FILENAME_AND_LINE) - -CXXFLAGS = $(CFLAGS) -fno-rtti -fno-exceptions -std=c++11 -felide-constructors - -# SSL support using axTLS -ifeq ($(ENABLE_SSL),1) - LIBS += axtls - EXTRA_INCDIR += $(THIRD_PARTY_DIR)/axtls-8266 $(THIRD_PARTY_DIR)/axtls-8266/ssl $(THIRD_PARTY_DIR)/axtls-8266/crypto - AXTLS_FLAGS = -DLWIP_RAW=1 -DENABLE_SSL=1 - ifeq ($(SSL_DEBUG),1) # - AXTLS_FLAGS += -DSSL_DEBUG=1 -DDEBUG_TLS_MEM=1 - endif - - CUSTOM_TARGETS += include/ssl/private_key.h - CFLAGS += $(AXTLS_FLAGS) - CXXFLAGS += $(AXTLS_FLAGS) -endif - -# we will use global WiFi settings from Eclipse Environment Variables, if possible -WIFI_SSID ?= "" -WIFI_PWD ?= "" -ifneq ($(WIFI_SSID), "") - CFLAGS += -DWIFI_SSID=\"$(WIFI_SSID)\" -endif -ifneq ($(WIFI_PWD), "") - CFLAGS += -DWIFI_PWD=\"$(WIFI_PWD)\" -endif -ifeq ($(DISABLE_SPIFFS), 1) - CFLAGS += -DDISABLE_SPIFFS=1 -endif - -# linker flags used to generate the main object file -LDFLAGS = -nostdlib -u call_user_start -u custom_crash_callback \ - -Wl,-static -Wl,--gc-sections -Wl,-Map=$(FW_BASE)/firmware.map -Wl,-wrap,system_restart_local - -# linker script used for the above linkier step -LD_PATH = $(SMING_HOME)/compiler/ld -PROJECT_LD_PATH=ld - -LD_SCRIPT = standalone.rom.ld - -ifeq ($(SPI_SPEED), 26) - flashimageoptions = -ff 26m -else ifeq ($(SPI_SPEED), 20) - flashimageoptions = -ff 20m -else ifeq ($(SPI_SPEED), 80) - flashimageoptions = -ff 80m -else - flashimageoptions = -ff 40m -endif - -ifeq ($(SPI_MODE), qout) - flashimageoptions += -fm qout -else ifeq ($(SPI_MODE), dio) - flashimageoptions += -fm dio -else ifeq ($(SPI_MODE), dout) - flashimageoptions += -fm dout -else - flashimageoptions += -fm qio -endif - -# flash larger than 1024KB only use 1024KB to storage user1.bin and user2.bin -ifeq ($(SPI_SIZE), 256K) - flashimageoptions += -fs 2m - SPIFF_SIZE ?= 131072 #128K -else ifeq ($(SPI_SIZE), 1M) - flashimageoptions += -fs 8m - SPIFF_SIZE ?= 524288 #512K - INIT_BIN_ADDR = 0x0fc000 - BLANK_BIN_ADDR = 0x0fe000 -else ifeq ($(SPI_SIZE), 2M) - flashimageoptions += -fs 16m - SPIFF_SIZE ?= 524288 #512K - INIT_BIN_ADDR = 0x1fc000 - BLANK_BIN_ADDR = 0x1fe000 -else ifeq ($(SPI_SIZE), 4M) - flashimageoptions += -fs 32m - SPIFF_SIZE ?= 524288 #512K - INIT_BIN_ADDR = 0x3fc000 - BLANK_BIN_ADDR = 0x3fe000 -else - flashimageoptions += -fs 4m - SPIFF_SIZE ?= 196608 #192K -endif - -# various paths from the SDK used in this project -SDK_LIBDIR = lib -SDK_LDDIR = ld -SDK_INCDIR = include - -# select which tools to use as assembler, compiler, librarian and linker -AS := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-gcc -CC := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-gcc -CXX := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-g++ -AR := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-ar -LD := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-gcc -OBJCOPY := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-objcopy -OBJDUMP := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-objdump - -SRC_DIR := $(MODULES) -BUILD_DIR := $(addprefix $(BUILD_BASE)/,$(MODULES)) - -SDK_LIBDIR := $(addprefix $(SDK_BASE)/,$(SDK_LIBDIR)) -SDK_INCDIR := $(addprefix -I$(SDK_BASE)/,$(SDK_INCDIR)) - -C_SRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.c)) -CXX_SRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.cpp)) - -C_OBJ := $(patsubst %.c,$(BUILD_BASE)/%.o,$(C_SRC)) -CXX_OBJ := $(patsubst %.cpp,$(BUILD_BASE)/%.o,$(CXX_SRC)) - -AS_SRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.s)) -AS_OBJ := $(patsubst %.s,$(BUILD_BASE)/%.o,$(AS_SRC)) -AS_SRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.S)) -AS_OBJ += $(patsubst %.S,$(BUILD_BASE)/%.o,$(AS_SRC)) - -OBJ := $(AS_OBJ) $(C_OBJ) $(CXX_OBJ) - -LIBS := $(addprefix -l,$(LIBS)) -APP_AR := $(addprefix $(BUILD_BASE)/,$(TARGET)_app.a) -TARGET_OUT := $(addprefix $(BUILD_BASE)/,$(TARGET).out) - -SPIFF_BIN_OUT ?= spiff_rom -SPIFF_BIN_OUT := $(FW_BASE)/$(SPIFF_BIN_OUT).bin - -INCDIR := $(addprefix -I,$(SRC_DIR)) -EXTRA_INCDIR := $(addprefix -I,$(EXTRA_INCDIR)) -MODULE_INCDIR := $(addsuffix /include,$(INCDIR)) - -V ?= $(VERBOSE) -ifeq ("$(V)","1") -Q := -vecho := @true -else -Q := @ -vecho := @echo -endif - - -define compile-objects -${BUILD_BASE}/$1/%.o: $1/%.s - $(vecho) "AS $$<" - $(Q) $(AS) $(INCDIR) $(MODULE_INCDIR) $(EXTRA_INCDIR) $(SDK_INCDIR) $(CFLAGS) -c $$< -o $$@ -${BUILD_BASE}/$1/%.o: $1/%.S - $(vecho) "AS $$<" - $(Q) $(AS) $(INCDIR) $(MODULE_INCDIR) $(EXTRA_INCDIR) $(SDK_INCDIR) $(CFLAGS) -c $$< -o $$@ -${BUILD_BASE}/$1/%.o: $1/%.c ${BUILD_BASE}/$1/%.c.d - $(vecho) "CC $$<" - $(Q) $(CC) $(INCDIR) $(MODULE_INCDIR) $(EXTRA_INCDIR) $(SDK_INCDIR) $(CFLAGS) -c $$< -o $$@ -${BUILD_BASE}/$1/%.o: $1/%.cpp ${BUILD_BASE}/$1/%.cpp.d - $(vecho) "C+ $$<" - $(Q) $(CXX) $(INCDIR) $(MODULE_INCDIR) $(EXTRA_INCDIR) $(SDK_INCDIR) $(CXXFLAGS) -c $$< -o $$@ -${BUILD_BASE}/$1/%.c.d: $1/%.c - $(Q) $(CC) $(INCDIR) $(MODULE_INCDIR) $(EXTRA_INCDIR) $(SDK_INCDIR) $(CFLAGS) -MM -MT $1/$$*.o $$< -o $$@ -${BUILD_BASE}/$1/%.cpp.d: $1/%.cpp - $(Q) $(CXX) $(INCDIR) $(MODULE_INCDIR) $(EXTRA_INCDIR) $(SDK_INCDIR) $(CXXFLAGS) -MM -MT $1/$$*.o $$< -o $$@ - -.PRECIOUS: ${BUILD_BASE}/$1/%.c.d ${BUILD_BASE}/$1/%.cpp.d -endef - -.PHONY: all checkdirs spiff_update spiff_clean clean - -all: $(USER_LIBDIR)/lib$(LIBSMING).a checkdirs $(TARGET_OUT) $(SPIFF_BIN_OUT) $(FW_FILE_1) $(FW_FILE_2) - -spiff_update: spiff_clean $(SPIFF_BIN_OUT) - -$(PROJECT_LD_PATH)/$(LD_SCRIPT): - $(Q) mkdir -p $(PROJECT_LD_PATH) - $(Q) cp $(LD_PATH)/$(LD_SCRIPT) $@ - -$(FW_BASE)/$(IMAGE_MAIN): $(APP_AR) -# Pass 1: Generate rom0 to be able to check its size - $(Q) $(LD) -L$(USER_LIBDIR) -L$(SDK_LIBDIR) -L$(LD_PATH) -T$(LD_SCRIPT) $(LDFLAGS) -Wl,--start-group $(LIBS) $(APP_AR) -Wl,--end-group -o $(TARGET_OUT).tmp - - $(Q) $(ESPTOOL2) $(ESPTOOL2_MAIN_ARGS) $(TARGET_OUT).tmp $@ $(ESPTOOL2_SECTS) - - $(Q) rm $(TARGET_OUT).tmp - -$(TARGET_OUT): $(FW_BASE)/$(IMAGE_MAIN) $(PROJECT_LD_PATH)/$(LD_SCRIPT) - $(vecho) "LD $@" - -# Readjust linker - $(Q) $(SED) -r "s/(^\s*irom0_0_seg *: *).*/\\1org = $(IROM0_ORG0), len = \(1M - $(IMAGE_SDK_OFFSET)\)/" $(LD_PATH)/$(LD_SCRIPT) > $(PROJECT_LD_PATH)/$(LD_SCRIPT) - -# Pass 2: Generate roms with correct offsets - $(Q) $(LD) -L$(USER_LIBDIR) -L$(SDK_LIBDIR) -L$(PROJECT_LD_PATH) -L$(LD_PATH) -T$(LD_SCRIPT) $(LDFLAGS) -Wl,--start-group $(LIBS) $(APP_AR) -Wl,--end-group -o $@ - - $(vecho) "" - $(vecho) "#Memory / Section info:" - $(vecho) "------------------------------------------------------------------------------" -#Check for existing old meminfo file and move it to /out/firmware as the infofile from previous build - $(Q) if [ -f "$(FW_MEMINFO_SAVED)" ]; then \ - mv $(FW_MEMINFO_SAVED) $(FW_MEMINFO_OLD); \ - fi - - $(Q) $(MEMANALYZER) $@ > $(FW_MEMINFO_NEW) - - $(Q) if [ -f "$(FW_MEMINFO_NEW)" -a -f "$(FW_MEMINFO_OLD)" ]; then \ - awk -F "|" 'FILENAME == "$(FW_MEMINFO_OLD)" { arr[$$1]=$$5 } FILENAME == "$(FW_MEMINFO_NEW)" { if (arr[$$1] != $$5){printf "%s (%+d)\n", $$0,$$5 - arr[$$1] } else {printf "%s\n", $$0} }' $(FW_MEMINFO_OLD) $(FW_MEMINFO_NEW); \ - elif [ -f "$(FW_MEMINFO_NEW)" ]; then \ - cat $(FW_MEMINFO_NEW); \ - fi - - $(vecho) "------------------------------------------------------------------------------" - $(vecho) "# Generating image..." -# $(Q) $(ESPTOOL2) elf2image $@ $(flashimageoptions) -o $(FW_BASE)/ - $(Q) $(ESPTOOL2) $(ESPTOOL2_MAIN_ARGS) $@ $(FW_BASE)/$(IMAGE_MAIN) $(ESPTOOL2_SECTS) - $(Q) $(ESPTOOL2) $(ESPTOOL2_SDK_ARGS) $@ $(FW_BASE)/$(IMAGE_SDK) - $(vecho) "Generate firmware images successully in folder $(FW_BASE)." - $(vecho) "Done" - -$(APP_AR): $(OBJ) - $(vecho) "AR $@" - $(Q) test ! -f $@ || rm $@ - $(Q) $(AR) rcsP $@ $^ - -$(USER_LIBDIR)/lib$(LIBSMING).a: - $(vecho) "(Re)compiling Sming. Enabled features: $(SMING_FEATURES). This may take some time" - $(Q) $(MAKE) -C $(SMING_HOME) clean V=$(V) ENABLE_SSL=$(ENABLE_SSL) SMING_HOME=$(SMING_HOME) - $(Q) $(MAKE) -C $(SMING_HOME) V=$(V) ENABLE_SSL=$(ENABLE_SSL) SMING_HOME=$(SMING_HOME) - -include/ssl/private_key.h: - $(vecho) "Generating unique certificate and key. This may take some time" - $(Q) mkdir -p $(CURRENT_DIR)/include/ssl/ - $(Q) AXDIR=$(CURRENT_DIR)/include/ssl/ $(THIRD_PARTY_DIR)/axtls-8266/tools/make_certs.sh - -ifeq ($(ENABLE_CUSTOM_PWM), 1) -$(USER_LIBDIR)/libpwm_open.a: - $(Q) $(MAKE) -C $(SMING_HOME) compiler/lib/libpwm_open.a ENABLE_CUSTOM_PWM=1 -endif - -$(USER_LIBDIR)/liblwip%.a: - $(Q) $(MAKE) -C $(SMING_HOME) compiler/lib/$(notdir $@) \ - ENABLE_CUSTOM_LWIP=$(ENABLE_CUSTOM_LWIP) \ - ENABLE_ESPCONN=$(ENABLE_ESPCONN) - -checkdirs: $(BUILD_DIR) $(FW_BASE) $(CUSTOM_TARGETS) - -$(BUILD_DIR): - $(Q) mkdir -p $@ - -$(FW_BASE): - $(Q) mkdir -p $@ - -spiff_clean: - $(vecho) "Cleaning $(SPIFF_BIN_OUT)" - $(Q) rm -rf $(SPIFF_BIN_OUT) - -$(SPIFF_BIN_OUT): -ifeq ($(DISABLE_SPIFFS), 1) - $(vecho) "(!) Spiffs support disabled. Remove 'DISABLE_SPIFFS' make argument to enable spiffs." -else - # Generating spiffs_bin - $(vecho) "Checking for spiffs files" - $(Q) if [ -d "$(SPIFF_FILES)" ]; then \ - echo "$(SPIFF_FILES) directory exists. Creating $(SPIFF_BIN_OUT)"; \ - $(SPIFFY) $(SPIFF_SIZE) $(SPIFF_FILES) $(SPIFF_BIN_OUT); \ - else \ - echo "No files found in ./$(SPIFF_FILES)."; \ - echo "Creating empty $(SPIFF_BIN_OUT)"; \ - $(SPIFFY) $(SPIFF_SIZE) dummy.dir $(SPIFF_BIN_OUT); \ - fi - $(vecho) "$(SPIFF_BIN_OUT)---------->$(SPIFF_START_OFFSET)" -endif - -flash: all - $(vecho) "Killing Terminal to free $(COM_PORT)" - -$(Q) $(KILL_TERM) -ifeq ($(DISABLE_SPIFFS), 1) - $(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED_ESPTOOL) write_flash $(flashimageoptions) $(basename $(IMAGE_MAIN)) $(FW_BASE)/$(IMAGE_MAIN) $(IMAGE_SDK_OFFSET) $(FW_BASE)/$(IMAGE_SDK) -else - $(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED_ESPTOOL) write_flash $(flashimageoptions) $(basename $(IMAGE_MAIN)) $(FW_BASE)/$(IMAGE_MAIN) $(IMAGE_SDK_OFFSET) $(FW_BASE)/$(IMAGE_SDK) $(SPIFF_START_OFFSET) $(SPIFF_BIN_OUT) -endif - $(TERMINAL) - -terminal: - $(vecho) "Killing Terminal to free $(COM_PORT)" - -$(Q) $(KILL_TERM) - $(TERMINAL) - -flashinit: - $(vecho) "Flash init data default and blank data." - $(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED_ESPTOOL) erase_flash - $(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED_ESPTOOL) write_flash $(flashimageoptions) $(INIT_BIN_ADDR) $(SDK_BASE)/bin/esp_init_data_default.bin $(BLANK_BIN_ADDR) $(SDK_BASE)/bin/blank.bin $(SPIFF_START_OFFSET) $(SMING_HOME)/compiler/data/blankfs.bin - -rebuild: clean all - -clean: -#preserve meminfo file from /out/firmware to /out/ - $(Q) if [ -f "$(FW_MEMINFO_NEW)" ]; then \ - mv $(FW_MEMINFO_NEW) $(FW_MEMINFO_SAVED); \ - fi -#remove build artifacts - $(Q) rm -f $(APP_AR) - $(Q) rm -f $(TARGET_OUT) - $(Q) rm -rf $(BUILD_DIR) - $(Q) rm -rf $(BUILD_BASE) - $(Q) rm -rf $(FW_BASE) - -$(foreach mod,$(MODULES),$(eval $(call compile-objects,$(mod)))) -$(foreach bdir,$(BUILD_DIR),$(eval include $(wildcard $(bdir)/*.c.d))) -$(foreach bdir,$(BUILD_DIR),$(eval include $(wildcard $(bdir)/*.cpp.d))) diff --git a/Sming/Makefile-rboot.mk b/Sming/Makefile-rboot.mk index 5b4842688b..7f77207ead 100644 --- a/Sming/Makefile-rboot.mk +++ b/Sming/Makefile-rboot.mk @@ -1,706 +1 @@ -############################################################# -# -# Created by Espressif -# UDK modifications by CHERTS -# Cross platform compatability by kireevco -# -############################################################# - -### Defaults ### - -SERVER_OTA_PORT ?= 9999 - -# rBoot options, overwrite them in the projects Makefile-user.mk -RBOOT_BIG_FLASH ?= 1 -RBOOT_TWO_ROMS ?= 0 -RBOOT_RTC_ENABLED ?= 0 -RBOOT_GPIO_ENABLED ?= 0 -# RBOOT_GPIO_SKIP_ENABLED and RBOOT_GPIO_ENABLED cannot be used at the same time. -RBOOT_GPIO_SKIP_ENABLED ?= 0 - -ifeq ($(RBOOT_GPIO_ENABLED)$(RBOOT_GPIO_SKIP_ENABLED),11) - $(error "Cannot enable RBOOT_GPIO_ENABLED and RBOOT_GPIO_SKIP_ENABLED at the same time) -endif - -### ROM Addresses ### -# The parameter below specifies the location of the second rom. -# This parameter is used only when RBOOT_BIG_FLASH = 1 -# BOOT_ROM1_ADDR = 0x200000 - -# The parameter below specifies the location of the GPIO ROM. -# This parameter is used only when RBOOT_GPIO_ENABLED = 1 -# If you use two SPIFFS make sure that this address is minimum -# RBOOT_SPIFFS_1 + SPIFF_SIZE -# BOOT_ROM2_ADDR = 0x310000 - -RBOOT_ROM_0 ?= rom0 -RBOOT_ROM_1 ?= rom1 -RBOOT_SPIFFS_0 ?= 0x100000 -RBOOT_SPIFFS_1 ?= 0x300000 -RBOOT_LD_0 ?= rboot.rom0.ld -RBOOT_LD_1 ?= rom1.ld -# esptool2 path -ESPTOOL2 ?= $(SMING_HOME)/../tools/esptool2/esptool2 -# path to spiffy -SPIFFY ?= $(SMING_HOME)/../tools/spiffy/spiffy -INIT_BIN_ADDR = 0x7c000 -BLANK_BIN_ADDR = 0x4b000 -# filenames and options for generating rBoot rom images with esptool2 -RBOOT_E2_SECTS ?= .text .data .rodata -RBOOT_E2_USER_ARGS ?= -quiet -bin -boot2 -# GDB path -GDB ?= $(ESP_HOME)/xtensa-lx106-elf/bin/xtensa-lx106-elf-gdb - -## COM port parameters -# Default COM port speed (generic) -COM_SPEED ?= 115200 - -# Default COM port speed (used for flashing) -COM_SPEED_ESPTOOL ?= $(COM_SPEED) - -# Default COM port speed (used in code) -COM_SPEED_SERIAL ?= $(COM_SPEED) - -## Flash parameters -# SPI_SPEED = 40, 26, 20, 80 -SPI_SPEED ?= 40 -# SPI_MODE: qio, qout, dio, dout -SPI_MODE ?= qio -# SPI_SIZE: 512K, 256K, 1M, 2M, 4M -SPI_SIZE ?= 512K - -### Debug output parameters -# By default `debugf` does not print file name and line number. If you want this enabled set the directive below to 1 -DEBUG_PRINT_FILENAME_AND_LINE ?= 0 - -# Defaut debug verbose level is INFO, where DEBUG=3 INFO=2 WARNING=1 ERROR=0 -DEBUG_VERBOSE_LEVEL ?= 2 - -# Disable CommandExecutor functionality if not used and save some ROM and RAM -ENABLE_CMD_EXECUTOR ?= 1 - -## ESP_HOME sets the path where ESP tools and SDK are located. -## Windows: -# ESP_HOME = c:/Espressif - -## MacOS / Linux: -# ESP_HOME = /opt/esp-open-sdk - -## SMING_HOME sets the path where Sming framework is located. -## Windows: -# SMING_HOME = c:/tools/sming/Sming - -# MacOS / Linux -# SMING_HOME = /opt/esp-open-sdk - -## COM port parameter is reqruied to flash firmware correctly. -## Windows: -# COM_PORT = COM3 - -# MacOS / Linux: -# COM_PORT = /dev/tty.usbserial - -# Detect OS and build environment -UNAME := $(shell uname -s) - -ifeq ($(OS),Windows_NT) - # Convert Windows paths to POSIX paths - SMING_HOME := $(subst \,/,$(addprefix /,$(subst :,,$(SMING_HOME)))) - SMING_HOME := $(subst //,/,$(SMING_HOME)) - ESP_HOME := $(subst \,/,$(addprefix /,$(subst :,,$(ESP_HOME)))) - ESP_HOME := $(subst //,/,$(ESP_HOME)) -endif - -ifneq ($(filter MINGW32_NT%,$(UNAME)),) - UNAME := Windows -else ifneq ($(filter CYGWIN%,$(UNAME)),) - # Cygwin Detected - UNAME := Linux -else ifneq ($(filter CYGWIN%WOW,$(UNAME)),) - #Cygwin32 - UNAME := Linux -else ifneq ($(filter MSYS%WOW,$(UNAME)),) - #Msys32 - UNAME := Linux -else ifeq ($(UNAME), Linux) - #Linux -else ifeq ($(UNAME), Darwin) - #OS X -else ifeq ($(UNAME), Freebsd) - #BSD -endif - -# OS specific configuration -ifeq ($(UNAME),Windows) - # Windows detected - - # Default SMING_HOME. Can be overriden. - SMING_HOME ?= c:\tools\Sming\Sming - - # Default ESP_HOME. Can be overriden. - ESP_HOME ?= c:\Espressif - - include $(SMING_HOME)/Makefile-windows.mk -else - ifeq ($(UNAME),Darwin) - # MacOS Detected - UNAME := MacOS - - # Default SMING_HOME. Can be overriden. - SMING_HOME ?= /opt/sming/Sming - - # Default ESP_HOME. Can be overriden. - ESP_HOME ?= /opt/esp-open-sdk - - include $(SMING_HOME)/Makefile-macos.mk - endif - ifneq ($(filter CYGWIN%,$(UNAME)),) - # Cygwin Detected - UNAME := Linux - endif - ifeq ($(UNAME),Linux) - # Linux Detected - UNAME := Linux - - # Default SMING_HOME. Can be overriden. - SMING_HOME ?= /opt/sming/Sming - - # Default ESP_HOME. Can be overriden. - ESP_HOME ?= /opt/esp-open-sdk - include $(SMING_HOME)/Makefile-linux.mk - endif - ifeq ($(UNAME),FreeBSD) - # Freebsd Detected - UNAME := FreeBSD - - # Default SMING_HOME. Can be overriden. - SMING_HOME ?= /usr/local/esp8266/Sming/Sming - - # Default ESP_HOME. Can be overriden. - ESP_HOME ?= /usr/local/esp8266/esp-open-sdk - include $(SMING_HOME)/Makefile-bsd.mk - endif -endif - -export COMPILE := gcc -export PATH := $(ESP_HOME)/xtensa-lx106-elf/bin:$(PATH) -XTENSA_TOOLS_ROOT := $(ESP_HOME)/xtensa-lx106-elf/bin - -CURRENT_DIR := $(dir $(abspath $(firstword $(MAKEFILE_LIST)))) - -SPIFF_FILES ?= files - -BUILD_BASE = out/build -FW_BASE = out/firmware - -#Firmware memory layout info files -FW_MEMINFO_NEW = $(FW_BASE)/fwMeminfo.new -FW_MEMINFO_OLD = $(FW_BASE)/fwMeminfo.old -FW_MEMINFO_SAVED = out/fwMeminfo - -RBOOT_ROM_0 := $(addprefix $(FW_BASE)/,$(RBOOT_ROM_0).bin) -RBOOT_ROM_1 := $(addprefix $(FW_BASE)/,$(RBOOT_ROM_1).bin) -RBOOT_SILENT ?= 0 - -# name for the target project -TARGET = app - -THIRD_PARTY_DIR = $(SMING_HOME)/third-party - -LIBSMING = sming -SMING_FEATURES = none -ifeq ($(ENABLE_SSL),1) - LIBSMING = smingssl - SMING_FEATURES = SSL -endif - -# which modules (subdirectories) of the project to include in compiling -# define your custom directories in the project's own Makefile before including this one -MODULES ?= app # default to app if not set by user -MODULES += $(THIRD_PARTY_DIR)/rboot/appcode -MODULES += $(SMING_HOME)/appspecific/rboot -MODULES += $(SMING_HOME)/appspecific/gdb -EXTRA_INCDIR ?= include # default to include if not set by user - -ENABLE_CUSTOM_LWIP ?= 1 -LWIP_INCDIR = $(SMING_HOME)/system/esp-lwip/lwip/include -ifeq ($(ENABLE_CUSTOM_LWIP), 1) - LWIP_INCDIR = $(SMING_HOME)/third-party/esp-open-lwip/include -else ifeq ($(ENABLE_CUSTOM_LWIP), 2) - LWIP_INCDIR = $(SMING_HOME)/third-party/lwip2/glue-esp/include-esp $(SMING_HOME)/third-party/lwip2/include -endif - -EXTRA_INCDIR += $(SMING_HOME)/include $(SMING_HOME)/ $(LWIP_INCDIR) $(SMING_HOME)/system/include \ - $(SMING_HOME)/Wiring $(SMING_HOME)/Libraries \ - $(SMING_HOME)/Libraries/Adafruit_GFX $(SMING_HOME)/Libraries/Adafruit_Sensor \ - $(SMING_HOME)/SmingCore $(SMING_HOME)/Services/SpifFS $(SDK_BASE)/../include \ - $(THIRD_PARTY_DIR)/rboot $(THIRD_PARTY_DIR)/rboot/appcode $(THIRD_PARTY_DIR)/spiffs/src - -USER_LIBDIR = $(SMING_HOME)/compiler/lib/ - -# compiler flags using during compilation of source files -CFLAGS = -Wall -Wundef -Wpointer-arith -Wno-comment -Wl,-EL -nostdlib -mlongcalls -mtext-section-literals -finline-functions -fdata-sections -ffunction-sections \ - -D__ets__ -DICACHE_FLASH -DARDUINO=106 -DCOM_SPEED_SERIAL=$(COM_SPEED_SERIAL) $(USER_CFLAGS) -DENABLE_CMD_EXECUTOR=$(ENABLE_CMD_EXECUTOR) -DSMING_INCLUDED=1 -ifneq ($(STRICT),1) -CFLAGS += -Werror -Wno-sign-compare -Wno-parentheses -Wno-unused-variable -Wno-unused-but-set-variable -Wno-strict-aliasing -Wno-return-type -Wno-maybe-uninitialized -endif - -# => SDK -ifneq (,$(findstring third-party/ESP8266_NONOS_SDK, $(SDK_BASE))) - CFLAGS += -DSDK_INTERNAL -endif - -ifeq ($(ENABLE_GDB), 1) - CFLAGS += -ggdb -DENABLE_GDB=1 - MODULES += $(SMING_HOME)/gdb - GDB_SYMBOLS := gdb_symbols -endif - -ifeq ($(SMING_RELEASE),1) - # See: https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html - # for full list of optimization options - CFLAGS += -Os -DSMING_RELEASE=1 -else ifeq ($(ENABLE_GDB), 1) - CFLAGS += -Og -else - CFLAGS += -Os -g -endif - -ifeq ($(ENABLE_WPS),1) - CFLAGS += -DENABLE_WPS=1 -endif - -# Flags for compatability with old versions (most of them should disappear with the next major release) -ifeq ($(MQTT_NO_COMPAT),1) - CFLAGS += -DMQTT_NO_COMPAT=1 -endif - -#Append debug options -CFLAGS += -DCUST_FILE_BASE=$$* -DDEBUG_VERBOSE_LEVEL=$(DEBUG_VERBOSE_LEVEL) -DDEBUG_PRINT_FILENAME_AND_LINE=$(DEBUG_PRINT_FILENAME_AND_LINE) -CXXFLAGS = $(CFLAGS) -fno-rtti -fno-exceptions -std=c++11 -felide-constructors - -ENABLE_CUSTOM_HEAP ?= 0 - -LIBMAIN = main -ifeq ($(ENABLE_CUSTOM_HEAP),1) - LIBMAIN = mainmm -endif - -LIBMAIN = main -LIBMAIN_SRC = $(addprefix $(SDK_LIBDIR)/,libmain.a) - -ifeq ($(ENABLE_CUSTOM_HEAP),1) - LIBMAIN = mainmm - LIBMAIN_SRC := $(USER_LIBDIR)lib$(LIBMAIN).a -endif - -# libmain must be modified for rBoot big flash support (just one symbol gets weakened) -ifeq ($(RBOOT_BIG_FLASH),1) - LIBMAIN = main2 - LIBMAIN_DST = $(addprefix $(BUILD_BASE)/,libmain2.a) - CFLAGS += -DBOOT_BIG_FLASH -else - LIBMAIN_DST = $() -endif -# libraries used in this project, mainly provided by the SDK - -LIBLWIP = lwip -ifeq ($(ENABLE_CUSTOM_LWIP), 1) - LIBLWIP = lwip_open - ifeq ($(ENABLE_ESPCONN), 1) - LIBLWIP = lwip_full - endif - CUSTOM_TARGETS += $(USER_LIBDIR)/lib$(LIBLWIP).a -endif -ifeq ($(ENABLE_CUSTOM_LWIP), 2) - ifeq ($(ENABLE_ESPCONN), 1) -$(error LWIP2 does not support espconn_* functions. Make sure to set ENABLE_CUSTOM_LWIP to 0 or 1.) - endif - LIBLWIP = lwip2 - CUSTOM_TARGETS += $(USER_LIBDIR)/liblwip2.a -endif - -LIBPWM = pwm - -ENABLE_CUSTOM_PWM ?= 1 -ifeq ($(ENABLE_CUSTOM_PWM), 1) - LIBPWM = pwm_open - CUSTOM_TARGETS += $(USER_LIBDIR)/lib$(LIBPWM).a -endif - -LIBS = microc microgcc hal phy pp net80211 $(LIBLWIP) mqttc wpa $(LIBSMING) $(LIBMAIN) crypto $(LIBPWM) smartconfig $(EXTRA_LIBS) -ifeq ($(ENABLE_WPS),1) - LIBS += wps -endif - -# SSL support using axTLS -ifeq ($(ENABLE_SSL),1) - LIBS += axtls - EXTRA_INCDIR += $(THIRD_PARTY_DIR)/axtls-8266 $(THIRD_PARTY_DIR)/axtls-8266/ssl $(THIRD_PARTY_DIR)/axtls-8266/crypto - AXTLS_FLAGS = -DLWIP_RAW=1 -DENABLE_SSL=1 - ifeq ($(SSL_DEBUG),1) # - AXTLS_FLAGS += -DSSL_DEBUG=1 -DDEBUG_TLS_MEM=1 - endif - - CUSTOM_TARGETS += include/ssl/private_key.h - CFLAGS += $(AXTLS_FLAGS) - CXXFLAGS += $(AXTLS_FLAGS) -endif - -ifeq ($(ENABLE_CUSTOM_LWIP), 1) - EXTRA_INCDIR += third-party/esp-open-lwip/include -endif -ifeq ($(ENABLE_CUSTOM_LWIP), 2) - EXTRA_INCDIR += third-party/lwip2/include -endif - - -# we will use global WiFi settings from Eclipse Environment Variables, if possible -WIFI_SSID ?= "" -WIFI_PWD ?= "" -ifneq ($(WIFI_SSID), "") - CFLAGS += -DWIFI_SSID=\"$(WIFI_SSID)\" -endif -ifneq ($(WIFI_PWD), "") - CFLAGS += -DWIFI_PWD=\"$(WIFI_PWD)\" -endif -ifeq ($(DISABLE_SPIFFS), 1) - CFLAGS += -DDISABLE_SPIFFS=1 -endif - -# linker flags used to generate the main object file -LDFLAGS = -nostdlib -u call_user_start -u Cache_Read_Enable_New -u spiffs_get_storage_config -u custom_crash_callback \ - -Wl,-static -Wl,--gc-sections -Wl,-Map=$(basename $@).map -Wl,-wrap,system_restart_local - -ifeq ($(SPI_SPEED), 26) - flashimageoptions = -ff 26m -else ifeq ($(SPI_SPEED), 20) - flashimageoptions = -ff 20m -else ifeq ($(SPI_SPEED), 80) - flashimageoptions = -ff 80m -else - flashimageoptions = -ff 40m -endif - -ifeq ($(SPI_MODE), qout) - flashimageoptions += -fm qout -else ifeq ($(SPI_MODE), dio) - flashimageoptions += -fm dio -else ifeq ($(SPI_MODE), dout) - flashimageoptions += -fm dout -else - flashimageoptions += -fm qio -endif - -ifeq ($(SPI_SIZE), 256K) - flashimageoptions += -fs 2m - SPIFF_SIZE ?= 131072 #128K -else ifeq ($(SPI_SIZE), 1M) - flashimageoptions += -fs 8m - SPIFF_SIZE ?= 524288 #512K - INIT_BIN_ADDR = 0x0fc000 - BLANK_BIN_ADDR = 0x0fe000 -else ifeq ($(SPI_SIZE), 2M) - flashimageoptions += -fs 16m - SPIFF_SIZE ?= 524288 #512K - INIT_BIN_ADDR = 0x1fc000 - BLANK_BIN_ADDR = 0x1fe000 -else ifeq ($(SPI_SIZE), 4M) - flashimageoptions += -fs 32m - SPIFF_SIZE ?= 524288 #512K - INIT_BIN_ADDR = 0x3fc000 - BLANK_BIN_ADDR = 0x3fe000 -else - flashimageoptions += -fs 4m - SPIFF_SIZE ?= 196608 #192K -endif -CFLAGS += -DSPIFF_SIZE=$(SPIFF_SIZE) -CFLAGS += -DRBOOT_SPIFFS_0=$(RBOOT_SPIFFS_0) -CFLAGS += -DRBOOT_SPIFFS_1=$(RBOOT_SPIFFS_1) - -# various paths from the SDK used in this project -SDK_LIBDIR = lib -SDK_LDDIR = ld -SDK_INCDIR = include - -# select which tools to use as assembler, compiler, librarian and linker -AS := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-gcc -CC := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-gcc -CXX := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-g++ -AR := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-ar -LD := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-gcc -OBJCOPY := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-objcopy -OBJDUMP := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-objdump - -SRC_DIR := $(MODULES) -BUILD_DIR := $(addprefix $(BUILD_BASE)/,$(MODULES)) - -SDK_LIBDIR := $(addprefix $(SDK_BASE)/,$(SDK_LIBDIR)) -SDK_INCDIR := $(addprefix -I$(SDK_BASE)/,$(SDK_INCDIR)) - -C_SRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.c)) -C_OBJ := $(patsubst %.c,$(BUILD_BASE)/%.o,$(C_SRC)) - -CXX_SRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.cpp)) -CXX_OBJ := $(patsubst %.cpp,$(BUILD_BASE)/%.o,$(CXX_SRC)) - -AS_SRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.s)) -AS_OBJ := $(patsubst %.s,$(BUILD_BASE)/%.o,$(AS_SRC)) -AS_SRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.S)) -AS_OBJ += $(patsubst %.S,$(BUILD_BASE)/%.o,$(AS_SRC)) - - -OBJ := $(AS_OBJ) $(C_OBJ) $(CXX_OBJ) - -LIBS := $(addprefix -l,$(LIBS)) -APP_AR := $(addprefix $(BUILD_BASE)/,$(TARGET)_app.a) -TARGET_OUT_0 := $(addprefix $(BUILD_BASE)/,$(TARGET)_0.out) -TARGET_OUT_1 := $(addprefix $(BUILD_BASE)/,$(TARGET)_1.out) - -SPIFF_BIN_OUT ?= spiff_rom -SPIFF_BIN_OUT := $(FW_BASE)/$(SPIFF_BIN_OUT).bin -RBOOT_LD_0 := $(addprefix -T,$(RBOOT_LD_0)) -RBOOT_LD_1 := $(addprefix -T,$(RBOOT_LD_1)) - -# extra flags -CFLAGS += -DRBOOT_INTEGRATION - -RBOOT_BIN := $(FW_BASE)/rboot.bin -RBOOT_BUILD_BASE := $(abspath $(BUILD_BASE)) -RBOOT_FW_BASE := $(abspath $(FW_BASE)) -# these are exported for use by the rBoot Makefile -export RBOOT_BIG_FLASH -export RBOOT_BUILD_BASE -export RBOOT_FW_BASE -export RBOOT_RTC_ENABLED -export RBOOT_GPIO_ENABLED -export RBOOT_GPIO_SKIP_ENABLED -export RBOOT_ROM1_ADDR -export RBOOT_ROM2_ADDR -export SPI_SIZE -export SPI_MODE -export SPI_SPEED -export ESPTOOL2 - -# multiple roms per 1mb block? -ifeq ($(RBOOT_TWO_ROMS),1) - # set a define so ota code can choose correct rom - CFLAGS += -DRBOOT_TWO_ROMS -else - # eliminate the second rBoot target - RBOOT_ROM_1 := $() -endif - -ifeq ($(RBOOT_RTC_ENABLED),1) - # enable the temporary switch to rom feature - CFLAGS += -DBOOT_RTC_ENABLED -endif - -ifeq ($(RBOOT_GPIO_ENABLED),1) - CFLAGS += -DBOOT_GPIO_ENABLED -endif - -ifeq ($(RBOOT_GPIO_SKIP_ENABLED),1) - CFLAGS += -DBOOT_GPIO_SKIP_ENABLED -endif - -INCDIR := $(addprefix -I,$(SRC_DIR)) -EXTRA_INCDIR := $(addprefix -I,$(EXTRA_INCDIR)) -MODULE_INCDIR := $(addsuffix /include,$(INCDIR)) - -V ?= $(VERBOSE) -ifeq ("$(V)","1") -Q := -vecho := @true -else -Q := @ -vecho := @echo -endif - - -define compile-objects -${BUILD_BASE}/$1/%.o: $1/%.s - $(vecho) "AS $$<" - $(Q) $(AS) $(INCDIR) $(MODULE_INCDIR) $(EXTRA_INCDIR) $(SDK_INCDIR) $(CFLAGS) -c $$< -o $$@ -${BUILD_BASE}/$1/%.o: $1/%.S - $(vecho) "AS $$<" - $(Q) $(AS) $(INCDIR) $(MODULE_INCDIR) $(EXTRA_INCDIR) $(SDK_INCDIR) $(CFLAGS) -c $$< -o $$@ -${BUILD_BASE}/$1/%.o: $1/%.c ${BUILD_BASE}/$1/%.c.d - $(vecho) "CC $$<" - $(Q) $(CC) $(INCDIR) $(MODULE_INCDIR) $(EXTRA_INCDIR) $(SDK_INCDIR) $(CFLAGS) -c $$< -o $$@ -${BUILD_BASE}/$1/%.o: $1/%.cpp ${BUILD_BASE}/$1/%.cpp.d - $(vecho) "C+ $$<" - $(Q) $(CXX) $(INCDIR) $(MODULE_INCDIR) $(EXTRA_INCDIR) $(SDK_INCDIR) $(CXXFLAGS) -c $$< -o $$@ -${BUILD_BASE}/$1/%.c.d: $1/%.c - $(Q) $(CC) $(INCDIR) $(MODULE_INCDIR) $(EXTRA_INCDIR) $(SDK_INCDIR) $(CFLAGS) -MM -MT $1/$$*.o $$< -o $$@ -${BUILD_BASE}/$1/%.cpp.d: $1/%.cpp - $(Q) $(CXX) $(INCDIR) $(MODULE_INCDIR) $(EXTRA_INCDIR) $(SDK_INCDIR) $(CXXFLAGS) -MM -MT $1/$$*.o $$< -o $$@ - -.PRECIOUS: ${BUILD_BASE}/$1/%.c.d ${BUILD_BASE}/$1/%.cpp.d -endef - -.PHONY: all checkdirs spiff_update spiff_clean clean kill_term terminal gdb - -all: $(USER_LIBDIR)/lib$(LIBSMING).a checkdirs $(LIBMAIN_DST) $(RBOOT_BIN) $(RBOOT_ROM_0) $(RBOOT_ROM_1) $(SPIFF_BIN_OUT) $(FW_FILE_1) $(FW_FILE_2) $(GDB_SYMBOLS) - -# Copy symbols required by GDB into build directory -gdb_symbols: $(BUILD_BASE)/bootrom.elf - -$(BUILD_BASE)/%.elf: - $(Q) cp $(SMING_HOME)/gdb/symbols/$(notdir $@) $@ - -$(RBOOT_BIN): - $(MAKE) -C $(THIRD_PARTY_DIR)/rboot RBOOT_GPIO_ENABLED=$(RBOOT_GPIO_ENABLED) RBOOT_SILENT=$(RBOOT_SILENT) - -$(LIBMAIN_DST): $(LIBMAIN_SRC) - @echo "OC $@" - @$(OBJCOPY) -W Cache_Read_Enable_New $^ $@ - -spiff_update: spiff_clean $(SPIFF_BIN_OUT) - -$(RBOOT_ROM_0): $(TARGET_OUT_0) - @echo "E2 $@" - @$(ESPTOOL2) $(RBOOT_E2_USER_ARGS) $(TARGET_OUT_0) $@ $(RBOOT_E2_SECTS) - -$(RBOOT_ROM_1): $(TARGET_OUT_1) - @echo "E2 $@" - @$(ESPTOOL2) $(RBOOT_E2_USER_ARGS) $(TARGET_OUT_1) $@ $(RBOOT_E2_SECTS) - -$(TARGET_OUT_0): $(APP_AR) - $(vecho) "LD $@" - $(Q) $(LD) -L$(USER_LIBDIR) -L$(SDK_LIBDIR) -L$(BUILD_BASE) -L$(SMING_HOME)/compiler/ld $(RBOOT_LD_0) $(LDFLAGS) -Wl,--start-group $(APP_AR) $(LIBS) -Wl,--end-group -o $@ - - $(Q) $(MEMANALYZER) $@ > $(FW_MEMINFO_NEW) - - $(Q) if [ -f "$(FW_MEMINFO_NEW)" -a -f "$(FW_MEMINFO_OLD)" ]; then \ - awk -F "|" 'FILENAME == "$(FW_MEMINFO_OLD)" { arr[$$1]=$$5 } FILENAME == "$(FW_MEMINFO_NEW)" { if (arr[$$1] != $$5){printf "%s%s%+d%s", substr($$0, 1, length($$0) - 1)," (",$$5 - arr[$$1],")\n" } else {print $$0} }' $(FW_MEMINFO_OLD) $(FW_MEMINFO_NEW); \ - elif [ -f "$(FW_MEMINFO_NEW)" ]; then \ - cat $(FW_MEMINFO_NEW); \ - fi - - -$(TARGET_OUT_1): $(APP_AR) - $(vecho) "LD $@" - $(Q) $(LD) -L$(USER_LIBDIR) -L$(SDK_LIBDIR) -L$(BUILD_BASE) -L$(SMING_HOME)/compiler/ld $(RBOOT_LD_1) $(LDFLAGS) -Wl,--start-group $(APP_AR) $(LIBS) -Wl,--end-group -o $@ - -# recreate it from 0, since you get into problems with same filenames -$(APP_AR): $(OBJ) - $(vecho) "AR $@" - $(Q) test ! -f $@ || rm $@ - $(Q) $(AR) rcsP $@ $^ - -$(USER_LIBDIR)/lib$(LIBSMING).a: - $(vecho) "(Re)compiling Sming. Enabled features: $(SMING_FEATURES). This may take some time" - $(Q) $(MAKE) -C $(SMING_HOME) clean V=$(V) ENABLE_SSL=$(ENABLE_SSL) SMING_HOME=$(SMING_HOME) - $(Q) $(MAKE) -C $(SMING_HOME) V=$(V) ENABLE_SSL=$(ENABLE_SSL) SMING_HOME=$(SMING_HOME) - -include/ssl/private_key.h: - $(vecho) "Generating unique certificate and key. This may take some time" - $(Q) mkdir -p $(CURRENT_DIR)/include/ssl/ - $(Q) AXDIR=$(CURRENT_DIR)/include/ssl/ $(THIRD_PARTY_DIR)/axtls-8266/tools/make_certs.sh - -ifeq ($(ENABLE_CUSTOM_PWM), 1) -$(USER_LIBDIR)/libpwm_open.a: - $(Q) $(MAKE) -C $(SMING_HOME) compiler/lib/libpwm_open.a ENABLE_CUSTOM_PWM=1 -endif - -$(USER_LIBDIR)/liblwip%.a: - $(Q) $(MAKE) -C $(SMING_HOME) compiler/lib/$(notdir $@) \ - ENABLE_CUSTOM_LWIP=$(ENABLE_CUSTOM_LWIP) \ - ENABLE_ESPCONN=$(ENABLE_ESPCONN) - -checkdirs: $(BUILD_DIR) $(FW_BASE) $(CUSTOM_TARGETS) - -$(BUILD_DIR): - $(Q) mkdir -p $@ - -$(FW_BASE): - $(Q) mkdir -p $@ - -spiff_clean: - $(vecho) "Cleaning $(SPIFF_BIN_OUT)" - $(Q) rm -rf $(SPIFF_BIN_OUT) - -$(SPIFF_BIN_OUT): -ifeq ($(DISABLE_SPIFFS), 1) - $(vecho) "(!) Spiffs support disabled. Remove 'DISABLE_SPIFFS' make argument to enable spiffs." -else -# Generating spiffs_bin - $(vecho) "Checking for spiffs files" - $(Q) if [ -d "$(SPIFF_FILES)" ]; then \ - echo "$(SPIFF_FILES) directory exists. Creating $(SPIFF_BIN_OUT)"; \ - $(SPIFFY) $(SPIFF_SIZE) $(SPIFF_FILES) $(SPIFF_BIN_OUT); \ - else \ - echo "No files found in ./$(SPIFF_FILES)."; \ - echo "Creating empty $(SPIFF_BIN_OUT)"; \ - $(SPIFFY) $(SPIFF_SIZE) dummy.dir $(SPIFF_BIN_OUT); \ - fi -endif - -flashboot: $(USER_LIBDIR)/lib$(LIBSMING).a $(RBOOT_BIN) - $(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED_ESPTOOL) write_flash $(flashimageoptions) 0x00000 $(RBOOT_BIN) - -flashconfig: kill_term - $(vecho) "Deleting rBoot config sector" - $(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED_ESPTOOL) write_flash $(flashimageoptions) 0x01000 $(SDK_BASE)/bin/blank.bin - -flashapp: all - $(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED_ESPTOOL) write_flash $(flashimageoptions) 0x02000 $(RBOOT_ROM_0) - -flashfs: $(USER_LIBDIR)/lib$(LIBSMING).a $(SPIFF_BIN_OUT) -ifeq ($(DISABLE_SPIFFS), 1) - $(vecho) "SPIFFS are not enabled!" -else - $(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED_ESPTOOL) write_flash $(flashimageoptions) $(RBOOT_SPIFFS_0) $(SPIFF_BIN_OUT) -endif - -# Full GDB command line -GDB := trap '' INT && $(GDB) -x $(SMING_HOME)/gdb/gdbcmds -b $(COM_SPEED_SERIAL) -ex "target remote $(COM_PORT)" - -flash: all kill_term -ifeq ($(DISABLE_SPIFFS), 1) -# flashes rboot and first rom - $(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED_ESPTOOL) write_flash $(flashimageoptions) 0x00000 $(RBOOT_BIN) 0x02000 $(RBOOT_ROM_0) -else -# flashes rboot, first rom and spiffs - $(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED_ESPTOOL) write_flash $(flashimageoptions) 0x00000 $(RBOOT_BIN) 0x02000 $(RBOOT_ROM_0) $(RBOOT_SPIFFS_0) $(SPIFF_BIN_OUT) -endif -ifeq ($(ENABLE_GDB), 1) - $(GDB) -else - $(TERMINAL) -endif - -otaserver: all - $(vecho) "Starting OTA server for TESTING" - $(Q) cd $(FW_BASE) && python -m SimpleHTTPServer $(SERVER_OTA_PORT) - -kill_term: - $(vecho) "Killing Terminal to free $(COM_PORT)" - -$(Q) $(KILL_TERM) - -terminal: kill_term - $(TERMINAL) - -gdb: kill_term - $(GDB) - -flashinit: - $(vecho) "Flash init data default and blank data." - $(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED_ESPTOOL) erase_flash -ifeq ($(DISABLE_SPIFFS), 1) - $(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED_ESPTOOL) write_flash $(flashimageoptions) $(INIT_BIN_ADDR) $(SDK_BASE)/bin/esp_init_data_default.bin $(BLANK_BIN_ADDR) $(SDK_BASE)/bin/blank.bin -else - $(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED_ESPTOOL) write_flash $(flashimageoptions) $(INIT_BIN_ADDR) $(SDK_BASE)/bin/esp_init_data_default.bin $(BLANK_BIN_ADDR) $(SDK_BASE)/bin/blank.bin $(RBOOT_SPIFFS_0) $(SMING_HOME)/compiler/data/blankfs.bin -endif - -rebuild: clean all - -clean: -#remove build artifacts - $(Q) rm -rf $(BUILD_BASE) - $(Q) rm -rf $(FW_BASE) - -$(foreach mod,$(MODULES),$(eval $(call compile-objects,$(mod)))) -$(foreach bdir,$(BUILD_DIR),$(eval include $(wildcard $(bdir)/*.c.d))) -$(foreach bdir,$(BUILD_DIR),$(eval include $(wildcard $(bdir)/*.cpp.d))) +include $(SMING_HOME)/Makefile-app.mk \ No newline at end of file diff --git a/Sming/Makefile-windows.mk b/Sming/Makefile-windows.mk index 44f4caae92..c23921de31 100644 --- a/Sming/Makefile-windows.mk +++ b/Sming/Makefile-windows.mk @@ -13,4 +13,4 @@ ESPTOOL ?= $(SDK_TOOLS)/ESP8266/esptool.exe KILL_TERM ?= taskkill.exe -f -im Terminal.exe || exit 0 GET_FILESIZE ?= stat --printf="%s" TERMINAL ?= $(SDK_TOOLS)/Terminal.exe $(COM_PORT) $(COM_SPEED_SERIAL) $(COM_OPTS) -MEMANALYZER ?= python $(SMING_HOME)/../tools/memanalyzer.py $(OBJDUMP).exe +MEMANALYZER ?= python $(PLATFORM_TOOLS)/memanalyzer.py $(OBJDUMP).exe diff --git a/Sming/SmingCore/Platform/AccessPoint.h b/Sming/Platform/Common/Platform/AccessPoint.h similarity index 100% rename from Sming/SmingCore/Platform/AccessPoint.h rename to Sming/Platform/Common/Platform/AccessPoint.h diff --git a/Sming/SmingCore/Platform/OsMessageInterceptor.cpp b/Sming/Platform/Common/Platform/OsMessageInterceptor.cpp similarity index 90% rename from Sming/SmingCore/Platform/OsMessageInterceptor.cpp rename to Sming/Platform/Common/Platform/OsMessageInterceptor.cpp index c373749eee..90e00979a9 100644 --- a/Sming/SmingCore/Platform/OsMessageInterceptor.cpp +++ b/Sming/Platform/Common/Platform/OsMessageInterceptor.cpp @@ -10,7 +10,7 @@ * ****/ -#include "OsMessageInterceptor.h" +#include "Platform/OsMessageInterceptor.h" extern void uart_debug_putc(char); diff --git a/Sming/SmingCore/Platform/OsMessageInterceptor.h b/Sming/Platform/Common/Platform/OsMessageInterceptor.h similarity index 100% rename from Sming/SmingCore/Platform/OsMessageInterceptor.h rename to Sming/Platform/Common/Platform/OsMessageInterceptor.h diff --git a/Sming/SmingCore/Platform/RTC.h b/Sming/Platform/Common/Platform/RTC.h similarity index 97% rename from Sming/SmingCore/Platform/RTC.h rename to Sming/Platform/Common/Platform/RTC.h index fbfade4114..596cad360a 100644 --- a/Sming/SmingCore/Platform/RTC.h +++ b/Sming/Platform/Common/Platform/RTC.h @@ -16,7 +16,7 @@ #ifndef _SMING_CORE_PLATFORM_RTC_H_ #define _SMING_CORE_PLATFORM_RTC_H_ -#include "../Wiring/WiringFrameworkDependencies.h" +#include "WiringFrameworkDependencies.h" #define RTC_MAGIC 0x55aaaa55 #define RTC_DES_ADDR 64 diff --git a/Sming/SmingCore/Platform/Station.h b/Sming/Platform/Common/Platform/Station.h similarity index 100% rename from Sming/SmingCore/Platform/Station.h rename to Sming/Platform/Common/Platform/Station.h diff --git a/Sming/SmingCore/Platform/System.h b/Sming/Platform/Common/Platform/System.h similarity index 100% rename from Sming/SmingCore/Platform/System.h rename to Sming/Platform/Common/Platform/System.h diff --git a/Sming/SmingCore/Platform/WDT.h b/Sming/Platform/Common/Platform/WDT.h similarity index 100% rename from Sming/SmingCore/Platform/WDT.h rename to Sming/Platform/Common/Platform/WDT.h diff --git a/Sming/SmingCore/Platform/WifiEvents.h b/Sming/Platform/Common/Platform/WifiEvents.h similarity index 95% rename from Sming/SmingCore/Platform/WifiEvents.h rename to Sming/Platform/Common/Platform/WifiEvents.h index 13fe6487c7..9c31f5e263 100644 --- a/Sming/SmingCore/Platform/WifiEvents.h +++ b/Sming/Platform/Common/Platform/WifiEvents.h @@ -14,9 +14,9 @@ #ifndef _SMING_CORE_PLATFORM_WIFI_EVENTS_H_ #define _SMING_CORE_PLATFORM_WIFI_EVENTS_H_ -#include "../SmingCore/Delegate.h" -#include "../../Wiring/WString.h" -#include "../../Wiring/IPAddress.h" +#include "Delegate.h" +#include "WString.h" +#include "IPAddress.h" //Define WifiEvents Delegates types typedef Delegate StationConnectDelegate; diff --git a/Sming/SmingCore/Platform/WifiSniffer.h b/Sming/Platform/Common/Platform/WifiSniffer.h similarity index 100% rename from Sming/SmingCore/Platform/WifiSniffer.h rename to Sming/Platform/Common/Platform/WifiSniffer.h diff --git a/Sming/compiler/data/blankfs.bin b/Sming/Platform/Esp8266/Compiler/data/blankfs.bin similarity index 100% rename from Sming/compiler/data/blankfs.bin rename to Sming/Platform/Esp8266/Compiler/data/blankfs.bin diff --git a/Sming/compiler/ld/common.ld b/Sming/Platform/Esp8266/Compiler/ld/common.ld similarity index 100% rename from Sming/compiler/ld/common.ld rename to Sming/Platform/Esp8266/Compiler/ld/common.ld diff --git a/Sming/compiler/ld/rboot.rom0.ld b/Sming/Platform/Esp8266/Compiler/ld/rboot.rom0.ld similarity index 100% rename from Sming/compiler/ld/rboot.rom0.ld rename to Sming/Platform/Esp8266/Compiler/ld/rboot.rom0.ld diff --git a/Sming/compiler/ld/standalone.rom.ld b/Sming/Platform/Esp8266/Compiler/ld/standalone.rom.ld similarity index 100% rename from Sming/compiler/ld/standalone.rom.ld rename to Sming/Platform/Esp8266/Compiler/ld/standalone.rom.ld diff --git a/Sming/compiler/lib/.gitignore b/Sming/Platform/Esp8266/Compiler/lib/.gitignore similarity index 100% rename from Sming/compiler/lib/.gitignore rename to Sming/Platform/Esp8266/Compiler/lib/.gitignore diff --git a/Sming/compiler/lib/libmicroc.a b/Sming/Platform/Esp8266/Compiler/lib/libmicroc.a similarity index 100% rename from Sming/compiler/lib/libmicroc.a rename to Sming/Platform/Esp8266/Compiler/lib/libmicroc.a diff --git a/Sming/compiler/lib/libmicrogcc.a b/Sming/Platform/Esp8266/Compiler/lib/libmicrogcc.a similarity index 100% rename from Sming/compiler/lib/libmicrogcc.a rename to Sming/Platform/Esp8266/Compiler/lib/libmicrogcc.a diff --git a/Sming/SmingCore/Clock.cpp b/Sming/Platform/Esp8266/Core/Clock.cpp similarity index 100% rename from Sming/SmingCore/Clock.cpp rename to Sming/Platform/Esp8266/Core/Clock.cpp diff --git a/Sming/SmingCore/Digital.cpp b/Sming/Platform/Esp8266/Core/Digital.cpp similarity index 99% rename from Sming/SmingCore/Digital.cpp rename to Sming/Platform/Esp8266/Core/Digital.cpp index 9a20656aa9..77f813993a 100644 --- a/Sming/SmingCore/Digital.cpp +++ b/Sming/Platform/Esp8266/Core/Digital.cpp @@ -11,6 +11,7 @@ #include "Digital.h" #include "WiringFrameworkIncludes.h" #include "espinc/peri.h" +#include "ESP8266EX.h" const unsigned int A0 = 17; // Single ESP8266EX analog input pin (TOUT) 10 bit, 0..1v diff --git a/Sming/SmingCore/ESP8266EX.cpp b/Sming/Platform/Esp8266/Core/ESP8266EX.cpp similarity index 100% rename from Sming/SmingCore/ESP8266EX.cpp rename to Sming/Platform/Esp8266/Core/ESP8266EX.cpp diff --git a/Sming/SmingCore/ESP8266EX.h b/Sming/Platform/Esp8266/Core/ESP8266EX.h similarity index 100% rename from Sming/SmingCore/ESP8266EX.h rename to Sming/Platform/Esp8266/Core/ESP8266EX.h diff --git a/Sming/SmingCore/HardwarePWM.cpp b/Sming/Platform/Esp8266/Core/HardwarePWM.cpp similarity index 99% rename from Sming/SmingCore/HardwarePWM.cpp rename to Sming/Platform/Esp8266/Core/HardwarePWM.cpp index 70490a2b02..742f5ff5c5 100644 --- a/Sming/SmingCore/HardwarePWM.cpp +++ b/Sming/Platform/Esp8266/Core/HardwarePWM.cpp @@ -25,6 +25,7 @@ #include "Clock.h" #include "WiringFrameworkIncludes.h" +#include "ESP8266EX.h" #include "HardwarePWM.h" diff --git a/Sming/SmingCore/HardwareSerial.cpp b/Sming/Platform/Esp8266/Core/HardwareSerial.cpp similarity index 99% rename from Sming/SmingCore/HardwareSerial.cpp rename to Sming/Platform/Esp8266/Core/HardwareSerial.cpp index e8f7788f60..56746c83a6 100644 --- a/Sming/SmingCore/HardwareSerial.cpp +++ b/Sming/Platform/Esp8266/Core/HardwareSerial.cpp @@ -12,7 +12,7 @@ #include "HardwareSerial.h" #include -#include "System.h" +#include "Platform/System.h" #include "m_printf.h" #if ENABLE_CMD_EXECUTOR diff --git a/Sming/SmingCore/HardwareTimer.cpp b/Sming/Platform/Esp8266/Core/HardwareTimer.cpp similarity index 100% rename from Sming/SmingCore/HardwareTimer.cpp rename to Sming/Platform/Esp8266/Core/HardwareTimer.cpp diff --git a/Sming/SmingCore/Interrupts.cpp b/Sming/Platform/Esp8266/Core/Interrupts.cpp similarity index 99% rename from Sming/SmingCore/Interrupts.cpp rename to Sming/Platform/Esp8266/Core/Interrupts.cpp index cbbcd368eb..36a73b4638 100644 --- a/Sming/SmingCore/Interrupts.cpp +++ b/Sming/Platform/Esp8266/Core/Interrupts.cpp @@ -11,7 +11,7 @@ #include "Interrupts.h" #include "Digital.h" #include "WiringFrameworkIncludes.h" -#include "System.h" +#include "Platform/System.h" static InterruptCallback gpioInterruptsList[16] = {0}; static InterruptDelegate delegateFunctionList[16]; diff --git a/Sming/SmingCore/Network/rBootHttpUpdate.cpp b/Sming/Platform/Esp8266/Core/Network/rBootHttpUpdate.cpp similarity index 100% rename from Sming/SmingCore/Network/rBootHttpUpdate.cpp rename to Sming/Platform/Esp8266/Core/Network/rBootHttpUpdate.cpp diff --git a/Sming/SmingCore/Network/rBootHttpUpdate.h b/Sming/Platform/Esp8266/Core/Network/rBootHttpUpdate.h similarity index 98% rename from Sming/SmingCore/Network/rBootHttpUpdate.h rename to Sming/Platform/Esp8266/Core/Network/rBootHttpUpdate.h index 1afd1d58ba..763c3e6948 100644 --- a/Sming/SmingCore/Network/rBootHttpUpdate.h +++ b/Sming/Platform/Esp8266/Core/Network/rBootHttpUpdate.h @@ -17,7 +17,7 @@ #define _SMING_CORE_NETWORK_RBOOT_HTTP_UPDATE_H_ #include "Data/Stream/DataSourceStream.h" -#include "HttpClient.h" +#include "Network/HttpClient.h" #include #define NO_ROM_SWITCH 0xff diff --git a/Sming/SmingCore/SPI.cpp b/Sming/Platform/Esp8266/Core/SPI.cpp similarity index 100% rename from Sming/SmingCore/SPI.cpp rename to Sming/Platform/Esp8266/Core/SPI.cpp diff --git a/Sming/SmingCore/SPISoft.cpp b/Sming/Platform/Esp8266/Core/SPISoft.cpp similarity index 100% rename from Sming/SmingCore/SPISoft.cpp rename to Sming/Platform/Esp8266/Core/SPISoft.cpp diff --git a/Sming/SmingCore/core_esp8266_si2c.cpp b/Sming/Platform/Esp8266/Core/core_esp8266_si2c.cpp similarity index 99% rename from Sming/SmingCore/core_esp8266_si2c.cpp rename to Sming/Platform/Esp8266/Core/core_esp8266_si2c.cpp index 6c4d6e9feb..221e83080b 100644 --- a/Sming/SmingCore/core_esp8266_si2c.cpp +++ b/Sming/Platform/Esp8266/Core/core_esp8266_si2c.cpp @@ -21,6 +21,8 @@ #include "twi.h" #include "Digital.h" +#include + unsigned char twi_dcount = 18; static unsigned char twi_sda, twi_scl; static uint32_t twi_clockStretchLimit; diff --git a/Sming/SmingCore/pins_arduino.h b/Sming/Platform/Esp8266/Core/pins_arduino.h similarity index 100% rename from Sming/SmingCore/pins_arduino.h rename to Sming/Platform/Esp8266/Core/pins_arduino.h diff --git a/Sming/SmingCore/Platform/AccessPoint.cpp b/Sming/Platform/Esp8266/Platform/AccessPoint.cpp similarity index 99% rename from Sming/SmingCore/Platform/AccessPoint.cpp rename to Sming/Platform/Esp8266/Platform/AccessPoint.cpp index 8847ee07ea..23d38bb39b 100644 --- a/Sming/SmingCore/Platform/AccessPoint.cpp +++ b/Sming/Platform/Esp8266/Platform/AccessPoint.cpp @@ -8,7 +8,7 @@ * ****/ -#include "AccessPoint.h" +#include "Platform/AccessPoint.h" #include "Interrupts.h" #include "Data/HexString.h" diff --git a/Sming/SmingCore/Platform/RTC.cpp b/Sming/Platform/Esp8266/Platform/RTC.cpp similarity index 95% rename from Sming/SmingCore/Platform/RTC.cpp rename to Sming/Platform/Esp8266/Platform/RTC.cpp index f70ddd10d9..0a39e0be69 100644 --- a/Sming/SmingCore/Platform/RTC.cpp +++ b/Sming/Platform/Esp8266/Platform/RTC.cpp @@ -8,7 +8,7 @@ * ****/ -#include "RTC.h" +#include "Platform/RTC.h" RtcClass::RtcClass() { diff --git a/Sming/SmingCore/Platform/Station.cpp b/Sming/Platform/Esp8266/Platform/Station.cpp similarity index 99% rename from Sming/SmingCore/Platform/Station.cpp rename to Sming/Platform/Esp8266/Platform/Station.cpp index 37a7c59d9c..2e865fa8d0 100644 --- a/Sming/SmingCore/Platform/Station.cpp +++ b/Sming/Platform/Esp8266/Platform/Station.cpp @@ -8,7 +8,7 @@ * ****/ -#include "Station.h" +#include "Platform/Station.h" #include "Interrupts.h" #include "Data/HexString.h" diff --git a/Sming/SmingCore/Platform/System.cpp b/Sming/Platform/Esp8266/Platform/System.cpp similarity index 99% rename from Sming/SmingCore/Platform/System.cpp rename to Sming/Platform/Esp8266/Platform/System.cpp index ffd7f9b7c0..15c5e576c7 100644 --- a/Sming/SmingCore/Platform/System.cpp +++ b/Sming/Platform/Esp8266/Platform/System.cpp @@ -8,7 +8,7 @@ * ****/ -#include "System.h" +#include "Platform/System.h" #include "SimpleTimer.h" SystemClass System; diff --git a/Sming/SmingCore/Platform/WDT.cpp b/Sming/Platform/Esp8266/Platform/WDT.cpp similarity index 96% rename from Sming/SmingCore/Platform/WDT.cpp rename to Sming/Platform/Esp8266/Platform/WDT.cpp index 0dc4d7d957..1d8ffc8955 100644 --- a/Sming/SmingCore/Platform/WDT.cpp +++ b/Sming/Platform/Esp8266/Platform/WDT.cpp @@ -11,7 +11,7 @@ * */ -#include "WDT.h" +#include "Platform/WDT.h" WDTClass WDT; diff --git a/Sming/SmingCore/Platform/WifiEvents.cpp b/Sming/Platform/Esp8266/Platform/WifiEvents.cpp similarity index 99% rename from Sming/SmingCore/Platform/WifiEvents.cpp rename to Sming/Platform/Esp8266/Platform/WifiEvents.cpp index 2256085e8a..80c1942a4f 100644 --- a/Sming/SmingCore/Platform/WifiEvents.cpp +++ b/Sming/Platform/Esp8266/Platform/WifiEvents.cpp @@ -10,7 +10,7 @@ * Author: shurik */ -#include +#include "Platform/WifiEvents.h" WifiEventsClass WifiEvents; diff --git a/Sming/SmingCore/Platform/WifiSniffer.cpp b/Sming/Platform/Esp8266/Platform/WifiSniffer.cpp similarity index 95% rename from Sming/SmingCore/Platform/WifiSniffer.cpp rename to Sming/Platform/Esp8266/Platform/WifiSniffer.cpp index 072eef7a2b..cc5a0510f3 100644 --- a/Sming/SmingCore/Platform/WifiSniffer.cpp +++ b/Sming/Platform/Esp8266/Platform/WifiSniffer.cpp @@ -12,7 +12,7 @@ * ****/ -#include "WifiSniffer.h" +#include "Platform/WifiSniffer.h" #include "esp_wifi_sniffer.h" WifiSnifferCallback WifiSniffer::snifferCallback; diff --git a/Sming/third-party/axtls-8266 b/Sming/Platform/Esp8266/System/components/axtls-8266/axtls-8266 similarity index 100% rename from Sming/third-party/axtls-8266 rename to Sming/Platform/Esp8266/System/components/axtls-8266/axtls-8266 diff --git a/Sming/third-party/.patches/axtls-8266.patch b/Sming/Platform/Esp8266/System/components/axtls-8266/axtls-8266.patch similarity index 100% rename from Sming/third-party/.patches/axtls-8266.patch rename to Sming/Platform/Esp8266/System/components/axtls-8266/axtls-8266.patch diff --git a/Sming/custom_heap/heap.c b/Sming/Platform/Esp8266/System/components/custom_heap/heap.c similarity index 100% rename from Sming/custom_heap/heap.c rename to Sming/Platform/Esp8266/System/components/custom_heap/heap.c diff --git a/Sming/third-party/umm_malloc b/Sming/Platform/Esp8266/System/components/custom_heap/umm_malloc similarity index 100% rename from Sming/third-party/umm_malloc rename to Sming/Platform/Esp8266/System/components/custom_heap/umm_malloc diff --git a/Sming/third-party/.patches/umm_malloc.patch b/Sming/Platform/Esp8266/System/components/custom_heap/umm_malloc.patch similarity index 100% rename from Sming/third-party/.patches/umm_malloc.patch rename to Sming/Platform/Esp8266/System/components/custom_heap/umm_malloc.patch diff --git a/Sming/system/include/espinc/uart.h b/Sming/Platform/Esp8266/System/components/driver/include/driver/uart.h similarity index 100% rename from Sming/system/include/espinc/uart.h rename to Sming/Platform/Esp8266/System/components/driver/include/driver/uart.h diff --git a/Sming/system/uart.cpp b/Sming/Platform/Esp8266/System/components/driver/uart.cpp similarity index 99% rename from Sming/system/uart.cpp rename to Sming/Platform/Esp8266/System/components/driver/uart.cpp index 572d7a787c..c0a873af06 100644 --- a/Sming/system/uart.cpp +++ b/Sming/Platform/Esp8266/System/components/driver/uart.cpp @@ -46,7 +46,7 @@ #include "Clock.h" #include "Digital.h" -#include "espinc/uart.h" +#include "driver/uart.h" #include "espinc/peri.h" #include "Data/Buffer/SerialBuffer.h" diff --git a/Sming/system/esp-lwip/arch/cc.h b/Sming/Platform/Esp8266/System/components/esp-lwip/arch/cc.h similarity index 100% rename from Sming/system/esp-lwip/arch/cc.h rename to Sming/Platform/Esp8266/System/components/esp-lwip/arch/cc.h diff --git a/Sming/system/esp-lwip/arch/perf.h b/Sming/Platform/Esp8266/System/components/esp-lwip/arch/perf.h similarity index 100% rename from Sming/system/esp-lwip/arch/perf.h rename to Sming/Platform/Esp8266/System/components/esp-lwip/arch/perf.h diff --git a/Sming/system/esp-lwip/arch/sys_arch.h b/Sming/Platform/Esp8266/System/components/esp-lwip/arch/sys_arch.h similarity index 100% rename from Sming/system/esp-lwip/arch/sys_arch.h rename to Sming/Platform/Esp8266/System/components/esp-lwip/arch/sys_arch.h diff --git a/Sming/system/esp-lwip/lwip/api.h b/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/api.h similarity index 100% rename from Sming/system/esp-lwip/lwip/api.h rename to Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/api.h diff --git a/Sming/system/esp-lwip/lwip/api_msg.h b/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/api_msg.h similarity index 100% rename from Sming/system/esp-lwip/lwip/api_msg.h rename to Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/api_msg.h diff --git a/Sming/system/esp-lwip/lwip/app/dhcpserver.h b/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/app/dhcpserver.h similarity index 100% rename from Sming/system/esp-lwip/lwip/app/dhcpserver.h rename to Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/app/dhcpserver.h diff --git a/Sming/system/esp-lwip/lwip/app/espconn.h b/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/app/espconn.h similarity index 100% rename from Sming/system/esp-lwip/lwip/app/espconn.h rename to Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/app/espconn.h diff --git a/Sming/system/esp-lwip/lwip/app/espconn_tcp.h b/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/app/espconn_tcp.h similarity index 100% rename from Sming/system/esp-lwip/lwip/app/espconn_tcp.h rename to Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/app/espconn_tcp.h diff --git a/Sming/system/esp-lwip/lwip/app/espconn_udp.h b/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/app/espconn_udp.h similarity index 100% rename from Sming/system/esp-lwip/lwip/app/espconn_udp.h rename to Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/app/espconn_udp.h diff --git a/Sming/system/esp-lwip/lwip/app/ping.h b/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/app/ping.h similarity index 100% rename from Sming/system/esp-lwip/lwip/app/ping.h rename to Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/app/ping.h diff --git a/Sming/system/esp-lwip/lwip/arch.h b/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/arch.h similarity index 100% rename from Sming/system/esp-lwip/lwip/arch.h rename to Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/arch.h diff --git a/Sming/system/esp-lwip/lwip/autoip.h b/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/autoip.h similarity index 100% rename from Sming/system/esp-lwip/lwip/autoip.h rename to Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/autoip.h diff --git a/Sming/system/esp-lwip/lwip/debug.h b/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/debug.h similarity index 100% rename from Sming/system/esp-lwip/lwip/debug.h rename to Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/debug.h diff --git a/Sming/system/esp-lwip/lwip/def.h b/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/def.h similarity index 100% rename from Sming/system/esp-lwip/lwip/def.h rename to Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/def.h diff --git a/Sming/system/esp-lwip/lwip/dhcp.h b/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/dhcp.h similarity index 100% rename from Sming/system/esp-lwip/lwip/dhcp.h rename to Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/dhcp.h diff --git a/Sming/system/esp-lwip/lwip/dns.h b/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/dns.h similarity index 100% rename from Sming/system/esp-lwip/lwip/dns.h rename to Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/dns.h diff --git a/Sming/system/esp-lwip/lwip/err.h b/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/err.h similarity index 100% rename from Sming/system/esp-lwip/lwip/err.h rename to Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/err.h diff --git a/Sming/system/esp-lwip/lwip/icmp.h b/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/icmp.h similarity index 100% rename from Sming/system/esp-lwip/lwip/icmp.h rename to Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/icmp.h diff --git a/Sming/system/esp-lwip/lwip/igmp.h b/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/igmp.h similarity index 100% rename from Sming/system/esp-lwip/lwip/igmp.h rename to Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/igmp.h diff --git a/Sming/system/esp-lwip/lwip/inet.h b/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/inet.h similarity index 100% rename from Sming/system/esp-lwip/lwip/inet.h rename to Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/inet.h diff --git a/Sming/system/esp-lwip/lwip/inet_chksum.h b/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/inet_chksum.h similarity index 100% rename from Sming/system/esp-lwip/lwip/inet_chksum.h rename to Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/inet_chksum.h diff --git a/Sming/system/esp-lwip/lwip/init.h b/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/init.h similarity index 100% rename from Sming/system/esp-lwip/lwip/init.h rename to Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/init.h diff --git a/Sming/system/esp-lwip/lwip/ip.h b/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/ip.h similarity index 100% rename from Sming/system/esp-lwip/lwip/ip.h rename to Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/ip.h diff --git a/Sming/system/esp-lwip/lwip/ip_addr.h b/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/ip_addr.h similarity index 100% rename from Sming/system/esp-lwip/lwip/ip_addr.h rename to Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/ip_addr.h diff --git a/Sming/system/esp-lwip/lwip/ip_frag.h b/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/ip_frag.h similarity index 100% rename from Sming/system/esp-lwip/lwip/ip_frag.h rename to Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/ip_frag.h diff --git a/Sming/system/esp-lwip/lwip/mem.h b/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/mem.h similarity index 100% rename from Sming/system/esp-lwip/lwip/mem.h rename to Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/mem.h diff --git a/Sming/system/esp-lwip/lwip/memp.h b/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/memp.h similarity index 100% rename from Sming/system/esp-lwip/lwip/memp.h rename to Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/memp.h diff --git a/Sming/system/esp-lwip/lwip/memp_std.h b/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/memp_std.h similarity index 100% rename from Sming/system/esp-lwip/lwip/memp_std.h rename to Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/memp_std.h diff --git a/Sming/system/esp-lwip/lwip/netbuf.h b/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/netbuf.h similarity index 100% rename from Sming/system/esp-lwip/lwip/netbuf.h rename to Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/netbuf.h diff --git a/Sming/system/esp-lwip/lwip/netdb.h b/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/netdb.h similarity index 100% rename from Sming/system/esp-lwip/lwip/netdb.h rename to Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/netdb.h diff --git a/Sming/system/esp-lwip/lwip/netif.h b/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/netif.h similarity index 100% rename from Sming/system/esp-lwip/lwip/netif.h rename to Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/netif.h diff --git a/Sming/system/esp-lwip/lwip/netifapi.h b/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/netifapi.h similarity index 100% rename from Sming/system/esp-lwip/lwip/netifapi.h rename to Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/netifapi.h diff --git a/Sming/system/esp-lwip/lwip/opt.h b/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/opt.h similarity index 100% rename from Sming/system/esp-lwip/lwip/opt.h rename to Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/opt.h diff --git a/Sming/system/esp-lwip/lwip/pbuf.h b/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/pbuf.h similarity index 100% rename from Sming/system/esp-lwip/lwip/pbuf.h rename to Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/pbuf.h diff --git a/Sming/system/esp-lwip/lwip/raw.h b/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/raw.h similarity index 100% rename from Sming/system/esp-lwip/lwip/raw.h rename to Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/raw.h diff --git a/Sming/system/esp-lwip/lwip/sio.h b/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/sio.h similarity index 100% rename from Sming/system/esp-lwip/lwip/sio.h rename to Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/sio.h diff --git a/Sming/system/esp-lwip/lwip/snmp.h b/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/snmp.h similarity index 100% rename from Sming/system/esp-lwip/lwip/snmp.h rename to Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/snmp.h diff --git a/Sming/system/esp-lwip/lwip/snmp_asn1.h b/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/snmp_asn1.h similarity index 100% rename from Sming/system/esp-lwip/lwip/snmp_asn1.h rename to Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/snmp_asn1.h diff --git a/Sming/system/esp-lwip/lwip/snmp_msg.h b/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/snmp_msg.h similarity index 100% rename from Sming/system/esp-lwip/lwip/snmp_msg.h rename to Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/snmp_msg.h diff --git a/Sming/system/esp-lwip/lwip/snmp_structs.h b/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/snmp_structs.h similarity index 100% rename from Sming/system/esp-lwip/lwip/snmp_structs.h rename to Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/snmp_structs.h diff --git a/Sming/system/esp-lwip/lwip/sockets.h b/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/sockets.h similarity index 100% rename from Sming/system/esp-lwip/lwip/sockets.h rename to Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/sockets.h diff --git a/Sming/system/esp-lwip/lwip/stats.h b/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/stats.h similarity index 100% rename from Sming/system/esp-lwip/lwip/stats.h rename to Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/stats.h diff --git a/Sming/system/esp-lwip/lwip/sys.h b/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/sys.h similarity index 100% rename from Sming/system/esp-lwip/lwip/sys.h rename to Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/sys.h diff --git a/Sming/system/esp-lwip/lwip/tcp.h b/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/tcp.h similarity index 100% rename from Sming/system/esp-lwip/lwip/tcp.h rename to Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/tcp.h diff --git a/Sming/system/esp-lwip/lwip/tcp_impl.h b/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/tcp_impl.h similarity index 100% rename from Sming/system/esp-lwip/lwip/tcp_impl.h rename to Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/tcp_impl.h diff --git a/Sming/system/esp-lwip/lwip/tcpip.h b/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/tcpip.h similarity index 100% rename from Sming/system/esp-lwip/lwip/tcpip.h rename to Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/tcpip.h diff --git a/Sming/system/esp-lwip/lwip/timers.h b/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/timers.h similarity index 100% rename from Sming/system/esp-lwip/lwip/timers.h rename to Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/timers.h diff --git a/Sming/system/esp-lwip/lwip/udp.h b/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/udp.h similarity index 100% rename from Sming/system/esp-lwip/lwip/udp.h rename to Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/udp.h diff --git a/Sming/system/esp-lwip/lwipopts.h b/Sming/Platform/Esp8266/System/components/esp-lwip/lwipopts.h similarity index 100% rename from Sming/system/esp-lwip/lwipopts.h rename to Sming/Platform/Esp8266/System/components/esp-lwip/lwipopts.h diff --git a/Sming/system/include/mem_manager.h b/Sming/Platform/Esp8266/System/components/esp-lwip/mem_manager.h similarity index 100% rename from Sming/system/include/mem_manager.h rename to Sming/Platform/Esp8266/System/components/esp-lwip/mem_manager.h diff --git a/Sming/third-party/esp-open-lwip b/Sming/Platform/Esp8266/System/components/esp-open-lwip/esp-open-lwip similarity index 100% rename from Sming/third-party/esp-open-lwip rename to Sming/Platform/Esp8266/System/components/esp-open-lwip/esp-open-lwip diff --git a/Sming/third-party/.patches/esp-open-lwip.patch b/Sming/Platform/Esp8266/System/components/esp-open-lwip/esp-open-lwip.patch similarity index 100% rename from Sming/third-party/.patches/esp-open-lwip.patch rename to Sming/Platform/Esp8266/System/components/esp-open-lwip/esp-open-lwip.patch diff --git a/Sming/system/crash_handler.c b/Sming/Platform/Esp8266/System/components/esp8266/crash_handler.c similarity index 98% rename from Sming/system/crash_handler.c rename to Sming/Platform/Esp8266/System/components/esp8266/crash_handler.c index 8b31fd3a6e..d5dcf5d3a7 100644 --- a/Sming/system/crash_handler.c +++ b/Sming/Platform/Esp8266/System/components/esp8266/crash_handler.c @@ -21,7 +21,7 @@ */ #include -#include "gdb_hooks.h" +#include "gdb/gdb_hooks.h" extern void __real_system_restart_local(); diff --git a/Sming/system/esp_cplusplus.cpp b/Sming/Platform/Esp8266/System/components/esp8266/esp_cplusplus.cpp similarity index 93% rename from Sming/system/esp_cplusplus.cpp rename to Sming/Platform/Esp8266/System/components/esp8266/esp_cplusplus.cpp index dbc340026e..2d95b5bc74 100644 --- a/Sming/system/esp_cplusplus.cpp +++ b/Sming/Platform/Esp8266/System/components/esp8266/esp_cplusplus.cpp @@ -1,5 +1,5 @@ -#include "../include/user_config.h" -#include "../include/esp_cplusplus.h" +#include +#include "include/esp_cplusplus.h" #include //////////////////////////////////////////////////////////////////////// diff --git a/Sming/system/flashmem.c b/Sming/Platform/Esp8266/System/components/esp8266/flashmem.c similarity index 100% rename from Sming/system/flashmem.c rename to Sming/Platform/Esp8266/System/components/esp8266/flashmem.c diff --git a/Sming/system/include/esp_cplusplus.h b/Sming/Platform/Esp8266/System/components/esp8266/include/esp_cplusplus.h similarity index 100% rename from Sming/system/include/esp_cplusplus.h rename to Sming/Platform/Esp8266/System/components/esp8266/include/esp_cplusplus.h diff --git a/Sming/system/include/esp_systemapi.h b/Sming/Platform/Esp8266/System/components/esp8266/include/esp_systemapi.h similarity index 100% rename from Sming/system/include/esp_systemapi.h rename to Sming/Platform/Esp8266/System/components/esp8266/include/esp_systemapi.h diff --git a/Sming/system/include/esp_wifi_sniffer.h b/Sming/Platform/Esp8266/System/components/esp8266/include/esp_wifi_sniffer.h similarity index 100% rename from Sming/system/include/esp_wifi_sniffer.h rename to Sming/Platform/Esp8266/System/components/esp8266/include/esp_wifi_sniffer.h diff --git a/Sming/system/include/espinc/c_types_compatible.h b/Sming/Platform/Esp8266/System/components/esp8266/include/espinc/c_types_compatible.h similarity index 100% rename from Sming/system/include/espinc/c_types_compatible.h rename to Sming/Platform/Esp8266/System/components/esp8266/include/espinc/c_types_compatible.h diff --git a/Sming/system/include/espinc/lwip_includes.h b/Sming/Platform/Esp8266/System/components/esp8266/include/espinc/lwip_includes.h similarity index 100% rename from Sming/system/include/espinc/lwip_includes.h rename to Sming/Platform/Esp8266/System/components/esp8266/include/espinc/lwip_includes.h diff --git a/Sming/system/include/espinc/peri.h b/Sming/Platform/Esp8266/System/components/esp8266/include/espinc/peri.h similarity index 100% rename from Sming/system/include/espinc/peri.h rename to Sming/Platform/Esp8266/System/components/esp8266/include/espinc/peri.h diff --git a/Sming/system/include/espinc/spi_register.h b/Sming/Platform/Esp8266/System/components/esp8266/include/espinc/spi_register.h similarity index 100% rename from Sming/system/include/espinc/spi_register.h rename to Sming/Platform/Esp8266/System/components/esp8266/include/espinc/spi_register.h diff --git a/Sming/system/include/espinc/uart_register.h b/Sming/Platform/Esp8266/System/components/esp8266/include/espinc/uart_register.h similarity index 100% rename from Sming/system/include/espinc/uart_register.h rename to Sming/Platform/Esp8266/System/components/esp8266/include/espinc/uart_register.h diff --git a/Sming/system/include/flashmem.h b/Sming/Platform/Esp8266/System/components/esp8266/include/flashmem.h similarity index 100% rename from Sming/system/include/flashmem.h rename to Sming/Platform/Esp8266/System/components/esp8266/include/flashmem.h diff --git a/Sming/system/irq_check.s b/Sming/Platform/Esp8266/System/components/esp8266/irq_check.s similarity index 100% rename from Sming/system/irq_check.s rename to Sming/Platform/Esp8266/System/components/esp8266/irq_check.s diff --git a/Sming/appinit/user_main.cpp b/Sming/Platform/Esp8266/System/components/esp8266/startup.cpp similarity index 98% rename from Sming/appinit/user_main.cpp rename to Sming/Platform/Esp8266/System/components/esp8266/startup.cpp index 39767f50a1..6cbc9a5bc0 100644 --- a/Sming/appinit/user_main.cpp +++ b/Sming/Platform/Esp8266/System/components/esp8266/startup.cpp @@ -10,8 +10,8 @@ #include #include "Platform/System.h" -#include "espinc/uart.h" -#include "gdb_hooks.h" +#include +#include extern void init(); diff --git a/Sming/system/xt_interrupts.cpp b/Sming/Platform/Esp8266/System/components/esp8266/xt_interrupts.cpp similarity index 100% rename from Sming/system/xt_interrupts.cpp rename to Sming/Platform/Esp8266/System/components/esp8266/xt_interrupts.cpp diff --git a/Sming/Services/FATFS/diskio.h b/Sming/Platform/Esp8266/System/components/fatfs/diskio.h similarity index 100% rename from Sming/Services/FATFS/diskio.h rename to Sming/Platform/Esp8266/System/components/fatfs/diskio.h diff --git a/Sming/Services/FATFS/ff.c b/Sming/Platform/Esp8266/System/components/fatfs/ff.c similarity index 100% rename from Sming/Services/FATFS/ff.c rename to Sming/Platform/Esp8266/System/components/fatfs/ff.c diff --git a/Sming/Services/FATFS/ff.h b/Sming/Platform/Esp8266/System/components/fatfs/ff.h similarity index 100% rename from Sming/Services/FATFS/ff.h rename to Sming/Platform/Esp8266/System/components/fatfs/ff.h diff --git a/Sming/Services/FATFS/ffconf.h b/Sming/Platform/Esp8266/System/components/fatfs/ffconf.h similarity index 100% rename from Sming/Services/FATFS/ffconf.h rename to Sming/Platform/Esp8266/System/components/fatfs/ffconf.h diff --git a/Sming/Services/FATFS/integer.h b/Sming/Platform/Esp8266/System/components/fatfs/integer.h similarity index 100% rename from Sming/Services/FATFS/integer.h rename to Sming/Platform/Esp8266/System/components/fatfs/integer.h diff --git a/Sming/gdb/GdbPacket.cpp b/Sming/Platform/Esp8266/System/components/gdbstub/GdbPacket.cpp similarity index 100% rename from Sming/gdb/GdbPacket.cpp rename to Sming/Platform/Esp8266/System/components/gdbstub/GdbPacket.cpp diff --git a/Sming/gdb/GdbPacket.h b/Sming/Platform/Esp8266/System/components/gdbstub/GdbPacket.h similarity index 100% rename from Sming/gdb/GdbPacket.h rename to Sming/Platform/Esp8266/System/components/gdbstub/GdbPacket.h diff --git a/Sming/appspecific/gdb/gdb_hooks.cpp b/Sming/Platform/Esp8266/System/components/gdbstub/appcode/gdb_hooks.cpp similarity index 93% rename from Sming/appspecific/gdb/gdb_hooks.cpp rename to Sming/Platform/Esp8266/System/components/gdbstub/appcode/gdb_hooks.cpp index 638593a9d9..78473e0b12 100644 --- a/Sming/appspecific/gdb/gdb_hooks.cpp +++ b/Sming/Platform/Esp8266/System/components/gdbstub/appcode/gdb_hooks.cpp @@ -8,13 +8,13 @@ * ****/ -#include -#include -#include "gdb/gdbstub.h" -#include "gdb/gdbuart.h" -#include "gdb/gdbstub-entry.h" -#include "gdb/exceptions.h" -#include +#include +#include +#include "gdbstub/gdbstub.h" +#include "gdbstub/gdbuart.h" +#include "gdbstub/gdbstub-entry.h" +#include "gdbstub/exceptions.h" +#include extern "C" { diff --git a/Sming/appspecific/gdb/gdbstub-entry.S b/Sming/Platform/Esp8266/System/components/gdbstub/appcode/gdbstub-entry.S similarity index 99% rename from Sming/appspecific/gdb/gdbstub-entry.S rename to Sming/Platform/Esp8266/System/components/gdbstub/appcode/gdbstub-entry.S index 4403f316db..66281605c3 100644 --- a/Sming/appspecific/gdb/gdbstub-entry.S +++ b/Sming/Platform/Esp8266/System/components/gdbstub/appcode/gdbstub-entry.S @@ -6,7 +6,7 @@ * License: ESPRESSIF MIT License *******************************************************************************/ -#include "gdb/gdbstub-internal.h" +#include "gdbstub/gdbstub-internal.h" #include #include diff --git a/Sming/gdb/exceptions.h b/Sming/Platform/Esp8266/System/components/gdbstub/exceptions.h similarity index 100% rename from Sming/gdb/exceptions.h rename to Sming/Platform/Esp8266/System/components/gdbstub/exceptions.h diff --git a/Sming/gdb/gdb/registers.h b/Sming/Platform/Esp8266/System/components/gdbstub/gdb/registers.h similarity index 100% rename from Sming/gdb/gdb/registers.h rename to Sming/Platform/Esp8266/System/components/gdbstub/gdb/registers.h diff --git a/Sming/gdb/gdb/signals.def b/Sming/Platform/Esp8266/System/components/gdbstub/gdb/signals.def similarity index 100% rename from Sming/gdb/gdb/signals.def rename to Sming/Platform/Esp8266/System/components/gdbstub/gdb/signals.def diff --git a/Sming/gdb/gdb/signals.h b/Sming/Platform/Esp8266/System/components/gdbstub/gdb/signals.h similarity index 100% rename from Sming/gdb/gdb/signals.h rename to Sming/Platform/Esp8266/System/components/gdbstub/gdb/signals.h diff --git a/Sming/gdb/gdbcmds b/Sming/Platform/Esp8266/System/components/gdbstub/gdbcmds similarity index 100% rename from Sming/gdb/gdbcmds rename to Sming/Platform/Esp8266/System/components/gdbstub/gdbcmds diff --git a/Sming/gdb/gdbhostio.cpp b/Sming/Platform/Esp8266/System/components/gdbstub/gdbhostio.cpp similarity index 100% rename from Sming/gdb/gdbhostio.cpp rename to Sming/Platform/Esp8266/System/components/gdbstub/gdbhostio.cpp diff --git a/Sming/gdb/gdbhostio.h b/Sming/Platform/Esp8266/System/components/gdbstub/gdbhostio.h similarity index 100% rename from Sming/gdb/gdbhostio.h rename to Sming/Platform/Esp8266/System/components/gdbstub/gdbhostio.h diff --git a/Sming/gdb/gdbstub-cfg.h b/Sming/Platform/Esp8266/System/components/gdbstub/gdbstub-cfg.h similarity index 100% rename from Sming/gdb/gdbstub-cfg.h rename to Sming/Platform/Esp8266/System/components/gdbstub/gdbstub-cfg.h diff --git a/Sming/gdb/gdbstub-entry.h b/Sming/Platform/Esp8266/System/components/gdbstub/gdbstub-entry.h similarity index 100% rename from Sming/gdb/gdbstub-entry.h rename to Sming/Platform/Esp8266/System/components/gdbstub/gdbstub-entry.h diff --git a/Sming/gdb/gdbstub-internal.h b/Sming/Platform/Esp8266/System/components/gdbstub/gdbstub-internal.h similarity index 100% rename from Sming/gdb/gdbstub-internal.h rename to Sming/Platform/Esp8266/System/components/gdbstub/gdbstub-internal.h diff --git a/Sming/gdb/gdbstub.cpp b/Sming/Platform/Esp8266/System/components/gdbstub/gdbstub.cpp similarity index 99% rename from Sming/gdb/gdbstub.cpp rename to Sming/Platform/Esp8266/System/components/gdbstub/gdbstub.cpp index b432cde6e8..581994a714 100644 --- a/Sming/gdb/gdbstub.cpp +++ b/Sming/Platform/Esp8266/System/components/gdbstub/gdbstub.cpp @@ -30,7 +30,7 @@ #include "gdbstub.h" #include "gdbstub-entry.h" -#include "gdb_hooks.h" +#include #include "GdbPacket.h" #include "exceptions.h" #include "gdb/registers.h" diff --git a/Sming/gdb/gdbstub.h b/Sming/Platform/Esp8266/System/components/gdbstub/gdbstub.h similarity index 96% rename from Sming/gdb/gdbstub.h rename to Sming/Platform/Esp8266/System/components/gdbstub/gdbstub.h index 1048388323..3122e69b1e 100644 --- a/Sming/gdb/gdbstub.h +++ b/Sming/Platform/Esp8266/System/components/gdbstub/gdbstub.h @@ -14,7 +14,7 @@ #define _GDB_GDBSTUB_H_ #include "gdbstub-internal.h" -#include +#include #include "BitManipulations.h" // GDB_xx macro versions required to ensure no flash access if requested diff --git a/Sming/gdb/gdbsyscall.cpp b/Sming/Platform/Esp8266/System/components/gdbstub/gdbsyscall.cpp similarity index 95% rename from Sming/gdb/gdbsyscall.cpp rename to Sming/Platform/Esp8266/System/components/gdbstub/gdbsyscall.cpp index 294b2c4aad..84a145d84a 100644 --- a/Sming/gdb/gdbsyscall.cpp +++ b/Sming/Platform/Esp8266/System/components/gdbstub/gdbsyscall.cpp @@ -16,7 +16,7 @@ #include "gdbsyscall.h" #include "GdbPacket.h" -#include +#include #include #include "Platform/System.h" diff --git a/Sming/gdb/gdbsyscall.h b/Sming/Platform/Esp8266/System/components/gdbstub/gdbsyscall.h similarity index 100% rename from Sming/gdb/gdbsyscall.h rename to Sming/Platform/Esp8266/System/components/gdbstub/gdbsyscall.h diff --git a/Sming/gdb/gdbuart.cpp b/Sming/Platform/Esp8266/System/components/gdbstub/gdbuart.cpp similarity index 95% rename from Sming/gdb/gdbuart.cpp rename to Sming/Platform/Esp8266/System/components/gdbstub/gdbuart.cpp index f1542e61c5..2f027bab68 100644 --- a/Sming/gdb/gdbuart.cpp +++ b/Sming/Platform/Esp8266/System/components/gdbstub/gdbuart.cpp @@ -12,7 +12,7 @@ #include "gdbuart.h" #include "GdbPacket.h" -#include "espinc/uart.h" +#include "driver/uart.h" #include "Data/Buffer/SerialBuffer.h" #include "Platform/System.h" #include "HardwareSerial.h" diff --git a/Sming/gdb/gdbuart.h b/Sming/Platform/Esp8266/System/components/gdbstub/gdbuart.h similarity index 100% rename from Sming/gdb/gdbuart.h rename to Sming/Platform/Esp8266/System/components/gdbstub/gdbuart.h diff --git a/Sming/gdb/readme.md b/Sming/Platform/Esp8266/System/components/gdbstub/readme.md similarity index 100% rename from Sming/gdb/readme.md rename to Sming/Platform/Esp8266/System/components/gdbstub/readme.md diff --git a/Sming/gdb/symbols/bootrom.elf b/Sming/Platform/Esp8266/System/components/gdbstub/symbols/bootrom.elf similarity index 100% rename from Sming/gdb/symbols/bootrom.elf rename to Sming/Platform/Esp8266/System/components/gdbstub/symbols/bootrom.elf diff --git a/Sming/gdb/xtensa/xtruntime-frames.h b/Sming/Platform/Esp8266/System/components/gdbstub/xtensa/xtruntime-frames.h similarity index 100% rename from Sming/gdb/xtensa/xtruntime-frames.h rename to Sming/Platform/Esp8266/System/components/gdbstub/xtensa/xtruntime-frames.h diff --git a/Sming/third-party/lwip2 b/Sming/Platform/Esp8266/System/components/lwip2/lwip2 similarity index 100% rename from Sming/third-party/lwip2 rename to Sming/Platform/Esp8266/System/components/lwip2/lwip2 diff --git a/Sming/third-party/.patches/lwip2.patch b/Sming/Platform/Esp8266/System/components/lwip2/lwip2.patch similarity index 100% rename from Sming/third-party/.patches/lwip2.patch rename to Sming/Platform/Esp8266/System/components/lwip2/lwip2.patch diff --git a/Sming/third-party/pwm b/Sming/Platform/Esp8266/System/components/pwm/new-pwm similarity index 100% rename from Sming/third-party/pwm rename to Sming/Platform/Esp8266/System/components/pwm/new-pwm diff --git a/Sming/third-party/.patches/pwm.patch b/Sming/Platform/Esp8266/System/components/pwm/new-pwm.patch similarity index 100% rename from Sming/third-party/.patches/pwm.patch rename to Sming/Platform/Esp8266/System/components/pwm/new-pwm.patch diff --git a/Sming/system/include/rboot-integration.h b/Sming/Platform/Esp8266/System/components/rboot/appcode/rboot-integration.h similarity index 100% rename from Sming/system/include/rboot-integration.h rename to Sming/Platform/Esp8266/System/components/rboot/appcode/rboot-integration.h diff --git a/Sming/appspecific/rboot/overrides.c b/Sming/Platform/Esp8266/System/components/rboot/appcode/rboot-overrides.c similarity index 100% rename from Sming/appspecific/rboot/overrides.c rename to Sming/Platform/Esp8266/System/components/rboot/appcode/rboot-overrides.c diff --git a/Sming/third-party/rboot b/Sming/Platform/Esp8266/System/components/rboot/rboot similarity index 100% rename from Sming/third-party/rboot rename to Sming/Platform/Esp8266/System/components/rboot/rboot diff --git a/Sming/third-party/.patches/rboot.patch b/Sming/Platform/Esp8266/System/components/rboot/rboot.patch similarity index 100% rename from Sming/third-party/.patches/rboot.patch rename to Sming/Platform/Esp8266/System/components/rboot/rboot.patch diff --git a/Sming/Services/SpifFS/spiffs_config.h b/Sming/Platform/Esp8266/System/components/spiffs/spiffs_config.h similarity index 100% rename from Sming/Services/SpifFS/spiffs_config.h rename to Sming/Platform/Esp8266/System/components/spiffs/spiffs_config.h diff --git a/Sming/Services/SpifFS/spiffs_sming.c b/Sming/Platform/Esp8266/System/components/spiffs/spiffs_sming.c similarity index 100% rename from Sming/Services/SpifFS/spiffs_sming.c rename to Sming/Platform/Esp8266/System/components/spiffs/spiffs_sming.c diff --git a/Sming/Services/SpifFS/spiffs_sming.h b/Sming/Platform/Esp8266/System/components/spiffs/spiffs_sming.h similarity index 100% rename from Sming/Services/SpifFS/spiffs_sming.h rename to Sming/Platform/Esp8266/System/components/spiffs/spiffs_sming.h diff --git a/Sming/Services/SpifFS/spiffy_host.h b/Sming/Platform/Esp8266/System/components/spiffs/spiffy_host.h similarity index 100% rename from Sming/Services/SpifFS/spiffy_host.h rename to Sming/Platform/Esp8266/System/components/spiffs/spiffy_host.h diff --git a/Sming/include/user_config.h b/Sming/Platform/Esp8266/System/include/user_config.h similarity index 100% rename from Sming/include/user_config.h rename to Sming/Platform/Esp8266/System/include/user_config.h diff --git a/tools/decode-stacktrace.py b/Sming/Platform/Esp8266/Tools/decode-stacktrace.py old mode 100755 new mode 100644 similarity index 100% rename from tools/decode-stacktrace.py rename to Sming/Platform/Esp8266/Tools/decode-stacktrace.py diff --git a/tools/esptool2 b/Sming/Platform/Esp8266/Tools/esptool2 similarity index 100% rename from tools/esptool2 rename to Sming/Platform/Esp8266/Tools/esptool2 diff --git a/tools/memanalyzer.py b/Sming/Platform/Esp8266/Tools/memanalyzer.py similarity index 100% rename from tools/memanalyzer.py rename to Sming/Platform/Esp8266/Tools/memanalyzer.py diff --git a/tools/spiffy/.gitignore b/Sming/Platform/Esp8266/Tools/spiffy/.gitignore similarity index 100% rename from tools/spiffy/.gitignore rename to Sming/Platform/Esp8266/Tools/spiffy/.gitignore diff --git a/tools/spiffy/Makefile b/Sming/Platform/Esp8266/Tools/spiffy/Makefile similarity index 84% rename from tools/spiffy/Makefile rename to Sming/Platform/Esp8266/Tools/spiffy/Makefile index 1d296bee1c..97bbe395e0 100644 --- a/tools/spiffy/Makefile +++ b/Sming/Platform/Esp8266/Tools/spiffy/Makefile @@ -5,7 +5,7 @@ HOST_CC ?= gcc HOST_LD ?= gcc -INCDIR := -I$(SMING_HOME)/Services/SpifFS -I$(SMING_HOME)/third-party/spiffs/src +INCDIR := -I$(SMING_HOME)/$(SPIFFS_BASE) -I$(SMING_HOME)/third-party/spiffs/src CFLAGS := -O2 -Wall -Wno-unused-value ifeq ("$(V)","1") @@ -18,7 +18,7 @@ endif all: spiffy -%.o: $(SMING_HOME)/Services/SpifFS/%.c +%.o: $(SPIFFS_BASE)/%.c $(vecho) "CC $<" $(Q) $(HOST_CC) $(CFLAGS) $(INCDIR) -c $< -o $@ diff --git a/tools/spiffy/spiffy.c b/Sming/Platform/Esp8266/Tools/spiffy/spiffy.c similarity index 100% rename from tools/spiffy/spiffy.c rename to Sming/Platform/Esp8266/Tools/spiffy/spiffy.c diff --git a/Sming/Platform/Esp8266/app.mk b/Sming/Platform/Esp8266/app.mk new file mode 100644 index 0000000000..f9c9fd53b5 --- /dev/null +++ b/Sming/Platform/Esp8266/app.mk @@ -0,0 +1,430 @@ +### +# +# SMING Application Makefile for ESP8266 platform +# +### + +ifndef ESP_HOME +$(error ESP_HOME variable is not set to a valid directory.) +endif + +.PHONY: all checkdirs app spiff_update spiff_clean clean kill_term terminal gdb +all: libsming checkdirs app + +# rBoot options, overwrite them in the projects Makefile-user.mk +RBOOT_BIG_FLASH ?= 1 +RBOOT_TWO_ROMS ?= 0 +RBOOT_RTC_ENABLED ?= 0 +RBOOT_GPIO_ENABLED ?= 0 +# RBOOT_GPIO_SKIP_ENABLED and RBOOT_GPIO_ENABLED cannot be used at the same time. +RBOOT_GPIO_SKIP_ENABLED ?= 0 + +ifeq ($(RBOOT_GPIO_ENABLED)$(RBOOT_GPIO_SKIP_ENABLED),11) + $(error "Cannot enable RBOOT_GPIO_ENABLED and RBOOT_GPIO_SKIP_ENABLED at the same time) +endif + +### ROM Addresses ### +# The parameter below specifies the location of the second rom. +# This parameter is used only when RBOOT_BIG_FLASH = 1 +# BOOT_ROM1_ADDR = 0x200000 + +# The parameter below specifies the location of the GPIO ROM. +# This parameter is used only when RBOOT_GPIO_ENABLED = 1 +# If you use two SPIFFS make sure that this address is minimum +# RBOOT_SPIFFS_1 + SPIFF_SIZE +# BOOT_ROM2_ADDR = 0x310000 + +RBOOT_SILENT ?= 0 +RBOOT_ROM_0 ?= rom0 +RBOOT_ROM_1 ?= rom1 +RBOOT_LD_0 ?= rboot.rom0.ld +RBOOT_LD_1 ?= rom1.ld + +# +RBOOT_SPIFFS_0 ?= 0x100000 +RBOOT_SPIFFS_1 ?= 0x300000 + +# Fixed addresses +ROM_0_ADDR := 0x002000 +BLANK_BIN_ADDR := 0x04b000 +INIT_BIN_ADDR := 0x07c000 + +# filenames and options for generating rBoot rom images with esptool2 +RBOOT_E2_SECTS ?= .text .data .rodata +RBOOT_E2_USER_ARGS ?= -quiet -bin -boot2 + +RBOOT_ROM_0 := $(FW_BASE)/$(RBOOT_ROM_0).bin +RBOOT_ROM_1 := $(FW_BASE)/$(RBOOT_ROM_1).bin + +# Code compiled with application +APPCODE := + +EXTRA_INCDIR += $(PLATFORM_COMPONENTS) \ + $(PLATFORM_COMPONENTS)/esp8266/include \ + $(PLATFORM_COMPONENTS)/driver/include + +# Macro to make an optional library +# $1 -> The library to make +# $2 -> List of options to add to make command line +define MakeLibrary + $(Q) $(MAKE) -C $(SMING_HOME) $(patsubst $(SMING_HOME)/%,%,$1) $2 +endef + +# => rBoot +RBOOT_BASE := $(PLATFORM_COMPONENTS)/rboot +APPCODE += $(RBOOT_BASE)/appcode $(RBOOT_BASE)/rboot/appcode +EXTRA_INCDIR += $(RBOOT_BASE)/rboot +RBOOT_BIN := $(FW_BASE)/rboot.bin +CUSTOM_TARGETS += $(RBOOT_BIN) +CFLAGS += -DRBOOT_INTEGRATION +# these are exported for use by the rBoot Makefile +export RBOOT_SILENT +export RBOOT_BIG_FLASH +export RBOOT_BUILD_BASE := $(abspath $(BUILD_BASE)) +export RBOOT_FW_BASE := $(abspath $(FW_BASE)) +export RBOOT_RTC_ENABLED +export RBOOT_GPIO_ENABLED +export RBOOT_GPIO_SKIP_ENABLED +export RBOOT_ROM1_ADDR +export RBOOT_ROM2_ADDR +export SPI_SIZE +export SPI_MODE +export SPI_SPEED +export ESPTOOL2 +# multiple roms per 1mb block? +ifeq ($(RBOOT_TWO_ROMS),1) + # set a define so ota code can choose correct rom + CFLAGS += -DRBOOT_TWO_ROMS +else + # eliminate the second rBoot target + RBOOT_ROM_1 := +endif +ifeq ($(RBOOT_RTC_ENABLED),1) + # enable the temporary switch to rom feature + CFLAGS += -DBOOT_RTC_ENABLED +endif +ifeq ($(RBOOT_GPIO_ENABLED),1) + CFLAGS += -DBOOT_GPIO_ENABLED +endif +ifeq ($(RBOOT_GPIO_SKIP_ENABLED),1) + CFLAGS += -DBOOT_GPIO_SKIP_ENABLED +endif +$(RBOOT_BIN): + $(MAKE) -C $(PLATFORM_COMPONENTS)/rboot/rboot + + +# => SPIFFS +DISABLE_SPIFFS ?= 0 +SPIFF_BIN_OUT ?= spiff_rom +SPIFF_BIN_OUT := $(FW_BASE)/$(SPIFF_BIN_OUT).bin +EXTRA_INCDIR += $(PLATFORM_COMPONENTS)/spiffs $(THIRD_PARTY_DIR)/spiffs/src +CFLAGS += -DRBOOT_SPIFFS_0=$(RBOOT_SPIFFS_0) +CFLAGS += -DRBOOT_SPIFFS_1=$(RBOOT_SPIFFS_1) +CUSTOM_TARGETS += $(SPIFF_BIN_OUT) + +# => LWIP +ENABLE_CUSTOM_LWIP ?= 1 +ifeq ($(ENABLE_CUSTOM_LWIP), 0) + LIBLWIP := lwip + LWIP_BASE := $(PLATFORM_COMPONENTS)/esp-lwip + EXTRA_INCDIR += $(LWIP_BASE)/include $(LWIP_BASE) +else ifeq ($(ENABLE_CUSTOM_LWIP), 1) + LIBLWIP := lwip_open + EXTRA_INCDIR += $(PLATFORM_COMPONENTS)/esp-open-lwip/esp-open-lwip/include + ifeq ($(ENABLE_ESPCONN), 1) + LIBLWIP := lwip_full + endif +else ifeq ($(ENABLE_CUSTOM_LWIP), 2) + ifeq ($(ENABLE_ESPCONN), 1) + $(error LWIP2 does not support espconn_* functions. Make sure to set ENABLE_CUSTOM_LWIP to 0 or 1.) + endif + LIBLWIP := lwip2 + LWIP2_BASE := $(PLATFORM_COMPONENTS)/lwip2/lwip2 + EXTRA_INCDIR += $(LWIP2_BASE)/glue-esp/include-esp $(LWIP2_BASE)/include +else + EXTRA_INCDIR += $(PLATFORM_COMPONENTS)/esp-lwip/lwip/include +endif +LIBS += $(LIBLWIP) + +ifneq ($(ENABLE_CUSTOM_LWIP), 0) + LIBLWIP_DST := $(USER_LIBDIR)/lib$(LIBLWIP).a + CUSTOM_TARGETS += $(LIBLWIP_DST) + +$(LIBLWIP_DST): + $(call MakeLibrary,$@,ENABLE_CUSTOM_LWIP=$(ENABLE_CUSTOM_LWIP) ENABLE_ESPCONN=$(ENABLE_ESPCONN)) +endif + +# => GDB +APPCODE += $(PLATFORM_COMPONENTS)/gdbstub/appcode +EXTRA_INCDIR += $(PLATFORM_COMPONENTS)/gdbstub/include +ifeq ($(ENABLE_GDB), 1) + APPCODE += $(PLATFORM_COMPONENTS)/gdbstub + CUSTOM_TARGETS += gdb_symbols + +# Copy symbols required by GDB into build directory +.PHONY: gdb_symbols +gdb_symbols: $(BUILD_BASE)/bootrom.elf + +$(BUILD_BASE)/%.elf: + $(Q) cp $(PLATFORM_COMPONENTS)/gdbstub/symbols/$(notdir $@) $@ +endif + +# Full GDB command line +GDB := trap '' INT; $(GDB) -x $(PLATFORM_COMPONENTS)/gdbstub/gdbcmds -b $(COM_SPEED_SERIAL) -ex "target remote $(COM_PORT)" + + +# => WPS +ifeq ($(ENABLE_WPS),1) + CFLAGS += -DENABLE_WPS=1 + LIBS += wps +endif + +# => MQTT +# Flags for compatability with old versions (most of them should disappear with the next major release) +ifeq ($(MQTT_NO_COMPAT),1) + CFLAGS += -DMQTT_NO_COMPAT=1 +endif + +# => Custom heap +ENABLE_CUSTOM_HEAP ?= 0 +ifeq ($(ENABLE_CUSTOM_HEAP),1) + LIBMAIN := mainmm + LIBMAIN_SRC := $(call UserLibPath,$(LIBMAIN)) + CUSTOM_TARGETS += $(LIBMAIN_SRC) + +$(LIBMAIN_SRC): + $(call MakeLibrary,$@,ENABLE_CUSTOM_HEAP=1) +else + LIBMAIN := main + LIBMAIN_SRC := $(SDK_LIBDIR)/lib$(LIBMAIN).a +endif + +# libmain must be modified for rBoot big flash support (just one symbol gets weakened) +ifeq ($(RBOOT_BIG_FLASH),1) + LIBMAIN := main2 + CFLAGS += -DBOOT_BIG_FLASH + LIBMAIN_DST := $(BUILD_BASE)/lib$(LIBMAIN).a + CUSTOM_TARGETS += $(LIBMAIN_DST) + +$(LIBMAIN_DST): $(LIBMAIN_SRC) + echo "OC $@" + $(Q) $(OBJCOPY) -W Cache_Read_Enable_New $^ $@ +endif + +LIBS += $(LIBMAIN) + + + +# SSL support using axTLS +ifeq ($(ENABLE_SSL),1) + LIBAXTLS := axtls + LIBS += $(LIBAXTLS) + LIBAXTLS_DST := $(call UserLibPath,$(LIBAXTLS)) + AXTLS_BASE := $(PLATFORM_COMPONENTS)/axtls-8266/axtls-8266 + EXTRA_INCDIR += $(AXTLS_BASE)/.. $(AXTLS_BASE) $(AXTLS_BASE)/ssl $(AXTLS_BASE)/crypto + AXTLS_FLAGS := -DLWIP_RAW=1 -DENABLE_SSL=1 + ifeq ($(SSL_DEBUG),1) # + AXTLS_FLAGS += -DSSL_DEBUG=1 -DDEBUG_TLS_MEM=1 + endif + + CUSTOM_TARGETS += $(LIBAXTLS_DST) include/ssl/private_key.h + CFLAGS += $(AXTLS_FLAGS) + +$(LIBAXTLS_DST): + $(call MakeLibrary,$@,ENABLE_SSL=1) + +include/ssl/private_key.h: + $(vecho) "Generating unique certificate and key. This may take some time" + $(Q) mkdir -p $(CURRENT_DIR)/include/ssl/ + AXDIR=$(CURRENT_DIR)/include/ssl/ $(PLATFORM_COMPONENTS)/axtls-8266/axtls-8266/tools/make_certs.sh +endif + + +# => PWM +ENABLE_CUSTOM_PWM ?= 1 +ifeq ($(ENABLE_CUSTOM_PWM), 1) + LIBPWM := pwm_open + LIBPWM_DST := $(call UserLibPath,$(LIBPWM)) + CUSTOM_TARGETS += $(LIBPWM_DST) + +$(LIBPWM_DST): + $(call MakeLibrary,$@,ENABLE_CUSTOM_PWM=1) +else + LIBPWM := pwm +endif +LIBS += $(LIBPWM) + + +LIBS := microc microgcc hal phy pp net80211 mqttc wpa $(LIBSMING) crypto smartconfig $(EXTRA_LIBS) $(LIBS) + +LIBS := $(addprefix -l,$(LIBS)) + +# linker flags used to generate the main object file +LDFLAGS = -nostdlib -u call_user_start -u Cache_Read_Enable_New -u spiffs_get_storage_config -u custom_crash_callback \ + -Wl,-static -Wl,--gc-sections -Wl,-Map=$(basename $@).map -Wl,-wrap,system_restart_local + +include $(PLATFORM_BASE)/flash.mk + +TARGET_OUT_0 := $(BUILD_BASE)/$(TARGET)_0.out +TARGET_OUT_1 := $(BUILD_BASE)/$(TARGET)_1.out + +############# +# +# Target definitions +# +############# + +include $(SMING_HOME)/modules.mk + +# Add APPCODE objects and targets +$(call ScanModules,$(APPCODE)) + +app: $(CUSTOM_TARGETS) $(RBOOT_ROM_0) $(RBOOT_ROM_1) $(FW_FILE_1) $(FW_FILE_2) + +spiff_update: spiff_clean $(SPIFF_BIN_OUT) + +# => Firmware images +$(RBOOT_ROM_0): $(TARGET_OUT_0) + $(vecho) "E2 $@" + $(Q) $(ESPTOOL2) $(RBOOT_E2_USER_ARGS) $< $@ $(RBOOT_E2_SECTS) + +$(RBOOT_ROM_1): $(TARGET_OUT_1) + $(vecho) "E2 $@" + $(Q) $(ESPTOOL2) $(RBOOT_E2_USER_ARGS) $< $@ $(RBOOT_E2_SECTS) + +$(TARGET_OUT_0): $(APP_AR) + $(vecho) "LD $@" + $(LD) -L$(USER_LIBDIR) -L$(SDK_LIBDIR) -L$(BUILD_BASE) -L$(PLATFORM_BASE)/Compiler/ld \ + -T$(RBOOT_LD_0) $(LDFLAGS) -Wl,--start-group $(APP_AR) $(LIBS) -Wl,--end-group -o $@ + + $(Q) $(MEMANALYZER) $@ > $(FW_MEMINFO_NEW) + + $(Q) if [ -f "$(FW_MEMINFO_NEW)" -a -f "$(FW_MEMINFO_OLD)" ]; then \ + awk -F "|" ' \ + FILENAME == "$(FW_MEMINFO_OLD)" { \ + arr[$$1]=$$5 \ + } \ + FILENAME == "$(FW_MEMINFO_NEW)" { \ + if (arr[$$1] != $$5) { \ + printf "%s%s%+d%s", substr($$0, 1, length($$0) - 1)," (",$$5 - arr[$$1],")\n" \ + } else { \ + print $$0 \ + } \ + }' $(FW_MEMINFO_OLD) $(FW_MEMINFO_NEW); \ + elif [ -f "$(FW_MEMINFO_NEW)" ]; then \ + cat $(FW_MEMINFO_NEW); \ + fi + + +$(TARGET_OUT_1): $(APP_AR) + $(vecho) "LD $@" + $(LD) -L$(USER_LIBDIR) -L$(SDK_LIBDIR) -L$(BUILD_BASE) -L$(PLATFORM_BASE)/Compiler/ld \ + -T$(RBOOT_LD_1) $(LDFLAGS) -Wl,--start-group $(APP_AR) $(LIBS) -Wl,--end-group -o $@ + +# recreate it from 0, since you get into problems with same filenames +$(APP_AR): $(OBJ) + $(vecho) "AR $@" + $(Q) test ! -f $@ || rm $@ + $(AR) rcsP $@ $^ + +.PHONY: libsming +libsming: $(USER_LIBDIR)/lib$(LIBSMING).a +$(USER_LIBDIR)/lib$(LIBSMING).a: + $(vecho) "(Re)compiling Sming. Enabled features: $(SMING_FEATURES). This may take some time" + $(Q) $(MAKE) -C $(SMING_HOME) clean V=$(V) ENABLE_SSL=$(ENABLE_SSL) + $(Q) $(MAKE) -C $(SMING_HOME) V=$(V) ENABLE_SSL=$(ENABLE_SSL) + + +checkdirs: | $(BUILD_DIR) $(FW_BASE) + +$(BUILD_DIR) $(FW_BASE): + $(Q) mkdir -p $@ + +spiff_clean: + $(vecho) "Cleaning $(SPIFF_BIN_OUT)" + $(Q) rm -rf $(SPIFF_BIN_OUT) + +$(SPIFF_BIN_OUT): +ifeq ($(DISABLE_SPIFFS), 1) + $(vecho) "(!) Spiffs support disabled. Remove 'DISABLE_SPIFFS' make argument to enable spiffs." +else +# Generating spiffs_bin + $(vecho) "Checking for spiffs files" + $(Q) if [ -d "$(SPIFF_FILES)" ]; then \ + echo "$(SPIFF_FILES) directory exists. Creating $(SPIFF_BIN_OUT)"; \ + $(SPIFFY) $(SPIFF_SIZE) $(SPIFF_FILES) $(SPIFF_BIN_OUT); \ + else \ + echo "No files found in ./$(SPIFF_FILES)."; \ + echo "Creating empty $(SPIFF_BIN_OUT)"; \ + $(SPIFFY) $(SPIFF_SIZE) dummy.dir $(SPIFF_BIN_OUT); \ + fi +endif + + +# Flashing + +flashboot: libsming $(RBOOT_BIN) + $(WRITE_FLASH) 0x00000 $(RBOOT_BIN) + +flashconfig: kill_term + $(vecho) "Deleting rBoot config sector" + $(WRITE_FLASH) 0x01000 $(SDK_BASE)/bin/blank.bin + +flashapp: all kill_term + $(WRITE_FLASH) $(ROM_0_ADDR) $(RBOOT_ROM_0) + +flashfs: libsming $(SPIFF_BIN_OUT) +ifeq ($(DISABLE_SPIFFS), 1) + $(vecho) "SPIFFS are not enabled!" +else + $(WRITE_FLASH) $(RBOOT_SPIFFS_0) $(SPIFF_BIN_OUT) +endif + +# flashes rboot and first rom +flash: all kill_term + FLASH_CHUNKS := 0x00000 $(RBOOT_BIN) + FLASH_CHUNKS += $(ROM_0_ADDR) $(RBOOT_ROM_0) + ifneq ($(DISABLE_SPIFFS), 1) + FLASH_CHUNKS += $(RBOOT_SPIFFS_0) $(SPIFF_BIN_OUT) + endif + $(WRITE_FLASH) $(FLASH_CHUNKS) + ifeq ($(ENABLE_GDB), 1) + $(GDB) + else + $(TERMINAL) + endif + +otaserver: all + $(vecho) "Starting OTA server for TESTING" + $(Q) cd $(FW_BASE) && python -m SimpleHTTPServer $(SERVER_OTA_PORT) + +kill_term: + $(vecho) "Killing Terminal to free $(COM_PORT)" + -$(Q) $(KILL_TERM) + +terminal: kill_term + $(TERMINAL) + +gdb: kill_term + $(GDB) + +# Wipe flash +flashinit: + FLASH_INIT_CHUNKS := $(INIT_BIN_ADDR) $(SDK_BASE)/bin/esp_init_data_default.bin + FLASH_INIT_CHUNKS += $(BLANK_BIN_ADDR) $(SDK_BASE)/bin/blank.bin + ifneq ($(DISABLE_SPIFFS), 1) + FLASH_INIT_CHUNKS += $(RBOOT_SPIFFS_0) $(PLATFORM_BASE)/Compiler/data/blankfs.bin + endif + $(vecho) "Flash init data default and blank data." + $(vecho) "DISABLE_SPIFFS = $(DISABLE_SPIFFS)" + $(ERASE_FLASH) + $(WRITE_FLASH) $(FLASH_INIT_CHUNKS) + + +rebuild: clean all + +# Remove build artifacts +clean: + $(Q) rm -rf $(BUILD_BASE) + $(Q) rm -rf $(FW_BASE) + diff --git a/Sming/Platform/Esp8266/build.mk b/Sming/Platform/Esp8266/build.mk new file mode 100644 index 0000000000..e9d623c544 --- /dev/null +++ b/Sming/Platform/Esp8266/build.mk @@ -0,0 +1,70 @@ +############## +# +# Platform build environment +# +############## + +ifndef ESP_HOME +$(error ESP_HOME variable is not set to a valid directory.) +endif + +## ESP_HOME sets the path where ESP tools and SDK are located. +## Windows: +# ESP_HOME = c:/Espressif + +## MacOS / Linux: +# ESP_HOME = /opt/esp-open-sdk + +ifeq ($(OS),Windows_NT) + # Convert Windows paths to POSIX paths + ESP_HOME := $(subst \,/,$(addprefix /,$(subst :,,$(ESP_HOME)))) + ESP_HOME := $(subst //,/,$(ESP_HOME)) +endif + +export ESP_HOME + +export PATH := $(ESP_HOME)/xtensa-lx106-elf/bin:$(PATH) +XTENSA_TOOLS_ROOT := $(ESP_HOME)/xtensa-lx106-elf/bin +CONFIG_TOOLPREFIX := xtensa-lx106-elf- +TOOLSPEC := $(XTENSA_TOOLS_ROOT)/$(CONFIG_TOOLPREFIX) + +# select which tools to use as assembler, compiler, librarian and linker +AS := $(TOOLSPEC)gcc +CC := $(TOOLSPEC)gcc +CXX := $(TOOLSPEC)g++ +AR := $(TOOLSPEC)ar +LD := $(TOOLSPEC)gcc +OBJCOPY := $(TOOLSPEC)objcopy +OBJDUMP := $(TOOLSPEC)objdump +GDB := $(TOOLSPEC)gdb + +CFLAGS_COMMON += -nostdlib -mlongcalls -mtext-section-literals +CFLAGS += -D__ets__ -DICACHE_FLASH -DUSE_OPTIMIZE_PRINTF -DESP8266=1 + +MFORCE32 := $(shell $(CC) --help=target | grep mforce-l32) +ifneq ($(MFORCE32),) + # Your compiler supports the -mforce-l32 flag which means that + # constants can be stored in flash (program) memory instead of SRAM. + # See: https://www.arduino.cc/en/Reference/PROGMEM + CFLAGS += -DPROGMEM_L32="__attribute__((aligned(4))) __attribute__((section(\".irom.text\")))" -mforce-l32 +else + CFLAGS += -DPROGMEM_L32="" +endif + +# => SDK +ifneq (,$(findstring $(THIRD_PARTY_DIR)/ESP8266_NONOS_SDK, $(SDK_BASE))) + CFLAGS += -DSDK_INTERNAL + SDK_INTERNAL = 1 +else + SDK_INTERNAL = 0 +endif + +# various paths from the SDK used in this project +SDK_LIBDIR := $(SDK_BASE)/lib +SDK_INCDIR := $(SDK_BASE)/include + + +# => Tools +ESPTOOL2 = $(PLATFORM_TOOLS)/esptool2/esptool2$(TOOL_EXT) +SPIFFY = $(PLATFORM_TOOLS)/spiffy/spiffy$(TOOL_EXT) + diff --git a/Sming/Platform/Esp8266/flash.mk b/Sming/Platform/Esp8266/flash.mk new file mode 100644 index 0000000000..f70253b0a3 --- /dev/null +++ b/Sming/Platform/Esp8266/flash.mk @@ -0,0 +1,57 @@ +## Flash parameters + +# SPI_SPEED = 40, 26, 20, 80 +SPI_SPEED ?= 40 +# SPI_MODE: qio, qout, dio, dout +SPI_MODE ?= qio +# SPI_SIZE: 512K, 256K, 1M, 2M, 4M +SPI_SIZE ?= 512K + +ifeq ($(SPI_SPEED), 26) + flashimageoptions := -ff 26m +else ifeq ($(SPI_SPEED), 20) + flashimageoptions := -ff 20m +else ifeq ($(SPI_SPEED), 80) + flashimageoptions := -ff 80m +else + flashimageoptions := -ff 40m +endif + +ifeq ($(SPI_MODE), qout) + flashimageoptions += -fm qout +else ifeq ($(SPI_MODE), dio) + flashimageoptions += -fm dio +else ifeq ($(SPI_MODE), dout) + flashimageoptions += -fm dout +else + flashimageoptions += -fm qio +endif + +ifeq ($(SPI_SIZE), 256K) + flashimageoptions += -fs 2m + SPIFF_SIZE ?= 131072 #128K +else ifeq ($(SPI_SIZE), 1M) + flashimageoptions += -fs 8m + SPIFF_SIZE ?= 524288 #512K + INIT_BIN_ADDR := 0x0fc000 + BLANK_BIN_ADDR := 0x0fe000 +else ifeq ($(SPI_SIZE), 2M) + flashimageoptions += -fs 16m + SPIFF_SIZE ?= 524288 #512K + INIT_BIN_ADDR := 0x1fc000 + BLANK_BIN_ADDR := 0x1fe000 +else ifeq ($(SPI_SIZE), 4M) + flashimageoptions += -fs 32m + SPIFF_SIZE ?= 524288 #512K + INIT_BIN_ADDR := 0x3fc000 + BLANK_BIN_ADDR := 0x3fe000 +else + flashimageoptions += -fs 4m + SPIFF_SIZE ?= 196608 #192K +endif + +CFLAGS += -DSPIFF_SIZE=$(SPIFF_SIZE) + +ESPTOOL := $(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED_ESPTOOL) +WRITE_FLASH := $(ESPTOOL) write_flash $(flashimageoptions) +ERASE_FLASH := $(ESPTOOL) erase_flash diff --git a/Sming/Platform/Esp8266/sming.mk b/Sming/Platform/Esp8266/sming.mk new file mode 100644 index 0000000000..2a399099ca --- /dev/null +++ b/Sming/Platform/Esp8266/sming.mk @@ -0,0 +1,179 @@ +# ESP8266 Sming framework + +# => SDK +SDK_INTERNAL = 0 +ifneq (,$(findstring $(THIRD_PARTY_DIR)/ESP8266_NONOS_SDK, $(SDK_BASE))) + SUBMODULES += $(SDK_BASE) + CFLAGS += -DSDK_INTERNAL + SDK_INTERNAL = 1 +endif + +EXTRA_INCDIR += $(PLATFORM_COMPONENTS) + +MODULES += $(PLATFORM_COMPONENTS)/esp8266 +EXTRA_INCDIR += $(PLATFORM_COMPONENTS)/esp8266/include $(PLATFORM_COMPONENTS)/driver/include + +MODULES += $(PLATFORM_COMPONENTS)/driver +EXTRA_INCDIR += $(PLATFORM_COMPONENTS)/driver/include + +MODULES += $(PLATFORM_COMPONENTS)/fatfs + +# => rboot +RBOOT_BASE := $(PLATFORM_COMPONENTS)/rboot/rboot +SUBMODULES += $(RBOOT_BASE) +EXTRA_INCDIR += $(RBOOT_BASE) $(RBOOT_BASE)/appcode + +# => SPIFFS +SPIFFS_BASE := $(PLATFORM_COMPONENTS)/spiffs +SUBMODULES += $(THIRD_PARTY_DIR)/spiffs +MODULES += $(SPIFFS_BASE) $(THIRD_PARTY_DIR)/spiffs/src +EXTRA_INCDIR += $(SPIFFS_BASE) $(SPIFFS_BASE)/spiffs/src + + +# => ESP8266_new_pwm +ENABLE_CUSTOM_PWM ?= 1 +ifeq ($(ENABLE_CUSTOM_PWM), 1) + PWM_BASE := $(PLATFORM_COMPONENTS)/pwm + SUBMODULES += $(PWM_BASE)/new-pwm + CFLAGS += -DSDK_PWM_PERIOD_COMPAT_MODE=1 + LIBPWM := pwm_open + LIBS += $(LIBPWM) + CLEAN += pwm-clean + +$(call UserLibPath,$(LIBPWM)): $(PWM_BASE)/new-pwm/pwm.c + $(Q) $(CC) $(INCDIR) $(MODULE_INCDIR) $(EXTRA_INCDIR) $(CFLAGS) -c $< -o $(dir $<)pwm.o + $(Q) $(AR) rcs $@ $(dir $<)pwm.o + +.PHONY: pwm-clean +pwm-clean: + -$(Q) rm -f $(PWM_BASE)/new-pwm/*.o +endif + + +# => umm_malloc (custom heap allocation) +ENABLE_CUSTOM_HEAP ?= 0 +ifeq ($(ENABLE_CUSTOM_HEAP), 1) + CUSTOM_HEAP_BASE := $(PLATFORM_COMPONENTS)/custom_heap + UMM_MALLOC_BASE := $(CUSTOM_HEAP_BASE)/umm_malloc + SUBMODULES += $(UMM_MALLOC_BASE) + MODULES += $(CUSTOM_HEAP_BASE) $(UMM_MALLOC_BASE)/src + EXTRA_INCDIR += $(UMM_MALLOC_BASE)/src $(UMM_MALLOC_BASE)/includes/c-helper-macros + LIBMAINMM := mainmm + LIBS += $(LIBMAINMM) + +# Make copy of libmain and remove mem_manager.o module +$(call UserLibPath,$(LIBMAINMM)): $(SDK_LIBDIR)/libmain.a + $(vecho) "Enabling custom heap implementation" + $(Q) cp $^ $@ + $(Q) $(AR) -d $@ mem_manager.o +endif + + +# => Open Source LWIP +ENABLE_CUSTOM_LWIP ?= 1 +ENABLE_ESPCONN ?= 0 +ifeq ($(ENABLE_CUSTOM_LWIP), 0) + LIBLWIP := lwip + LWIP_BASE := $(PLATFORM_COMPONENTS)/esp-lwip + EXTRA_INCDIR += $(LWIP_BASE)/include $(LWIP_BASE) +else + EXTRA_CFLAGS_LWIP := -I$(SMING_HOME)/System/include -I$(PLATFORM_SYS)/include -I$(PLATFORM_COMPONENTS)/esp8266/include -I$(SMING_HOME)/Wiring + ENABLE_LWIPDEBUG ?= 0 + ifeq ($(ENABLE_LWIPDEBUG), 1) + EXTRA_CFLAGS_LWIP += -DLWIP_DEBUG + endif + + ifeq ($(ENABLE_CUSTOM_LWIP), 1) + LWIP_BASE := $(PLATFORM_COMPONENTS)/esp-open-lwip/esp-open-lwip + SUBMODULES += $(LWIP_BASE) + EXTRA_INCDIR += $(LWIP_BASE)/include + ifeq ($(ENABLE_ESPCONN), 1) + LIBLWIP := lwip_full + else + LIBLWIP := lwip_open + endif + LWIP_BUILD = $(MAKE) -C $(LWIP_BASE) -f Makefile.open ENABLE_ESPCONN=$(ENABLE_ESPCONN) SDK_BASE=$(SDK_BASE) \ + USER_LIBDIR="$(SMING_HOME)/$(USER_LIBDIR)/" CFLAGS_EXTRA="$(EXTRA_CFLAGS_LWIP) $(CFLAGS_COMMON)" + else ifeq ($(ENABLE_CUSTOM_LWIP), 2) + ifeq ($(ENABLE_ESPCONN), 1) + $(error LWIP2 does not support espconn_* functions. Make sure to set ENABLE_CUSTOM_LWIP to 0 or 1.) + endif + LWIP_BASE := $(PLATFORM_COMPONENTS)/lwip2/lwip2 + SUBMODULES += $(LWIP_BASE) + EXTRA_INCDIR += $(LWIP_BASE)/glue-esp/include-esp $(LWIP_BASE)/include + LIBLWIP ?= lwip2 + LWIP_BUILD := $(MAKE) -C $(LWIP_BASE) -f Makefile.sming ENABLE_ESPCONN=$(ENABLE_ESPCONN) \ + SDK_BASE=$(SDK_BASE) SDK_INTERNAL=$(SDK_INTERNAL) \ + USER_LIBDIR="$(SMING_HOME)/$(USER_LIBDIR)/" CFLAGS_EXTRA="$(EXTRA_CFLAGS_LWIP)" + endif + LIBS += $(LIBLWIP) + CLEAN += lwip-clean + +$(call UserLibPath,lwip%): $(LWIP_BASE)/.submodule + $(vecho) "Building $(notdir $@)..." + $(Q) $(LWIP_BUILD) CC=$(CC) AR=$(AR) all + +.PHONY: lwip-clean +lwip-clean: + -$(Q) -$(LWIP_BUILD) clean + +endif + +# => SSL support using axTLS +ENABLE_SSL ?= 0 +ifeq ($(ENABLE_SSL),1) + AXTLS_BASE := $(PLATFORM_COMPONENTS)/axtls-8266/axtls-8266 + SUBMODULES += $(AXTLS_BASE) + LIBAXTLS := axtls + LIBS += $(LIBAXTLS) + MODULES += $(AXTLS_BASE)/compat $(AXTLS_BASE)/replacements + EXTRA_INCDIR += $(AXTLS_BASE)/.. $(AXTLS_BASE) $(AXTLS_BASE)/ssl $(AXTLS_BASE)/crypto + AXTLS_FLAGS = -DLWIP_RAW=1 -DENABLE_SSL=1 + ifeq ($(SSL_DEBUG),1) # + AXTLS_FLAGS += -DSSL_DEBUG=1 -DDEBUG_TLS_MEM=1 -DAXL_DEBUG=1 + endif + CLEAN += axtls-clean + CFLAGS += $(AXTLS_FLAGS) + AXTLS_BUILD := $(MAKE) -C $(AXTLS_BASE) -e V=$(V) BIN_DIR="$(SMING_HOME)/$(USER_LIBDIR)" + +$(call UserLibPath,$(LIBAXTLS)): + $(Q) $(AXTLS_BUILD) all + +.PHONY: axtls-clean +axtls-clean: + -$(Q) $(AXTLS_BUILD) clean +endif + + +# => GDB +EXTRA_INCDIR += $(PLATFORM_COMPONENTS)/gdbstub/include + + +# Tools + +define make-tool + $(MAKE) --no-print-directory -C $(dir $1) V=$(V) $2 +endef + +# => spiffy +TOOLS += $(SPIFFY) +TOOLS_CLEAN += spiffy-clean + +$(SPIFFY): $(THIRD_PARTY_DIR)/spiffs/.submodule + $(Q) $(call make-tool,$@,SPIFFS_BASE=$(SPIFFS_BASE)) + +.PHONY: spiffy-clean +spiffy-clean: + -$(Q) -$(call make-tool,$(SPIFFY),clean) + +# => esptool2 +TOOLS += $(ESPTOOL2) +TOOLS_CLEAN += esptool2-clean + +$(ESPTOOL2): $(dir $(ESPTOOL2)).submodule + $(Q) $(call make-tool,$@) + +.PHONY: esptool2-clean +esptool2-clean: + -$(Q) -$(call make-tool,$(ESPTOOL2),clean) + diff --git a/Sming/Services/CommandProcessing/CommandDelegate.h b/Sming/Services/CommandProcessing/CommandDelegate.h index 7b725e7957..c8e4ca9f39 100644 --- a/Sming/Services/CommandProcessing/CommandDelegate.h +++ b/Sming/Services/CommandProcessing/CommandDelegate.h @@ -11,7 +11,7 @@ #ifndef SERVICES_COMMANDPROCESSING_COMMANDDELEGATE_H_ #define SERVICES_COMMANDPROCESSING_COMMANDDELEGATE_H_ -#include "../Wiring/WString.h" +#include "WString.h" #include "Delegate.h" #include "Network/TcpClient.h" #include "WiringFrameworkIncludes.h" diff --git a/Sming/Services/CommandProcessing/CommandHandler.h b/Sming/Services/CommandProcessing/CommandHandler.h index a679e3f772..77e2f4dbda 100644 --- a/Sming/Services/CommandProcessing/CommandHandler.h +++ b/Sming/Services/CommandProcessing/CommandHandler.h @@ -25,9 +25,9 @@ #ifndef SERVICES_COMMANDPROCESSING_COMMANDHANDLER_H_ #define SERVICES_COMMANDPROCESSING_COMMANDHANDLER_H_ -#include "../Wiring/WiringFrameworkIncludes.h" +#include "WiringFrameworkIncludes.h" #include "CommandDelegate.h" -#include "../Wiring/WHashMap.h" +#include "WHashMap.h" #include "SystemClock.h" #include #include "HardwareSerial.h" diff --git a/Sming/Services/Yeelight/YeelightBulb.h b/Sming/Services/Yeelight/YeelightBulb.h index 93da5128ac..111405eb18 100644 --- a/Sming/Services/Yeelight/YeelightBulb.h +++ b/Sming/Services/Yeelight/YeelightBulb.h @@ -5,10 +5,10 @@ * All files of the Sming Core are provided under the LGPL v3 license. ****/ -#include "../Wiring/WiringFrameworkDependencies.h" -#include "../Wiring/WHashMap.h" -#include "../Wiring/WVector.h" -#include "../Wiring/WString.h" +#include "WiringFrameworkDependencies.h" +#include "WHashMap.h" +#include "WVector.h" +#include "WString.h" #include "IPAddress.h" class TcpClient; diff --git a/Sming/SmingCore/Data/Stream/Base64OutputStream.h b/Sming/SmingCore/Data/Stream/Base64OutputStream.h index 796e2b7749..1b1871b760 100644 --- a/Sming/SmingCore/Data/Stream/Base64OutputStream.h +++ b/Sming/SmingCore/Data/Stream/Base64OutputStream.h @@ -14,7 +14,7 @@ #define _SMING_CORE_DATA_STREAM_BASE64_OUTPUT_STREAM_H_ #include "../StreamTransformer.h" -#include "../Services/libb64/cencode.h" +#include "Services/libb64/cencode.h" /** * @brief Base64 Stream diff --git a/Sming/SmingCore/Data/Stream/GdbFileStream.cpp b/Sming/SmingCore/Data/Stream/GdbFileStream.cpp index b3946f733c..b8672d2c26 100644 --- a/Sming/SmingCore/Data/Stream/GdbFileStream.cpp +++ b/Sming/SmingCore/Data/Stream/GdbFileStream.cpp @@ -9,7 +9,7 @@ ****/ #include "GdbFileStream.h" -#include "gdb_syscall.h" +#include /* GdbFileStream */ diff --git a/Sming/SmingCore/Data/Stream/JsonObjectStream.h b/Sming/SmingCore/Data/Stream/JsonObjectStream.h index d890c3001e..33f11fc684 100644 --- a/Sming/SmingCore/Data/Stream/JsonObjectStream.h +++ b/Sming/SmingCore/Data/Stream/JsonObjectStream.h @@ -12,7 +12,7 @@ #define _SMING_CORE_DATA_STREAM_JSON_OBJECT_STREAM_H_ #include "MemoryDataStream.h" -#include "../Libraries/ArduinoJson/include/ArduinoJson.h" +#include "Libraries/ArduinoJson/include/ArduinoJson.h" /** @brief JsonObject stream class * @ingroup stream data diff --git a/Sming/SmingCore/Debug.h b/Sming/SmingCore/Debug.h index 65c3887ba9..ad08ea69c7 100644 --- a/Sming/SmingCore/Debug.h +++ b/Sming/SmingCore/Debug.h @@ -14,7 +14,7 @@ #include "HardwareSerial.h" #include "Clock.h" #include "WString.h" -#include "../Services/CommandProcessing/CommandProcessingIncludes.h" +#include "Services/CommandProcessing/CommandProcessingIncludes.h" /** @brief Delegate constructor usage: (&YourClass::method, this) * @ingroup event_handlers diff --git a/Sming/SmingCore/Digital.h b/Sming/SmingCore/Digital.h index 075bad2c7b..864fb0ab41 100644 --- a/Sming/SmingCore/Digital.h +++ b/Sming/SmingCore/Digital.h @@ -17,8 +17,7 @@ #ifndef _SMING_CORE_DIGITAL_H_ #define _SMING_CORE_DIGITAL_H_ -#include "../SmingCore/ESP8266EX.h" -#include "../Wiring/WiringFrameworkDependencies.h" +#include "WiringFrameworkDependencies.h" /** @brief Set the mode of a GPIO pin * @param pin GPIO pin to configure diff --git a/Sming/SmingCore/FileSystem.h b/Sming/SmingCore/FileSystem.h index d8a37138bd..6831a10854 100644 --- a/Sming/SmingCore/FileSystem.h +++ b/Sming/SmingCore/FileSystem.h @@ -16,7 +16,7 @@ #ifndef _SMING_CORE_FILE_SYSTEM_H_ #define _SMING_CORE_FILE_SYSTEM_H_ -#include "../Services/SpifFS/spiffs_sming.h" +#include "spiffs/spiffs_sming.h" #include "WVector.h" class String; diff --git a/Sming/SmingCore/HardwarePWM.h b/Sming/SmingCore/HardwarePWM.h index 17dd0a601d..5179c189ff 100644 --- a/Sming/SmingCore/HardwarePWM.h +++ b/Sming/SmingCore/HardwarePWM.h @@ -28,7 +28,6 @@ #ifndef _SMING_CORE_HARDWARE_PWM_H_ #define _SMING_CORE_HARDWARE_PWM_H_ -#include "ESP8266EX.h" #include "WiringFrameworkDependencies.h" #ifdef __cplusplus diff --git a/Sming/SmingCore/HardwareSerial.h b/Sming/SmingCore/HardwareSerial.h index 60a005af44..1cf00306e9 100644 --- a/Sming/SmingCore/HardwareSerial.h +++ b/Sming/SmingCore/HardwareSerial.h @@ -19,7 +19,7 @@ #include "WiringFrameworkDependencies.h" #include "Data/Stream/ReadWriteStream.h" #include "Delegate.h" -#include "espinc/uart.h" +#include "driver/uart.h" #define UART_ID_0 0 ///< ID of UART 0 #define UART_ID_1 1 ///< ID of UART 1 diff --git a/Sming/SmingCore/Network/Http/HttpCommon.h b/Sming/SmingCore/Network/Http/HttpCommon.h index 5fb042b7a7..50b03c7e6a 100644 --- a/Sming/SmingCore/Network/Http/HttpCommon.h +++ b/Sming/SmingCore/Network/Http/HttpCommon.h @@ -28,7 +28,7 @@ #define HTTP_REQUEST_POOL_SIZE 20 #endif -#include "../http-parser/http_parser.h" +#include "http-parser/http_parser.h" typedef enum http_method HttpMethod; diff --git a/Sming/SmingCore/Network/Http/HttpParams.cpp b/Sming/SmingCore/Network/Http/HttpParams.cpp index 31aa2a1106..d4dde9ec67 100644 --- a/Sming/SmingCore/Network/Http/HttpParams.cpp +++ b/Sming/SmingCore/Network/Http/HttpParams.cpp @@ -11,9 +11,9 @@ ****/ #include "HttpParams.h" -#include "../Services/WebHelpers/escape.h" +#include "Services/WebHelpers/escape.h" #include "Print.h" -#include "../third-party/libyuarel/yuarel.h" +#include "libyuarel/yuarel.h" // Set a reasonable limit on the number of expected parameters in a query string static const unsigned MAX_PARAMS = 16; diff --git a/Sming/SmingCore/Network/Http/HttpRequestAuth.cpp b/Sming/SmingCore/Network/Http/HttpRequestAuth.cpp index 3015f55c2a..f6b72ed408 100644 --- a/Sming/SmingCore/Network/Http/HttpRequestAuth.cpp +++ b/Sming/SmingCore/Network/Http/HttpRequestAuth.cpp @@ -12,7 +12,7 @@ #include "HttpRequestAuth.h" #include "HttpRequest.h" -#include "../Services/WebHelpers/base64.h" +#include "Services/WebHelpers/base64.h" // Basic Auth void HttpBasicAuth::setRequest(HttpRequest* request) diff --git a/Sming/SmingCore/Network/Http/Websocket/WebsocketConnection.cpp b/Sming/SmingCore/Network/Http/Websocket/WebsocketConnection.cpp index 34480d0d6e..da0475e428 100644 --- a/Sming/SmingCore/Network/Http/Websocket/WebsocketConnection.cpp +++ b/Sming/SmingCore/Network/Http/Websocket/WebsocketConnection.cpp @@ -10,8 +10,8 @@ #include "WebsocketConnection.h" -#include "../Services/WebHelpers/aw-sha1.h" -#include "../Services/WebHelpers/base64.h" +#include "Services/WebHelpers/aw-sha1.h" +#include "Services/WebHelpers/base64.h" DEFINE_FSTR(WSSTR_CONNECTION, "connection") DEFINE_FSTR(WSSTR_UPGRADE, "upgrade") diff --git a/Sming/SmingCore/Network/Http/Websocket/WebsocketConnection.h b/Sming/SmingCore/Network/Http/Websocket/WebsocketConnection.h index fc7109a115..c857b9f713 100644 --- a/Sming/SmingCore/Network/Http/Websocket/WebsocketConnection.h +++ b/Sming/SmingCore/Network/Http/Websocket/WebsocketConnection.h @@ -14,7 +14,7 @@ #include "Network/TcpServer.h" #include "../HttpConnection.h" extern "C" { -#include "../ws_parser/ws_parser.h" +#include "ws_parser/ws_parser.h" } /** @defgroup Websocket connection diff --git a/Sming/SmingCore/Network/Http/Websocket/WsCommandHandlerResource.h b/Sming/SmingCore/Network/Http/Websocket/WsCommandHandlerResource.h index ad84eb1608..987f1a363d 100644 --- a/Sming/SmingCore/Network/Http/Websocket/WsCommandHandlerResource.h +++ b/Sming/SmingCore/Network/Http/Websocket/WsCommandHandlerResource.h @@ -16,7 +16,7 @@ #include "../HttpResource.h" #include "WebsocketConnection.h" #include "WString.h" -#include "../Services/CommandProcessing/CommandProcessingIncludes.h" // TODO: .... +#include "Services/CommandProcessing/CommandProcessingIncludes.h" // TODO: .... class WsCommandHandlerResource : protected WebsocketResource { diff --git a/Sming/SmingCore/Network/Mqtt/MqttPayloadParser.h b/Sming/SmingCore/Network/Mqtt/MqttPayloadParser.h index 7b738e5881..d81bc300e7 100644 --- a/Sming/SmingCore/Network/Mqtt/MqttPayloadParser.h +++ b/Sming/SmingCore/Network/Mqtt/MqttPayloadParser.h @@ -14,7 +14,7 @@ #define _SMING_CORE_NETWORK_MQTT_PAYLOAD_PARSER_H_ #include "Delegate.h" -#include "../mqtt-codec/src/message.h" +#include "mqtt-codec/src/message.h" /** @defgroup mqttpayload Provides MQTT payload parser * @brief MQTT streaming processor for the payload data of a PUBLISH message diff --git a/Sming/SmingCore/Network/MqttClient.cpp b/Sming/SmingCore/Network/MqttClient.cpp index 0b5555b877..4b4f63dfa7 100644 --- a/Sming/SmingCore/Network/MqttClient.cpp +++ b/Sming/SmingCore/Network/MqttClient.cpp @@ -13,7 +13,7 @@ #include "Data/Stream/MemoryDataStream.h" #include "Data/Stream/StreamChain.h" -#include "../Clock.h" +#include "Clock.h" #define MQTT_PUBLISH_STREAM 0 diff --git a/Sming/SmingCore/Network/MqttClient.h b/Sming/SmingCore/Network/MqttClient.h index 12571c8cb5..c5ceaf10c5 100644 --- a/Sming/SmingCore/Network/MqttClient.h +++ b/Sming/SmingCore/Network/MqttClient.h @@ -17,9 +17,9 @@ #include "WHashMap.h" #include "Data/ObjectQueue.h" #include "Mqtt/MqttPayloadParser.h" -#include "../mqtt-codec/src/message.h" -#include "../mqtt-codec/src/serialiser.h" -#include "../mqtt-codec/src/parser.h" +#include "mqtt-codec/src/message.h" +#include "mqtt-codec/src/serialiser.h" +#include "mqtt-codec/src/parser.h" /** @defgroup mqttclient MQTT client * @brief Provides MQTT client diff --git a/Sming/SmingCore/Network/SmtpClient.cpp b/Sming/SmingCore/Network/SmtpClient.cpp index 83e520138a..4be999712c 100644 --- a/Sming/SmingCore/Network/SmtpClient.cpp +++ b/Sming/SmingCore/Network/SmtpClient.cpp @@ -17,7 +17,7 @@ */ #include "SmtpClient.h" -#include "../Services/WebHelpers/base64.h" +#include "Services/WebHelpers/base64.h" #include "Data/Stream/QuotedPrintableOutputStream.h" #include "Data/Stream/Base64OutputStream.h" #include "Data/HexString.h" diff --git a/Sming/SmingCore/Network/TcpConnection.h b/Sming/SmingCore/Network/TcpConnection.h index e06ae4e801..34bf42f2d9 100644 --- a/Sming/SmingCore/Network/TcpConnection.h +++ b/Sming/SmingCore/Network/TcpConnection.h @@ -17,7 +17,7 @@ #define _SMING_CORE_NETWORK_TCP_CONNECTION_H_ #ifdef ENABLE_SSL -#include "../axtls-8266/compat/lwipr_compat.h" +#include "axtls-8266/compat/lwipr_compat.h" #include "Clock.h" #include "Ssl/SslStructs.h" #endif diff --git a/Sming/SmingCore/Network/TelnetServer.h b/Sming/SmingCore/Network/TelnetServer.h index d66228c35b..fc1d7d1ab0 100644 --- a/Sming/SmingCore/Network/TelnetServer.h +++ b/Sming/SmingCore/Network/TelnetServer.h @@ -25,7 +25,7 @@ #include "TcpClient.h" #include "TcpServer.h" #include "SystemClock.h" -#include "../Services/CommandProcessing/CommandExecutor.h" +#include "Services/CommandProcessing/CommandExecutor.h" #define TELNETSERVER_MAX_COMMANDSIZE 64 diff --git a/Sming/SmingCore/Network/Url.cpp b/Sming/SmingCore/Network/Url.cpp index 198ae01429..a24cfbe0d3 100644 --- a/Sming/SmingCore/Network/Url.cpp +++ b/Sming/SmingCore/Network/Url.cpp @@ -11,8 +11,8 @@ ****/ #include "Url.h" -#include "../libyuarel/yuarel.h" -#include "../Services/WebHelpers/escape.h" +#include "libyuarel/yuarel.h" +#include "Services/WebHelpers/escape.h" #include "Print.h" /** diff --git a/Sming/SmingCore/Network/WebsocketClient.cpp b/Sming/SmingCore/Network/WebsocketClient.cpp index ad2224aa0b..87483c498f 100644 --- a/Sming/SmingCore/Network/WebsocketClient.cpp +++ b/Sming/SmingCore/Network/WebsocketClient.cpp @@ -15,8 +15,8 @@ #include "WebsocketClient.h" #include "Network/Http/HttpHeaders.h" -#include "../Services/WebHelpers/aw-sha1.h" -#include "../Services/WebHelpers/base64.h" +#include "Services/WebHelpers/aw-sha1.h" +#include "Services/WebHelpers/base64.h" HttpConnection* WebsocketClient::getHttpConnection() { diff --git a/Sming/SmingCore/SmingCore.h b/Sming/SmingCore/SmingCore.h index 48116c0c32..c49b120b65 100644 --- a/Sming/SmingCore/SmingCore.h +++ b/Sming/SmingCore/SmingCore.h @@ -15,14 +15,13 @@ #include -#include "gdb_hooks.h" +#include "gdb/gdb_hooks.h" #include "WiringFrameworkIncludes.h" #include "Delegate.h" #include "Clock.h" #include "SystemClock.h" #include "Digital.h" -#include "ESP8266EX.h" #include "FileSystem.h" #include "HardwareSerial.h" #include "Interrupts.h" @@ -61,7 +60,7 @@ #include "DateTime.h" -#include "../Services/FATFS/ff.h" -#include "../Services/Yeelight/YeelightBulb.h" +#include "fatfs/ff.h" +#include "Services/Yeelight/YeelightBulb.h" #endif /* _SMING_CORE_H_ */ diff --git a/Sming/SmingCore/twi.h b/Sming/SmingCore/twi.h index 3296a53d6c..740a6f3437 100644 --- a/Sming/SmingCore/twi.h +++ b/Sming/SmingCore/twi.h @@ -23,7 +23,6 @@ #define _SMING_CORE_TWI_H_ #include "WiringFrameworkDependencies.h" -#include "espinc/peri.h" #ifdef __cplusplus extern "C" { diff --git a/Sming/system/include/debug_progmem.h b/Sming/System/include/debug_progmem.h similarity index 100% rename from Sming/system/include/debug_progmem.h rename to Sming/System/include/debug_progmem.h diff --git a/Sming/system/include/gdb_hooks.h b/Sming/System/include/gdb/gdb_hooks.h similarity index 100% rename from Sming/system/include/gdb_hooks.h rename to Sming/System/include/gdb/gdb_hooks.h diff --git a/Sming/system/include/gdb_syscall.h b/Sming/System/include/gdb/gdb_syscall.h similarity index 100% rename from Sming/system/include/gdb_syscall.h rename to Sming/System/include/gdb/gdb_syscall.h diff --git a/Sming/system/include/m_printf.h b/Sming/System/include/m_printf.h similarity index 100% rename from Sming/system/include/m_printf.h rename to Sming/System/include/m_printf.h diff --git a/Sming/system/include/stringconversion.h b/Sming/System/include/stringconversion.h similarity index 100% rename from Sming/system/include/stringconversion.h rename to Sming/System/include/stringconversion.h diff --git a/Sming/system/include/stringutil.h b/Sming/System/include/stringutil.h similarity index 100% rename from Sming/system/include/stringutil.h rename to Sming/System/include/stringutil.h diff --git a/Sming/system/m_printf.cpp b/Sming/System/m_printf.cpp similarity index 100% rename from Sming/system/m_printf.cpp rename to Sming/System/m_printf.cpp diff --git a/Sming/system/stringconversion.cpp b/Sming/System/stringconversion.cpp similarity index 100% rename from Sming/system/stringconversion.cpp rename to Sming/System/stringconversion.cpp diff --git a/Sming/system/stringutil.cpp b/Sming/System/stringutil.cpp similarity index 100% rename from Sming/system/stringutil.cpp rename to Sming/System/stringutil.cpp diff --git a/Sming/Wiring/Arduino.h b/Sming/Wiring/Arduino.h index efb7103798..d7018c378f 100644 --- a/Sming/Wiring/Arduino.h +++ b/Sming/Wiring/Arduino.h @@ -3,10 +3,10 @@ #ifndef INCLUDE_ARDUINO_H_ #define INCLUDE_ARDUINO_H_ -#include "../include/user_config.h" -#include "../Wiring/WiringFrameworkDependencies.h" -#include "../SmingCore/SmingCore.h" -#include "../SmingCore/ArduinoCompat.h" +#include +#include "WiringFrameworkDependencies.h" +#include "SmingCore.h" +#include "ArduinoCompat.h" #endif /* INCLUDE_ARDUINO_H_ */ diff --git a/Sming/Wiring/WConstants.h b/Sming/Wiring/WConstants.h index 9a1544b006..b802b5f9c2 100644 --- a/Sming/Wiring/WConstants.h +++ b/Sming/Wiring/WConstants.h @@ -18,7 +18,7 @@ #ifndef WCONSTANTS_H #define WCONSTANTS_H -#include "../include/user_config.h" +#include // Wiring API version for libraries // this is passed in at compile-time diff --git a/Sming/Wiring/WHashMap.h b/Sming/Wiring/WHashMap.h index 3cf7c6cfc8..597493d0d1 100644 --- a/Sming/Wiring/WHashMap.h +++ b/Sming/Wiring/WHashMap.h @@ -29,7 +29,7 @@ #ifndef HASHMAP_H #define HASHMAP_H -#include "Countable.h" +#include "WiringFrameworkDependencies.h" template class HashMap diff --git a/Sming/Wiring/WShift.cpp b/Sming/Wiring/WShift.cpp index 7167745a24..bc8b264682 100644 --- a/Sming/Wiring/WShift.cpp +++ b/Sming/Wiring/WShift.cpp @@ -15,8 +15,8 @@ || */ -#include "../SmingCore/Clock.h" -#include "../SmingCore/Digital.h" +#include "Clock.h" +#include "Digital.h" #include "WiringFrameworkIncludes.h" diff --git a/Sming/Wiring/WiringFrameworkDependencies.h b/Sming/Wiring/WiringFrameworkDependencies.h index 11063ab382..2b4f6cd7cc 100644 --- a/Sming/Wiring/WiringFrameworkDependencies.h +++ b/Sming/Wiring/WiringFrameworkDependencies.h @@ -1,14 +1,14 @@ /* * WiringFrameworkDependencies.h * - * Created on: 28 ���. 2015 �. + * Created on: 28 ���. 2015 �. * Author: Anakonda */ #ifndef WIRING_WIRINGFRAMEWORKDEPENDENCIES_H_ #define WIRING_WIRINGFRAMEWORKDEPENDENCIES_H_ -#include "../include/user_config.h" +#include #include #include @@ -20,7 +20,7 @@ #include "WConstants.h" #include "BitManipulations.h" #include "FakePgmSpace.h" -#include "../SmingCore/pins_arduino.h" +#include "pins_arduino.h" // std::min, etc. #include diff --git a/Sming/apptest/apptest.cpp b/Sming/apptest/apptest.cpp index 15dc9f38aa..3d5866442e 100644 --- a/Sming/apptest/apptest.cpp +++ b/Sming/apptest/apptest.cpp @@ -1,4 +1,4 @@ -#include "../SmingCore/SmingCore.h" +#include Timer procTimer; diff --git a/Sming/build.mk b/Sming/build.mk new file mode 100644 index 0000000000..35087c3c6a --- /dev/null +++ b/Sming/build.mk @@ -0,0 +1,148 @@ +# Build environment definitions + +# Use this form to define platform as environment variable +ifdef SMING_PLATFORM +PLATFORM := $(SMING_PLATFORM) +else +PLATFORM ?= Esp8266 +endif + +MAKECMDGOALS ?= all +$(info Building '$(MAKECMDGOALS)' for '$(PLATFORM)' platform) + +LIBS ?= +CUSTOM_TARGETS ?= +CLEAN ?= +TOOLS ?= +TOOLS_CLEAN ?= + +# Detect OS and build environment +UNAME := $(shell uname -s) + +ifeq ($(OS),Windows_NT) + # Convert Windows paths to POSIX paths + SMING_HOME := $(subst \,/,$(addprefix /,$(subst :,,$(SMING_HOME)))) + SMING_HOME := $(subst //,/,$(SMING_HOME)) +endif + +ifneq ($(filter MINGW32_NT%,$(UNAME)),) + UNAME := Windows +else ifneq ($(filter CYGWIN%,$(UNAME)),) + # Cygwin Detected + UNAME := Linux +else ifneq ($(filter CYGWIN%WOW,$(UNAME)),) + #Cygwin32 + UNAME := Linux +else ifneq ($(filter MSYS%WOW,$(UNAME)),) + #Msys32 + UNAME := Linux +else ifeq ($(UNAME), Linux) + #Linux +else ifeq ($(UNAME), Darwin) + #OS X +else ifeq ($(UNAME), Freebsd) + #BSD +endif + +# OS specific configuration +ifeq ($(UNAME),Windows) + # Windows detected + include $(SMING_HOME)/Makefile-windows.mk + TOOL_EXT := .exe +else + ifeq ($(UNAME),Darwin) + # MacOS Detected + UNAME := MacOS + include $(SMING_HOME)/Makefile-macos.mk + else ifeq ($(UNAME),Linux) + # Linux Detected + include $(SMING_HOME)/Makefile-linux.mk + else ifeq ($(UNAME),FreeBSD) + # Freebsd Detected + include $(SMING_HOME)/Makefile-bsd.mk + endif +endif + +export SMING_HOME +export COMPILE := gcc + +PLATFORM_BASE := Platform/$(PLATFORM) +PLATFORM_SYS = $(PLATFORM_BASE)/System +PLATFORM_CORE = $(PLATFORM_BASE)/Core +PLATFORM_TOOLS = $(PLATFORM_BASE)/Tools +PLATFORM_COMPONENTS = $(PLATFORM_SYS)/components +USER_LIBDIR = $(PLATFORM_BASE)/Compiler/lib +THIRD_PARTY_DIR = third-party + +# Git command +GIT ?= git + +### Debug output parameters +# By default `debugf` does not print file name and line number. If you want this enabled set the directive below to 1 +DEBUG_PRINT_FILENAME_AND_LINE ?= 0 + +# Default debug verbose level is INFO, where DEBUG=3 INFO=2 WARNING=1 ERROR=0 +DEBUG_VERBOSE_LEVEL ?= 2 + +# Disable CommandExecutor functionality if not used and save some ROM and RAM +ENABLE_CMD_EXECUTOR ?= 1 + +V ?= $(VERBOSE) +ifeq ("$(V)","1") +Q := +vecho := @true +else +Q := @ +vecho := @echo +endif + +# Common flags passed to user libraries +CFLAGS_COMMON = -Wl,-EL -finline-functions -fdata-sections -ffunction-sections +# compiler flags using during compilation of source files. Add '-pg' for debugging +CFLAGS = -Wall -Wundef -Wpointer-arith -Wno-comment $(CFLAGS_COMMON) \ + -DARDUINO=106 -DENABLE_CMD_EXECUTOR=$(ENABLE_CMD_EXECUTOR) -DSMING_INCLUDED=1 +ifneq ($(STRICT),1) +CFLAGS += -Werror -Wno-sign-compare -Wno-parentheses -Wno-unused-variable -Wno-unused-but-set-variable -Wno-strict-aliasing -Wno-return-type -Wno-maybe-uninitialized +endif + +ifeq ($(ENABLE_GDB), 1) + CFLAGS += -ggdb -DENABLE_GDB=1 +endif + +ifeq ($(SMING_RELEASE),1) + # See: https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html + # for full list of optimization options + CFLAGS += -Os -DSMING_RELEASE=1 -DLWIP_NOASSERT +else ifeq ($(ENABLE_GDB), 1) + CFLAGS += -Og +else + CFLAGS += -Os -g +endif + +#Append debug options +CFLAGS += -DCUST_FILE_BASE=$$* -DDEBUG_VERBOSE_LEVEL=$(DEBUG_VERBOSE_LEVEL) -DDEBUG_PRINT_FILENAME_AND_LINE=$(DEBUG_PRINT_FILENAME_AND_LINE) + +CXXFLAGS = $(CFLAGS) -fno-rtti -fno-exceptions -std=c++11 -felide-constructors +ifneq ($(STRICT),1) +CXXFLAGS += -Wno-reorder +endif + +# => LOCALE +ifdef LOCALE + CFLAGS += -DLOCALE=$(LOCALE) +endif + +include $(SMING_HOME)/$(PLATFORM_BASE)/build.mk + +AS := $(Q)$(AS) +CC := $(Q)$(CC) +CXX := $(Q)$(CXX) +AR := $(Q)$(AR) +LD := $(Q)$(LD) + +# Declare target for user library +# $1 -> Name of library +define UserLibPath + $(USER_LIBDIR)/lib$1.a +endef + diff --git a/Sming/building.md b/Sming/building.md new file mode 100644 index 0000000000..cd006ae7b6 --- /dev/null +++ b/Sming/building.md @@ -0,0 +1,179 @@ +# Sming makefiles + +## Introduction + +This guide is provided to assist with developing and modifying the build system. + +There are two main makefiles: + +> **Makefile** to build the Sming framework libraries + +> **Makefile-app.mk** to build an application + +There are also specific makefiles for each supported host environment: + +> **Makefile-bsd.mk** + +> **Makefile-linux.mk** + +> **Makefile-macos.mk** + +> **Makefile-windows.mk** + +The following are internal makefiles containing shared script for both framework and application: + +> **build.mk** Defines the build environment + +> **modules.mk** Parses defined MODULES, etc. and creates target rules + +In addition, `Sming/Platform/$(PLATFORM)` must contain: + +> **sming.mk** to define platform-specific modules and libraries + +> **app.mk** to build an application + +`PLATFORM` may be defined as + +> **Esp8266** + +> **Esp32** {todo} + +> **Host** {todo} builds a version of the library for native host debugging + +If setting this as an environment variable you should use `SMING_PLATFORM` to avoid potential conflicts. + +## Directories + +``` +Directory Contents +--------- -------- +Libraries\ Arduino Libraries +Platform/ + Common/ Headers and code common to all platforms + Esp8266/ Existing Sming platform code + Compiler/ + Core/ + out/ + Platform/ + System/ + Tools/ + Esp32/ + ... + Host/ + ... + +SmingCore/ Main framework core (TODO: rename to `Core`) + +System/ Common framework system code + esp8266/ + include/ + +third-party/ Shared GIT submodules + +Wiring/ + +``` + + +## Environment Setup + +You must provide `SMING_HOME` and `ESP_HOME`. All others are optional. + +# Building the framework + +## Makefile + +Targets include: + +> **all** (default) Builds the Sming library, user libraries, arduino libraries and tools + +> **libsming** Build the Sming framework and user libraries + +> **mqttc** Build mqttc-codec user library + +> **docs** Build the documentation + +> **third-party** Fetch third-party submodules, but do not build + +> **libraries** Fetch Arduino libraries from repos, but do not build + +> **samples** Build all the sample applications + +> **test** Build a few basic test applications + +> **tools** Build all required internal tools + +Esp8266 targets: + +> **axtls** Build axtls-8266 library - `ENABLE_SSL=1` required + +> **pwm_open** Build the PWM replacement library + +> **pwm-clean** + +Cleaning: + +> **dist-clean** Clean everything + +> **clean** Remove intermediate files + +> **user-lib-clean** Clear generated user libraries + +> **third-party-clean** Reset state of third-party repos + +> **libraries-clean** Reset state of Arduino libraries + +> **samples-clean** Invoke **clean** on all samples + +> **tools-clean** + +> **cs** Apply coding style to core files + +Flags: + +> ** ARDUINO_LIBRARIES** Specify which Arduino Libraries are to be built. Default: unspecified, builds them all. Example: `make ARDUINO_LIBRARIES="ArduinoJson SI7021 BMP180"` +This can be set in the platform `sming.mk` file. + +## GIT Submodules + +These are used in various places throughout the framework. A single `%/.submodule` rule takes care of updating and optionally patching the code. +A patch file with the same name as the submodule must be present in `..` or `../.patches`. +After updating and patching, an `.submodule` file is created to confirm this has been done. + +# Building applications + +## Makefile-app.mk + +This does not contain any targets, but sets up the common build environment, configures Sming variables then invokes the platform-specific makefile in `Platform$/$(PLATFORM)/app.mk` + +## Application Code (APPCODE) + +Some code is recompiled for every application (e.g. `gdbstub`, `rboot`). +Code must be placed in a separate sub-directory of the corresponding module or component, then added to the `APPCODE` variable within the makefiles. +This mechanism is appropriate for files with multiple configurable options and avoids the need to rebuild the framework. + +# Known Issues + +## Parallel build + +i.e. Using `make -j` doesn't work for rules which pull in submodules from GIT, so this must be done as a first step: + +`make third-party libraries` + +then you can + +`make -j` + +to compile the framework or application. Ensure that any options (`ENABLE_SSL`, `ARDUINO_LIBRARIES`) are set identically for both. + + +## Cleaning + +Optional libraries are not cleaned unless defined. e.g. `make axtls-clean` will fail unless you also specify `ENABLE_SSL=1`. + + +## Custom heap + +Changing the heap allocator requires a rebuild of the framework. +TODO: Implement as separate user library. + diff --git a/Sming/modules.mk b/Sming/modules.mk new file mode 100644 index 0000000000..b3e02e42a5 --- /dev/null +++ b/Sming/modules.mk @@ -0,0 +1,72 @@ +##### +# +# Module support +# +# Both Sming and Application makefiles include this once all modules, libs, etc. have been defined +# +##### + +# List of directories containing object files +BUILD_DIR := + +# List of object files +OBJ := + +APP_AR := $(addprefix $(BUILD_BASE)/,$(TARGET)_app.a) +TARGET_OUT := $(addprefix $(BUILD_BASE)/,$(TARGET).out) + +INCDIR := -I$(SDK_INCDIR) $(addprefix -I,$(APPCODE) $(MODULES)) +EXTRA_INCDIR := $(addprefix -I,$(EXTRA_INCDIR)) + +# $1 -> directory containing source files +# $2 -> output build directory +define GenerateCompileTargets +$2/%.o: $1/%.s + $(vecho) "AS $$<" + $(AS) $(INCDIR) -I$1/include $(EXTRA_INCDIR) $(CFLAGS) -c $$< -o $$@ +$2/%.o: $1/%.S + $(vecho) "AS $$<" + $(AS) $(INCDIR) -I$1/include $(EXTRA_INCDIR) $(CFLAGS) -c $$< -o $$@ +$2/%.o: $1/%.c $2/%.c.d + $(vecho) "CC $$<" + $(CC) $(INCDIR) -I$1/include $(EXTRA_INCDIR) $(CFLAGS) -c $$< -o $$@ +$2/%.o: $1/%.cpp $2/%.cpp.d + $(vecho) "C+ $$<" + $(CXX) $(INCDIR) -I$1/include $(EXTRA_INCDIR) $(CXXFLAGS) -c $$< -o $$@ +$2/%.c.d: $1/%.c + $(CC) $(INCDIR) -I$1/include $(EXTRA_INCDIR) $(CFLAGS) -MM -MT $2/$$*.o $$< -o $$@ +$2/%.cpp.d: $1/%.cpp + $(CXX) $(INCDIR) -I$1/include $(EXTRA_INCDIR) $(CXXFLAGS) -MM -MT $2/$$*.o $$< -o $$@ + +.PRECIOUS: $2/%.c.d $2/%.cpp.d +endef + + +# Append target object file paths to OBJ +# $1 -> directory containing source files +# $2 -> output build directory +# $3 -> file extension +define ScanObjectFiles + OBJ += $(addprefix $2/,$(patsubst $(SMING_HOME)/%,%,$(patsubst %$3,%.o,$(wildcard $1/*$3)))) +endef + +# Generate all the compile target patterns and update object list for all source files in a module directory +# $1 -> directory containing source files +# $2 -> output build directory +define ScanModule + $(if $(V), $(info Scan $1)) + BUILD_DIR += $2/$(patsubst $(SMING_HOME)/%,%,$1) + $(eval $(call ScanObjectFiles,$1,$2,.s)) + $(eval $(call ScanObjectFiles,$1,$2,.S)) + $(eval $(call ScanObjectFiles,$1,$2,.c)) + $(eval $(call ScanObjectFiles,$1,$2,.cpp)) + $(eval $(call GenerateCompileTargets,$1,$(BUILD_BASE)/$(patsubst $(SMING_HOME)/%,%,$1))) +endef + +# $1 -> directory containing source files +define ScanModules + $(foreach sdir,$1,$(eval $(call ScanModule,$(sdir),$(BUILD_BASE)))) +endef + +# Generate all the compile target patterns and object references +$(call ScanModules,$(MODULES)) diff --git a/Sming/third-party/.patches/esp-gdbstub.patch b/Sming/third-party/.patches/esp-gdbstub.patch deleted file mode 100644 index f34e5a7e6c..0000000000 --- a/Sming/third-party/.patches/esp-gdbstub.patch +++ /dev/null @@ -1,56 +0,0 @@ -diff --git a/gdbstub.c b/gdbstub.c -index 5fc6633..1df3b9c 100644 ---- a/gdbstub.c -+++ b/gdbstub.c -@@ -8,6 +8,7 @@ - *******************************************************************************/ - - #include "gdbstub.h" -+#include - #include "ets_sys.h" - #include "eagle_soc.h" - #include "c_types.h" -@@ -72,6 +73,10 @@ the xthal stack frame struct. - - void _xtos_set_exception_handler(int cause, void (exhandler)(struct XTensa_exception_frame_s *frame)); - int os_printf_plus(const char *format, ...) __attribute__ ((format (printf, 1, 2))); -+void xthal_set_intenable(unsigned); -+ -+extern void ets_wdt_enable(void); -+extern void ets_wdt_disable(void); - - #endif - -@@ -575,6 +580,7 @@ void ATTR_GDBFN gdbstub_handle_debug_exception() { - } - - sendReason(); -+ xthal_set_intenable(0); // enable receiving UART bytes without interrupts - while(gdbReadCommand()!=ST_CONT); - if ((gdbstub_savedRegs.reason&0x84)==0x4) { - //We stopped due to a watchpoint. We can't re-execute the current instruction -@@ -627,6 +633,7 @@ static void ATTR_GDBFN gdb_exception_handler(struct XTensa_exception_frame_s *fr - - ets_wdt_disable(); - sendReason(); -+ xthal_set_intenable(0); // enable receiving UART bytes without interrupts - while(gdbReadCommand()!=ST_CONT); - ets_wdt_enable(); - -@@ -706,6 +713,7 @@ static void ATTR_GDBFN uart_hdlr(void *arg, void *frame) { - - ets_wdt_disable(); - sendReason(); -+ xthal_set_intenable(0); // enable receiving UART bytes without interrupts - while(gdbReadCommand()!=ST_CONT); - ets_wdt_enable(); - //Copy any changed registers back to the frame the Xtensa HAL uses. -@@ -714,7 +722,7 @@ static void ATTR_GDBFN uart_hdlr(void *arg, void *frame) { - } - - static void ATTR_GDBINIT install_uart_hdlr() { -- ets_isr_attach(ETS_UART_INUM, uart_hdlr, NULL); -+ ets_isr_attach(ETS_UART_INUM, (ets_isr_t)uart_hdlr, NULL); - SET_PERI_REG_MASK(UART_INT_ENA(0), UART_RXFIFO_FULL_INT_ENA|UART_RXFIFO_TOUT_INT_ENA); - ets_isr_unmask((1< #include #include "HardwareTimer.h" -#include +#include #include #include #include From 5d7ad1d3eab9ba74b293b79d64a2522ae2acff32 Mon Sep 17 00:00:00 2001 From: mikee47 Date: Sat, 27 Apr 2019 16:20:05 +0100 Subject: [PATCH 02/22] Makefile fixes and remove `apptest` directory `Platform/Esp8266/app.mk` * Move variable statements before `flashinit` and `flash` rules (doesn't work otherwise) `Makefile` * Add `mkdir` for `libraries-clean` to improve reliablity (sometimes fails) * Add `submodules` and `submodules-clean` rules to replace `third-party` and `libraries` rules * Prioritise rules in `dist-clean`, put sample cleaning last --- Sming/Makefile | 16 +++++------ Sming/Platform/Esp8266/app.mk | 32 +++++++++++----------- Sming/apptest/apptest.cpp | 50 ----------------------------------- Sming/building.md | 10 +++---- 4 files changed, 25 insertions(+), 83 deletions(-) delete mode 100644 Sming/apptest/apptest.cpp diff --git a/Sming/Makefile b/Sming/Makefile index e0117f801f..c997a27505 100644 --- a/Sming/Makefile +++ b/Sming/Makefile @@ -150,13 +150,13 @@ endif $(vecho) "Done" .PHONY: checkdirs -checkdirs: libraries third-party reload | $(BUILD_DIR) +checkdirs: submodules reload | $(BUILD_DIR) $(BUILD_DIR): $(Q) mkdir -p $@ .PHONY: dist-clean -dist-clean: clean samples-clean third-party-clean libraries-clean tools-clean user-lib-clean +dist-clean: clean submodules-clean tools-clean user-lib-clean samples-clean .PHONY: clean clean: $(CLEAN) @@ -219,19 +219,15 @@ define TryApplyPatch fi endef -.PHONY: third-party third-party-clean -third-party: $(addsuffix /.submodule,$(SUBMODULES)) +.PHONY: submodules submodules-clean +submodules: $(LIBRARY_SUBMODULES) $(addsuffix /.submodule,$(SUBMODULES)) -third-party-clean: +submodules-clean: -$(Q) rm -rf $(SUBMODULES) $(GIT) checkout third-party - -.PHONY: libraries libraries-clean -libraries: $(LIBRARY_SUBMODULES) - -libraries-clean: -$(Q) rm -rf Libraries -$(Q) rm -rf $(BUILD_BASE)/Libraries + -$(Q) mkdir -p Libraries $(GIT) checkout Libraries # Update and patch submodule diff --git a/Sming/Platform/Esp8266/app.mk b/Sming/Platform/Esp8266/app.mk index f9c9fd53b5..c40de6d312 100644 --- a/Sming/Platform/Esp8266/app.mk +++ b/Sming/Platform/Esp8266/app.mk @@ -344,11 +344,11 @@ spiff_clean: $(vecho) "Cleaning $(SPIFF_BIN_OUT)" $(Q) rm -rf $(SPIFF_BIN_OUT) +# Generating spiffs_bin $(SPIFF_BIN_OUT): ifeq ($(DISABLE_SPIFFS), 1) $(vecho) "(!) Spiffs support disabled. Remove 'DISABLE_SPIFFS' make argument to enable spiffs." else -# Generating spiffs_bin $(vecho) "Checking for spiffs files" $(Q) if [ -d "$(SPIFF_FILES)" ]; then \ echo "$(SPIFF_FILES) directory exists. Creating $(SPIFF_BIN_OUT)"; \ @@ -381,18 +381,18 @@ else endif # flashes rboot and first rom +FLASH_CHUNKS := 0x00000 $(RBOOT_BIN) +FLASH_CHUNKS += $(ROM_0_ADDR) $(RBOOT_ROM_0) +ifneq ($(DISABLE_SPIFFS), 1) + FLASH_CHUNKS += $(RBOOT_SPIFFS_0) $(SPIFF_BIN_OUT) +endif flash: all kill_term - FLASH_CHUNKS := 0x00000 $(RBOOT_BIN) - FLASH_CHUNKS += $(ROM_0_ADDR) $(RBOOT_ROM_0) - ifneq ($(DISABLE_SPIFFS), 1) - FLASH_CHUNKS += $(RBOOT_SPIFFS_0) $(SPIFF_BIN_OUT) - endif $(WRITE_FLASH) $(FLASH_CHUNKS) - ifeq ($(ENABLE_GDB), 1) - $(GDB) - else - $(TERMINAL) - endif +ifeq ($(ENABLE_GDB), 1) + $(GDB) +else + $(TERMINAL) +endif otaserver: all $(vecho) "Starting OTA server for TESTING" @@ -409,12 +409,12 @@ gdb: kill_term $(GDB) # Wipe flash +FLASH_INIT_CHUNKS := $(INIT_BIN_ADDR) $(SDK_BASE)/bin/esp_init_data_default.bin +FLASH_INIT_CHUNKS += $(BLANK_BIN_ADDR) $(SDK_BASE)/bin/blank.bin +ifneq ($(DISABLE_SPIFFS), 1) + FLASH_INIT_CHUNKS += $(RBOOT_SPIFFS_0) $(PLATFORM_BASE)/Compiler/data/blankfs.bin +endif flashinit: - FLASH_INIT_CHUNKS := $(INIT_BIN_ADDR) $(SDK_BASE)/bin/esp_init_data_default.bin - FLASH_INIT_CHUNKS += $(BLANK_BIN_ADDR) $(SDK_BASE)/bin/blank.bin - ifneq ($(DISABLE_SPIFFS), 1) - FLASH_INIT_CHUNKS += $(RBOOT_SPIFFS_0) $(PLATFORM_BASE)/Compiler/data/blankfs.bin - endif $(vecho) "Flash init data default and blank data." $(vecho) "DISABLE_SPIFFS = $(DISABLE_SPIFFS)" $(ERASE_FLASH) diff --git a/Sming/apptest/apptest.cpp b/Sming/apptest/apptest.cpp deleted file mode 100644 index 3d5866442e..0000000000 --- a/Sming/apptest/apptest.cpp +++ /dev/null @@ -1,50 +0,0 @@ -#include - -Timer procTimer; - -bool ok = false; -void onTimer() -{ - ok = !ok; - digitalWrite(0, ok); - digitalWrite(2, !ok); -} - -void init() -{ - Serial.begin(230400); - Serial.systemDebugOutput(true); - Serial.println("Hello friendly world! :)"); - - - debugf("ST"); - char json[] = "{\"sensor\":\"gps\",\"time\":1351824120,\"data\":[48.756080,2.302038]}"; - - DynamicJsonBuffer jsonBuffer; - - JsonObject& root = jsonBuffer.parseObject(json); - - const char* sensor = root["sensor"]; - long timese = root["time"]; - double latitude = root["data"][0]; - double longitude = root["data"][1]; - - debugf("%s, %d %s", sensor, timese, String(longitude, 12).c_str()); - debugf("OK"); - - { - JsonObject& root = jsonBuffer.createObject(); - root["sensor"] = "gps"; - root["time"] = 1351824121; - - JsonArray& data = root.createNestedArray("data"); - data.add(48.756080, 6); // 6 is the number of decimals to print - data.add(2.302038, 6); // if not specified, 2 digits are printed - - root.printTo(Serial); - } - - pinMode(0, OUTPUT); - pinMode(2, OUTPUT); - procTimer.initializeMs(10, onTimer).start(); -} diff --git a/Sming/building.md b/Sming/building.md index cd006ae7b6..af6c0268b5 100644 --- a/Sming/building.md +++ b/Sming/building.md @@ -93,9 +93,7 @@ Targets include: > **docs** Build the documentation -> **third-party** Fetch third-party submodules, but do not build - -> **libraries** Fetch Arduino libraries from repos, but do not build +> **submodules** Fetch all third-party submodules, but do not build > **samples** Build all the sample applications @@ -119,9 +117,7 @@ Cleaning: > **user-lib-clean** Clear generated user libraries -> **third-party-clean** Reset state of third-party repos - -> **libraries-clean** Reset state of Arduino libraries +> **submodules-clean** Reset state of third-party repos > **samples-clean** Invoke **clean** on all samples @@ -158,7 +154,7 @@ This mechanism is appropriate for files with multiple configurable options and a i.e. Using `make -j` doesn't work for rules which pull in submodules from GIT, so this must be done as a first step: -`make third-party libraries` +`make submodules` then you can From cd9919af45b97fb24efd762de665750bcbafbc3a Mon Sep 17 00:00:00 2001 From: mikee47 Date: Sat, 27 Apr 2019 17:39:23 +0100 Subject: [PATCH 03/22] Use `Arch` directory instead of `Platform` * Relocate submodules and tidy `.gitmodules` file * Move libsming definitions and MQTT flag into `build.mk` as they apply to both framework and application builds * Move SDK into `Arch/Esp8266/Sdk` and update to use Version 3 un-patched release --- .gitmodules | 100 +++++++++--------- .../Esp8266/Compiler/data/blankfs.bin | 0 .../Esp8266/Compiler/ld/common.ld | 0 .../Esp8266/Compiler/ld/rboot.rom0.ld | 0 .../Esp8266/Compiler/ld/standalone.rom.ld | 0 .../Esp8266/Compiler/lib/.gitignore | 0 .../Esp8266/Compiler/lib/libmicroc.a | Bin .../Esp8266/Compiler/lib/libmicrogcc.a | Bin .../Esp8266/Components/Sdk/ESP8266_NONOS_SDK | 1 + .../Esp8266/Components}/axtls-8266/axtls-8266 | 0 .../Components}/axtls-8266/axtls-8266.patch | 0 .../Esp8266/Components}/custom_heap/heap.c | 0 .../Components}/custom_heap/umm_malloc | 0 .../Components}/custom_heap/umm_malloc.patch | 0 .../Components}/driver/include/driver/uart.h | 0 .../Esp8266/Components}/driver/uart.cpp | 0 .../Esp8266/Components}/esp-lwip/arch/cc.h | 0 .../Esp8266/Components}/esp-lwip/arch/perf.h | 0 .../Components}/esp-lwip/arch/sys_arch.h | 0 .../Components}/esp-lwip/include/lwip/api.h | 0 .../esp-lwip/include/lwip/api_msg.h | 0 .../esp-lwip/include/lwip/app/dhcpserver.h | 0 .../esp-lwip/include/lwip/app/espconn.h | 0 .../esp-lwip/include/lwip/app/espconn_tcp.h | 0 .../esp-lwip/include/lwip/app/espconn_udp.h | 0 .../esp-lwip/include/lwip/app/ping.h | 0 .../Components}/esp-lwip/include/lwip/arch.h | 0 .../esp-lwip/include/lwip/autoip.h | 0 .../Components}/esp-lwip/include/lwip/debug.h | 0 .../Components}/esp-lwip/include/lwip/def.h | 0 .../Components}/esp-lwip/include/lwip/dhcp.h | 0 .../Components}/esp-lwip/include/lwip/dns.h | 0 .../Components}/esp-lwip/include/lwip/err.h | 0 .../Components}/esp-lwip/include/lwip/icmp.h | 0 .../Components}/esp-lwip/include/lwip/igmp.h | 0 .../Components}/esp-lwip/include/lwip/inet.h | 0 .../esp-lwip/include/lwip/inet_chksum.h | 0 .../Components}/esp-lwip/include/lwip/init.h | 0 .../Components}/esp-lwip/include/lwip/ip.h | 0 .../esp-lwip/include/lwip/ip_addr.h | 0 .../esp-lwip/include/lwip/ip_frag.h | 0 .../Components}/esp-lwip/include/lwip/mem.h | 0 .../Components}/esp-lwip/include/lwip/memp.h | 0 .../esp-lwip/include/lwip/memp_std.h | 0 .../esp-lwip/include/lwip/netbuf.h | 0 .../Components}/esp-lwip/include/lwip/netdb.h | 0 .../Components}/esp-lwip/include/lwip/netif.h | 0 .../esp-lwip/include/lwip/netifapi.h | 0 .../Components}/esp-lwip/include/lwip/opt.h | 0 .../Components}/esp-lwip/include/lwip/pbuf.h | 0 .../Components}/esp-lwip/include/lwip/raw.h | 0 .../Components}/esp-lwip/include/lwip/sio.h | 0 .../Components}/esp-lwip/include/lwip/snmp.h | 0 .../esp-lwip/include/lwip/snmp_asn1.h | 0 .../esp-lwip/include/lwip/snmp_msg.h | 0 .../esp-lwip/include/lwip/snmp_structs.h | 0 .../esp-lwip/include/lwip/sockets.h | 0 .../Components}/esp-lwip/include/lwip/stats.h | 0 .../Components}/esp-lwip/include/lwip/sys.h | 0 .../Components}/esp-lwip/include/lwip/tcp.h | 0 .../esp-lwip/include/lwip/tcp_impl.h | 0 .../Components}/esp-lwip/include/lwip/tcpip.h | 0 .../esp-lwip/include/lwip/timers.h | 0 .../Components}/esp-lwip/include/lwip/udp.h | 0 .../Esp8266/Components}/esp-lwip/lwipopts.h | 0 .../Components}/esp-lwip/mem_manager.h | 0 .../Components}/esp-open-lwip/esp-open-lwip | 0 .../esp-open-lwip/esp-open-lwip.patch | 0 .../Components}/esp8266/crash_handler.c | 0 .../Components}/esp8266/esp_cplusplus.cpp | 0 .../Esp8266/Components}/esp8266/flashmem.c | 0 .../esp8266/include/esp_cplusplus.h | 0 .../esp8266/include/esp_systemapi.h | 0 .../esp8266/include/esp_wifi_sniffer.h | 0 .../include/espinc/c_types_compatible.h | 0 .../esp8266/include/espinc/lwip_includes.h | 0 .../Components}/esp8266/include/espinc/peri.h | 0 .../esp8266/include/espinc/spi_register.h | 0 .../esp8266/include/espinc/uart_register.h | 0 .../Components}/esp8266/include/flashmem.h | 0 .../Esp8266/Components}/esp8266/irq_check.s | 0 .../Esp8266/Components}/esp8266/startup.cpp | 0 .../Components}/esp8266/xt_interrupts.cpp | 0 .../Esp8266/Components}/fatfs/diskio.h | 0 .../Esp8266/Components}/fatfs/ff.c | 0 .../Esp8266/Components}/fatfs/ff.h | 0 .../Esp8266/Components}/fatfs/ffconf.h | 0 .../Esp8266/Components}/fatfs/integer.h | 0 .../Esp8266/Components}/gdbstub/GdbPacket.cpp | 0 .../Esp8266/Components}/gdbstub/GdbPacket.h | 0 .../Components}/gdbstub/appcode/gdb_hooks.cpp | 0 .../gdbstub/appcode/gdbstub-entry.S | 0 .../Esp8266/Components}/gdbstub/exceptions.h | 0 .../Components}/gdbstub/gdb/registers.h | 0 .../Components}/gdbstub/gdb/signals.def | 0 .../Esp8266/Components}/gdbstub/gdb/signals.h | 0 .../Esp8266/Components}/gdbstub/gdbcmds | 0 .../Esp8266/Components}/gdbstub/gdbhostio.cpp | 0 .../Esp8266/Components}/gdbstub/gdbhostio.h | 0 .../Esp8266/Components}/gdbstub/gdbstub-cfg.h | 0 .../Components}/gdbstub/gdbstub-entry.h | 0 .../Components}/gdbstub/gdbstub-internal.h | 0 .../Esp8266/Components}/gdbstub/gdbstub.cpp | 0 .../Esp8266/Components}/gdbstub/gdbstub.h | 0 .../Components}/gdbstub/gdbsyscall.cpp | 0 .../Esp8266/Components}/gdbstub/gdbsyscall.h | 0 .../Esp8266/Components}/gdbstub/gdbuart.cpp | 0 .../Esp8266/Components}/gdbstub/gdbuart.h | 0 .../Esp8266/Components}/gdbstub/readme.md | 0 .../Components}/gdbstub/symbols/bootrom.elf | Bin .../gdbstub/xtensa/xtruntime-frames.h | 0 .../Esp8266/Components}/lwip2/lwip2 | 0 .../Esp8266/Components}/lwip2/lwip2.patch | 0 .../Esp8266/Components}/pwm/new-pwm | 0 .../Esp8266/Components}/pwm/new-pwm.patch | 0 .../rboot/appcode/rboot-integration.h | 0 .../rboot/appcode/rboot-overrides.c | 0 .../Esp8266/Components}/rboot/rboot | 0 .../Esp8266/Components}/rboot/rboot.patch | 0 .../Components}/spiffs/spiffs_config.h | 0 .../Esp8266/Components}/spiffs/spiffs_sming.c | 0 .../Esp8266/Components}/spiffs/spiffs_sming.h | 0 .../Esp8266/Components}/spiffs/spiffy_host.h | 0 .../{Platform => Arch}/Esp8266/Core/Clock.cpp | 0 .../Esp8266/Core/Digital.cpp | 0 .../Esp8266/Core/ESP8266EX.cpp | 0 .../Esp8266/Core/ESP8266EX.h | 0 .../Esp8266/Core/HardwarePWM.cpp | 0 .../Esp8266/Core/HardwareSerial.cpp | 0 .../Esp8266/Core/HardwareTimer.cpp | 0 .../Esp8266/Core/Interrupts.cpp | 0 .../Esp8266/Core/Network/rBootHttpUpdate.cpp | 0 .../Esp8266/Core/Network/rBootHttpUpdate.h | 0 Sming/{Platform => Arch}/Esp8266/Core/SPI.cpp | 0 .../Esp8266/Core/SPISoft.cpp | 0 .../Esp8266/Core/core_esp8266_si2c.cpp | 0 .../Esp8266/Core/pins_arduino.h | 0 .../Esp8266/Platform/AccessPoint.cpp | 0 .../Esp8266/Platform/RTC.cpp | 0 .../Esp8266/Platform/Station.cpp | 0 .../Esp8266/Platform/System.cpp | 0 .../Esp8266/Platform/WDT.cpp | 0 .../Esp8266/Platform/WifiEvents.cpp | 0 .../Esp8266/Platform/WifiSniffer.cpp | 0 .../Esp8266/System/include/user_config.h | 0 .../Esp8266/Tools/decode-stacktrace.py | 0 .../{Platform => Arch}/Esp8266/Tools/esptool2 | 0 .../Esp8266/Tools/memanalyzer.py | 0 .../Esp8266/Tools/spiffy/.gitignore | 0 .../Esp8266/Tools/spiffy/Makefile | 8 +- .../Esp8266/Tools/spiffy/spiffy.c | 0 Sming/{Platform => Arch}/Esp8266/app.mk | 61 +++++------ Sming/{Platform => Arch}/Esp8266/build.mk | 17 +-- Sming/{Platform => Arch}/Esp8266/flash.mk | 0 Sming/{Platform => Arch}/Esp8266/sming.mk | 56 +++++----- .../.patches/Readme.md | 0 .../.patches/http-parser.patch | 0 .../.patches/mqtt-codec.patch | 0 .../.patches/ws_parser.patch | 0 Sming/{third-party => Components}/http-parser | 0 Sming/{third-party => Components}/libyuarel | 0 Sming/{third-party => Components}/mqtt-codec | 0 Sming/{third-party => Components}/spiffs | 0 Sming/{third-party => Components}/ws_parser | 0 Sming/Makefile | 66 +++++------- Sming/Makefile-app.mk | 18 +--- Sming/Makefile-bsd.mk | 2 +- Sming/Makefile-linux.mk | 2 +- Sming/Makefile-macos.mk | 2 +- Sming/Makefile-windows.mk | 2 +- .../{Common/Platform => }/AccessPoint.h | 0 .../Platform => }/OsMessageInterceptor.cpp | 0 .../Platform => }/OsMessageInterceptor.h | 0 Sming/Platform/{Common/Platform => }/RTC.h | 0 .../Platform/{Common/Platform => }/Station.h | 0 Sming/Platform/{Common/Platform => }/System.h | 0 Sming/Platform/{Common/Platform => }/WDT.h | 0 .../{Common/Platform => }/WifiEvents.h | 0 .../{Common/Platform => }/WifiSniffer.h | 0 Sming/build.mk | 50 ++++++--- .../.patches/ESP8266_NONOS_SDK.patch | 24 ----- Sming/third-party/ESP8266_NONOS_SDK | 1 - 182 files changed, 194 insertions(+), 216 deletions(-) rename Sming/{Platform => Arch}/Esp8266/Compiler/data/blankfs.bin (100%) rename Sming/{Platform => Arch}/Esp8266/Compiler/ld/common.ld (100%) rename Sming/{Platform => Arch}/Esp8266/Compiler/ld/rboot.rom0.ld (100%) rename Sming/{Platform => Arch}/Esp8266/Compiler/ld/standalone.rom.ld (100%) rename Sming/{Platform => Arch}/Esp8266/Compiler/lib/.gitignore (100%) rename Sming/{Platform => Arch}/Esp8266/Compiler/lib/libmicroc.a (100%) rename Sming/{Platform => Arch}/Esp8266/Compiler/lib/libmicrogcc.a (100%) create mode 160000 Sming/Arch/Esp8266/Components/Sdk/ESP8266_NONOS_SDK rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/axtls-8266/axtls-8266 (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/axtls-8266/axtls-8266.patch (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/custom_heap/heap.c (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/custom_heap/umm_malloc (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/custom_heap/umm_malloc.patch (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/driver/include/driver/uart.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/driver/uart.cpp (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp-lwip/arch/cc.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp-lwip/arch/perf.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp-lwip/arch/sys_arch.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp-lwip/include/lwip/api.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp-lwip/include/lwip/api_msg.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp-lwip/include/lwip/app/dhcpserver.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp-lwip/include/lwip/app/espconn.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp-lwip/include/lwip/app/espconn_tcp.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp-lwip/include/lwip/app/espconn_udp.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp-lwip/include/lwip/app/ping.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp-lwip/include/lwip/arch.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp-lwip/include/lwip/autoip.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp-lwip/include/lwip/debug.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp-lwip/include/lwip/def.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp-lwip/include/lwip/dhcp.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp-lwip/include/lwip/dns.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp-lwip/include/lwip/err.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp-lwip/include/lwip/icmp.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp-lwip/include/lwip/igmp.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp-lwip/include/lwip/inet.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp-lwip/include/lwip/inet_chksum.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp-lwip/include/lwip/init.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp-lwip/include/lwip/ip.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp-lwip/include/lwip/ip_addr.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp-lwip/include/lwip/ip_frag.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp-lwip/include/lwip/mem.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp-lwip/include/lwip/memp.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp-lwip/include/lwip/memp_std.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp-lwip/include/lwip/netbuf.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp-lwip/include/lwip/netdb.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp-lwip/include/lwip/netif.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp-lwip/include/lwip/netifapi.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp-lwip/include/lwip/opt.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp-lwip/include/lwip/pbuf.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp-lwip/include/lwip/raw.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp-lwip/include/lwip/sio.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp-lwip/include/lwip/snmp.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp-lwip/include/lwip/snmp_asn1.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp-lwip/include/lwip/snmp_msg.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp-lwip/include/lwip/snmp_structs.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp-lwip/include/lwip/sockets.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp-lwip/include/lwip/stats.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp-lwip/include/lwip/sys.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp-lwip/include/lwip/tcp.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp-lwip/include/lwip/tcp_impl.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp-lwip/include/lwip/tcpip.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp-lwip/include/lwip/timers.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp-lwip/include/lwip/udp.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp-lwip/lwipopts.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp-lwip/mem_manager.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp-open-lwip/esp-open-lwip (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp-open-lwip/esp-open-lwip.patch (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp8266/crash_handler.c (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp8266/esp_cplusplus.cpp (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp8266/flashmem.c (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp8266/include/esp_cplusplus.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp8266/include/esp_systemapi.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp8266/include/esp_wifi_sniffer.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp8266/include/espinc/c_types_compatible.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp8266/include/espinc/lwip_includes.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp8266/include/espinc/peri.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp8266/include/espinc/spi_register.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp8266/include/espinc/uart_register.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp8266/include/flashmem.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp8266/irq_check.s (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp8266/startup.cpp (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/esp8266/xt_interrupts.cpp (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/fatfs/diskio.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/fatfs/ff.c (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/fatfs/ff.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/fatfs/ffconf.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/fatfs/integer.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/gdbstub/GdbPacket.cpp (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/gdbstub/GdbPacket.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/gdbstub/appcode/gdb_hooks.cpp (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/gdbstub/appcode/gdbstub-entry.S (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/gdbstub/exceptions.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/gdbstub/gdb/registers.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/gdbstub/gdb/signals.def (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/gdbstub/gdb/signals.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/gdbstub/gdbcmds (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/gdbstub/gdbhostio.cpp (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/gdbstub/gdbhostio.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/gdbstub/gdbstub-cfg.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/gdbstub/gdbstub-entry.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/gdbstub/gdbstub-internal.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/gdbstub/gdbstub.cpp (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/gdbstub/gdbstub.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/gdbstub/gdbsyscall.cpp (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/gdbstub/gdbsyscall.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/gdbstub/gdbuart.cpp (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/gdbstub/gdbuart.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/gdbstub/readme.md (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/gdbstub/symbols/bootrom.elf (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/gdbstub/xtensa/xtruntime-frames.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/lwip2/lwip2 (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/lwip2/lwip2.patch (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/pwm/new-pwm (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/pwm/new-pwm.patch (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/rboot/appcode/rboot-integration.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/rboot/appcode/rboot-overrides.c (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/rboot/rboot (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/rboot/rboot.patch (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/spiffs/spiffs_config.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/spiffs/spiffs_sming.c (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/spiffs/spiffs_sming.h (100%) rename Sming/{Platform/Esp8266/System/components => Arch/Esp8266/Components}/spiffs/spiffy_host.h (100%) rename Sming/{Platform => Arch}/Esp8266/Core/Clock.cpp (100%) rename Sming/{Platform => Arch}/Esp8266/Core/Digital.cpp (100%) rename Sming/{Platform => Arch}/Esp8266/Core/ESP8266EX.cpp (100%) rename Sming/{Platform => Arch}/Esp8266/Core/ESP8266EX.h (100%) rename Sming/{Platform => Arch}/Esp8266/Core/HardwarePWM.cpp (100%) rename Sming/{Platform => Arch}/Esp8266/Core/HardwareSerial.cpp (100%) rename Sming/{Platform => Arch}/Esp8266/Core/HardwareTimer.cpp (100%) rename Sming/{Platform => Arch}/Esp8266/Core/Interrupts.cpp (100%) rename Sming/{Platform => Arch}/Esp8266/Core/Network/rBootHttpUpdate.cpp (100%) rename Sming/{Platform => Arch}/Esp8266/Core/Network/rBootHttpUpdate.h (100%) rename Sming/{Platform => Arch}/Esp8266/Core/SPI.cpp (100%) rename Sming/{Platform => Arch}/Esp8266/Core/SPISoft.cpp (100%) rename Sming/{Platform => Arch}/Esp8266/Core/core_esp8266_si2c.cpp (100%) rename Sming/{Platform => Arch}/Esp8266/Core/pins_arduino.h (100%) rename Sming/{Platform => Arch}/Esp8266/Platform/AccessPoint.cpp (100%) rename Sming/{Platform => Arch}/Esp8266/Platform/RTC.cpp (100%) rename Sming/{Platform => Arch}/Esp8266/Platform/Station.cpp (100%) rename Sming/{Platform => Arch}/Esp8266/Platform/System.cpp (100%) rename Sming/{Platform => Arch}/Esp8266/Platform/WDT.cpp (100%) rename Sming/{Platform => Arch}/Esp8266/Platform/WifiEvents.cpp (100%) rename Sming/{Platform => Arch}/Esp8266/Platform/WifiSniffer.cpp (100%) rename Sming/{Platform => Arch}/Esp8266/System/include/user_config.h (100%) rename Sming/{Platform => Arch}/Esp8266/Tools/decode-stacktrace.py (100%) rename Sming/{Platform => Arch}/Esp8266/Tools/esptool2 (100%) rename Sming/{Platform => Arch}/Esp8266/Tools/memanalyzer.py (100%) rename Sming/{Platform => Arch}/Esp8266/Tools/spiffy/.gitignore (100%) rename Sming/{Platform => Arch}/Esp8266/Tools/spiffy/Makefile (70%) rename Sming/{Platform => Arch}/Esp8266/Tools/spiffy/spiffy.c (100%) rename Sming/{Platform => Arch}/Esp8266/app.mk (82%) rename Sming/{Platform => Arch}/Esp8266/build.mk (71%) rename Sming/{Platform => Arch}/Esp8266/flash.mk (100%) rename Sming/{Platform => Arch}/Esp8266/sming.mk (70%) rename Sming/{third-party => Components}/.patches/Readme.md (100%) rename Sming/{third-party => Components}/.patches/http-parser.patch (100%) rename Sming/{third-party => Components}/.patches/mqtt-codec.patch (100%) rename Sming/{third-party => Components}/.patches/ws_parser.patch (100%) rename Sming/{third-party => Components}/http-parser (100%) rename Sming/{third-party => Components}/libyuarel (100%) rename Sming/{third-party => Components}/mqtt-codec (100%) rename Sming/{third-party => Components}/spiffs (100%) rename Sming/{third-party => Components}/ws_parser (100%) rename Sming/Platform/{Common/Platform => }/AccessPoint.h (100%) rename Sming/Platform/{Common/Platform => }/OsMessageInterceptor.cpp (100%) rename Sming/Platform/{Common/Platform => }/OsMessageInterceptor.h (100%) rename Sming/Platform/{Common/Platform => }/RTC.h (100%) rename Sming/Platform/{Common/Platform => }/Station.h (100%) rename Sming/Platform/{Common/Platform => }/System.h (100%) rename Sming/Platform/{Common/Platform => }/WDT.h (100%) rename Sming/Platform/{Common/Platform => }/WifiEvents.h (100%) rename Sming/Platform/{Common/Platform => }/WifiSniffer.h (100%) delete mode 100644 Sming/third-party/.patches/ESP8266_NONOS_SDK.patch delete mode 160000 Sming/third-party/ESP8266_NONOS_SDK diff --git a/.gitmodules b/.gitmodules index ef86d3d069..a7f8d2b8fb 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,96 +1,100 @@ -[submodule "ESP8266.rboot"] - path = Sming/Platform/Esp8266/System/components/rboot/rboot - url = https://github.com/raburton/rboot.git - ignore = dirty [submodule "Sming.wiki"] path = docs/wiki url = https://github.com/SmingHub/Sming.wiki.git ignore = dirty +[submodule "spiffs"] + path = Sming/Components/spiffs + url = https://github.com/pellepl/spiffs.git + ignore = dirty +[submodule "http-parser"] + path = Sming/Components/http-parser + url = https://github.com/nodejs/http-parser.git + ignore = dirty +[submodule "ws_parser"] + path = Sming/Components/ws_parser + url = https://github.com/charliesome/ws_parser.git + ignore = dirty +[submodule "mqtt-codec"] + path = Sming/Components/mqtt-codec + url = https://github.com/slaff/mqtt-codec.git + ignore = dirty +[submodule "libyuarel"] + path = Sming/Components/libyuarel + url = https://github.com/jacketizer/libyuarel.git + ignore = dirty + +[submodule "ESP8266.rboot"] + path = Sming/Arch/Esp8266/Components/rboot/rboot + url = https://github.com/raburton/rboot.git + ignore = dirty [submodule "ESP8266.new-pwm"] - path = Sming/Platform/Esp8266/System/components/pwm/new-pwm + path = Sming/Arch/Esp8266/Components/pwm/new-pwm url = https://github.com/StefanBruens/ESP8266_new_pwm.git ignore = dirty [submodule "ESP8266.axtls-8266"] - path = Sming/Platform/Esp8266/System/components/axtls-8266/axtls-8266 + path = Sming/Arch/Esp8266/Components/axtls-8266/axtls-8266 url = https://github.com/igrr/axtls-8266.git ignore = dirty -[submodule "ESP8266.spiffs"] - path = Sming/third-party/spiffs - url = https://github.com/pellepl/spiffs.git - ignore = dirty [submodule "ESP8266.umm_malloc"] - path = Sming/Platform/Esp8266/System/components/custom_heap/umm_malloc + path = Sming/Arch/Esp8266/Components/custom_heap/umm_malloc url = https://github.com/rhempel/umm_malloc.git ignore = dirty [submodule "ESP8266.esp-open-lwip"] - path = Sming/Platform/Esp8266/System/components/esp-open-lwip/esp-open-lwip + path = Sming/Arch/Esp8266/Components/esp-open-lwip/esp-open-lwip url = https://github.com/pfalcon/esp-open-lwip.git ignore = dirty -[submodule "Sming/third-party/http-parser"] - path = Sming/third-party/http-parser - url = https://github.com/nodejs/http-parser.git +[submodule "ESP8266.lwip2"] + path = Sming/Arch/Esp8266/Components/lwip2/lwip2 + url = https://github.com/d-a-v/esp82xx-nonos-linklayer.git ignore = dirty -[submodule "Sming/third-party/ws_parser"] - path = Sming/third-party/ws_parser - url = https://github.com/charliesome/ws_parser.git + +[submodule "ESP8266.Sdk"] + path = Sming/Arch/Esp8266/Components/Sdk/ESP8266_NONOS_SDK + url = https://github.com/espressif/ESP8266_NONOS_SDK.git + ignore = dirty +[submodule "ESP8266.esptool2"] + path = Sming/Arch/Esp8266/Tools/esptool2 + url = https://github.com/raburton/esptool2.git ignore = dirty -[submodule "Sming/Libraries/Adafruit_ST7735"] + +[submodule "Libraries.Adafruit_ST7735"] path = Sming/Libraries/Adafruit_ST7735 url = https://github.com/adafruit/Adafruit-ST7735-Library.git ignore = dirty -[submodule "Sming/Libraries/Adafruit_SSD1306"] +[submodule "Libraries.Adafruit_SSD1306"] path = Sming/Libraries/Adafruit_SSD1306 url = https://github.com/adafruit/Adafruit_SSD1306.git ignore = dirty -[submodule "Sming/Libraries/Adafruit_BME280_Library"] +[submodule "Libraries.Adafruit_BME280_Library"] path = Sming/Libraries/Adafruit_BME280_Library url = https://github.com/adafruit/Adafruit_BME280_Library.git ignore = dirty -[submodule "Sming/Libraries/Adafruit_Sensor"] +[submodule "Libraries.Adafruit_Sensor"] path = Sming/Libraries/Adafruit_Sensor url = https://github.com/adafruit/Adafruit_Sensor ignore = dirty -[submodule "ESP8266.lwip2"] - path = Sming/Platform/Esp8266/System/components/lwip2/lwip2 - url = https://github.com/d-a-v/esp82xx-nonos-linklayer.git - ignore = dirty -[submodule "Sming/third-party/ESP8266_NONOS_SDK"] - path = Sming/third-party/ESP8266_NONOS_SDK - url = https://github.com/espressif/ESP8266_NONOS_SDK.git - ignore = dirty -[submodule "ESP8266.esptool2"] - path = Sming/Platform/Esp8266/Tools/esptool2 - url = https://github.com/raburton/esptool2.git - ignore = dirty -[submodule "Sming/Libraries/RingBufCPP"] +[submodule "Libraries.RingBufCPP"] path = Sming/Libraries/RingBufCPP url = https://github.com/wizard97/Embedded_RingBuf_CPP.git ignore = dirty -[submodule "Sming/Libraries/IR"] +[submodule "Libraries.IR"] path = Sming/Libraries/IR url = https://github.com/markszabo/IRremoteESP8266.git ignore = dirty -[submodule "Sming/Libraries/DHTesp"] +[submodule "Libraries.DHTesp"] path = Sming/Libraries/DHTesp url = https://github.com/beegee-tokyo/DHTesp.git ignore = dirty -[submodule "Sming/third-party/ITEADLIB_Arduino_Nextion"] +[submodule "Libraries.ITEADLIB_Arduino_Nextion"] path = Sming/Libraries/ITEADLIB_Arduino_Nextion url = https://github.com/itead/ITEADLIB_Arduino_Nextion.git ignore = dirty -[submodule "Sming/Libraries/DFRobotDFPlayerMini"] +[submodule "Libraries.DFRobotDFPlayerMini"] path = Sming/Libraries/DFRobotDFPlayerMini url = https://github.com/DFRobot/DFRobotDFPlayerMini.git ignore = dirty -[submodule "Sming/Libraries/TM1637"] +[submodule "Libraries.TM1637"] path = Sming/Libraries/TM1637 url = https://github.com/avishorp/TM1637.git ignore = dirty -[submodule "Sming/third-party/mqtt-codec"] - path = Sming/third-party/mqtt-codec - url = https://github.com/slaff/mqtt-codec.git - ignore = dirty -[submodule "Sming/third-party/libyuarel"] - path = Sming/third-party/libyuarel - url = https://github.com/jacketizer/libyuarel.git - ignore = dirty + diff --git a/Sming/Platform/Esp8266/Compiler/data/blankfs.bin b/Sming/Arch/Esp8266/Compiler/data/blankfs.bin similarity index 100% rename from Sming/Platform/Esp8266/Compiler/data/blankfs.bin rename to Sming/Arch/Esp8266/Compiler/data/blankfs.bin diff --git a/Sming/Platform/Esp8266/Compiler/ld/common.ld b/Sming/Arch/Esp8266/Compiler/ld/common.ld similarity index 100% rename from Sming/Platform/Esp8266/Compiler/ld/common.ld rename to Sming/Arch/Esp8266/Compiler/ld/common.ld diff --git a/Sming/Platform/Esp8266/Compiler/ld/rboot.rom0.ld b/Sming/Arch/Esp8266/Compiler/ld/rboot.rom0.ld similarity index 100% rename from Sming/Platform/Esp8266/Compiler/ld/rboot.rom0.ld rename to Sming/Arch/Esp8266/Compiler/ld/rboot.rom0.ld diff --git a/Sming/Platform/Esp8266/Compiler/ld/standalone.rom.ld b/Sming/Arch/Esp8266/Compiler/ld/standalone.rom.ld similarity index 100% rename from Sming/Platform/Esp8266/Compiler/ld/standalone.rom.ld rename to Sming/Arch/Esp8266/Compiler/ld/standalone.rom.ld diff --git a/Sming/Platform/Esp8266/Compiler/lib/.gitignore b/Sming/Arch/Esp8266/Compiler/lib/.gitignore similarity index 100% rename from Sming/Platform/Esp8266/Compiler/lib/.gitignore rename to Sming/Arch/Esp8266/Compiler/lib/.gitignore diff --git a/Sming/Platform/Esp8266/Compiler/lib/libmicroc.a b/Sming/Arch/Esp8266/Compiler/lib/libmicroc.a similarity index 100% rename from Sming/Platform/Esp8266/Compiler/lib/libmicroc.a rename to Sming/Arch/Esp8266/Compiler/lib/libmicroc.a diff --git a/Sming/Platform/Esp8266/Compiler/lib/libmicrogcc.a b/Sming/Arch/Esp8266/Compiler/lib/libmicrogcc.a similarity index 100% rename from Sming/Platform/Esp8266/Compiler/lib/libmicrogcc.a rename to Sming/Arch/Esp8266/Compiler/lib/libmicrogcc.a diff --git a/Sming/Arch/Esp8266/Components/Sdk/ESP8266_NONOS_SDK b/Sming/Arch/Esp8266/Components/Sdk/ESP8266_NONOS_SDK new file mode 160000 index 0000000000..e4434aa730 --- /dev/null +++ b/Sming/Arch/Esp8266/Components/Sdk/ESP8266_NONOS_SDK @@ -0,0 +1 @@ +Subproject commit e4434aa730e78c63040ace360493aef420ec267c diff --git a/Sming/Platform/Esp8266/System/components/axtls-8266/axtls-8266 b/Sming/Arch/Esp8266/Components/axtls-8266/axtls-8266 similarity index 100% rename from Sming/Platform/Esp8266/System/components/axtls-8266/axtls-8266 rename to Sming/Arch/Esp8266/Components/axtls-8266/axtls-8266 diff --git a/Sming/Platform/Esp8266/System/components/axtls-8266/axtls-8266.patch b/Sming/Arch/Esp8266/Components/axtls-8266/axtls-8266.patch similarity index 100% rename from Sming/Platform/Esp8266/System/components/axtls-8266/axtls-8266.patch rename to Sming/Arch/Esp8266/Components/axtls-8266/axtls-8266.patch diff --git a/Sming/Platform/Esp8266/System/components/custom_heap/heap.c b/Sming/Arch/Esp8266/Components/custom_heap/heap.c similarity index 100% rename from Sming/Platform/Esp8266/System/components/custom_heap/heap.c rename to Sming/Arch/Esp8266/Components/custom_heap/heap.c diff --git a/Sming/Platform/Esp8266/System/components/custom_heap/umm_malloc b/Sming/Arch/Esp8266/Components/custom_heap/umm_malloc similarity index 100% rename from Sming/Platform/Esp8266/System/components/custom_heap/umm_malloc rename to Sming/Arch/Esp8266/Components/custom_heap/umm_malloc diff --git a/Sming/Platform/Esp8266/System/components/custom_heap/umm_malloc.patch b/Sming/Arch/Esp8266/Components/custom_heap/umm_malloc.patch similarity index 100% rename from Sming/Platform/Esp8266/System/components/custom_heap/umm_malloc.patch rename to Sming/Arch/Esp8266/Components/custom_heap/umm_malloc.patch diff --git a/Sming/Platform/Esp8266/System/components/driver/include/driver/uart.h b/Sming/Arch/Esp8266/Components/driver/include/driver/uart.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/driver/include/driver/uart.h rename to Sming/Arch/Esp8266/Components/driver/include/driver/uart.h diff --git a/Sming/Platform/Esp8266/System/components/driver/uart.cpp b/Sming/Arch/Esp8266/Components/driver/uart.cpp similarity index 100% rename from Sming/Platform/Esp8266/System/components/driver/uart.cpp rename to Sming/Arch/Esp8266/Components/driver/uart.cpp diff --git a/Sming/Platform/Esp8266/System/components/esp-lwip/arch/cc.h b/Sming/Arch/Esp8266/Components/esp-lwip/arch/cc.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp-lwip/arch/cc.h rename to Sming/Arch/Esp8266/Components/esp-lwip/arch/cc.h diff --git a/Sming/Platform/Esp8266/System/components/esp-lwip/arch/perf.h b/Sming/Arch/Esp8266/Components/esp-lwip/arch/perf.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp-lwip/arch/perf.h rename to Sming/Arch/Esp8266/Components/esp-lwip/arch/perf.h diff --git a/Sming/Platform/Esp8266/System/components/esp-lwip/arch/sys_arch.h b/Sming/Arch/Esp8266/Components/esp-lwip/arch/sys_arch.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp-lwip/arch/sys_arch.h rename to Sming/Arch/Esp8266/Components/esp-lwip/arch/sys_arch.h diff --git a/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/api.h b/Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/api.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/api.h rename to Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/api.h diff --git a/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/api_msg.h b/Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/api_msg.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/api_msg.h rename to Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/api_msg.h diff --git a/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/app/dhcpserver.h b/Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/app/dhcpserver.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/app/dhcpserver.h rename to Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/app/dhcpserver.h diff --git a/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/app/espconn.h b/Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/app/espconn.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/app/espconn.h rename to Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/app/espconn.h diff --git a/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/app/espconn_tcp.h b/Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/app/espconn_tcp.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/app/espconn_tcp.h rename to Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/app/espconn_tcp.h diff --git a/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/app/espconn_udp.h b/Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/app/espconn_udp.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/app/espconn_udp.h rename to Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/app/espconn_udp.h diff --git a/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/app/ping.h b/Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/app/ping.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/app/ping.h rename to Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/app/ping.h diff --git a/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/arch.h b/Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/arch.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/arch.h rename to Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/arch.h diff --git a/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/autoip.h b/Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/autoip.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/autoip.h rename to Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/autoip.h diff --git a/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/debug.h b/Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/debug.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/debug.h rename to Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/debug.h diff --git a/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/def.h b/Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/def.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/def.h rename to Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/def.h diff --git a/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/dhcp.h b/Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/dhcp.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/dhcp.h rename to Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/dhcp.h diff --git a/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/dns.h b/Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/dns.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/dns.h rename to Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/dns.h diff --git a/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/err.h b/Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/err.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/err.h rename to Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/err.h diff --git a/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/icmp.h b/Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/icmp.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/icmp.h rename to Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/icmp.h diff --git a/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/igmp.h b/Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/igmp.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/igmp.h rename to Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/igmp.h diff --git a/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/inet.h b/Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/inet.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/inet.h rename to Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/inet.h diff --git a/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/inet_chksum.h b/Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/inet_chksum.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/inet_chksum.h rename to Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/inet_chksum.h diff --git a/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/init.h b/Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/init.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/init.h rename to Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/init.h diff --git a/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/ip.h b/Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/ip.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/ip.h rename to Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/ip.h diff --git a/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/ip_addr.h b/Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/ip_addr.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/ip_addr.h rename to Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/ip_addr.h diff --git a/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/ip_frag.h b/Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/ip_frag.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/ip_frag.h rename to Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/ip_frag.h diff --git a/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/mem.h b/Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/mem.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/mem.h rename to Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/mem.h diff --git a/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/memp.h b/Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/memp.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/memp.h rename to Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/memp.h diff --git a/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/memp_std.h b/Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/memp_std.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/memp_std.h rename to Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/memp_std.h diff --git a/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/netbuf.h b/Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/netbuf.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/netbuf.h rename to Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/netbuf.h diff --git a/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/netdb.h b/Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/netdb.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/netdb.h rename to Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/netdb.h diff --git a/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/netif.h b/Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/netif.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/netif.h rename to Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/netif.h diff --git a/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/netifapi.h b/Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/netifapi.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/netifapi.h rename to Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/netifapi.h diff --git a/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/opt.h b/Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/opt.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/opt.h rename to Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/opt.h diff --git a/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/pbuf.h b/Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/pbuf.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/pbuf.h rename to Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/pbuf.h diff --git a/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/raw.h b/Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/raw.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/raw.h rename to Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/raw.h diff --git a/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/sio.h b/Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/sio.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/sio.h rename to Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/sio.h diff --git a/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/snmp.h b/Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/snmp.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/snmp.h rename to Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/snmp.h diff --git a/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/snmp_asn1.h b/Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/snmp_asn1.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/snmp_asn1.h rename to Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/snmp_asn1.h diff --git a/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/snmp_msg.h b/Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/snmp_msg.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/snmp_msg.h rename to Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/snmp_msg.h diff --git a/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/snmp_structs.h b/Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/snmp_structs.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/snmp_structs.h rename to Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/snmp_structs.h diff --git a/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/sockets.h b/Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/sockets.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/sockets.h rename to Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/sockets.h diff --git a/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/stats.h b/Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/stats.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/stats.h rename to Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/stats.h diff --git a/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/sys.h b/Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/sys.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/sys.h rename to Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/sys.h diff --git a/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/tcp.h b/Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/tcp.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/tcp.h rename to Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/tcp.h diff --git a/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/tcp_impl.h b/Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/tcp_impl.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/tcp_impl.h rename to Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/tcp_impl.h diff --git a/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/tcpip.h b/Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/tcpip.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/tcpip.h rename to Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/tcpip.h diff --git a/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/timers.h b/Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/timers.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/timers.h rename to Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/timers.h diff --git a/Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/udp.h b/Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/udp.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp-lwip/include/lwip/udp.h rename to Sming/Arch/Esp8266/Components/esp-lwip/include/lwip/udp.h diff --git a/Sming/Platform/Esp8266/System/components/esp-lwip/lwipopts.h b/Sming/Arch/Esp8266/Components/esp-lwip/lwipopts.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp-lwip/lwipopts.h rename to Sming/Arch/Esp8266/Components/esp-lwip/lwipopts.h diff --git a/Sming/Platform/Esp8266/System/components/esp-lwip/mem_manager.h b/Sming/Arch/Esp8266/Components/esp-lwip/mem_manager.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp-lwip/mem_manager.h rename to Sming/Arch/Esp8266/Components/esp-lwip/mem_manager.h diff --git a/Sming/Platform/Esp8266/System/components/esp-open-lwip/esp-open-lwip b/Sming/Arch/Esp8266/Components/esp-open-lwip/esp-open-lwip similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp-open-lwip/esp-open-lwip rename to Sming/Arch/Esp8266/Components/esp-open-lwip/esp-open-lwip diff --git a/Sming/Platform/Esp8266/System/components/esp-open-lwip/esp-open-lwip.patch b/Sming/Arch/Esp8266/Components/esp-open-lwip/esp-open-lwip.patch similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp-open-lwip/esp-open-lwip.patch rename to Sming/Arch/Esp8266/Components/esp-open-lwip/esp-open-lwip.patch diff --git a/Sming/Platform/Esp8266/System/components/esp8266/crash_handler.c b/Sming/Arch/Esp8266/Components/esp8266/crash_handler.c similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp8266/crash_handler.c rename to Sming/Arch/Esp8266/Components/esp8266/crash_handler.c diff --git a/Sming/Platform/Esp8266/System/components/esp8266/esp_cplusplus.cpp b/Sming/Arch/Esp8266/Components/esp8266/esp_cplusplus.cpp similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp8266/esp_cplusplus.cpp rename to Sming/Arch/Esp8266/Components/esp8266/esp_cplusplus.cpp diff --git a/Sming/Platform/Esp8266/System/components/esp8266/flashmem.c b/Sming/Arch/Esp8266/Components/esp8266/flashmem.c similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp8266/flashmem.c rename to Sming/Arch/Esp8266/Components/esp8266/flashmem.c diff --git a/Sming/Platform/Esp8266/System/components/esp8266/include/esp_cplusplus.h b/Sming/Arch/Esp8266/Components/esp8266/include/esp_cplusplus.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp8266/include/esp_cplusplus.h rename to Sming/Arch/Esp8266/Components/esp8266/include/esp_cplusplus.h diff --git a/Sming/Platform/Esp8266/System/components/esp8266/include/esp_systemapi.h b/Sming/Arch/Esp8266/Components/esp8266/include/esp_systemapi.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp8266/include/esp_systemapi.h rename to Sming/Arch/Esp8266/Components/esp8266/include/esp_systemapi.h diff --git a/Sming/Platform/Esp8266/System/components/esp8266/include/esp_wifi_sniffer.h b/Sming/Arch/Esp8266/Components/esp8266/include/esp_wifi_sniffer.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp8266/include/esp_wifi_sniffer.h rename to Sming/Arch/Esp8266/Components/esp8266/include/esp_wifi_sniffer.h diff --git a/Sming/Platform/Esp8266/System/components/esp8266/include/espinc/c_types_compatible.h b/Sming/Arch/Esp8266/Components/esp8266/include/espinc/c_types_compatible.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp8266/include/espinc/c_types_compatible.h rename to Sming/Arch/Esp8266/Components/esp8266/include/espinc/c_types_compatible.h diff --git a/Sming/Platform/Esp8266/System/components/esp8266/include/espinc/lwip_includes.h b/Sming/Arch/Esp8266/Components/esp8266/include/espinc/lwip_includes.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp8266/include/espinc/lwip_includes.h rename to Sming/Arch/Esp8266/Components/esp8266/include/espinc/lwip_includes.h diff --git a/Sming/Platform/Esp8266/System/components/esp8266/include/espinc/peri.h b/Sming/Arch/Esp8266/Components/esp8266/include/espinc/peri.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp8266/include/espinc/peri.h rename to Sming/Arch/Esp8266/Components/esp8266/include/espinc/peri.h diff --git a/Sming/Platform/Esp8266/System/components/esp8266/include/espinc/spi_register.h b/Sming/Arch/Esp8266/Components/esp8266/include/espinc/spi_register.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp8266/include/espinc/spi_register.h rename to Sming/Arch/Esp8266/Components/esp8266/include/espinc/spi_register.h diff --git a/Sming/Platform/Esp8266/System/components/esp8266/include/espinc/uart_register.h b/Sming/Arch/Esp8266/Components/esp8266/include/espinc/uart_register.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp8266/include/espinc/uart_register.h rename to Sming/Arch/Esp8266/Components/esp8266/include/espinc/uart_register.h diff --git a/Sming/Platform/Esp8266/System/components/esp8266/include/flashmem.h b/Sming/Arch/Esp8266/Components/esp8266/include/flashmem.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp8266/include/flashmem.h rename to Sming/Arch/Esp8266/Components/esp8266/include/flashmem.h diff --git a/Sming/Platform/Esp8266/System/components/esp8266/irq_check.s b/Sming/Arch/Esp8266/Components/esp8266/irq_check.s similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp8266/irq_check.s rename to Sming/Arch/Esp8266/Components/esp8266/irq_check.s diff --git a/Sming/Platform/Esp8266/System/components/esp8266/startup.cpp b/Sming/Arch/Esp8266/Components/esp8266/startup.cpp similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp8266/startup.cpp rename to Sming/Arch/Esp8266/Components/esp8266/startup.cpp diff --git a/Sming/Platform/Esp8266/System/components/esp8266/xt_interrupts.cpp b/Sming/Arch/Esp8266/Components/esp8266/xt_interrupts.cpp similarity index 100% rename from Sming/Platform/Esp8266/System/components/esp8266/xt_interrupts.cpp rename to Sming/Arch/Esp8266/Components/esp8266/xt_interrupts.cpp diff --git a/Sming/Platform/Esp8266/System/components/fatfs/diskio.h b/Sming/Arch/Esp8266/Components/fatfs/diskio.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/fatfs/diskio.h rename to Sming/Arch/Esp8266/Components/fatfs/diskio.h diff --git a/Sming/Platform/Esp8266/System/components/fatfs/ff.c b/Sming/Arch/Esp8266/Components/fatfs/ff.c similarity index 100% rename from Sming/Platform/Esp8266/System/components/fatfs/ff.c rename to Sming/Arch/Esp8266/Components/fatfs/ff.c diff --git a/Sming/Platform/Esp8266/System/components/fatfs/ff.h b/Sming/Arch/Esp8266/Components/fatfs/ff.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/fatfs/ff.h rename to Sming/Arch/Esp8266/Components/fatfs/ff.h diff --git a/Sming/Platform/Esp8266/System/components/fatfs/ffconf.h b/Sming/Arch/Esp8266/Components/fatfs/ffconf.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/fatfs/ffconf.h rename to Sming/Arch/Esp8266/Components/fatfs/ffconf.h diff --git a/Sming/Platform/Esp8266/System/components/fatfs/integer.h b/Sming/Arch/Esp8266/Components/fatfs/integer.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/fatfs/integer.h rename to Sming/Arch/Esp8266/Components/fatfs/integer.h diff --git a/Sming/Platform/Esp8266/System/components/gdbstub/GdbPacket.cpp b/Sming/Arch/Esp8266/Components/gdbstub/GdbPacket.cpp similarity index 100% rename from Sming/Platform/Esp8266/System/components/gdbstub/GdbPacket.cpp rename to Sming/Arch/Esp8266/Components/gdbstub/GdbPacket.cpp diff --git a/Sming/Platform/Esp8266/System/components/gdbstub/GdbPacket.h b/Sming/Arch/Esp8266/Components/gdbstub/GdbPacket.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/gdbstub/GdbPacket.h rename to Sming/Arch/Esp8266/Components/gdbstub/GdbPacket.h diff --git a/Sming/Platform/Esp8266/System/components/gdbstub/appcode/gdb_hooks.cpp b/Sming/Arch/Esp8266/Components/gdbstub/appcode/gdb_hooks.cpp similarity index 100% rename from Sming/Platform/Esp8266/System/components/gdbstub/appcode/gdb_hooks.cpp rename to Sming/Arch/Esp8266/Components/gdbstub/appcode/gdb_hooks.cpp diff --git a/Sming/Platform/Esp8266/System/components/gdbstub/appcode/gdbstub-entry.S b/Sming/Arch/Esp8266/Components/gdbstub/appcode/gdbstub-entry.S similarity index 100% rename from Sming/Platform/Esp8266/System/components/gdbstub/appcode/gdbstub-entry.S rename to Sming/Arch/Esp8266/Components/gdbstub/appcode/gdbstub-entry.S diff --git a/Sming/Platform/Esp8266/System/components/gdbstub/exceptions.h b/Sming/Arch/Esp8266/Components/gdbstub/exceptions.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/gdbstub/exceptions.h rename to Sming/Arch/Esp8266/Components/gdbstub/exceptions.h diff --git a/Sming/Platform/Esp8266/System/components/gdbstub/gdb/registers.h b/Sming/Arch/Esp8266/Components/gdbstub/gdb/registers.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/gdbstub/gdb/registers.h rename to Sming/Arch/Esp8266/Components/gdbstub/gdb/registers.h diff --git a/Sming/Platform/Esp8266/System/components/gdbstub/gdb/signals.def b/Sming/Arch/Esp8266/Components/gdbstub/gdb/signals.def similarity index 100% rename from Sming/Platform/Esp8266/System/components/gdbstub/gdb/signals.def rename to Sming/Arch/Esp8266/Components/gdbstub/gdb/signals.def diff --git a/Sming/Platform/Esp8266/System/components/gdbstub/gdb/signals.h b/Sming/Arch/Esp8266/Components/gdbstub/gdb/signals.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/gdbstub/gdb/signals.h rename to Sming/Arch/Esp8266/Components/gdbstub/gdb/signals.h diff --git a/Sming/Platform/Esp8266/System/components/gdbstub/gdbcmds b/Sming/Arch/Esp8266/Components/gdbstub/gdbcmds similarity index 100% rename from Sming/Platform/Esp8266/System/components/gdbstub/gdbcmds rename to Sming/Arch/Esp8266/Components/gdbstub/gdbcmds diff --git a/Sming/Platform/Esp8266/System/components/gdbstub/gdbhostio.cpp b/Sming/Arch/Esp8266/Components/gdbstub/gdbhostio.cpp similarity index 100% rename from Sming/Platform/Esp8266/System/components/gdbstub/gdbhostio.cpp rename to Sming/Arch/Esp8266/Components/gdbstub/gdbhostio.cpp diff --git a/Sming/Platform/Esp8266/System/components/gdbstub/gdbhostio.h b/Sming/Arch/Esp8266/Components/gdbstub/gdbhostio.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/gdbstub/gdbhostio.h rename to Sming/Arch/Esp8266/Components/gdbstub/gdbhostio.h diff --git a/Sming/Platform/Esp8266/System/components/gdbstub/gdbstub-cfg.h b/Sming/Arch/Esp8266/Components/gdbstub/gdbstub-cfg.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/gdbstub/gdbstub-cfg.h rename to Sming/Arch/Esp8266/Components/gdbstub/gdbstub-cfg.h diff --git a/Sming/Platform/Esp8266/System/components/gdbstub/gdbstub-entry.h b/Sming/Arch/Esp8266/Components/gdbstub/gdbstub-entry.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/gdbstub/gdbstub-entry.h rename to Sming/Arch/Esp8266/Components/gdbstub/gdbstub-entry.h diff --git a/Sming/Platform/Esp8266/System/components/gdbstub/gdbstub-internal.h b/Sming/Arch/Esp8266/Components/gdbstub/gdbstub-internal.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/gdbstub/gdbstub-internal.h rename to Sming/Arch/Esp8266/Components/gdbstub/gdbstub-internal.h diff --git a/Sming/Platform/Esp8266/System/components/gdbstub/gdbstub.cpp b/Sming/Arch/Esp8266/Components/gdbstub/gdbstub.cpp similarity index 100% rename from Sming/Platform/Esp8266/System/components/gdbstub/gdbstub.cpp rename to Sming/Arch/Esp8266/Components/gdbstub/gdbstub.cpp diff --git a/Sming/Platform/Esp8266/System/components/gdbstub/gdbstub.h b/Sming/Arch/Esp8266/Components/gdbstub/gdbstub.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/gdbstub/gdbstub.h rename to Sming/Arch/Esp8266/Components/gdbstub/gdbstub.h diff --git a/Sming/Platform/Esp8266/System/components/gdbstub/gdbsyscall.cpp b/Sming/Arch/Esp8266/Components/gdbstub/gdbsyscall.cpp similarity index 100% rename from Sming/Platform/Esp8266/System/components/gdbstub/gdbsyscall.cpp rename to Sming/Arch/Esp8266/Components/gdbstub/gdbsyscall.cpp diff --git a/Sming/Platform/Esp8266/System/components/gdbstub/gdbsyscall.h b/Sming/Arch/Esp8266/Components/gdbstub/gdbsyscall.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/gdbstub/gdbsyscall.h rename to Sming/Arch/Esp8266/Components/gdbstub/gdbsyscall.h diff --git a/Sming/Platform/Esp8266/System/components/gdbstub/gdbuart.cpp b/Sming/Arch/Esp8266/Components/gdbstub/gdbuart.cpp similarity index 100% rename from Sming/Platform/Esp8266/System/components/gdbstub/gdbuart.cpp rename to Sming/Arch/Esp8266/Components/gdbstub/gdbuart.cpp diff --git a/Sming/Platform/Esp8266/System/components/gdbstub/gdbuart.h b/Sming/Arch/Esp8266/Components/gdbstub/gdbuart.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/gdbstub/gdbuart.h rename to Sming/Arch/Esp8266/Components/gdbstub/gdbuart.h diff --git a/Sming/Platform/Esp8266/System/components/gdbstub/readme.md b/Sming/Arch/Esp8266/Components/gdbstub/readme.md similarity index 100% rename from Sming/Platform/Esp8266/System/components/gdbstub/readme.md rename to Sming/Arch/Esp8266/Components/gdbstub/readme.md diff --git a/Sming/Platform/Esp8266/System/components/gdbstub/symbols/bootrom.elf b/Sming/Arch/Esp8266/Components/gdbstub/symbols/bootrom.elf similarity index 100% rename from Sming/Platform/Esp8266/System/components/gdbstub/symbols/bootrom.elf rename to Sming/Arch/Esp8266/Components/gdbstub/symbols/bootrom.elf diff --git a/Sming/Platform/Esp8266/System/components/gdbstub/xtensa/xtruntime-frames.h b/Sming/Arch/Esp8266/Components/gdbstub/xtensa/xtruntime-frames.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/gdbstub/xtensa/xtruntime-frames.h rename to Sming/Arch/Esp8266/Components/gdbstub/xtensa/xtruntime-frames.h diff --git a/Sming/Platform/Esp8266/System/components/lwip2/lwip2 b/Sming/Arch/Esp8266/Components/lwip2/lwip2 similarity index 100% rename from Sming/Platform/Esp8266/System/components/lwip2/lwip2 rename to Sming/Arch/Esp8266/Components/lwip2/lwip2 diff --git a/Sming/Platform/Esp8266/System/components/lwip2/lwip2.patch b/Sming/Arch/Esp8266/Components/lwip2/lwip2.patch similarity index 100% rename from Sming/Platform/Esp8266/System/components/lwip2/lwip2.patch rename to Sming/Arch/Esp8266/Components/lwip2/lwip2.patch diff --git a/Sming/Platform/Esp8266/System/components/pwm/new-pwm b/Sming/Arch/Esp8266/Components/pwm/new-pwm similarity index 100% rename from Sming/Platform/Esp8266/System/components/pwm/new-pwm rename to Sming/Arch/Esp8266/Components/pwm/new-pwm diff --git a/Sming/Platform/Esp8266/System/components/pwm/new-pwm.patch b/Sming/Arch/Esp8266/Components/pwm/new-pwm.patch similarity index 100% rename from Sming/Platform/Esp8266/System/components/pwm/new-pwm.patch rename to Sming/Arch/Esp8266/Components/pwm/new-pwm.patch diff --git a/Sming/Platform/Esp8266/System/components/rboot/appcode/rboot-integration.h b/Sming/Arch/Esp8266/Components/rboot/appcode/rboot-integration.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/rboot/appcode/rboot-integration.h rename to Sming/Arch/Esp8266/Components/rboot/appcode/rboot-integration.h diff --git a/Sming/Platform/Esp8266/System/components/rboot/appcode/rboot-overrides.c b/Sming/Arch/Esp8266/Components/rboot/appcode/rboot-overrides.c similarity index 100% rename from Sming/Platform/Esp8266/System/components/rboot/appcode/rboot-overrides.c rename to Sming/Arch/Esp8266/Components/rboot/appcode/rboot-overrides.c diff --git a/Sming/Platform/Esp8266/System/components/rboot/rboot b/Sming/Arch/Esp8266/Components/rboot/rboot similarity index 100% rename from Sming/Platform/Esp8266/System/components/rboot/rboot rename to Sming/Arch/Esp8266/Components/rboot/rboot diff --git a/Sming/Platform/Esp8266/System/components/rboot/rboot.patch b/Sming/Arch/Esp8266/Components/rboot/rboot.patch similarity index 100% rename from Sming/Platform/Esp8266/System/components/rboot/rboot.patch rename to Sming/Arch/Esp8266/Components/rboot/rboot.patch diff --git a/Sming/Platform/Esp8266/System/components/spiffs/spiffs_config.h b/Sming/Arch/Esp8266/Components/spiffs/spiffs_config.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/spiffs/spiffs_config.h rename to Sming/Arch/Esp8266/Components/spiffs/spiffs_config.h diff --git a/Sming/Platform/Esp8266/System/components/spiffs/spiffs_sming.c b/Sming/Arch/Esp8266/Components/spiffs/spiffs_sming.c similarity index 100% rename from Sming/Platform/Esp8266/System/components/spiffs/spiffs_sming.c rename to Sming/Arch/Esp8266/Components/spiffs/spiffs_sming.c diff --git a/Sming/Platform/Esp8266/System/components/spiffs/spiffs_sming.h b/Sming/Arch/Esp8266/Components/spiffs/spiffs_sming.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/spiffs/spiffs_sming.h rename to Sming/Arch/Esp8266/Components/spiffs/spiffs_sming.h diff --git a/Sming/Platform/Esp8266/System/components/spiffs/spiffy_host.h b/Sming/Arch/Esp8266/Components/spiffs/spiffy_host.h similarity index 100% rename from Sming/Platform/Esp8266/System/components/spiffs/spiffy_host.h rename to Sming/Arch/Esp8266/Components/spiffs/spiffy_host.h diff --git a/Sming/Platform/Esp8266/Core/Clock.cpp b/Sming/Arch/Esp8266/Core/Clock.cpp similarity index 100% rename from Sming/Platform/Esp8266/Core/Clock.cpp rename to Sming/Arch/Esp8266/Core/Clock.cpp diff --git a/Sming/Platform/Esp8266/Core/Digital.cpp b/Sming/Arch/Esp8266/Core/Digital.cpp similarity index 100% rename from Sming/Platform/Esp8266/Core/Digital.cpp rename to Sming/Arch/Esp8266/Core/Digital.cpp diff --git a/Sming/Platform/Esp8266/Core/ESP8266EX.cpp b/Sming/Arch/Esp8266/Core/ESP8266EX.cpp similarity index 100% rename from Sming/Platform/Esp8266/Core/ESP8266EX.cpp rename to Sming/Arch/Esp8266/Core/ESP8266EX.cpp diff --git a/Sming/Platform/Esp8266/Core/ESP8266EX.h b/Sming/Arch/Esp8266/Core/ESP8266EX.h similarity index 100% rename from Sming/Platform/Esp8266/Core/ESP8266EX.h rename to Sming/Arch/Esp8266/Core/ESP8266EX.h diff --git a/Sming/Platform/Esp8266/Core/HardwarePWM.cpp b/Sming/Arch/Esp8266/Core/HardwarePWM.cpp similarity index 100% rename from Sming/Platform/Esp8266/Core/HardwarePWM.cpp rename to Sming/Arch/Esp8266/Core/HardwarePWM.cpp diff --git a/Sming/Platform/Esp8266/Core/HardwareSerial.cpp b/Sming/Arch/Esp8266/Core/HardwareSerial.cpp similarity index 100% rename from Sming/Platform/Esp8266/Core/HardwareSerial.cpp rename to Sming/Arch/Esp8266/Core/HardwareSerial.cpp diff --git a/Sming/Platform/Esp8266/Core/HardwareTimer.cpp b/Sming/Arch/Esp8266/Core/HardwareTimer.cpp similarity index 100% rename from Sming/Platform/Esp8266/Core/HardwareTimer.cpp rename to Sming/Arch/Esp8266/Core/HardwareTimer.cpp diff --git a/Sming/Platform/Esp8266/Core/Interrupts.cpp b/Sming/Arch/Esp8266/Core/Interrupts.cpp similarity index 100% rename from Sming/Platform/Esp8266/Core/Interrupts.cpp rename to Sming/Arch/Esp8266/Core/Interrupts.cpp diff --git a/Sming/Platform/Esp8266/Core/Network/rBootHttpUpdate.cpp b/Sming/Arch/Esp8266/Core/Network/rBootHttpUpdate.cpp similarity index 100% rename from Sming/Platform/Esp8266/Core/Network/rBootHttpUpdate.cpp rename to Sming/Arch/Esp8266/Core/Network/rBootHttpUpdate.cpp diff --git a/Sming/Platform/Esp8266/Core/Network/rBootHttpUpdate.h b/Sming/Arch/Esp8266/Core/Network/rBootHttpUpdate.h similarity index 100% rename from Sming/Platform/Esp8266/Core/Network/rBootHttpUpdate.h rename to Sming/Arch/Esp8266/Core/Network/rBootHttpUpdate.h diff --git a/Sming/Platform/Esp8266/Core/SPI.cpp b/Sming/Arch/Esp8266/Core/SPI.cpp similarity index 100% rename from Sming/Platform/Esp8266/Core/SPI.cpp rename to Sming/Arch/Esp8266/Core/SPI.cpp diff --git a/Sming/Platform/Esp8266/Core/SPISoft.cpp b/Sming/Arch/Esp8266/Core/SPISoft.cpp similarity index 100% rename from Sming/Platform/Esp8266/Core/SPISoft.cpp rename to Sming/Arch/Esp8266/Core/SPISoft.cpp diff --git a/Sming/Platform/Esp8266/Core/core_esp8266_si2c.cpp b/Sming/Arch/Esp8266/Core/core_esp8266_si2c.cpp similarity index 100% rename from Sming/Platform/Esp8266/Core/core_esp8266_si2c.cpp rename to Sming/Arch/Esp8266/Core/core_esp8266_si2c.cpp diff --git a/Sming/Platform/Esp8266/Core/pins_arduino.h b/Sming/Arch/Esp8266/Core/pins_arduino.h similarity index 100% rename from Sming/Platform/Esp8266/Core/pins_arduino.h rename to Sming/Arch/Esp8266/Core/pins_arduino.h diff --git a/Sming/Platform/Esp8266/Platform/AccessPoint.cpp b/Sming/Arch/Esp8266/Platform/AccessPoint.cpp similarity index 100% rename from Sming/Platform/Esp8266/Platform/AccessPoint.cpp rename to Sming/Arch/Esp8266/Platform/AccessPoint.cpp diff --git a/Sming/Platform/Esp8266/Platform/RTC.cpp b/Sming/Arch/Esp8266/Platform/RTC.cpp similarity index 100% rename from Sming/Platform/Esp8266/Platform/RTC.cpp rename to Sming/Arch/Esp8266/Platform/RTC.cpp diff --git a/Sming/Platform/Esp8266/Platform/Station.cpp b/Sming/Arch/Esp8266/Platform/Station.cpp similarity index 100% rename from Sming/Platform/Esp8266/Platform/Station.cpp rename to Sming/Arch/Esp8266/Platform/Station.cpp diff --git a/Sming/Platform/Esp8266/Platform/System.cpp b/Sming/Arch/Esp8266/Platform/System.cpp similarity index 100% rename from Sming/Platform/Esp8266/Platform/System.cpp rename to Sming/Arch/Esp8266/Platform/System.cpp diff --git a/Sming/Platform/Esp8266/Platform/WDT.cpp b/Sming/Arch/Esp8266/Platform/WDT.cpp similarity index 100% rename from Sming/Platform/Esp8266/Platform/WDT.cpp rename to Sming/Arch/Esp8266/Platform/WDT.cpp diff --git a/Sming/Platform/Esp8266/Platform/WifiEvents.cpp b/Sming/Arch/Esp8266/Platform/WifiEvents.cpp similarity index 100% rename from Sming/Platform/Esp8266/Platform/WifiEvents.cpp rename to Sming/Arch/Esp8266/Platform/WifiEvents.cpp diff --git a/Sming/Platform/Esp8266/Platform/WifiSniffer.cpp b/Sming/Arch/Esp8266/Platform/WifiSniffer.cpp similarity index 100% rename from Sming/Platform/Esp8266/Platform/WifiSniffer.cpp rename to Sming/Arch/Esp8266/Platform/WifiSniffer.cpp diff --git a/Sming/Platform/Esp8266/System/include/user_config.h b/Sming/Arch/Esp8266/System/include/user_config.h similarity index 100% rename from Sming/Platform/Esp8266/System/include/user_config.h rename to Sming/Arch/Esp8266/System/include/user_config.h diff --git a/Sming/Platform/Esp8266/Tools/decode-stacktrace.py b/Sming/Arch/Esp8266/Tools/decode-stacktrace.py similarity index 100% rename from Sming/Platform/Esp8266/Tools/decode-stacktrace.py rename to Sming/Arch/Esp8266/Tools/decode-stacktrace.py diff --git a/Sming/Platform/Esp8266/Tools/esptool2 b/Sming/Arch/Esp8266/Tools/esptool2 similarity index 100% rename from Sming/Platform/Esp8266/Tools/esptool2 rename to Sming/Arch/Esp8266/Tools/esptool2 diff --git a/Sming/Platform/Esp8266/Tools/memanalyzer.py b/Sming/Arch/Esp8266/Tools/memanalyzer.py similarity index 100% rename from Sming/Platform/Esp8266/Tools/memanalyzer.py rename to Sming/Arch/Esp8266/Tools/memanalyzer.py diff --git a/Sming/Platform/Esp8266/Tools/spiffy/.gitignore b/Sming/Arch/Esp8266/Tools/spiffy/.gitignore similarity index 100% rename from Sming/Platform/Esp8266/Tools/spiffy/.gitignore rename to Sming/Arch/Esp8266/Tools/spiffy/.gitignore diff --git a/Sming/Platform/Esp8266/Tools/spiffy/Makefile b/Sming/Arch/Esp8266/Tools/spiffy/Makefile similarity index 70% rename from Sming/Platform/Esp8266/Tools/spiffy/Makefile rename to Sming/Arch/Esp8266/Tools/spiffy/Makefile index 97bbe395e0..3156015802 100644 --- a/Sming/Platform/Esp8266/Tools/spiffy/Makefile +++ b/Sming/Arch/Esp8266/Tools/spiffy/Makefile @@ -5,7 +5,7 @@ HOST_CC ?= gcc HOST_LD ?= gcc -INCDIR := -I$(SMING_HOME)/$(SPIFFS_BASE) -I$(SMING_HOME)/third-party/spiffs/src +INCDIR := -I$(SPIFFS_SMING) -I$(SPIFFS_BASE)/src CFLAGS := -O2 -Wall -Wno-unused-value ifeq ("$(V)","1") @@ -18,11 +18,7 @@ endif all: spiffy -%.o: $(SPIFFS_BASE)/%.c - $(vecho) "CC $<" - $(Q) $(HOST_CC) $(CFLAGS) $(INCDIR) -c $< -o $@ - -%.o: $(SMING_HOME)/third-party/spiffs/src/%.c +%.o: $(SPIFFS_BASE)/src/%.c $(vecho) "CC $<" $(Q) $(HOST_CC) $(CFLAGS) $(INCDIR) -c $< -o $@ diff --git a/Sming/Platform/Esp8266/Tools/spiffy/spiffy.c b/Sming/Arch/Esp8266/Tools/spiffy/spiffy.c similarity index 100% rename from Sming/Platform/Esp8266/Tools/spiffy/spiffy.c rename to Sming/Arch/Esp8266/Tools/spiffy/spiffy.c diff --git a/Sming/Platform/Esp8266/app.mk b/Sming/Arch/Esp8266/app.mk similarity index 82% rename from Sming/Platform/Esp8266/app.mk rename to Sming/Arch/Esp8266/app.mk index c40de6d312..c1ef6cd392 100644 --- a/Sming/Platform/Esp8266/app.mk +++ b/Sming/Arch/Esp8266/app.mk @@ -1,6 +1,6 @@ ### # -# SMING Application Makefile for ESP8266 platform +# SMING Application Makefile for ESP8266 architecture # ### @@ -59,9 +59,9 @@ RBOOT_ROM_1 := $(FW_BASE)/$(RBOOT_ROM_1).bin # Code compiled with application APPCODE := -EXTRA_INCDIR += $(PLATFORM_COMPONENTS) \ - $(PLATFORM_COMPONENTS)/esp8266/include \ - $(PLATFORM_COMPONENTS)/driver/include +EXTRA_INCDIR += $(ARCH_COMPONENTS) \ + $(ARCH_COMPONENTS)/esp8266/include \ + $(ARCH_COMPONENTS)/driver/include # Macro to make an optional library # $1 -> The library to make @@ -71,7 +71,7 @@ define MakeLibrary endef # => rBoot -RBOOT_BASE := $(PLATFORM_COMPONENTS)/rboot +RBOOT_BASE := $(ARCH_COMPONENTS)/rboot APPCODE += $(RBOOT_BASE)/appcode $(RBOOT_BASE)/rboot/appcode EXTRA_INCDIR += $(RBOOT_BASE)/rboot RBOOT_BIN := $(FW_BASE)/rboot.bin @@ -110,14 +110,14 @@ ifeq ($(RBOOT_GPIO_SKIP_ENABLED),1) CFLAGS += -DBOOT_GPIO_SKIP_ENABLED endif $(RBOOT_BIN): - $(MAKE) -C $(PLATFORM_COMPONENTS)/rboot/rboot + $(MAKE) -C $(ARCH_COMPONENTS)/rboot/rboot # => SPIFFS DISABLE_SPIFFS ?= 0 SPIFF_BIN_OUT ?= spiff_rom SPIFF_BIN_OUT := $(FW_BASE)/$(SPIFF_BIN_OUT).bin -EXTRA_INCDIR += $(PLATFORM_COMPONENTS)/spiffs $(THIRD_PARTY_DIR)/spiffs/src +EXTRA_INCDIR += $(ARCH_COMPONENTS)/spiffs $(COMPONENTS)/spiffs/src CFLAGS += -DRBOOT_SPIFFS_0=$(RBOOT_SPIFFS_0) CFLAGS += -DRBOOT_SPIFFS_1=$(RBOOT_SPIFFS_1) CUSTOM_TARGETS += $(SPIFF_BIN_OUT) @@ -126,11 +126,12 @@ CUSTOM_TARGETS += $(SPIFF_BIN_OUT) ENABLE_CUSTOM_LWIP ?= 1 ifeq ($(ENABLE_CUSTOM_LWIP), 0) LIBLWIP := lwip - LWIP_BASE := $(PLATFORM_COMPONENTS)/esp-lwip + LWIP_BASE := $(ARCH_COMPONENTS)/esp-lwip EXTRA_INCDIR += $(LWIP_BASE)/include $(LWIP_BASE) else ifeq ($(ENABLE_CUSTOM_LWIP), 1) LIBLWIP := lwip_open - EXTRA_INCDIR += $(PLATFORM_COMPONENTS)/esp-open-lwip/esp-open-lwip/include + LWIP_BASE := $(ARCH_COMPONENTS)/esp-open-lwip/esp-open-lwip + EXTRA_INCDIR += $(LWIP_BASE)/include ifeq ($(ENABLE_ESPCONN), 1) LIBLWIP := lwip_full endif @@ -139,15 +140,15 @@ else ifeq ($(ENABLE_CUSTOM_LWIP), 2) $(error LWIP2 does not support espconn_* functions. Make sure to set ENABLE_CUSTOM_LWIP to 0 or 1.) endif LIBLWIP := lwip2 - LWIP2_BASE := $(PLATFORM_COMPONENTS)/lwip2/lwip2 - EXTRA_INCDIR += $(LWIP2_BASE)/glue-esp/include-esp $(LWIP2_BASE)/include + LWIP_BASE := $(ARCH_COMPONENTS)/lwip2/lwip2 + EXTRA_INCDIR += $(LWIP_BASE)/glue-esp/include-esp $(LWIP_BASE)/include else - EXTRA_INCDIR += $(PLATFORM_COMPONENTS)/esp-lwip/lwip/include + EXTRA_INCDIR += $(ARCH_COMPONENTS)/esp-lwip/lwip/include endif LIBS += $(LIBLWIP) ifneq ($(ENABLE_CUSTOM_LWIP), 0) - LIBLWIP_DST := $(USER_LIBDIR)/lib$(LIBLWIP).a + LIBLWIP_DST := $(call UserLibPath,$(LIBLWIP)) CUSTOM_TARGETS += $(LIBLWIP_DST) $(LIBLWIP_DST): @@ -155,10 +156,10 @@ $(LIBLWIP_DST): endif # => GDB -APPCODE += $(PLATFORM_COMPONENTS)/gdbstub/appcode -EXTRA_INCDIR += $(PLATFORM_COMPONENTS)/gdbstub/include +APPCODE += $(ARCH_COMPONENTS)/gdbstub/appcode +EXTRA_INCDIR += $(ARCH_COMPONENTS)/gdbstub/include ifeq ($(ENABLE_GDB), 1) - APPCODE += $(PLATFORM_COMPONENTS)/gdbstub + APPCODE += $(ARCH_COMPONENTS)/gdbstub CUSTOM_TARGETS += gdb_symbols # Copy symbols required by GDB into build directory @@ -166,11 +167,11 @@ ifeq ($(ENABLE_GDB), 1) gdb_symbols: $(BUILD_BASE)/bootrom.elf $(BUILD_BASE)/%.elf: - $(Q) cp $(PLATFORM_COMPONENTS)/gdbstub/symbols/$(notdir $@) $@ + $(Q) cp $(ARCH_COMPONENTS)/gdbstub/symbols/$(notdir $@) $@ endif # Full GDB command line -GDB := trap '' INT; $(GDB) -x $(PLATFORM_COMPONENTS)/gdbstub/gdbcmds -b $(COM_SPEED_SERIAL) -ex "target remote $(COM_PORT)" +GDB := trap '' INT; $(GDB) -x $(ARCH_COMPONENTS)/gdbstub/gdbcmds -b $(COM_SPEED_SERIAL) -ex "target remote $(COM_PORT)" # => WPS @@ -179,12 +180,6 @@ ifeq ($(ENABLE_WPS),1) LIBS += wps endif -# => MQTT -# Flags for compatability with old versions (most of them should disappear with the next major release) -ifeq ($(MQTT_NO_COMPAT),1) - CFLAGS += -DMQTT_NO_COMPAT=1 -endif - # => Custom heap ENABLE_CUSTOM_HEAP ?= 0 ifeq ($(ENABLE_CUSTOM_HEAP),1) @@ -220,7 +215,7 @@ ifeq ($(ENABLE_SSL),1) LIBAXTLS := axtls LIBS += $(LIBAXTLS) LIBAXTLS_DST := $(call UserLibPath,$(LIBAXTLS)) - AXTLS_BASE := $(PLATFORM_COMPONENTS)/axtls-8266/axtls-8266 + AXTLS_BASE := $(ARCH_COMPONENTS)/axtls-8266/axtls-8266 EXTRA_INCDIR += $(AXTLS_BASE)/.. $(AXTLS_BASE) $(AXTLS_BASE)/ssl $(AXTLS_BASE)/crypto AXTLS_FLAGS := -DLWIP_RAW=1 -DENABLE_SSL=1 ifeq ($(SSL_DEBUG),1) # @@ -236,7 +231,7 @@ $(LIBAXTLS_DST): include/ssl/private_key.h: $(vecho) "Generating unique certificate and key. This may take some time" $(Q) mkdir -p $(CURRENT_DIR)/include/ssl/ - AXDIR=$(CURRENT_DIR)/include/ssl/ $(PLATFORM_COMPONENTS)/axtls-8266/axtls-8266/tools/make_certs.sh + AXDIR=$(CURRENT_DIR)/include/ssl/ $(ARCH_COMPONENTS)/axtls-8266/axtls-8266/tools/make_certs.sh endif @@ -255,6 +250,7 @@ endif LIBS += $(LIBPWM) +# LIBS := microc microgcc hal phy pp net80211 mqttc wpa $(LIBSMING) crypto smartconfig $(EXTRA_LIBS) $(LIBS) LIBS := $(addprefix -l,$(LIBS)) @@ -263,7 +259,7 @@ LIBS := $(addprefix -l,$(LIBS)) LDFLAGS = -nostdlib -u call_user_start -u Cache_Read_Enable_New -u spiffs_get_storage_config -u custom_crash_callback \ -Wl,-static -Wl,--gc-sections -Wl,-Map=$(basename $@).map -Wl,-wrap,system_restart_local -include $(PLATFORM_BASE)/flash.mk +include $(ARCH_BASE)/flash.mk TARGET_OUT_0 := $(BUILD_BASE)/$(TARGET)_0.out TARGET_OUT_1 := $(BUILD_BASE)/$(TARGET)_1.out @@ -294,7 +290,7 @@ $(RBOOT_ROM_1): $(TARGET_OUT_1) $(TARGET_OUT_0): $(APP_AR) $(vecho) "LD $@" - $(LD) -L$(USER_LIBDIR) -L$(SDK_LIBDIR) -L$(BUILD_BASE) -L$(PLATFORM_BASE)/Compiler/ld \ + $(LD) -L$(USER_LIBDIR) -L$(SDK_LIBDIR) -L$(BUILD_BASE) -L$(ARCH_BASE)/Compiler/ld \ -T$(RBOOT_LD_0) $(LDFLAGS) -Wl,--start-group $(APP_AR) $(LIBS) -Wl,--end-group -o $@ $(Q) $(MEMANALYZER) $@ > $(FW_MEMINFO_NEW) @@ -318,7 +314,7 @@ $(TARGET_OUT_0): $(APP_AR) $(TARGET_OUT_1): $(APP_AR) $(vecho) "LD $@" - $(LD) -L$(USER_LIBDIR) -L$(SDK_LIBDIR) -L$(BUILD_BASE) -L$(PLATFORM_BASE)/Compiler/ld \ + $(LD) -L$(USER_LIBDIR) -L$(SDK_LIBDIR) -L$(BUILD_BASE) -L$(ARCH_BASE)/Compiler/ld \ -T$(RBOOT_LD_1) $(LDFLAGS) -Wl,--start-group $(APP_AR) $(LIBS) -Wl,--end-group -o $@ # recreate it from 0, since you get into problems with same filenames @@ -327,9 +323,10 @@ $(APP_AR): $(OBJ) $(Q) test ! -f $@ || rm $@ $(AR) rcsP $@ $^ +# .PHONY: libsming -libsming: $(USER_LIBDIR)/lib$(LIBSMING).a -$(USER_LIBDIR)/lib$(LIBSMING).a: +libsming: $(LIBSMING_DST) +$(LIBSMING_DST): $(vecho) "(Re)compiling Sming. Enabled features: $(SMING_FEATURES). This may take some time" $(Q) $(MAKE) -C $(SMING_HOME) clean V=$(V) ENABLE_SSL=$(ENABLE_SSL) $(Q) $(MAKE) -C $(SMING_HOME) V=$(V) ENABLE_SSL=$(ENABLE_SSL) @@ -412,7 +409,7 @@ gdb: kill_term FLASH_INIT_CHUNKS := $(INIT_BIN_ADDR) $(SDK_BASE)/bin/esp_init_data_default.bin FLASH_INIT_CHUNKS += $(BLANK_BIN_ADDR) $(SDK_BASE)/bin/blank.bin ifneq ($(DISABLE_SPIFFS), 1) - FLASH_INIT_CHUNKS += $(RBOOT_SPIFFS_0) $(PLATFORM_BASE)/Compiler/data/blankfs.bin + FLASH_INIT_CHUNKS += $(RBOOT_SPIFFS_0) $(ARCH_BASE)/Compiler/data/blankfs.bin endif flashinit: $(vecho) "Flash init data default and blank data." diff --git a/Sming/Platform/Esp8266/build.mk b/Sming/Arch/Esp8266/build.mk similarity index 71% rename from Sming/Platform/Esp8266/build.mk rename to Sming/Arch/Esp8266/build.mk index e9d623c544..257f2db1a9 100644 --- a/Sming/Platform/Esp8266/build.mk +++ b/Sming/Arch/Esp8266/build.mk @@ -1,6 +1,6 @@ ############## # -# Platform build environment +# Esp8266 Architecture build environment # ############## @@ -51,9 +51,13 @@ else CFLAGS += -DPROGMEM_L32="" endif -# => SDK -ifneq (,$(findstring $(THIRD_PARTY_DIR)/ESP8266_NONOS_SDK, $(SDK_BASE))) - CFLAGS += -DSDK_INTERNAL +# => 'Internal' SDK - for SDK Version 3+ as submodule in Sming repository +# SDK_BASE just needs to point into our repo as it's overridden with the correct submodule path +# This provides backward-compatiblity, so $(SMING)/third-party/ESP8266_NONOS_SDK) still works +ifneq (,$(findstring $(abspath $(SMING_HOME)),$(abspath $(SDK_BASE)))) + SDK_COMPONENT := $(ARCH_COMPONENTS)/Sdk/ESP8266_NONOS_SDK + SDK_BASE := $(SMING_HOME)/$(SDK_COMPONENT) + CFLAGS += -DSDK_INTERNAL SDK_INTERNAL = 1 else SDK_INTERNAL = 0 @@ -63,8 +67,7 @@ endif SDK_LIBDIR := $(SDK_BASE)/lib SDK_INCDIR := $(SDK_BASE)/include - # => Tools -ESPTOOL2 = $(PLATFORM_TOOLS)/esptool2/esptool2$(TOOL_EXT) -SPIFFY = $(PLATFORM_TOOLS)/spiffy/spiffy$(TOOL_EXT) +ESPTOOL2 = $(ARCH_TOOLS)/esptool2/esptool2$(TOOL_EXT) +SPIFFY = $(ARCH_TOOLS)/spiffy/spiffy$(TOOL_EXT) diff --git a/Sming/Platform/Esp8266/flash.mk b/Sming/Arch/Esp8266/flash.mk similarity index 100% rename from Sming/Platform/Esp8266/flash.mk rename to Sming/Arch/Esp8266/flash.mk diff --git a/Sming/Platform/Esp8266/sming.mk b/Sming/Arch/Esp8266/sming.mk similarity index 70% rename from Sming/Platform/Esp8266/sming.mk rename to Sming/Arch/Esp8266/sming.mk index 2a399099ca..3c04565ca3 100644 --- a/Sming/Platform/Esp8266/sming.mk +++ b/Sming/Arch/Esp8266/sming.mk @@ -1,39 +1,40 @@ # ESP8266 Sming framework # => SDK -SDK_INTERNAL = 0 -ifneq (,$(findstring $(THIRD_PARTY_DIR)/ESP8266_NONOS_SDK, $(SDK_BASE))) - SUBMODULES += $(SDK_BASE) - CFLAGS += -DSDK_INTERNAL - SDK_INTERNAL = 1 +ifeq ($(SDK_INTERNAL), 1) + SUBMODULES += $(SDK_COMPONENT) + CUSTOM_TARGETS += $(SDK_COMPONENT)/bin/esp_init_data_default.bin + +$(SDK_COMPONENT)/bin/esp_init_data_default.bin: + $(Q) cp -f $(dir $@)esp_init_data_default_v08.bin $@ endif -EXTRA_INCDIR += $(PLATFORM_COMPONENTS) +EXTRA_INCDIR += $(ARCH_COMPONENTS) -MODULES += $(PLATFORM_COMPONENTS)/esp8266 -EXTRA_INCDIR += $(PLATFORM_COMPONENTS)/esp8266/include $(PLATFORM_COMPONENTS)/driver/include +MODULES += $(ARCH_COMPONENTS)/esp8266 +EXTRA_INCDIR += $(ARCH_COMPONENTS)/esp8266/include -MODULES += $(PLATFORM_COMPONENTS)/driver -EXTRA_INCDIR += $(PLATFORM_COMPONENTS)/driver/include +MODULES += $(ARCH_COMPONENTS)/driver +EXTRA_INCDIR += $(ARCH_COMPONENTS)/driver/include -MODULES += $(PLATFORM_COMPONENTS)/fatfs +MODULES += $(ARCH_COMPONENTS)/fatfs # => rboot -RBOOT_BASE := $(PLATFORM_COMPONENTS)/rboot/rboot +RBOOT_BASE := $(ARCH_COMPONENTS)/rboot/rboot SUBMODULES += $(RBOOT_BASE) EXTRA_INCDIR += $(RBOOT_BASE) $(RBOOT_BASE)/appcode # => SPIFFS -SPIFFS_BASE := $(PLATFORM_COMPONENTS)/spiffs -SUBMODULES += $(THIRD_PARTY_DIR)/spiffs -MODULES += $(SPIFFS_BASE) $(THIRD_PARTY_DIR)/spiffs/src -EXTRA_INCDIR += $(SPIFFS_BASE) $(SPIFFS_BASE)/spiffs/src +SPIFFS_SMING := $(ARCH_COMPONENTS)/spiffs +SPIFFS_BASE := $(COMPONENTS)/spiffs +SUBMODULES += $(SPIFFS_BASE) +MODULES += $(SPIFFS_SMING) $(SPIFFS_BASE)/src # => ESP8266_new_pwm ENABLE_CUSTOM_PWM ?= 1 ifeq ($(ENABLE_CUSTOM_PWM), 1) - PWM_BASE := $(PLATFORM_COMPONENTS)/pwm + PWM_BASE := $(ARCH_COMPONENTS)/pwm SUBMODULES += $(PWM_BASE)/new-pwm CFLAGS += -DSDK_PWM_PERIOD_COMPAT_MODE=1 LIBPWM := pwm_open @@ -53,7 +54,7 @@ endif # => umm_malloc (custom heap allocation) ENABLE_CUSTOM_HEAP ?= 0 ifeq ($(ENABLE_CUSTOM_HEAP), 1) - CUSTOM_HEAP_BASE := $(PLATFORM_COMPONENTS)/custom_heap + CUSTOM_HEAP_BASE := $(ARCH_COMPONENTS)/custom_heap UMM_MALLOC_BASE := $(CUSTOM_HEAP_BASE)/umm_malloc SUBMODULES += $(UMM_MALLOC_BASE) MODULES += $(CUSTOM_HEAP_BASE) $(UMM_MALLOC_BASE)/src @@ -74,17 +75,17 @@ ENABLE_CUSTOM_LWIP ?= 1 ENABLE_ESPCONN ?= 0 ifeq ($(ENABLE_CUSTOM_LWIP), 0) LIBLWIP := lwip - LWIP_BASE := $(PLATFORM_COMPONENTS)/esp-lwip + LWIP_BASE := $(ARCH_COMPONENTS)/esp-lwip EXTRA_INCDIR += $(LWIP_BASE)/include $(LWIP_BASE) else - EXTRA_CFLAGS_LWIP := -I$(SMING_HOME)/System/include -I$(PLATFORM_SYS)/include -I$(PLATFORM_COMPONENTS)/esp8266/include -I$(SMING_HOME)/Wiring + EXTRA_CFLAGS_LWIP := -I$(SMING_HOME)/System/include -I$(ARCH_SYS)/include -I$(ARCH_COMPONENTS)/esp8266/include -I$(SMING_HOME)/Wiring ENABLE_LWIPDEBUG ?= 0 ifeq ($(ENABLE_LWIPDEBUG), 1) EXTRA_CFLAGS_LWIP += -DLWIP_DEBUG endif ifeq ($(ENABLE_CUSTOM_LWIP), 1) - LWIP_BASE := $(PLATFORM_COMPONENTS)/esp-open-lwip/esp-open-lwip + LWIP_BASE := $(ARCH_COMPONENTS)/esp-open-lwip/esp-open-lwip SUBMODULES += $(LWIP_BASE) EXTRA_INCDIR += $(LWIP_BASE)/include ifeq ($(ENABLE_ESPCONN), 1) @@ -98,7 +99,7 @@ else ifeq ($(ENABLE_ESPCONN), 1) $(error LWIP2 does not support espconn_* functions. Make sure to set ENABLE_CUSTOM_LWIP to 0 or 1.) endif - LWIP_BASE := $(PLATFORM_COMPONENTS)/lwip2/lwip2 + LWIP_BASE := $(ARCH_COMPONENTS)/lwip2/lwip2 SUBMODULES += $(LWIP_BASE) EXTRA_INCDIR += $(LWIP_BASE)/glue-esp/include-esp $(LWIP_BASE)/include LIBLWIP ?= lwip2 @@ -122,7 +123,7 @@ endif # => SSL support using axTLS ENABLE_SSL ?= 0 ifeq ($(ENABLE_SSL),1) - AXTLS_BASE := $(PLATFORM_COMPONENTS)/axtls-8266/axtls-8266 + AXTLS_BASE := $(ARCH_COMPONENTS)/axtls-8266/axtls-8266 SUBMODULES += $(AXTLS_BASE) LIBAXTLS := axtls LIBS += $(LIBAXTLS) @@ -146,7 +147,7 @@ endif # => GDB -EXTRA_INCDIR += $(PLATFORM_COMPONENTS)/gdbstub/include +EXTRA_INCDIR += $(ARCH_COMPONENTS)/gdbstub/include # Tools @@ -159,8 +160,8 @@ endef TOOLS += $(SPIFFY) TOOLS_CLEAN += spiffy-clean -$(SPIFFY): $(THIRD_PARTY_DIR)/spiffs/.submodule - $(Q) $(call make-tool,$@,SPIFFS_BASE=$(SPIFFS_BASE)) +$(SPIFFY): $(COMPONENTS)/spiffs/.submodule + $(Q) $(call make-tool,$@,SPIFFS_SMING=$(SMING_HOME)/$(SPIFFS_SMING) SPIFFS_BASE=$(SMING_HOME)/$(SPIFFS_BASE)) .PHONY: spiffy-clean spiffy-clean: @@ -170,7 +171,8 @@ spiffy-clean: TOOLS += $(ESPTOOL2) TOOLS_CLEAN += esptool2-clean -$(ESPTOOL2): $(dir $(ESPTOOL2)).submodule +SUBMODULES += $(dir $(ESPTOOL2)) +$(ESPTOOL2): $(Q) $(call make-tool,$@) .PHONY: esptool2-clean diff --git a/Sming/third-party/.patches/Readme.md b/Sming/Components/.patches/Readme.md similarity index 100% rename from Sming/third-party/.patches/Readme.md rename to Sming/Components/.patches/Readme.md diff --git a/Sming/third-party/.patches/http-parser.patch b/Sming/Components/.patches/http-parser.patch similarity index 100% rename from Sming/third-party/.patches/http-parser.patch rename to Sming/Components/.patches/http-parser.patch diff --git a/Sming/third-party/.patches/mqtt-codec.patch b/Sming/Components/.patches/mqtt-codec.patch similarity index 100% rename from Sming/third-party/.patches/mqtt-codec.patch rename to Sming/Components/.patches/mqtt-codec.patch diff --git a/Sming/third-party/.patches/ws_parser.patch b/Sming/Components/.patches/ws_parser.patch similarity index 100% rename from Sming/third-party/.patches/ws_parser.patch rename to Sming/Components/.patches/ws_parser.patch diff --git a/Sming/third-party/http-parser b/Sming/Components/http-parser similarity index 100% rename from Sming/third-party/http-parser rename to Sming/Components/http-parser diff --git a/Sming/third-party/libyuarel b/Sming/Components/libyuarel similarity index 100% rename from Sming/third-party/libyuarel rename to Sming/Components/libyuarel diff --git a/Sming/third-party/mqtt-codec b/Sming/Components/mqtt-codec similarity index 100% rename from Sming/third-party/mqtt-codec rename to Sming/Components/mqtt-codec diff --git a/Sming/third-party/spiffs b/Sming/Components/spiffs similarity index 100% rename from Sming/third-party/spiffs rename to Sming/Components/spiffs diff --git a/Sming/third-party/ws_parser b/Sming/Components/ws_parser similarity index 100% rename from Sming/third-party/ws_parser rename to Sming/Components/ws_parser diff --git a/Sming/Makefile b/Sming/Makefile index c997a27505..d6a5081630 100644 --- a/Sming/Makefile +++ b/Sming/Makefile @@ -3,6 +3,7 @@ # Created by Espressif # UDK modifications by CHERTS # Cross platform compatability by kireevco +# Multi-architecture support by mikee47 # ############################################################# @@ -24,22 +25,13 @@ all: checkdirs libsming tools include $(SMING_HOME)/build.mk -BUILD_BASE := $(PLATFORM_BASE)/out/build +BUILD_BASE := $(ARCH_BASE)/out/build RELOAD_MKFILE = 0 -LIBSMING := libsming -ifeq ($(ENABLE_SSL),1) - LIBSMING := libsmingssl -endif - # name for the target project TARGET = app -# If specified, restrict importing and building to a specific list of libraries -ARDUINO_LIBRARIES ?= $(patsubst Libraries/%,%,$(wildcard Libraries/*/)) -ARDUINO_LIBRARIES := $(ARDUINO_LIBRARIES:/=) - # List of directories containing source code to build MODULES := @@ -53,29 +45,24 @@ EXTRA_INCDIR := SAMPLES_DIRS := $(shell ls -1 ../samples) DOXYGEN := $(shell command -v doxygen 2> /dev/null) -# Flags for compatability with old versions (most of them should disappear with the next major release) -ifeq ($(MQTT_NO_COMPAT),1) - CFLAGS += -DMQTT_NO_COMPAT=1 -endif - ifeq ($(ENABLE_WPS), 1) CFLAGS += -DENABLE_WPS=1 endif # => http-parser -SUBMODULES += $(THIRD_PARTY_DIR)/http-parser -MODULES += $(THIRD_PARTY_DIR)/http-parser +SUBMODULES += $(COMPONENTS)/http-parser +MODULES += $(COMPONENTS)/http-parser # => websocket-parser -SUBMODULES += $(THIRD_PARTY_DIR)/ws_parser -MODULES += $(THIRD_PARTY_DIR)/ws_parser +SUBMODULES += $(COMPONENTS)/ws_parser +MODULES += $(COMPONENTS)/ws_parser # => mqtt-codec -SUBMODULES += $(THIRD_PARTY_DIR)/mqtt-codec -EXTRA_INCDIR += $(THIRD_PARTY_DIR)/mqtt-codec/src +SUBMODULES += $(COMPONENTS)/mqtt-codec +EXTRA_INCDIR += $(COMPONENTS)/mqtt-codec/src LIBMQTTC := mqttc LIBS += $(LIBMQTTC) -BUILD_MQTTC := $(MAKE) -C $(THIRD_PARTY_DIR)/mqtt-codec MQTT_ENABLE_SERVER=0 MQTT_ENABLE_CLIENT=1 CC=$(CC) AR=$(AR) \ +BUILD_MQTTC := $(MAKE) -C $(COMPONENTS)/mqtt-codec MQTT_ENABLE_SERVER=0 MQTT_ENABLE_CLIENT=1 CC=$(CC) AR=$(AR) \ CFLAGS_EXTRA="-ISystem/include $(CFLAGS_COMMON)" \ LIB_FOLDER="$(SMING_HOME)/$(USER_LIBDIR)" CLEAN += mqttc-clean @@ -89,10 +76,10 @@ mqttc-clean: # => yuarel -SUBMODULES += $(THIRD_PARTY_DIR)/libyuarel -MODULES += $(THIRD_PARTY_DIR)/libyuarel +SUBMODULES += $(COMPONENTS)/libyuarel +MODULES += $(COMPONENTS)/libyuarel -include $(PLATFORM_BASE)/sming.mk +include $(ARCH_BASE)/sming.mk # Get list of subdirectory paths # $1 -> Root directory @@ -100,24 +87,28 @@ define ScanModuleDirs $(sort $(dir $(wildcard $1/*/ $1/*/*/ $1/*/*/*/))) endef +# If specified, restrict importing and building to a specific list of libraries +ARDUINO_LIBRARIES ?= $(patsubst Libraries/%,%,$(wildcard Libraries/*/)) +ARDUINO_LIBRARIES := $(ARDUINO_LIBRARIES:/=) + # Identify which libraries have submodules -LIBRARY_SUBMODULES := $(shell git submodule status Libraries | cut -c2- | cut -f2 -d ' ') +LIBRARY_SUBMODULES := $(call ListSubmodules,Libraries) LIBRARY_SUBMODULES := $(patsubst Libraries/%,%,$(LIBRARY_SUBMODULES)) LIBRARY_SUBMODULES := $(filter $(LIBRARY_SUBMODULES), $(ARDUINO_LIBRARIES)) -# List of .submodule targets for any third-party Arduino libraries +# List of any Arduino library .submodule targets LIBRARY_SUBMODULES := $(foreach lib,$(LIBRARY_SUBMODULES),Libraries/$(lib)/.submodule) # which modules (subdirectories) to include in compiling -SMING_MODULES := $(PLATFORM_CORE) $(PLATFORM_BASE)/Platform Platform/Common SmingCore +SMING_MODULES := $(ARCH_CORE) $(ARCH_BASE)/Platform Platform SmingCore SMING_MODULES := $(foreach mod,$(SMING_MODULES),$(call ScanModuleDirs,$(mod))) -MODULES := System $(PLATFORM_SYS) Wiring $(SMING_MODULES) $(MODULES) +MODULES := System $(ARCH_SYS) Wiring $(SMING_MODULES) $(MODULES) MODULES += $(wildcard Services/*/) MODULES += $(foreach lib,$(ARDUINO_LIBRARIES),Libraries/$(lib) Libraries/$(lib)/src) MODULES := $(MODULES:/=) -EXTRA_INCDIR := System/include Wiring Libraries SmingCore Platform/Common \ - $(PLATFORM_BASE) $(PLATFORM_SYS)/include $(PLATFORM_CORE) \ - $(THIRD_PARTY_DIR) . $(EXTRA_INCDIR) +EXTRA_INCDIR := System/include Wiring Libraries SmingCore \ + $(ARCH_BASE) $(ARCH_SYS)/include \ + $(COMPONENTS) . $(EXTRA_INCDIR) include $(SMING_HOME)/modules.mk @@ -132,21 +123,20 @@ endef $(foreach lib,$(LIBS),$(eval $(call UserLibrary,$(lib)))) -# Target library (libsming) - +# Main Sming library .PHONY: libsming libsming: $(APP_AR) $(CUSTOM_TARGETS) $(APP_AR): $(OBJ) $(vecho) "AR $@" $(AR) cru $@ $^ - $(vecho) "Installing $(LIBSMING)" + $(vecho) "Installing '$(LIBSMING)' library" ifeq ($(ENABLE_SSL), 1) $(vecho) "+ SSL support is enabled" else $(vecho) "(!) SSL support is not enabled. To enable it type: 'make clean; make ENABLE_SSL=1'" endif - $(Q) cp -r $(APP_AR) $(USER_LIBDIR)/$(LIBSMING).a + $(Q) cp -r $(APP_AR) $(LIBSMING_DST) $(vecho) "Done" .PHONY: checkdirs @@ -224,7 +214,7 @@ submodules: $(LIBRARY_SUBMODULES) $(addsuffix /.submodule,$(SUBMODULES)) submodules-clean: -$(Q) rm -rf $(SUBMODULES) - $(GIT) checkout third-party + $(GIT) checkout Components -$(Q) rm -rf Libraries -$(Q) rm -rf $(BUILD_BASE)/Libraries -$(Q) mkdir -p Libraries @@ -272,7 +262,7 @@ tools-clean: $(TOOLS_CLEAN) rwildcard = $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d)) # Files that should follow our coding standards -CS_DIRS := SmingCore Platform/*/Core Platform/*/Platform ../samples +CS_DIRS := SmingCore Arch/*/Core Arch/*/Platform ../samples CS_FILES := $(call rwildcard,$(patsubst %,%/*,$(CS_DIRS)),*.cpp *.h *.c) .PHONY: cs diff --git a/Sming/Makefile-app.mk b/Sming/Makefile-app.mk index 1f52225142..90d2dae2bb 100644 --- a/Sming/Makefile-app.mk +++ b/Sming/Makefile-app.mk @@ -22,8 +22,8 @@ COM_SPEED_SERIAL ?= $(COM_SPEED) include $(SMING_HOME)/build.mk -PLATFORM_BASE := $(SMING_HOME)/$(PLATFORM_BASE) -THIRD_PARTY_DIR := $(SMING_HOME)/$(THIRD_PARTY_DIR) +ARCH_BASE := $(SMING_HOME)/$(ARCH_BASE) +COMPONENTS := $(SMING_HOME)/$(COMPONENTS) BUILD_BASE := out/build FW_BASE := out/firmware @@ -40,24 +40,16 @@ FW_MEMINFO_SAVED = out/fwMeminfo # name for the target project TARGET = app -LIBSMING = sming -SMING_FEATURES = none -ifeq ($(ENABLE_SSL),1) - LIBSMING = smingssl - SMING_FEATURES = SSL -endif - # which modules (subdirectories) of the project to include in compiling # define your custom directories in the project's own Makefile before including this one MODULES ?= app # default to app if not set by user EXTRA_INCDIR ?= include # default to include if not set by user -SMING_INCDIR := System/include Wiring Libraries SmingCore Platform/Common \ +SMING_INCDIR := System/include Wiring Libraries SmingCore Platform \ Libraries/Adafruit_GFX Libraries/Adafruit_Sensor EXTRA_INCDIR += $(SMING_HOME) $(addprefix $(SMING_HOME)/,$(SMING_INCDIR)) \ - $(PLATFORM_BASE) $(PLATFORM_SYS)/include $(PLATFORM_CORE) \ - $(THIRD_PARTY_DIR) + $(ARCH_BASE) $(ARCH_SYS)/include $(ARCH_CORE) $(COMPONENTS) # we will use global WiFi settings from Eclipse Environment Variables, if possible WIFI_SSID ?= "" @@ -75,5 +67,5 @@ endif # => Serial CFLAGS += -DCOM_SPEED_SERIAL=$(COM_SPEED_SERIAL) $(USER_CFLAGS) -include $(PLATFORM_BASE)/app.mk +include $(ARCH_BASE)/app.mk diff --git a/Sming/Makefile-bsd.mk b/Sming/Makefile-bsd.mk index ad5be5f834..8414f88921 100644 --- a/Sming/Makefile-bsd.mk +++ b/Sming/Makefile-bsd.mk @@ -13,4 +13,4 @@ ESPTOOL ?= $(ESP_HOME)/esptool/esptool.py KILL_TERM ?= pkill -9 -f "$(COM_PORT) $(COM_SPEED_SERIAL)" || exit 0 GET_FILESIZE ?= stat -f "%-15z" TERMINAL ?= python -m serial.tools.miniterm $(COM_PORT) $(COM_SPEED_SERIAL) $(COM_OPTS) -MEMANALYZER ?= python $(PLATFORM_TOOLS)/memanalyzer.py $(OBJDUMP) \ No newline at end of file +MEMANALYZER ?= python $(ARCH_TOOLS)/memanalyzer.py $(OBJDUMP) \ No newline at end of file diff --git a/Sming/Makefile-linux.mk b/Sming/Makefile-linux.mk index 7177c820a4..c89dc47927 100644 --- a/Sming/Makefile-linux.mk +++ b/Sming/Makefile-linux.mk @@ -13,4 +13,4 @@ ESPTOOL ?= $(ESP_HOME)/esptool/esptool.py KILL_TERM ?= pkill -9 -f "$(COM_PORT) $(COM_SPEED_SERIAL)" || exit 0 GET_FILESIZE ?= stat -c %s TERMINAL ?= python -m serial.tools.miniterm $(COM_PORT) $(COM_SPEED_SERIAL) $(COM_OPTS) -MEMANALYZER ?= python $(PLATFORM_TOOLS)/memanalyzer.py $(OBJDUMP) \ No newline at end of file +MEMANALYZER ?= python $(ARCH_TOOLS)/memanalyzer.py $(OBJDUMP) \ No newline at end of file diff --git a/Sming/Makefile-macos.mk b/Sming/Makefile-macos.mk index d147abe545..c60aed8d82 100644 --- a/Sming/Makefile-macos.mk +++ b/Sming/Makefile-macos.mk @@ -13,4 +13,4 @@ ESPTOOL ?= $(ESP_HOME)/esptool/esptool.py KILL_TERM ?= pkill -9 -f "$(COM_PORT) $(COM_SPEED_SERIAL)" || exit 0 GET_FILESIZE ?= stat -L -f%z TERMINAL ?= python -m serial.tools.miniterm $(COM_PORT) $(COM_SPEED_SERIAL) $(COM_OPTS) -MEMANALYZER ?= python $(PLATFORM_TOOLS)/memanalyzer.py $(OBJDUMP) \ No newline at end of file +MEMANALYZER ?= python $(ARCH_TOOLS)/memanalyzer.py $(OBJDUMP) \ No newline at end of file diff --git a/Sming/Makefile-windows.mk b/Sming/Makefile-windows.mk index c23921de31..20122a6a0c 100644 --- a/Sming/Makefile-windows.mk +++ b/Sming/Makefile-windows.mk @@ -13,4 +13,4 @@ ESPTOOL ?= $(SDK_TOOLS)/ESP8266/esptool.exe KILL_TERM ?= taskkill.exe -f -im Terminal.exe || exit 0 GET_FILESIZE ?= stat --printf="%s" TERMINAL ?= $(SDK_TOOLS)/Terminal.exe $(COM_PORT) $(COM_SPEED_SERIAL) $(COM_OPTS) -MEMANALYZER ?= python $(PLATFORM_TOOLS)/memanalyzer.py $(OBJDUMP).exe +MEMANALYZER ?= python $(ARCH_TOOLS)/memanalyzer.py $(OBJDUMP).exe diff --git a/Sming/Platform/Common/Platform/AccessPoint.h b/Sming/Platform/AccessPoint.h similarity index 100% rename from Sming/Platform/Common/Platform/AccessPoint.h rename to Sming/Platform/AccessPoint.h diff --git a/Sming/Platform/Common/Platform/OsMessageInterceptor.cpp b/Sming/Platform/OsMessageInterceptor.cpp similarity index 100% rename from Sming/Platform/Common/Platform/OsMessageInterceptor.cpp rename to Sming/Platform/OsMessageInterceptor.cpp diff --git a/Sming/Platform/Common/Platform/OsMessageInterceptor.h b/Sming/Platform/OsMessageInterceptor.h similarity index 100% rename from Sming/Platform/Common/Platform/OsMessageInterceptor.h rename to Sming/Platform/OsMessageInterceptor.h diff --git a/Sming/Platform/Common/Platform/RTC.h b/Sming/Platform/RTC.h similarity index 100% rename from Sming/Platform/Common/Platform/RTC.h rename to Sming/Platform/RTC.h diff --git a/Sming/Platform/Common/Platform/Station.h b/Sming/Platform/Station.h similarity index 100% rename from Sming/Platform/Common/Platform/Station.h rename to Sming/Platform/Station.h diff --git a/Sming/Platform/Common/Platform/System.h b/Sming/Platform/System.h similarity index 100% rename from Sming/Platform/Common/Platform/System.h rename to Sming/Platform/System.h diff --git a/Sming/Platform/Common/Platform/WDT.h b/Sming/Platform/WDT.h similarity index 100% rename from Sming/Platform/Common/Platform/WDT.h rename to Sming/Platform/WDT.h diff --git a/Sming/Platform/Common/Platform/WifiEvents.h b/Sming/Platform/WifiEvents.h similarity index 100% rename from Sming/Platform/Common/Platform/WifiEvents.h rename to Sming/Platform/WifiEvents.h diff --git a/Sming/Platform/Common/Platform/WifiSniffer.h b/Sming/Platform/WifiSniffer.h similarity index 100% rename from Sming/Platform/Common/Platform/WifiSniffer.h rename to Sming/Platform/WifiSniffer.h diff --git a/Sming/build.mk b/Sming/build.mk index 35087c3c6a..3093806e86 100644 --- a/Sming/build.mk +++ b/Sming/build.mk @@ -1,14 +1,10 @@ # Build environment definitions -# Use this form to define platform as environment variable -ifdef SMING_PLATFORM -PLATFORM := $(SMING_PLATFORM) -else -PLATFORM ?= Esp8266 -endif +# +SMING_ARCH ?= Esp8266 -MAKECMDGOALS ?= all -$(info Building '$(MAKECMDGOALS)' for '$(PLATFORM)' platform) +MAKECMDGOALS ?= all +$(info Building '$(MAKECMDGOALS)' for '$(SMING_ARCH)' architecture) LIBS ?= CUSTOM_TARGETS ?= @@ -66,13 +62,13 @@ endif export SMING_HOME export COMPILE := gcc -PLATFORM_BASE := Platform/$(PLATFORM) -PLATFORM_SYS = $(PLATFORM_BASE)/System -PLATFORM_CORE = $(PLATFORM_BASE)/Core -PLATFORM_TOOLS = $(PLATFORM_BASE)/Tools -PLATFORM_COMPONENTS = $(PLATFORM_SYS)/components -USER_LIBDIR = $(PLATFORM_BASE)/Compiler/lib -THIRD_PARTY_DIR = third-party +ARCH_BASE := Arch/$(SMING_ARCH) +ARCH_SYS = $(ARCH_BASE)/System +ARCH_CORE = $(ARCH_BASE)/Core +ARCH_TOOLS = $(ARCH_BASE)/Tools +ARCH_COMPONENTS = $(ARCH_BASE)/Components +USER_LIBDIR = $(ARCH_BASE)/Compiler/lib +COMPONENTS := Components # Git command GIT ?= git @@ -132,7 +128,7 @@ ifdef LOCALE CFLAGS += -DLOCALE=$(LOCALE) endif -include $(SMING_HOME)/$(PLATFORM_BASE)/build.mk +include $(SMING_HOME)/$(ARCH_BASE)/build.mk AS := $(Q)$(AS) CC := $(Q)$(CC) @@ -146,3 +142,25 @@ define UserLibPath $(USER_LIBDIR)/lib$1.a endef +# Fetch full path for submodules matching given pattern +# $1 -> Path pattern to match +define ListSubmodules + $(shell git submodule status $1 | cut -c2- | cut -f2 -d ' ') +endef + + +# => Main Sming library +ifeq ($(ENABLE_SSL),1) + LIBSMING = smingssl + SMING_FEATURES = SSL +else + LIBSMING = sming + SMING_FEATURES = none +endif +LIBSMING_DST = $(call UserLibPath,$(LIBSMING)) + +# => MQTT +# Flags for compatability with old versions (most of them should disappear with the next major release) +ifeq ($(MQTT_NO_COMPAT),1) + CFLAGS += -DMQTT_NO_COMPAT=1 +endif diff --git a/Sming/third-party/.patches/ESP8266_NONOS_SDK.patch b/Sming/third-party/.patches/ESP8266_NONOS_SDK.patch deleted file mode 100644 index f412a0b74d..0000000000 --- a/Sming/third-party/.patches/ESP8266_NONOS_SDK.patch +++ /dev/null @@ -1,24 +0,0 @@ -diff --git a/include/version.h b/include/version.h -index 3f18631..82e2e94 100644 ---- a/include/version.h -+++ b/include/version.h -@@ -1,11 +1,11 @@ - #ifndef ESP_SDK_VERSION_H - #define ESP_SDK_VERSION_H - --#define ESP_SDK_VERSION_MAJOR 2 --#define ESP_SDK_VERSION_MINOR 2 -+#define ESP_SDK_VERSION_MAJOR 3 -+#define ESP_SDK_VERSION_MINOR 0 - #define ESP_SDK_VERSION_PATCH 0 - --#define ESP_SDK_VERSION_NUMBER 0x020200 --#define ESP_SDK_VERSION_STRING "2.2.0" -+#define ESP_SDK_VERSION_NUMBER 0x030000 -+#define ESP_SDK_VERSION_STRING "3.0.0" - - #endif -diff --git a/bin/esp_init_data_default_v08.bin b/bin/esp_init_data_default.bin -similarity index 100% -rename from bin/esp_init_data_default_v08.bin -rename to bin/esp_init_data_default.bin diff --git a/Sming/third-party/ESP8266_NONOS_SDK b/Sming/third-party/ESP8266_NONOS_SDK deleted file mode 160000 index d948d7e4c8..0000000000 --- a/Sming/third-party/ESP8266_NONOS_SDK +++ /dev/null @@ -1 +0,0 @@ -Subproject commit d948d7e4c8255f669bc1cb9cdae5906642cb4fc1 From f4f9b61a435cbe127d5718d047a39f1c4d80de1e Mon Sep 17 00:00:00 2001 From: mikee47 Date: Sun, 28 Apr 2019 11:26:24 +0100 Subject: [PATCH 04/22] Add makefile rule to run stack trace and update instructions * Fix `decode-stacktrace.py` so pasting content works, using `raw_input()` instead of `input()` --- Sming/Arch/Esp8266/Components/gdbstub/appcode/gdb_hooks.cpp | 2 +- Sming/Arch/Esp8266/Tools/decode-stacktrace.py | 2 +- Sming/Arch/Esp8266/app.mk | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Sming/Arch/Esp8266/Components/gdbstub/appcode/gdb_hooks.cpp b/Sming/Arch/Esp8266/Components/gdbstub/appcode/gdb_hooks.cpp index 78473e0b12..1ddf36bd82 100644 --- a/Sming/Arch/Esp8266/Components/gdbstub/appcode/gdb_hooks.cpp +++ b/Sming/Arch/Esp8266/Components/gdbstub/appcode/gdb_hooks.cpp @@ -49,7 +49,7 @@ void debug_print_stack(uint32_t start, uint32_t end) m_puts(_F("\r\n" "Stack dump:\r\n")); PSTR_ARRAY(instructions, "To decode the stack dump call from command line:\r\n" - " python $SMING_HOME/../tools/decode-stacktrace.py out/build/app.out\r\n" + " make decode-stacktrace\r\n" "and copy & paste the text enclosed in '===='.\r\n"); PSTR_ARRAY(separatorLine, "\n================================================================\r\n"); m_puts(instructions); diff --git a/Sming/Arch/Esp8266/Tools/decode-stacktrace.py b/Sming/Arch/Esp8266/Tools/decode-stacktrace.py index 52628f7fc0..a2de96284c 100644 --- a/Sming/Arch/Esp8266/Tools/decode-stacktrace.py +++ b/Sming/Arch/Esp8266/Tools/decode-stacktrace.py @@ -37,7 +37,7 @@ def extractAddresses(data): pipe.communicate("\n".join(extractAddresses(data)).encode('ascii')) else: while True: - data = input() + data = raw_input() addresses = extractAddresses(data) if len(addresses) == 0: continue diff --git a/Sming/Arch/Esp8266/app.mk b/Sming/Arch/Esp8266/app.mk index c1ef6cd392..f9ab2b8813 100644 --- a/Sming/Arch/Esp8266/app.mk +++ b/Sming/Arch/Esp8266/app.mk @@ -405,6 +405,10 @@ terminal: kill_term gdb: kill_term $(GDB) +decode-stacktrace: + @echo "Decode stack trace: Paste stack trace here" + $(Q) python $(ARCH_TOOLS)/decode-stacktrace.py $(TARGET_OUT_0) + # Wipe flash FLASH_INIT_CHUNKS := $(INIT_BIN_ADDR) $(SDK_BASE)/bin/esp_init_data_default.bin FLASH_INIT_CHUNKS += $(BLANK_BIN_ADDR) $(SDK_BASE)/bin/blank.bin From 6c58abb7e950858f9862084eb9bb77e04dc1795c Mon Sep 17 00:00:00 2001 From: mikee47 Date: Sun, 28 Apr 2019 12:05:51 +0100 Subject: [PATCH 05/22] Move `Services/libb64` into `Components` --- Sming/{Services => Components}/libb64/AUTHORS | 0 Sming/{Services => Components}/libb64/LICENSE | 0 Sming/{Services => Components}/libb64/cdecode.c | 0 Sming/{Services => Components}/libb64/cdecode.h | 0 Sming/{Services => Components}/libb64/cencode.c | 0 Sming/{Services => Components}/libb64/cencode.h | 0 Sming/Makefile | 3 +++ Sming/SmingCore/Data/Stream/Base64OutputStream.h | 2 +- 8 files changed, 4 insertions(+), 1 deletion(-) rename Sming/{Services => Components}/libb64/AUTHORS (100%) rename Sming/{Services => Components}/libb64/LICENSE (100%) rename Sming/{Services => Components}/libb64/cdecode.c (100%) rename Sming/{Services => Components}/libb64/cdecode.h (100%) rename Sming/{Services => Components}/libb64/cencode.c (100%) rename Sming/{Services => Components}/libb64/cencode.h (100%) diff --git a/Sming/Services/libb64/AUTHORS b/Sming/Components/libb64/AUTHORS similarity index 100% rename from Sming/Services/libb64/AUTHORS rename to Sming/Components/libb64/AUTHORS diff --git a/Sming/Services/libb64/LICENSE b/Sming/Components/libb64/LICENSE similarity index 100% rename from Sming/Services/libb64/LICENSE rename to Sming/Components/libb64/LICENSE diff --git a/Sming/Services/libb64/cdecode.c b/Sming/Components/libb64/cdecode.c similarity index 100% rename from Sming/Services/libb64/cdecode.c rename to Sming/Components/libb64/cdecode.c diff --git a/Sming/Services/libb64/cdecode.h b/Sming/Components/libb64/cdecode.h similarity index 100% rename from Sming/Services/libb64/cdecode.h rename to Sming/Components/libb64/cdecode.h diff --git a/Sming/Services/libb64/cencode.c b/Sming/Components/libb64/cencode.c similarity index 100% rename from Sming/Services/libb64/cencode.c rename to Sming/Components/libb64/cencode.c diff --git a/Sming/Services/libb64/cencode.h b/Sming/Components/libb64/cencode.h similarity index 100% rename from Sming/Services/libb64/cencode.h rename to Sming/Components/libb64/cencode.h diff --git a/Sming/Makefile b/Sming/Makefile index d6a5081630..9052dad13f 100644 --- a/Sming/Makefile +++ b/Sming/Makefile @@ -53,6 +53,9 @@ endif SUBMODULES += $(COMPONENTS)/http-parser MODULES += $(COMPONENTS)/http-parser +# => libb64 +MODULES += $(COMPONENTS)/libb64 + # => websocket-parser SUBMODULES += $(COMPONENTS)/ws_parser MODULES += $(COMPONENTS)/ws_parser diff --git a/Sming/SmingCore/Data/Stream/Base64OutputStream.h b/Sming/SmingCore/Data/Stream/Base64OutputStream.h index 1b1871b760..32c08c9e45 100644 --- a/Sming/SmingCore/Data/Stream/Base64OutputStream.h +++ b/Sming/SmingCore/Data/Stream/Base64OutputStream.h @@ -14,7 +14,7 @@ #define _SMING_CORE_DATA_STREAM_BASE64_OUTPUT_STREAM_H_ #include "../StreamTransformer.h" -#include "Services/libb64/cencode.h" +#include "libb64/cencode.h" /** * @brief Base64 Stream From 1149ba8a2a62a11403bbaf5423e05124dcab3cd7 Mon Sep 17 00:00:00 2001 From: mikee47 Date: Sun, 28 Apr 2019 12:07:48 +0100 Subject: [PATCH 06/22] Move `Services/WebHelpers` into `SmingCore/Network` --- Sming/SmingCore/Network/Http/HttpBodyParser.cpp | 2 +- Sming/SmingCore/Network/Http/HttpParams.cpp | 2 +- Sming/SmingCore/Network/Http/HttpRequestAuth.cpp | 2 +- .../SmingCore/Network/Http/Websocket/WebsocketConnection.cpp | 4 ++-- Sming/SmingCore/Network/SmtpClient.cpp | 2 +- Sming/SmingCore/Network/Url.cpp | 2 +- Sming/{Services => SmingCore/Network}/WebHelpers/aw-sha1.cpp | 0 Sming/{Services => SmingCore/Network}/WebHelpers/aw-sha1.h | 0 Sming/{Services => SmingCore/Network}/WebHelpers/base64.cpp | 0 Sming/{Services => SmingCore/Network}/WebHelpers/base64.h | 0 Sming/{Services => SmingCore/Network}/WebHelpers/escape.cpp | 0 Sming/{Services => SmingCore/Network}/WebHelpers/escape.h | 0 Sming/SmingCore/Network/WebsocketClient.cpp | 4 ++-- 13 files changed, 9 insertions(+), 9 deletions(-) rename Sming/{Services => SmingCore/Network}/WebHelpers/aw-sha1.cpp (100%) rename Sming/{Services => SmingCore/Network}/WebHelpers/aw-sha1.h (100%) rename Sming/{Services => SmingCore/Network}/WebHelpers/base64.cpp (100%) rename Sming/{Services => SmingCore/Network}/WebHelpers/base64.h (100%) rename Sming/{Services => SmingCore/Network}/WebHelpers/escape.cpp (100%) rename Sming/{Services => SmingCore/Network}/WebHelpers/escape.h (100%) diff --git a/Sming/SmingCore/Network/Http/HttpBodyParser.cpp b/Sming/SmingCore/Network/Http/HttpBodyParser.cpp index 9650ffa42c..2fd00b6381 100644 --- a/Sming/SmingCore/Network/Http/HttpBodyParser.cpp +++ b/Sming/SmingCore/Network/Http/HttpBodyParser.cpp @@ -15,7 +15,7 @@ ****/ #include "HttpBodyParser.h" -#include "../WebHelpers/escape.h" +#include "WebHelpers/escape.h" /* * Content is received in chunks which we need to reassemble into name=value pairs. diff --git a/Sming/SmingCore/Network/Http/HttpParams.cpp b/Sming/SmingCore/Network/Http/HttpParams.cpp index d4dde9ec67..391681fcb1 100644 --- a/Sming/SmingCore/Network/Http/HttpParams.cpp +++ b/Sming/SmingCore/Network/Http/HttpParams.cpp @@ -11,7 +11,7 @@ ****/ #include "HttpParams.h" -#include "Services/WebHelpers/escape.h" +#include "WebHelpers/escape.h" #include "Print.h" #include "libyuarel/yuarel.h" diff --git a/Sming/SmingCore/Network/Http/HttpRequestAuth.cpp b/Sming/SmingCore/Network/Http/HttpRequestAuth.cpp index f6b72ed408..552f87fdaa 100644 --- a/Sming/SmingCore/Network/Http/HttpRequestAuth.cpp +++ b/Sming/SmingCore/Network/Http/HttpRequestAuth.cpp @@ -12,7 +12,7 @@ #include "HttpRequestAuth.h" #include "HttpRequest.h" -#include "Services/WebHelpers/base64.h" +#include "WebHelpers/base64.h" // Basic Auth void HttpBasicAuth::setRequest(HttpRequest* request) diff --git a/Sming/SmingCore/Network/Http/Websocket/WebsocketConnection.cpp b/Sming/SmingCore/Network/Http/Websocket/WebsocketConnection.cpp index da0475e428..f3916370f5 100644 --- a/Sming/SmingCore/Network/Http/Websocket/WebsocketConnection.cpp +++ b/Sming/SmingCore/Network/Http/Websocket/WebsocketConnection.cpp @@ -10,8 +10,8 @@ #include "WebsocketConnection.h" -#include "Services/WebHelpers/aw-sha1.h" -#include "Services/WebHelpers/base64.h" +#include "WebHelpers/aw-sha1.h" +#include "WebHelpers/base64.h" DEFINE_FSTR(WSSTR_CONNECTION, "connection") DEFINE_FSTR(WSSTR_UPGRADE, "upgrade") diff --git a/Sming/SmingCore/Network/SmtpClient.cpp b/Sming/SmingCore/Network/SmtpClient.cpp index 4be999712c..9cc562179d 100644 --- a/Sming/SmingCore/Network/SmtpClient.cpp +++ b/Sming/SmingCore/Network/SmtpClient.cpp @@ -17,7 +17,7 @@ */ #include "SmtpClient.h" -#include "Services/WebHelpers/base64.h" +#include "WebHelpers/base64.h" #include "Data/Stream/QuotedPrintableOutputStream.h" #include "Data/Stream/Base64OutputStream.h" #include "Data/HexString.h" diff --git a/Sming/SmingCore/Network/Url.cpp b/Sming/SmingCore/Network/Url.cpp index a24cfbe0d3..e7e6d53c7a 100644 --- a/Sming/SmingCore/Network/Url.cpp +++ b/Sming/SmingCore/Network/Url.cpp @@ -12,7 +12,7 @@ #include "Url.h" #include "libyuarel/yuarel.h" -#include "Services/WebHelpers/escape.h" +#include "WebHelpers/escape.h" #include "Print.h" /** diff --git a/Sming/Services/WebHelpers/aw-sha1.cpp b/Sming/SmingCore/Network/WebHelpers/aw-sha1.cpp similarity index 100% rename from Sming/Services/WebHelpers/aw-sha1.cpp rename to Sming/SmingCore/Network/WebHelpers/aw-sha1.cpp diff --git a/Sming/Services/WebHelpers/aw-sha1.h b/Sming/SmingCore/Network/WebHelpers/aw-sha1.h similarity index 100% rename from Sming/Services/WebHelpers/aw-sha1.h rename to Sming/SmingCore/Network/WebHelpers/aw-sha1.h diff --git a/Sming/Services/WebHelpers/base64.cpp b/Sming/SmingCore/Network/WebHelpers/base64.cpp similarity index 100% rename from Sming/Services/WebHelpers/base64.cpp rename to Sming/SmingCore/Network/WebHelpers/base64.cpp diff --git a/Sming/Services/WebHelpers/base64.h b/Sming/SmingCore/Network/WebHelpers/base64.h similarity index 100% rename from Sming/Services/WebHelpers/base64.h rename to Sming/SmingCore/Network/WebHelpers/base64.h diff --git a/Sming/Services/WebHelpers/escape.cpp b/Sming/SmingCore/Network/WebHelpers/escape.cpp similarity index 100% rename from Sming/Services/WebHelpers/escape.cpp rename to Sming/SmingCore/Network/WebHelpers/escape.cpp diff --git a/Sming/Services/WebHelpers/escape.h b/Sming/SmingCore/Network/WebHelpers/escape.h similarity index 100% rename from Sming/Services/WebHelpers/escape.h rename to Sming/SmingCore/Network/WebHelpers/escape.h diff --git a/Sming/SmingCore/Network/WebsocketClient.cpp b/Sming/SmingCore/Network/WebsocketClient.cpp index 87483c498f..33973bd2c9 100644 --- a/Sming/SmingCore/Network/WebsocketClient.cpp +++ b/Sming/SmingCore/Network/WebsocketClient.cpp @@ -15,8 +15,8 @@ #include "WebsocketClient.h" #include "Network/Http/HttpHeaders.h" -#include "Services/WebHelpers/aw-sha1.h" -#include "Services/WebHelpers/base64.h" +#include "WebHelpers/aw-sha1.h" +#include "WebHelpers/base64.h" HttpConnection* WebsocketClient::getHttpConnection() { From e12090909816020557fb0e09a22a538195d9eafd Mon Sep 17 00:00:00 2001 From: mikee47 Date: Sun, 28 Apr 2019 12:20:29 +0100 Subject: [PATCH 07/22] Rename `SmingCore` to `Core` --- Sming/{SmingCore => Core}/ArduinoCompat.cpp | 0 Sming/{SmingCore => Core}/ArduinoCompat.h | 0 Sming/{SmingCore => Core}/AtClient.cpp | 0 Sming/{SmingCore => Core}/AtClient.h | 0 Sming/{SmingCore => Core}/Clock.h | 0 Sming/{SmingCore => Core}/Data/Buffer/CircularBuffer.cpp | 0 Sming/{SmingCore => Core}/Data/Buffer/CircularBuffer.h | 0 Sming/{SmingCore => Core}/Data/Buffer/LineBuffer.h | 0 Sming/{SmingCore => Core}/Data/Buffer/SerialBuffer.cpp | 0 Sming/{SmingCore => Core}/Data/Buffer/SerialBuffer.h | 0 Sming/{SmingCore => Core}/Data/CStringArray.cpp | 0 Sming/{SmingCore => Core}/Data/CStringArray.h | 0 Sming/{SmingCore => Core}/Data/HexString.cpp | 0 Sming/{SmingCore => Core}/Data/HexString.h | 0 Sming/{SmingCore => Core}/Data/MailMessage.cpp | 0 Sming/{SmingCore => Core}/Data/MailMessage.h | 0 Sming/{SmingCore => Core}/Data/ObjectMap.h | 0 Sming/{SmingCore => Core}/Data/ObjectQueue.h | 0 .../{SmingCore => Core}/Data/Stream/Base64OutputStream.cpp | 0 Sming/{SmingCore => Core}/Data/Stream/Base64OutputStream.h | 0 Sming/{SmingCore => Core}/Data/Stream/ChunkedStream.cpp | 0 Sming/{SmingCore => Core}/Data/Stream/ChunkedStream.h | 0 Sming/{SmingCore => Core}/Data/Stream/DataSourceStream.cpp | 0 Sming/{SmingCore => Core}/Data/Stream/DataSourceStream.h | 0 .../{SmingCore => Core}/Data/Stream/EndlessMemoryStream.cpp | 0 Sming/{SmingCore => Core}/Data/Stream/EndlessMemoryStream.h | 0 Sming/{SmingCore => Core}/Data/Stream/FileStream.cpp | 0 Sming/{SmingCore => Core}/Data/Stream/FileStream.h | 0 Sming/{SmingCore => Core}/Data/Stream/FlashMemoryStream.cpp | 0 Sming/{SmingCore => Core}/Data/Stream/FlashMemoryStream.h | 0 Sming/{SmingCore => Core}/Data/Stream/GdbFileStream.cpp | 0 Sming/{SmingCore => Core}/Data/Stream/GdbFileStream.h | 0 Sming/{SmingCore => Core}/Data/Stream/JsonObjectStream.cpp | 0 Sming/{SmingCore => Core}/Data/Stream/JsonObjectStream.h | 0 .../{SmingCore => Core}/Data/Stream/LimitedMemoryStream.cpp | 0 Sming/{SmingCore => Core}/Data/Stream/LimitedMemoryStream.h | 0 Sming/{SmingCore => Core}/Data/Stream/MemoryDataStream.cpp | 0 Sming/{SmingCore => Core}/Data/Stream/MemoryDataStream.h | 0 Sming/{SmingCore => Core}/Data/Stream/MultiStream.cpp | 0 Sming/{SmingCore => Core}/Data/Stream/MultiStream.h | 0 Sming/{SmingCore => Core}/Data/Stream/MultipartStream.cpp | 0 Sming/{SmingCore => Core}/Data/Stream/MultipartStream.h | 0 .../Data/Stream/QuotedPrintableOutputStream.cpp | 0 .../Data/Stream/QuotedPrintableOutputStream.h | 0 Sming/{SmingCore => Core}/Data/Stream/ReadWriteStream.h | 0 Sming/{SmingCore => Core}/Data/Stream/StreamChain.h | 0 Sming/{SmingCore => Core}/Data/Stream/TemplateFileStream.h | 0 .../Data/Stream/TemplateFlashMemoryStream.h | 0 Sming/{SmingCore => Core}/Data/Stream/TemplateStream.cpp | 0 Sming/{SmingCore => Core}/Data/Stream/TemplateStream.h | 0 .../Data/Stream/UrlencodedOutputStream.cpp | 0 .../Data/Stream/UrlencodedOutputStream.h | 0 Sming/{SmingCore => Core}/Data/StreamTransformer.cpp | 0 Sming/{SmingCore => Core}/Data/StreamTransformer.h | 0 Sming/{SmingCore => Core}/DateTime.cpp | 0 Sming/{SmingCore => Core}/DateTime.h | 0 Sming/{SmingCore => Core}/Debug.cpp | 0 Sming/{SmingCore => Core}/Debug.h | 0 Sming/{SmingCore => Core}/Delegate.h | 0 Sming/{SmingCore => Core}/Digital.h | 0 Sming/{SmingCore => Core}/FileSystem.cpp | 0 Sming/{SmingCore => Core}/FileSystem.h | 0 Sming/{SmingCore => Core}/HardwarePWM.h | 0 Sming/{SmingCore => Core}/HardwareSerial.h | 0 Sming/{SmingCore => Core}/HardwareTimer.h | 0 Sming/{SmingCore => Core}/Interrupts.h | 0 Sming/{SmingCore => Core}/License.txt | 0 Sming/{SmingCore => Core}/Network/DNSServer.cpp | 0 Sming/{SmingCore => Core}/Network/DNSServer.h | 0 Sming/{SmingCore => Core}/Network/Ftp/FtpDataFileList.h | 0 Sming/{SmingCore => Core}/Network/Ftp/FtpDataRetrieve.h | 0 Sming/{SmingCore => Core}/Network/Ftp/FtpDataStore.h | 0 Sming/{SmingCore => Core}/Network/Ftp/FtpDataStream.h | 0 .../{SmingCore => Core}/Network/Ftp/FtpServerConnection.cpp | 0 Sming/{SmingCore => Core}/Network/Ftp/FtpServerConnection.h | 0 Sming/{SmingCore => Core}/Network/FtpServer.cpp | 0 Sming/{SmingCore => Core}/Network/FtpServer.h | 0 Sming/{SmingCore => Core}/Network/Http/HttpBodyParser.cpp | 0 Sming/{SmingCore => Core}/Network/Http/HttpBodyParser.h | 0 .../Network/Http/HttpClientConnection.cpp | 0 .../{SmingCore => Core}/Network/Http/HttpClientConnection.h | 0 Sming/{SmingCore => Core}/Network/Http/HttpCommon.cpp | 0 Sming/{SmingCore => Core}/Network/Http/HttpCommon.h | 0 Sming/{SmingCore => Core}/Network/Http/HttpConnection.cpp | 0 Sming/{SmingCore => Core}/Network/Http/HttpConnection.h | 0 Sming/{SmingCore => Core}/Network/Http/HttpHeaderBuilder.h | 0 Sming/{SmingCore => Core}/Network/Http/HttpHeaders.cpp | 0 Sming/{SmingCore => Core}/Network/Http/HttpHeaders.h | 0 Sming/{SmingCore => Core}/Network/Http/HttpParams.cpp | 0 Sming/{SmingCore => Core}/Network/Http/HttpParams.h | 0 Sming/{SmingCore => Core}/Network/Http/HttpRequest.cpp | 0 Sming/{SmingCore => Core}/Network/Http/HttpRequest.h | 0 Sming/{SmingCore => Core}/Network/Http/HttpRequestAuth.cpp | 0 Sming/{SmingCore => Core}/Network/Http/HttpRequestAuth.h | 0 Sming/{SmingCore => Core}/Network/Http/HttpResource.h | 0 Sming/{SmingCore => Core}/Network/Http/HttpResourceTree.cpp | 0 Sming/{SmingCore => Core}/Network/Http/HttpResourceTree.h | 0 Sming/{SmingCore => Core}/Network/Http/HttpResponse.cpp | 0 Sming/{SmingCore => Core}/Network/Http/HttpResponse.h | 0 .../Network/Http/HttpServerConnection.cpp | 0 .../{SmingCore => Core}/Network/Http/HttpServerConnection.h | 0 .../Network/Http/Websocket/WebsocketConnection.cpp | 0 .../Network/Http/Websocket/WebsocketConnection.h | 0 .../Network/Http/Websocket/WebsocketResource.cpp | 0 .../Network/Http/Websocket/WebsocketResource.h | 0 .../Network/Http/Websocket/WsCommandHandlerResource.h | 0 Sming/{SmingCore => Core}/Network/HttpClient.cpp | 0 Sming/{SmingCore => Core}/Network/HttpClient.h | 0 Sming/{SmingCore => Core}/Network/HttpServer.cpp | 0 Sming/{SmingCore => Core}/Network/HttpServer.h | 0 .../{SmingCore => Core}/Network/Mqtt/MqttPayloadParser.cpp | 0 Sming/{SmingCore => Core}/Network/Mqtt/MqttPayloadParser.h | 0 Sming/{SmingCore => Core}/Network/MqttClient.cpp | 0 Sming/{SmingCore => Core}/Network/MqttClient.h | 0 Sming/{SmingCore => Core}/Network/NetUtils.cpp | 0 Sming/{SmingCore => Core}/Network/NetUtils.h | 0 Sming/{SmingCore => Core}/Network/NtpClient.cpp | 0 Sming/{SmingCore => Core}/Network/NtpClient.h | 0 Sming/{SmingCore => Core}/Network/SmtpClient.cpp | 0 Sming/{SmingCore => Core}/Network/SmtpClient.h | 0 Sming/{SmingCore => Core}/Network/Ssl/SslFingerprints.cpp | 0 Sming/{SmingCore => Core}/Network/Ssl/SslFingerprints.h | 0 Sming/{SmingCore => Core}/Network/Ssl/SslKeyCertPair.h | 0 Sming/{SmingCore => Core}/Network/Ssl/SslSessionId.h | 0 Sming/{SmingCore => Core}/Network/Ssl/SslStructs.h | 0 Sming/{SmingCore => Core}/Network/Ssl/SslValidator.cpp | 0 Sming/{SmingCore => Core}/Network/Ssl/SslValidator.h | 0 Sming/{SmingCore => Core}/Network/TcpClient.cpp | 0 Sming/{SmingCore => Core}/Network/TcpClient.h | 0 Sming/{SmingCore => Core}/Network/TcpConnection.cpp | 0 Sming/{SmingCore => Core}/Network/TcpConnection.h | 0 Sming/{SmingCore => Core}/Network/TcpServer.cpp | 0 Sming/{SmingCore => Core}/Network/TcpServer.h | 0 Sming/{SmingCore => Core}/Network/TelnetServer.cpp | 0 Sming/{SmingCore => Core}/Network/TelnetServer.h | 0 Sming/{SmingCore => Core}/Network/UdpConnection.cpp | 0 Sming/{SmingCore => Core}/Network/UdpConnection.h | 0 Sming/{SmingCore => Core}/Network/Url.cpp | 0 Sming/{SmingCore => Core}/Network/Url.h | 0 Sming/{SmingCore => Core}/Network/WebConstants.cpp | 0 Sming/{SmingCore => Core}/Network/WebConstants.h | 0 Sming/{SmingCore => Core}/Network/WebHelpers/aw-sha1.cpp | 0 Sming/{SmingCore => Core}/Network/WebHelpers/aw-sha1.h | 0 Sming/{SmingCore => Core}/Network/WebHelpers/base64.cpp | 0 Sming/{SmingCore => Core}/Network/WebHelpers/base64.h | 0 Sming/{SmingCore => Core}/Network/WebHelpers/escape.cpp | 0 Sming/{SmingCore => Core}/Network/WebHelpers/escape.h | 0 Sming/{SmingCore => Core}/Network/WebsocketClient.cpp | 0 Sming/{SmingCore => Core}/Network/WebsocketClient.h | 0 Sming/{SmingCore => Core}/SPI.h | 0 Sming/{SmingCore => Core}/SPIBase.h | 0 Sming/{SmingCore => Core}/SPISettings.h | 0 Sming/{SmingCore => Core}/SPISoft.h | 0 Sming/{SmingCore => Core}/SimpleTimer.h | 0 Sming/{SmingCore => Core}/SmingCore.h | 0 Sming/{SmingCore => Core}/SmingLocale.h | 0 Sming/{SmingCore => Core}/SystemClock.cpp | 0 Sming/{SmingCore => Core}/SystemClock.h | 0 Sming/{SmingCore => Core}/Timer.cpp | 0 Sming/{SmingCore => Core}/Timer.h | 0 Sming/{SmingCore => Core}/Wire.cpp | 0 Sming/{SmingCore => Core}/Wire.h | 0 Sming/{SmingCore => Core}/pgmspace.h | 0 Sming/{SmingCore => Core}/twi.h | 0 Sming/Libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp | 2 +- Sming/Libraries/Adafruit_PCD8544/Adafruit_PCD8544.cpp | 2 +- Sming/Libraries/Adafruit_PCD8544/Adafruit_PCD8544.h | 2 +- Sming/Libraries/BMP180/BMP180.h | 2 +- Sming/Libraries/DS18S20/ds18s20.h | 2 +- Sming/Libraries/LiquidCrystal/I2CIO.cpp | 2 +- Sming/Libraries/RCSwitch/RCSwitch.cpp | 2 +- Sming/Libraries/SI7021/SI7021.h | 2 +- Sming/Libraries/Servo/Servo.h | 2 +- Sming/Libraries/Servo/ServoChannel.h | 2 +- Sming/Libraries/TFT_ILI9163C/TFT_ILI9163C.cpp | 4 ++-- Sming/Libraries/WS2812/WS2812.h | 2 +- Sming/Makefile | 6 +++--- Sming/Makefile-app.mk | 2 +- samples/DFPlayerMini/app/application.cpp | 2 +- samples/Display_TM1637/app/application.cpp | 2 +- samples/Nextion_Button/app/application.cpp | 2 +- samples/SmtpClient/app/application.cpp | 4 ++-- 182 files changed, 22 insertions(+), 22 deletions(-) rename Sming/{SmingCore => Core}/ArduinoCompat.cpp (100%) rename Sming/{SmingCore => Core}/ArduinoCompat.h (100%) rename Sming/{SmingCore => Core}/AtClient.cpp (100%) rename Sming/{SmingCore => Core}/AtClient.h (100%) rename Sming/{SmingCore => Core}/Clock.h (100%) rename Sming/{SmingCore => Core}/Data/Buffer/CircularBuffer.cpp (100%) rename Sming/{SmingCore => Core}/Data/Buffer/CircularBuffer.h (100%) rename Sming/{SmingCore => Core}/Data/Buffer/LineBuffer.h (100%) rename Sming/{SmingCore => Core}/Data/Buffer/SerialBuffer.cpp (100%) rename Sming/{SmingCore => Core}/Data/Buffer/SerialBuffer.h (100%) rename Sming/{SmingCore => Core}/Data/CStringArray.cpp (100%) rename Sming/{SmingCore => Core}/Data/CStringArray.h (100%) rename Sming/{SmingCore => Core}/Data/HexString.cpp (100%) rename Sming/{SmingCore => Core}/Data/HexString.h (100%) rename Sming/{SmingCore => Core}/Data/MailMessage.cpp (100%) rename Sming/{SmingCore => Core}/Data/MailMessage.h (100%) rename Sming/{SmingCore => Core}/Data/ObjectMap.h (100%) rename Sming/{SmingCore => Core}/Data/ObjectQueue.h (100%) rename Sming/{SmingCore => Core}/Data/Stream/Base64OutputStream.cpp (100%) rename Sming/{SmingCore => Core}/Data/Stream/Base64OutputStream.h (100%) rename Sming/{SmingCore => Core}/Data/Stream/ChunkedStream.cpp (100%) rename Sming/{SmingCore => Core}/Data/Stream/ChunkedStream.h (100%) rename Sming/{SmingCore => Core}/Data/Stream/DataSourceStream.cpp (100%) rename Sming/{SmingCore => Core}/Data/Stream/DataSourceStream.h (100%) rename Sming/{SmingCore => Core}/Data/Stream/EndlessMemoryStream.cpp (100%) rename Sming/{SmingCore => Core}/Data/Stream/EndlessMemoryStream.h (100%) rename Sming/{SmingCore => Core}/Data/Stream/FileStream.cpp (100%) rename Sming/{SmingCore => Core}/Data/Stream/FileStream.h (100%) rename Sming/{SmingCore => Core}/Data/Stream/FlashMemoryStream.cpp (100%) rename Sming/{SmingCore => Core}/Data/Stream/FlashMemoryStream.h (100%) rename Sming/{SmingCore => Core}/Data/Stream/GdbFileStream.cpp (100%) rename Sming/{SmingCore => Core}/Data/Stream/GdbFileStream.h (100%) rename Sming/{SmingCore => Core}/Data/Stream/JsonObjectStream.cpp (100%) rename Sming/{SmingCore => Core}/Data/Stream/JsonObjectStream.h (100%) rename Sming/{SmingCore => Core}/Data/Stream/LimitedMemoryStream.cpp (100%) rename Sming/{SmingCore => Core}/Data/Stream/LimitedMemoryStream.h (100%) rename Sming/{SmingCore => Core}/Data/Stream/MemoryDataStream.cpp (100%) rename Sming/{SmingCore => Core}/Data/Stream/MemoryDataStream.h (100%) rename Sming/{SmingCore => Core}/Data/Stream/MultiStream.cpp (100%) rename Sming/{SmingCore => Core}/Data/Stream/MultiStream.h (100%) rename Sming/{SmingCore => Core}/Data/Stream/MultipartStream.cpp (100%) rename Sming/{SmingCore => Core}/Data/Stream/MultipartStream.h (100%) rename Sming/{SmingCore => Core}/Data/Stream/QuotedPrintableOutputStream.cpp (100%) rename Sming/{SmingCore => Core}/Data/Stream/QuotedPrintableOutputStream.h (100%) rename Sming/{SmingCore => Core}/Data/Stream/ReadWriteStream.h (100%) rename Sming/{SmingCore => Core}/Data/Stream/StreamChain.h (100%) rename Sming/{SmingCore => Core}/Data/Stream/TemplateFileStream.h (100%) rename Sming/{SmingCore => Core}/Data/Stream/TemplateFlashMemoryStream.h (100%) rename Sming/{SmingCore => Core}/Data/Stream/TemplateStream.cpp (100%) rename Sming/{SmingCore => Core}/Data/Stream/TemplateStream.h (100%) rename Sming/{SmingCore => Core}/Data/Stream/UrlencodedOutputStream.cpp (100%) rename Sming/{SmingCore => Core}/Data/Stream/UrlencodedOutputStream.h (100%) rename Sming/{SmingCore => Core}/Data/StreamTransformer.cpp (100%) rename Sming/{SmingCore => Core}/Data/StreamTransformer.h (100%) rename Sming/{SmingCore => Core}/DateTime.cpp (100%) rename Sming/{SmingCore => Core}/DateTime.h (100%) rename Sming/{SmingCore => Core}/Debug.cpp (100%) rename Sming/{SmingCore => Core}/Debug.h (100%) rename Sming/{SmingCore => Core}/Delegate.h (100%) rename Sming/{SmingCore => Core}/Digital.h (100%) rename Sming/{SmingCore => Core}/FileSystem.cpp (100%) rename Sming/{SmingCore => Core}/FileSystem.h (100%) rename Sming/{SmingCore => Core}/HardwarePWM.h (100%) rename Sming/{SmingCore => Core}/HardwareSerial.h (100%) rename Sming/{SmingCore => Core}/HardwareTimer.h (100%) rename Sming/{SmingCore => Core}/Interrupts.h (100%) rename Sming/{SmingCore => Core}/License.txt (100%) rename Sming/{SmingCore => Core}/Network/DNSServer.cpp (100%) rename Sming/{SmingCore => Core}/Network/DNSServer.h (100%) rename Sming/{SmingCore => Core}/Network/Ftp/FtpDataFileList.h (100%) rename Sming/{SmingCore => Core}/Network/Ftp/FtpDataRetrieve.h (100%) rename Sming/{SmingCore => Core}/Network/Ftp/FtpDataStore.h (100%) rename Sming/{SmingCore => Core}/Network/Ftp/FtpDataStream.h (100%) rename Sming/{SmingCore => Core}/Network/Ftp/FtpServerConnection.cpp (100%) rename Sming/{SmingCore => Core}/Network/Ftp/FtpServerConnection.h (100%) rename Sming/{SmingCore => Core}/Network/FtpServer.cpp (100%) rename Sming/{SmingCore => Core}/Network/FtpServer.h (100%) rename Sming/{SmingCore => Core}/Network/Http/HttpBodyParser.cpp (100%) rename Sming/{SmingCore => Core}/Network/Http/HttpBodyParser.h (100%) rename Sming/{SmingCore => Core}/Network/Http/HttpClientConnection.cpp (100%) rename Sming/{SmingCore => Core}/Network/Http/HttpClientConnection.h (100%) rename Sming/{SmingCore => Core}/Network/Http/HttpCommon.cpp (100%) rename Sming/{SmingCore => Core}/Network/Http/HttpCommon.h (100%) rename Sming/{SmingCore => Core}/Network/Http/HttpConnection.cpp (100%) rename Sming/{SmingCore => Core}/Network/Http/HttpConnection.h (100%) rename Sming/{SmingCore => Core}/Network/Http/HttpHeaderBuilder.h (100%) rename Sming/{SmingCore => Core}/Network/Http/HttpHeaders.cpp (100%) rename Sming/{SmingCore => Core}/Network/Http/HttpHeaders.h (100%) rename Sming/{SmingCore => Core}/Network/Http/HttpParams.cpp (100%) rename Sming/{SmingCore => Core}/Network/Http/HttpParams.h (100%) rename Sming/{SmingCore => Core}/Network/Http/HttpRequest.cpp (100%) rename Sming/{SmingCore => Core}/Network/Http/HttpRequest.h (100%) rename Sming/{SmingCore => Core}/Network/Http/HttpRequestAuth.cpp (100%) rename Sming/{SmingCore => Core}/Network/Http/HttpRequestAuth.h (100%) rename Sming/{SmingCore => Core}/Network/Http/HttpResource.h (100%) rename Sming/{SmingCore => Core}/Network/Http/HttpResourceTree.cpp (100%) rename Sming/{SmingCore => Core}/Network/Http/HttpResourceTree.h (100%) rename Sming/{SmingCore => Core}/Network/Http/HttpResponse.cpp (100%) rename Sming/{SmingCore => Core}/Network/Http/HttpResponse.h (100%) rename Sming/{SmingCore => Core}/Network/Http/HttpServerConnection.cpp (100%) rename Sming/{SmingCore => Core}/Network/Http/HttpServerConnection.h (100%) rename Sming/{SmingCore => Core}/Network/Http/Websocket/WebsocketConnection.cpp (100%) rename Sming/{SmingCore => Core}/Network/Http/Websocket/WebsocketConnection.h (100%) rename Sming/{SmingCore => Core}/Network/Http/Websocket/WebsocketResource.cpp (100%) rename Sming/{SmingCore => Core}/Network/Http/Websocket/WebsocketResource.h (100%) rename Sming/{SmingCore => Core}/Network/Http/Websocket/WsCommandHandlerResource.h (100%) rename Sming/{SmingCore => Core}/Network/HttpClient.cpp (100%) rename Sming/{SmingCore => Core}/Network/HttpClient.h (100%) rename Sming/{SmingCore => Core}/Network/HttpServer.cpp (100%) rename Sming/{SmingCore => Core}/Network/HttpServer.h (100%) rename Sming/{SmingCore => Core}/Network/Mqtt/MqttPayloadParser.cpp (100%) rename Sming/{SmingCore => Core}/Network/Mqtt/MqttPayloadParser.h (100%) rename Sming/{SmingCore => Core}/Network/MqttClient.cpp (100%) rename Sming/{SmingCore => Core}/Network/MqttClient.h (100%) rename Sming/{SmingCore => Core}/Network/NetUtils.cpp (100%) rename Sming/{SmingCore => Core}/Network/NetUtils.h (100%) rename Sming/{SmingCore => Core}/Network/NtpClient.cpp (100%) rename Sming/{SmingCore => Core}/Network/NtpClient.h (100%) rename Sming/{SmingCore => Core}/Network/SmtpClient.cpp (100%) rename Sming/{SmingCore => Core}/Network/SmtpClient.h (100%) rename Sming/{SmingCore => Core}/Network/Ssl/SslFingerprints.cpp (100%) rename Sming/{SmingCore => Core}/Network/Ssl/SslFingerprints.h (100%) rename Sming/{SmingCore => Core}/Network/Ssl/SslKeyCertPair.h (100%) rename Sming/{SmingCore => Core}/Network/Ssl/SslSessionId.h (100%) rename Sming/{SmingCore => Core}/Network/Ssl/SslStructs.h (100%) rename Sming/{SmingCore => Core}/Network/Ssl/SslValidator.cpp (100%) rename Sming/{SmingCore => Core}/Network/Ssl/SslValidator.h (100%) rename Sming/{SmingCore => Core}/Network/TcpClient.cpp (100%) rename Sming/{SmingCore => Core}/Network/TcpClient.h (100%) rename Sming/{SmingCore => Core}/Network/TcpConnection.cpp (100%) rename Sming/{SmingCore => Core}/Network/TcpConnection.h (100%) rename Sming/{SmingCore => Core}/Network/TcpServer.cpp (100%) rename Sming/{SmingCore => Core}/Network/TcpServer.h (100%) rename Sming/{SmingCore => Core}/Network/TelnetServer.cpp (100%) rename Sming/{SmingCore => Core}/Network/TelnetServer.h (100%) rename Sming/{SmingCore => Core}/Network/UdpConnection.cpp (100%) rename Sming/{SmingCore => Core}/Network/UdpConnection.h (100%) rename Sming/{SmingCore => Core}/Network/Url.cpp (100%) rename Sming/{SmingCore => Core}/Network/Url.h (100%) rename Sming/{SmingCore => Core}/Network/WebConstants.cpp (100%) rename Sming/{SmingCore => Core}/Network/WebConstants.h (100%) rename Sming/{SmingCore => Core}/Network/WebHelpers/aw-sha1.cpp (100%) rename Sming/{SmingCore => Core}/Network/WebHelpers/aw-sha1.h (100%) rename Sming/{SmingCore => Core}/Network/WebHelpers/base64.cpp (100%) rename Sming/{SmingCore => Core}/Network/WebHelpers/base64.h (100%) rename Sming/{SmingCore => Core}/Network/WebHelpers/escape.cpp (100%) rename Sming/{SmingCore => Core}/Network/WebHelpers/escape.h (100%) rename Sming/{SmingCore => Core}/Network/WebsocketClient.cpp (100%) rename Sming/{SmingCore => Core}/Network/WebsocketClient.h (100%) rename Sming/{SmingCore => Core}/SPI.h (100%) rename Sming/{SmingCore => Core}/SPIBase.h (100%) rename Sming/{SmingCore => Core}/SPISettings.h (100%) rename Sming/{SmingCore => Core}/SPISoft.h (100%) rename Sming/{SmingCore => Core}/SimpleTimer.h (100%) rename Sming/{SmingCore => Core}/SmingCore.h (100%) rename Sming/{SmingCore => Core}/SmingLocale.h (100%) rename Sming/{SmingCore => Core}/SystemClock.cpp (100%) rename Sming/{SmingCore => Core}/SystemClock.h (100%) rename Sming/{SmingCore => Core}/Timer.cpp (100%) rename Sming/{SmingCore => Core}/Timer.h (100%) rename Sming/{SmingCore => Core}/Wire.cpp (100%) rename Sming/{SmingCore => Core}/Wire.h (100%) rename Sming/{SmingCore => Core}/pgmspace.h (100%) rename Sming/{SmingCore => Core}/twi.h (100%) diff --git a/Sming/SmingCore/ArduinoCompat.cpp b/Sming/Core/ArduinoCompat.cpp similarity index 100% rename from Sming/SmingCore/ArduinoCompat.cpp rename to Sming/Core/ArduinoCompat.cpp diff --git a/Sming/SmingCore/ArduinoCompat.h b/Sming/Core/ArduinoCompat.h similarity index 100% rename from Sming/SmingCore/ArduinoCompat.h rename to Sming/Core/ArduinoCompat.h diff --git a/Sming/SmingCore/AtClient.cpp b/Sming/Core/AtClient.cpp similarity index 100% rename from Sming/SmingCore/AtClient.cpp rename to Sming/Core/AtClient.cpp diff --git a/Sming/SmingCore/AtClient.h b/Sming/Core/AtClient.h similarity index 100% rename from Sming/SmingCore/AtClient.h rename to Sming/Core/AtClient.h diff --git a/Sming/SmingCore/Clock.h b/Sming/Core/Clock.h similarity index 100% rename from Sming/SmingCore/Clock.h rename to Sming/Core/Clock.h diff --git a/Sming/SmingCore/Data/Buffer/CircularBuffer.cpp b/Sming/Core/Data/Buffer/CircularBuffer.cpp similarity index 100% rename from Sming/SmingCore/Data/Buffer/CircularBuffer.cpp rename to Sming/Core/Data/Buffer/CircularBuffer.cpp diff --git a/Sming/SmingCore/Data/Buffer/CircularBuffer.h b/Sming/Core/Data/Buffer/CircularBuffer.h similarity index 100% rename from Sming/SmingCore/Data/Buffer/CircularBuffer.h rename to Sming/Core/Data/Buffer/CircularBuffer.h diff --git a/Sming/SmingCore/Data/Buffer/LineBuffer.h b/Sming/Core/Data/Buffer/LineBuffer.h similarity index 100% rename from Sming/SmingCore/Data/Buffer/LineBuffer.h rename to Sming/Core/Data/Buffer/LineBuffer.h diff --git a/Sming/SmingCore/Data/Buffer/SerialBuffer.cpp b/Sming/Core/Data/Buffer/SerialBuffer.cpp similarity index 100% rename from Sming/SmingCore/Data/Buffer/SerialBuffer.cpp rename to Sming/Core/Data/Buffer/SerialBuffer.cpp diff --git a/Sming/SmingCore/Data/Buffer/SerialBuffer.h b/Sming/Core/Data/Buffer/SerialBuffer.h similarity index 100% rename from Sming/SmingCore/Data/Buffer/SerialBuffer.h rename to Sming/Core/Data/Buffer/SerialBuffer.h diff --git a/Sming/SmingCore/Data/CStringArray.cpp b/Sming/Core/Data/CStringArray.cpp similarity index 100% rename from Sming/SmingCore/Data/CStringArray.cpp rename to Sming/Core/Data/CStringArray.cpp diff --git a/Sming/SmingCore/Data/CStringArray.h b/Sming/Core/Data/CStringArray.h similarity index 100% rename from Sming/SmingCore/Data/CStringArray.h rename to Sming/Core/Data/CStringArray.h diff --git a/Sming/SmingCore/Data/HexString.cpp b/Sming/Core/Data/HexString.cpp similarity index 100% rename from Sming/SmingCore/Data/HexString.cpp rename to Sming/Core/Data/HexString.cpp diff --git a/Sming/SmingCore/Data/HexString.h b/Sming/Core/Data/HexString.h similarity index 100% rename from Sming/SmingCore/Data/HexString.h rename to Sming/Core/Data/HexString.h diff --git a/Sming/SmingCore/Data/MailMessage.cpp b/Sming/Core/Data/MailMessage.cpp similarity index 100% rename from Sming/SmingCore/Data/MailMessage.cpp rename to Sming/Core/Data/MailMessage.cpp diff --git a/Sming/SmingCore/Data/MailMessage.h b/Sming/Core/Data/MailMessage.h similarity index 100% rename from Sming/SmingCore/Data/MailMessage.h rename to Sming/Core/Data/MailMessage.h diff --git a/Sming/SmingCore/Data/ObjectMap.h b/Sming/Core/Data/ObjectMap.h similarity index 100% rename from Sming/SmingCore/Data/ObjectMap.h rename to Sming/Core/Data/ObjectMap.h diff --git a/Sming/SmingCore/Data/ObjectQueue.h b/Sming/Core/Data/ObjectQueue.h similarity index 100% rename from Sming/SmingCore/Data/ObjectQueue.h rename to Sming/Core/Data/ObjectQueue.h diff --git a/Sming/SmingCore/Data/Stream/Base64OutputStream.cpp b/Sming/Core/Data/Stream/Base64OutputStream.cpp similarity index 100% rename from Sming/SmingCore/Data/Stream/Base64OutputStream.cpp rename to Sming/Core/Data/Stream/Base64OutputStream.cpp diff --git a/Sming/SmingCore/Data/Stream/Base64OutputStream.h b/Sming/Core/Data/Stream/Base64OutputStream.h similarity index 100% rename from Sming/SmingCore/Data/Stream/Base64OutputStream.h rename to Sming/Core/Data/Stream/Base64OutputStream.h diff --git a/Sming/SmingCore/Data/Stream/ChunkedStream.cpp b/Sming/Core/Data/Stream/ChunkedStream.cpp similarity index 100% rename from Sming/SmingCore/Data/Stream/ChunkedStream.cpp rename to Sming/Core/Data/Stream/ChunkedStream.cpp diff --git a/Sming/SmingCore/Data/Stream/ChunkedStream.h b/Sming/Core/Data/Stream/ChunkedStream.h similarity index 100% rename from Sming/SmingCore/Data/Stream/ChunkedStream.h rename to Sming/Core/Data/Stream/ChunkedStream.h diff --git a/Sming/SmingCore/Data/Stream/DataSourceStream.cpp b/Sming/Core/Data/Stream/DataSourceStream.cpp similarity index 100% rename from Sming/SmingCore/Data/Stream/DataSourceStream.cpp rename to Sming/Core/Data/Stream/DataSourceStream.cpp diff --git a/Sming/SmingCore/Data/Stream/DataSourceStream.h b/Sming/Core/Data/Stream/DataSourceStream.h similarity index 100% rename from Sming/SmingCore/Data/Stream/DataSourceStream.h rename to Sming/Core/Data/Stream/DataSourceStream.h diff --git a/Sming/SmingCore/Data/Stream/EndlessMemoryStream.cpp b/Sming/Core/Data/Stream/EndlessMemoryStream.cpp similarity index 100% rename from Sming/SmingCore/Data/Stream/EndlessMemoryStream.cpp rename to Sming/Core/Data/Stream/EndlessMemoryStream.cpp diff --git a/Sming/SmingCore/Data/Stream/EndlessMemoryStream.h b/Sming/Core/Data/Stream/EndlessMemoryStream.h similarity index 100% rename from Sming/SmingCore/Data/Stream/EndlessMemoryStream.h rename to Sming/Core/Data/Stream/EndlessMemoryStream.h diff --git a/Sming/SmingCore/Data/Stream/FileStream.cpp b/Sming/Core/Data/Stream/FileStream.cpp similarity index 100% rename from Sming/SmingCore/Data/Stream/FileStream.cpp rename to Sming/Core/Data/Stream/FileStream.cpp diff --git a/Sming/SmingCore/Data/Stream/FileStream.h b/Sming/Core/Data/Stream/FileStream.h similarity index 100% rename from Sming/SmingCore/Data/Stream/FileStream.h rename to Sming/Core/Data/Stream/FileStream.h diff --git a/Sming/SmingCore/Data/Stream/FlashMemoryStream.cpp b/Sming/Core/Data/Stream/FlashMemoryStream.cpp similarity index 100% rename from Sming/SmingCore/Data/Stream/FlashMemoryStream.cpp rename to Sming/Core/Data/Stream/FlashMemoryStream.cpp diff --git a/Sming/SmingCore/Data/Stream/FlashMemoryStream.h b/Sming/Core/Data/Stream/FlashMemoryStream.h similarity index 100% rename from Sming/SmingCore/Data/Stream/FlashMemoryStream.h rename to Sming/Core/Data/Stream/FlashMemoryStream.h diff --git a/Sming/SmingCore/Data/Stream/GdbFileStream.cpp b/Sming/Core/Data/Stream/GdbFileStream.cpp similarity index 100% rename from Sming/SmingCore/Data/Stream/GdbFileStream.cpp rename to Sming/Core/Data/Stream/GdbFileStream.cpp diff --git a/Sming/SmingCore/Data/Stream/GdbFileStream.h b/Sming/Core/Data/Stream/GdbFileStream.h similarity index 100% rename from Sming/SmingCore/Data/Stream/GdbFileStream.h rename to Sming/Core/Data/Stream/GdbFileStream.h diff --git a/Sming/SmingCore/Data/Stream/JsonObjectStream.cpp b/Sming/Core/Data/Stream/JsonObjectStream.cpp similarity index 100% rename from Sming/SmingCore/Data/Stream/JsonObjectStream.cpp rename to Sming/Core/Data/Stream/JsonObjectStream.cpp diff --git a/Sming/SmingCore/Data/Stream/JsonObjectStream.h b/Sming/Core/Data/Stream/JsonObjectStream.h similarity index 100% rename from Sming/SmingCore/Data/Stream/JsonObjectStream.h rename to Sming/Core/Data/Stream/JsonObjectStream.h diff --git a/Sming/SmingCore/Data/Stream/LimitedMemoryStream.cpp b/Sming/Core/Data/Stream/LimitedMemoryStream.cpp similarity index 100% rename from Sming/SmingCore/Data/Stream/LimitedMemoryStream.cpp rename to Sming/Core/Data/Stream/LimitedMemoryStream.cpp diff --git a/Sming/SmingCore/Data/Stream/LimitedMemoryStream.h b/Sming/Core/Data/Stream/LimitedMemoryStream.h similarity index 100% rename from Sming/SmingCore/Data/Stream/LimitedMemoryStream.h rename to Sming/Core/Data/Stream/LimitedMemoryStream.h diff --git a/Sming/SmingCore/Data/Stream/MemoryDataStream.cpp b/Sming/Core/Data/Stream/MemoryDataStream.cpp similarity index 100% rename from Sming/SmingCore/Data/Stream/MemoryDataStream.cpp rename to Sming/Core/Data/Stream/MemoryDataStream.cpp diff --git a/Sming/SmingCore/Data/Stream/MemoryDataStream.h b/Sming/Core/Data/Stream/MemoryDataStream.h similarity index 100% rename from Sming/SmingCore/Data/Stream/MemoryDataStream.h rename to Sming/Core/Data/Stream/MemoryDataStream.h diff --git a/Sming/SmingCore/Data/Stream/MultiStream.cpp b/Sming/Core/Data/Stream/MultiStream.cpp similarity index 100% rename from Sming/SmingCore/Data/Stream/MultiStream.cpp rename to Sming/Core/Data/Stream/MultiStream.cpp diff --git a/Sming/SmingCore/Data/Stream/MultiStream.h b/Sming/Core/Data/Stream/MultiStream.h similarity index 100% rename from Sming/SmingCore/Data/Stream/MultiStream.h rename to Sming/Core/Data/Stream/MultiStream.h diff --git a/Sming/SmingCore/Data/Stream/MultipartStream.cpp b/Sming/Core/Data/Stream/MultipartStream.cpp similarity index 100% rename from Sming/SmingCore/Data/Stream/MultipartStream.cpp rename to Sming/Core/Data/Stream/MultipartStream.cpp diff --git a/Sming/SmingCore/Data/Stream/MultipartStream.h b/Sming/Core/Data/Stream/MultipartStream.h similarity index 100% rename from Sming/SmingCore/Data/Stream/MultipartStream.h rename to Sming/Core/Data/Stream/MultipartStream.h diff --git a/Sming/SmingCore/Data/Stream/QuotedPrintableOutputStream.cpp b/Sming/Core/Data/Stream/QuotedPrintableOutputStream.cpp similarity index 100% rename from Sming/SmingCore/Data/Stream/QuotedPrintableOutputStream.cpp rename to Sming/Core/Data/Stream/QuotedPrintableOutputStream.cpp diff --git a/Sming/SmingCore/Data/Stream/QuotedPrintableOutputStream.h b/Sming/Core/Data/Stream/QuotedPrintableOutputStream.h similarity index 100% rename from Sming/SmingCore/Data/Stream/QuotedPrintableOutputStream.h rename to Sming/Core/Data/Stream/QuotedPrintableOutputStream.h diff --git a/Sming/SmingCore/Data/Stream/ReadWriteStream.h b/Sming/Core/Data/Stream/ReadWriteStream.h similarity index 100% rename from Sming/SmingCore/Data/Stream/ReadWriteStream.h rename to Sming/Core/Data/Stream/ReadWriteStream.h diff --git a/Sming/SmingCore/Data/Stream/StreamChain.h b/Sming/Core/Data/Stream/StreamChain.h similarity index 100% rename from Sming/SmingCore/Data/Stream/StreamChain.h rename to Sming/Core/Data/Stream/StreamChain.h diff --git a/Sming/SmingCore/Data/Stream/TemplateFileStream.h b/Sming/Core/Data/Stream/TemplateFileStream.h similarity index 100% rename from Sming/SmingCore/Data/Stream/TemplateFileStream.h rename to Sming/Core/Data/Stream/TemplateFileStream.h diff --git a/Sming/SmingCore/Data/Stream/TemplateFlashMemoryStream.h b/Sming/Core/Data/Stream/TemplateFlashMemoryStream.h similarity index 100% rename from Sming/SmingCore/Data/Stream/TemplateFlashMemoryStream.h rename to Sming/Core/Data/Stream/TemplateFlashMemoryStream.h diff --git a/Sming/SmingCore/Data/Stream/TemplateStream.cpp b/Sming/Core/Data/Stream/TemplateStream.cpp similarity index 100% rename from Sming/SmingCore/Data/Stream/TemplateStream.cpp rename to Sming/Core/Data/Stream/TemplateStream.cpp diff --git a/Sming/SmingCore/Data/Stream/TemplateStream.h b/Sming/Core/Data/Stream/TemplateStream.h similarity index 100% rename from Sming/SmingCore/Data/Stream/TemplateStream.h rename to Sming/Core/Data/Stream/TemplateStream.h diff --git a/Sming/SmingCore/Data/Stream/UrlencodedOutputStream.cpp b/Sming/Core/Data/Stream/UrlencodedOutputStream.cpp similarity index 100% rename from Sming/SmingCore/Data/Stream/UrlencodedOutputStream.cpp rename to Sming/Core/Data/Stream/UrlencodedOutputStream.cpp diff --git a/Sming/SmingCore/Data/Stream/UrlencodedOutputStream.h b/Sming/Core/Data/Stream/UrlencodedOutputStream.h similarity index 100% rename from Sming/SmingCore/Data/Stream/UrlencodedOutputStream.h rename to Sming/Core/Data/Stream/UrlencodedOutputStream.h diff --git a/Sming/SmingCore/Data/StreamTransformer.cpp b/Sming/Core/Data/StreamTransformer.cpp similarity index 100% rename from Sming/SmingCore/Data/StreamTransformer.cpp rename to Sming/Core/Data/StreamTransformer.cpp diff --git a/Sming/SmingCore/Data/StreamTransformer.h b/Sming/Core/Data/StreamTransformer.h similarity index 100% rename from Sming/SmingCore/Data/StreamTransformer.h rename to Sming/Core/Data/StreamTransformer.h diff --git a/Sming/SmingCore/DateTime.cpp b/Sming/Core/DateTime.cpp similarity index 100% rename from Sming/SmingCore/DateTime.cpp rename to Sming/Core/DateTime.cpp diff --git a/Sming/SmingCore/DateTime.h b/Sming/Core/DateTime.h similarity index 100% rename from Sming/SmingCore/DateTime.h rename to Sming/Core/DateTime.h diff --git a/Sming/SmingCore/Debug.cpp b/Sming/Core/Debug.cpp similarity index 100% rename from Sming/SmingCore/Debug.cpp rename to Sming/Core/Debug.cpp diff --git a/Sming/SmingCore/Debug.h b/Sming/Core/Debug.h similarity index 100% rename from Sming/SmingCore/Debug.h rename to Sming/Core/Debug.h diff --git a/Sming/SmingCore/Delegate.h b/Sming/Core/Delegate.h similarity index 100% rename from Sming/SmingCore/Delegate.h rename to Sming/Core/Delegate.h diff --git a/Sming/SmingCore/Digital.h b/Sming/Core/Digital.h similarity index 100% rename from Sming/SmingCore/Digital.h rename to Sming/Core/Digital.h diff --git a/Sming/SmingCore/FileSystem.cpp b/Sming/Core/FileSystem.cpp similarity index 100% rename from Sming/SmingCore/FileSystem.cpp rename to Sming/Core/FileSystem.cpp diff --git a/Sming/SmingCore/FileSystem.h b/Sming/Core/FileSystem.h similarity index 100% rename from Sming/SmingCore/FileSystem.h rename to Sming/Core/FileSystem.h diff --git a/Sming/SmingCore/HardwarePWM.h b/Sming/Core/HardwarePWM.h similarity index 100% rename from Sming/SmingCore/HardwarePWM.h rename to Sming/Core/HardwarePWM.h diff --git a/Sming/SmingCore/HardwareSerial.h b/Sming/Core/HardwareSerial.h similarity index 100% rename from Sming/SmingCore/HardwareSerial.h rename to Sming/Core/HardwareSerial.h diff --git a/Sming/SmingCore/HardwareTimer.h b/Sming/Core/HardwareTimer.h similarity index 100% rename from Sming/SmingCore/HardwareTimer.h rename to Sming/Core/HardwareTimer.h diff --git a/Sming/SmingCore/Interrupts.h b/Sming/Core/Interrupts.h similarity index 100% rename from Sming/SmingCore/Interrupts.h rename to Sming/Core/Interrupts.h diff --git a/Sming/SmingCore/License.txt b/Sming/Core/License.txt similarity index 100% rename from Sming/SmingCore/License.txt rename to Sming/Core/License.txt diff --git a/Sming/SmingCore/Network/DNSServer.cpp b/Sming/Core/Network/DNSServer.cpp similarity index 100% rename from Sming/SmingCore/Network/DNSServer.cpp rename to Sming/Core/Network/DNSServer.cpp diff --git a/Sming/SmingCore/Network/DNSServer.h b/Sming/Core/Network/DNSServer.h similarity index 100% rename from Sming/SmingCore/Network/DNSServer.h rename to Sming/Core/Network/DNSServer.h diff --git a/Sming/SmingCore/Network/Ftp/FtpDataFileList.h b/Sming/Core/Network/Ftp/FtpDataFileList.h similarity index 100% rename from Sming/SmingCore/Network/Ftp/FtpDataFileList.h rename to Sming/Core/Network/Ftp/FtpDataFileList.h diff --git a/Sming/SmingCore/Network/Ftp/FtpDataRetrieve.h b/Sming/Core/Network/Ftp/FtpDataRetrieve.h similarity index 100% rename from Sming/SmingCore/Network/Ftp/FtpDataRetrieve.h rename to Sming/Core/Network/Ftp/FtpDataRetrieve.h diff --git a/Sming/SmingCore/Network/Ftp/FtpDataStore.h b/Sming/Core/Network/Ftp/FtpDataStore.h similarity index 100% rename from Sming/SmingCore/Network/Ftp/FtpDataStore.h rename to Sming/Core/Network/Ftp/FtpDataStore.h diff --git a/Sming/SmingCore/Network/Ftp/FtpDataStream.h b/Sming/Core/Network/Ftp/FtpDataStream.h similarity index 100% rename from Sming/SmingCore/Network/Ftp/FtpDataStream.h rename to Sming/Core/Network/Ftp/FtpDataStream.h diff --git a/Sming/SmingCore/Network/Ftp/FtpServerConnection.cpp b/Sming/Core/Network/Ftp/FtpServerConnection.cpp similarity index 100% rename from Sming/SmingCore/Network/Ftp/FtpServerConnection.cpp rename to Sming/Core/Network/Ftp/FtpServerConnection.cpp diff --git a/Sming/SmingCore/Network/Ftp/FtpServerConnection.h b/Sming/Core/Network/Ftp/FtpServerConnection.h similarity index 100% rename from Sming/SmingCore/Network/Ftp/FtpServerConnection.h rename to Sming/Core/Network/Ftp/FtpServerConnection.h diff --git a/Sming/SmingCore/Network/FtpServer.cpp b/Sming/Core/Network/FtpServer.cpp similarity index 100% rename from Sming/SmingCore/Network/FtpServer.cpp rename to Sming/Core/Network/FtpServer.cpp diff --git a/Sming/SmingCore/Network/FtpServer.h b/Sming/Core/Network/FtpServer.h similarity index 100% rename from Sming/SmingCore/Network/FtpServer.h rename to Sming/Core/Network/FtpServer.h diff --git a/Sming/SmingCore/Network/Http/HttpBodyParser.cpp b/Sming/Core/Network/Http/HttpBodyParser.cpp similarity index 100% rename from Sming/SmingCore/Network/Http/HttpBodyParser.cpp rename to Sming/Core/Network/Http/HttpBodyParser.cpp diff --git a/Sming/SmingCore/Network/Http/HttpBodyParser.h b/Sming/Core/Network/Http/HttpBodyParser.h similarity index 100% rename from Sming/SmingCore/Network/Http/HttpBodyParser.h rename to Sming/Core/Network/Http/HttpBodyParser.h diff --git a/Sming/SmingCore/Network/Http/HttpClientConnection.cpp b/Sming/Core/Network/Http/HttpClientConnection.cpp similarity index 100% rename from Sming/SmingCore/Network/Http/HttpClientConnection.cpp rename to Sming/Core/Network/Http/HttpClientConnection.cpp diff --git a/Sming/SmingCore/Network/Http/HttpClientConnection.h b/Sming/Core/Network/Http/HttpClientConnection.h similarity index 100% rename from Sming/SmingCore/Network/Http/HttpClientConnection.h rename to Sming/Core/Network/Http/HttpClientConnection.h diff --git a/Sming/SmingCore/Network/Http/HttpCommon.cpp b/Sming/Core/Network/Http/HttpCommon.cpp similarity index 100% rename from Sming/SmingCore/Network/Http/HttpCommon.cpp rename to Sming/Core/Network/Http/HttpCommon.cpp diff --git a/Sming/SmingCore/Network/Http/HttpCommon.h b/Sming/Core/Network/Http/HttpCommon.h similarity index 100% rename from Sming/SmingCore/Network/Http/HttpCommon.h rename to Sming/Core/Network/Http/HttpCommon.h diff --git a/Sming/SmingCore/Network/Http/HttpConnection.cpp b/Sming/Core/Network/Http/HttpConnection.cpp similarity index 100% rename from Sming/SmingCore/Network/Http/HttpConnection.cpp rename to Sming/Core/Network/Http/HttpConnection.cpp diff --git a/Sming/SmingCore/Network/Http/HttpConnection.h b/Sming/Core/Network/Http/HttpConnection.h similarity index 100% rename from Sming/SmingCore/Network/Http/HttpConnection.h rename to Sming/Core/Network/Http/HttpConnection.h diff --git a/Sming/SmingCore/Network/Http/HttpHeaderBuilder.h b/Sming/Core/Network/Http/HttpHeaderBuilder.h similarity index 100% rename from Sming/SmingCore/Network/Http/HttpHeaderBuilder.h rename to Sming/Core/Network/Http/HttpHeaderBuilder.h diff --git a/Sming/SmingCore/Network/Http/HttpHeaders.cpp b/Sming/Core/Network/Http/HttpHeaders.cpp similarity index 100% rename from Sming/SmingCore/Network/Http/HttpHeaders.cpp rename to Sming/Core/Network/Http/HttpHeaders.cpp diff --git a/Sming/SmingCore/Network/Http/HttpHeaders.h b/Sming/Core/Network/Http/HttpHeaders.h similarity index 100% rename from Sming/SmingCore/Network/Http/HttpHeaders.h rename to Sming/Core/Network/Http/HttpHeaders.h diff --git a/Sming/SmingCore/Network/Http/HttpParams.cpp b/Sming/Core/Network/Http/HttpParams.cpp similarity index 100% rename from Sming/SmingCore/Network/Http/HttpParams.cpp rename to Sming/Core/Network/Http/HttpParams.cpp diff --git a/Sming/SmingCore/Network/Http/HttpParams.h b/Sming/Core/Network/Http/HttpParams.h similarity index 100% rename from Sming/SmingCore/Network/Http/HttpParams.h rename to Sming/Core/Network/Http/HttpParams.h diff --git a/Sming/SmingCore/Network/Http/HttpRequest.cpp b/Sming/Core/Network/Http/HttpRequest.cpp similarity index 100% rename from Sming/SmingCore/Network/Http/HttpRequest.cpp rename to Sming/Core/Network/Http/HttpRequest.cpp diff --git a/Sming/SmingCore/Network/Http/HttpRequest.h b/Sming/Core/Network/Http/HttpRequest.h similarity index 100% rename from Sming/SmingCore/Network/Http/HttpRequest.h rename to Sming/Core/Network/Http/HttpRequest.h diff --git a/Sming/SmingCore/Network/Http/HttpRequestAuth.cpp b/Sming/Core/Network/Http/HttpRequestAuth.cpp similarity index 100% rename from Sming/SmingCore/Network/Http/HttpRequestAuth.cpp rename to Sming/Core/Network/Http/HttpRequestAuth.cpp diff --git a/Sming/SmingCore/Network/Http/HttpRequestAuth.h b/Sming/Core/Network/Http/HttpRequestAuth.h similarity index 100% rename from Sming/SmingCore/Network/Http/HttpRequestAuth.h rename to Sming/Core/Network/Http/HttpRequestAuth.h diff --git a/Sming/SmingCore/Network/Http/HttpResource.h b/Sming/Core/Network/Http/HttpResource.h similarity index 100% rename from Sming/SmingCore/Network/Http/HttpResource.h rename to Sming/Core/Network/Http/HttpResource.h diff --git a/Sming/SmingCore/Network/Http/HttpResourceTree.cpp b/Sming/Core/Network/Http/HttpResourceTree.cpp similarity index 100% rename from Sming/SmingCore/Network/Http/HttpResourceTree.cpp rename to Sming/Core/Network/Http/HttpResourceTree.cpp diff --git a/Sming/SmingCore/Network/Http/HttpResourceTree.h b/Sming/Core/Network/Http/HttpResourceTree.h similarity index 100% rename from Sming/SmingCore/Network/Http/HttpResourceTree.h rename to Sming/Core/Network/Http/HttpResourceTree.h diff --git a/Sming/SmingCore/Network/Http/HttpResponse.cpp b/Sming/Core/Network/Http/HttpResponse.cpp similarity index 100% rename from Sming/SmingCore/Network/Http/HttpResponse.cpp rename to Sming/Core/Network/Http/HttpResponse.cpp diff --git a/Sming/SmingCore/Network/Http/HttpResponse.h b/Sming/Core/Network/Http/HttpResponse.h similarity index 100% rename from Sming/SmingCore/Network/Http/HttpResponse.h rename to Sming/Core/Network/Http/HttpResponse.h diff --git a/Sming/SmingCore/Network/Http/HttpServerConnection.cpp b/Sming/Core/Network/Http/HttpServerConnection.cpp similarity index 100% rename from Sming/SmingCore/Network/Http/HttpServerConnection.cpp rename to Sming/Core/Network/Http/HttpServerConnection.cpp diff --git a/Sming/SmingCore/Network/Http/HttpServerConnection.h b/Sming/Core/Network/Http/HttpServerConnection.h similarity index 100% rename from Sming/SmingCore/Network/Http/HttpServerConnection.h rename to Sming/Core/Network/Http/HttpServerConnection.h diff --git a/Sming/SmingCore/Network/Http/Websocket/WebsocketConnection.cpp b/Sming/Core/Network/Http/Websocket/WebsocketConnection.cpp similarity index 100% rename from Sming/SmingCore/Network/Http/Websocket/WebsocketConnection.cpp rename to Sming/Core/Network/Http/Websocket/WebsocketConnection.cpp diff --git a/Sming/SmingCore/Network/Http/Websocket/WebsocketConnection.h b/Sming/Core/Network/Http/Websocket/WebsocketConnection.h similarity index 100% rename from Sming/SmingCore/Network/Http/Websocket/WebsocketConnection.h rename to Sming/Core/Network/Http/Websocket/WebsocketConnection.h diff --git a/Sming/SmingCore/Network/Http/Websocket/WebsocketResource.cpp b/Sming/Core/Network/Http/Websocket/WebsocketResource.cpp similarity index 100% rename from Sming/SmingCore/Network/Http/Websocket/WebsocketResource.cpp rename to Sming/Core/Network/Http/Websocket/WebsocketResource.cpp diff --git a/Sming/SmingCore/Network/Http/Websocket/WebsocketResource.h b/Sming/Core/Network/Http/Websocket/WebsocketResource.h similarity index 100% rename from Sming/SmingCore/Network/Http/Websocket/WebsocketResource.h rename to Sming/Core/Network/Http/Websocket/WebsocketResource.h diff --git a/Sming/SmingCore/Network/Http/Websocket/WsCommandHandlerResource.h b/Sming/Core/Network/Http/Websocket/WsCommandHandlerResource.h similarity index 100% rename from Sming/SmingCore/Network/Http/Websocket/WsCommandHandlerResource.h rename to Sming/Core/Network/Http/Websocket/WsCommandHandlerResource.h diff --git a/Sming/SmingCore/Network/HttpClient.cpp b/Sming/Core/Network/HttpClient.cpp similarity index 100% rename from Sming/SmingCore/Network/HttpClient.cpp rename to Sming/Core/Network/HttpClient.cpp diff --git a/Sming/SmingCore/Network/HttpClient.h b/Sming/Core/Network/HttpClient.h similarity index 100% rename from Sming/SmingCore/Network/HttpClient.h rename to Sming/Core/Network/HttpClient.h diff --git a/Sming/SmingCore/Network/HttpServer.cpp b/Sming/Core/Network/HttpServer.cpp similarity index 100% rename from Sming/SmingCore/Network/HttpServer.cpp rename to Sming/Core/Network/HttpServer.cpp diff --git a/Sming/SmingCore/Network/HttpServer.h b/Sming/Core/Network/HttpServer.h similarity index 100% rename from Sming/SmingCore/Network/HttpServer.h rename to Sming/Core/Network/HttpServer.h diff --git a/Sming/SmingCore/Network/Mqtt/MqttPayloadParser.cpp b/Sming/Core/Network/Mqtt/MqttPayloadParser.cpp similarity index 100% rename from Sming/SmingCore/Network/Mqtt/MqttPayloadParser.cpp rename to Sming/Core/Network/Mqtt/MqttPayloadParser.cpp diff --git a/Sming/SmingCore/Network/Mqtt/MqttPayloadParser.h b/Sming/Core/Network/Mqtt/MqttPayloadParser.h similarity index 100% rename from Sming/SmingCore/Network/Mqtt/MqttPayloadParser.h rename to Sming/Core/Network/Mqtt/MqttPayloadParser.h diff --git a/Sming/SmingCore/Network/MqttClient.cpp b/Sming/Core/Network/MqttClient.cpp similarity index 100% rename from Sming/SmingCore/Network/MqttClient.cpp rename to Sming/Core/Network/MqttClient.cpp diff --git a/Sming/SmingCore/Network/MqttClient.h b/Sming/Core/Network/MqttClient.h similarity index 100% rename from Sming/SmingCore/Network/MqttClient.h rename to Sming/Core/Network/MqttClient.h diff --git a/Sming/SmingCore/Network/NetUtils.cpp b/Sming/Core/Network/NetUtils.cpp similarity index 100% rename from Sming/SmingCore/Network/NetUtils.cpp rename to Sming/Core/Network/NetUtils.cpp diff --git a/Sming/SmingCore/Network/NetUtils.h b/Sming/Core/Network/NetUtils.h similarity index 100% rename from Sming/SmingCore/Network/NetUtils.h rename to Sming/Core/Network/NetUtils.h diff --git a/Sming/SmingCore/Network/NtpClient.cpp b/Sming/Core/Network/NtpClient.cpp similarity index 100% rename from Sming/SmingCore/Network/NtpClient.cpp rename to Sming/Core/Network/NtpClient.cpp diff --git a/Sming/SmingCore/Network/NtpClient.h b/Sming/Core/Network/NtpClient.h similarity index 100% rename from Sming/SmingCore/Network/NtpClient.h rename to Sming/Core/Network/NtpClient.h diff --git a/Sming/SmingCore/Network/SmtpClient.cpp b/Sming/Core/Network/SmtpClient.cpp similarity index 100% rename from Sming/SmingCore/Network/SmtpClient.cpp rename to Sming/Core/Network/SmtpClient.cpp diff --git a/Sming/SmingCore/Network/SmtpClient.h b/Sming/Core/Network/SmtpClient.h similarity index 100% rename from Sming/SmingCore/Network/SmtpClient.h rename to Sming/Core/Network/SmtpClient.h diff --git a/Sming/SmingCore/Network/Ssl/SslFingerprints.cpp b/Sming/Core/Network/Ssl/SslFingerprints.cpp similarity index 100% rename from Sming/SmingCore/Network/Ssl/SslFingerprints.cpp rename to Sming/Core/Network/Ssl/SslFingerprints.cpp diff --git a/Sming/SmingCore/Network/Ssl/SslFingerprints.h b/Sming/Core/Network/Ssl/SslFingerprints.h similarity index 100% rename from Sming/SmingCore/Network/Ssl/SslFingerprints.h rename to Sming/Core/Network/Ssl/SslFingerprints.h diff --git a/Sming/SmingCore/Network/Ssl/SslKeyCertPair.h b/Sming/Core/Network/Ssl/SslKeyCertPair.h similarity index 100% rename from Sming/SmingCore/Network/Ssl/SslKeyCertPair.h rename to Sming/Core/Network/Ssl/SslKeyCertPair.h diff --git a/Sming/SmingCore/Network/Ssl/SslSessionId.h b/Sming/Core/Network/Ssl/SslSessionId.h similarity index 100% rename from Sming/SmingCore/Network/Ssl/SslSessionId.h rename to Sming/Core/Network/Ssl/SslSessionId.h diff --git a/Sming/SmingCore/Network/Ssl/SslStructs.h b/Sming/Core/Network/Ssl/SslStructs.h similarity index 100% rename from Sming/SmingCore/Network/Ssl/SslStructs.h rename to Sming/Core/Network/Ssl/SslStructs.h diff --git a/Sming/SmingCore/Network/Ssl/SslValidator.cpp b/Sming/Core/Network/Ssl/SslValidator.cpp similarity index 100% rename from Sming/SmingCore/Network/Ssl/SslValidator.cpp rename to Sming/Core/Network/Ssl/SslValidator.cpp diff --git a/Sming/SmingCore/Network/Ssl/SslValidator.h b/Sming/Core/Network/Ssl/SslValidator.h similarity index 100% rename from Sming/SmingCore/Network/Ssl/SslValidator.h rename to Sming/Core/Network/Ssl/SslValidator.h diff --git a/Sming/SmingCore/Network/TcpClient.cpp b/Sming/Core/Network/TcpClient.cpp similarity index 100% rename from Sming/SmingCore/Network/TcpClient.cpp rename to Sming/Core/Network/TcpClient.cpp diff --git a/Sming/SmingCore/Network/TcpClient.h b/Sming/Core/Network/TcpClient.h similarity index 100% rename from Sming/SmingCore/Network/TcpClient.h rename to Sming/Core/Network/TcpClient.h diff --git a/Sming/SmingCore/Network/TcpConnection.cpp b/Sming/Core/Network/TcpConnection.cpp similarity index 100% rename from Sming/SmingCore/Network/TcpConnection.cpp rename to Sming/Core/Network/TcpConnection.cpp diff --git a/Sming/SmingCore/Network/TcpConnection.h b/Sming/Core/Network/TcpConnection.h similarity index 100% rename from Sming/SmingCore/Network/TcpConnection.h rename to Sming/Core/Network/TcpConnection.h diff --git a/Sming/SmingCore/Network/TcpServer.cpp b/Sming/Core/Network/TcpServer.cpp similarity index 100% rename from Sming/SmingCore/Network/TcpServer.cpp rename to Sming/Core/Network/TcpServer.cpp diff --git a/Sming/SmingCore/Network/TcpServer.h b/Sming/Core/Network/TcpServer.h similarity index 100% rename from Sming/SmingCore/Network/TcpServer.h rename to Sming/Core/Network/TcpServer.h diff --git a/Sming/SmingCore/Network/TelnetServer.cpp b/Sming/Core/Network/TelnetServer.cpp similarity index 100% rename from Sming/SmingCore/Network/TelnetServer.cpp rename to Sming/Core/Network/TelnetServer.cpp diff --git a/Sming/SmingCore/Network/TelnetServer.h b/Sming/Core/Network/TelnetServer.h similarity index 100% rename from Sming/SmingCore/Network/TelnetServer.h rename to Sming/Core/Network/TelnetServer.h diff --git a/Sming/SmingCore/Network/UdpConnection.cpp b/Sming/Core/Network/UdpConnection.cpp similarity index 100% rename from Sming/SmingCore/Network/UdpConnection.cpp rename to Sming/Core/Network/UdpConnection.cpp diff --git a/Sming/SmingCore/Network/UdpConnection.h b/Sming/Core/Network/UdpConnection.h similarity index 100% rename from Sming/SmingCore/Network/UdpConnection.h rename to Sming/Core/Network/UdpConnection.h diff --git a/Sming/SmingCore/Network/Url.cpp b/Sming/Core/Network/Url.cpp similarity index 100% rename from Sming/SmingCore/Network/Url.cpp rename to Sming/Core/Network/Url.cpp diff --git a/Sming/SmingCore/Network/Url.h b/Sming/Core/Network/Url.h similarity index 100% rename from Sming/SmingCore/Network/Url.h rename to Sming/Core/Network/Url.h diff --git a/Sming/SmingCore/Network/WebConstants.cpp b/Sming/Core/Network/WebConstants.cpp similarity index 100% rename from Sming/SmingCore/Network/WebConstants.cpp rename to Sming/Core/Network/WebConstants.cpp diff --git a/Sming/SmingCore/Network/WebConstants.h b/Sming/Core/Network/WebConstants.h similarity index 100% rename from Sming/SmingCore/Network/WebConstants.h rename to Sming/Core/Network/WebConstants.h diff --git a/Sming/SmingCore/Network/WebHelpers/aw-sha1.cpp b/Sming/Core/Network/WebHelpers/aw-sha1.cpp similarity index 100% rename from Sming/SmingCore/Network/WebHelpers/aw-sha1.cpp rename to Sming/Core/Network/WebHelpers/aw-sha1.cpp diff --git a/Sming/SmingCore/Network/WebHelpers/aw-sha1.h b/Sming/Core/Network/WebHelpers/aw-sha1.h similarity index 100% rename from Sming/SmingCore/Network/WebHelpers/aw-sha1.h rename to Sming/Core/Network/WebHelpers/aw-sha1.h diff --git a/Sming/SmingCore/Network/WebHelpers/base64.cpp b/Sming/Core/Network/WebHelpers/base64.cpp similarity index 100% rename from Sming/SmingCore/Network/WebHelpers/base64.cpp rename to Sming/Core/Network/WebHelpers/base64.cpp diff --git a/Sming/SmingCore/Network/WebHelpers/base64.h b/Sming/Core/Network/WebHelpers/base64.h similarity index 100% rename from Sming/SmingCore/Network/WebHelpers/base64.h rename to Sming/Core/Network/WebHelpers/base64.h diff --git a/Sming/SmingCore/Network/WebHelpers/escape.cpp b/Sming/Core/Network/WebHelpers/escape.cpp similarity index 100% rename from Sming/SmingCore/Network/WebHelpers/escape.cpp rename to Sming/Core/Network/WebHelpers/escape.cpp diff --git a/Sming/SmingCore/Network/WebHelpers/escape.h b/Sming/Core/Network/WebHelpers/escape.h similarity index 100% rename from Sming/SmingCore/Network/WebHelpers/escape.h rename to Sming/Core/Network/WebHelpers/escape.h diff --git a/Sming/SmingCore/Network/WebsocketClient.cpp b/Sming/Core/Network/WebsocketClient.cpp similarity index 100% rename from Sming/SmingCore/Network/WebsocketClient.cpp rename to Sming/Core/Network/WebsocketClient.cpp diff --git a/Sming/SmingCore/Network/WebsocketClient.h b/Sming/Core/Network/WebsocketClient.h similarity index 100% rename from Sming/SmingCore/Network/WebsocketClient.h rename to Sming/Core/Network/WebsocketClient.h diff --git a/Sming/SmingCore/SPI.h b/Sming/Core/SPI.h similarity index 100% rename from Sming/SmingCore/SPI.h rename to Sming/Core/SPI.h diff --git a/Sming/SmingCore/SPIBase.h b/Sming/Core/SPIBase.h similarity index 100% rename from Sming/SmingCore/SPIBase.h rename to Sming/Core/SPIBase.h diff --git a/Sming/SmingCore/SPISettings.h b/Sming/Core/SPISettings.h similarity index 100% rename from Sming/SmingCore/SPISettings.h rename to Sming/Core/SPISettings.h diff --git a/Sming/SmingCore/SPISoft.h b/Sming/Core/SPISoft.h similarity index 100% rename from Sming/SmingCore/SPISoft.h rename to Sming/Core/SPISoft.h diff --git a/Sming/SmingCore/SimpleTimer.h b/Sming/Core/SimpleTimer.h similarity index 100% rename from Sming/SmingCore/SimpleTimer.h rename to Sming/Core/SimpleTimer.h diff --git a/Sming/SmingCore/SmingCore.h b/Sming/Core/SmingCore.h similarity index 100% rename from Sming/SmingCore/SmingCore.h rename to Sming/Core/SmingCore.h diff --git a/Sming/SmingCore/SmingLocale.h b/Sming/Core/SmingLocale.h similarity index 100% rename from Sming/SmingCore/SmingLocale.h rename to Sming/Core/SmingLocale.h diff --git a/Sming/SmingCore/SystemClock.cpp b/Sming/Core/SystemClock.cpp similarity index 100% rename from Sming/SmingCore/SystemClock.cpp rename to Sming/Core/SystemClock.cpp diff --git a/Sming/SmingCore/SystemClock.h b/Sming/Core/SystemClock.h similarity index 100% rename from Sming/SmingCore/SystemClock.h rename to Sming/Core/SystemClock.h diff --git a/Sming/SmingCore/Timer.cpp b/Sming/Core/Timer.cpp similarity index 100% rename from Sming/SmingCore/Timer.cpp rename to Sming/Core/Timer.cpp diff --git a/Sming/SmingCore/Timer.h b/Sming/Core/Timer.h similarity index 100% rename from Sming/SmingCore/Timer.h rename to Sming/Core/Timer.h diff --git a/Sming/SmingCore/Wire.cpp b/Sming/Core/Wire.cpp similarity index 100% rename from Sming/SmingCore/Wire.cpp rename to Sming/Core/Wire.cpp diff --git a/Sming/SmingCore/Wire.h b/Sming/Core/Wire.h similarity index 100% rename from Sming/SmingCore/Wire.h rename to Sming/Core/Wire.h diff --git a/Sming/SmingCore/pgmspace.h b/Sming/Core/pgmspace.h similarity index 100% rename from Sming/SmingCore/pgmspace.h rename to Sming/Core/pgmspace.h diff --git a/Sming/SmingCore/twi.h b/Sming/Core/twi.h similarity index 100% rename from Sming/SmingCore/twi.h rename to Sming/Core/twi.h diff --git a/Sming/Libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp b/Sming/Libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp index bc524876a5..8189a767a4 100644 --- a/Sming/Libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp +++ b/Sming/Libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp @@ -36,7 +36,7 @@ * alonewolf07@gmail.com */ #include "Adafruit_NeoPixel.h" -#include "../../SmingCore/Wire.h" +#include Adafruit_NeoPixel::Adafruit_NeoPixel(uint16_t n, uint8_t p, uint8_t t) : numLEDs(n), numBytes(n * 3), pin(p), pixels(NULL) ,type(t), brightness(0), endTime(0) diff --git a/Sming/Libraries/Adafruit_PCD8544/Adafruit_PCD8544.cpp b/Sming/Libraries/Adafruit_PCD8544/Adafruit_PCD8544.cpp index 30227bbfda..06c45d4c5a 100644 --- a/Sming/Libraries/Adafruit_PCD8544/Adafruit_PCD8544.cpp +++ b/Sming/Libraries/Adafruit_PCD8544/Adafruit_PCD8544.cpp @@ -37,7 +37,7 @@ All text above, and the splash screen below must be included in any redistributi #include -#include "../../SmingCore/Wire.h" +#include #include "../Adafruit_GFX/Adafruit_GFX.h" diff --git a/Sming/Libraries/Adafruit_PCD8544/Adafruit_PCD8544.h b/Sming/Libraries/Adafruit_PCD8544/Adafruit_PCD8544.h index d573fde4e1..1f37f000a0 100644 --- a/Sming/Libraries/Adafruit_PCD8544/Adafruit_PCD8544.h +++ b/Sming/Libraries/Adafruit_PCD8544/Adafruit_PCD8544.h @@ -25,7 +25,7 @@ All text above, and the splash screen must be included in any redistribution #define WIRE_WRITE Wire.send #endif -#include "../../SmingCore/SPI.h" +#include #include "../Adafruit_GFX/Adafruit_GFX.h" #ifdef __SAM3X8E__ diff --git a/Sming/Libraries/BMP180/BMP180.h b/Sming/Libraries/BMP180/BMP180.h index 0bf57bf605..9f336f96af 100644 --- a/Sming/Libraries/BMP180/BMP180.h +++ b/Sming/Libraries/BMP180/BMP180.h @@ -24,7 +24,7 @@ along with this program. If not, see . #include -#include "../../SmingCore/Wire.h" +#include #define BMP180_Address 0x77 diff --git a/Sming/Libraries/DS18S20/ds18s20.h b/Sming/Libraries/DS18S20/ds18s20.h index 9a03bbc7a1..c3e26724ea 100644 --- a/Sming/Libraries/DS18S20/ds18s20.h +++ b/Sming/Libraries/DS18S20/ds18s20.h @@ -15,7 +15,7 @@ * @ingroup libraries * @{ */ -#include "../../SmingCore/Wire.h" +#include #define MAX_SENSORS 4 ///< Maximum quantity of sensors to read diff --git a/Sming/Libraries/LiquidCrystal/I2CIO.cpp b/Sming/Libraries/LiquidCrystal/I2CIO.cpp index a0afcd2419..00e063b504 100644 --- a/Sming/Libraries/LiquidCrystal/I2CIO.cpp +++ b/Sming/Libraries/LiquidCrystal/I2CIO.cpp @@ -32,7 +32,7 @@ #include -#include "../../SmingCore/Wire.h" +#include #include "I2CIO.h" // CLASS VARIABLES diff --git a/Sming/Libraries/RCSwitch/RCSwitch.cpp b/Sming/Libraries/RCSwitch/RCSwitch.cpp index 429a919654..098f4293d6 100644 --- a/Sming/Libraries/RCSwitch/RCSwitch.cpp +++ b/Sming/Libraries/RCSwitch/RCSwitch.cpp @@ -32,7 +32,7 @@ */ #include -//#include <../../SmingCore/SmingCore.h> +//#include #include "RCSwitch.h" /* Format for protocol definitions: diff --git a/Sming/Libraries/SI7021/SI7021.h b/Sming/Libraries/SI7021/SI7021.h index bc133cf37c..494c5318fe 100644 --- a/Sming/Libraries/SI7021/SI7021.h +++ b/Sming/Libraries/SI7021/SI7021.h @@ -3,7 +3,7 @@ #define si7021_h #include -#include "../../SmingCore/Wire.h" +#include typedef struct si7021_env { int temperature; diff --git a/Sming/Libraries/Servo/Servo.h b/Sming/Libraries/Servo/Servo.h index 4ab232924d..76437e5ce4 100644 --- a/Sming/Libraries/Servo/Servo.h +++ b/Sming/Libraries/Servo/Servo.h @@ -11,7 +11,7 @@ */ #ifndef LIB_SERVO_H_ #define LIB_SERVO_H_ -#include "../../SmingCore/SmingCore.h" +#include #include "ServoChannel.h" #define SERVO_CHANNEL_NUM_MAX 4 ///< maximum number of servo channels diff --git a/Sming/Libraries/Servo/ServoChannel.h b/Sming/Libraries/Servo/ServoChannel.h index 624c22a411..9b519a3fd9 100644 --- a/Sming/Libraries/Servo/ServoChannel.h +++ b/Sming/Libraries/Servo/ServoChannel.h @@ -12,7 +12,7 @@ #ifndef LIB_SERVOCHANNEL_H_ #define LIB_SERVOCHANNEL_H_ -#include "../../SmingCore/SmingCore.h" +#include #define DEFAULTMAXVALUE 2300 ///< default max value for output in us #define DEFAULTMINVALUE 700 ///< default min value for output in us diff --git a/Sming/Libraries/TFT_ILI9163C/TFT_ILI9163C.cpp b/Sming/Libraries/TFT_ILI9163C/TFT_ILI9163C.cpp index 3d00ff27cc..87982c0d8f 100644 --- a/Sming/Libraries/TFT_ILI9163C/TFT_ILI9163C.cpp +++ b/Sming/Libraries/TFT_ILI9163C/TFT_ILI9163C.cpp @@ -2,8 +2,8 @@ #include -#include "../../SmingCore/Digital.h" -#include "../../SmingCore/SPI.h" +#include +#include #include "pins_arduino.h" #include "wiring_private.h" diff --git a/Sming/Libraries/WS2812/WS2812.h b/Sming/Libraries/WS2812/WS2812.h index 6fb7eb0567..cb77709db6 100644 --- a/Sming/Libraries/WS2812/WS2812.h +++ b/Sming/Libraries/WS2812/WS2812.h @@ -1,7 +1,7 @@ #ifndef WS2812_h #define WS2812_h -#include "../../SmingCore/SmingCore.h" +#include // Byte triples in the buffer are interpreted as R G B values and sent to the hardware as G R B. int ICACHE_FLASH_ATTR ws2812_writergb(uint8_t gpio, char *buffer, size_t length); diff --git a/Sming/Makefile b/Sming/Makefile index 9052dad13f..721b6ceb83 100644 --- a/Sming/Makefile +++ b/Sming/Makefile @@ -102,14 +102,14 @@ LIBRARY_SUBMODULES := $(filter $(LIBRARY_SUBMODULES), $(ARDUINO_LIBRARIES)) LIBRARY_SUBMODULES := $(foreach lib,$(LIBRARY_SUBMODULES),Libraries/$(lib)/.submodule) # which modules (subdirectories) to include in compiling -SMING_MODULES := $(ARCH_CORE) $(ARCH_BASE)/Platform Platform SmingCore +SMING_MODULES := $(ARCH_CORE) $(ARCH_BASE)/Platform Platform Core SMING_MODULES := $(foreach mod,$(SMING_MODULES),$(call ScanModuleDirs,$(mod))) MODULES := System $(ARCH_SYS) Wiring $(SMING_MODULES) $(MODULES) MODULES += $(wildcard Services/*/) MODULES += $(foreach lib,$(ARDUINO_LIBRARIES),Libraries/$(lib) Libraries/$(lib)/src) MODULES := $(MODULES:/=) -EXTRA_INCDIR := System/include Wiring Libraries SmingCore \ +EXTRA_INCDIR := System/include Wiring Libraries Core \ $(ARCH_BASE) $(ARCH_SYS)/include \ $(COMPONENTS) . $(EXTRA_INCDIR) @@ -265,7 +265,7 @@ tools-clean: $(TOOLS_CLEAN) rwildcard = $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d)) # Files that should follow our coding standards -CS_DIRS := SmingCore Arch/*/Core Arch/*/Platform ../samples +CS_DIRS := Core Arch/*/Core Arch/*/Platform ../samples CS_FILES := $(call rwildcard,$(patsubst %,%/*,$(CS_DIRS)),*.cpp *.h *.c) .PHONY: cs diff --git a/Sming/Makefile-app.mk b/Sming/Makefile-app.mk index 90d2dae2bb..5b3f920296 100644 --- a/Sming/Makefile-app.mk +++ b/Sming/Makefile-app.mk @@ -45,7 +45,7 @@ TARGET = app MODULES ?= app # default to app if not set by user EXTRA_INCDIR ?= include # default to include if not set by user -SMING_INCDIR := System/include Wiring Libraries SmingCore Platform \ +SMING_INCDIR := System/include Wiring Libraries Core Platform \ Libraries/Adafruit_GFX Libraries/Adafruit_Sensor EXTRA_INCDIR += $(SMING_HOME) $(addprefix $(SMING_HOME)/,$(SMING_INCDIR)) \ diff --git a/samples/DFPlayerMini/app/application.cpp b/samples/DFPlayerMini/app/application.cpp index d66b2d3b72..a32e84b915 100644 --- a/samples/DFPlayerMini/app/application.cpp +++ b/samples/DFPlayerMini/app/application.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #define GPIO_LED 2 diff --git a/samples/Display_TM1637/app/application.cpp b/samples/Display_TM1637/app/application.cpp index 2c9b8bf64d..d15d198263 100644 --- a/samples/Display_TM1637/app/application.cpp +++ b/samples/Display_TM1637/app/application.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include // Module connection pins (Digital Pins) diff --git a/samples/Nextion_Button/app/application.cpp b/samples/Nextion_Button/app/application.cpp index 3e21967960..c766f68398 100644 --- a/samples/Nextion_Button/app/application.cpp +++ b/samples/Nextion_Button/app/application.cpp @@ -1,6 +1,6 @@ using namespace std; #include -#include +#include #include #include diff --git a/samples/SmtpClient/app/application.cpp b/samples/SmtpClient/app/application.cpp index 6bb243c7bb..ef629bb80b 100644 --- a/samples/SmtpClient/app/application.cpp +++ b/samples/SmtpClient/app/application.cpp @@ -1,6 +1,6 @@ #include -#include "SmingCore/SmingCore.h" -#include "SmingCore/Network/SmtpClient.h" +#include +#include // If you want, you can define WiFi settings globally in Eclipse Environment Variables #ifndef WIFI_SSID From acf29f324e012c4464329e3e2c3f38100da5e8b0 Mon Sep 17 00:00:00 2001 From: mikee47 Date: Mon, 29 Apr 2019 16:47:35 +0100 Subject: [PATCH 08/22] Add help documenation to makefiles * Document relevant targets using `##` comments, groups with `##@` * Tag configuration variables using `CONFIG_VARS` so values can be examined (using `list-config`) * Add `help` and `list-config` targets * Add `rebuild` target for framework (app already has one) * Move `kill_term`, `terminal` and `decode-stacktrace` targets into `Makefile-app.mk` * Use CURDIR instead of fabricating CURRENT_DIR * Add `FixPath` function to deal with Windows/POSIX path conversion --- Sming/Arch/Esp8266/app.mk | 96 +++++++++++++++++++----------------- Sming/Arch/Esp8266/build.mk | 15 ++++-- Sming/Arch/Esp8266/sming.mk | 4 ++ Sming/Makefile | 63 +++++++++++++++++------- Sming/Makefile-app.mk | 74 +++++++++++++++++++++++----- Sming/build.mk | 98 +++++++++++++++++++++++++++++++++---- Sming/building.md | 77 ++++++++--------------------- 7 files changed, 282 insertions(+), 145 deletions(-) diff --git a/Sming/Arch/Esp8266/app.mk b/Sming/Arch/Esp8266/app.mk index f9ab2b8813..69b99201c6 100644 --- a/Sming/Arch/Esp8266/app.mk +++ b/Sming/Arch/Esp8266/app.mk @@ -8,10 +8,13 @@ ifndef ESP_HOME $(error ESP_HOME variable is not set to a valid directory.) endif -.PHONY: all checkdirs app spiff_update spiff_clean clean kill_term terminal gdb -all: libsming checkdirs app +##@Building + +.PHONY: all +all: libsming checkdirs app ##(default) Build application # rBoot options, overwrite them in the projects Makefile-user.mk +CONFIG_VARS += RBOOT_BIG_FLASH RBOOT_TWO_ROMS RBOOT_RTC_ENABLED RBOOT_GPIO_ENABLED RBOOT_GPIO_SKIP_ENABLED RBOOT_BIG_FLASH ?= 1 RBOOT_TWO_ROMS ?= 0 RBOOT_RTC_ENABLED ?= 0 @@ -34,6 +37,7 @@ endif # RBOOT_SPIFFS_1 + SPIFF_SIZE # BOOT_ROM2_ADDR = 0x310000 +CONFIG_VARS += RBOOT_SILENT RBOOT_ROM_0 RBOOT_ROM_1 RBOOT_LD_0 RBOOT_LD_1 RBOOT_SILENT ?= 0 RBOOT_ROM_0 ?= rom0 RBOOT_ROM_1 ?= rom1 @@ -41,6 +45,7 @@ RBOOT_LD_0 ?= rboot.rom0.ld RBOOT_LD_1 ?= rom1.ld # +CONFIG_VARS += RBOOT_SPIFFS_0 RBOOT_SPIFFS_1 RBOOT_SPIFFS_0 ?= 0x100000 RBOOT_SPIFFS_1 ?= 0x300000 @@ -114,6 +119,7 @@ $(RBOOT_BIN): # => SPIFFS +CONFIG_VARS += DISABLE_SPIFFS SPIFF_BIN_OUT DISABLE_SPIFFS ?= 0 SPIFF_BIN_OUT ?= spiff_rom SPIFF_BIN_OUT := $(FW_BASE)/$(SPIFF_BIN_OUT).bin @@ -123,6 +129,7 @@ CFLAGS += -DRBOOT_SPIFFS_1=$(RBOOT_SPIFFS_1) CUSTOM_TARGETS += $(SPIFF_BIN_OUT) # => LWIP +CONFIG_VARS += ENABLE_CUSTOM_LWIP LIBLWIP ENABLE_CUSTOM_LWIP ?= 1 ifeq ($(ENABLE_CUSTOM_LWIP), 0) LIBLWIP := lwip @@ -156,6 +163,7 @@ $(LIBLWIP_DST): endif # => GDB +CONFIG_VARS += ENABLE_GDB APPCODE += $(ARCH_COMPONENTS)/gdbstub/appcode EXTRA_INCDIR += $(ARCH_COMPONENTS)/gdbstub/include ifeq ($(ENABLE_GDB), 1) @@ -175,12 +183,14 @@ GDB := trap '' INT; $(GDB) -x $(ARCH_COMPONENTS)/gdbstub/gdbcmds -b $(COM_SPEED_ # => WPS +CONFIG_VARS += ENABLE_WPS ifeq ($(ENABLE_WPS),1) CFLAGS += -DENABLE_WPS=1 LIBS += wps endif # => Custom heap +CONFIG_VARS += ENABLE_CUSTOM_HEAP ENABLE_CUSTOM_HEAP ?= 0 ifeq ($(ENABLE_CUSTOM_HEAP),1) LIBMAIN := mainmm @@ -211,6 +221,7 @@ LIBS += $(LIBMAIN) # SSL support using axTLS +CONFIG_VARS += ENABLE_SSL SSL_DEBUG ifeq ($(ENABLE_SSL),1) LIBAXTLS := axtls LIBS += $(LIBAXTLS) @@ -230,12 +241,13 @@ $(LIBAXTLS_DST): include/ssl/private_key.h: $(vecho) "Generating unique certificate and key. This may take some time" - $(Q) mkdir -p $(CURRENT_DIR)/include/ssl/ - AXDIR=$(CURRENT_DIR)/include/ssl/ $(ARCH_COMPONENTS)/axtls-8266/axtls-8266/tools/make_certs.sh + $(Q) mkdir -p $(CURDIR)/include/ssl/ + AXDIR=$(CURDIR)/include/ssl/ $(ARCH_COMPONENTS)/axtls-8266/axtls-8266/tools/make_certs.sh endif # => PWM +CONFIG_VARS += ENABLE_CUSTOM_PWM ENABLE_CUSTOM_PWM ?= 1 ifeq ($(ENABLE_CUSTOM_PWM), 1) LIBPWM := pwm_open @@ -253,8 +265,6 @@ LIBS += $(LIBPWM) # LIBS := microc microgcc hal phy pp net80211 mqttc wpa $(LIBSMING) crypto smartconfig $(EXTRA_LIBS) $(LIBS) -LIBS := $(addprefix -l,$(LIBS)) - # linker flags used to generate the main object file LDFLAGS = -nostdlib -u call_user_start -u Cache_Read_Enable_New -u spiffs_get_storage_config -u custom_crash_callback \ -Wl,-static -Wl,--gc-sections -Wl,-Map=$(basename $@).map -Wl,-wrap,system_restart_local @@ -275,10 +285,9 @@ include $(SMING_HOME)/modules.mk # Add APPCODE objects and targets $(call ScanModules,$(APPCODE)) +.PHONY: app app: $(CUSTOM_TARGETS) $(RBOOT_ROM_0) $(RBOOT_ROM_1) $(FW_FILE_1) $(FW_FILE_2) -spiff_update: spiff_clean $(SPIFF_BIN_OUT) - # => Firmware images $(RBOOT_ROM_0): $(TARGET_OUT_0) $(vecho) "E2 $@" @@ -291,7 +300,7 @@ $(RBOOT_ROM_1): $(TARGET_OUT_1) $(TARGET_OUT_0): $(APP_AR) $(vecho) "LD $@" $(LD) -L$(USER_LIBDIR) -L$(SDK_LIBDIR) -L$(BUILD_BASE) -L$(ARCH_BASE)/Compiler/ld \ - -T$(RBOOT_LD_0) $(LDFLAGS) -Wl,--start-group $(APP_AR) $(LIBS) -Wl,--end-group -o $@ + -T$(RBOOT_LD_0) $(LDFLAGS) -Wl,--start-group $(APP_AR) $(addprefix -l,$(LIBS)) -Wl,--end-group -o $@ $(Q) $(MEMANALYZER) $@ > $(FW_MEMINFO_NEW) @@ -315,7 +324,7 @@ $(TARGET_OUT_0): $(APP_AR) $(TARGET_OUT_1): $(APP_AR) $(vecho) "LD $@" $(LD) -L$(USER_LIBDIR) -L$(SDK_LIBDIR) -L$(BUILD_BASE) -L$(ARCH_BASE)/Compiler/ld \ - -T$(RBOOT_LD_1) $(LDFLAGS) -Wl,--start-group $(APP_AR) $(LIBS) -Wl,--end-group -o $@ + -T$(RBOOT_LD_1) $(LDFLAGS) -Wl,--start-group $(APP_AR) $(addprefix -l,$(LIBS)) -Wl,--end-group -o $@ # recreate it from 0, since you get into problems with same filenames $(APP_AR): $(OBJ) @@ -323,21 +332,30 @@ $(APP_AR): $(OBJ) $(Q) test ! -f $@ || rm $@ $(AR) rcsP $@ $^ -# .PHONY: libsming -libsming: $(LIBSMING_DST) +libsming: $(LIBSMING_DST) ##Build the Sming framework and user libraries $(LIBSMING_DST): $(vecho) "(Re)compiling Sming. Enabled features: $(SMING_FEATURES). This may take some time" $(Q) $(MAKE) -C $(SMING_HOME) clean V=$(V) ENABLE_SSL=$(ENABLE_SSL) $(Q) $(MAKE) -C $(SMING_HOME) V=$(V) ENABLE_SSL=$(ENABLE_SSL) +.PHONY: rebuild +rebuild: clean all ##Re-build your application + +.PHONY: checkdirs checkdirs: | $(BUILD_DIR) $(FW_BASE) $(BUILD_DIR) $(FW_BASE): $(Q) mkdir -p $@ -spiff_clean: +##@Cleaning + +.PHONY: spiff_update +spiff_update: spiff_clean $(SPIFF_BIN_OUT) ##Rebuild the SPIFFS filesystem image + +.PHONY: spiff_clean +spiff_clean: ##Remove SPIFFS image file $(vecho) "Cleaning $(SPIFF_BIN_OUT)" $(Q) rm -rf $(SPIFF_BIN_OUT) @@ -358,19 +376,23 @@ else endif -# Flashing +##@Flashing -flashboot: libsming $(RBOOT_BIN) +.PHONY: flashboot +flashboot: libsming $(RBOOT_BIN) ##Write just the rBoot boot sector $(WRITE_FLASH) 0x00000 $(RBOOT_BIN) -flashconfig: kill_term - $(vecho) "Deleting rBoot config sector" +.PHONY: flashconfig +flashconfig: kill_term ##Erase the rBoot config sector + $(vecho) "Erasing rBoot config sector" $(WRITE_FLASH) 0x01000 $(SDK_BASE)/bin/blank.bin - -flashapp: all kill_term + +.PHONY: flashapp +flashapp: all kill_term ##Write just the application image $(WRITE_FLASH) $(ROM_0_ADDR) $(RBOOT_ROM_0) -flashfs: libsming $(SPIFF_BIN_OUT) +.PHONY: flashfs +flashfs: libsming $(SPIFF_BIN_OUT) ##Write just the SPIFFS filesystem image ifeq ($(DISABLE_SPIFFS), 1) $(vecho) "SPIFFS are not enabled!" else @@ -383,7 +405,9 @@ FLASH_CHUNKS += $(ROM_0_ADDR) $(RBOOT_ROM_0) ifneq ($(DISABLE_SPIFFS), 1) FLASH_CHUNKS += $(RBOOT_SPIFFS_0) $(SPIFF_BIN_OUT) endif -flash: all kill_term + +.PHONY: flash +flash: all kill_term ##Write the rBoot boot sector, application image and (if enabled) SPIFFS image $(WRITE_FLASH) $(FLASH_CHUNKS) ifeq ($(ENABLE_GDB), 1) $(GDB) @@ -391,41 +415,23 @@ else $(TERMINAL) endif -otaserver: all - $(vecho) "Starting OTA server for TESTING" - $(Q) cd $(FW_BASE) && python -m SimpleHTTPServer $(SERVER_OTA_PORT) - -kill_term: - $(vecho) "Killing Terminal to free $(COM_PORT)" - -$(Q) $(KILL_TERM) - -terminal: kill_term - $(TERMINAL) - -gdb: kill_term - $(GDB) - -decode-stacktrace: - @echo "Decode stack trace: Paste stack trace here" - $(Q) python $(ARCH_TOOLS)/decode-stacktrace.py $(TARGET_OUT_0) - # Wipe flash FLASH_INIT_CHUNKS := $(INIT_BIN_ADDR) $(SDK_BASE)/bin/esp_init_data_default.bin FLASH_INIT_CHUNKS += $(BLANK_BIN_ADDR) $(SDK_BASE)/bin/blank.bin ifneq ($(DISABLE_SPIFFS), 1) FLASH_INIT_CHUNKS += $(RBOOT_SPIFFS_0) $(ARCH_BASE)/Compiler/data/blankfs.bin endif -flashinit: + +.PHONY: flashinit +flashinit: ##Erase your device's flash memory and reset system configuration area to defaults $(vecho) "Flash init data default and blank data." $(vecho) "DISABLE_SPIFFS = $(DISABLE_SPIFFS)" $(ERASE_FLASH) $(WRITE_FLASH) $(FLASH_INIT_CHUNKS) +##@Cleaning -rebuild: clean all - -# Remove build artifacts -clean: +.PHONY: clean +clean: ##Remove all generated build files $(Q) rm -rf $(BUILD_BASE) $(Q) rm -rf $(FW_BASE) - diff --git a/Sming/Arch/Esp8266/build.mk b/Sming/Arch/Esp8266/build.mk index 257f2db1a9..870a55f419 100644 --- a/Sming/Arch/Esp8266/build.mk +++ b/Sming/Arch/Esp8266/build.mk @@ -15,11 +15,14 @@ endif ## MacOS / Linux: # ESP_HOME = /opt/esp-open-sdk -ifeq ($(OS),Windows_NT) - # Convert Windows paths to POSIX paths - ESP_HOME := $(subst \,/,$(addprefix /,$(subst :,,$(ESP_HOME)))) - ESP_HOME := $(subst //,/,$(ESP_HOME)) -endif +#ifeq ($(OS),Windows_NT) +# # Convert Windows paths to POSIX paths +# ESP_HOME := $(subst \,/,$(addprefix /,$(subst :,,$(ESP_HOME)))) +# ESP_HOME := $(subst //,/,$(ESP_HOME)) +#endif + +CONFIG_VARS += ESP_HOME +ESP_HOME := $(call FixPath,$(ESP_HOME)) export ESP_HOME @@ -41,6 +44,7 @@ GDB := $(TOOLSPEC)gdb CFLAGS_COMMON += -nostdlib -mlongcalls -mtext-section-literals CFLAGS += -D__ets__ -DICACHE_FLASH -DUSE_OPTIMIZE_PRINTF -DESP8266=1 +CONFIG_VARS += MFORCE32 MFORCE32 := $(shell $(CC) --help=target | grep mforce-l32) ifneq ($(MFORCE32),) # Your compiler supports the -mforce-l32 flag which means that @@ -54,6 +58,7 @@ endif # => 'Internal' SDK - for SDK Version 3+ as submodule in Sming repository # SDK_BASE just needs to point into our repo as it's overridden with the correct submodule path # This provides backward-compatiblity, so $(SMING)/third-party/ESP8266_NONOS_SDK) still works +CONFIG_VARS += SDK_BASE SDK_INTERNAL ifneq (,$(findstring $(abspath $(SMING_HOME)),$(abspath $(SDK_BASE)))) SDK_COMPONENT := $(ARCH_COMPONENTS)/Sdk/ESP8266_NONOS_SDK SDK_BASE := $(SMING_HOME)/$(SDK_COMPONENT) diff --git a/Sming/Arch/Esp8266/sming.mk b/Sming/Arch/Esp8266/sming.mk index 3c04565ca3..2a17ae468e 100644 --- a/Sming/Arch/Esp8266/sming.mk +++ b/Sming/Arch/Esp8266/sming.mk @@ -32,6 +32,7 @@ MODULES += $(SPIFFS_SMING) $(SPIFFS_BASE)/src # => ESP8266_new_pwm +CONFIG_VARS += ENABLE_CUSTOM_PWM ENABLE_CUSTOM_PWM ?= 1 ifeq ($(ENABLE_CUSTOM_PWM), 1) PWM_BASE := $(ARCH_COMPONENTS)/pwm @@ -52,6 +53,7 @@ endif # => umm_malloc (custom heap allocation) +CONFIG_VARS += ENABLE_CUSTOM_HEAP ENABLE_CUSTOM_HEAP ?= 0 ifeq ($(ENABLE_CUSTOM_HEAP), 1) CUSTOM_HEAP_BASE := $(ARCH_COMPONENTS)/custom_heap @@ -71,6 +73,7 @@ endif # => Open Source LWIP +CONFIG_VARS += ENABLE_CUSTOM_LWIP ENABLE_LWIP_DEBUG ENABLE_ESPCONN ENABLE_CUSTOM_LWIP ?= 1 ENABLE_ESPCONN ?= 0 ifeq ($(ENABLE_CUSTOM_LWIP), 0) @@ -121,6 +124,7 @@ lwip-clean: endif # => SSL support using axTLS +CONFIG_VARS += ENABLE_SSL SSL_DEBUG ENABLE_SSL ?= 0 ifeq ($(ENABLE_SSL),1) AXTLS_BASE := $(ARCH_COMPONENTS)/axtls-8266/axtls-8266 diff --git a/Sming/Makefile b/Sming/Makefile index 721b6ceb83..b081f743f9 100644 --- a/Sming/Makefile +++ b/Sming/Makefile @@ -20,8 +20,10 @@ endif # MacOS / Linux # SMING_HOME = /opt/esp-open-sdk +##@Building + .PHONY: all -all: checkdirs libsming tools +all: checkdirs libsming tools ##(default) Build the Sming library, user libraries, Arduino libraries and tools include $(SMING_HOME)/build.mk @@ -45,6 +47,7 @@ EXTRA_INCDIR := SAMPLES_DIRS := $(shell ls -1 ../samples) DOXYGEN := $(shell command -v doxygen 2> /dev/null) +CONFIG_VARS += ENABLE_WPS ifeq ($(ENABLE_WPS), 1) CFLAGS += -DENABLE_WPS=1 endif @@ -126,9 +129,8 @@ endef $(foreach lib,$(LIBS),$(eval $(call UserLibrary,$(lib)))) -# Main Sming library .PHONY: libsming -libsming: $(APP_AR) $(CUSTOM_TARGETS) +libsming: $(APP_AR) $(CUSTOM_TARGETS) ##Build the Sming framework and user libraries $(APP_AR): $(OBJ) $(vecho) "AR $@" @@ -148,29 +150,33 @@ checkdirs: submodules reload | $(BUILD_DIR) $(BUILD_DIR): $(Q) mkdir -p $@ +##@Cleaning + .PHONY: dist-clean -dist-clean: clean submodules-clean tools-clean user-lib-clean samples-clean +dist-clean: clean submodules-clean tools-clean user-lib-clean samples-clean ##Clean everything .PHONY: clean -clean: $(CLEAN) +clean: $(CLEAN) ##Remove all generated build files $(Q) rm -f $(APP_AR) $(Q) rm -f $(TARGET_OUT) $(Q) rm -rf $(BUILD_BASE) .PHONY: user-lib-clean -user-lib-clean: +user-lib-clean: ##Remove generated user libraries -$(Q) rm -f $(wildcard $(USER_LIBDIR)/lib*.a) $(APP_AR) $(Q) $(GIT) checkout $(USER_LIBDIR) +##@Building + .PHONY: test -test: Basic_Blink Basic_rBoot Basic_Ssl Basic_HwPWM +test: Basic_Blink Basic_rBoot Basic_Ssl Basic_HwPWM ##Build a few sample applications # => Documentation DOCS_DIR := ../docs .PHONY: wiki api docs -docs: wiki api +docs: wiki api ##Build the Sming API and Wiki documentation wiki: $(DOCS_DIR)/wiki/Home.md api: $(DOCS_DIR)/api/sming/index.html @@ -213,9 +219,10 @@ define TryApplyPatch endef .PHONY: submodules submodules-clean -submodules: $(LIBRARY_SUBMODULES) $(addsuffix /.submodule,$(SUBMODULES)) +submodules: $(LIBRARY_SUBMODULES) $(addsuffix /.submodule,$(SUBMODULES)) ##Fetch all third-party submodules (but do not build) -submodules-clean: +##@Cleaning +submodules-clean: ##Reset state of all third-party submodules -$(Q) rm -rf $(SUBMODULES) $(GIT) checkout Components -$(Q) rm -rf Libraries @@ -244,20 +251,30 @@ reload: $(MAKE) -C $(SMING_HOME) $(MAKECMDGOALS) RELOAD_MKFILE=0; \ fi +##@Building .PHONY: samples $(SAMPLES_DIRS) samples-clean -samples: | $(SAMPLES_DIRS) +samples: | $(SAMPLES_DIRS) ##Build all sample applications $(SAMPLES_DIRS): $(Q) $(MAKE) -C $(SMING_HOME)/../samples/$@ -samples-clean: +##@Cleaning +samples-clean: ##Invoke 'clean' on all sample applications -$(Q) for dir in $(SAMPLES_DIRS); do \ $(MAKE) -C $(SMING_HOME)/../samples/$$dir clean; \ done -.PHONY: tools tools-clean -tools: $(TOOLS) -tools-clean: $(TOOLS_CLEAN) +##@Building +.PHONY: tools +tools: $(TOOLS) ##Build all required internal tools + +##@Cleaning +.PHONY: tools-clean +tools-clean: $(TOOLS_CLEAN) ##@Cleaning Remove intermediate files created when building tools + +##@Building +.PHONY: rebuild +rebuild: clean all ##Re-build the Sming libraries # Recursive wildcard search # $1 -> directory @@ -265,11 +282,23 @@ tools-clean: $(TOOLS_CLEAN) rwildcard = $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d)) # Files that should follow our coding standards -CS_DIRS := Core Arch/*/Core Arch/*/Platform ../samples +CS_DIRS := Core Platform Arch/*/Core Arch/*/Platform ../samples CS_FILES := $(call rwildcard,$(patsubst %,%/*,$(CS_DIRS)),*.cpp *.h *.c) +##@Developer + .PHONY: cs -cs: +cs: ##Apply coding style to all core files $(Q) for FILE in $(CS_FILES); do \ clang-format -i -style=file $$FILE; \ done + +##@Help + +.PHONY: list-config +list-config: ##Print the contents of internal build variables + $(call ListConfig) + +.PHONY: help +help: ##Show this help summary + $(call PrintHelp) diff --git a/Sming/Makefile-app.mk b/Sming/Makefile-app.mk index 5b3f920296..bfc79682ca 100644 --- a/Sming/Makefile-app.mk +++ b/Sming/Makefile-app.mk @@ -8,6 +8,7 @@ ### Defaults ### +CONFIG_VARS += SERVER_OTA_PORT SERVER_OTA_PORT ?= 9999 ## COM port parameters @@ -28,14 +29,16 @@ COMPONENTS := $(SMING_HOME)/$(COMPONENTS) BUILD_BASE := out/build FW_BASE := out/firmware -CURRENT_DIR := $(dir $(abspath $(firstword $(MAKEFILE_LIST)))) +CONFIG_VARS += CURDIR MAKE_VERSION SHELL -SPIFF_FILES ?= files +# +CONFIG_VARS += SPIFF_FILES +SPIFF_FILES ?= files -#Firmware memory layout info files -FW_MEMINFO_NEW = $(FW_BASE)/fwMeminfo.new -FW_MEMINFO_OLD = $(FW_BASE)/fwMeminfo.old -FW_MEMINFO_SAVED = out/fwMeminfo +# Firmware memory layout info files +FW_MEMINFO_NEW := $(FW_BASE)/fwMeminfo.new +FW_MEMINFO_OLD := $(FW_BASE)/fwMeminfo.old +FW_MEMINFO_SAVED := out/fwMeminfo # name for the target project TARGET = app @@ -52,20 +55,67 @@ EXTRA_INCDIR += $(SMING_HOME) $(addprefix $(SMING_HOME)/,$(SMING_INCDIR)) \ $(ARCH_BASE) $(ARCH_SYS)/include $(ARCH_CORE) $(COMPONENTS) # we will use global WiFi settings from Eclipse Environment Variables, if possible -WIFI_SSID ?= "" -WIFI_PWD ?= "" +CONFIG_VARS += WIFI_SSID WIFI_PWD +WIFI_SSID ?= "" +WIFI_PWD ?= "" ifneq ($(WIFI_SSID), "") - CFLAGS += -DWIFI_SSID=\"$(WIFI_SSID)\" + CFLAGS += -DWIFI_SSID=\"$(WIFI_SSID)\" endif ifneq ($(WIFI_PWD), "") - CFLAGS += -DWIFI_PWD=\"$(WIFI_PWD)\" + CFLAGS += -DWIFI_PWD=\"$(WIFI_PWD)\" endif + +# +CONFIG_VARS += DISABLE_SPIFFS ifeq ($(DISABLE_SPIFFS), 1) - CFLAGS += -DDISABLE_SPIFFS=1 + CFLAGS += -DDISABLE_SPIFFS=1 endif # => Serial -CFLAGS += -DCOM_SPEED_SERIAL=$(COM_SPEED_SERIAL) $(USER_CFLAGS) +CONFIG_VARS += COM_SPEED_SERIAL +CFLAGS += -DCOM_SPEED_SERIAL=$(COM_SPEED_SERIAL) + +# +CONFIG_VARS += USER_CFLAGS +CFLAGS += $(USER_CFLAGS) include $(ARCH_BASE)/app.mk +# +.PHONY: kill_term +kill_term: + $(vecho) "Killing Terminal to free $(COM_PORT)" + -$(Q) $(KILL_TERM) + +##@Tools + +.PHONY: terminal +terminal: kill_term ##Open the serial terminal + $(TERMINAL) + +.PHONY: gdb +gdb: kill_term ##Run the debugger console + $(GDB) + +.PHONY: decode-stacktrace +decode-stacktrace: ##If a crash occurred, use this option then cut & paste dump text as prompted + @echo "Decode stack trace: Paste stack trace here" + $(Q) python $(ARCH_TOOLS)/decode-stacktrace.py $(TARGET_OUT_0) + +##@Testing + +.PHONY: otaserver +otaserver: all ##Launch a simple python HTTP server for testing OTA updates + $(vecho) "Starting OTA server for TESTING" + $(Q) cd $(FW_BASE) && python -m SimpleHTTPServer $(SERVER_OTA_PORT) + +##@Help + +.PHONY: list-config +list-config: ##Print the contents of internal build variables + $(call ListConfig) + +# => Help +.PHONY: help +help: ##Show this help summary + $(call PrintHelp) diff --git a/Sming/build.mk b/Sming/build.mk index 3093806e86..ad3a12fb9c 100644 --- a/Sming/build.mk +++ b/Sming/build.mk @@ -1,10 +1,14 @@ # Build environment definitions +# Add configuration variable names to CONFIG_VARS as they are encountered (see ListConfig macro) +CONFIG_VARS := + # +CONFIG_VARS += SMING_ARCH SMING_ARCH ?= Esp8266 MAKECMDGOALS ?= all -$(info Building '$(MAKECMDGOALS)' for '$(SMING_ARCH)' architecture) +$(info Invoking '$(MAKECMDGOALS)' for '$(SMING_ARCH)' architecture) LIBS ?= CUSTOM_TARGETS ?= @@ -15,12 +19,7 @@ TOOLS_CLEAN ?= # Detect OS and build environment UNAME := $(shell uname -s) -ifeq ($(OS),Windows_NT) - # Convert Windows paths to POSIX paths - SMING_HOME := $(subst \,/,$(addprefix /,$(subst :,,$(SMING_HOME)))) - SMING_HOME := $(subst //,/,$(SMING_HOME)) -endif - +CONFIG_VARS += UNAME ifneq ($(filter MINGW32_NT%,$(UNAME)),) UNAME := Windows else ifneq ($(filter CYGWIN%,$(UNAME)),) @@ -40,6 +39,18 @@ else ifeq ($(UNAME), Freebsd) #BSD endif + +# Convert Windows paths to POSIX paths +CONFIG_VARS += OS +ifeq ($(OS),Windows_NT) +FixPath = $(subst //,/,$(subst \,/,$(addprefix /,$(subst :,,$1)))) +else +FixPath = $1 +endif + +CONFIG_VARS += SMING_HOME +SMING_HOME := $(call FixPath,$(realpath $(SMING_HOME))) + # OS specific configuration ifeq ($(UNAME),Windows) # Windows detected @@ -75,12 +86,15 @@ GIT ?= git ### Debug output parameters # By default `debugf` does not print file name and line number. If you want this enabled set the directive below to 1 +CONFIG_VARS += DEBUG_PRINT_FILENAME_AND_LINE DEBUG_PRINT_FILENAME_AND_LINE ?= 0 # Default debug verbose level is INFO, where DEBUG=3 INFO=2 WARNING=1 ERROR=0 +CONFIG_VARS += DEBUG_VERBOSE_LEVEL DEBUG_VERBOSE_LEVEL ?= 2 # Disable CommandExecutor functionality if not used and save some ROM and RAM +CONFIG_VARS += ENABLE_CMD_EXECUTOR ENABLE_CMD_EXECUTOR ?= 1 V ?= $(VERBOSE) @@ -97,14 +111,17 @@ CFLAGS_COMMON = -Wl,-EL -finline-functions -fdata-sections -ffunction-sections # compiler flags using during compilation of source files. Add '-pg' for debugging CFLAGS = -Wall -Wundef -Wpointer-arith -Wno-comment $(CFLAGS_COMMON) \ -DARDUINO=106 -DENABLE_CMD_EXECUTOR=$(ENABLE_CMD_EXECUTOR) -DSMING_INCLUDED=1 +CONFIG_VARS += STRICT ifneq ($(STRICT),1) -CFLAGS += -Werror -Wno-sign-compare -Wno-parentheses -Wno-unused-variable -Wno-unused-but-set-variable -Wno-strict-aliasing -Wno-return-type -Wno-maybe-uninitialized + CFLAGS += -Werror -Wno-sign-compare -Wno-parentheses -Wno-unused-variable -Wno-unused-but-set-variable -Wno-strict-aliasing -Wno-return-type -Wno-maybe-uninitialized endif +CONFIG_VARS += ENABLE_GDB ifeq ($(ENABLE_GDB), 1) CFLAGS += -ggdb -DENABLE_GDB=1 endif +CONFIG_VARS += SMING_RELEASE ifeq ($(SMING_RELEASE),1) # See: https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html # for full list of optimization options @@ -116,11 +133,12 @@ else endif #Append debug options +CONFIG_VARS += SMING_RELEASE CFLAGS += -DCUST_FILE_BASE=$$* -DDEBUG_VERBOSE_LEVEL=$(DEBUG_VERBOSE_LEVEL) -DDEBUG_PRINT_FILENAME_AND_LINE=$(DEBUG_PRINT_FILENAME_AND_LINE) CXXFLAGS = $(CFLAGS) -fno-rtti -fno-exceptions -std=c++11 -felide-constructors ifneq ($(STRICT),1) -CXXFLAGS += -Wno-reorder + CXXFLAGS += -Wno-reorder endif # => LOCALE @@ -148,8 +166,69 @@ define ListSubmodules $(shell git submodule status $1 | cut -c2- | cut -f2 -d ' ') endef +# Display variable and list values, e.g. $(call PrintVariable,LIBS) +# $1 -> Name of variable containing values +define PrintVariable + $(info $1) + $(foreach item,$(sort $($1)),$(info - $(item))) +endef + +# Display list of variable references with their values e.g. $(call PrintVariableRefs,CONFIG_VARS) +# $1 -> Name of variable containing list of variable names +define PrintVariableRefs + $(info $1) + $(foreach item,$(sort $($1)),$(info - $(item) = $($(item))) ) +endef + +# Display some internal configuration information +define ListConfig + $(info ) + $(info ** Sming internal build configuration **) + $(info ) + $(call PrintVariable,MAKEFILE_LIST) + $(call PrintVariable,CUSTOM_TARGETS) + $(call PrintVariable,LIBSMING) + $(call PrintVariable,LIBS) + $(call PrintVariable,ARDUINO_LIBRARIES) + $(call PrintVariable,SUBMODULES) + $(call PrintVariableRefs,CONFIG_VARS) + $(info ) + $(info ) +endef + +# Extract commented target information from makefiles and display +# Based on code from https://suva.sh/posts/well-documented-makefiles/ +define PrintHelp + $(info ) + $(info Welcome to the Sming build system!) + @awk 'BEGIN { \ + FS = "(:.*##)|(##@)"; \ + printf "Usage:\n make \033[1;36m\033[0m\n"; \ + } /^##@/ { \ + group = $$2; \ + groups[group] = group; \ + } /^[a-zA-Z_-]+:.*?##/ { \ + targets[$$1, group] = $$2; \ + } \ + END { \ + groupCount = asort(groups); \ + for (g = 1; g <= groupCount; ++g) { \ + printf "\n\033[1m%s\033[0m\n", groups[g]; \ + targetCount = asorti(targets, idx); \ + for (t = 1; t <= targetCount; ++t) { \ + split(idx[t], sep, SUBSEP); \ + if (sep[2] == groups[g]) \ + printf " \033[1;36m%-18s\033[0m %s\n", sep[1], targets[idx[t]] \ + } \ + } \ + } ' $(MAKEFILE_LIST) + + $(info ) +endef + # => Main Sming library +CONFIG_VARS += ENABLE_SSL ifeq ($(ENABLE_SSL),1) LIBSMING = smingssl SMING_FEATURES = SSL @@ -161,6 +240,7 @@ LIBSMING_DST = $(call UserLibPath,$(LIBSMING)) # => MQTT # Flags for compatability with old versions (most of them should disappear with the next major release) +CONFIG_VARS += MQTT_NO_COMPAT ifeq ($(MQTT_NO_COMPAT),1) CFLAGS += -DMQTT_NO_COMPAT=1 endif diff --git a/Sming/building.md b/Sming/building.md index af6c0268b5..a5d5b511fb 100644 --- a/Sming/building.md +++ b/Sming/building.md @@ -26,32 +26,31 @@ The following are internal makefiles containing shared script for both framework > **modules.mk** Parses defined MODULES, etc. and creates target rules -In addition, `Sming/Platform/$(PLATFORM)` must contain: +In addition, `Sming/Arch/$(ARCH)` must contain: -> **sming.mk** to define platform-specific modules and libraries +> **sming.mk** to define architecture-specific modules and libraries > **app.mk** to build an application -`PLATFORM` may be defined as +`SMING_ARCH` may be defined as > **Esp8266** > **Esp32** {todo} -> **Host** {todo} builds a version of the library for native host debugging +> **Host** {todo} builds a version of the library for native host debugging (e.g. Linux/Windows) -If setting this as an environment variable you should use `SMING_PLATFORM` to avoid potential conflicts. ## Directories ``` Directory Contents --------- -------- -Libraries\ Arduino Libraries -Platform/ - Common/ Headers and code common to all platforms - Esp8266/ Existing Sming platform code + +Arch/ Architecture-specific makefiles and code + Esp8266/ Compiler/ + Components/ Core/ out/ Platform/ @@ -62,14 +61,20 @@ Platform/ Host/ ... -SmingCore/ Main framework core (TODO: rename to `Core`) +Components/ Framework support code, not to be used directly by applications + +Core/ Main framework core (TODO: rename to `Core`) + +Libraries/ Arduino Libraries + +Platform/ System-level classes -System/ Common framework system code +Services/ Modules not considered as part of Core + +System/ Common framework low-level system code esp8266/ include/ -third-party/ Shared GIT submodules - Wiring/ ``` @@ -77,54 +82,12 @@ Wiring/ ## Environment Setup -You must provide `SMING_HOME` and `ESP_HOME`. All others are optional. +You must provide `SMING_HOME` and any architecture-specific ones. For the Esp8266 you must define `ESP_HOME` for SDK & tools. # Building the framework ## Makefile -Targets include: - -> **all** (default) Builds the Sming library, user libraries, arduino libraries and tools - -> **libsming** Build the Sming framework and user libraries - -> **mqttc** Build mqttc-codec user library - -> **docs** Build the documentation - -> **submodules** Fetch all third-party submodules, but do not build - -> **samples** Build all the sample applications - -> **test** Build a few basic test applications - -> **tools** Build all required internal tools - -Esp8266 targets: - -> **axtls** Build axtls-8266 library - `ENABLE_SSL=1` required - -> **pwm_open** Build the PWM replacement library - -> **pwm-clean** - -Cleaning: - -> **dist-clean** Clean everything - -> **clean** Remove intermediate files - -> **user-lib-clean** Clear generated user libraries - -> **submodules-clean** Reset state of third-party repos - -> **samples-clean** Invoke **clean** on all samples - -> **tools-clean** - -> **cs** Apply coding style to core files - Flags: > ** ARDUINO_LIBRARIES** Specify which Arduino Libraries are to be built. Default: unspecified, builds them all. Example: `make ARDUINO_LIBRARIES="ArduinoJson SI7021 BMP180"` @@ -140,7 +103,7 @@ After updating and patching, an `.submodule` file is created to confirm this has ## Makefile-app.mk -This does not contain any targets, but sets up the common build environment, configures Sming variables then invokes the platform-specific makefile in `Platform$/$(PLATFORM)/app.mk` +This does not contain any targets, but sets up the common build environment, configures Sming variables then invokes the platform-specific makefile in `Platform$/$(PLATFORM)/app.mk`. ## Application Code (APPCODE) From 78b419ca7d6626cf58569adadf5fd280cc560ff7 Mon Sep 17 00:00:00 2001 From: mikee47 Date: Mon, 29 Apr 2019 14:54:46 +0100 Subject: [PATCH 09/22] WebHelpers now subject to coding style --- Sming/Core/Network/WebHelpers/aw-sha1.cpp | 66 +++--- Sming/Core/Network/WebHelpers/aw-sha1.h | 7 +- Sming/Core/Network/WebHelpers/base64.cpp | 17 +- Sming/Core/Network/WebHelpers/base64.h | 11 +- Sming/Core/Network/WebHelpers/escape.cpp | 241 +++++++++++----------- Sming/Core/Network/WebHelpers/escape.h | 16 +- 6 files changed, 178 insertions(+), 180 deletions(-) diff --git a/Sming/Core/Network/WebHelpers/aw-sha1.cpp b/Sming/Core/Network/WebHelpers/aw-sha1.cpp index 795806b64d..d05a38b5f8 100644 --- a/Sming/Core/Network/WebHelpers/aw-sha1.cpp +++ b/Sming/Core/Network/WebHelpers/aw-sha1.cpp @@ -21,10 +21,10 @@ THE SOFTWARE. */ - #include "aw-sha1.h" -static inline void sha1mix(unsigned *_sha1_restrict r, unsigned *_sha1_restrict w) { +static inline void sha1mix(unsigned* _sha1_restrict r, unsigned* _sha1_restrict w) +{ unsigned a = r[0]; unsigned b = r[1]; unsigned c = r[2]; @@ -32,35 +32,36 @@ static inline void sha1mix(unsigned *_sha1_restrict r, unsigned *_sha1_restrict unsigned e = r[4]; unsigned t, i = 0; -#define rol(x,s) ((x) << (s) | (unsigned) (x) >> (32 - (s))) -#define mix(f,v) do { \ - t = (f) + (v) + rol(a, 5) + e + w[i & 0xf]; \ - e = d; \ - d = c; \ - c = rol(b, 30); \ - b = a; \ - a = t; \ - } while (0) - - for (; i < 16; ++i) +#define rol(x, s) ((x) << (s) | (unsigned)(x) >> (32 - (s))) +#define mix(f, v) \ + do { \ + t = (f) + (v) + rol(a, 5) + e + w[i & 0xf]; \ + e = d; \ + d = c; \ + c = rol(b, 30); \ + b = a; \ + a = t; \ + } while(0) + + for(; i < 16; ++i) mix(d ^ (b & (c ^ d)), 0x5a827999); - for (; i < 20; ++i) { + for(; i < 20; ++i) { w[i & 0xf] = rol(w[(i + 13) & 0xf] ^ w[(i + 8) & 0xf] ^ w[(i + 2) & 0xf] ^ w[i & 0xf], 1); mix(d ^ (b & (c ^ d)), 0x5a827999); } - for (; i < 40; ++i) { + for(; i < 40; ++i) { w[i & 0xf] = rol(w[(i + 13) & 0xf] ^ w[(i + 8) & 0xf] ^ w[(i + 2) & 0xf] ^ w[i & 0xf], 1); mix(b ^ c ^ d, 0x6ed9eba1); } - for (; i < 60; ++i) { + for(; i < 60; ++i) { w[i & 0xf] = rol(w[(i + 13) & 0xf] ^ w[(i + 8) & 0xf] ^ w[(i + 2) & 0xf] ^ w[i & 0xf], 1); mix((b & c) | (d & (b | c)), 0x8f1bbcdc); } - for (; i < 80; ++i) { + for(; i < 80; ++i) { w[i & 0xf] = rol(w[(i + 13) & 0xf] ^ w[(i + 8) & 0xf] ^ w[(i + 2) & 0xf] ^ w[i & 0xf], 1); mix(b ^ c ^ d, 0xca62c1d6); } @@ -75,28 +76,27 @@ static inline void sha1mix(unsigned *_sha1_restrict r, unsigned *_sha1_restrict r[4] += e; } -void sha1(unsigned char h[SHA1_SIZE], const void *_sha1_restrict p, size_t n) { +void sha1(unsigned char h[SHA1_SIZE], const void* _sha1_restrict p, size_t n) +{ size_t i = 0; unsigned w[16], r[5] = {0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0}; - for (; i < (n & ~0x3f);) { - do w[i >> 2 & 0xf] = - ((const unsigned char *) p)[i + 3] << 0x00 | - ((const unsigned char *) p)[i + 2] << 0x08 | - ((const unsigned char *) p)[i + 1] << 0x10 | - ((const unsigned char *) p)[i + 0] << 0x18; - while ((i += 4) & 0x3f); + for(; i < (n & ~0x3f);) { + do + w[i >> 2 & 0xf] = ((const unsigned char*)p)[i + 3] << 0x00 | ((const unsigned char*)p)[i + 2] << 0x08 | + ((const unsigned char*)p)[i + 1] << 0x10 | ((const unsigned char*)p)[i + 0] << 0x18; + while((i += 4) & 0x3f); sha1mix(r, w); } memset(w, 0, sizeof w); - for (; i < n; ++i) - w[i >> 2 & 0xf] |= ((const unsigned char *) p)[i] << (((3 ^ i) & 3) << 3); + for(; i < n; ++i) + w[i >> 2 & 0xf] |= ((const unsigned char*)p)[i] << (((3 ^ i) & 3) << 3); w[i >> 2 & 0xf] |= 0x80 << (((3 ^ i) & 3) << 3); - if ((n & 0x3f) > 56) { + if((n & 0x3f) > 56) { sha1mix(r, w); memset(w, 0, sizeof w); } @@ -104,11 +104,7 @@ void sha1(unsigned char h[SHA1_SIZE], const void *_sha1_restrict p, size_t n) { w[15] = n << 3; sha1mix(r, w); - for (i = 0; i < 5; ++i) - h[(i << 2) + 0] = (unsigned char) (r[i] >> 0x18), - h[(i << 2) + 1] = (unsigned char) (r[i] >> 0x10), - h[(i << 2) + 2] = (unsigned char) (r[i] >> 0x08), - h[(i << 2) + 3] = (unsigned char) (r[i] >> 0x00); + for(i = 0; i < 5; ++i) + h[(i << 2) + 0] = (unsigned char)(r[i] >> 0x18), h[(i << 2) + 1] = (unsigned char)(r[i] >> 0x10), + h[(i << 2) + 2] = (unsigned char)(r[i] >> 0x08), h[(i << 2) + 3] = (unsigned char)(r[i] >> 0x00); } - - diff --git a/Sming/Core/Network/WebHelpers/aw-sha1.h b/Sming/Core/Network/WebHelpers/aw-sha1.h index c197c6b4ff..b8a6a3b5b1 100644 --- a/Sming/Core/Network/WebHelpers/aw-sha1.h +++ b/Sming/Core/Network/WebHelpers/aw-sha1.h @@ -27,9 +27,9 @@ #include #if defined(_MSC_VER) -# define _sha1_restrict __restrict +#define _sha1_restrict __restrict #else -# define _sha1_restrict __restrict__ +#define _sha1_restrict __restrict__ #endif #define SHA1_SIZE 20 @@ -38,11 +38,10 @@ extern "C" { #endif -void sha1(unsigned char h[SHA1_SIZE], const void *_sha1_restrict p, size_t n); +void sha1(unsigned char h[SHA1_SIZE], const void* _sha1_restrict p, size_t n); #ifdef __cplusplus } /* extern "C" */ #endif #endif /* AW_SHA1_H */ - diff --git a/Sming/Core/Network/WebHelpers/base64.cpp b/Sming/Core/Network/WebHelpers/base64.cpp index 0f0bf9021e..18ecd6daf9 100644 --- a/Sming/Core/Network/WebHelpers/base64.cpp +++ b/Sming/Core/Network/WebHelpers/base64.cpp @@ -22,7 +22,7 @@ int base64_encode(size_t in_len, const unsigned char* in, size_t out_len, char* { // Base-64 encoding produces 3 output bytes for every 2 input bytes unsigned min_out_len = MIN_ENCODE_LEN(in_len); - if (out_len < min_out_len) + if(out_len < min_out_len) return -1; base64_encodestate state; @@ -35,11 +35,11 @@ int base64_encode(size_t in_len, const unsigned char* in, size_t out_len, char* String base64_encode(const unsigned char* in, size_t in_len) { String s; - if (!s.setLength(MIN_ENCODE_LEN(in_len))) + if(!s.setLength(MIN_ENCODE_LEN(in_len))) return nullptr; int len = base64_encode(in_len, in, s.length(), s.begin()); - if (len < 0) + if(len < 0) return nullptr; s.setLength(len); @@ -49,7 +49,7 @@ String base64_encode(const unsigned char* in, size_t in_len) /* decode a base64 string in one shot */ int base64_decode(size_t in_len, const char* in, size_t out_len, unsigned char* out) { - if (out_len < MIN_DECODE_LEN(in_len)) + if(out_len < MIN_DECODE_LEN(in_len)) return -1; base64_decodestate _state; @@ -57,19 +57,16 @@ int base64_decode(size_t in_len, const char* in, size_t out_len, unsigned char* return base64_decode_block(in, in_len, (char*)out, &_state); } - -String base64_decode(const char *in, size_t in_len) +String base64_decode(const char* in, size_t in_len) { String s; - if (!s.setLength(MIN_DECODE_LEN(in_len))) + if(!s.setLength(MIN_DECODE_LEN(in_len))) return nullptr; int outlen = base64_decode(in_len, in, s.length(), (unsigned char*)s.begin()); - if (outlen < 0) + if(outlen < 0) return nullptr; s.setLength(outlen); return s; } - - diff --git a/Sming/Core/Network/WebHelpers/base64.h b/Sming/Core/Network/WebHelpers/base64.h index 93e681c0a9..62cc863932 100644 --- a/Sming/Core/Network/WebHelpers/base64.h +++ b/Sming/Core/Network/WebHelpers/base64.h @@ -25,14 +25,14 @@ * @note Output is broken by newline every 72 characters. Final terminating newline * is not included. */ -int base64_encode(size_t in_len, const unsigned char *in, size_t out_len, char *out); +int base64_encode(size_t in_len, const unsigned char* in, size_t out_len, char* out); /** @brief encode a block of data into base64, stored in a String * @param in text to encode * @param in_len quantity of characters to encode * @retval String the base64-encoded text */ -String base64_encode(const unsigned char *in, size_t in_len); +String base64_encode(const unsigned char* in, size_t in_len); /** @brief encode a block of data into base64, both input and output are String objects * @param in @@ -43,7 +43,6 @@ static inline String base64_encode(const String& in) return base64_encode((unsigned char*)in.c_str(), in.length()); } - /** @brief decode base64 digits with MIME style === pads into binary data * @param in_len length of source base64 text in characters * @param in base64-encoded text @@ -51,14 +50,14 @@ static inline String base64_encode(const String& in) * @param out buffer for decoded output * @retval int length of decoded output, or -1 if output buffer is too small */ -int base64_decode(size_t in_len, const char *in, size_t out_len, unsigned char *out); +int base64_decode(size_t in_len, const char* in, size_t out_len, unsigned char* out); /** @brief decode base64 text into binary data * @param in source base64-encoded text * @param in_len length of input text in characters * @retval String the decoded text */ -String base64_decode(const char *in, size_t in_len); +String base64_decode(const char* in, size_t in_len); /** @brief encode a block of data into base64, both input and output are String objects * @param in @@ -69,6 +68,4 @@ static inline String base64_decode(const String& in) return base64_decode(in.c_str(), in.length()); } - - #endif /* BASE64_H */ diff --git a/Sming/Core/Network/WebHelpers/escape.cpp b/Sming/Core/Network/WebHelpers/escape.cpp index 05371dcfb8..9786f07728 100644 --- a/Sming/Core/Network/WebHelpers/escape.cpp +++ b/Sming/Core/Network/WebHelpers/escape.cpp @@ -7,18 +7,20 @@ #include // Append str to dest with checks -static unsigned safe_append(char *dest, size_t len, const char *str) { +static unsigned safe_append(char* dest, size_t len, const char* str) +{ unsigned len2; - len2=strlen(str); - if(len2>len) { + len2 = strlen(str); + if(len2 > len) { return 0; /* refuse to append */ } - memcpy(dest, str, len2+1); + memcpy(dest, str, len2 + 1); return len2; } /* return true if 2 characters are valid hexidecimal */ -static bool ishex(const char code[2]) { +static bool ishex(const char code[2]) +{ return isxdigit(code[0]) && isxdigit(code[1]); } @@ -29,43 +31,45 @@ static uint8_t unhex(const char code[2]) } // These characters are escaped -static bool must_escape(char c) { - switch (c) { - case '\r': - case '\n': - case '+': - case '~': - case '!': - case '#': - case '$': - case '%': - case '^': - case '&': - case '(': - case ')': - case '{': - case '}': - case '[': - case ']': - case '=': - case ':': - case ',': - case ';': - case '?': - case '\'': - case '"': - case '\\': - return true; - default: - return false; +static bool must_escape(char c) +{ + switch(c) { + case '\r': + case '\n': + case '+': + case '~': + case '!': + case '#': + case '$': + case '%': + case '^': + case '&': + case '(': + case ')': + case '{': + case '}': + case '[': + case ']': + case '=': + case ':': + case ',': + case ';': + case '?': + case '\'': + case '"': + case '\\': + return true; + default: + return false; } } -unsigned uri_escape_len(const char *s, size_t len) { +unsigned uri_escape_len(const char* s, size_t len) +{ unsigned ret; - for(ret=0;len>0;len--,s++) { - if (must_escape(*s)) - ret+=3; + for(ret = 0; len > 0; len--, s++) { + if(must_escape(*s)) + ret += 3; else ret++; } @@ -80,31 +84,31 @@ unsigned uri_escape_len(const char *s, size_t len) { * dest or allocated pointer on success * destination string will always be null terminated */ -char *uri_escape(char *dest, size_t dest_len, const char *src, int src_len) +char* uri_escape(char* dest, size_t dest_len, const char* src, int src_len) { assert(src != nullptr); - if(src_len<0) { - src_len=strlen(src); + if(src_len < 0) { + src_len = strlen(src); } - bool ret_is_allocated=!dest; + bool ret_is_allocated = !dest; if(ret_is_allocated) { /* src_len is non-negative because of earlier condition */ - assert(src_len>=0); - dest_len=uri_escape_len(src, src_len)+1; - dest=(char*)malloc(dest_len); + assert(src_len >= 0); + dest_len = uri_escape_len(src, src_len) + 1; + dest = (char*)malloc(dest_len); if(!dest) { return 0; /* allocation failure */ } } - char* ret=dest; + char* ret = dest; /* escape these values ~!#$%^&(){}[]=:,;?'"\ * make sure there is room in dest for a '\0' */ - for(;src_len>0 && dest_len>1;src++,src_len--) { + for(; src_len > 0 && dest_len > 1; src++, src_len--) { char c = *src; if(must_escape(c)) { /* check that there is room for "%XX\0" in dest */ - if(dest_len<=3) { + if(dest_len <= 3) { if(ret_is_allocated) free(ret); return 0; @@ -112,25 +116,25 @@ char *uri_escape(char *dest, size_t dest_len, const char *src, int src_len) dest[0] = '%'; dest[1] = hexchar(*src >> 4); dest[2] = hexchar(*src & 0x0f); - dest+=3; - dest_len-=3; - } else if (c == ' ') { + dest += 3; + dest_len -= 3; + } else if(c == ' ') { *dest++ = '+'; dest_len--; } else { - *(dest++)=*src; + *(dest++) = *src; dest_len--; } } /* check for errors - src was not fully consumed */ - if(src_len!=0) { + if(src_len != 0) { if(ret_is_allocated) { free(ret); } return 0; } - assert(dest_len>=1); - *dest='\0'; + assert(dest_len >= 1); + *dest = '\0'; return ret; } @@ -142,60 +146,71 @@ char *uri_escape(char *dest, size_t dest_len, const char *src, int src_len) * 0 on error (overflow of dest, allocation failure) * dest or allocated pointer on success */ -char *uri_unescape(char *dest, size_t dest_len, const char *src, int src_len) +char* uri_unescape(char* dest, size_t dest_len, const char* src, int src_len) { - assert(src!=nullptr); - if(src_len<0) { - src_len=strlen(src); + assert(src != nullptr); + if(src_len < 0) { + src_len = strlen(src); } - bool ret_is_allocated=!dest; + bool ret_is_allocated = !dest; if(ret_is_allocated) { - dest_len=src_len+1; /* TODO: calculate the exact needed size? */ - dest=(char*)malloc(dest_len); + dest_len = src_len + 1; /* TODO: calculate the exact needed size? */ + dest = (char*)malloc(dest_len); if(!dest) { return 0; /* allocation failure */ } } - char* ret=dest; - for(;dest_len>1 && src_len>0;dest_len--,dest++) { - if(*src=='%' && src_len>=3 && ishex(src+1)) { - *dest=(char)unhex(src+1); - src+=3; - src_len-=3; - } else if(*src=='+') { - *dest=' '; + char* ret = dest; + for(; dest_len > 1 && src_len > 0; dest_len--, dest++) { + if(*src == '%' && src_len >= 3 && ishex(src + 1)) { + *dest = (char)unhex(src + 1); + src += 3; + src_len -= 3; + } else if(*src == '+') { + *dest = ' '; src++; src_len--; } else { - *dest=*(src++); + *dest = *(src++); src_len--; } } /* check for errors - src was not fully consumed */ - if(src_len!=0) { + if(src_len != 0) { if(ret_is_allocated) { free(ret); } return 0; } - assert(dest_len>=1); - *dest=0; + assert(dest_len >= 1); + *dest = 0; return ret; } /* calculates the required length for html_escape */ -unsigned html_escape_len(const char *s, size_t len) { +unsigned html_escape_len(const char* s, size_t len) +{ unsigned ret; - for(ret=0;len && *s;len--,s++) { + for(ret = 0; len && *s; len--, s++) { switch(*s) { - case '<': ret+=4; break; /* < */ - case '>': ret+=4; break; /* > */ - case '&': ret+=5; break; /* & */ - case '"': ret+=6; break; /* " */ - case '\'': ret+=6; break; /* ' */ - default: - ret++; + case '<': + ret += 4; + break; /* < */ + case '>': + ret += 4; + break; /* > */ + case '&': + ret += 5; + break; /* & */ + case '"': + ret += 6; + break; /* " */ + case '\'': + ret += 6; + break; /* ' */ + default: + ret++; } } return ret; @@ -204,50 +219,48 @@ unsigned html_escape_len(const char *s, size_t len) { /** escapes HTML entities * BUG: silently drops entities if there is no room */ -void html_escape(char *dest, size_t len, const char *s) { +void html_escape(char* dest, size_t len, const char* s) +{ unsigned i; - for(i=0;i': - i+=safe_append(dest+i,len-i, ">"); - break; - case '&': - i+=safe_append(dest+i,len-i, "&"); - break; - case '"': - i+=safe_append(dest+i,len-i, """); - break; - case '\'': - i+=safe_append(dest+i,len-i, "'"); - break; - default: - dest[i++]=*s; + case '<': + i += safe_append(dest + i, len - i, "<"); + break; + case '>': + i += safe_append(dest + i, len - i, ">"); + break; + case '&': + i += safe_append(dest + i, len - i, "&"); + break; + case '"': + i += safe_append(dest + i, len - i, """); + break; + case '\'': + i += safe_append(dest + i, len - i, "'"); + break; + default: + dest[i++] = *s; } } - dest[i]='\0'; + dest[i] = '\0'; } - - - -String uri_escape(const char *src, int src_len) +String uri_escape(const char* src, int src_len) { String s; - if (src && src_len) { + if(src && src_len) { unsigned dst_len = uri_escape_len(src, src_len); - if (s.setLength(dst_len)) + if(s.setLength(dst_len)) uri_escape(s.begin(), s.length() + 1, src, src_len); // +1 for nul terminator } return s; } -char* uri_unescape_inplace(char *str) +char* uri_unescape_inplace(char* str) { - if (str) { + if(str) { auto len = strlen(str); uri_unescape(str, len + 1, str, len); // +1 for nul terminator } @@ -256,14 +269,12 @@ char* uri_unescape_inplace(char *str) String& uri_unescape_inplace(String& str) { - if (str) { + if(str) { char* p = str.begin(); - uri_unescape(p, str.length() + 1, p, str.length()); // +1 for nul terminator + uri_unescape(p, str.length() + 1, p, str.length()); // +1 for nul terminator auto len = strlen(p); assert(len <= str.length()); str.setLength(len); } return str; } - - diff --git a/Sming/Core/Network/WebHelpers/escape.h b/Sming/Core/Network/WebHelpers/escape.h index 7025832a8f..e0c8a2bf35 100644 --- a/Sming/Core/Network/WebHelpers/escape.h +++ b/Sming/Core/Network/WebHelpers/escape.h @@ -9,7 +9,7 @@ * @param len Number of characters in source text * @retval unsigned number of characters for output, NOT including nul terminator */ -unsigned uri_escape_len(const char *s, size_t len); +unsigned uri_escape_len(const char* s, size_t len); static inline unsigned uri_escape_len(const String& str) { @@ -25,7 +25,7 @@ static inline unsigned uri_escape_len(const String& str) * @retval char* points to start of dest * @note destination and source MUST be different buffers */ -char *uri_escape(char *dest, size_t dest_len, const char *src, int src_len); +char* uri_escape(char* dest, size_t dest_len, const char* src, int src_len); /** @brief unescape text * @param dest buffer to store result @@ -35,18 +35,17 @@ char *uri_escape(char *dest, size_t dest_len, const char *src, int src_len); * @retval char* points to start of dest * @note destination and source may be the same buffer */ -char *uri_unescape(char *dest, size_t dest_len, const char *src, int src_len); - -unsigned html_escape_len(const char *s, size_t len); -void html_escape(char *dest, size_t len, const char *s); +char* uri_unescape(char* dest, size_t dest_len, const char* src, int src_len); +unsigned html_escape_len(const char* s, size_t len); +void html_escape(char* dest, size_t len, const char* s); /** @brief Replace a nul-terminated string with its unescaped version * @param str the string to un-escape * @retval char* the result, a copy of str * @note unescaped string is never longer than escaped version */ -char* uri_unescape_inplace(char *str); +char* uri_unescape_inplace(char* str); /** @brief escape the given URI string * @param src @@ -54,14 +53,13 @@ char* uri_unescape_inplace(char *str); * @retval String the escaped string * @note escaping may increase text size (but not always) */ -String uri_escape(const char *src, int src_len); +String uri_escape(const char* src, int src_len); static inline String uri_escape(const String& src) { return src ? uri_escape(src.c_str(), src.length()) : src; } - /** @brief replace the given text by its unescaped version * @param str the string to unescape * @retval reference to str, unescaped From a98ba2e40428ca09160da8bdff7ba53f9e232032 Mon Sep 17 00:00:00 2001 From: mikee47 Date: Mon, 29 Apr 2019 14:59:54 +0100 Subject: [PATCH 10/22] Add `make help` and `make list-config` to travis/appveyor, update coding-style check --- .travis.yml | 2 ++ .travis/tools/clang/format-pr.sh | 2 +- appveyor.yml | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 86a02e0e63..910d5d1eb9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -59,6 +59,8 @@ script: - cd $SMING_HOME - if [ "$SDK_VERSION" == "2.0.0" ]; then ../.travis/tools/clang/format-pr.sh; fi - cd $SMING_HOME +- make help +- make list-config - make STRICT=1 - make samples - make clean samples-clean diff --git a/.travis/tools/clang/format-pr.sh b/.travis/tools/clang/format-pr.sh index 139b6ca893..d264a4f3c8 100755 --- a/.travis/tools/clang/format-pr.sh +++ b/.travis/tools/clang/format-pr.sh @@ -10,7 +10,7 @@ $CLANG_FORMAT --version cd $SMING_HOME/.. # Get list of modified files -files_to_lint="$(git diff --name-only --diff-filter=ACMRTUXB $TRAVIS_COMMIT_RANGE | grep '^[^.]*[.]\(c\|cpp\|h\)$' | grep -e Sming/SmingCore -e samples || true)" +files_to_lint="$(git diff --name-only --diff-filter=ACMRTUXB $TRAVIS_COMMIT_RANGE | grep '^[^.]*[.]\(c\|cpp\|h\)$' | grep -e Sming/Core -e Sming/Platform -e Sming/Arch/.+/Core -e Sming/Arch/.+/Platform -e samples || true)" for f in $files_to_lint; do diff --git a/appveyor.yml b/appveyor.yml index 01fd1e645c..cbf5aa37a0 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -35,6 +35,9 @@ build_script: - SET PATH=%PATH%;%ESP_HOME%/utils - cd %SMING_HOME% - gcc -v +# + - make help + - make list-config # Compile the tools first - make tools V=1 # Followed by the library and test sample apps From 7a1d8c15b9e42ec894b8db02f2541c7d03630d11 Mon Sep 17 00:00:00 2001 From: mikee47 Date: Mon, 29 Apr 2019 16:07:07 +0100 Subject: [PATCH 11/22] Update `Doxyfile` --- docs/Doxyfile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/Doxyfile b/docs/Doxyfile index 9f347d0748..254826b17e 100644 --- a/docs/Doxyfile +++ b/docs/Doxyfile @@ -759,14 +759,15 @@ WARN_LOGFILE = api/error.log # Note: If this tag is empty the current directory is searched. INPUT = api.dox sdk.dox \ - ../Sming/SmingCore \ + ../Sming/Core \ + ../Sming/Platform \ ../Sming/Services \ ../Sming/Wiring \ - ../Sming/third-party/rboot \ + ../Sming/Components/rboot \ ../Sming/Libraries \ $(ESP_HOME)/sdk/include/gpio.h \ ../Sming/System \ - ../Sming/gdb \ + ../Sming/Components/gdbstub \ # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses From 3e68e58166fa1b2543e3fa3ad21021938004c9d4 Mon Sep 17 00:00:00 2001 From: mikee47 Date: Mon, 29 Apr 2019 17:48:17 +0100 Subject: [PATCH 12/22] Fix esptool2 submodule dependency --- Sming/Arch/Esp8266/sming.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sming/Arch/Esp8266/sming.mk b/Sming/Arch/Esp8266/sming.mk index 2a17ae468e..9ae6d2cc51 100644 --- a/Sming/Arch/Esp8266/sming.mk +++ b/Sming/Arch/Esp8266/sming.mk @@ -176,7 +176,7 @@ TOOLS += $(ESPTOOL2) TOOLS_CLEAN += esptool2-clean SUBMODULES += $(dir $(ESPTOOL2)) -$(ESPTOOL2): +$(ESPTOOL2): $(dir $(ESPTOOL2)).submodule $(Q) $(call make-tool,$@) .PHONY: esptool2-clean From 100c6c9a5f1b8e5a4476278236e679f8baa833d3 Mon Sep 17 00:00:00 2001 From: mikee47 Date: Tue, 30 Apr 2019 11:42:16 +0100 Subject: [PATCH 13/22] Add individual .submodule dependencies for user libraries, make them order-only pre-requisites --- Sming/Arch/Esp8266/sming.mk | 22 +++++++++++----------- Sming/Makefile | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Sming/Arch/Esp8266/sming.mk b/Sming/Arch/Esp8266/sming.mk index 9ae6d2cc51..81136db274 100644 --- a/Sming/Arch/Esp8266/sming.mk +++ b/Sming/Arch/Esp8266/sming.mk @@ -35,20 +35,20 @@ MODULES += $(SPIFFS_SMING) $(SPIFFS_BASE)/src CONFIG_VARS += ENABLE_CUSTOM_PWM ENABLE_CUSTOM_PWM ?= 1 ifeq ($(ENABLE_CUSTOM_PWM), 1) - PWM_BASE := $(ARCH_COMPONENTS)/pwm - SUBMODULES += $(PWM_BASE)/new-pwm + PWM_BASE := $(ARCH_COMPONENTS)/pwm/new-pwm + SUBMODULES += $(PWM_BASE) CFLAGS += -DSDK_PWM_PERIOD_COMPAT_MODE=1 LIBPWM := pwm_open LIBS += $(LIBPWM) CLEAN += pwm-clean -$(call UserLibPath,$(LIBPWM)): $(PWM_BASE)/new-pwm/pwm.c - $(Q) $(CC) $(INCDIR) $(MODULE_INCDIR) $(EXTRA_INCDIR) $(CFLAGS) -c $< -o $(dir $<)pwm.o - $(Q) $(AR) rcs $@ $(dir $<)pwm.o +$(call UserLibPath,$(LIBPWM)): | $(PWM_BASE)/.submodule + $(Q) $(CC) $(INCDIR) $(MODULE_INCDIR) $(EXTRA_INCDIR) $(CFLAGS) -c $(PWM_BASE)/pwm.c -o $(PWM_BASE)/pwm.o + $(Q) $(AR) rcs $@ $(PWM_BASE)/pwm.o .PHONY: pwm-clean pwm-clean: - -$(Q) rm -f $(PWM_BASE)/new-pwm/*.o + -$(Q) rm -f $(PWM_BASE)/*.o endif @@ -65,7 +65,7 @@ ifeq ($(ENABLE_CUSTOM_HEAP), 1) LIBS += $(LIBMAINMM) # Make copy of libmain and remove mem_manager.o module -$(call UserLibPath,$(LIBMAINMM)): $(SDK_LIBDIR)/libmain.a +$(call UserLibPath,$(LIBMAINMM)): $(SDK_LIBDIR)/libmain.a | $(UMM_MALLOC_BASE)/.submodule $(vecho) "Enabling custom heap implementation" $(Q) cp $^ $@ $(Q) $(AR) -d $@ mem_manager.o @@ -113,7 +113,7 @@ else LIBS += $(LIBLWIP) CLEAN += lwip-clean -$(call UserLibPath,lwip%): $(LWIP_BASE)/.submodule +$(call UserLibPath,lwip%): | $(LWIP_BASE)/.submodule $(vecho) "Building $(notdir $@)..." $(Q) $(LWIP_BUILD) CC=$(CC) AR=$(AR) all @@ -141,7 +141,7 @@ ifeq ($(ENABLE_SSL),1) CFLAGS += $(AXTLS_FLAGS) AXTLS_BUILD := $(MAKE) -C $(AXTLS_BASE) -e V=$(V) BIN_DIR="$(SMING_HOME)/$(USER_LIBDIR)" -$(call UserLibPath,$(LIBAXTLS)): +$(call UserLibPath,$(LIBAXTLS)): | $(AXTLS_BASE)/.submodule $(Q) $(AXTLS_BUILD) all .PHONY: axtls-clean @@ -164,7 +164,7 @@ endef TOOLS += $(SPIFFY) TOOLS_CLEAN += spiffy-clean -$(SPIFFY): $(COMPONENTS)/spiffs/.submodule +$(SPIFFY): | $(COMPONENTS)/spiffs/.submodule $(Q) $(call make-tool,$@,SPIFFS_SMING=$(SMING_HOME)/$(SPIFFS_SMING) SPIFFS_BASE=$(SMING_HOME)/$(SPIFFS_BASE)) .PHONY: spiffy-clean @@ -176,7 +176,7 @@ TOOLS += $(ESPTOOL2) TOOLS_CLEAN += esptool2-clean SUBMODULES += $(dir $(ESPTOOL2)) -$(ESPTOOL2): $(dir $(ESPTOOL2)).submodule +$(ESPTOOL2): | $(dir $(ESPTOOL2)).submodule $(Q) $(call make-tool,$@) .PHONY: esptool2-clean diff --git a/Sming/Makefile b/Sming/Makefile index b081f743f9..a7fc5bcfb9 100644 --- a/Sming/Makefile +++ b/Sming/Makefile @@ -219,7 +219,7 @@ define TryApplyPatch endef .PHONY: submodules submodules-clean -submodules: $(LIBRARY_SUBMODULES) $(addsuffix /.submodule,$(SUBMODULES)) ##Fetch all third-party submodules (but do not build) +submodules: | $(LIBRARY_SUBMODULES) $(addsuffix /.submodule,$(SUBMODULES)) ##Fetch all third-party submodules (but do not build) ##@Cleaning submodules-clean: ##Reset state of all third-party submodules From 85a5ea7389ef9085c0e08943f6cf172b4bd83222 Mon Sep 17 00:00:00 2001 From: mikee47 Date: Tue, 30 Apr 2019 11:42:44 +0100 Subject: [PATCH 14/22] Add optional `TRACE` variable for `decode-tracktrace` target --- Sming/Makefile-app.mk | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Sming/Makefile-app.mk b/Sming/Makefile-app.mk index bfc79682ca..1978ebddbf 100644 --- a/Sming/Makefile-app.mk +++ b/Sming/Makefile-app.mk @@ -97,10 +97,15 @@ terminal: kill_term ##Open the serial terminal gdb: kill_term ##Run the debugger console $(GDB) +# Stack trace decoder +CONFIG_VARS += TRACE +TRACE ?= .PHONY: decode-stacktrace -decode-stacktrace: ##If a crash occurred, use this option then cut & paste dump text as prompted - @echo "Decode stack trace: Paste stack trace here" - $(Q) python $(ARCH_TOOLS)/decode-stacktrace.py $(TARGET_OUT_0) +decode-stacktrace: ##Open the stack trace decoder ready to paste dump text. Alteratively, use `make decode-stacktrace TRACE=/path/to/crash.stack` + $(Q) if [ -z "$(TRACE)" ]; then \ + echo "Decode stack trace: Paste stack trace here"; \ + fi + $(Q) python $(ARCH_TOOLS)/decode-stacktrace.py $(TARGET_OUT_0) $(TRACE) ##@Testing From bc3367ed2f9ec47e7cfb54b7e812fe8ea58684c3 Mon Sep 17 00:00:00 2001 From: mikee47 Date: Tue, 30 Apr 2019 11:44:01 +0100 Subject: [PATCH 15/22] Add `SmingCore/SmingCore.h` legacy file with warnings and link to Wiki migration page --- Sming/SmingCore/SmingCore.h | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 Sming/SmingCore/SmingCore.h diff --git a/Sming/SmingCore/SmingCore.h b/Sming/SmingCore/SmingCore.h new file mode 100644 index 0000000000..8a298d6664 --- /dev/null +++ b/Sming/SmingCore/SmingCore.h @@ -0,0 +1,3 @@ +#include +#pragma warning "Please update to #include " +#pragma warning "See https://github.com/SmingHub/Sming/wiki/migrate-v3.8-v4.0" From e8496380c4da2078025f2df0319300b2dab2b292 Mon Sep 17 00:00:00 2001 From: mikee47 Date: Tue, 30 Apr 2019 13:37:46 +0100 Subject: [PATCH 16/22] In `decode-stacktrace.py`, use `sys.stdin.readline()` instead of `raw_input()` for consistent behaviour across python versions --- Sming/Arch/Esp8266/Tools/decode-stacktrace.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sming/Arch/Esp8266/Tools/decode-stacktrace.py b/Sming/Arch/Esp8266/Tools/decode-stacktrace.py index a2de96284c..91d61460a9 100644 --- a/Sming/Arch/Esp8266/Tools/decode-stacktrace.py +++ b/Sming/Arch/Esp8266/Tools/decode-stacktrace.py @@ -37,7 +37,7 @@ def extractAddresses(data): pipe.communicate("\n".join(extractAddresses(data)).encode('ascii')) else: while True: - data = raw_input() + data = sys.stdin.readline() addresses = extractAddresses(data) if len(addresses) == 0: continue From b207eedf03a8b87ed845bdc8697f1b17c971d54f Mon Sep 17 00:00:00 2001 From: mikee47 Date: Tue, 30 Apr 2019 13:37:01 +0100 Subject: [PATCH 17/22] Remove sorting from `PrintHelp` make function to improve compatibility with non-GNU `awk` implementations --- Sming/build.mk | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/Sming/build.mk b/Sming/build.mk index ad3a12fb9c..120f004797 100644 --- a/Sming/build.mk +++ b/Sming/build.mk @@ -211,18 +211,15 @@ define PrintHelp targets[$$1, group] = $$2; \ } \ END { \ - groupCount = asort(groups); \ - for (g = 1; g <= groupCount; ++g) { \ - printf "\n\033[1m%s\033[0m\n", groups[g]; \ - targetCount = asorti(targets, idx); \ - for (t = 1; t <= targetCount; ++t) { \ - split(idx[t], sep, SUBSEP); \ - if (sep[2] == groups[g]) \ - printf " \033[1;36m%-18s\033[0m %s\n", sep[1], targets[idx[t]] \ + for (g in groups) { \ + printf "\n\033[1m%s\033[0m\n", g; \ + for (t in targets) { \ + split(t, sep, SUBSEP); \ + if (sep[2] == g) \ + printf " \033[1;36m%-18s\033[0m %s\n", sep[1], targets[t] \ } \ } \ } ' $(MAKEFILE_LIST) - $(info ) endef From a8e25f6f4eaea160e91bcdb9a1d9167a8f1b6c75 Mon Sep 17 00:00:00 2001 From: mikee47 Date: Tue, 30 Apr 2019 12:28:07 +0100 Subject: [PATCH 18/22] Replace `#include` guards with `#pragma once` --- .../Arch/Esp8266/Components/driver/include/driver/uart.h | 5 +---- .../Esp8266/Components/esp8266/include/esp_cplusplus.h | 5 +---- .../Esp8266/Components/esp8266/include/esp_systemapi.h | 5 +---- .../Components/esp8266/include/esp_wifi_sniffer.h | 5 +---- .../esp8266/include/espinc/c_types_compatible.h | 5 +---- .../Components/esp8266/include/espinc/lwip_includes.h | 5 +---- .../Esp8266/Components/esp8266/include/espinc/peri.h | 5 +---- .../Components/esp8266/include/espinc/spi_register.h | 5 +---- .../Components/esp8266/include/espinc/uart_register.h | 5 +---- Sming/Arch/Esp8266/Components/esp8266/include/flashmem.h | 5 +---- Sming/Arch/Esp8266/Components/gdbstub/GdbPacket.h | 5 +---- Sming/Arch/Esp8266/Components/gdbstub/exceptions.h | 5 +---- Sming/Arch/Esp8266/Components/gdbstub/gdb/registers.h | 5 +---- Sming/Arch/Esp8266/Components/gdbstub/gdbhostio.h | 5 +---- Sming/Arch/Esp8266/Components/gdbstub/gdbstub-cfg.h | 5 +---- Sming/Arch/Esp8266/Components/gdbstub/gdbstub-entry.h | 5 +---- Sming/Arch/Esp8266/Components/gdbstub/gdbstub-internal.h | 5 +---- Sming/Arch/Esp8266/Components/gdbstub/gdbstub.h | 5 +---- Sming/Arch/Esp8266/Components/gdbstub/gdbsyscall.h | 5 +---- Sming/Arch/Esp8266/Components/gdbstub/gdbuart.h | 5 +---- .../Esp8266/Components/rboot/appcode/rboot-integration.h | 5 +---- Sming/Arch/Esp8266/Components/spiffs/spiffs_sming.h | 5 ++--- Sming/Arch/Esp8266/Components/spiffs/spiffy_host.h | 7 ++----- Sming/Arch/Esp8266/Core/ESP8266EX.h | 5 +---- Sming/Arch/Esp8266/Core/Network/rBootHttpUpdate.h | 5 +---- Sming/Arch/Esp8266/Core/pins_arduino.h | 5 +---- Sming/Core/ArduinoCompat.h | 5 +---- Sming/Core/AtClient.h | 4 +--- Sming/Core/Clock.h | 4 +--- Sming/Core/Data/Buffer/CircularBuffer.h | 4 +--- Sming/Core/Data/Buffer/LineBuffer.h | 5 +---- Sming/Core/Data/Buffer/SerialBuffer.h | 5 +---- Sming/Core/Data/CStringArray.h | 5 +---- Sming/Core/Data/HexString.h | 5 +---- Sming/Core/Data/MailMessage.h | 4 +--- Sming/Core/Data/ObjectMap.h | 5 +---- Sming/Core/Data/ObjectQueue.h | 4 +--- Sming/Core/Data/Stream/Base64OutputStream.h | 4 +--- Sming/Core/Data/Stream/ChunkedStream.h | 4 +--- Sming/Core/Data/Stream/DataSourceStream.h | 4 +--- Sming/Core/Data/Stream/EndlessMemoryStream.h | 4 +--- Sming/Core/Data/Stream/FileStream.h | 4 +--- Sming/Core/Data/Stream/FlashMemoryStream.h | 4 +--- Sming/Core/Data/Stream/GdbFileStream.h | 5 +---- Sming/Core/Data/Stream/JsonObjectStream.h | 4 +--- Sming/Core/Data/Stream/LimitedMemoryStream.h | 4 +--- Sming/Core/Data/Stream/MemoryDataStream.h | 4 +--- Sming/Core/Data/Stream/MultiStream.h | 5 +---- Sming/Core/Data/Stream/MultipartStream.h | 4 +--- Sming/Core/Data/Stream/QuotedPrintableOutputStream.h | 4 +--- Sming/Core/Data/Stream/ReadWriteStream.h | 4 +--- Sming/Core/Data/Stream/StreamChain.h | 5 +---- Sming/Core/Data/Stream/TemplateFileStream.h | 5 +---- Sming/Core/Data/Stream/TemplateFlashMemoryStream.h | 5 +---- Sming/Core/Data/Stream/TemplateStream.h | 5 +---- Sming/Core/Data/Stream/UrlencodedOutputStream.h | 4 +--- Sming/Core/Data/StreamTransformer.h | 4 +--- Sming/Core/DateTime.h | 4 +--- Sming/Core/Debug.h | 4 +--- Sming/Core/Delegate.h | 4 +--- Sming/Core/Digital.h | 5 +---- Sming/Core/FileSystem.h | 4 +--- Sming/Core/HardwarePWM.h | 4 +--- Sming/Core/HardwareSerial.h | 4 +--- Sming/Core/HardwareTimer.h | 4 +--- Sming/Core/Interrupts.h | 4 +--- Sming/Core/Network/DNSServer.h | 4 +--- Sming/Core/Network/Ftp/FtpDataFileList.h | 5 +---- Sming/Core/Network/Ftp/FtpDataRetrieve.h | 5 +---- Sming/Core/Network/Ftp/FtpDataStore.h | 5 +---- Sming/Core/Network/Ftp/FtpDataStream.h | 5 +---- Sming/Core/Network/Ftp/FtpServerConnection.h | 5 +---- Sming/Core/Network/FtpServer.h | 4 +--- Sming/Core/Network/Http/HttpBodyParser.h | 5 +---- Sming/Core/Network/Http/HttpClientConnection.h | 4 +--- Sming/Core/Network/Http/HttpCommon.h | 5 +---- Sming/Core/Network/Http/HttpConnection.h | 4 +--- Sming/Core/Network/Http/HttpHeaderBuilder.h | 5 +---- Sming/Core/Network/Http/HttpHeaders.h | 5 +---- Sming/Core/Network/Http/HttpParams.h | 5 +---- Sming/Core/Network/Http/HttpRequest.h | 5 +---- Sming/Core/Network/Http/HttpRequestAuth.h | 5 +---- Sming/Core/Network/Http/HttpResource.h | 5 +---- Sming/Core/Network/Http/HttpResourceTree.h | 5 +---- Sming/Core/Network/Http/HttpResponse.h | 5 +---- Sming/Core/Network/Http/HttpServerConnection.h | 4 +--- Sming/Core/Network/Http/Websocket/WebsocketConnection.h | 4 +--- Sming/Core/Network/Http/Websocket/WebsocketResource.h | 5 +---- .../Network/Http/Websocket/WsCommandHandlerResource.h | 5 +---- Sming/Core/Network/HttpClient.h | 4 +--- Sming/Core/Network/HttpServer.h | 4 +--- Sming/Core/Network/Mqtt/MqttPayloadParser.h | 4 +--- Sming/Core/Network/MqttClient.h | 4 +--- Sming/Core/Network/NetUtils.h | 4 +--- Sming/Core/Network/NtpClient.h | 4 +--- Sming/Core/Network/SmtpClient.h | 5 +---- Sming/Core/Network/Ssl/SslFingerprints.h | 5 +---- Sming/Core/Network/Ssl/SslKeyCertPair.h | 5 +---- Sming/Core/Network/Ssl/SslSessionId.h | 5 +---- Sming/Core/Network/Ssl/SslStructs.h | 5 +---- Sming/Core/Network/Ssl/SslValidator.h | 4 +--- Sming/Core/Network/TcpClient.h | 4 +--- Sming/Core/Network/TcpConnection.h | 4 +--- Sming/Core/Network/TcpServer.h | 4 +--- Sming/Core/Network/TelnetServer.h | 4 +--- Sming/Core/Network/UdpConnection.h | 4 +--- Sming/Core/Network/Url.h | 4 +--- Sming/Core/Network/WebConstants.h | 4 +--- Sming/Core/Network/WebHelpers/aw-sha1.h | 5 +---- Sming/Core/Network/WebHelpers/base64.h | 5 +---- Sming/Core/Network/WebHelpers/escape.h | 5 +---- Sming/Core/Network/WebsocketClient.h | 4 +--- Sming/Core/SPI.h | 5 +---- Sming/Core/SPIBase.h | 5 +---- Sming/Core/SPISettings.h | 5 +---- Sming/Core/SPISoft.h | 5 +---- Sming/Core/SimpleTimer.h | 5 +---- Sming/Core/SmingCore.h | 5 +---- Sming/Core/SmingLocale.h | 5 +---- Sming/Core/SystemClock.h | 5 +---- Sming/Core/Timer.h | 4 +--- Sming/Core/Wire.h | 5 +---- Sming/Core/twi.h | 4 +--- Sming/Platform/AccessPoint.h | 5 +---- Sming/Platform/OsMessageInterceptor.h | 5 +---- Sming/Platform/RTC.h | 4 +--- Sming/Platform/Station.h | 4 +--- Sming/Platform/System.h | 4 +--- Sming/Platform/WDT.h | 5 +---- Sming/Platform/WifiEvents.h | 4 +--- Sming/Platform/WifiSniffer.h | 5 +---- Sming/Services/CommandProcessing/CommandDelegate.h | 4 +--- Sming/Services/CommandProcessing/CommandExecutor.h | 5 +---- Sming/Services/CommandProcessing/CommandHandler.h | 4 +--- Sming/Services/CommandProcessing/CommandOutput.h | 5 +---- .../CommandProcessing/CommandProcessingDependencies.h | 9 +-------- .../CommandProcessing/CommandProcessingIncludes.h | 7 +------ Sming/Services/HexDump/HexDump.h | 5 +---- Sming/Services/Profiling/ElapseTimer.h | 6 +----- Sming/Services/Yeelight/YeelightBulb.h | 6 +----- Sming/System/include/debug_progmem.h | 5 +---- Sming/System/include/gdb/gdb_hooks.h | 5 +---- Sming/System/include/gdb/gdb_syscall.h | 4 +--- Sming/System/include/m_printf.h | 5 +---- Sming/System/include/stringconversion.h | 5 +---- Sming/System/include/stringutil.h | 5 +---- Sming/Wiring/Arduino.h | 6 +----- Sming/Wiring/Binary.h | 6 +----- Sming/Wiring/BitManipulations.h | 9 ++------- Sming/Wiring/Countable.h | 6 +----- Sming/Wiring/Display.h | 6 +----- Sming/Wiring/FILO.h | 6 +----- Sming/Wiring/FakePgmSpace.h | 5 +---- Sming/Wiring/FlashString.h | 5 +---- Sming/Wiring/IPAddress.h | 5 +---- Sming/Wiring/Print.h | 5 +---- Sming/Wiring/Printable.h | 6 +----- Sming/Wiring/SplitString.h | 5 +---- Sming/Wiring/Stream.h | 6 +----- Sming/Wiring/WCharacter.h | 6 +----- Sming/Wiring/WConstants.h | 6 +----- Sming/Wiring/WHashMap.h | 6 +----- Sming/Wiring/WMath.h | 6 +----- Sming/Wiring/WShift.h | 6 +----- Sming/Wiring/WString.h | 5 +---- Sming/Wiring/WVector.h | 6 +----- Sming/Wiring/WiringFrameworkDependencies.h | 6 +----- Sming/Wiring/WiringFrameworkIncludes.h | 5 +---- Sming/Wiring/wiring_private.h | 5 +---- 169 files changed, 172 insertions(+), 644 deletions(-) diff --git a/Sming/Arch/Esp8266/Components/driver/include/driver/uart.h b/Sming/Arch/Esp8266/Components/driver/include/driver/uart.h index 3fa55ce26b..c73feafeeb 100644 --- a/Sming/Arch/Esp8266/Components/driver/include/driver/uart.h +++ b/Sming/Arch/Esp8266/Components/driver/include/driver/uart.h @@ -34,8 +34,7 @@ * Note: uart_detach_all() should be called at startup, i.e. from user_init(). */ -#ifndef ESP_UART_H -#define ESP_UART_H +#pragma once #if defined (__cplusplus) extern "C" { @@ -427,5 +426,3 @@ void uart_restore_interrupts(); #if defined (__cplusplus) } // extern "C" #endif - -#endif // ESP_UART_H diff --git a/Sming/Arch/Esp8266/Components/esp8266/include/esp_cplusplus.h b/Sming/Arch/Esp8266/Components/esp8266/include/esp_cplusplus.h index f1715690fe..8d6ad827af 100644 --- a/Sming/Arch/Esp8266/Components/esp8266/include/esp_cplusplus.h +++ b/Sming/Arch/Esp8266/Components/esp8266/include/esp_cplusplus.h @@ -8,8 +8,7 @@ * ****/ -#ifndef _SYSTEM_INCLUDE_ESP_CPLUSPLUS_H_ -#define _SYSTEM_INCLUDE_ESP_CPLUSPLUS_H_ +#pragma once #ifdef __cplusplus extern "C" { @@ -23,5 +22,3 @@ extern void (*__init_array_start)(void); extern void (*__init_array_end)(void); void cpp_core_initialize(); - -#endif /* _SYSTEM_INCLUDE_ESP_CPLUSPLUS_H_ */ diff --git a/Sming/Arch/Esp8266/Components/esp8266/include/esp_systemapi.h b/Sming/Arch/Esp8266/Components/esp8266/include/esp_systemapi.h index 061a728b95..52435eda60 100644 --- a/Sming/Arch/Esp8266/Components/esp8266/include/esp_systemapi.h +++ b/Sming/Arch/Esp8266/Components/esp8266/include/esp_systemapi.h @@ -10,8 +10,7 @@ * ****/ -#ifndef _SYSTEM_INCLUDE_ESP_SYSTEMAPI_H_ -#define _SYSTEM_INCLUDE_ESP_SYSTEMAPI_H_ +#pragma once #include #include @@ -126,5 +125,3 @@ extern void ets_isr_mask(unsigned intr); extern void ets_isr_unmask(unsigned intr); typedef signed short file_t; - -#endif /* _SYSTEM_INCLUDE_ESP_SYSTEMAPI_H_ */ diff --git a/Sming/Arch/Esp8266/Components/esp8266/include/esp_wifi_sniffer.h b/Sming/Arch/Esp8266/Components/esp8266/include/esp_wifi_sniffer.h index 0da292c228..acf1d18530 100644 --- a/Sming/Arch/Esp8266/Components/esp8266/include/esp_wifi_sniffer.h +++ b/Sming/Arch/Esp8266/Components/esp8266/include/esp_wifi_sniffer.h @@ -6,8 +6,7 @@ * See ESP8266 Technical Reference, Chapter 14: Sniffer Introduction */ -#ifndef _ESP_WIFI_SNIFFER_H_ -#define _ESP_WIFI_SNIFFER_H_ +#pragma once #include @@ -60,5 +59,3 @@ struct sniffer_buf2 { uint16_t cnt; uint16_t len; }; - -#endif /* _ESP_WIFI_SNIFFER_H_ */ diff --git a/Sming/Arch/Esp8266/Components/esp8266/include/espinc/c_types_compatible.h b/Sming/Arch/Esp8266/Components/esp8266/include/espinc/c_types_compatible.h index 2c9462fd0a..b466070ea0 100644 --- a/Sming/Arch/Esp8266/Components/esp8266/include/espinc/c_types_compatible.h +++ b/Sming/Arch/Esp8266/Components/esp8266/include/espinc/c_types_compatible.h @@ -6,8 +6,7 @@ // Updated, compatible version of c_types.h // Just removed types declared in -#ifndef _SYSTEM_INCLUDE_ESPINC_C_TYPES_COMPATIBLE_H_ -#define _SYSTEM_INCLUDE_ESPINC_C_TYPES_COMPATIBLE_H_ +#pragma once /*typedef unsigned char uint8_t; typedef signed char sint8_t; @@ -100,5 +99,3 @@ typedef unsigned char bool; #endif /* !__cplusplus */ - -#endif /* _SYSTEM_INCLUDE_ESPINC_C_TYPES_COMPATIBLE_H_ */ diff --git a/Sming/Arch/Esp8266/Components/esp8266/include/espinc/lwip_includes.h b/Sming/Arch/Esp8266/Components/esp8266/include/espinc/lwip_includes.h index 3f76df603d..a711646608 100644 --- a/Sming/Arch/Esp8266/Components/esp8266/include/espinc/lwip_includes.h +++ b/Sming/Arch/Esp8266/Components/esp8266/include/espinc/lwip_includes.h @@ -5,8 +5,7 @@ * Author: Anakonda */ -#ifndef _SYSTEM_INCLUDE_ESPINC_LWIP_INCLUDES_H_ -#define _SYSTEM_INCLUDE_ESPINC_LWIP_INCLUDES_H_ +#pragma once #include #include @@ -15,5 +14,3 @@ #include #include #include - -#endif /* _SYSTEM_INCLUDE_ESPINC_LWIP_INCLUDES_H_ */ diff --git a/Sming/Arch/Esp8266/Components/esp8266/include/espinc/peri.h b/Sming/Arch/Esp8266/Components/esp8266/include/espinc/peri.h index 36835bffab..83ea7be52a 100644 --- a/Sming/Arch/Esp8266/Components/esp8266/include/espinc/peri.h +++ b/Sming/Arch/Esp8266/Components/esp8266/include/espinc/peri.h @@ -19,8 +19,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef _SYSTEM_INCLUDE_ESPINC_PERI_H_ -#define _SYSTEM_INCLUDE_ESPINC_PERI_H_ +#pragma once #ifdef __cplusplus extern "C" { @@ -850,5 +849,3 @@ extern const uint8_t esp8266_gpioToFn[16]; #ifdef __cplusplus } #endif - -#endif /* _SYSTEM_INCLUDE_ESPINC_PERI_H_ */ diff --git a/Sming/Arch/Esp8266/Components/esp8266/include/espinc/spi_register.h b/Sming/Arch/Esp8266/Components/esp8266/include/espinc/spi_register.h index 1cdac7f542..cb9000a260 100644 --- a/Sming/Arch/Esp8266/Components/esp8266/include/espinc/spi_register.h +++ b/Sming/Arch/Esp8266/Components/esp8266/include/espinc/spi_register.h @@ -8,8 +8,7 @@ * names of these defines are likely to change. */ -#ifndef _SYSTEM_INCLUDE_ESPINC_SPI_REGISTER_H_ -#define _SYSTEM_INCLUDE_ESPINC_SPI_REGISTER_H_ +#pragma once #define REG_SPI_BASE(i) (0x60000200-i*0x100) @@ -275,5 +274,3 @@ #define SPI_EXT3(i) (REG_SPI_BASE(i) + 0xFC) #define SPI_INT_HOLD_ENA 0x00000003 #define SPI_INT_HOLD_ENA_S 0 - -#endif /* _SYSTEM_INCLUDE_ESPINC_SPI_REGISTER_H_ */ diff --git a/Sming/Arch/Esp8266/Components/esp8266/include/espinc/uart_register.h b/Sming/Arch/Esp8266/Components/esp8266/include/espinc/uart_register.h index 1e7effe436..c33f1a1a1e 100644 --- a/Sming/Arch/Esp8266/Components/esp8266/include/espinc/uart_register.h +++ b/Sming/Arch/Esp8266/Components/esp8266/include/espinc/uart_register.h @@ -4,8 +4,7 @@ * */ -#ifndef _SYSTEM_INCLUDE_ESPINC_UART_REGISTER_H_ -#define _SYSTEM_INCLUDE_ESPINC_UART_REGISTER_H_ +#pragma once #define REG_UART_BASE( i ) (0x60000000+(i)*0xf00) //version value:32'h062000 @@ -130,5 +129,3 @@ #define UART_DATE( i ) (REG_UART_BASE( i ) + 0x78) #define UART_ID( i ) (REG_UART_BASE( i ) + 0x7C) - -#endif /* _SYSTEM_INCLUDE_ESPINC_UART_REGISTER_H_ */ diff --git a/Sming/Arch/Esp8266/Components/esp8266/include/flashmem.h b/Sming/Arch/Esp8266/Components/esp8266/include/flashmem.h index 6e1c31de66..ec354ca9d8 100644 --- a/Sming/Arch/Esp8266/Components/esp8266/include/flashmem.h +++ b/Sming/Arch/Esp8266/Components/esp8266/include/flashmem.h @@ -9,8 +9,7 @@ * ****/ -#ifndef _SYSTEM_INCLUDE_FLASHMEM_H_ -#define _SYSTEM_INCLUDE_FLASHMEM_H_ +#pragma once #ifdef __cplusplus extern "C" { @@ -160,5 +159,3 @@ uint32_t flashmem_get_first_free_block_address(); #ifdef __cplusplus } #endif - -#endif /* _SYSTEM_INCLUDE_FLASHMEM_H_ */ diff --git a/Sming/Arch/Esp8266/Components/gdbstub/GdbPacket.h b/Sming/Arch/Esp8266/Components/gdbstub/GdbPacket.h index 1ab8a2d9e3..a3f23030e6 100644 --- a/Sming/Arch/Esp8266/Components/gdbstub/GdbPacket.h +++ b/Sming/Arch/Esp8266/Components/gdbstub/GdbPacket.h @@ -12,8 +12,7 @@ * ****/ -#ifndef _GDB_GDB_PACKET_H_ -#define _GDB_GDB_PACKET_H_ +#pragma once #include "gdbuart.h" @@ -108,5 +107,3 @@ class GdbPacket uint8_t checksum = 0; ///< Running checksum of the output packet unsigned packetLength = 0; }; - -#endif /* _GDB_GDB_PACKET_H_ */ diff --git a/Sming/Arch/Esp8266/Components/gdbstub/exceptions.h b/Sming/Arch/Esp8266/Components/gdbstub/exceptions.h index 2072dce910..3f7cddb684 100644 --- a/Sming/Arch/Esp8266/Components/gdbstub/exceptions.h +++ b/Sming/Arch/Esp8266/Components/gdbstub/exceptions.h @@ -10,8 +10,7 @@ * ****/ -#ifndef _GDB_EXCEPTIONS_H_ -#define _GDB_EXCEPTIONS_H_ +#pragma once #include #include "gdb/signals.h" @@ -57,5 +56,3 @@ XX(STORE_PROHIBITED, GDB_SIGNAL_SEGV, "Cache Attribute does not allow Store") #define EXCCAUSE_MAX EXCCAUSE_STORE_PROHIBITED - -#endif /* _GDB_EXCEPTION_MAP_H_ */ diff --git a/Sming/Arch/Esp8266/Components/gdbstub/gdb/registers.h b/Sming/Arch/Esp8266/Components/gdbstub/gdb/registers.h index ec5e8eeb22..b6e2bda2d6 100644 --- a/Sming/Arch/Esp8266/Components/gdbstub/gdb/registers.h +++ b/Sming/Arch/Esp8266/Components/gdbstub/gdb/registers.h @@ -10,8 +10,7 @@ * ****/ -#ifndef _GDB_REGISTERS_H_ -#define _GDB_REGISTERS_H_ +#pragma once #include "gdbstub-cfg.h" #include "signals.h" @@ -175,5 +174,3 @@ enum GdbReg { XT_REGISTER_MAP(XX) #undef XX }; - -#endif /* _GDB_REGISTERS_H_ */ diff --git a/Sming/Arch/Esp8266/Components/gdbstub/gdbhostio.h b/Sming/Arch/Esp8266/Components/gdbstub/gdbhostio.h index 2be22e6019..34221f46e5 100644 --- a/Sming/Arch/Esp8266/Components/gdbstub/gdbhostio.h +++ b/Sming/Arch/Esp8266/Components/gdbstub/gdbhostio.h @@ -10,9 +10,6 @@ * ****/ -#ifndef GDB_GDBHOSTIO_H_ -#define GDB_GDBHOSTIO_H_ +#pragma once void gdbHandleHostIo(char* commandBuffer, unsigned cmdLen); - -#endif /* GDB_GDBHOSTIO_H_ */ diff --git a/Sming/Arch/Esp8266/Components/gdbstub/gdbstub-cfg.h b/Sming/Arch/Esp8266/Components/gdbstub/gdbstub-cfg.h index d31120ee5e..21ed401a4f 100644 --- a/Sming/Arch/Esp8266/Components/gdbstub/gdbstub-cfg.h +++ b/Sming/Arch/Esp8266/Components/gdbstub/gdbstub-cfg.h @@ -10,8 +10,7 @@ * ****/ -#ifndef _GDB_GDBSTUB_CFG_H_ -#define _GDB_GDBSTUB_CFG_H_ +#pragma once /* * When enabled, an exception or crash dumps a stack trace to debug output @@ -180,5 +179,3 @@ #ifndef GDBSTUB_FORCE_IRAM #define GDBSTUB_FORCE_IRAM 0 #endif - -#endif /* _GDB_GDBSTUB_CFG_H_ */ diff --git a/Sming/Arch/Esp8266/Components/gdbstub/gdbstub-entry.h b/Sming/Arch/Esp8266/Components/gdbstub/gdbstub-entry.h index 09575bec1f..b99395045b 100644 --- a/Sming/Arch/Esp8266/Components/gdbstub/gdbstub-entry.h +++ b/Sming/Arch/Esp8266/Components/gdbstub/gdbstub-entry.h @@ -6,8 +6,7 @@ * License: ESPRESSIF MIT License *******************************************************************************/ -#ifndef _GDBSTUB_ENTRY_H_ -#define _GDBSTUB_ENTRY_H_ +#pragma once #ifdef __cplusplus extern "C" { @@ -27,5 +26,3 @@ extern void* gdbstub_do_break_breakpoint_addr; #ifdef __cplusplus } #endif - -#endif /* _GDBSTUB_ENTRY_H_ */ diff --git a/Sming/Arch/Esp8266/Components/gdbstub/gdbstub-internal.h b/Sming/Arch/Esp8266/Components/gdbstub/gdbstub-internal.h index b145d8f522..3c3830304f 100644 --- a/Sming/Arch/Esp8266/Components/gdbstub/gdbstub-internal.h +++ b/Sming/Arch/Esp8266/Components/gdbstub/gdbstub-internal.h @@ -10,8 +10,7 @@ * ****/ -#ifndef _GDB_GDBSTUB_INTERNAL_H_ -#define _GDB_GDBSTUB_INTERNAL_H_ +#pragma once #include "xtensa/xtruntime-frames.h" #include "gdbstub-cfg.h" @@ -74,5 +73,3 @@ STRUCT_END(GdbstubSavedRegisters) // Section definitions for assembler #define ASATTR_GDBINIT .section .irom0.text #define ASATTR_GDBFN .section .iram.text - -#endif /* _GDB_GDBSTUB_INTERNAL_H_ */ diff --git a/Sming/Arch/Esp8266/Components/gdbstub/gdbstub.h b/Sming/Arch/Esp8266/Components/gdbstub/gdbstub.h index 3122e69b1e..04791ed2e9 100644 --- a/Sming/Arch/Esp8266/Components/gdbstub/gdbstub.h +++ b/Sming/Arch/Esp8266/Components/gdbstub/gdbstub.h @@ -10,8 +10,7 @@ * ****/ -#ifndef _GDB_GDBSTUB_H_ -#define _GDB_GDBSTUB_H_ +#pragma once #include "gdbstub-internal.h" #include @@ -65,5 +64,3 @@ void gdbstub_handle_exception(); // Optimise GDB stub code for size, regardless of application settings #pragma GCC optimize("Os") #endif - -#endif /* _GDB_GDBSTUB_H_ */ diff --git a/Sming/Arch/Esp8266/Components/gdbstub/gdbsyscall.h b/Sming/Arch/Esp8266/Components/gdbstub/gdbsyscall.h index 226e3791b3..d47ecdf83d 100644 --- a/Sming/Arch/Esp8266/Components/gdbstub/gdbsyscall.h +++ b/Sming/Arch/Esp8266/Components/gdbstub/gdbsyscall.h @@ -10,8 +10,7 @@ * ****/ -#ifndef _GDB_GDBSYSCALL_H_ -#define _GDB_GDBSYSCALL_H_ +#pragma once #include "gdbstub.h" @@ -29,5 +28,3 @@ void gdbstub_syscall_execute(); * Fretcode,errno,Ctrl-C flag;call-specific attachment */ bool gdb_syscall_complete(const char* data); - -#endif /* _GDB_GDBSYSCALL_H_ */ diff --git a/Sming/Arch/Esp8266/Components/gdbstub/gdbuart.h b/Sming/Arch/Esp8266/Components/gdbstub/gdbuart.h index fd5fbd9a2a..20a4b17e15 100644 --- a/Sming/Arch/Esp8266/Components/gdbstub/gdbuart.h +++ b/Sming/Arch/Esp8266/Components/gdbstub/gdbuart.h @@ -8,8 +8,7 @@ * ****/ -#ifndef _GDB_GDBUART_H_ -#define _GDB_GDBUART_H_ +#pragma once #include "gdbstub.h" @@ -53,5 +52,3 @@ size_t gdbSendUserData(); * @brief Ensure all user data has been written to serial port */ void gdbFlushUserData(); - -#endif /* _GDB_GDBUART_H_ */ diff --git a/Sming/Arch/Esp8266/Components/rboot/appcode/rboot-integration.h b/Sming/Arch/Esp8266/Components/rboot/appcode/rboot-integration.h index 21efd81241..269f53d47a 100644 --- a/Sming/Arch/Esp8266/Components/rboot/appcode/rboot-integration.h +++ b/Sming/Arch/Esp8266/Components/rboot/appcode/rboot-integration.h @@ -8,8 +8,7 @@ * ****/ -#ifndef _SYSTEM_INCLUDE_RBOOT_INTEGRATION_H_ -#define _SYSTEM_INCLUDE_RBOOT_INTEGRATION_H_ +#pragma once // prevent sming user_config.h being included #define __USER_CONFIG_H__ @@ -19,5 +18,3 @@ // missing prototypes for sdk functions #include - -#endif /* _SYSTEM_INCLUDE_RBOOT_INTEGRATION_H_ */ diff --git a/Sming/Arch/Esp8266/Components/spiffs/spiffs_sming.h b/Sming/Arch/Esp8266/Components/spiffs/spiffs_sming.h index 31cb89eaa8..3c628e5272 100644 --- a/Sming/Arch/Esp8266/Components/spiffs/spiffs_sming.h +++ b/Sming/Arch/Esp8266/Components/spiffs/spiffs_sming.h @@ -1,6 +1,6 @@ -#ifndef SPIFFS_SMING_H_ -#define SPIFFS_SMING_H_ +#pragma once + #if defined(__cplusplus) extern "C" { #endif @@ -22,4 +22,3 @@ extern spiffs _filesystemStorageHandle; #if defined(__cplusplus) } #endif -#endif /* SPIFFS_SMING_H_ */ diff --git a/Sming/Arch/Esp8266/Components/spiffs/spiffy_host.h b/Sming/Arch/Esp8266/Components/spiffs/spiffy_host.h index c9dde30e1c..8f7bd65ea2 100644 --- a/Sming/Arch/Esp8266/Components/spiffs/spiffy_host.h +++ b/Sming/Arch/Esp8266/Components/spiffs/spiffy_host.h @@ -1,5 +1,5 @@ -#ifndef SERVICES_SPIFFS_SPIFFY_HOST_H_ -#define SERVICES_SPIFFS_SPIFFY_HOST_H_ + +#pragma once #include #include @@ -42,6 +42,3 @@ typedef signed short s16_t; typedef unsigned short u16_t; typedef signed char s8_t; typedef unsigned char u8_t; - - -#endif /* SERVICES_SPIFFS_SPIFFY_HOST_H_ */ diff --git a/Sming/Arch/Esp8266/Core/ESP8266EX.h b/Sming/Arch/Esp8266/Core/ESP8266EX.h index 664c5f6bdd..3f877f40ca 100644 --- a/Sming/Arch/Esp8266/Core/ESP8266EX.h +++ b/Sming/Arch/Esp8266/Core/ESP8266EX.h @@ -8,8 +8,7 @@ * ****/ -#ifndef _SMING_CORE_ESP8266EX_H_ -#define _SMING_CORE_ESP8266EX_H_ +#pragma once #include "user_config.h" @@ -37,5 +36,3 @@ struct EspDigitalPin { * @ingroup gpio */ extern const EspDigitalPin EspDigitalPins[]; - -#endif /* _SMING_CORE_ESP8266EX_H_ */ diff --git a/Sming/Arch/Esp8266/Core/Network/rBootHttpUpdate.h b/Sming/Arch/Esp8266/Core/Network/rBootHttpUpdate.h index 763c3e6948..6c1949fdf4 100644 --- a/Sming/Arch/Esp8266/Core/Network/rBootHttpUpdate.h +++ b/Sming/Arch/Esp8266/Core/Network/rBootHttpUpdate.h @@ -13,8 +13,7 @@ * ****/ -#ifndef _SMING_CORE_NETWORK_RBOOT_HTTP_UPDATE_H_ -#define _SMING_CORE_NETWORK_RBOOT_HTTP_UPDATE_H_ +#pragma once #include "Data/Stream/DataSourceStream.h" #include "Network/HttpClient.h" @@ -138,5 +137,3 @@ class rBootHttpUpdate : protected HttpClient HttpRequest* baseRequest = nullptr; }; - -#endif /* _SMING_CORE_NETWORK_RBOOT_HTTP_UPDATE_H_ */ diff --git a/Sming/Arch/Esp8266/Core/pins_arduino.h b/Sming/Arch/Esp8266/Core/pins_arduino.h index 8104fa677b..1e368312f0 100644 --- a/Sming/Arch/Esp8266/Core/pins_arduino.h +++ b/Sming/Arch/Esp8266/Core/pins_arduino.h @@ -10,8 +10,7 @@ // File name selected for compatibility -#ifndef _SMING_CORE_PINS_ARDUINO_H_ -#define _SMING_CORE_PINS_ARDUINO_H_ +#pragma once #include "espinc/peri.h" @@ -35,5 +34,3 @@ extern const unsigned int A0; // Single ESP8266EX analog input pin (TOUT) 10 bit #define portOutputRegister(port) ((volatile uint32_t*)&GPO) #define portInputRegister(port) ((volatile uint32_t*)&GPI) #define portModeRegister(port) ((volatile uint32_t*)&GPE) - -#endif /* _SMING_CORE_PINS_ARDUINO_H_ */ diff --git a/Sming/Core/ArduinoCompat.h b/Sming/Core/ArduinoCompat.h index c3edd701c3..eba5c6bd1c 100644 --- a/Sming/Core/ArduinoCompat.h +++ b/Sming/Core/ArduinoCompat.h @@ -10,8 +10,7 @@ * ****/ -#ifndef _SMING_CORE_ARDUINO_COMPAT_H_ -#define _SMING_CORE_ARDUINO_COMPAT_H_ +#pragma once #include "SmingCore.h" #include ///< sprintf() @@ -28,5 +27,3 @@ void yield(); #ifdef __cplusplus } #endif - -#endif /* _SMING_CORE_ARDUINO_COMPAT_H_ */ diff --git a/Sming/Core/AtClient.h b/Sming/Core/AtClient.h index 97a31ba025..6fadb807d5 100644 --- a/Sming/Core/AtClient.h +++ b/Sming/Core/AtClient.h @@ -13,8 +13,7 @@ * @{ */ -#ifndef _SMING_CORE_ATCLIENT_H_ -#define _SMING_CORE_ATCLIENT_H_ +#pragma once #include "HardwareSerial.h" #include "FILO.h" @@ -152,4 +151,3 @@ class AtClient */ /** @} */ -#endif /* _SMING_CORE_ATCLIENT_H_ */ diff --git a/Sming/Core/Clock.h b/Sming/Core/Clock.h index 26d68752ff..fb45a4c0cd 100644 --- a/Sming/Core/Clock.h +++ b/Sming/Core/Clock.h @@ -14,8 +14,7 @@ * @{ */ -#ifndef _SMING_CORE_CLOCK_H_ -#define _SMING_CORE_CLOCK_H_ +#pragma once #include "WiringFrameworkDependencies.h" @@ -60,4 +59,3 @@ void delayMicroseconds(uint32_t time); #endif /** @} */ -#endif /* _SMING_CORE_CLOCK_H_ */ diff --git a/Sming/Core/Data/Buffer/CircularBuffer.h b/Sming/Core/Data/Buffer/CircularBuffer.h index f95d86bdda..4ff0ec746e 100644 --- a/Sming/Core/Data/Buffer/CircularBuffer.h +++ b/Sming/Core/Data/Buffer/CircularBuffer.h @@ -13,8 +13,7 @@ * ****/ -#ifndef _SMING_CORE_DATA_BUFFER_CIRCULAR_BUFFER_H_ -#define _SMING_CORE_DATA_BUFFER_CIRCULAR_BUFFER_H_ +#pragma once #include "Stream/ReadWriteStream.h" @@ -119,4 +118,3 @@ class CircularBuffer : public ReadWriteStream }; /** @} */ -#endif /* _SMING_CORE_DATA_BUFFER_CIRCULAR_BUFFER_H_ */ diff --git a/Sming/Core/Data/Buffer/LineBuffer.h b/Sming/Core/Data/Buffer/LineBuffer.h index 79a6fa8418..2ce0f6172f 100644 --- a/Sming/Core/Data/Buffer/LineBuffer.h +++ b/Sming/Core/Data/Buffer/LineBuffer.h @@ -10,8 +10,7 @@ * ****/ -#ifndef _SMING_CORE_DATA_BUFFER_LINE_BUFFER_H_ -#define _SMING_CORE_DATA_BUFFER_LINE_BUFFER_H_ +#pragma once #include @@ -113,5 +112,3 @@ template bool LineBuffer::contains(const char* text) { return strstr(buffer, text) != nullptr; } - -#endif /* _SMING_CORE_DATA_BUFFER_LINE_BUFFER_H_ */ diff --git a/Sming/Core/Data/Buffer/SerialBuffer.h b/Sming/Core/Data/Buffer/SerialBuffer.h index ca4122ebe2..d98b5551da 100644 --- a/Sming/Core/Data/Buffer/SerialBuffer.h +++ b/Sming/Core/Data/Buffer/SerialBuffer.h @@ -10,8 +10,7 @@ * ****/ -#ifndef _SMING_CORE_DATA_BUFFER_SERIAL_BUFFER_H_ -#define _SMING_CORE_DATA_BUFFER_SERIAL_BUFFER_H_ +#pragma once #include @@ -165,5 +164,3 @@ struct SerialBuffer { size_t writePos = 0; char* buffer = nullptr; }; - -#endif // _SMING_CORE_DATA_BUFFER_SERIAL_BUFFER_H_ diff --git a/Sming/Core/Data/CStringArray.h b/Sming/Core/Data/CStringArray.h index 862a537544..39fe75a04e 100644 --- a/Sming/Core/Data/CStringArray.h +++ b/Sming/Core/Data/CStringArray.h @@ -10,8 +10,7 @@ * ****/ -#ifndef _SMING_CORE_DATA_C_STRING_ARRAY_H_ -#define _SMING_CORE_DATA_C_STRING_ARRAY_H_ +#pragma once #include "WString.h" @@ -120,5 +119,3 @@ class CStringArray : protected String private: mutable unsigned stringCount = 0; }; - -#endif // _SMING_CORE_DATA_C_STRING_ARRAY_H_ diff --git a/Sming/Core/Data/HexString.h b/Sming/Core/Data/HexString.h index c90a6c8c6d..3b813e6190 100644 --- a/Sming/Core/Data/HexString.h +++ b/Sming/Core/Data/HexString.h @@ -10,8 +10,7 @@ * */ -#ifndef _SMING_CORE_DATA_HEX_STRING_H_ -#define _SMING_CORE_DATA_HEX_STRING_H_ +#pragma once #include "WString.h" @@ -22,5 +21,3 @@ * @retval String */ String makeHexString(const uint8_t* data, unsigned length, char separator = '\0'); - -#endif /* _SMING_CORE_DATA_HEX_STRING_H_ */ diff --git a/Sming/Core/Data/MailMessage.h b/Sming/Core/Data/MailMessage.h index 665c432576..39ffc0db8c 100644 --- a/Sming/Core/Data/MailMessage.h +++ b/Sming/Core/Data/MailMessage.h @@ -16,8 +16,7 @@ * @{ */ -#ifndef _SMING_CORE_DATA_MAIL_MESSAGE_H_ -#define _SMING_CORE_DATA_MAIL_MESSAGE_H_ +#pragma once #include "WString.h" #include "WVector.h" @@ -79,4 +78,3 @@ class MailMessage }; /** @} */ -#endif /* _SMING_CORE_DATA_MAIL_MESSAGE_H_ */ diff --git a/Sming/Core/Data/ObjectMap.h b/Sming/Core/Data/ObjectMap.h index 73ad2c4f00..e679ce31e8 100644 --- a/Sming/Core/Data/ObjectMap.h +++ b/Sming/Core/Data/ObjectMap.h @@ -10,8 +10,7 @@ * */ -#ifndef _SMING_CORE_DATA_OBJECT_MAP_H_ -#define _SMING_CORE_DATA_OBJECT_MAP_H_ +#pragma once #include "WVector.h" @@ -340,5 +339,3 @@ template class ObjectMap // Copy constructor unsafe, so prevent access ObjectMap(ObjectMap& that); }; - -#endif // _SMING_CORE_DATA_OBJECT_MAP_H_ diff --git a/Sming/Core/Data/ObjectQueue.h b/Sming/Core/Data/ObjectQueue.h index 5102c0012d..1bb1337f7c 100644 --- a/Sming/Core/Data/ObjectQueue.h +++ b/Sming/Core/Data/ObjectQueue.h @@ -13,8 +13,7 @@ * ****/ -#ifndef _SMING_CORE_DATA_OBJECT_QUEUE_H_ -#define _SMING_CORE_DATA_OBJECT_QUEUE_H_ +#pragma once #include "WString.h" #include "WHashMap.h" @@ -41,4 +40,3 @@ template class ObjectQueue : public FIFO } }; -#endif /* _SMING_CORE_DATA_OBJECT_QUEUE_H_ */ diff --git a/Sming/Core/Data/Stream/Base64OutputStream.h b/Sming/Core/Data/Stream/Base64OutputStream.h index 32c08c9e45..c25d97decc 100644 --- a/Sming/Core/Data/Stream/Base64OutputStream.h +++ b/Sming/Core/Data/Stream/Base64OutputStream.h @@ -10,8 +10,7 @@ * ****/ -#ifndef _SMING_CORE_DATA_STREAM_BASE64_OUTPUT_STREAM_H_ -#define _SMING_CORE_DATA_STREAM_BASE64_OUTPUT_STREAM_H_ +#pragma once #include "../StreamTransformer.h" #include "libb64/cencode.h" @@ -51,4 +50,3 @@ class Base64OutputStream : public StreamTransformer }; /** @} */ -#endif /* _SMING_CORE_DATA_STREAM_BASE64_OUTPUT_STREAM_H_ */ diff --git a/Sming/Core/Data/Stream/ChunkedStream.h b/Sming/Core/Data/Stream/ChunkedStream.h index 1d43ae98ca..a85c12fb1f 100644 --- a/Sming/Core/Data/Stream/ChunkedStream.h +++ b/Sming/Core/Data/Stream/ChunkedStream.h @@ -10,8 +10,7 @@ * ****/ -#ifndef _SMING_CORE_DATA_STREAM_CHUNKED_STREAM_H_ -#define _SMING_CORE_DATA_STREAM_CHUNKED_STREAM_H_ +#pragma once #include "../StreamTransformer.h" @@ -32,4 +31,3 @@ class ChunkedStream : public StreamTransformer }; /** @} */ -#endif /* _SMING_CORE_DATA_STREAM_CHUNKED_STREAM_H_ */ diff --git a/Sming/Core/Data/Stream/DataSourceStream.h b/Sming/Core/Data/Stream/DataSourceStream.h index da4f0d3b86..4728689928 100644 --- a/Sming/Core/Data/Stream/DataSourceStream.h +++ b/Sming/Core/Data/Stream/DataSourceStream.h @@ -8,8 +8,7 @@ * ****/ -#ifndef _SMING_CORE_DATA_STREAM_DATA_SOURCE_STREAM_H_ -#define _SMING_CORE_DATA_STREAM_DATA_SOURCE_STREAM_H_ +#pragma once #include #include "Stream.h" @@ -144,4 +143,3 @@ class IDataSourceStream : public Stream }; /** @} */ -#endif /* _SMING_CORE_DATA_STREAM_DATA_SOURCE_STREAM_H_ */ diff --git a/Sming/Core/Data/Stream/EndlessMemoryStream.h b/Sming/Core/Data/Stream/EndlessMemoryStream.h index e32e2ee292..79c2c9c395 100644 --- a/Sming/Core/Data/Stream/EndlessMemoryStream.h +++ b/Sming/Core/Data/Stream/EndlessMemoryStream.h @@ -8,8 +8,7 @@ * ****/ -#ifndef _SMING_CORE_DATA_STREAM_ENDLESS_MEMORY_STREAM_H_ -#define _SMING_CORE_DATA_STREAM_ENDLESS_MEMORY_STREAM_H_ +#pragma once #include "MemoryDataStream.h" @@ -62,4 +61,3 @@ class EndlessMemoryStream : public ReadWriteStream }; /** @} */ -#endif /* _SMING_CORE_DATA_STREAM_ENDLESS_MEMORY_STREAM_H_ */ diff --git a/Sming/Core/Data/Stream/FileStream.h b/Sming/Core/Data/Stream/FileStream.h index cceaede41c..46d7ef72e8 100644 --- a/Sming/Core/Data/Stream/FileStream.h +++ b/Sming/Core/Data/Stream/FileStream.h @@ -8,8 +8,7 @@ * ****/ -#ifndef _SMING_CORE_DATA_FILE_STREAM_H_ -#define _SMING_CORE_DATA_FILE_STREAM_H_ +#pragma once #include "ReadWriteStream.h" #include "FileSystem.h" @@ -160,4 +159,3 @@ class FileStream : public ReadWriteStream /** @} */ -#endif /* _SMING_CORE_DATA_FILE_STREAM_H_ */ diff --git a/Sming/Core/Data/Stream/FlashMemoryStream.h b/Sming/Core/Data/Stream/FlashMemoryStream.h index 29a4643fee..93914bd3dd 100644 --- a/Sming/Core/Data/Stream/FlashMemoryStream.h +++ b/Sming/Core/Data/Stream/FlashMemoryStream.h @@ -10,8 +10,7 @@ * ****/ -#ifndef _SMING_CORE_DATA_STREAM_FLASH_MEMORY_STREAM_H_ -#define _SMING_CORE_DATA_STREAM_FLASH_MEMORY_STREAM_H_ +#pragma once #include "DataSourceStream.h" @@ -61,4 +60,3 @@ class FlashMemoryStream : public IDataSourceStream }; /** @} */ -#endif /* _SMING_CORE_DATA_STREAM_FLASH_MEMORY_STREAM_H_ */ diff --git a/Sming/Core/Data/Stream/GdbFileStream.h b/Sming/Core/Data/Stream/GdbFileStream.h index ff101306f6..acc2f3e985 100644 --- a/Sming/Core/Data/Stream/GdbFileStream.h +++ b/Sming/Core/Data/Stream/GdbFileStream.h @@ -8,8 +8,7 @@ * ****/ -#ifndef _SMING_CORE_DATA_GDB_FILE_STREAM_H_ -#define _SMING_CORE_DATA_GDB_FILE_STREAM_H_ +#pragma once #include "ReadWriteStream.h" #include "FileSystem.h" @@ -140,5 +139,3 @@ class GdbFileStream : public ReadWriteStream size_t size = 0; int lastError = 0; }; - -#endif /* _SMING_CORE_DATA_GDB_FILE_STREAM_H_ */ diff --git a/Sming/Core/Data/Stream/JsonObjectStream.h b/Sming/Core/Data/Stream/JsonObjectStream.h index 33f11fc684..177f419b52 100644 --- a/Sming/Core/Data/Stream/JsonObjectStream.h +++ b/Sming/Core/Data/Stream/JsonObjectStream.h @@ -8,8 +8,7 @@ * ****/ -#ifndef _SMING_CORE_DATA_STREAM_JSON_OBJECT_STREAM_H_ -#define _SMING_CORE_DATA_STREAM_JSON_OBJECT_STREAM_H_ +#pragma once #include "MemoryDataStream.h" #include "Libraries/ArduinoJson/include/ArduinoJson.h" @@ -62,4 +61,3 @@ class JsonObjectStream : public MemoryDataStream }; /** @} */ -#endif /* _SMING_CORE_DATA_STREAM_JSON_OBJECT_STREAM_H_ */ diff --git a/Sming/Core/Data/Stream/LimitedMemoryStream.h b/Sming/Core/Data/Stream/LimitedMemoryStream.h index 32d18ae996..5b6060b677 100644 --- a/Sming/Core/Data/Stream/LimitedMemoryStream.h +++ b/Sming/Core/Data/Stream/LimitedMemoryStream.h @@ -8,8 +8,7 @@ * ****/ -#ifndef _SMING_CORE_DATA_STREAM_LIMITED_MEMORY_STREAM_H_ -#define _SMING_CORE_DATA_STREAM_LIMITED_MEMORY_STREAM_H_ +#pragma once #include "ReadWriteStream.h" @@ -73,4 +72,3 @@ class LimitedMemoryStream : public ReadWriteStream }; /** @} */ -#endif /* _SMING_CORE_DATA_STREAM_LIMITED_MEMORY_STREAM_H_ */ diff --git a/Sming/Core/Data/Stream/MemoryDataStream.h b/Sming/Core/Data/Stream/MemoryDataStream.h index a90433befa..f18afd2506 100644 --- a/Sming/Core/Data/Stream/MemoryDataStream.h +++ b/Sming/Core/Data/Stream/MemoryDataStream.h @@ -8,8 +8,7 @@ * ****/ -#ifndef _SMING_CORE_DATA_STREAM_MEMORY_DATA_STREAM_H_ -#define _SMING_CORE_DATA_STREAM_MEMORY_DATA_STREAM_H_ +#pragma once #include "ReadWriteStream.h" @@ -86,4 +85,3 @@ class MemoryDataStream : public ReadWriteStream }; /** @} */ -#endif /* _SMING_CORE_DATA_STREAM_MEMORY_DATA_STREAM_H_ */ diff --git a/Sming/Core/Data/Stream/MultiStream.h b/Sming/Core/Data/Stream/MultiStream.h index 143b28cdf0..4725dd16fd 100644 --- a/Sming/Core/Data/Stream/MultiStream.h +++ b/Sming/Core/Data/Stream/MultiStream.h @@ -11,8 +11,7 @@ * ****/ -#ifndef _SMING_CORE_DATA_STREAM_MULTISTREAM_H_ -#define _SMING_CORE_DATA_STREAM_MULTISTREAM_H_ +#pragma once #include "DataSourceStream.h" @@ -68,5 +67,3 @@ class MultiStream : public IDataSourceStream bool finished = false; }; - -#endif /* _SMING_CORE_DATA_STREAM_MULTISTREAM_H_ */ diff --git a/Sming/Core/Data/Stream/MultipartStream.h b/Sming/Core/Data/Stream/MultipartStream.h index 7e939962e7..0b0dc58d77 100644 --- a/Sming/Core/Data/Stream/MultipartStream.h +++ b/Sming/Core/Data/Stream/MultipartStream.h @@ -10,8 +10,7 @@ * ****/ -#ifndef _SMING_CORE_DATA_STREAM_MULTIPART_STREAM_H_ -#define _SMING_CORE_DATA_STREAM_MULTIPART_STREAM_H_ +#pragma once #include "MultiStream.h" #include "Delegate.h" @@ -63,4 +62,3 @@ class MultipartStream : public MultiStream }; /** @} */ -#endif /* _SMING_CORE_DATA_STREAM_MULTIPART_STREAM_H_ */ diff --git a/Sming/Core/Data/Stream/QuotedPrintableOutputStream.h b/Sming/Core/Data/Stream/QuotedPrintableOutputStream.h index 6872e63b23..b6d28ee2b0 100644 --- a/Sming/Core/Data/Stream/QuotedPrintableOutputStream.h +++ b/Sming/Core/Data/Stream/QuotedPrintableOutputStream.h @@ -10,8 +10,7 @@ * ****/ -#ifndef _SMING_CORE_DATA_STREAM_QUOTED_PRINTABLE_OUTPUT_STREAM_H_ -#define _SMING_CORE_DATA_STREAM_QUOTED_PRINTABLE_OUTPUT_STREAM_H_ +#pragma once #include "../StreamTransformer.h" @@ -41,4 +40,3 @@ class QuotedPrintableOutputStream : public StreamTransformer }; /** @} */ -#endif /* _SMING_CORE_DATA_STREAM_QUOTED_PRINTABLE_OUTPUT_STREAM_H_ */ diff --git a/Sming/Core/Data/Stream/ReadWriteStream.h b/Sming/Core/Data/Stream/ReadWriteStream.h index c99198a518..bd2994aa8c 100644 --- a/Sming/Core/Data/Stream/ReadWriteStream.h +++ b/Sming/Core/Data/Stream/ReadWriteStream.h @@ -8,8 +8,7 @@ * ****/ -#ifndef _SMING_CORE_DATA_STREAM_READ_WRITE_STREAM_H_ -#define _SMING_CORE_DATA_STREAM_READ_WRITE_STREAM_H_ +#pragma once #include "DataSourceStream.h" @@ -44,4 +43,3 @@ class ReadWriteStream : public IDataSourceStream }; /** @} */ -#endif /* _SMING_CORE_DATA_STREAM_READ_WRITE_STREAM_H_ */ diff --git a/Sming/Core/Data/Stream/StreamChain.h b/Sming/Core/Data/Stream/StreamChain.h index 656c69c87c..696dca17fd 100644 --- a/Sming/Core/Data/Stream/StreamChain.h +++ b/Sming/Core/Data/Stream/StreamChain.h @@ -10,8 +10,7 @@ * ****/ -#ifndef _SMING_CORE_DATA_STREAM_STREAM_CHAIN_H_ -#define _SMING_CORE_DATA_STREAM_STREAM_CHAIN_H_ +#pragma once #include "MultiStream.h" #include "../ObjectQueue.h" @@ -47,5 +46,3 @@ class StreamChain : public MultiStream private: StreamChainQueue queue; }; - -#endif /* _SMING_CORE_DATA_STREAM_STREAM_CHAIN_H_ */ diff --git a/Sming/Core/Data/Stream/TemplateFileStream.h b/Sming/Core/Data/Stream/TemplateFileStream.h index f59a85f04c..b86cd30611 100644 --- a/Sming/Core/Data/Stream/TemplateFileStream.h +++ b/Sming/Core/Data/Stream/TemplateFileStream.h @@ -8,8 +8,7 @@ * ****/ -#ifndef _SMING_CORE_DATA_STREAM_TEMPLATE_FILE_STREAM_H_ -#define _SMING_CORE_DATA_STREAM_TEMPLATE_FILE_STREAM_H_ +#pragma once #include "FileStream.h" #include "TemplateStream.h" @@ -33,5 +32,3 @@ class TemplateFileStream : public TemplateStream }; /** @} */ - -#endif /* _SMING_CORE_DATA_STREAM_TEMPLATE_FILE_STREAM_H_ */ diff --git a/Sming/Core/Data/Stream/TemplateFlashMemoryStream.h b/Sming/Core/Data/Stream/TemplateFlashMemoryStream.h index 2bbb787dbf..63e9d185b6 100644 --- a/Sming/Core/Data/Stream/TemplateFlashMemoryStream.h +++ b/Sming/Core/Data/Stream/TemplateFlashMemoryStream.h @@ -10,8 +10,7 @@ * ****/ -#ifndef _SMING_CORE_DATA_STREAM_TEMPLATE_FLASH_MEMORY_STREAM_H_ -#define _SMING_CORE_DATA_STREAM_TEMPLATE_FLASH_MEMORY_STREAM_H_ +#pragma once #include "FlashMemoryStream.h" #include "TemplateStream.h" @@ -35,5 +34,3 @@ class TemplateFlashMemoryStream : public TemplateStream }; /** @} */ - -#endif /* _SMING_CORE_DATA_STREAM_TEMPLATE_FLASH_MEMORY_STREAM_H_ */ diff --git a/Sming/Core/Data/Stream/TemplateStream.h b/Sming/Core/Data/Stream/TemplateStream.h index 4525d6b3d8..8b8b693ba5 100644 --- a/Sming/Core/Data/Stream/TemplateStream.h +++ b/Sming/Core/Data/Stream/TemplateStream.h @@ -8,8 +8,7 @@ * ****/ -#ifndef _SMING_CORE_DATA_STREAM_TEMPLATE_STREAM_H_ -#define _SMING_CORE_DATA_STREAM_TEMPLATE_STREAM_H_ +#pragma once #include "DataSourceStream.h" #include "WHashMap.h" @@ -125,5 +124,3 @@ class TemplateStream : public IDataSourceStream }; /** @} */ - -#endif /* _SMING_CORE_DATA_STREAM_TEMPLATE_STREAM_H_ */ diff --git a/Sming/Core/Data/Stream/UrlencodedOutputStream.h b/Sming/Core/Data/Stream/UrlencodedOutputStream.h index 7549758607..7afc44b046 100644 --- a/Sming/Core/Data/Stream/UrlencodedOutputStream.h +++ b/Sming/Core/Data/Stream/UrlencodedOutputStream.h @@ -10,8 +10,7 @@ * ****/ -#ifndef _SMING_CORE_DATA_URL_ENCODDED_OUTPUT_STREAM_H_ -#define _SMING_CORE_DATA_URL_ENCODDED_OUTPUT_STREAM_H_ +#pragma once #include "MemoryDataStream.h" #include "Network/Http/HttpParams.h" @@ -70,4 +69,3 @@ class UrlencodedOutputStream : public IDataSourceStream }; /** @} */ -#endif /* _SMING_CORE_DATA_URL_ENCODDED_OUTPUT_STREAM_H_ */ diff --git a/Sming/Core/Data/StreamTransformer.h b/Sming/Core/Data/StreamTransformer.h index 8b76acc80a..d5ab6d38c6 100644 --- a/Sming/Core/Data/StreamTransformer.h +++ b/Sming/Core/Data/StreamTransformer.h @@ -10,8 +10,7 @@ * ****/ -#ifndef _SMING_CORE_DATA_STREAM_TRANSFORMER_H_ -#define _SMING_CORE_DATA_STREAM_TRANSFORMER_H_ +#pragma once #include "Buffer/CircularBuffer.h" @@ -120,4 +119,3 @@ class StreamTransformer : public IDataSourceStream }; /** @} */ -#endif /* _SMING_CORE_DATA_STREAM_TRANSFORMER_H_ */ diff --git a/Sming/Core/DateTime.h b/Sming/Core/DateTime.h index 290348eaf0..95be99f26d 100755 --- a/Sming/Core/DateTime.h +++ b/Sming/Core/DateTime.h @@ -14,8 +14,7 @@ /** @defgroup datetime Date and time functions * @{ */ -#ifndef _DateTime_h -#define _DateTime_h +#pragma once #include #include "WString.h" @@ -348,4 +347,3 @@ class DateTime }; /** @} */ -#endif /* DateTime_h */ diff --git a/Sming/Core/Debug.h b/Sming/Core/Debug.h index ad08ea69c7..1c231b0d88 100644 --- a/Sming/Core/Debug.h +++ b/Sming/Core/Debug.h @@ -8,8 +8,7 @@ * ****/ -#ifndef _SMING_CORE_DEBUG_H_ -#define _SMING_CORE_DEBUG_H_ +#pragma once #include "HardwareSerial.h" #include "Clock.h" @@ -110,4 +109,3 @@ class DebugClass : public Print extern DebugClass Debug; /** @} */ -#endif /* _SMING_CORE_DEBUG_H_ */ diff --git a/Sming/Core/Delegate.h b/Sming/Core/Delegate.h index 26c17cce39..1442f6fce2 100644 --- a/Sming/Core/Delegate.h +++ b/Sming/Core/Delegate.h @@ -13,8 +13,7 @@ * Several handlers may be triggered for each event * @{ */ -#ifndef _SMING_CORE_DELEGATE_H_ -#define _SMING_CORE_DELEGATE_H_ +#pragma once #include @@ -244,4 +243,3 @@ template class Delegate CStringArray customFieldNames; }; - -#endif /* _SMING_CORE_NETWORK_HTTP_HTTP_HEADERS_H_ */ diff --git a/Sming/Core/Network/Http/HttpParams.h b/Sming/Core/Network/Http/HttpParams.h index 507e5f2326..027f1edd52 100644 --- a/Sming/Core/Network/Http/HttpParams.h +++ b/Sming/Core/Network/Http/HttpParams.h @@ -16,8 +16,7 @@ * ****/ -#ifndef _SMING_CORE_NETWORK_HTTP_HTTP_PARAMS_H_ -#define _SMING_CORE_NETWORK_HTTP_HTTP_PARAMS_H_ +#pragma once #include "WString.h" #include "WHashMap.h" @@ -75,5 +74,3 @@ class HttpParams : public HashMap, public Printable */ void debugPrintTo(Print& p) const; }; - -#endif /* _SMING_CORE_NETWORK_HTTP_HTTP_PARAMS_H_ */ diff --git a/Sming/Core/Network/Http/HttpRequest.h b/Sming/Core/Network/Http/HttpRequest.h index 994c04965e..105dd7f339 100644 --- a/Sming/Core/Network/Http/HttpRequest.h +++ b/Sming/Core/Network/Http/HttpRequest.h @@ -10,8 +10,7 @@ * ****/ -#ifndef _SMING_CORE_NETWORK_HTTP_HTTP_REQUEST_H_ -#define _SMING_CORE_NETWORK_HTTP_HTTP_REQUEST_H_ +#pragma once #include "HttpCommon.h" #ifdef ENABLE_HTTP_REQUEST_AUTH @@ -306,5 +305,3 @@ class HttpRequest HttpParams* queryParams = nullptr; // << @todo deprecate }; - -#endif /* _SMING_CORE_NETWORK_HTTP_HTTP_REQUEST_H_ */ diff --git a/Sming/Core/Network/Http/HttpRequestAuth.h b/Sming/Core/Network/Http/HttpRequestAuth.h index fd1dcd3218..e8c7b65f6a 100644 --- a/Sming/Core/Network/Http/HttpRequestAuth.h +++ b/Sming/Core/Network/Http/HttpRequestAuth.h @@ -10,8 +10,7 @@ * ****/ -#ifndef _SMING_CORE_NETWORK_HTTP_HTTP_REQUEST_AUTH_H_ -#define _SMING_CORE_NETWORK_HTTP_HTTP_REQUEST_AUTH_H_ +#pragma once #include "HttpResponse.h" @@ -64,5 +63,3 @@ class HttpDigestAuth : public AuthAdapter String password; HttpRequest* request = nullptr; }; - -#endif /* _SMING_CORE_NETWORK_HTTP_HTTP_REQUEST_AUTH_H_ */ diff --git a/Sming/Core/Network/Http/HttpResource.h b/Sming/Core/Network/Http/HttpResource.h index f0edf90542..f0cc5a4b75 100644 --- a/Sming/Core/Network/Http/HttpResource.h +++ b/Sming/Core/Network/Http/HttpResource.h @@ -10,8 +10,7 @@ * ****/ -#ifndef _SMING_CORE_NETWORK_HTTP_HTTP_RESOURCE_H_ -#define _SMING_CORE_NETWORK_HTTP_HTTP_RESOURCE_H_ +#pragma once #include "WString.h" #include "Data/ObjectMap.h" @@ -49,5 +48,3 @@ class HttpResource HttpResourceDelegate onRequestComplete = nullptr; ///< request is complete OR upgraded HttpServerConnectionUpgradeDelegate onUpgrade = nullptr; ///< request is upgraded and raw data is passed to it }; - -#endif /* _SMING_CORE_NETWORK_HTTP_HTTP_RESOURCE_H_ */ diff --git a/Sming/Core/Network/Http/HttpResourceTree.h b/Sming/Core/Network/Http/HttpResourceTree.h index 213306c510..bae79decf9 100644 --- a/Sming/Core/Network/Http/HttpResourceTree.h +++ b/Sming/Core/Network/Http/HttpResourceTree.h @@ -10,8 +10,7 @@ * ****/ -#ifndef _SMING_CORE_NETWORK_HTTP_HTTP_RESOURCE_TREE_H_ -#define _SMING_CORE_NETWORK_HTTP_HTTP_RESOURCE_TREE_H_ +#pragma once #include "HttpResource.h" @@ -80,5 +79,3 @@ class HttpResourceTree : public ObjectMap */ void set(String path, const HttpPathDelegate& callback); }; - -#endif /* _SMING_CORE_NETWORK_HTTP_HTTP_RESOURCE_TREE_H_ */ diff --git a/Sming/Core/Network/Http/HttpResponse.h b/Sming/Core/Network/Http/HttpResponse.h index 05988be9ce..422ef18abc 100644 --- a/Sming/Core/Network/Http/HttpResponse.h +++ b/Sming/Core/Network/Http/HttpResponse.h @@ -10,8 +10,7 @@ * ****/ -#ifndef _SMING_CORE_NETWORK_HTTP_HTTP_RESPONSE_H_ -#define _SMING_CORE_NETWORK_HTTP_HTTP_RESPONSE_H_ +#pragma once #include "HttpCommon.h" #include "Data/Stream/ReadWriteStream.h" @@ -144,5 +143,3 @@ class HttpResponse ReadWriteStream* buffer = nullptr; ///< Internal stream for storing strings and receiving responses IDataSourceStream* stream = nullptr; ///< The body stream }; - -#endif /* _SMING_CORE_NETWORK_HTTP_HTTP_RESPONSE_H_ */ diff --git a/Sming/Core/Network/Http/HttpServerConnection.h b/Sming/Core/Network/Http/HttpServerConnection.h index 587ed7a44a..db103e3da1 100644 --- a/Sming/Core/Network/Http/HttpServerConnection.h +++ b/Sming/Core/Network/Http/HttpServerConnection.h @@ -10,8 +10,7 @@ * ****/ -#ifndef _SMING_CORE_NETWORK_HTTP_HTTP_SERVER_CONNECTION_H_ -#define _SMING_CORE_NETWORK_HTTP_HTTP_SERVER_CONNECTION_H_ +#pragma once #include "HttpConnection.h" #include "HttpResource.h" @@ -129,4 +128,3 @@ class HttpServerConnection : public HttpConnection }; /** @} */ -#endif /* _SMING_CORE_NETWORK_HTTP_HTTP_SERVER_CONNECTION_H_ */ diff --git a/Sming/Core/Network/Http/Websocket/WebsocketConnection.h b/Sming/Core/Network/Http/Websocket/WebsocketConnection.h index c857b9f713..dc6e13ed41 100644 --- a/Sming/Core/Network/Http/Websocket/WebsocketConnection.h +++ b/Sming/Core/Network/Http/Websocket/WebsocketConnection.h @@ -8,8 +8,7 @@ * ****/ -#ifndef _SMING_CORE_NETWORK_HTTP_WEBSOCKET_WEBSOCKET_CONNECTION_H_ -#define _SMING_CORE_NETWORK_HTTP_WEBSOCKET_WEBSOCKET_CONNECTION_H_ +#pragma once #include "Network/TcpServer.h" #include "../HttpConnection.h" @@ -317,4 +316,3 @@ class WebsocketConnection }; /** @} */ -#endif /* _SMING_CORE_NETWORK_HTTP_WEBSOCKET_WEBSOCKET_CONNECTION_H_ */ diff --git a/Sming/Core/Network/Http/Websocket/WebsocketResource.h b/Sming/Core/Network/Http/Websocket/WebsocketResource.h index a5d71cb970..f0c6e48b86 100644 --- a/Sming/Core/Network/Http/Websocket/WebsocketResource.h +++ b/Sming/Core/Network/Http/Websocket/WebsocketResource.h @@ -10,8 +10,7 @@ * ****/ -#ifndef _SMING_CORE_NETWORK_HTTP_WEBSOCKET_WEBSOCKET_RESOURCE_H_ -#define _SMING_CORE_NETWORK_HTTP_WEBSOCKET_WEBSOCKET_RESOURCE_H_ +#pragma once #include "../HttpServerConnection.h" #include "../HttpResource.h" @@ -59,5 +58,3 @@ class WebsocketResource : public HttpResource WebsocketBinaryDelegate wsBinary = nullptr; WebsocketDelegate wsDisconnect = nullptr; }; - -#endif /* _SMING_CORE_NETWORK_HTTP_WEBSOCKET_WEBSOCKET_RESOURCE_H_ */ diff --git a/Sming/Core/Network/Http/Websocket/WsCommandHandlerResource.h b/Sming/Core/Network/Http/Websocket/WsCommandHandlerResource.h index 987f1a363d..881ba21624 100644 --- a/Sming/Core/Network/Http/Websocket/WsCommandHandlerResource.h +++ b/Sming/Core/Network/Http/Websocket/WsCommandHandlerResource.h @@ -10,8 +10,7 @@ * ****/ -#ifndef _SMING_CORE_NETWORK_HTTP_WEBSOCKET_WS_COMMAND_HANDLER_RESOURCE_H_ -#define _SMING_CORE_NETWORK_HTTP_WEBSOCKET_WS_COMMAND_HANDLER_RESOURCE_H_ +#pragma once #include "../HttpResource.h" #include "WebsocketConnection.h" @@ -50,5 +49,3 @@ class WsCommandHandlerResource : protected WebsocketResource private: CommandExecutor commandExecutor; }; - -#endif /* _SMING_CORE_NETWORK_HTTP_WEBSOCKET_WS_COMMAND_HANDLER_RESOURCE_H_ */ diff --git a/Sming/Core/Network/HttpClient.h b/Sming/Core/Network/HttpClient.h index 8322698cfc..9cc490331e 100644 --- a/Sming/Core/Network/HttpClient.h +++ b/Sming/Core/Network/HttpClient.h @@ -16,8 +16,7 @@ * @{ */ -#ifndef _SMING_CORE_NETWORK_HTTP_CLIENT_H_ -#define _SMING_CORE_NETWORK_HTTP_CLIENT_H_ +#pragma once #include "TcpClient.h" #include "Http/HttpCommon.h" @@ -123,4 +122,3 @@ class HttpClient }; /** @} */ -#endif /* _SMING_CORE_NETWORK_HTTP_CLIENT_H_ */ diff --git a/Sming/Core/Network/HttpServer.h b/Sming/Core/Network/HttpServer.h index 0afaac119c..b547646cf0 100644 --- a/Sming/Core/Network/HttpServer.h +++ b/Sming/Core/Network/HttpServer.h @@ -16,8 +16,7 @@ * @{ */ -#ifndef _SMING_CORE_NETWORK_HTTP_SERVER_H_ -#define _SMING_CORE_NETWORK_HTTP_SERVER_H_ +#pragma once #include "TcpServer.h" #include "WString.h" @@ -113,4 +112,3 @@ class HttpServer : public TcpServer }; /** @} */ -#endif /* _SMING_CORE_NETWORK_HTTP_SERVER_H_ */ diff --git a/Sming/Core/Network/Mqtt/MqttPayloadParser.h b/Sming/Core/Network/Mqtt/MqttPayloadParser.h index d81bc300e7..693449120d 100644 --- a/Sming/Core/Network/Mqtt/MqttPayloadParser.h +++ b/Sming/Core/Network/Mqtt/MqttPayloadParser.h @@ -10,8 +10,7 @@ * ****/ -#ifndef _SMING_CORE_NETWORK_MQTT_PAYLOAD_PARSER_H_ -#define _SMING_CORE_NETWORK_MQTT_PAYLOAD_PARSER_H_ +#pragma once #include "Delegate.h" #include "mqtt-codec/src/message.h" @@ -41,4 +40,3 @@ typedef Delegate }; /** @} */ -#endif /* _SMING_CORE_SSL_VALIDATOR_H_ */ diff --git a/Sming/Core/Network/TcpClient.h b/Sming/Core/Network/TcpClient.h index 14a8b323f9..904db86c77 100644 --- a/Sming/Core/Network/TcpClient.h +++ b/Sming/Core/Network/TcpClient.h @@ -14,8 +14,7 @@ * @{ */ -#ifndef _SMING_CORE_NETWORK_TCP_CLIENT_H_ -#define _SMING_CORE_NETWORK_TCP_CLIENT_H_ +#pragma once #include "TcpConnection.h" #include "Delegate.h" @@ -196,4 +195,3 @@ class TcpClient : public TcpConnection }; /** @} */ -#endif /* _SMING_CORE_NETWORK_TCP_CLIENT_H_ */ diff --git a/Sming/Core/Network/TcpConnection.h b/Sming/Core/Network/TcpConnection.h index 34bf42f2d9..009cf3febb 100644 --- a/Sming/Core/Network/TcpConnection.h +++ b/Sming/Core/Network/TcpConnection.h @@ -13,8 +13,7 @@ * @{ */ -#ifndef _SMING_CORE_NETWORK_TCP_CONNECTION_H_ -#define _SMING_CORE_NETWORK_TCP_CONNECTION_H_ +#pragma once #ifdef ENABLE_SSL #include "axtls-8266/compat/lwipr_compat.h" @@ -299,4 +298,3 @@ class TcpConnection }; /** @} */ -#endif /* _SMING_CORE_NETWORK_TCP_CONNECTION_H_ */ diff --git a/Sming/Core/Network/TcpServer.h b/Sming/Core/Network/TcpServer.h index 6111057912..9ea508b604 100644 --- a/Sming/Core/Network/TcpServer.h +++ b/Sming/Core/Network/TcpServer.h @@ -15,8 +15,7 @@ * @{ */ -#ifndef _SMING_CORE_NETWORK_TCP_SERVER_H_ -#define _SMING_CORE_NETWORK_TCP_SERVER_H_ +#pragma once #include "TcpConnection.h" #include "TcpClient.h" @@ -120,4 +119,3 @@ class TcpServer : public TcpConnection }; /** @} */ -#endif /* _SMING_CORE_NETWORK_TCP_SERVER_H_ */ diff --git a/Sming/Core/Network/TelnetServer.h b/Sming/Core/Network/TelnetServer.h index fc1d7d1ab0..e81fb29552 100644 --- a/Sming/Core/Network/TelnetServer.h +++ b/Sming/Core/Network/TelnetServer.h @@ -17,8 +17,7 @@ * @{ */ -#ifndef _SMING_CORE_NETWORK_TELNET_SERVER_H_ -#define _SMING_CORE_NETWORK_TELNET_SERVER_H_ +#pragma once #include #include "Delegate.h" @@ -57,4 +56,3 @@ class TelnetServer : public TcpServer }; /** @} */ -#endif /* _SMING_CORE_NETWORK_TELNET_SERVER_H_ */ diff --git a/Sming/Core/Network/UdpConnection.h b/Sming/Core/Network/UdpConnection.h index 205450f8da..eeea38de58 100644 --- a/Sming/Core/Network/UdpConnection.h +++ b/Sming/Core/Network/UdpConnection.h @@ -14,8 +14,7 @@ * @{ */ -#ifndef _SMING_CORE_NETWORK_UDP_CONNECTION_H_ -#define _SMING_CORE_NETWORK_UDP_CONNECTION_H_ +#pragma once #include "WiringFrameworkDependencies.h" #include "Delegate.h" @@ -86,4 +85,3 @@ class UdpConnection }; /** @} */ -#endif /* _SMING_CORE_NETWORK_UDP_CONNECTION_H_ */ diff --git a/Sming/Core/Network/Url.h b/Sming/Core/Network/Url.h index dce07ee8ce..a229df97aa 100644 --- a/Sming/Core/Network/Url.h +++ b/Sming/Core/Network/Url.h @@ -22,8 +22,7 @@ * @{ */ -#ifndef _SMING_CORE_NETWORK_URL_H_ -#define _SMING_CORE_NETWORK_URL_H_ +#pragma once #include "WString.h" #include "Http/HttpParams.h" @@ -180,4 +179,3 @@ class Url typedef Url URL SMING_DEPRECATED; ///< @deprecated Use `Url` instead /** @} */ -#endif /* _SMING_CORE_NETWORK_URL_H_ */ diff --git a/Sming/Core/Network/WebConstants.h b/Sming/Core/Network/WebConstants.h index 74126ed640..f1e42f7ae1 100644 --- a/Sming/Core/Network/WebConstants.h +++ b/Sming/Core/Network/WebConstants.h @@ -15,8 +15,7 @@ * @{ */ -#ifndef _SMING_CORE_NETWORK_WEB_CONSTANTS_H_ -#define _SMING_CORE_NETWORK_WEB_CONSTANTS_H_ +#pragma once #include "WString.h" @@ -98,4 +97,3 @@ static inline String fromFullFileName(const String& fileName) }; // namespace ContentType /** @} */ -#endif /* _SMING_CORE_NETWORK_WEB_CONSTANTS_H_ */ diff --git a/Sming/Core/Network/WebHelpers/aw-sha1.h b/Sming/Core/Network/WebHelpers/aw-sha1.h index b8a6a3b5b1..6132c58422 100644 --- a/Sming/Core/Network/WebHelpers/aw-sha1.h +++ b/Sming/Core/Network/WebHelpers/aw-sha1.h @@ -21,8 +21,7 @@ THE SOFTWARE. */ -#ifndef AW_SHA1_H -#define AW_SHA1_H +#pragma once #include @@ -43,5 +42,3 @@ void sha1(unsigned char h[SHA1_SIZE], const void* _sha1_restrict p, size_t n); #ifdef __cplusplus } /* extern "C" */ #endif - -#endif /* AW_SHA1_H */ diff --git a/Sming/Core/Network/WebHelpers/base64.h b/Sming/Core/Network/WebHelpers/base64.h index 62cc863932..a0a46568d0 100644 --- a/Sming/Core/Network/WebHelpers/base64.h +++ b/Sming/Core/Network/WebHelpers/base64.h @@ -11,8 +11,7 @@ * ****/ -#ifndef BASE64_H -#define BASE64_H +#pragma once #include "WString.h" @@ -67,5 +66,3 @@ static inline String base64_decode(const String& in) { return base64_decode(in.c_str(), in.length()); } - -#endif /* BASE64_H */ diff --git a/Sming/Core/Network/WebHelpers/escape.h b/Sming/Core/Network/WebHelpers/escape.h index e0c8a2bf35..d7b874392b 100644 --- a/Sming/Core/Network/WebHelpers/escape.h +++ b/Sming/Core/Network/WebHelpers/escape.h @@ -1,5 +1,4 @@ -#ifndef ESCAPE_H -#define ESCAPE_H +#pragma once #include #include "WString.h" @@ -76,5 +75,3 @@ static inline String uri_unescape(const String& str) uri_unescape_inplace(ret); return ret; } - -#endif diff --git a/Sming/Core/Network/WebsocketClient.h b/Sming/Core/Network/WebsocketClient.h index 71352868db..0bd0474a4b 100644 --- a/Sming/Core/Network/WebsocketClient.h +++ b/Sming/Core/Network/WebsocketClient.h @@ -15,8 +15,7 @@ //TODO: Add stream support for sending big chunks of data via websockets. -#ifndef _SMING_CORE_NETWORK_WEBSOCKET_CLIENT_H_ -#define _SMING_CORE_NETWORK_WEBSOCKET_CLIENT_H_ +#pragma once #include "Http/HttpClientConnection.h" #include "Http/Websocket/WebsocketConnection.h" @@ -100,4 +99,3 @@ class WebsocketClient : protected WebsocketConnection }; /** @} */ -#endif /* _SMING_CORE_NETWORK_WEBSOCKET_CLIENT_H_ */ diff --git a/Sming/Core/SPI.h b/Sming/Core/SPI.h index 21e2a6b887..e3717f41ec 100644 --- a/Sming/Core/SPI.h +++ b/Sming/Core/SPI.h @@ -15,8 +15,7 @@ * @brief Provides hardware SPI support */ -#ifndef _SMING_CORE_SPI_H_ -#define _SMING_CORE_SPI_H_ +#pragma once #include "SPIBase.h" #include "SPISettings.h" @@ -184,5 +183,3 @@ class SPIClass : public SPIBase /** @brief Global instance of SPI class */ extern SPIClass SPI; - -#endif /* _SMING_CORE_SPI_H_ */ diff --git a/Sming/Core/SPIBase.h b/Sming/Core/SPIBase.h index 5465121c43..724937f7d1 100644 --- a/Sming/Core/SPIBase.h +++ b/Sming/Core/SPIBase.h @@ -15,8 +15,7 @@ * @brief Provides SPI support */ -#ifndef _SMING_CORE_SPI_BASE_H_ -#define _SMING_CORE_SPI_BASE_H_ +#pragma once #include "SPISettings.h" @@ -74,5 +73,3 @@ class SPIBase */ SPISettings SPIDefaultSettings; }; - -#endif /* _SMING_CORE_SPI_BASE_H_ */ diff --git a/Sming/Core/SPISettings.h b/Sming/Core/SPISettings.h index a09e56b7a1..067f0be862 100644 --- a/Sming/Core/SPISettings.h +++ b/Sming/Core/SPISettings.h @@ -15,8 +15,7 @@ * @brief Provides SPI support */ -#ifndef _SMING_CORE_SPI_SETTINGS_H_ -#define _SMING_CORE_SPI_SETTINGS_H_ +#pragma once #include "Digital.h" @@ -106,5 +105,3 @@ class SPISettings uint8_t byteOrder = MSBFIRST; uint8_t dataMode = SPI_MODE0; }; - -#endif /* _SMING_CORE_SPI_SETTINGS_H_ */ diff --git a/Sming/Core/SPISoft.h b/Sming/Core/SPISoft.h index 2cb25f729c..d82867e846 100644 --- a/Sming/Core/SPISoft.h +++ b/Sming/Core/SPISoft.h @@ -5,9 +5,7 @@ License: MIT Date: 15.07.2015 Descr: Implement software SPI for HW configs other than hardware SPI pins(GPIO 12,13,14) */ - -#ifndef _SMING_CORE_SPI_SOFT_H_ -#define _SMING_CORE_SPI_SOFT_H_ +#pragma once #include "SPIBase.h" #include "SPISettings.h" @@ -83,4 +81,3 @@ class SPISoft : public SPIBase uint8_t m_delay; }; -#endif /* _SMING_CORE_SPI_SOFT_H_ */ diff --git a/Sming/Core/SimpleTimer.h b/Sming/Core/SimpleTimer.h index 813cbb566f..09cd789310 100644 --- a/Sming/Core/SimpleTimer.h +++ b/Sming/Core/SimpleTimer.h @@ -21,8 +21,7 @@ * @brief Provides basic OS timer functions */ -#ifndef _SMING_CORE_SIMPLE_TIMER_H_ -#define _SMING_CORE_SIMPLE_TIMER_H_ +#pragma once extern "C" { #include "esp_systemapi.h" @@ -100,5 +99,3 @@ class SimpleTimer private: os_timer_t osTimer; }; - -#endif /* _SMING_CORE_SIMPLE_TIMER_H_ */ diff --git a/Sming/Core/SmingCore.h b/Sming/Core/SmingCore.h index c49b120b65..ec671e6792 100644 --- a/Sming/Core/SmingCore.h +++ b/Sming/Core/SmingCore.h @@ -8,8 +8,7 @@ * ****/ -#ifndef _SMING_CORE_H_ -#define _SMING_CORE_H_ +#pragma once #define SMING_VERSION "3.8.0" // Major Minor Sub @@ -62,5 +61,3 @@ #include "fatfs/ff.h" #include "Services/Yeelight/YeelightBulb.h" - -#endif /* _SMING_CORE_H_ */ diff --git a/Sming/Core/SmingLocale.h b/Sming/Core/SmingLocale.h index 2e3d22c61b..4f6c483044 100755 --- a/Sming/Core/SmingLocale.h +++ b/Sming/Core/SmingLocale.h @@ -15,8 +15,7 @@ * Default settings are at end of file */ -#ifndef _SMING_CORE_SMING_LOCALE_H_ -#define _SMING_CORE_SMING_LOCALE_H_ +#pragma once // Define unique values for each locale (try to use ISD codes if appropriate) #define LOCALE_EN_US 1 @@ -79,5 +78,3 @@ // String with time and date format (see DateTime::format for options - this implements %c format) #define LOCALE_DATE_TIME "%a %d %b %Y %X" #endif // LOCALE_DATE_TIME - -#endif /* _SMING_CORE_SMING_LOCALE_H_ */ diff --git a/Sming/Core/SystemClock.h b/Sming/Core/SystemClock.h index f13827bbd5..6aeda6b856 100644 --- a/Sming/Core/SystemClock.h +++ b/Sming/Core/SystemClock.h @@ -12,9 +12,7 @@ * @ingroup datetime * @brief Provides system clock functions */ - -#ifndef _SMING_CORE_SYSTEM_CLOCK_H_ -#define _SMING_CORE_SYSTEM_CLOCK_H_ +#pragma once #include "DateTime.h" #include "WString.h" @@ -94,4 +92,3 @@ class SystemClockClass extern SystemClockClass SystemClock; /** @} */ -#endif /* _SMING_CORE_SYSTEM_CLOCK_H_ */ diff --git a/Sming/Core/Timer.h b/Sming/Core/Timer.h index c9d6023321..1971b1ee40 100644 --- a/Sming/Core/Timer.h +++ b/Sming/Core/Timer.h @@ -11,8 +11,7 @@ /** @defgroup timer Timer functions * @brief Provides timer functions */ -#ifndef _SMING_CORE_TIMER_H_ -#define _SMING_CORE_TIMER_H_ +#pragma once #include #include "Interrupts.h" @@ -192,4 +191,3 @@ class Timer uint16_t longIntervalCounterLimit = 0; }; -#endif /* _SMING_CORE_TIMER_H_ */ diff --git a/Sming/Core/Wire.h b/Sming/Core/Wire.h index 387937ad49..0e34ce8e55 100644 --- a/Sming/Core/Wire.h +++ b/Sming/Core/Wire.h @@ -21,8 +21,7 @@ Modified April 2015 by Hrsto Gochkov (ficeto@ficeto.com) - alternative esp8266 support */ -#ifndef _SMING_CORE_WIRE_H_ -#define _SMING_CORE_WIRE_H_ +#pragma once #include #include "Stream.h" @@ -105,5 +104,3 @@ class TwoWire : public Stream #if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_TWOWIRE) extern TwoWire Wire; #endif - -#endif /* _SMING_CORE_WIRE_H_ */ diff --git a/Sming/Core/twi.h b/Sming/Core/twi.h index 740a6f3437..a4cc16f263 100644 --- a/Sming/Core/twi.h +++ b/Sming/Core/twi.h @@ -19,8 +19,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef _SMING_CORE_TWI_H_ -#define _SMING_CORE_TWI_H_ +#pragma once #include "WiringFrameworkDependencies.h" @@ -46,4 +45,3 @@ uint8_t twi_status(); } #endif -#endif /* _SMING_CORE_TWI_H_ */ diff --git a/Sming/Platform/AccessPoint.h b/Sming/Platform/AccessPoint.h index 59195d9f3c..112db356ee 100644 --- a/Sming/Platform/AccessPoint.h +++ b/Sming/Platform/AccessPoint.h @@ -17,8 +17,7 @@ * @todo How is wifi access point dhcp controlled? */ -#ifndef _SMING_CORE_PLATFORM_ACCESS_POINT_H_ -#define _SMING_CORE_PLATFORM_ACCESS_POINT_H_ +#pragma once #include "System.h" #include "WString.h" @@ -118,5 +117,3 @@ class AccessPointClass : protected ISystemReadyHandler * @ingroup wifi_ap */ extern AccessPointClass WifiAccessPoint; - -#endif /* _SMING_CORE_PLATFORM_ACCESS_POINT_H_ */ diff --git a/Sming/Platform/OsMessageInterceptor.h b/Sming/Platform/OsMessageInterceptor.h index aa96354a97..3b16f0013b 100644 --- a/Sming/Platform/OsMessageInterceptor.h +++ b/Sming/Platform/OsMessageInterceptor.h @@ -42,8 +42,7 @@ * ****/ -#ifndef _SMING_CORE_PLATFORM_OS_MESSAGE_INTERCEPTOR_H_ -#define _SMING_CORE_PLATFORM_OS_MESSAGE_INTERCEPTOR_H_ +#pragma once #include "Data/Buffer/LineBuffer.h" @@ -98,5 +97,3 @@ class OsMessageInterceptor OsMessageCallback callback = nullptr; ///< User-provided callback static OsMessageInterceptor* self; }; - -#endif /* _SMING_CORE_PLATFORM_OS_MESSAGE_INTERCEPTOR_H_ */ diff --git a/Sming/Platform/RTC.h b/Sming/Platform/RTC.h index 596cad360a..a1d5a16da8 100644 --- a/Sming/Platform/RTC.h +++ b/Sming/Platform/RTC.h @@ -13,8 +13,7 @@ * @note Provides ability to set and read the ESP8266 RTC. * @ingroup datetime */ -#ifndef _SMING_CORE_PLATFORM_RTC_H_ -#define _SMING_CORE_PLATFORM_RTC_H_ +#pragma once #include "WiringFrameworkDependencies.h" @@ -83,4 +82,3 @@ class RtcClass * @ingroup rtc */ extern RtcClass RTC; -#endif /* _SMING_CORE_PLATFORM_RTC_H_ */ diff --git a/Sming/Platform/Station.h b/Sming/Platform/Station.h index 2f3b57850d..21f42ad857 100644 --- a/Sming/Platform/Station.h +++ b/Sming/Platform/Station.h @@ -16,8 +16,7 @@ * @see \ref wifi_ap */ -#ifndef _SMING_CORE_PLATFORM_STATION_H_ -#define _SMING_CORE_PLATFORM_STATION_H_ +#pragma once #include "System.h" #include "Delegate.h" @@ -302,4 +301,3 @@ class BssInfo extern StationClass WifiStation; /** @} */ -#endif /* _SMING_CORE_PLATFORM_STATION_H_ */ diff --git a/Sming/Platform/System.h b/Sming/Platform/System.h index e93b383d77..4966ed300a 100644 --- a/Sming/Platform/System.h +++ b/Sming/Platform/System.h @@ -21,8 +21,7 @@ * @brief Access to the ESP8266 system * @note Provides system control and monitoring of the ESP8266. */ -#ifndef _SMING_CORE_PLATFORM_SYSTEM_H_ -#define _SMING_CORE_PLATFORM_SYSTEM_H_ +#pragma once #include "Delegate.h" @@ -197,4 +196,3 @@ class SystemClass extern SystemClass System; /** @} */ -#endif /* _SMING_CORE_PLATFORM_SYSTEM_H_ */ diff --git a/Sming/Platform/WDT.h b/Sming/Platform/WDT.h index c5c1f36d5d..80cc7a386c 100644 --- a/Sming/Platform/WDT.h +++ b/Sming/Platform/WDT.h @@ -18,8 +18,7 @@ * To use WDT, enable the WDT then poke it regularly with WDT.alive(); */ -#ifndef _SMING_CORE_PLATFORM_WDT_H_ -#define _SMING_CORE_PLATFORM_WDT_H_ +#pragma once #include #include "System.h" @@ -59,5 +58,3 @@ class WDTClass : protected ISystemReadyHandler * @endcode */ extern WDTClass WDT; - -#endif /* _SMING_CORE_PLATFORM_WDT_H_ */ diff --git a/Sming/Platform/WifiEvents.h b/Sming/Platform/WifiEvents.h index 9c31f5e263..51dacc6b9e 100644 --- a/Sming/Platform/WifiEvents.h +++ b/Sming/Platform/WifiEvents.h @@ -11,8 +11,7 @@ * ****/ -#ifndef _SMING_CORE_PLATFORM_WIFI_EVENTS_H_ -#define _SMING_CORE_PLATFORM_WIFI_EVENTS_H_ +#pragma once #include "Delegate.h" #include "WString.h" @@ -54,4 +53,3 @@ class WifiEventsClass }; extern WifiEventsClass WifiEvents; -#endif /* _SMING_CORE_PLATFORM_WIFI_EVENTS_H_ */ diff --git a/Sming/Platform/WifiSniffer.h b/Sming/Platform/WifiSniffer.h index acb5c09365..8a8a91ed1f 100644 --- a/Sming/Platform/WifiSniffer.h +++ b/Sming/Platform/WifiSniffer.h @@ -14,8 +14,7 @@ * ****/ -#ifndef _SMING_CORE_WIFI_SNIFFER_H_ -#define _SMING_CORE_WIFI_SNIFFER_H_ +#pragma once #include "System.h" #include "WVector.h" @@ -142,5 +141,3 @@ class WifiSniffer : public ISystemReadyHandler static WifiBeaconCallback beaconCallback; static WifiClientCallback clientCallback; }; - -#endif /* _SMING_CORE_WIFI_SNIFFER_H_ */ diff --git a/Sming/Services/CommandProcessing/CommandDelegate.h b/Sming/Services/CommandProcessing/CommandDelegate.h index c8e4ca9f39..f9a00bf24c 100644 --- a/Sming/Services/CommandProcessing/CommandDelegate.h +++ b/Sming/Services/CommandProcessing/CommandDelegate.h @@ -8,8 +8,7 @@ * @{ */ -#ifndef SERVICES_COMMANDPROCESSING_COMMANDDELEGATE_H_ -#define SERVICES_COMMANDPROCESSING_COMMANDDELEGATE_H_ +#pragma once #include "WString.h" #include "Delegate.h" @@ -51,4 +50,3 @@ private : }; /** @} */ -#endif /* SERVICES_COMMANDPROCESSING_COMMANDDELEGATE_H_ */ diff --git a/Sming/Services/CommandProcessing/CommandExecutor.h b/Sming/Services/CommandProcessing/CommandExecutor.h index 0fda2b5a70..e8d565f4d9 100644 --- a/Sming/Services/CommandProcessing/CommandExecutor.h +++ b/Sming/Services/CommandProcessing/CommandExecutor.h @@ -5,8 +5,7 @@ * Author: Herman */ -#ifndef SERVICES_COMMANDPROCESSING_COMMANDEXECUTOR_H_ -#define SERVICES_COMMANDPROCESSING_COMMANDEXECUTOR_H_ +#pragma once #include "WiringFrameworkIncludes.h" #include "Network/TcpClient.h" @@ -36,5 +35,3 @@ private : uint16_t commandIndex = 0; CommandOutput* commandOutput = nullptr; }; - -#endif /* SERVICES_COMMANDPROCESSING_COMMANDEXECUTOR_H_ */ diff --git a/Sming/Services/CommandProcessing/CommandHandler.h b/Sming/Services/CommandProcessing/CommandHandler.h index 77e2f4dbda..08f9761983 100644 --- a/Sming/Services/CommandProcessing/CommandHandler.h +++ b/Sming/Services/CommandProcessing/CommandHandler.h @@ -22,8 +22,7 @@ * @{ */ -#ifndef SERVICES_COMMANDPROCESSING_COMMANDHANDLER_H_ -#define SERVICES_COMMANDPROCESSING_COMMANDHANDLER_H_ +#pragma once #include "WiringFrameworkIncludes.h" #include "CommandDelegate.h" @@ -147,4 +146,3 @@ private : extern CommandHandler commandHandler; /** @} */ -#endif /* SERVICES_COMMANDPROCESSING_COMMANDHANDLER_H_ */ diff --git a/Sming/Services/CommandProcessing/CommandOutput.h b/Sming/Services/CommandProcessing/CommandOutput.h index eb7e8a45a8..a618bdeeeb 100644 --- a/Sming/Services/CommandProcessing/CommandOutput.h +++ b/Sming/Services/CommandProcessing/CommandOutput.h @@ -5,8 +5,7 @@ * Author: Herman */ -#ifndef SERVICES_COMMANDPROCESSING_COMMANDOUTPUT_H_ -#define SERVICES_COMMANDPROCESSING_COMMANDOUTPUT_H_ +#pragma once #include "Network/TcpClient.h" #include "Stream.h" @@ -29,5 +28,3 @@ class CommandOutput: public Print WebsocketConnection* outputSocket = nullptr; String tempSocket = ""; }; - -#endif /* SERVICES_COMMANDPROCESSING_COMMANDOUTPUT_H_ */ diff --git a/Sming/Services/CommandProcessing/CommandProcessingDependencies.h b/Sming/Services/CommandProcessing/CommandProcessingDependencies.h index 54cf578b1a..00a48271bb 100644 --- a/Sming/Services/CommandProcessing/CommandProcessingDependencies.h +++ b/Sming/Services/CommandProcessing/CommandProcessingDependencies.h @@ -5,11 +5,4 @@ * Author: Herman */ -#ifndef SERVICES_COMMANDPROCESSING_COMMANDPROCESSINGDEPENDENCIES_H_ -#define SERVICES_COMMANDPROCESSING_COMMANDPROCESSINGDEPENDENCIES_H_ - - - - - -#endif /* SERVICES_COMMANDPROCESSING_COMMANDPROCESSINGDEPENDENCIES_H_ */ +#pragma once diff --git a/Sming/Services/CommandProcessing/CommandProcessingIncludes.h b/Sming/Services/CommandProcessing/CommandProcessingIncludes.h index 38a66f7fd8..6061ee7ec9 100644 --- a/Sming/Services/CommandProcessing/CommandProcessingIncludes.h +++ b/Sming/Services/CommandProcessing/CommandProcessingIncludes.h @@ -5,15 +5,10 @@ * Author: Herman */ -#ifndef SERVICES_COMMANDPROCESSING_COMMANDPROCESSINGINCLUDES_H_ -#define SERVICES_COMMANDPROCESSING_COMMANDPROCESSINGINCLUDES_H_ +#pragma once #include "CommandOutput.h" #include "CommandProcessingDependencies.h" #include "CommandDelegate.h" #include "CommandExecutor.h" #include "CommandHandler.h" - - - -#endif /* SERVICES_COMMANDPROCESSING_COMMANDPROCESSINGINCLUDES_H_ */ diff --git a/Sming/Services/HexDump/HexDump.h b/Sming/Services/HexDump/HexDump.h index 290f3ef892..3faf4bef3e 100644 --- a/Sming/Services/HexDump/HexDump.h +++ b/Sming/Services/HexDump/HexDump.h @@ -5,8 +5,7 @@ * Author: harry */ -#ifndef SAMPLES_ARDUCAM_APP_HEXDUMP_H_ -#define SAMPLES_ARDUCAM_APP_HEXDUMP_H_ +#pragma once #include "Arduino.h" @@ -24,5 +23,3 @@ class HexDump { // char *buf = new char(16); }; - -#endif /* SAMPLES_ARDUCAM_APP_HEXDUMP_H_ */ diff --git a/Sming/Services/Profiling/ElapseTimer.h b/Sming/Services/Profiling/ElapseTimer.h index d8d5af6eea..548ebe7c4a 100644 --- a/Sming/Services/Profiling/ElapseTimer.h +++ b/Sming/Services/Profiling/ElapseTimer.h @@ -7,9 +7,7 @@ * Simple class for elapse timing * ****/ - -#ifndef __ELAPSETIMER_H -#define __ELAPSETIMER_H +#pragma once #include "HardwareTimer.h" @@ -37,5 +35,3 @@ class ElapseTimer private: uint32_t startTicks; }; - -#endif // __ELAPSETIMER_H diff --git a/Sming/Services/Yeelight/YeelightBulb.h b/Sming/Services/Yeelight/YeelightBulb.h index 111405eb18..c0694e062f 100644 --- a/Sming/Services/Yeelight/YeelightBulb.h +++ b/Sming/Services/Yeelight/YeelightBulb.h @@ -4,6 +4,7 @@ * http://github.com/anakod/Sming * All files of the Sming Core are provided under the LGPL v3 license. ****/ +#pragma once #include "WiringFrameworkDependencies.h" #include "WHashMap.h" @@ -12,9 +13,6 @@ #include "IPAddress.h" class TcpClient; -#ifndef SERVICES_YEELIGHTBULB_H_ -#define SERVICES_YEELIGHTBULB_H_ - enum YeelightBulbState { eYBS_Unknown = -1, @@ -70,5 +68,3 @@ class YeelightBulb long propsId = 0; YeelightBulbState state = eYBS_Unknown; }; - -#endif /* SERVICES_YEELIGHTBULB_H_ */ diff --git a/Sming/System/include/debug_progmem.h b/Sming/System/include/debug_progmem.h index 52cd72a22f..154a1270db 100644 --- a/Sming/System/include/debug_progmem.h +++ b/Sming/System/include/debug_progmem.h @@ -14,8 +14,7 @@ * ****/ -#ifndef _SYSTEM_INCLUDE_DEBUG_PROGMEM_H -#define _SYSTEM_INCLUDE_DEBUG_PROGMEM_H +#pragma once #include #include "FakePgmSpace.h" @@ -131,5 +130,3 @@ extern "C" { #ifdef __cplusplus } #endif - -#endif /* _SYSTEM_INCLUDE_DEBUG_PROGMEM_H */ diff --git a/Sming/System/include/gdb/gdb_hooks.h b/Sming/System/include/gdb/gdb_hooks.h index 6eda397051..20e1f8e289 100644 --- a/Sming/System/include/gdb/gdb_hooks.h +++ b/Sming/System/include/gdb/gdb_hooks.h @@ -17,8 +17,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef _GDB_HOOKS_H_ -#define _GDB_HOOKS_H_ +#pragma once #include @@ -101,5 +100,3 @@ void debug_print_stack(uint32_t start, uint32_t end); #endif /** @} */ - -#endif /* _GDB_HOOKS_H_ */ diff --git a/Sming/System/include/gdb/gdb_syscall.h b/Sming/System/include/gdb/gdb_syscall.h index df8c0bd08e..6ba7cda779 100644 --- a/Sming/System/include/gdb/gdb_syscall.h +++ b/Sming/System/include/gdb/gdb_syscall.h @@ -24,8 +24,7 @@ * ****/ -#ifndef _SYSTEM_INCLUDE_GDB_SYSCALL_H_ -#define _SYSTEM_INCLUDE_GDB_SYSCALL_H_ +#pragma once #include #include @@ -421,4 +420,3 @@ static inline int gdb_console_write(const void* buffer, size_t count, gdb_syscal } /** @} */ -#endif /* _SYSTEM_INCLUDE_GDB_SYSCALL_H_ */ diff --git a/Sming/System/include/m_printf.h b/Sming/System/include/m_printf.h index 35249c5d15..0676156a6b 100644 --- a/Sming/System/include/m_printf.h +++ b/Sming/System/include/m_printf.h @@ -5,8 +5,7 @@ License: MIT Date: 21.12.2015 Descr: embedded very simple version of printf with float support */ -#ifndef _M_PRINTF_ -#define _M_PRINTF_ +#pragma once #include #include @@ -76,5 +75,3 @@ void m_printHex(const char* tag, const void* data, size_t len, int addr = -1, si } #endif - -#endif /*_M_PRINTF_*/ diff --git a/Sming/System/include/stringconversion.h b/Sming/System/include/stringconversion.h index d7decc4fbc..3b27cea1dd 100644 --- a/Sming/System/include/stringconversion.h +++ b/Sming/System/include/stringconversion.h @@ -11,8 +11,7 @@ * ****/ -#ifndef _SYSTEM_INCLUDE_STRINGCONVERSION_H_ -#define _SYSTEM_INCLUDE_STRINGCONVERSION_H_ +#pragma once #ifdef __cplusplus extern "C" { @@ -39,5 +38,3 @@ double os_atof(const char* s); #ifdef __cplusplus } #endif - -#endif /* _SYSTEM_INCLUDE_STRINGCONVERSION_H_ */ diff --git a/Sming/System/include/stringutil.h b/Sming/System/include/stringutil.h index 94d2855a6d..a30b7831b1 100644 --- a/Sming/System/include/stringutil.h +++ b/Sming/System/include/stringutil.h @@ -13,8 +13,7 @@ * ****/ -#ifndef _SYSTEM_INCLUDE_STRINGUTIL_H_ -#define _SYSTEM_INCLUDE_STRINGUTIL_H_ +#pragma once #ifdef __cplusplus extern "C" { @@ -69,5 +68,3 @@ static inline signed char unhex(char c) #ifdef __cplusplus } #endif - -#endif /* _SYSTEM_INCLUDE_STRINGUTIL_H_ */ diff --git a/Sming/Wiring/Arduino.h b/Sming/Wiring/Arduino.h index d7018c378f..17c9cc8ed8 100644 --- a/Sming/Wiring/Arduino.h +++ b/Sming/Wiring/Arduino.h @@ -1,12 +1,8 @@ // Just for compatibility with Arduino libraries. -#ifndef INCLUDE_ARDUINO_H_ -#define INCLUDE_ARDUINO_H_ +#pragma once #include #include "WiringFrameworkDependencies.h" #include "SmingCore.h" #include "ArduinoCompat.h" - - -#endif /* INCLUDE_ARDUINO_H_ */ diff --git a/Sming/Wiring/Binary.h b/Sming/Wiring/Binary.h index 5c457392f8..c4a431341e 100644 --- a/Sming/Wiring/Binary.h +++ b/Sming/Wiring/Binary.h @@ -21,8 +21,7 @@ || */ -#ifndef BINARY_H -#define BINARY_H +#pragma once #define B0 0 #define B00 0 @@ -534,6 +533,3 @@ #define B11111101 253 #define B11111110 254 #define B11111111 255 - -#endif - diff --git a/Sming/Wiring/BitManipulations.h b/Sming/Wiring/BitManipulations.h index d3c6c1653f..f8f4b0c7de 100644 --- a/Sming/Wiring/BitManipulations.h +++ b/Sming/Wiring/BitManipulations.h @@ -1,12 +1,11 @@ /* * BitManipulations.h * - * Created on: 03 ����. 2015 �. + * Created on: 03 ����. 2015 �. * Author: Anakonda */ -#ifndef WIRING_BITMANIPULATIONS_H_ -#define WIRING_BITMANIPULATIONS_H_ +#pragma once #define _BV(bit) (1 << (bit)) @@ -40,7 +39,3 @@ #define bit_is_clear(sfr, bit) (!(_SFR_BYTE(sfr) & _BV(bit))) #define loop_until_bit_is_set(sfr, bit) do { } while (bit_is_clear(sfr, bit)) #define loop_until_bit_is_clear(sfr, bit) do { } while (bit_is_set(sfr, bit)) - - - -#endif /* WIRING_BITMANIPULATIONS_H_ */ diff --git a/Sming/Wiring/Countable.h b/Sming/Wiring/Countable.h index c819e6d163..1cbc21c99e 100644 --- a/Sming/Wiring/Countable.h +++ b/Sming/Wiring/Countable.h @@ -14,8 +14,7 @@ || */ -#ifndef COUNTABLE_H -#define COUNTABLE_H +#pragma once #include "WiringFrameworkDependencies.h" @@ -32,6 +31,3 @@ class Countable return operator[](i); } }; - -#endif -// COUNTABLE_H diff --git a/Sming/Wiring/Display.h b/Sming/Wiring/Display.h index 0ee7578c84..bd5e3e7f76 100644 --- a/Sming/Wiring/Display.h +++ b/Sming/Wiring/Display.h @@ -14,8 +14,7 @@ || */ -#ifndef DISPLAY_H -#define DISPLAY_H +#pragma once #include "Print.h" #include "WiringFrameworkIncludes.h" @@ -33,6 +32,3 @@ class Display : public Print virtual void scrollRight(void) = 0; */ }; - -#endif -// DISPLAY_H diff --git a/Sming/Wiring/FILO.h b/Sming/Wiring/FILO.h index 022485906f..2c736947df 100644 --- a/Sming/Wiring/FILO.h +++ b/Sming/Wiring/FILO.h @@ -16,8 +16,7 @@ || */ -#ifndef FILO_H -#define FILO_H +#pragma once #include "WiringFrameworkIncludes.h" @@ -89,6 +88,3 @@ void FILO::flush() { nextIn = nextOut = numberOfElements = 0; } - -#endif -// FILO_H diff --git a/Sming/Wiring/FakePgmSpace.h b/Sming/Wiring/FakePgmSpace.h index ceb9862f33..74f7e27ce0 100644 --- a/Sming/Wiring/FakePgmSpace.h +++ b/Sming/Wiring/FakePgmSpace.h @@ -8,8 +8,7 @@ * ****/ -#ifndef __FAKE_PGMSPACE_H_ -#define __FAKE_PGMSPACE_H_ +#pragma once #include "m_printf.h" #include "c_types.h" @@ -237,5 +236,3 @@ extern "C" #define PSTR_ARRAY(_name, _str) \ static DEFINE_PSTR(_##_name, _str); \ LOAD_PSTR(_name, _##_name) - -#endif /* __FAKE_PGMSPACE_H_ */ diff --git a/Sming/Wiring/FlashString.h b/Sming/Wiring/FlashString.h index a699f9d06e..c75ddb4004 100644 --- a/Sming/Wiring/FlashString.h +++ b/Sming/Wiring/FlashString.h @@ -78,8 +78,7 @@ * */ -#ifndef __FLASH_STRING_H_ -#define __FLASH_STRING_H_ +#pragma once #include "WString.h" @@ -254,5 +253,3 @@ struct FlashString { return !isEqual(str); } }; - -#endif /* __FLASH_STRING_H_ */ diff --git a/Sming/Wiring/IPAddress.h b/Sming/Wiring/IPAddress.h index fe1d55489e..e6ff7602a4 100644 --- a/Sming/Wiring/IPAddress.h +++ b/Sming/Wiring/IPAddress.h @@ -17,8 +17,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef IPAddress_h -#define IPAddress_h +#pragma once #include #include "Printable.h" @@ -138,5 +137,3 @@ class IPAddress : public Printable // Making this extern saves 100's of bytes; each usage otherwise incurs 4 bytes of BSS #define INADDR_NONE IPAddress() - -#endif diff --git a/Sming/Wiring/Print.h b/Sming/Wiring/Print.h index aace171e28..420350e867 100644 --- a/Sming/Wiring/Print.h +++ b/Sming/Wiring/Print.h @@ -16,8 +16,7 @@ || */ -#ifndef PRINT_H -#define PRINT_H +#pragma once #ifdef __cplusplus @@ -97,5 +96,3 @@ class Print }; #endif // __cplusplus -#endif -// PRINT_H diff --git a/Sming/Wiring/Printable.h b/Sming/Wiring/Printable.h index 6fe72992ba..bcd5cb7702 100644 --- a/Sming/Wiring/Printable.h +++ b/Sming/Wiring/Printable.h @@ -33,8 +33,7 @@ || */ -#ifndef PRINTABLE_H -#define PRINTABLE_H +#pragma once class Print; @@ -44,6 +43,3 @@ class Printable virtual ~Printable() { } virtual size_t printTo(Print &p) const = 0; }; - -#endif -// PRINTABLE_H diff --git a/Sming/Wiring/SplitString.h b/Sming/Wiring/SplitString.h index 2badb00792..58124a2cc3 100644 --- a/Sming/Wiring/SplitString.h +++ b/Sming/Wiring/SplitString.h @@ -9,8 +9,7 @@ || */ -#ifndef _SPLIT_STRING_H_ -#define _SPLIT_STRING_H_ +#pragma once #include "WVector.h" #include "WString.h" @@ -35,5 +34,3 @@ int splitString(String &what, char delim, Vector &splits); * example: " a,b,c,d,e" returns ["a", "b", "c", "d", "e"] */ int splitString(String &what, char delim, Vector &splits); - -#endif diff --git a/Sming/Wiring/Stream.h b/Sming/Wiring/Stream.h index 4fda9a97c7..aa98ae6f6b 100644 --- a/Sming/Wiring/Stream.h +++ b/Sming/Wiring/Stream.h @@ -21,8 +21,7 @@ || */ -#ifndef STREAM_H -#define STREAM_H +#pragma once #include "Print.h" #include "WiringFrameworkDependencies.h" @@ -93,6 +92,3 @@ class Stream : public Print float parseFloat(char skipChar); // as above but the given skipChar is ignored }; - -#endif -// STREAM_H diff --git a/Sming/Wiring/WCharacter.h b/Sming/Wiring/WCharacter.h index d039819ff0..aa3e78b245 100644 --- a/Sming/Wiring/WCharacter.h +++ b/Sming/Wiring/WCharacter.h @@ -15,8 +15,7 @@ || */ -#ifndef WCHARACTER_H -#define WCHARACTER_H +#pragma once #include "WiringFrameworkIncludes.h" @@ -162,6 +161,3 @@ inline int toUpperCase(int c) { return toupper(c); } - -#endif -// WCHARACTER_H diff --git a/Sming/Wiring/WConstants.h b/Sming/Wiring/WConstants.h index b802b5f9c2..ce03186b41 100644 --- a/Sming/Wiring/WConstants.h +++ b/Sming/Wiring/WConstants.h @@ -15,8 +15,7 @@ || */ -#ifndef WCONSTANTS_H -#define WCONSTANTS_H +#pragma once #include @@ -143,6 +142,3 @@ typedef unsigned int word; typedef uint8_t byte; typedef uint8_t boolean; typedef void (*voidFuncPtr)(void); - -#endif -// WCONSTANTS_H diff --git a/Sming/Wiring/WHashMap.h b/Sming/Wiring/WHashMap.h index 597493d0d1..add54e8dbc 100644 --- a/Sming/Wiring/WHashMap.h +++ b/Sming/Wiring/WHashMap.h @@ -26,8 +26,7 @@ * */ -#ifndef HASHMAP_H -#define HASHMAP_H +#pragma once #include "WiringFrameworkDependencies.h" @@ -320,6 +319,3 @@ class HashMap private: HashMap(const HashMap& that); }; - -#endif -// HASHMAP_H diff --git a/Sming/Wiring/WMath.h b/Sming/Wiring/WMath.h index deb9e04cd8..923ebde31f 100644 --- a/Sming/Wiring/WMath.h +++ b/Sming/Wiring/WMath.h @@ -15,8 +15,7 @@ || */ -#ifndef WMATH_H -#define WMATH_H +#pragma once #include "WiringFrameworkIncludes.h" @@ -26,6 +25,3 @@ long map(long, long, long, long, long); void randomSeed(uint16_t); uint16_t makeWord(uint8_t, uint8_t); uint16_t makeWord(uint16_t); - -#endif -// WMATH_H diff --git a/Sming/Wiring/WShift.h b/Sming/Wiring/WShift.h index bc013835ff..8b2f8cec42 100644 --- a/Sming/Wiring/WShift.h +++ b/Sming/Wiring/WShift.h @@ -15,13 +15,9 @@ || */ -#ifndef WSHIFT_H -#define WSHIFT_H +#pragma once #include "WiringFrameworkIncludes.h" uint16_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t count = 8, uint8_t delayTime = 1); void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint16_t value, uint8_t count = 8, uint8_t delayTime = 1); - -#endif -// WSHIFT_H diff --git a/Sming/Wiring/WString.h b/Sming/Wiring/WString.h index ea36552f74..925c6dd1c6 100644 --- a/Sming/Wiring/WString.h +++ b/Sming/Wiring/WString.h @@ -46,8 +46,7 @@ * */ -#ifndef WSTRING_H -#define WSTRING_H +#pragma once #ifdef __cplusplus @@ -385,5 +384,3 @@ class StringSumHelper : public String #include "SplitString.h" #endif // __cplusplus -#endif -// WSTRING_H diff --git a/Sming/Wiring/WVector.h b/Sming/Wiring/WVector.h index a6c9b803fc..41c224c4b1 100644 --- a/Sming/Wiring/WVector.h +++ b/Sming/Wiring/WVector.h @@ -15,8 +15,7 @@ || */ -#ifndef WVECTOR_H -#define WVECTOR_H +#pragma once #include "Countable.h" #include @@ -452,6 +451,3 @@ void Vector::sort(Comparer compareFunction) _data[i+1] = key; //Put key into its proper location } } - -#endif -// WVECTOR_H diff --git a/Sming/Wiring/WiringFrameworkDependencies.h b/Sming/Wiring/WiringFrameworkDependencies.h index 2b4f6cd7cc..65e76017c5 100644 --- a/Sming/Wiring/WiringFrameworkDependencies.h +++ b/Sming/Wiring/WiringFrameworkDependencies.h @@ -5,8 +5,7 @@ * Author: Anakonda */ -#ifndef WIRING_WIRINGFRAMEWORKDEPENDENCIES_H_ -#define WIRING_WIRINGFRAMEWORKDEPENDENCIES_H_ +#pragma once #include @@ -29,6 +28,3 @@ using std::isinf; using std::isnan; using std::max; using std::min; - - -#endif /* WIRING_WIRINGFRAMEWORKDEPENDENCIES_H_ */ diff --git a/Sming/Wiring/WiringFrameworkIncludes.h b/Sming/Wiring/WiringFrameworkIncludes.h index 61ae080956..3d3d23fc30 100644 --- a/Sming/Wiring/WiringFrameworkIncludes.h +++ b/Sming/Wiring/WiringFrameworkIncludes.h @@ -5,8 +5,7 @@ * Author: Anakonda */ -#ifndef WIRING_WIRINGFRAMEWORKINCLUDES_H_ -#define WIRING_WIRINGFRAMEWORKINCLUDES_H_ +#pragma once #include "WiringFrameworkDependencies.h" #include "WConstants.h" @@ -26,5 +25,3 @@ #include "Display.h" #include "WHashMap.h" #include "IPAddress.h" - -#endif /* WIRING_WIRINGFRAMEWORKINCLUDES_H_ */ diff --git a/Sming/Wiring/wiring_private.h b/Sming/Wiring/wiring_private.h index 413b082c10..984c984c6d 100644 --- a/Sming/Wiring/wiring_private.h +++ b/Sming/Wiring/wiring_private.h @@ -1,7 +1,6 @@ // Just for compatibility with Arduino libraries. -#ifndef WIRING_WIRING_PRIVATE_H_ -#define WIRING_WIRING_PRIVATE_H_ +#pragma once #include #include @@ -23,5 +22,3 @@ typedef void (*voidFuncPtr)(void); #ifdef __cplusplus } // extern "C" #endif - -#endif /* WIRING_WIRING_PRIVATE_H_ */ From 9fb2b9a51b636165c5b3193dc482e929a90df359 Mon Sep 17 00:00:00 2001 From: mikee47 Date: Tue, 30 Apr 2019 11:48:32 +0100 Subject: [PATCH 19/22] Minor change to `building.md` --- Sming/building.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sming/building.md b/Sming/building.md index a5d5b511fb..25f8c88b9e 100644 --- a/Sming/building.md +++ b/Sming/building.md @@ -63,7 +63,7 @@ Arch/ Architecture-specific makefiles and code Components/ Framework support code, not to be used directly by applications -Core/ Main framework core (TODO: rename to `Core`) +Core/ Main framework core Libraries/ Arduino Libraries From 4498378451528e023cd665b9287871217dc9d6c1 Mon Sep 17 00:00:00 2001 From: mikee47 Date: Tue, 30 Apr 2019 14:48:29 +0100 Subject: [PATCH 20/22] Fix coding style --- Sming/Core/Data/ObjectQueue.h | 1 - Sming/Core/Data/Stream/FileStream.h | 1 - Sming/Core/SPISoft.h | 1 - Sming/Core/Timer.h | 1 - Sming/Core/twi.h | 1 - 5 files changed, 5 deletions(-) diff --git a/Sming/Core/Data/ObjectQueue.h b/Sming/Core/Data/ObjectQueue.h index 1bb1337f7c..9108764b70 100644 --- a/Sming/Core/Data/ObjectQueue.h +++ b/Sming/Core/Data/ObjectQueue.h @@ -39,4 +39,3 @@ template class ObjectQueue : public FIFO return FIFO::count() ? FIFO::dequeue() : nullptr; } }; - diff --git a/Sming/Core/Data/Stream/FileStream.h b/Sming/Core/Data/Stream/FileStream.h index 46d7ef72e8..9a20542a59 100644 --- a/Sming/Core/Data/Stream/FileStream.h +++ b/Sming/Core/Data/Stream/FileStream.h @@ -158,4 +158,3 @@ class FileStream : public ReadWriteStream }; /** @} */ - diff --git a/Sming/Core/SPISoft.h b/Sming/Core/SPISoft.h index d82867e846..425fecca67 100644 --- a/Sming/Core/SPISoft.h +++ b/Sming/Core/SPISoft.h @@ -80,4 +80,3 @@ class SPISoft : public SPIBase uint16_t mMISO, mMOSI, mCLK; uint8_t m_delay; }; - diff --git a/Sming/Core/Timer.h b/Sming/Core/Timer.h index 1971b1ee40..49bc0af11c 100644 --- a/Sming/Core/Timer.h +++ b/Sming/Core/Timer.h @@ -190,4 +190,3 @@ class Timer uint16_t longIntervalCounter = 0; uint16_t longIntervalCounterLimit = 0; }; - diff --git a/Sming/Core/twi.h b/Sming/Core/twi.h index a4cc16f263..f482286ded 100644 --- a/Sming/Core/twi.h +++ b/Sming/Core/twi.h @@ -44,4 +44,3 @@ uint8_t twi_status(); #ifdef __cplusplus } #endif - From f0ad288b19600f5e112cb9f9de08d1086302e88b Mon Sep 17 00:00:00 2001 From: mikee47 Date: Tue, 30 Apr 2019 14:59:31 +0100 Subject: [PATCH 21/22] Fix line endings by running everything through dos2unix --- .../esp8266/include/esp_wifi_sniffer.h | 122 +-- .../Esp8266/Components/gdbstub/GdbPacket.cpp | 294 +++--- .../Esp8266/Components/gdbstub/GdbPacket.h | 218 ++--- .../Components/gdbstub/appcode/gdb_hooks.cpp | 502 +++++------ .../Esp8266/Components/gdbstub/exceptions.h | 116 +-- .../Components/gdbstub/gdb/registers.h | 352 ++++---- .../Esp8266/Components/gdbstub/gdbhostio.cpp | 348 ++++---- .../Esp8266/Components/gdbstub/gdbhostio.h | 30 +- .../Components/gdbstub/gdbstub-entry.h | 56 +- .../Components/gdbstub/gdbstub-internal.h | 150 ++-- .../Arch/Esp8266/Components/gdbstub/gdbstub.h | 132 +-- .../Esp8266/Components/gdbstub/gdbsyscall.cpp | 526 +++++------ .../Esp8266/Components/gdbstub/gdbsyscall.h | 60 +- .../Esp8266/Components/gdbstub/gdbuart.cpp | 836 ++++++++--------- .../Arch/Esp8266/Components/gdbstub/gdbuart.h | 108 +-- .../gdbstub/xtensa/xtruntime-frames.h | 320 +++---- Sming/Arch/Esp8266/Platform/RTC.cpp | 170 ++-- Sming/Arch/Esp8266/Platform/WifiSniffer.cpp | 352 ++++---- Sming/Core/Data/Buffer/LineBuffer.h | 228 ++--- Sming/Core/Data/Buffer/SerialBuffer.cpp | 132 +-- Sming/Core/Data/Buffer/SerialBuffer.h | 332 +++---- Sming/Core/Data/ObjectMap.h | 682 +++++++------- Sming/Core/Data/Stream/JsonObjectStream.cpp | 42 +- Sming/Core/Network/Http/HttpCommon.cpp | 142 +-- Sming/Core/Network/Http/HttpHeaderBuilder.h | 106 +-- Sming/Core/Network/Http/HttpHeaders.cpp | 132 +-- Sming/Core/Network/Http/HttpHeaders.h | 454 +++++----- Sming/Core/Network/Http/HttpParams.cpp | 270 +++--- Sming/Core/Network/Http/HttpParams.h | 152 ++-- Sming/Core/Network/Http/HttpResourceTree.cpp | 88 +- Sming/Core/Network/Http/HttpResourceTree.h | 162 ++-- Sming/Core/Network/Ssl/SslFingerprints.cpp | 166 ++-- Sming/Core/Network/Ssl/SslFingerprints.h | 204 ++--- Sming/Core/Network/Ssl/SslKeyCertPair.h | 224 ++--- Sming/Core/Network/Ssl/SslSessionId.h | 98 +- Sming/Core/Network/Ssl/SslStructs.h | 46 +- Sming/Core/Network/WebConstants.cpp | 142 +-- Sming/Libraries/ArduCAM/ArduCAM.h | 696 +++++++-------- Sming/Platform/OsMessageInterceptor.cpp | 80 +- Sming/Platform/OsMessageInterceptor.h | 198 ++-- Sming/Platform/WifiSniffer.h | 286 +++--- Sming/SmingCore/SmingCore.h | 6 +- Sming/System/include/gdb/gdb_syscall.h | 844 +++++++++--------- Sming/Wiring/FlashString.h | 510 +++++------ Sming/build.mk | 486 +++++----- Sming/building.md | 276 +++--- Sming/modules.mk | 144 +-- 47 files changed, 6010 insertions(+), 6010 deletions(-) diff --git a/Sming/Arch/Esp8266/Components/esp8266/include/esp_wifi_sniffer.h b/Sming/Arch/Esp8266/Components/esp8266/include/esp_wifi_sniffer.h index acf1d18530..9814dcfe2c 100644 --- a/Sming/Arch/Esp8266/Components/esp8266/include/esp_wifi_sniffer.h +++ b/Sming/Arch/Esp8266/Components/esp8266/include/esp_wifi_sniffer.h @@ -1,61 +1,61 @@ -/* - * esp_promiscuous.h - * - * Internal structures for decoding WiFi in promiscuous mode - * - * See ESP8266 Technical Reference, Chapter 14: Sniffer Introduction - */ - -#pragma once - -#include - -/* ============================================== - Promiscous callback structures, see ESP manual - ============================================== */ -struct RxControl { - signed rssi : 8; - unsigned rate : 4; - unsigned is_group : 1; - unsigned : 1; - unsigned sig_mode : 2; - unsigned legacy_length : 12; - unsigned damatch0 : 1; - unsigned damatch1 : 1; - unsigned bssidmatch0 : 1; - unsigned bssidmatch1 : 1; - unsigned MCS : 7; - unsigned CWB : 1; - unsigned HT_length : 16; - unsigned Smoothing : 1; - unsigned Not_Sounding : 1; - unsigned : 1; - unsigned Aggregation : 1; - unsigned STBC : 2; - unsigned FEC_CODING : 1; - unsigned SGI : 1; - unsigned rxend_state : 8; - unsigned ampdu_cnt : 8; - unsigned channel : 4; - unsigned : 12; -}; - -struct LenSeq { - uint16_t length; - uint16_t seq; - uint8_t address3[6]; -}; - -struct sniffer_buf { - struct RxControl rx_ctrl; - uint8_t buf[36]; - uint16_t cnt; - struct LenSeq lenseq[1]; -}; - -struct sniffer_buf2 { - struct RxControl rx_ctrl; - uint8_t buf[112]; - uint16_t cnt; - uint16_t len; -}; +/* + * esp_promiscuous.h + * + * Internal structures for decoding WiFi in promiscuous mode + * + * See ESP8266 Technical Reference, Chapter 14: Sniffer Introduction + */ + +#pragma once + +#include + +/* ============================================== + Promiscous callback structures, see ESP manual + ============================================== */ +struct RxControl { + signed rssi : 8; + unsigned rate : 4; + unsigned is_group : 1; + unsigned : 1; + unsigned sig_mode : 2; + unsigned legacy_length : 12; + unsigned damatch0 : 1; + unsigned damatch1 : 1; + unsigned bssidmatch0 : 1; + unsigned bssidmatch1 : 1; + unsigned MCS : 7; + unsigned CWB : 1; + unsigned HT_length : 16; + unsigned Smoothing : 1; + unsigned Not_Sounding : 1; + unsigned : 1; + unsigned Aggregation : 1; + unsigned STBC : 2; + unsigned FEC_CODING : 1; + unsigned SGI : 1; + unsigned rxend_state : 8; + unsigned ampdu_cnt : 8; + unsigned channel : 4; + unsigned : 12; +}; + +struct LenSeq { + uint16_t length; + uint16_t seq; + uint8_t address3[6]; +}; + +struct sniffer_buf { + struct RxControl rx_ctrl; + uint8_t buf[36]; + uint16_t cnt; + struct LenSeq lenseq[1]; +}; + +struct sniffer_buf2 { + struct RxControl rx_ctrl; + uint8_t buf[112]; + uint16_t cnt; + uint16_t len; +}; diff --git a/Sming/Arch/Esp8266/Components/gdbstub/GdbPacket.cpp b/Sming/Arch/Esp8266/Components/gdbstub/GdbPacket.cpp index 51ca564620..16f791ff6f 100644 --- a/Sming/Arch/Esp8266/Components/gdbstub/GdbPacket.cpp +++ b/Sming/Arch/Esp8266/Components/gdbstub/GdbPacket.cpp @@ -1,147 +1,147 @@ -/**** - * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. - * Created 2015 by Skurydin Alexey - * http://github.com/SmingHub/Sming - * All files of the Sming Core are provided under the LGPL v3 license. - * - * @author: 2019 - Mikee47 - * - * Manages GDB packet encoding - * - ****/ - -#include "GdbPacket.h" - -// Send the start of a packet; reset checksum calculation. -void ATTR_GDBEXTERNFN GdbPacket::start() -{ -#if GDBSTUB_ENABLE_DEBUG - m_puts(_F("> PKT ")); -#endif - gdbSendChar('$'); -} - -void ATTR_GDBEXTERNFN GdbPacket::end() -{ - gdbSendChar('#'); - writeHexByte(checksum); -#if GDBSTUB_ENABLE_DEBUG - m_puts("\r\n"); -#endif -} - -void ATTR_GDBEXTERNFN GdbPacket::writeChar(char c) -{ - gdbSendChar(c); - ++packetLength; - checksum += uint8_t(c); -} - -void ATTR_GDBEXTERNFN GdbPacket::writeCharEscaped(char c) -{ - if(c == '#' || c == '$' || c == '}' || c == '*') { - writeChar('}'); - c ^= 0x20; - } - writeChar(c); -} - -void ATTR_GDBEXTERNFN GdbPacket::writeEscaped(const void* data, unsigned length) -{ - for(unsigned i = 0; i < length; ++i) { - writeCharEscaped(static_cast(data)[i]); - } -} - -void ATTR_GDBEXTERNFN GdbPacket::write(const void* data, unsigned length) -{ - for(unsigned i = 0; i < length; ++i) { - checksum += static_cast(data)[i]; - } - gdbSendData(data, length); - packetLength += length; -} - -void ATTR_GDBEXTERNFN GdbPacket::writeStr(const char* str) -{ - write(str, strlen(str)); -} - -void ATTR_GDBEXTERNFN GdbPacket::writeStrRef(const char* str) -{ - writeHexWord32(uint32_t(str)); - writeChar('/'); - writeHexWord16(strlen_P(str) + 1); -} - -void ATTR_GDBEXTERNFN GdbPacket::writeX32() -{ - for(int i = 0; i < 8; i++) { - writeChar('x'); - } -} - -void ATTR_GDBEXTERNFN GdbPacket::writeHexByte(uint8_t value) -{ - writeChar(hexchar((value >> 4) & 0x0f)); - writeChar(hexchar(value & 0x0f)); -} - -void ATTR_GDBEXTERNFN GdbPacket::writeHexWord16(uint16_t value) -{ - writeHexByte(value >> 8); - writeHexByte(value); -} - -void ATTR_GDBEXTERNFN GdbPacket::writeHexWord32(uint32_t value) -{ - writeHexByte(value >> 24); - writeHexByte(value >> 16); - writeHexByte(value >> 8); - writeHexByte(value); -} - -void ATTR_GDBEXTERNFN GdbPacket::writeHexBlock(const void* src, size_t size) -{ - for(unsigned i = 0; i < size; ++i) { - writeHexByte(static_cast(src)[i]); - } -} - -uint32_t ATTR_GDBEXTERNFN GdbPacket::readHexValue(const char*& data) -{ - uint32_t result = 0; - int8_t c; - while((c = unhex(*data)) >= 0) { - result = (result << 4) | c; - ++data; - } - return result; -} - -void ATTR_GDBEXTERNFN GdbPacket::encodeHexBlock(char* dst, const void* src, size_t size) -{ - for(unsigned i = 0; i < size; ++i) { - uint8_t value = static_cast(src)[i]; - *dst++ = hexchar((value >> 4) & 0x0f); - *dst++ = hexchar(value & 0x0f); - } -} - -size_t ATTR_GDBEXTERNFN GdbPacket::decodeHexBlock(void* dst, const char*& src) -{ - auto out = static_cast(dst); - for(;;) { - int8_t c1 = unhex(src[0]); - if(c1 < 0) { - break; - } - int8_t c0 = unhex(src[1]); - if(c0 < 0) { - break; - } - src += 2; - *out++ = (c1 << 4) | c0; - } - return out - static_cast(dst); -} +/**** + * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. + * Created 2015 by Skurydin Alexey + * http://github.com/SmingHub/Sming + * All files of the Sming Core are provided under the LGPL v3 license. + * + * @author: 2019 - Mikee47 + * + * Manages GDB packet encoding + * + ****/ + +#include "GdbPacket.h" + +// Send the start of a packet; reset checksum calculation. +void ATTR_GDBEXTERNFN GdbPacket::start() +{ +#if GDBSTUB_ENABLE_DEBUG + m_puts(_F("> PKT ")); +#endif + gdbSendChar('$'); +} + +void ATTR_GDBEXTERNFN GdbPacket::end() +{ + gdbSendChar('#'); + writeHexByte(checksum); +#if GDBSTUB_ENABLE_DEBUG + m_puts("\r\n"); +#endif +} + +void ATTR_GDBEXTERNFN GdbPacket::writeChar(char c) +{ + gdbSendChar(c); + ++packetLength; + checksum += uint8_t(c); +} + +void ATTR_GDBEXTERNFN GdbPacket::writeCharEscaped(char c) +{ + if(c == '#' || c == '$' || c == '}' || c == '*') { + writeChar('}'); + c ^= 0x20; + } + writeChar(c); +} + +void ATTR_GDBEXTERNFN GdbPacket::writeEscaped(const void* data, unsigned length) +{ + for(unsigned i = 0; i < length; ++i) { + writeCharEscaped(static_cast(data)[i]); + } +} + +void ATTR_GDBEXTERNFN GdbPacket::write(const void* data, unsigned length) +{ + for(unsigned i = 0; i < length; ++i) { + checksum += static_cast(data)[i]; + } + gdbSendData(data, length); + packetLength += length; +} + +void ATTR_GDBEXTERNFN GdbPacket::writeStr(const char* str) +{ + write(str, strlen(str)); +} + +void ATTR_GDBEXTERNFN GdbPacket::writeStrRef(const char* str) +{ + writeHexWord32(uint32_t(str)); + writeChar('/'); + writeHexWord16(strlen_P(str) + 1); +} + +void ATTR_GDBEXTERNFN GdbPacket::writeX32() +{ + for(int i = 0; i < 8; i++) { + writeChar('x'); + } +} + +void ATTR_GDBEXTERNFN GdbPacket::writeHexByte(uint8_t value) +{ + writeChar(hexchar((value >> 4) & 0x0f)); + writeChar(hexchar(value & 0x0f)); +} + +void ATTR_GDBEXTERNFN GdbPacket::writeHexWord16(uint16_t value) +{ + writeHexByte(value >> 8); + writeHexByte(value); +} + +void ATTR_GDBEXTERNFN GdbPacket::writeHexWord32(uint32_t value) +{ + writeHexByte(value >> 24); + writeHexByte(value >> 16); + writeHexByte(value >> 8); + writeHexByte(value); +} + +void ATTR_GDBEXTERNFN GdbPacket::writeHexBlock(const void* src, size_t size) +{ + for(unsigned i = 0; i < size; ++i) { + writeHexByte(static_cast(src)[i]); + } +} + +uint32_t ATTR_GDBEXTERNFN GdbPacket::readHexValue(const char*& data) +{ + uint32_t result = 0; + int8_t c; + while((c = unhex(*data)) >= 0) { + result = (result << 4) | c; + ++data; + } + return result; +} + +void ATTR_GDBEXTERNFN GdbPacket::encodeHexBlock(char* dst, const void* src, size_t size) +{ + for(unsigned i = 0; i < size; ++i) { + uint8_t value = static_cast(src)[i]; + *dst++ = hexchar((value >> 4) & 0x0f); + *dst++ = hexchar(value & 0x0f); + } +} + +size_t ATTR_GDBEXTERNFN GdbPacket::decodeHexBlock(void* dst, const char*& src) +{ + auto out = static_cast(dst); + for(;;) { + int8_t c1 = unhex(src[0]); + if(c1 < 0) { + break; + } + int8_t c0 = unhex(src[1]); + if(c0 < 0) { + break; + } + src += 2; + *out++ = (c1 << 4) | c0; + } + return out - static_cast(dst); +} diff --git a/Sming/Arch/Esp8266/Components/gdbstub/GdbPacket.h b/Sming/Arch/Esp8266/Components/gdbstub/GdbPacket.h index a3f23030e6..83344ec3c9 100644 --- a/Sming/Arch/Esp8266/Components/gdbstub/GdbPacket.h +++ b/Sming/Arch/Esp8266/Components/gdbstub/GdbPacket.h @@ -1,109 +1,109 @@ -/**** - * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. - * Created 2015 by Skurydin Alexey - * http://github.com/SmingHub/Sming - * All files of the Sming Core are provided under the LGPL v3 license. - * - * @author: 2019 - Mikee47 - * - * Manages GDB packet encoding. See here for details: - * - * https://sourceware.org/gdb/current/onlinedocs/gdb/Remote-Protocol.html - * - ****/ - -#pragma once - -#include "gdbuart.h" - -class GdbPacket -{ -public: - // Automatically start sending a packet - __forceinline GdbPacket() - { - start(); - } - - // Finish sending a packet - __forceinline ~GdbPacket() - { - end(); - } - - // Send a char as part of a packet - void writeChar(char c); - - /** @brief Send a character, escaping if required */ - void writeCharEscaped(char c); - - /** @brief Send a block of data, escaping as required */ - void writeEscaped(const void* data, unsigned length); - - /** @brief Output 8-bit value */ - void writeHexByte(uint8_t value); - - /** @brief Output 16-bit value */ - void writeHexWord16(uint16_t value); - - /** @brief Output 32-bit value */ - void writeHexWord32(uint32_t value); - - /** - * @brief Output a block of data, hex-encoded - * @param src - * @param size - */ - void writeHexBlock(const void* src, size_t size); - - /** @brief Output 'xxxxxxxx' to indicate undefined register value */ - void writeX32(); - - /** @brief Output block of data exactly as given without escaping */ - void write(const void* data, unsigned length); - - /** @brief Output a null-terminated string exactly as given without escaping */ - void writeStr(const char* str); - - /** @brief Output a string reference in addr/len format */ - void writeStrRef(const char* str); - - size_t getLength() - { - return packetLength + 3; // Include # and checksum digits - } - - /** - * @brief Decode a variable-length hex value, MSB first - * @param data will get positioned on the end of the hex string, as far as the routine has read into it - * @retval uint32_t decoded value - */ - static uint32_t readHexValue(const char*& data); - - /** @brief Encode a value as hex characters, LSB first - * @param dst Location for output, will NOT be nul-terminated - * @param srcData Data bytes to encode - * @param size Size of source data in bytes - * @Note destination buffer must have enough space for (size * 2) chars - */ - static void encodeHexBlock(char* dst, const void* src, size_t size); - - /** @brief Decode hex-encoded data block - * @param dst buffer for decoded hex bytes (may be same as src) - * @param src source data, on return points to first character after hex data - * @retval size_t number of decoded bytes - * @note Output is always smaller than input so safe to overwrite src - */ - static size_t decodeHexBlock(void* dst, const char*& src); - -private: - // Send the start of a packet; reset checksum calculation. - void start(); - - // Finish sending a packet. - void end(); - -private: - uint8_t checksum = 0; ///< Running checksum of the output packet - unsigned packetLength = 0; -}; +/**** + * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. + * Created 2015 by Skurydin Alexey + * http://github.com/SmingHub/Sming + * All files of the Sming Core are provided under the LGPL v3 license. + * + * @author: 2019 - Mikee47 + * + * Manages GDB packet encoding. See here for details: + * + * https://sourceware.org/gdb/current/onlinedocs/gdb/Remote-Protocol.html + * + ****/ + +#pragma once + +#include "gdbuart.h" + +class GdbPacket +{ +public: + // Automatically start sending a packet + __forceinline GdbPacket() + { + start(); + } + + // Finish sending a packet + __forceinline ~GdbPacket() + { + end(); + } + + // Send a char as part of a packet + void writeChar(char c); + + /** @brief Send a character, escaping if required */ + void writeCharEscaped(char c); + + /** @brief Send a block of data, escaping as required */ + void writeEscaped(const void* data, unsigned length); + + /** @brief Output 8-bit value */ + void writeHexByte(uint8_t value); + + /** @brief Output 16-bit value */ + void writeHexWord16(uint16_t value); + + /** @brief Output 32-bit value */ + void writeHexWord32(uint32_t value); + + /** + * @brief Output a block of data, hex-encoded + * @param src + * @param size + */ + void writeHexBlock(const void* src, size_t size); + + /** @brief Output 'xxxxxxxx' to indicate undefined register value */ + void writeX32(); + + /** @brief Output block of data exactly as given without escaping */ + void write(const void* data, unsigned length); + + /** @brief Output a null-terminated string exactly as given without escaping */ + void writeStr(const char* str); + + /** @brief Output a string reference in addr/len format */ + void writeStrRef(const char* str); + + size_t getLength() + { + return packetLength + 3; // Include # and checksum digits + } + + /** + * @brief Decode a variable-length hex value, MSB first + * @param data will get positioned on the end of the hex string, as far as the routine has read into it + * @retval uint32_t decoded value + */ + static uint32_t readHexValue(const char*& data); + + /** @brief Encode a value as hex characters, LSB first + * @param dst Location for output, will NOT be nul-terminated + * @param srcData Data bytes to encode + * @param size Size of source data in bytes + * @Note destination buffer must have enough space for (size * 2) chars + */ + static void encodeHexBlock(char* dst, const void* src, size_t size); + + /** @brief Decode hex-encoded data block + * @param dst buffer for decoded hex bytes (may be same as src) + * @param src source data, on return points to first character after hex data + * @retval size_t number of decoded bytes + * @note Output is always smaller than input so safe to overwrite src + */ + static size_t decodeHexBlock(void* dst, const char*& src); + +private: + // Send the start of a packet; reset checksum calculation. + void start(); + + // Finish sending a packet. + void end(); + +private: + uint8_t checksum = 0; ///< Running checksum of the output packet + unsigned packetLength = 0; +}; diff --git a/Sming/Arch/Esp8266/Components/gdbstub/appcode/gdb_hooks.cpp b/Sming/Arch/Esp8266/Components/gdbstub/appcode/gdb_hooks.cpp index 1ddf36bd82..d060758ccb 100644 --- a/Sming/Arch/Esp8266/Components/gdbstub/appcode/gdb_hooks.cpp +++ b/Sming/Arch/Esp8266/Components/gdbstub/appcode/gdb_hooks.cpp @@ -1,251 +1,251 @@ -/**** - * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. - * Created 2015 by Skurydin Alexey - * http://github.com/SmingHub/Sming - * All files of the Sming Core are provided under the LGPL v3 license. - * - * gdb_hooks.cpp - * - ****/ - -#include -#include -#include "gdbstub/gdbstub.h" -#include "gdbstub/gdbuart.h" -#include "gdbstub/gdbstub-entry.h" -#include "gdbstub/exceptions.h" -#include - -extern "C" { - -void Cache_Read_Enable_New(); - -typedef void (*xtos_handler_func)(UserFrame* frame); -void _xtos_set_exception_handler(int, xtos_handler_func); -} - -// List of GDB signals used for exceptions -const uint8_t gdb_exception_signals[] GDB_PROGMEM = { -#define XX(ex, sig, desc) sig, - SYSTEM_EXCEPTION_MAP(XX) -#undef XX -}; - -// List of exception names -#define XX(ex, sig, desc) static DEFINE_PSTR(exception_str_##ex, #ex) -SYSTEM_EXCEPTION_MAP(XX) -#undef XX -static PGM_P const exceptionNames[] PROGMEM = { -#define XX(ex, sig, desc) exception_str_##ex, - SYSTEM_EXCEPTION_MAP(XX) -#undef XX -}; - -// The asm stub saves the Xtensa registers here when an exception is raised -GdbstubSavedRegisters gdbstub_savedRegs; - -void debug_print_stack(uint32_t start, uint32_t end) -{ - m_puts(_F("\r\n" - "Stack dump:\r\n")); - PSTR_ARRAY(instructions, "To decode the stack dump call from command line:\r\n" - " make decode-stacktrace\r\n" - "and copy & paste the text enclosed in '===='.\r\n"); - PSTR_ARRAY(separatorLine, "\n================================================================\r\n"); - m_puts(instructions); - m_puts(separatorLine); - for(uint32_t addr = start; addr < end; addr += 0x10) { - uint32_t* values = (uint32_t*)addr; - // rough indicator: stack frames usually have SP saved as the second word - bool looksLikeStackFrame = (values[2] == addr + 0x10); - - m_printf(_F("%08x: %08x %08x %08x %08x %c\r\n"), addr, values[0], values[1], values[2], values[3], - (looksLikeStackFrame) ? '<' : ' '); - - system_soft_wdt_feed(); - wdt_feed(); - } - m_puts(separatorLine); - m_puts(instructions); -} - -void debug_crash_callback(const rst_info* rst_info, uint32_t stack, uint32_t stack_end) -{ -#ifdef ENABLE_GDB - gdbFlushUserData(); - if(gdb_state.attached) { - m_setPuts(gdbWriteConsole); - } -#endif - -#if defined(ENABLE_GDB) || ENABLE_CRASH_DUMP - switch(rst_info->reason) { - case REASON_EXCEPTION_RST: - m_printf(_F("\r\n" - "\n" - "***** Exception Reset (%u):\r\n" - "epc1=0x%08x epc2=0x%08x epc3=0x%08x excvaddr=0x%08x depc=0x%08x\r\n"), - rst_info->exccause, rst_info->epc1, rst_info->epc2, rst_info->epc3, rst_info->excvaddr, - rst_info->depc); - break; - case REASON_SOFT_WDT_RST: - m_puts(_F("\r\n" - "\n" - "***** Software Watchdog Reset\r\n")); - break; - default: - // - ; - } - -#if defined(ENABLE_GDB) && GDBSTUB_BREAK_ON_RESTART - // Drop interrupt level to enable break instruction - asm("rsil a2, 1"); // XCHAL_DEBUGLEVEL - 1 - gdbstub_break_internal(DBGFLAG_RESTART); -#elif ENABLE_CRASH_DUMP - debug_print_stack(stack, stack_end); -#endif - -#endif // defined(ENABLE_GDB) || ENABLE_CRASH_DUMP -} - -#ifdef HOOK_SYSTEM_EXCEPTIONS - -void dumpExceptionInfo() -{ - auto& reg = gdbstub_savedRegs; - - m_printf(_F("\r\n" - "\n" - "***** Fatal exception %u"), - reg.cause); - if(reg.cause <= EXCCAUSE_MAX) { - m_printf(_F(" (%s)"), exceptionNames[reg.cause]); - } - m_puts("\r\n"); - - // EXCVADDR isn't set for all exceptions, so zero it out rather than show potentially misleading information - if(reg.cause < EXCCAUSE_UNALIGNED && reg.cause != EXCCAUSE_IFETCHERROR && reg.cause != EXCCAUSE_LOAD_STORE_ERROR) { - reg.excvaddr = 0; - } - - m_printf(_F("pc=0x%08x sp=0x%08x excvaddr=0x%08x\r\n"), reg.pc, reg.a[1], reg.excvaddr); - m_printf(_F("ps=0x%08x sar=0x%08x vpri=0x%08x\r\n"), reg.ps, reg.sar, reg.vpri); - for(int i = 0; i < 16; i++) { - uint32_t r = reg.a[i]; - m_printf(_F("r%02u: 0x%08x=%10d "), i, r, r); - if(i % 3 == 2) { - m_puts("\r\n"); - } - } - m_puts("\r\n"); - // Stack dump can be quite large, and not helpful to dump it to GDB console - if(gdb_present() != eGDB_Attached) { - debug_print_stack(reg.a[1], 0x3fffffb0); - } -} - -// Main exception handler code -static void __attribute__((noinline)) gdbstub_exception_handler_flash(UserFrame* frame) -{ - // Copy registers the Xtensa HAL did save to gdbstub_savedRegs - memcpy(&gdbstub_savedRegs, frame, 5 * 4); - memcpy(&gdbstub_savedRegs.a[2], &frame->a2, 14 * 4); - // Credits go to Cesanta for this trick. A1 seems to be destroyed, but because it - // has a fixed offset from the address of the passed frame, we can recover it. - const uint32_t EXCEPTION_GDB_SP_OFFSET = 0x100; - gdbstub_savedRegs.a[1] = uint32_t(frame) + EXCEPTION_GDB_SP_OFFSET; - -#if defined(ENABLE_GDB) && GDBSTUB_BREAK_ON_EXCEPTION - gdbFlushUserData(); - - // If GDB is attached, temporarily redirect m_printf calls to the console - nputs_callback_t oldPuts = nullptr; - if(gdb_state.attached) { - oldPuts = m_setPuts(gdbWriteConsole); - } - - dumpExceptionInfo(); - - if(gdb_state.attached) { - m_setPuts(oldPuts); - } - - gdbstub_handle_exception(); - - // Copy any changed registers back to the frame the Xtensa HAL uses. - memcpy(frame, &gdbstub_savedRegs, 5 * 4); - memcpy(&frame->a2, &gdbstub_savedRegs.a[2], 14 * 4); - -#else - - dumpExceptionInfo(); - -#if defined(ENABLE_GDB) - gdbFlushUserData(); -#endif - - // Wait for watchdog to reset system - while(true) - ; -#endif -} - -// Non-OS exception handler. Gets called by the Xtensa HAL. -static void IRAM_ATTR gdbstub_exception_handler(UserFrame* frame) -{ - // Save the extra registers the Xtensa HAL doesn't save - gdbstub_save_extra_sfrs_for_exception(); - Cache_Read_Enable_New(); - gdbstub_exception_handler_flash(frame); -} - -// The OS-less SDK uses the Xtensa HAL to handle exceptions. We can use those functions to catch any -// fatal exceptions and invoke the debugger when this happens. -static void ATTR_GDBINIT installExceptionHandler() -{ - for(unsigned ex = 0; ex <= EXCCAUSE_MAX; ++ex) { - unsigned signal = pgm_read_byte(&gdb_exception_signals[ex]); - if(signal != 0) { - _xtos_set_exception_handler(ex, gdbstub_exception_handler); - } - } -} - -#endif // HOOK_SYSTEM_EXCEPTIONS - -extern "C" { - -void ATTR_GDBINIT gdb_init(void) -{ - // Reset all serial ports to user-specified baud rate - for(unsigned i = 0; i < UART_PHYSICAL_COUNT; ++i) { - uart_set_baudrate_reg(i, SERIAL_BAUD_RATE); - } - -#ifdef HOOK_SYSTEM_EXCEPTIONS - installExceptionHandler(); -#endif - -#ifdef ENABLE_GDB - gdbstub_init(); -#endif -} - -static unsigned IRAM_ATTR __gdb_no_op(void) -{ - return 0; -} - -#define NOOP __attribute__((weak, alias("__gdb_no_op"))) - -void gdb_enable(bool state) NOOP; -GdbState gdb_present(void) NOOP; -void gdb_on_attach(bool attached) NOOP; -void gdb_detach(void) NOOP; -}; - -int __attribute__((weak)) gdb_syscall(const GdbSyscallInfo& info) -{ - return -1; -} +/**** + * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. + * Created 2015 by Skurydin Alexey + * http://github.com/SmingHub/Sming + * All files of the Sming Core are provided under the LGPL v3 license. + * + * gdb_hooks.cpp + * + ****/ + +#include +#include +#include "gdbstub/gdbstub.h" +#include "gdbstub/gdbuart.h" +#include "gdbstub/gdbstub-entry.h" +#include "gdbstub/exceptions.h" +#include + +extern "C" { + +void Cache_Read_Enable_New(); + +typedef void (*xtos_handler_func)(UserFrame* frame); +void _xtos_set_exception_handler(int, xtos_handler_func); +} + +// List of GDB signals used for exceptions +const uint8_t gdb_exception_signals[] GDB_PROGMEM = { +#define XX(ex, sig, desc) sig, + SYSTEM_EXCEPTION_MAP(XX) +#undef XX +}; + +// List of exception names +#define XX(ex, sig, desc) static DEFINE_PSTR(exception_str_##ex, #ex) +SYSTEM_EXCEPTION_MAP(XX) +#undef XX +static PGM_P const exceptionNames[] PROGMEM = { +#define XX(ex, sig, desc) exception_str_##ex, + SYSTEM_EXCEPTION_MAP(XX) +#undef XX +}; + +// The asm stub saves the Xtensa registers here when an exception is raised +GdbstubSavedRegisters gdbstub_savedRegs; + +void debug_print_stack(uint32_t start, uint32_t end) +{ + m_puts(_F("\r\n" + "Stack dump:\r\n")); + PSTR_ARRAY(instructions, "To decode the stack dump call from command line:\r\n" + " make decode-stacktrace\r\n" + "and copy & paste the text enclosed in '===='.\r\n"); + PSTR_ARRAY(separatorLine, "\n================================================================\r\n"); + m_puts(instructions); + m_puts(separatorLine); + for(uint32_t addr = start; addr < end; addr += 0x10) { + uint32_t* values = (uint32_t*)addr; + // rough indicator: stack frames usually have SP saved as the second word + bool looksLikeStackFrame = (values[2] == addr + 0x10); + + m_printf(_F("%08x: %08x %08x %08x %08x %c\r\n"), addr, values[0], values[1], values[2], values[3], + (looksLikeStackFrame) ? '<' : ' '); + + system_soft_wdt_feed(); + wdt_feed(); + } + m_puts(separatorLine); + m_puts(instructions); +} + +void debug_crash_callback(const rst_info* rst_info, uint32_t stack, uint32_t stack_end) +{ +#ifdef ENABLE_GDB + gdbFlushUserData(); + if(gdb_state.attached) { + m_setPuts(gdbWriteConsole); + } +#endif + +#if defined(ENABLE_GDB) || ENABLE_CRASH_DUMP + switch(rst_info->reason) { + case REASON_EXCEPTION_RST: + m_printf(_F("\r\n" + "\n" + "***** Exception Reset (%u):\r\n" + "epc1=0x%08x epc2=0x%08x epc3=0x%08x excvaddr=0x%08x depc=0x%08x\r\n"), + rst_info->exccause, rst_info->epc1, rst_info->epc2, rst_info->epc3, rst_info->excvaddr, + rst_info->depc); + break; + case REASON_SOFT_WDT_RST: + m_puts(_F("\r\n" + "\n" + "***** Software Watchdog Reset\r\n")); + break; + default: + // + ; + } + +#if defined(ENABLE_GDB) && GDBSTUB_BREAK_ON_RESTART + // Drop interrupt level to enable break instruction + asm("rsil a2, 1"); // XCHAL_DEBUGLEVEL - 1 + gdbstub_break_internal(DBGFLAG_RESTART); +#elif ENABLE_CRASH_DUMP + debug_print_stack(stack, stack_end); +#endif + +#endif // defined(ENABLE_GDB) || ENABLE_CRASH_DUMP +} + +#ifdef HOOK_SYSTEM_EXCEPTIONS + +void dumpExceptionInfo() +{ + auto& reg = gdbstub_savedRegs; + + m_printf(_F("\r\n" + "\n" + "***** Fatal exception %u"), + reg.cause); + if(reg.cause <= EXCCAUSE_MAX) { + m_printf(_F(" (%s)"), exceptionNames[reg.cause]); + } + m_puts("\r\n"); + + // EXCVADDR isn't set for all exceptions, so zero it out rather than show potentially misleading information + if(reg.cause < EXCCAUSE_UNALIGNED && reg.cause != EXCCAUSE_IFETCHERROR && reg.cause != EXCCAUSE_LOAD_STORE_ERROR) { + reg.excvaddr = 0; + } + + m_printf(_F("pc=0x%08x sp=0x%08x excvaddr=0x%08x\r\n"), reg.pc, reg.a[1], reg.excvaddr); + m_printf(_F("ps=0x%08x sar=0x%08x vpri=0x%08x\r\n"), reg.ps, reg.sar, reg.vpri); + for(int i = 0; i < 16; i++) { + uint32_t r = reg.a[i]; + m_printf(_F("r%02u: 0x%08x=%10d "), i, r, r); + if(i % 3 == 2) { + m_puts("\r\n"); + } + } + m_puts("\r\n"); + // Stack dump can be quite large, and not helpful to dump it to GDB console + if(gdb_present() != eGDB_Attached) { + debug_print_stack(reg.a[1], 0x3fffffb0); + } +} + +// Main exception handler code +static void __attribute__((noinline)) gdbstub_exception_handler_flash(UserFrame* frame) +{ + // Copy registers the Xtensa HAL did save to gdbstub_savedRegs + memcpy(&gdbstub_savedRegs, frame, 5 * 4); + memcpy(&gdbstub_savedRegs.a[2], &frame->a2, 14 * 4); + // Credits go to Cesanta for this trick. A1 seems to be destroyed, but because it + // has a fixed offset from the address of the passed frame, we can recover it. + const uint32_t EXCEPTION_GDB_SP_OFFSET = 0x100; + gdbstub_savedRegs.a[1] = uint32_t(frame) + EXCEPTION_GDB_SP_OFFSET; + +#if defined(ENABLE_GDB) && GDBSTUB_BREAK_ON_EXCEPTION + gdbFlushUserData(); + + // If GDB is attached, temporarily redirect m_printf calls to the console + nputs_callback_t oldPuts = nullptr; + if(gdb_state.attached) { + oldPuts = m_setPuts(gdbWriteConsole); + } + + dumpExceptionInfo(); + + if(gdb_state.attached) { + m_setPuts(oldPuts); + } + + gdbstub_handle_exception(); + + // Copy any changed registers back to the frame the Xtensa HAL uses. + memcpy(frame, &gdbstub_savedRegs, 5 * 4); + memcpy(&frame->a2, &gdbstub_savedRegs.a[2], 14 * 4); + +#else + + dumpExceptionInfo(); + +#if defined(ENABLE_GDB) + gdbFlushUserData(); +#endif + + // Wait for watchdog to reset system + while(true) + ; +#endif +} + +// Non-OS exception handler. Gets called by the Xtensa HAL. +static void IRAM_ATTR gdbstub_exception_handler(UserFrame* frame) +{ + // Save the extra registers the Xtensa HAL doesn't save + gdbstub_save_extra_sfrs_for_exception(); + Cache_Read_Enable_New(); + gdbstub_exception_handler_flash(frame); +} + +// The OS-less SDK uses the Xtensa HAL to handle exceptions. We can use those functions to catch any +// fatal exceptions and invoke the debugger when this happens. +static void ATTR_GDBINIT installExceptionHandler() +{ + for(unsigned ex = 0; ex <= EXCCAUSE_MAX; ++ex) { + unsigned signal = pgm_read_byte(&gdb_exception_signals[ex]); + if(signal != 0) { + _xtos_set_exception_handler(ex, gdbstub_exception_handler); + } + } +} + +#endif // HOOK_SYSTEM_EXCEPTIONS + +extern "C" { + +void ATTR_GDBINIT gdb_init(void) +{ + // Reset all serial ports to user-specified baud rate + for(unsigned i = 0; i < UART_PHYSICAL_COUNT; ++i) { + uart_set_baudrate_reg(i, SERIAL_BAUD_RATE); + } + +#ifdef HOOK_SYSTEM_EXCEPTIONS + installExceptionHandler(); +#endif + +#ifdef ENABLE_GDB + gdbstub_init(); +#endif +} + +static unsigned IRAM_ATTR __gdb_no_op(void) +{ + return 0; +} + +#define NOOP __attribute__((weak, alias("__gdb_no_op"))) + +void gdb_enable(bool state) NOOP; +GdbState gdb_present(void) NOOP; +void gdb_on_attach(bool attached) NOOP; +void gdb_detach(void) NOOP; +}; + +int __attribute__((weak)) gdb_syscall(const GdbSyscallInfo& info) +{ + return -1; +} diff --git a/Sming/Arch/Esp8266/Components/gdbstub/exceptions.h b/Sming/Arch/Esp8266/Components/gdbstub/exceptions.h index 3f7cddb684..115e635ea6 100644 --- a/Sming/Arch/Esp8266/Components/gdbstub/exceptions.h +++ b/Sming/Arch/Esp8266/Components/gdbstub/exceptions.h @@ -1,58 +1,58 @@ -/**** - * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. - * Created 2015 by Skurydin Alexey - * http://github.com/SmingHub/Sming - * All files of the Sming Core are provided under the LGPL v3 license. - * - * exceptions.h - * - * @author: 2019 - Mikee47 - * - ****/ - -#pragma once - -#include -#include "gdb/signals.h" - -/* - * Trapped exceptions and the corresponding GDB signal - * Ordered from 0 to last used exception - * - * EXCCAUSE_*, signal, desc - * - * Only those exceptions where `signal` is non-zero are trapped - */ -#define SYSTEM_EXCEPTION_MAP(XX) \ - XX(ILLEGAL, GDB_SIGNAL_ILL, "Illegal Instruction") \ - XX(SYSCALL, GDB_SIGNAL_USR2, "System Call") \ - XX(INSTR_ERROR, GDB_SIGNAL_SEGV, "Instruction Fetch Error") \ - XX(LOAD_STORE_ERROR, GDB_SIGNAL_SEGV, "Load Store Error") \ - XX(LEVEL1_INTERRUPT, 0, "Level 1 Interrupt") \ - XX(ALLOCA, 0, "MOVSP inst") \ - XX(DIVIDE_BY_ZERO, GDB_SIGNAL_FPE, "Integer Divide by Zero") \ - XX(SPECULATION, 0, "") \ - XX(PRIVILEGED, GDB_SIGNAL_ABRT, "Privileged Instruction") \ - XX(UNALIGNED, GDB_SIGNAL_EMT, "Unaligned Load/Store") \ - XX(RSVD_10, 0, "") \ - XX(RSVD_11, 0, "") \ - XX(INSTR_DATA_ERROR, GDB_SIGNAL_EMT, "PIF Data Error on Instruction Fetch") \ - XX(LOAD_STORE_DATA_ERROR, GDB_SIGNAL_EMT, "PIF Data Error on Load/Store") \ - XX(INSTR_ADDR_ERROR, GDB_SIGNAL_EMT, "PIF Address Error on Instruction Fetch") \ - XX(LOAD_STORE_ADDR_ERROR, GDB_SIGNAL_EMT, "PIF Address Error on Load/Store") \ - XX(ITLB_MISS, 0, "ITLB Miss") \ - XX(ITLB_MULTIHIT, 0, "ITLB Multihit") \ - XX(INSTR_RING, 0, "Ring Privilege Violation on Instruction Fetch") \ - XX(RSVD_19, 0, "") \ - XX(INSTR_PROHIBITED, GDB_SIGNAL_SEGV, "Cache Attribute does not allow Instruction Fetch") \ - XX(RSVD_21, 0, "") \ - XX(RSVD_22, 0, "") \ - XX(RSVD_23, 0, "") \ - XX(DTLB_MISS, 0, "DTLB Miss") \ - XX(DTLB_MULTIHIT, 0, "TBLD Multihit") \ - XX(LOAD_STORE_RING, 0, "Ring Privilege Violation on Load/Store") \ - XX(RSVD_27, 0, "") \ - XX(LOAD_PROHIBITED, GDB_SIGNAL_SEGV, "Cache Attribute does not allow Load") \ - XX(STORE_PROHIBITED, GDB_SIGNAL_SEGV, "Cache Attribute does not allow Store") - -#define EXCCAUSE_MAX EXCCAUSE_STORE_PROHIBITED +/**** + * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. + * Created 2015 by Skurydin Alexey + * http://github.com/SmingHub/Sming + * All files of the Sming Core are provided under the LGPL v3 license. + * + * exceptions.h + * + * @author: 2019 - Mikee47 + * + ****/ + +#pragma once + +#include +#include "gdb/signals.h" + +/* + * Trapped exceptions and the corresponding GDB signal + * Ordered from 0 to last used exception + * + * EXCCAUSE_*, signal, desc + * + * Only those exceptions where `signal` is non-zero are trapped + */ +#define SYSTEM_EXCEPTION_MAP(XX) \ + XX(ILLEGAL, GDB_SIGNAL_ILL, "Illegal Instruction") \ + XX(SYSCALL, GDB_SIGNAL_USR2, "System Call") \ + XX(INSTR_ERROR, GDB_SIGNAL_SEGV, "Instruction Fetch Error") \ + XX(LOAD_STORE_ERROR, GDB_SIGNAL_SEGV, "Load Store Error") \ + XX(LEVEL1_INTERRUPT, 0, "Level 1 Interrupt") \ + XX(ALLOCA, 0, "MOVSP inst") \ + XX(DIVIDE_BY_ZERO, GDB_SIGNAL_FPE, "Integer Divide by Zero") \ + XX(SPECULATION, 0, "") \ + XX(PRIVILEGED, GDB_SIGNAL_ABRT, "Privileged Instruction") \ + XX(UNALIGNED, GDB_SIGNAL_EMT, "Unaligned Load/Store") \ + XX(RSVD_10, 0, "") \ + XX(RSVD_11, 0, "") \ + XX(INSTR_DATA_ERROR, GDB_SIGNAL_EMT, "PIF Data Error on Instruction Fetch") \ + XX(LOAD_STORE_DATA_ERROR, GDB_SIGNAL_EMT, "PIF Data Error on Load/Store") \ + XX(INSTR_ADDR_ERROR, GDB_SIGNAL_EMT, "PIF Address Error on Instruction Fetch") \ + XX(LOAD_STORE_ADDR_ERROR, GDB_SIGNAL_EMT, "PIF Address Error on Load/Store") \ + XX(ITLB_MISS, 0, "ITLB Miss") \ + XX(ITLB_MULTIHIT, 0, "ITLB Multihit") \ + XX(INSTR_RING, 0, "Ring Privilege Violation on Instruction Fetch") \ + XX(RSVD_19, 0, "") \ + XX(INSTR_PROHIBITED, GDB_SIGNAL_SEGV, "Cache Attribute does not allow Instruction Fetch") \ + XX(RSVD_21, 0, "") \ + XX(RSVD_22, 0, "") \ + XX(RSVD_23, 0, "") \ + XX(DTLB_MISS, 0, "DTLB Miss") \ + XX(DTLB_MULTIHIT, 0, "TBLD Multihit") \ + XX(LOAD_STORE_RING, 0, "Ring Privilege Violation on Load/Store") \ + XX(RSVD_27, 0, "") \ + XX(LOAD_PROHIBITED, GDB_SIGNAL_SEGV, "Cache Attribute does not allow Load") \ + XX(STORE_PROHIBITED, GDB_SIGNAL_SEGV, "Cache Attribute does not allow Store") + +#define EXCCAUSE_MAX EXCCAUSE_STORE_PROHIBITED diff --git a/Sming/Arch/Esp8266/Components/gdbstub/gdb/registers.h b/Sming/Arch/Esp8266/Components/gdbstub/gdb/registers.h index b6e2bda2d6..00dc84e40e 100644 --- a/Sming/Arch/Esp8266/Components/gdbstub/gdb/registers.h +++ b/Sming/Arch/Esp8266/Components/gdbstub/gdb/registers.h @@ -1,176 +1,176 @@ -/**** - * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. - * Created 2015 by Skurydin Alexey - * http://github.com/SmingHub/Sming - * All files of the Sming Core are provided under the LGPL v3 license. - * - * @author: 2019 - Mikee47 - * - * GDB register definitions - * - ****/ - -#pragma once - -#include "gdbstub-cfg.h" -#include "signals.h" - -#if GDBSTUB_GDB_PATCHED == 1 -/* - * Patched GDB uses a small subset of registers - */ -#define GDB_REGCOUNT 22 -#define XT_REGISTER_MAP(XTREG) \ - XX(0, a0) \ - XX(1, a1) \ - XX(2, a2) \ - XX(3, a3) \ - XX(4, a4) \ - XX(5, a5) \ - XX(6, a6) \ - XX(7, a7) \ - XX(8, a8) \ - XX(9, a9) \ - XX(10, a10) \ - XX(11, a11) \ - XX(12, a12) \ - XX(13, a13) \ - XX(14, a14) \ - XX(15, a15) \ - XX(16, pc) \ - XX(17, sar) \ - XX(18, litbase) \ - XX(19, sr176) \ - XX(20, sr208) \ - XX(21, ps) - -#else -/* - * Unpatched GDB full register set - * Note that our stub doesn't return all of these, we send 'xxxxxxxx' for those - */ -#define GDB_REGCOUNT 113 -// This table is extracted from xtensa-config.c in GDB source code -#define XT_REGISTER_MAP(XX) \ - XX(0, pc) \ - XX(1, ar0) \ - XX(2, ar1) \ - XX(3, ar2) \ - XX(4, ar3) \ - XX(5, ar4) \ - XX(6, ar5) \ - XX(7, ar6) \ - XX(8, ar7) \ - XX(9, ar8) \ - XX(10, ar9) \ - XX(11, ar10) \ - XX(12, ar11) \ - XX(13, ar12) \ - XX(14, ar13) \ - XX(15, ar14) \ - XX(16, ar15) \ - XX(17, ar16) \ - XX(18, ar17) \ - XX(19, ar18) \ - XX(20, ar19) \ - XX(21, ar20) \ - XX(22, ar21) \ - XX(23, ar22) \ - XX(24, ar23) \ - XX(25, ar24) \ - XX(26, ar25) \ - XX(27, ar26) \ - XX(28, ar27) \ - XX(29, ar28) \ - XX(30, ar29) \ - XX(31, ar30) \ - XX(32, ar31) \ - XX(33, lbeg) \ - XX(34, lend) \ - XX(35, lcount) \ - XX(36, sar) \ - XX(37, litbase) \ - XX(38, windowbase) \ - XX(39, windowstart) \ - XX(40, sr176) \ - XX(41, sr208) \ - XX(42, ps) \ - XX(43, threadptr) \ - XX(44, scompare1) \ - XX(45, ptevaddr) \ - XX(46, mmid) \ - XX(47, rasid) \ - XX(48, itlbcfg) \ - XX(49, dtlbcfg) \ - XX(50, ibreakenable) \ - XX(51, ddr) \ - XX(52, ibreaka0) \ - XX(53, ibreaka1) \ - XX(54, dbreaka0) \ - XX(55, dbreaka1) \ - XX(56, dbreakc0) \ - XX(57, dbreakc1) \ - XX(58, epc1) \ - XX(59, epc2) \ - XX(60, epc3) \ - XX(61, epc4) \ - XX(62, epc5) \ - XX(63, epc6) \ - XX(64, epc7) \ - XX(65, depc) \ - XX(66, eps2) \ - XX(67, eps3) \ - XX(68, eps4) \ - XX(69, eps5) \ - XX(70, eps6) \ - XX(71, eps7) \ - XX(72, excsave1) \ - XX(73, excsave2) \ - XX(74, excsave3) \ - XX(75, excsave4) \ - XX(76, excsave5) \ - XX(77, excsave6) \ - XX(78, excsave7) \ - XX(79, cpenable) \ - XX(80, interrupt) \ - XX(81, intset) \ - XX(82, intclear) \ - XX(83, intenable) \ - XX(84, vecbase) \ - XX(85, exccause) \ - XX(86, debugcause) \ - XX(87, ccount) \ - XX(88, prid) \ - XX(89, icount) \ - XX(90, icountlevel) \ - XX(91, excvaddr) \ - XX(92, ccompare0) \ - XX(93, ccompare1) \ - XX(94, ccompare2) \ - XX(95, misc0) \ - XX(96, misc1) \ - XX(97, a0) \ - XX(98, a1) \ - XX(99, a2) \ - XX(100, a3) \ - XX(101, a4) \ - XX(102, a5) \ - XX(103, a6) \ - XX(104, a7) \ - XX(105, a8) \ - XX(106, a9) \ - XX(107, a10) \ - XX(108, a11) \ - XX(109, a12) \ - XX(110, a13) \ - XX(111, a14) \ - XX(112, a15) - -#endif - -// Register numbers -enum GdbReg { -#define XX(idx, name) GdbReg_##name = idx, - XT_REGISTER_MAP(XX) -#undef XX -}; +/**** + * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. + * Created 2015 by Skurydin Alexey + * http://github.com/SmingHub/Sming + * All files of the Sming Core are provided under the LGPL v3 license. + * + * @author: 2019 - Mikee47 + * + * GDB register definitions + * + ****/ + +#pragma once + +#include "gdbstub-cfg.h" +#include "signals.h" + +#if GDBSTUB_GDB_PATCHED == 1 +/* + * Patched GDB uses a small subset of registers + */ +#define GDB_REGCOUNT 22 +#define XT_REGISTER_MAP(XTREG) \ + XX(0, a0) \ + XX(1, a1) \ + XX(2, a2) \ + XX(3, a3) \ + XX(4, a4) \ + XX(5, a5) \ + XX(6, a6) \ + XX(7, a7) \ + XX(8, a8) \ + XX(9, a9) \ + XX(10, a10) \ + XX(11, a11) \ + XX(12, a12) \ + XX(13, a13) \ + XX(14, a14) \ + XX(15, a15) \ + XX(16, pc) \ + XX(17, sar) \ + XX(18, litbase) \ + XX(19, sr176) \ + XX(20, sr208) \ + XX(21, ps) + +#else +/* + * Unpatched GDB full register set + * Note that our stub doesn't return all of these, we send 'xxxxxxxx' for those + */ +#define GDB_REGCOUNT 113 +// This table is extracted from xtensa-config.c in GDB source code +#define XT_REGISTER_MAP(XX) \ + XX(0, pc) \ + XX(1, ar0) \ + XX(2, ar1) \ + XX(3, ar2) \ + XX(4, ar3) \ + XX(5, ar4) \ + XX(6, ar5) \ + XX(7, ar6) \ + XX(8, ar7) \ + XX(9, ar8) \ + XX(10, ar9) \ + XX(11, ar10) \ + XX(12, ar11) \ + XX(13, ar12) \ + XX(14, ar13) \ + XX(15, ar14) \ + XX(16, ar15) \ + XX(17, ar16) \ + XX(18, ar17) \ + XX(19, ar18) \ + XX(20, ar19) \ + XX(21, ar20) \ + XX(22, ar21) \ + XX(23, ar22) \ + XX(24, ar23) \ + XX(25, ar24) \ + XX(26, ar25) \ + XX(27, ar26) \ + XX(28, ar27) \ + XX(29, ar28) \ + XX(30, ar29) \ + XX(31, ar30) \ + XX(32, ar31) \ + XX(33, lbeg) \ + XX(34, lend) \ + XX(35, lcount) \ + XX(36, sar) \ + XX(37, litbase) \ + XX(38, windowbase) \ + XX(39, windowstart) \ + XX(40, sr176) \ + XX(41, sr208) \ + XX(42, ps) \ + XX(43, threadptr) \ + XX(44, scompare1) \ + XX(45, ptevaddr) \ + XX(46, mmid) \ + XX(47, rasid) \ + XX(48, itlbcfg) \ + XX(49, dtlbcfg) \ + XX(50, ibreakenable) \ + XX(51, ddr) \ + XX(52, ibreaka0) \ + XX(53, ibreaka1) \ + XX(54, dbreaka0) \ + XX(55, dbreaka1) \ + XX(56, dbreakc0) \ + XX(57, dbreakc1) \ + XX(58, epc1) \ + XX(59, epc2) \ + XX(60, epc3) \ + XX(61, epc4) \ + XX(62, epc5) \ + XX(63, epc6) \ + XX(64, epc7) \ + XX(65, depc) \ + XX(66, eps2) \ + XX(67, eps3) \ + XX(68, eps4) \ + XX(69, eps5) \ + XX(70, eps6) \ + XX(71, eps7) \ + XX(72, excsave1) \ + XX(73, excsave2) \ + XX(74, excsave3) \ + XX(75, excsave4) \ + XX(76, excsave5) \ + XX(77, excsave6) \ + XX(78, excsave7) \ + XX(79, cpenable) \ + XX(80, interrupt) \ + XX(81, intset) \ + XX(82, intclear) \ + XX(83, intenable) \ + XX(84, vecbase) \ + XX(85, exccause) \ + XX(86, debugcause) \ + XX(87, ccount) \ + XX(88, prid) \ + XX(89, icount) \ + XX(90, icountlevel) \ + XX(91, excvaddr) \ + XX(92, ccompare0) \ + XX(93, ccompare1) \ + XX(94, ccompare2) \ + XX(95, misc0) \ + XX(96, misc1) \ + XX(97, a0) \ + XX(98, a1) \ + XX(99, a2) \ + XX(100, a3) \ + XX(101, a4) \ + XX(102, a5) \ + XX(103, a6) \ + XX(104, a7) \ + XX(105, a8) \ + XX(106, a9) \ + XX(107, a10) \ + XX(108, a11) \ + XX(109, a12) \ + XX(110, a13) \ + XX(111, a14) \ + XX(112, a15) + +#endif + +// Register numbers +enum GdbReg { +#define XX(idx, name) GdbReg_##name = idx, + XT_REGISTER_MAP(XX) +#undef XX +}; diff --git a/Sming/Arch/Esp8266/Components/gdbstub/gdbhostio.cpp b/Sming/Arch/Esp8266/Components/gdbstub/gdbhostio.cpp index c73631b84b..e50fe8d150 100644 --- a/Sming/Arch/Esp8266/Components/gdbstub/gdbhostio.cpp +++ b/Sming/Arch/Esp8266/Components/gdbstub/gdbhostio.cpp @@ -1,174 +1,174 @@ -/**** - * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. - * Created 2015 by Skurydin Alexey - * http://github.com/SmingHub/Sming - * All files of the Sming Core are provided under the LGPL v3 license. - * - * gdbhostio.h - * - * @author: 2019 - Mikee47 - * - * Deals with Host I/O commands from GDB - * - ****/ - -#include "gdbstub-cfg.h" - -#if GDBSTUB_ENABLE_HOSTIO - -#include "GdbPacket.h" -#include -#include -#include "FileSystem.h" -#include "WString.h" - -void ATTR_GDBEXTERNFN gdbHandleHostIo(char* commandBuffer, unsigned cmdLen) -{ - const char* data = &commandBuffer[1]; - - auto match = [&](const char* tag) -> bool { - auto len = strlen(tag); - if(data[len] == ':' && memcmp(data, tag, len) == 0) { - data += len + 1; - return true; - } else { - return false; - } - }; - - // Start a packet for the result - GdbPacket packet; - - /* - * Host I/O - * - * `vFile:operation:parameter...` - */ - if(!match(GDB_F("File"))) { - return; // empty packet response - } - - /* - * open: filename, flags, mode - */ - if(match(GDB_F("open"))) { - char* filename = commandBuffer; - size_t len = GdbPacket::decodeHexBlock(filename, data); - filename[len] = '\0'; - ++data; // skip , - unsigned flags = GdbPacket::readHexValue(data); - ++data; // Skip , - unsigned mode = GdbPacket::readHexValue(data); - - FileOpenFlags openFlags; - if((flags & 0xff) == O_RDWR) { - openFlags = eFO_ReadWrite; - } else if((flags & 0xff) == O_WRONLY) { - openFlags = eFO_WriteOnly; - } else { - openFlags = eFO_ReadOnly; - } - if(flags & O_CREAT) { - openFlags = openFlags | eFO_CreateIfNotExist; - } - if(flags & O_TRUNC) { - openFlags = openFlags | eFO_Truncate; - } - int fd = fileOpen(filename, openFlags); - - debug_i("File:open('%s', 0x%04x, 0x%04x), %d", filename, flags, mode, fd); - - packet.writeChar('F'); - if(fd < 0) { - packet.writeStr(_F("-1,")); - packet.writeHexByte(ENOENT); - } else { - packet.writeHexByte(fd); - } - return; - } - - /* - * close: fd, count, offset - */ - if(match(GDB_F("close"))) { - int fd = GdbPacket::readHexValue(data); - debug_i("File:close(%d)", fd); - fileClose(fd); - - packet.writeChar('F'); - packet.writeChar('0'); - return; - } - - /* - * pread: fd, count, offset - */ - if(match(GDB_F("pread"))) { - int fd = GdbPacket::readHexValue(data); - ++data; // Skip , - unsigned count = GdbPacket::readHexValue(data); - ++data; // Skip , - unsigned offset = GdbPacket::readHexValue(data); - debug_i("File:pread(%d, %u, %u)", fd, count, offset); - - packet.writeChar('F'); - if(fileSeek(fd, offset, eSO_FileStart) == int(offset)) { - count = fileRead(fd, commandBuffer, count); - if(int(count) >= 0) { - packet.writeHexWord16(count); - packet.writeChar(';'); - packet.writeEscaped(commandBuffer, count); - return; - } - } - packet.writeStr(_F("-1,")); - packet.writeHexByte(EIO); - return; - } - - /* - * pwrite: fd, offset, data - */ - if(match(GDB_F("pwrite"))) { - int fd = GdbPacket::readHexValue(data); - ++data; // Skip , - unsigned offset = GdbPacket::readHexValue(data); - ++data; // Skip , - unsigned size = cmdLen - (data - commandBuffer); - debug_i("File:pwrite(%d, %u, %u)", fd, offset, size); - - packet.writeChar('F'); - if(fileSeek(fd, offset, eSO_FileStart) == int(offset)) { - int count = fileWrite(fd, data, size); - if(count >= 0) { - packet.writeHexWord16(count); - return; - } - } - packet.writeStr(_F("-1,")); - packet.writeHexByte(EIO); - } - - /* - * unlink: filename - */ - if(match(GDB_F("unlink"))) { - char* filename = commandBuffer; - size_t len = GdbPacket::decodeHexBlock(filename, data); - filename[len] = '\0'; - int res = fileDelete(filename); - debug_i("File:delete('%s'), %d", filename, res); - - packet.writeChar('F'); - if(res < 0) { - packet.writeStr(_F("-1,")); - packet.writeHexByte(ENOENT); - } else { - packet.writeHexByte(0); - } - return; - } -} - -#endif // GDBSTUB_ENABLE_HOSTIO +/**** + * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. + * Created 2015 by Skurydin Alexey + * http://github.com/SmingHub/Sming + * All files of the Sming Core are provided under the LGPL v3 license. + * + * gdbhostio.h + * + * @author: 2019 - Mikee47 + * + * Deals with Host I/O commands from GDB + * + ****/ + +#include "gdbstub-cfg.h" + +#if GDBSTUB_ENABLE_HOSTIO + +#include "GdbPacket.h" +#include +#include +#include "FileSystem.h" +#include "WString.h" + +void ATTR_GDBEXTERNFN gdbHandleHostIo(char* commandBuffer, unsigned cmdLen) +{ + const char* data = &commandBuffer[1]; + + auto match = [&](const char* tag) -> bool { + auto len = strlen(tag); + if(data[len] == ':' && memcmp(data, tag, len) == 0) { + data += len + 1; + return true; + } else { + return false; + } + }; + + // Start a packet for the result + GdbPacket packet; + + /* + * Host I/O + * + * `vFile:operation:parameter...` + */ + if(!match(GDB_F("File"))) { + return; // empty packet response + } + + /* + * open: filename, flags, mode + */ + if(match(GDB_F("open"))) { + char* filename = commandBuffer; + size_t len = GdbPacket::decodeHexBlock(filename, data); + filename[len] = '\0'; + ++data; // skip , + unsigned flags = GdbPacket::readHexValue(data); + ++data; // Skip , + unsigned mode = GdbPacket::readHexValue(data); + + FileOpenFlags openFlags; + if((flags & 0xff) == O_RDWR) { + openFlags = eFO_ReadWrite; + } else if((flags & 0xff) == O_WRONLY) { + openFlags = eFO_WriteOnly; + } else { + openFlags = eFO_ReadOnly; + } + if(flags & O_CREAT) { + openFlags = openFlags | eFO_CreateIfNotExist; + } + if(flags & O_TRUNC) { + openFlags = openFlags | eFO_Truncate; + } + int fd = fileOpen(filename, openFlags); + + debug_i("File:open('%s', 0x%04x, 0x%04x), %d", filename, flags, mode, fd); + + packet.writeChar('F'); + if(fd < 0) { + packet.writeStr(_F("-1,")); + packet.writeHexByte(ENOENT); + } else { + packet.writeHexByte(fd); + } + return; + } + + /* + * close: fd, count, offset + */ + if(match(GDB_F("close"))) { + int fd = GdbPacket::readHexValue(data); + debug_i("File:close(%d)", fd); + fileClose(fd); + + packet.writeChar('F'); + packet.writeChar('0'); + return; + } + + /* + * pread: fd, count, offset + */ + if(match(GDB_F("pread"))) { + int fd = GdbPacket::readHexValue(data); + ++data; // Skip , + unsigned count = GdbPacket::readHexValue(data); + ++data; // Skip , + unsigned offset = GdbPacket::readHexValue(data); + debug_i("File:pread(%d, %u, %u)", fd, count, offset); + + packet.writeChar('F'); + if(fileSeek(fd, offset, eSO_FileStart) == int(offset)) { + count = fileRead(fd, commandBuffer, count); + if(int(count) >= 0) { + packet.writeHexWord16(count); + packet.writeChar(';'); + packet.writeEscaped(commandBuffer, count); + return; + } + } + packet.writeStr(_F("-1,")); + packet.writeHexByte(EIO); + return; + } + + /* + * pwrite: fd, offset, data + */ + if(match(GDB_F("pwrite"))) { + int fd = GdbPacket::readHexValue(data); + ++data; // Skip , + unsigned offset = GdbPacket::readHexValue(data); + ++data; // Skip , + unsigned size = cmdLen - (data - commandBuffer); + debug_i("File:pwrite(%d, %u, %u)", fd, offset, size); + + packet.writeChar('F'); + if(fileSeek(fd, offset, eSO_FileStart) == int(offset)) { + int count = fileWrite(fd, data, size); + if(count >= 0) { + packet.writeHexWord16(count); + return; + } + } + packet.writeStr(_F("-1,")); + packet.writeHexByte(EIO); + } + + /* + * unlink: filename + */ + if(match(GDB_F("unlink"))) { + char* filename = commandBuffer; + size_t len = GdbPacket::decodeHexBlock(filename, data); + filename[len] = '\0'; + int res = fileDelete(filename); + debug_i("File:delete('%s'), %d", filename, res); + + packet.writeChar('F'); + if(res < 0) { + packet.writeStr(_F("-1,")); + packet.writeHexByte(ENOENT); + } else { + packet.writeHexByte(0); + } + return; + } +} + +#endif // GDBSTUB_ENABLE_HOSTIO diff --git a/Sming/Arch/Esp8266/Components/gdbstub/gdbhostio.h b/Sming/Arch/Esp8266/Components/gdbstub/gdbhostio.h index 34221f46e5..cb7072dfcc 100644 --- a/Sming/Arch/Esp8266/Components/gdbstub/gdbhostio.h +++ b/Sming/Arch/Esp8266/Components/gdbstub/gdbhostio.h @@ -1,15 +1,15 @@ -/**** - * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. - * Created 2015 by Skurydin Alexey - * http://github.com/SmingHub/Sming - * All files of the Sming Core are provided under the LGPL v3 license. - * - * gdbhostio.h - * - * @author: 2019 - Mikee47 - * - ****/ - -#pragma once - -void gdbHandleHostIo(char* commandBuffer, unsigned cmdLen); +/**** + * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. + * Created 2015 by Skurydin Alexey + * http://github.com/SmingHub/Sming + * All files of the Sming Core are provided under the LGPL v3 license. + * + * gdbhostio.h + * + * @author: 2019 - Mikee47 + * + ****/ + +#pragma once + +void gdbHandleHostIo(char* commandBuffer, unsigned cmdLen); diff --git a/Sming/Arch/Esp8266/Components/gdbstub/gdbstub-entry.h b/Sming/Arch/Esp8266/Components/gdbstub/gdbstub-entry.h index b99395045b..e562fe406b 100644 --- a/Sming/Arch/Esp8266/Components/gdbstub/gdbstub-entry.h +++ b/Sming/Arch/Esp8266/Components/gdbstub/gdbstub-entry.h @@ -1,28 +1,28 @@ -/****************************************************************************** - * Copyright 2015 Espressif Systems - * - * Description: Assembly routines for the gdbstub - * - * License: ESPRESSIF MIT License - *******************************************************************************/ - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -void gdbstub_init_debug_entry(); -void gdbstub_icount_ena_single_step(); -void gdbstub_save_extra_sfrs_for_exception(); - -int gdbstub_set_hw_breakpoint(int addr, int len); -int gdbstub_set_hw_watchpoint(int addr, int len, int type); -int gdbstub_del_hw_breakpoint(int addr); -int gdbstub_del_hw_watchpoint(int addr); - -extern void* gdbstub_do_break_breakpoint_addr; - -#ifdef __cplusplus -} -#endif +/****************************************************************************** + * Copyright 2015 Espressif Systems + * + * Description: Assembly routines for the gdbstub + * + * License: ESPRESSIF MIT License + *******************************************************************************/ + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +void gdbstub_init_debug_entry(); +void gdbstub_icount_ena_single_step(); +void gdbstub_save_extra_sfrs_for_exception(); + +int gdbstub_set_hw_breakpoint(int addr, int len); +int gdbstub_set_hw_watchpoint(int addr, int len, int type); +int gdbstub_del_hw_breakpoint(int addr); +int gdbstub_del_hw_watchpoint(int addr); + +extern void* gdbstub_do_break_breakpoint_addr; + +#ifdef __cplusplus +} +#endif diff --git a/Sming/Arch/Esp8266/Components/gdbstub/gdbstub-internal.h b/Sming/Arch/Esp8266/Components/gdbstub/gdbstub-internal.h index 3c3830304f..6b6de377a4 100644 --- a/Sming/Arch/Esp8266/Components/gdbstub/gdbstub-internal.h +++ b/Sming/Arch/Esp8266/Components/gdbstub/gdbstub-internal.h @@ -1,75 +1,75 @@ -/**** - * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. - * Created 2015 by Skurydin Alexey - * http://github.com/SmingHub/Sming - * All files of the Sming Core are provided under the LGPL v3 license. - * - * @author: 2019 - Mikee47 - * - * Standard definitions for gdbstub code modules, both C++ and assembler (.S only). - * - ****/ - -#pragma once - -#include "xtensa/xtruntime-frames.h" -#include "gdbstub-cfg.h" - -#define UINT32_T unsigned int - -/* - * Defines our debugging exception frame which is provided to GDB when paused. - * Our exception handlers save register values here, restoring them on continuation. - * Any register changes made by GDB are stored here. - * - * System exceptions are initially handled by the Xtensa HAL, which saves some (but not all) - * registers into a `UserFrame` structure (see xtensa/xtruntime-frames.h). - * Control passes to gdbstub_exception_handler, which copies those values plus some extra ones. - * - * Debug exceptions are handled entirely by gdbstub_debug_exception_entry, which saves - * registers, calls gdbstub_handle_debug_exception, then restores them. - * - * Using the macros provided by xtensa allow changes to this structure to be reflected into - * both C and assembler code. - */ -STRUCT_BEGIN -STRUCT_FIELD(UINT32_T, 4, GDBSR_, pc) -STRUCT_FIELD(UINT32_T, 4, GDBSR_, ps) -STRUCT_FIELD(UINT32_T, 4, GDBSR_, sar) -STRUCT_FIELD(UINT32_T, 4, GDBSR_, vpri) -STRUCT_AFIELD(UINT32_T, 4, GDBSR_, a, 16) // a0..a15 -#define GDBSR_A(n) GDBSR_a + ((n)*4) -// These are added manually by the exception code; the HAL doesn't set these on an exception. -STRUCT_FIELD(UINT32_T, 4, GDBSR_, litbase) -STRUCT_FIELD(UINT32_T, 4, GDBSR_, sr176) -STRUCT_FIELD(UINT32_T, 4, GDBSR_, sr208) -STRUCT_FIELD(UINT32_T, 4, GDBSR_, cause) ///< Either EXCCAUSE or DBGCAUSE, depending on exception type -STRUCT_FIELD(UINT32_T, 4, GDBSR_, excvaddr) ///< Exception Virtual Address -STRUCT_END(GdbstubSavedRegisters) - -#undef UINT32_T - -// Don't include debug output for this module unless excplitly requested -#if GDBSTUB_ENABLE_DEBUG == 0 -#undef DEBUG_BUILD -#define DEBUG_BUILD 0 -#endif - -#if(defined(ENABLE_GDB) && GDBSTUB_BREAK_ON_EXCEPTION) || ENABLE_EXCEPTION_DUMP -#define HOOK_SYSTEM_EXCEPTIONS -#endif - -/* - * Code memory allocation attributes - */ -#define ATTR_GDBINIT ICACHE_FLASH_ATTR - -#if GDBSTUB_FORCE_IRAM -#define ATTR_GDBEXTERNFN IRAM_ATTR -#else -#define ATTR_GDBEXTERNFN ICACHE_FLASH_ATTR -#endif - -// Section definitions for assembler -#define ASATTR_GDBINIT .section .irom0.text -#define ASATTR_GDBFN .section .iram.text +/**** + * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. + * Created 2015 by Skurydin Alexey + * http://github.com/SmingHub/Sming + * All files of the Sming Core are provided under the LGPL v3 license. + * + * @author: 2019 - Mikee47 + * + * Standard definitions for gdbstub code modules, both C++ and assembler (.S only). + * + ****/ + +#pragma once + +#include "xtensa/xtruntime-frames.h" +#include "gdbstub-cfg.h" + +#define UINT32_T unsigned int + +/* + * Defines our debugging exception frame which is provided to GDB when paused. + * Our exception handlers save register values here, restoring them on continuation. + * Any register changes made by GDB are stored here. + * + * System exceptions are initially handled by the Xtensa HAL, which saves some (but not all) + * registers into a `UserFrame` structure (see xtensa/xtruntime-frames.h). + * Control passes to gdbstub_exception_handler, which copies those values plus some extra ones. + * + * Debug exceptions are handled entirely by gdbstub_debug_exception_entry, which saves + * registers, calls gdbstub_handle_debug_exception, then restores them. + * + * Using the macros provided by xtensa allow changes to this structure to be reflected into + * both C and assembler code. + */ +STRUCT_BEGIN +STRUCT_FIELD(UINT32_T, 4, GDBSR_, pc) +STRUCT_FIELD(UINT32_T, 4, GDBSR_, ps) +STRUCT_FIELD(UINT32_T, 4, GDBSR_, sar) +STRUCT_FIELD(UINT32_T, 4, GDBSR_, vpri) +STRUCT_AFIELD(UINT32_T, 4, GDBSR_, a, 16) // a0..a15 +#define GDBSR_A(n) GDBSR_a + ((n)*4) +// These are added manually by the exception code; the HAL doesn't set these on an exception. +STRUCT_FIELD(UINT32_T, 4, GDBSR_, litbase) +STRUCT_FIELD(UINT32_T, 4, GDBSR_, sr176) +STRUCT_FIELD(UINT32_T, 4, GDBSR_, sr208) +STRUCT_FIELD(UINT32_T, 4, GDBSR_, cause) ///< Either EXCCAUSE or DBGCAUSE, depending on exception type +STRUCT_FIELD(UINT32_T, 4, GDBSR_, excvaddr) ///< Exception Virtual Address +STRUCT_END(GdbstubSavedRegisters) + +#undef UINT32_T + +// Don't include debug output for this module unless excplitly requested +#if GDBSTUB_ENABLE_DEBUG == 0 +#undef DEBUG_BUILD +#define DEBUG_BUILD 0 +#endif + +#if(defined(ENABLE_GDB) && GDBSTUB_BREAK_ON_EXCEPTION) || ENABLE_EXCEPTION_DUMP +#define HOOK_SYSTEM_EXCEPTIONS +#endif + +/* + * Code memory allocation attributes + */ +#define ATTR_GDBINIT ICACHE_FLASH_ATTR + +#if GDBSTUB_FORCE_IRAM +#define ATTR_GDBEXTERNFN IRAM_ATTR +#else +#define ATTR_GDBEXTERNFN ICACHE_FLASH_ATTR +#endif + +// Section definitions for assembler +#define ASATTR_GDBINIT .section .irom0.text +#define ASATTR_GDBFN .section .iram.text diff --git a/Sming/Arch/Esp8266/Components/gdbstub/gdbstub.h b/Sming/Arch/Esp8266/Components/gdbstub/gdbstub.h index 04791ed2e9..7c5fcb9bfc 100644 --- a/Sming/Arch/Esp8266/Components/gdbstub/gdbstub.h +++ b/Sming/Arch/Esp8266/Components/gdbstub/gdbstub.h @@ -1,66 +1,66 @@ -/**** - * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. - * Created 2015 by Skurydin Alexey - * http://github.com/SmingHub/Sming - * All files of the Sming Core are provided under the LGPL v3 license. - * - * gdbstub.h - * - * @author: 2019 - Mikee47 - * - ****/ - -#pragma once - -#include "gdbstub-internal.h" -#include -#include "BitManipulations.h" - -// GDB_xx macro versions required to ensure no flash access if requested -#if GDBSTUB_FORCE_IRAM -#define GDB_F(str) str -#define GDB_PROGMEM -#else -#define GDB_F(str) _F(str) -#define GDB_PROGMEM PROGMEM -#endif - -#define gdbstub_break_internal(flag) \ - { \ - bitSet(gdb_state.flags, flag); \ - gdb_do_break(); \ - } - -// Additional debugging flags mainly used to qualify reason for a debugging break -enum GdbDebugFlag { - DBGFLAG_DEBUG_EXCEPTION, ///< For debug exceptions, cause is DBGCAUSE (see DebugCause bits) - DBGFLAG_SYSTEM_EXCEPTION, ///< For system exceptions, cause is EXCCAUSE (see EXCCAUSE_* values) - DBGFLAG_CTRL_BREAK, ///< Break caused by call to gdbstub_ctrl_break() - DBGFLAG_PACKET_STARTED, ///< Incoming packet detected by uart interrupt handler - DBGFLAG_RESTART, ///< Breaking into debugger because of unexpected system restart -}; - -enum SyscallState { - syscall_ready, ///< Ready for new syscall - syscall_pending, ///< Syscall queued but not yet sent to GDB - syscall_active, ///< Syscall executing, awaiting response from GDB -}; - -// State information in shared global structure -struct gdb_state_t { - bool attached; ///< true if GDB is attached to stub - bool enabled; ///< Debugging may be disabled via gdb_enable() - SyscallState syscall; ///< State of system call - uint8_t flags; ///< Combination of GdbDebugFlag -}; - -extern volatile gdb_state_t gdb_state; -extern const uint8_t gdb_exception_signals[]; - -void gdbstub_init(); -void gdbstub_handle_exception(); - -#if GDBSTUB_ENABLE_DEBUG == 0 -// Optimise GDB stub code for size, regardless of application settings -#pragma GCC optimize("Os") -#endif +/**** + * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. + * Created 2015 by Skurydin Alexey + * http://github.com/SmingHub/Sming + * All files of the Sming Core are provided under the LGPL v3 license. + * + * gdbstub.h + * + * @author: 2019 - Mikee47 + * + ****/ + +#pragma once + +#include "gdbstub-internal.h" +#include +#include "BitManipulations.h" + +// GDB_xx macro versions required to ensure no flash access if requested +#if GDBSTUB_FORCE_IRAM +#define GDB_F(str) str +#define GDB_PROGMEM +#else +#define GDB_F(str) _F(str) +#define GDB_PROGMEM PROGMEM +#endif + +#define gdbstub_break_internal(flag) \ + { \ + bitSet(gdb_state.flags, flag); \ + gdb_do_break(); \ + } + +// Additional debugging flags mainly used to qualify reason for a debugging break +enum GdbDebugFlag { + DBGFLAG_DEBUG_EXCEPTION, ///< For debug exceptions, cause is DBGCAUSE (see DebugCause bits) + DBGFLAG_SYSTEM_EXCEPTION, ///< For system exceptions, cause is EXCCAUSE (see EXCCAUSE_* values) + DBGFLAG_CTRL_BREAK, ///< Break caused by call to gdbstub_ctrl_break() + DBGFLAG_PACKET_STARTED, ///< Incoming packet detected by uart interrupt handler + DBGFLAG_RESTART, ///< Breaking into debugger because of unexpected system restart +}; + +enum SyscallState { + syscall_ready, ///< Ready for new syscall + syscall_pending, ///< Syscall queued but not yet sent to GDB + syscall_active, ///< Syscall executing, awaiting response from GDB +}; + +// State information in shared global structure +struct gdb_state_t { + bool attached; ///< true if GDB is attached to stub + bool enabled; ///< Debugging may be disabled via gdb_enable() + SyscallState syscall; ///< State of system call + uint8_t flags; ///< Combination of GdbDebugFlag +}; + +extern volatile gdb_state_t gdb_state; +extern const uint8_t gdb_exception_signals[]; + +void gdbstub_init(); +void gdbstub_handle_exception(); + +#if GDBSTUB_ENABLE_DEBUG == 0 +// Optimise GDB stub code for size, regardless of application settings +#pragma GCC optimize("Os") +#endif diff --git a/Sming/Arch/Esp8266/Components/gdbstub/gdbsyscall.cpp b/Sming/Arch/Esp8266/Components/gdbstub/gdbsyscall.cpp index 84a145d84a..c8deff9ba9 100644 --- a/Sming/Arch/Esp8266/Components/gdbstub/gdbsyscall.cpp +++ b/Sming/Arch/Esp8266/Components/gdbstub/gdbsyscall.cpp @@ -1,263 +1,263 @@ -/**** - * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. - * Created 2015 by Skurydin Alexey - * http://github.com/SmingHub/Sming - * All files of the Sming Core are provided under the LGPL v3 license. - * - * gdbsyscall.cpp - Support for GDB file I/O - * - * @author: 2019 - Mikee47 - * - ****/ - -#include "gdbstub-cfg.h" - -#if GDBSTUB_ENABLE_SYSCALL - -#include "gdbsyscall.h" -#include "GdbPacket.h" -#include -#include -#include "Platform/System.h" - -// Whilst GCC has intrinsics to do this, they eat IRAM -//#define bswap32(value) __builtin_bswap32(value) -//#define bswap64(value) __builtin_bswap64(value) - -/** @brief Swap byte order in 32-bit value */ -static uint32_t ATTR_GDBEXTERNFN bswap32(uint32_t value) -{ - return (value >> 24) | ((value >> 8) & 0xff00) | ((value << 8) & 0xff0000) | (value << 24); -} - -/** @brief Swap byte order of array of 32-bit values - * @param words - * @param size - */ -static void ATTR_GDBEXTERNFN bswap32p(uint32_t* words, unsigned count) -{ - for(unsigned i = 0; i < count; ++i) { - words[i] = bswap32(words[i]); - } -} - -/** @brief Swap word order in 64-bit value */ -__forceinline void bswap64wp(uint64_t* value) -{ - *value = (*value >> 32) | (*value << 32); -} - -static GdbSyscallInfo syscall_info; ///< The syscall packet - -/* - * If there is user data being packetised we need to wait until that's finished - * before starting a syscall. - * - * If the call is asynchronous, we can set it up now and send it when user data has finished. - * Otherwise we need to force send of uart data via sendUserData() (in gdbuart.cpp). - * - * Both of these deal with packetising whilst the debugger is attached but not paused. - */ -int gdb_syscall(const GdbSyscallInfo& info) -{ - if(!gdb_state.attached) { - debug_e("syscall failed, not attached"); - return -EPERM; - } - if(gdb_state.syscall != syscall_ready) { - debug_e("syscall failed, not ready"); - return -EAGAIN; - } - - syscall_info = info; - gdb_state.syscall = syscall_pending; - - debug_i("syscall pending"); - - if(info.callback == nullptr) { - gdbFlushUserData(); - gdbstub_syscall_execute(); - // No callback, wait for completion - while(gdb_state.syscall != syscall_ready) { - // Watchdog will fire if this takes too long - intentional - } - debug_i("syscall returned %d", syscall_info.result); - return syscall_info.result; - } else { - if(gdbSendUserData() == 0) { - gdbstub_syscall_execute(); - } else { - // will be executed via user task in gdbuart - } - return 0; - } -} - -void gdbstub_syscall_execute() -{ - if(gdb_state.syscall != syscall_pending) { - // Nothing to execute - debug_w("No pending syscall"); - return; - } - - auto& info = syscall_info; - GdbPacket packet; - packet.writeChar('F'); - switch(info.command) { - case eGDBSYS_open: - packet.writeStr(GDB_F("open,")); - packet.writeStrRef(info.open.filename); - packet.writeChar(','); - packet.writeHexWord32(info.open.flags); - packet.writeChar(','); - packet.writeHexByte(info.open.mode); - break; - - case eGDBSYS_close: - packet.writeStr(GDB_F("close,")); - packet.writeHexByte(info.close.fd); - break; - - case eGDBSYS_read: - packet.writeStr(GDB_F("read,")); - packet.writeHexByte(info.read.fd); - packet.writeChar(','); - packet.writeHexWord32(uint32_t(info.read.buffer)); - packet.writeChar(','); - packet.writeHexWord16(info.read.bufSize); - break; - - case eGDBSYS_write: - packet.writeStr(GDB_F("write,")); - packet.writeHexByte(info.write.fd); - packet.writeChar(','); - packet.writeHexWord32(uint32_t(info.write.buffer)); - packet.writeChar(','); - packet.writeHexWord16(info.write.count); - break; - - case eGDBSYS_lseek: - packet.writeStr(GDB_F("lseek,")); - packet.writeHexByte(info.lseek.fd); - packet.writeChar(','); - packet.writeHexWord32(info.lseek.offset); - packet.writeChar(','); - packet.writeHexByte(info.lseek.whence); - break; - - case eGDBSYS_rename: - packet.writeStr(GDB_F("rename,")); - packet.writeStrRef(info.rename.oldpath); - packet.writeChar(','); - packet.writeStrRef(info.rename.newpath); - break; - - case eGDBSYS_unlink: - packet.writeStr(GDB_F("unlink,")); - packet.writeStrRef(info.unlink.pathname); - break; - - case eGDBSYS_stat: - packet.writeStr(GDB_F("stat,")); - packet.writeStrRef(info.stat.pathname); - packet.writeChar(','); - packet.writeHexWord32(uint32_t(info.stat.buf)); - break; - - case eGDBSYS_fstat: - packet.writeStr(GDB_F("fstat,")); - packet.writeHexByte(info.fstat.fd); - packet.writeChar(','); - packet.writeHexWord32(uint32_t(info.fstat.buf)); - break; - - case eGDBSYS_gettimeofday: - packet.writeStr(GDB_F("gettimeofday,")); - packet.writeHexWord32(uint32_t(info.gettimeofday.tv)); - packet.writeChar(','); - packet.writeHexWord32(uint32_t(info.gettimeofday.tz)); - break; - - case eGDBSYS_isatty: - packet.writeStr(GDB_F("isatty,")); - packet.writeHexByte(info.isatty.fd); - break; - - case eGDBSYS_system: - packet.writeStr(GDB_F("system,")); - packet.writeStrRef(info.system.command); - break; - } - - gdb_state.syscall = syscall_active; - - debug_i("syscall active"); -} - -bool ATTR_GDBEXTERNFN gdb_syscall_complete(const char* data) -{ - // normally a hex value, but on error it's -1 - bool isNeg = false; - if(*data == '-') { - ++data; - isNeg = true; - } - int len = GdbPacket::readHexValue(data); - if(isNeg) { - len = -len; - } - - char ctrl_c_flag = '\0'; - - if(*data == ',') { - ++data; - unsigned err = GdbPacket::readHexValue(data); - syscall_info.result = -err; - } else { - syscall_info.result = len; - - switch(syscall_info.command) { - case eGDBSYS_gettimeofday: { - auto tv = syscall_info.gettimeofday.tv; - if(tv != nullptr) { - // Content written in big-endian, so we need to correct it - bswap32p(reinterpret_cast(tv), sizeof(gdb_timeval_t) / 4); - bswap64wp(&tv->tv_usec); - } - break; - } - - case eGDBSYS_stat: - case eGDBSYS_fstat: { - auto stat = syscall_info.stat.buf; - if(stat != nullptr) { - bswap32p(reinterpret_cast(stat), sizeof(gdb_stat_t) / 4); - bswap64wp(&stat->st_size); - bswap64wp(&stat->st_blksize); - bswap64wp(&stat->st_blocks); - } - break; - } - - default:; // No processing required for other commands - } - } - - if(*data == ',') { - ++data; - ctrl_c_flag = *data; - if(ctrl_c_flag) { - bitSet(gdb_state.flags, DBGFLAG_CTRL_BREAK); - } - } - - if(syscall_info.callback != nullptr) { - System.queueCallback(TaskCallback(syscall_info.callback), uint32_t(&syscall_info)); - } - gdb_state.syscall = syscall_ready; - - return ctrl_c_flag; -} - -#endif // GDBSTUB_ENABLE_SYSCALL +/**** + * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. + * Created 2015 by Skurydin Alexey + * http://github.com/SmingHub/Sming + * All files of the Sming Core are provided under the LGPL v3 license. + * + * gdbsyscall.cpp - Support for GDB file I/O + * + * @author: 2019 - Mikee47 + * + ****/ + +#include "gdbstub-cfg.h" + +#if GDBSTUB_ENABLE_SYSCALL + +#include "gdbsyscall.h" +#include "GdbPacket.h" +#include +#include +#include "Platform/System.h" + +// Whilst GCC has intrinsics to do this, they eat IRAM +//#define bswap32(value) __builtin_bswap32(value) +//#define bswap64(value) __builtin_bswap64(value) + +/** @brief Swap byte order in 32-bit value */ +static uint32_t ATTR_GDBEXTERNFN bswap32(uint32_t value) +{ + return (value >> 24) | ((value >> 8) & 0xff00) | ((value << 8) & 0xff0000) | (value << 24); +} + +/** @brief Swap byte order of array of 32-bit values + * @param words + * @param size + */ +static void ATTR_GDBEXTERNFN bswap32p(uint32_t* words, unsigned count) +{ + for(unsigned i = 0; i < count; ++i) { + words[i] = bswap32(words[i]); + } +} + +/** @brief Swap word order in 64-bit value */ +__forceinline void bswap64wp(uint64_t* value) +{ + *value = (*value >> 32) | (*value << 32); +} + +static GdbSyscallInfo syscall_info; ///< The syscall packet + +/* + * If there is user data being packetised we need to wait until that's finished + * before starting a syscall. + * + * If the call is asynchronous, we can set it up now and send it when user data has finished. + * Otherwise we need to force send of uart data via sendUserData() (in gdbuart.cpp). + * + * Both of these deal with packetising whilst the debugger is attached but not paused. + */ +int gdb_syscall(const GdbSyscallInfo& info) +{ + if(!gdb_state.attached) { + debug_e("syscall failed, not attached"); + return -EPERM; + } + if(gdb_state.syscall != syscall_ready) { + debug_e("syscall failed, not ready"); + return -EAGAIN; + } + + syscall_info = info; + gdb_state.syscall = syscall_pending; + + debug_i("syscall pending"); + + if(info.callback == nullptr) { + gdbFlushUserData(); + gdbstub_syscall_execute(); + // No callback, wait for completion + while(gdb_state.syscall != syscall_ready) { + // Watchdog will fire if this takes too long - intentional + } + debug_i("syscall returned %d", syscall_info.result); + return syscall_info.result; + } else { + if(gdbSendUserData() == 0) { + gdbstub_syscall_execute(); + } else { + // will be executed via user task in gdbuart + } + return 0; + } +} + +void gdbstub_syscall_execute() +{ + if(gdb_state.syscall != syscall_pending) { + // Nothing to execute + debug_w("No pending syscall"); + return; + } + + auto& info = syscall_info; + GdbPacket packet; + packet.writeChar('F'); + switch(info.command) { + case eGDBSYS_open: + packet.writeStr(GDB_F("open,")); + packet.writeStrRef(info.open.filename); + packet.writeChar(','); + packet.writeHexWord32(info.open.flags); + packet.writeChar(','); + packet.writeHexByte(info.open.mode); + break; + + case eGDBSYS_close: + packet.writeStr(GDB_F("close,")); + packet.writeHexByte(info.close.fd); + break; + + case eGDBSYS_read: + packet.writeStr(GDB_F("read,")); + packet.writeHexByte(info.read.fd); + packet.writeChar(','); + packet.writeHexWord32(uint32_t(info.read.buffer)); + packet.writeChar(','); + packet.writeHexWord16(info.read.bufSize); + break; + + case eGDBSYS_write: + packet.writeStr(GDB_F("write,")); + packet.writeHexByte(info.write.fd); + packet.writeChar(','); + packet.writeHexWord32(uint32_t(info.write.buffer)); + packet.writeChar(','); + packet.writeHexWord16(info.write.count); + break; + + case eGDBSYS_lseek: + packet.writeStr(GDB_F("lseek,")); + packet.writeHexByte(info.lseek.fd); + packet.writeChar(','); + packet.writeHexWord32(info.lseek.offset); + packet.writeChar(','); + packet.writeHexByte(info.lseek.whence); + break; + + case eGDBSYS_rename: + packet.writeStr(GDB_F("rename,")); + packet.writeStrRef(info.rename.oldpath); + packet.writeChar(','); + packet.writeStrRef(info.rename.newpath); + break; + + case eGDBSYS_unlink: + packet.writeStr(GDB_F("unlink,")); + packet.writeStrRef(info.unlink.pathname); + break; + + case eGDBSYS_stat: + packet.writeStr(GDB_F("stat,")); + packet.writeStrRef(info.stat.pathname); + packet.writeChar(','); + packet.writeHexWord32(uint32_t(info.stat.buf)); + break; + + case eGDBSYS_fstat: + packet.writeStr(GDB_F("fstat,")); + packet.writeHexByte(info.fstat.fd); + packet.writeChar(','); + packet.writeHexWord32(uint32_t(info.fstat.buf)); + break; + + case eGDBSYS_gettimeofday: + packet.writeStr(GDB_F("gettimeofday,")); + packet.writeHexWord32(uint32_t(info.gettimeofday.tv)); + packet.writeChar(','); + packet.writeHexWord32(uint32_t(info.gettimeofday.tz)); + break; + + case eGDBSYS_isatty: + packet.writeStr(GDB_F("isatty,")); + packet.writeHexByte(info.isatty.fd); + break; + + case eGDBSYS_system: + packet.writeStr(GDB_F("system,")); + packet.writeStrRef(info.system.command); + break; + } + + gdb_state.syscall = syscall_active; + + debug_i("syscall active"); +} + +bool ATTR_GDBEXTERNFN gdb_syscall_complete(const char* data) +{ + // normally a hex value, but on error it's -1 + bool isNeg = false; + if(*data == '-') { + ++data; + isNeg = true; + } + int len = GdbPacket::readHexValue(data); + if(isNeg) { + len = -len; + } + + char ctrl_c_flag = '\0'; + + if(*data == ',') { + ++data; + unsigned err = GdbPacket::readHexValue(data); + syscall_info.result = -err; + } else { + syscall_info.result = len; + + switch(syscall_info.command) { + case eGDBSYS_gettimeofday: { + auto tv = syscall_info.gettimeofday.tv; + if(tv != nullptr) { + // Content written in big-endian, so we need to correct it + bswap32p(reinterpret_cast(tv), sizeof(gdb_timeval_t) / 4); + bswap64wp(&tv->tv_usec); + } + break; + } + + case eGDBSYS_stat: + case eGDBSYS_fstat: { + auto stat = syscall_info.stat.buf; + if(stat != nullptr) { + bswap32p(reinterpret_cast(stat), sizeof(gdb_stat_t) / 4); + bswap64wp(&stat->st_size); + bswap64wp(&stat->st_blksize); + bswap64wp(&stat->st_blocks); + } + break; + } + + default:; // No processing required for other commands + } + } + + if(*data == ',') { + ++data; + ctrl_c_flag = *data; + if(ctrl_c_flag) { + bitSet(gdb_state.flags, DBGFLAG_CTRL_BREAK); + } + } + + if(syscall_info.callback != nullptr) { + System.queueCallback(TaskCallback(syscall_info.callback), uint32_t(&syscall_info)); + } + gdb_state.syscall = syscall_ready; + + return ctrl_c_flag; +} + +#endif // GDBSTUB_ENABLE_SYSCALL diff --git a/Sming/Arch/Esp8266/Components/gdbstub/gdbsyscall.h b/Sming/Arch/Esp8266/Components/gdbstub/gdbsyscall.h index d47ecdf83d..ce50d4375c 100644 --- a/Sming/Arch/Esp8266/Components/gdbstub/gdbsyscall.h +++ b/Sming/Arch/Esp8266/Components/gdbstub/gdbsyscall.h @@ -1,30 +1,30 @@ -/**** - * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. - * Created 2015 by Skurydin Alexey - * http://github.com/SmingHub/Sming - * All files of the Sming Core are provided under the LGPL v3 license. - * - * gdbsyscall.h - Support for GDB file I/O - * - * @author: 2019 - Mikee47 - * - ****/ - -#pragma once - -#include "gdbstub.h" - -/** - * @brief Called from gdbSendUserData() when user data has finished sending - */ -void gdbstub_syscall_execute(); - -/** - * @brief Command handler for 'F' - * @param data first character after 'F' - * @retval bool true means Ctrl-C was pressed - * @note A file (or console) I/O request ends with receipt of an 'F' command: - * - * Fretcode,errno,Ctrl-C flag;call-specific attachment - */ -bool gdb_syscall_complete(const char* data); +/**** + * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. + * Created 2015 by Skurydin Alexey + * http://github.com/SmingHub/Sming + * All files of the Sming Core are provided under the LGPL v3 license. + * + * gdbsyscall.h - Support for GDB file I/O + * + * @author: 2019 - Mikee47 + * + ****/ + +#pragma once + +#include "gdbstub.h" + +/** + * @brief Called from gdbSendUserData() when user data has finished sending + */ +void gdbstub_syscall_execute(); + +/** + * @brief Command handler for 'F' + * @param data first character after 'F' + * @retval bool true means Ctrl-C was pressed + * @note A file (or console) I/O request ends with receipt of an 'F' command: + * + * Fretcode,errno,Ctrl-C flag;call-specific attachment + */ +bool gdb_syscall_complete(const char* data); diff --git a/Sming/Arch/Esp8266/Components/gdbstub/gdbuart.cpp b/Sming/Arch/Esp8266/Components/gdbstub/gdbuart.cpp index 2f027bab68..e3751b2568 100644 --- a/Sming/Arch/Esp8266/Components/gdbstub/gdbuart.cpp +++ b/Sming/Arch/Esp8266/Components/gdbstub/gdbuart.cpp @@ -1,418 +1,418 @@ -/**** - * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. - * Created 2015 by Skurydin Alexey - * http://github.com/SmingHub/Sming - * All files of the Sming Core are provided under the LGPL v3 license. - * - * gdbuart.cpp - * - * @author: 2019 - Mikee47 - * - ****/ - -#include "gdbuart.h" -#include "GdbPacket.h" -#include "driver/uart.h" -#include "Data/Buffer/SerialBuffer.h" -#include "Platform/System.h" -#include "HardwareSerial.h" -#include "HardwareTimer.h" -#include "gdbsyscall.h" - -#define GDB_UART UART0 // Only UART0 supports for debugging as RX/TX required - -static uart_t* gdb_uart; // Port debugger is attached to - -#if GDBSTUB_ENABLE_UART2 -static uart_t* user_uart; // If open, virtual port being used for user passthrough -static uint32_t user_uart_status; // See gdb_uart_callback (ISR handler) -static volatile bool userDataSending; // Transmit completion callback invoked on user uart -static bool sendUserDataQueued; // Ensures only one call to gdbSendUserData() is queued at a time -static uint8_t break_requests; ///< How many times Ctrl+C was received before actually breaking -#endif - -// Get number of characters in receive FIFO -__forceinline static uint8_t uart_rxfifo_count(uint8_t nr) -{ - return (USS(nr) >> USRXC) & 0xff; -} - -// Get number of characters in transmit FIFO -__forceinline static uint8_t uart_txfifo_count(uint8_t nr) -{ - return (USS(nr) >> USTXC) & 0xff; -} - -// Get available free characters in transmit FIFO -__forceinline static uint8_t uart_txfifo_free(uint8_t nr) -{ - return UART_TX_FIFO_SIZE - uart_txfifo_count(nr) - 1; -} - -// Return true if transmit FIFO is full -__forceinline static bool uart_txfifo_full(uint8_t nr) -{ - return uart_txfifo_count(nr) >= (UART_TX_FIFO_SIZE - 1); -} - -/* - * Minimal version of uart_read_char() - */ -static int ATTR_GDBEXTERNFN gdb_uart_read_char() -{ - int c; - if(uart_rxfifo_count(GDB_UART) == 0) { - c = -1; - } else { - c = USF(GDB_UART) & 0xff; - } - return c; -} - -/* - * Minimal version of uart_write(). Blocks until all data queued. - */ -static size_t ATTR_GDBEXTERNFN gdb_uart_write(const void* data, size_t length) -{ - if(data == nullptr || length == 0) { - return 0; - } - - for(unsigned i = 0; i < length; ++i) { - while(uart_txfifo_full(GDB_UART)) { - // - } - USF(GDB_UART) = static_cast(data)[i]; - } - - // Enable TX FIFO EMPTY interrupt - bitSet(USIE(GDB_UART), UIFE); - - return length; -} - -/* - * Minimal version of uart_write_char(). Blocks until data queued. - */ -static size_t ATTR_GDBEXTERNFN gdb_uart_write_char(char c) -{ - while(uart_txfifo_full(GDB_UART)) { - // - } - USF(GDB_UART) = c; - - // Enable TX FIFO EMPTY interrupt - bitSet(USIE(GDB_UART), UIFE); - - return 1; -} - -int ATTR_GDBEXTERNFN gdbReceiveChar() -{ -#if GDBSTUB_UART_READ_TIMEOUT - auto timeout = usToTimerTicks(GDBSTUB_UART_READ_TIMEOUT * 1000U); - auto startTicks = NOW(); -#define checkTimeout() (NOW() - startTicks >= timeout) -#else -#define checkTimeout() (false) -#endif - - do { - wdt_feed(); - system_soft_wdt_feed(); - int c = gdb_uart_read_char(); - if(c >= 0) { -#if GDBSTUB_ENABLE_DEBUG >= 3 - m_putc(c); -#endif - return c; - } - } while(!checkTimeout()); - - return -1; -} - -size_t ATTR_GDBEXTERNFN gdbSendData(const void* data, size_t length) -{ -#if GDBSTUB_ENABLE_DEBUG >= 3 - m_nputs(static_cast(data), length); -#endif - return gdb_uart_write(data, length); -} - -size_t ATTR_GDBEXTERNFN gdbSendChar(char c) -{ -#if GDBSTUB_ENABLE_DEBUG >= 3 - m_putc(c); -#endif - return gdb_uart_write_char(c); -} - -size_t ATTR_GDBEXTERNFN gdbWriteConsole(const char* data, size_t length) -{ - GdbPacket packet; - packet.writeChar('O'); - packet.writeHexBlock(data, length); - return length; -} - -size_t ATTR_GDBEXTERNFN gdbSendUserData() -{ -#if GDBSTUB_ENABLE_UART2 - auto txbuf = user_uart == nullptr ? nullptr : user_uart->tx_buffer; - if(txbuf == nullptr) { - return 0; - } - - size_t avail; - void* data; - while((avail = txbuf->getReadData(data)) != 0) { - size_t charCount; - unsigned used = uart_txfifo_count(GDB_UART); - unsigned space = UART_TX_FIFO_SIZE - used - 1; - if(gdb_state.attached) { - // $Onn#CC is smallest packet, for a single character, but we want to avoid that as it's inefficient - if(used >= 8) { - break; - } - - charCount = std::min((space - 3) / 2, avail); - gdbWriteConsole(static_cast(data), charCount); - } else { - charCount = gdb_uart_write(data, std::min(space, avail)); - } - - userDataSending = true; - - user_uart->tx_buffer->skipRead(charCount); - if(charCount != avail) { - break; // That's all for now - } - } - - return avail; -#else - // UART2 disabled, no user data to send - return 0; -#endif -} - -void ATTR_GDBEXTERNFN gdbFlushUserData() -{ -#if GDBSTUB_ENABLE_UART2 - while(gdbSendUserData() != 0) { - wdt_feed(); - system_soft_wdt_feed(); - } -#endif -} - -#if GDBSTUB_ENABLE_UART2 - -static void sendUserDataTask(uint32_t) -{ - sendUserDataQueued = false; - - if(gdbSendUserData() == 0) { -#if GDBSTUB_ENABLE_SYSCALL - // When all data has been sent, see if there's a pending syscall to send - gdbstub_syscall_execute(); -#endif - } -} - -__forceinline void queueSendUserData() -{ - if(!sendUserDataQueued) { - System.queueCallback(sendUserDataTask); - sendUserDataQueued = true; - } -} - -/** - * @brief Notify callback for user uart, called from uart driver - */ -static void userUartNotify(uart_t* uart, uart_notify_code_t code) -{ - switch(code) { - case UART_NOTIFY_AFTER_OPEN: - user_uart = uart; - break; - - case UART_NOTIFY_BEFORE_CLOSE: - user_uart = nullptr; - break; - - case UART_NOTIFY_AFTER_WRITE: { - /* - * Driver calls here from uart_write() after data has been written to tx buffer. - * Mostly we rely on task callback to transfer data from buffer to serial port, - * but we need to send some data directly if the buffer is full otherwise we'll - * loop indefinitely if UART_OPT_TXWAIT is set. - */ - if(uart->tx_buffer->isFull()) { - gdbSendUserData(); - } else { - queueSendUserData(); - } - break; - } - - case UART_NOTIFY_WAIT_TX: { - gdbFlushUserData(); - break; - } - - case UART_NOTIFY_BEFORE_READ: - break; - } -} -#endif - -static void IRAM_ATTR doCtrlBreak() -{ - if(break_requests != 0) { - break_requests = 0; - gdbstub_break_internal(DBGFLAG_CTRL_BREAK); - } -} - -static void IRAM_ATTR gdb_uart_callback(uart_t* uart, uint32_t status) -{ -#if GDBSTUB_ENABLE_UART2 - user_uart_status = status; - - // TX FIFO empty ? - if(bitRead(status, UIFE)) { - // Disable TX FIFO EMPTY interrupt to stop it recurring - re-enabled by uart_write() - if(uart_txfifo_count(GDB_UART) == 0) { - bitClear(USIE(GDB_UART), UIFE); - } - - auto txbuf = user_uart == nullptr ? nullptr : user_uart->tx_buffer; - if(txbuf != nullptr) { - // More user data to send? - if(!txbuf->isEmpty()) { - // Yes - send it via task callback (because packetising code may not be in IRAM) - queueSendUserData(); - bitClear(user_uart_status, UIFE); - } else if(userDataSending) { - // User data has now all been sent - UIFE will remain set - userDataSending = false; - } else { - // No user data was in transit, so this event doesn't apply to user uart - bitClear(user_uart_status, UIFE); - } - } - } -#else - bitClear(USIE(GDB_UART), UIFE); -#endif - - // RX FIFO Full or RX FIFO Timeout ? - if(status & (_BV(UIFF) | _BV(UITO))) { -#if GDBSTUB_ENABLE_UART2 - auto rxbuf = user_uart == nullptr ? nullptr : user_uart->rx_buffer; -#endif - - while(uart_rxfifo_count(GDB_UART) != 0) { - char c = USF(GDB_UART); -#if GDBSTUB_CTRLC_BREAK - bool breakCheck = gdb_state.enabled; -#if GDBSTUB_CTRLC_BREAK == 1 - if(!gdb_state.attached) { - breakCheck = false; - } -#endif - if(breakCheck && c == '\x03') { - if(break_requests++ == 0) { - // First attempt, break within a task callback - System.queueCallback(TaskCallback(doCtrlBreak)); - } else if(break_requests == 3) { - // Application failed to stop, break immediately - doCtrlBreak(); - } - continue; - } -#endif - -#if GDBSTUB_ENABLE_SYSCALL - // If packet start detected whilst handling a system call, break into debugger to process it - if(c == '$' && gdb_state.syscall == syscall_active) { - gdbstub_break_internal(DBGFLAG_PACKET_STARTED); - continue; - } -#endif - -#if GDBSTUB_ENABLE_UART2 - // When attached, nothing gets routed to UART2 - if(!gdb_state.attached && rxbuf != nullptr) { - if(rxbuf->writeChar(c) == 0) { - bitSet(user_uart_status, UIOF); // Overflow - } - } -#endif - } - -#if GDBSTUB_ENABLE_UART2 - if(rxbuf != nullptr) { - if(rxbuf->isEmpty()) { - // This event doesn't apply to user uart - bitClear(user_uart_status, UIFF); - bitClear(user_uart_status, UITO); - } else if(rxbuf->getFreeSpace() > size_t(UART_RX_FIFO_SIZE) + user_uart->rx_headroom) { - bitClear(user_uart_status, UIFF); - } - } -#endif - } - -#if GDBSTUB_ENABLE_UART2 - if(user_uart_status != 0 && user_uart != nullptr) { - user_uart->status |= user_uart_status; - if(user_uart->callback != nullptr) { - user_uart->callback(user_uart, user_uart_status); - } - } -#endif -} - -bool ATTR_GDBINIT gdb_uart_init() -{ - uart_set_debug(UART_NO); - - // Additional buffering not supported because interrupts are disabled when debugger halted - uart_config cfg = {.uart_nr = GDB_UART, - .tx_pin = 1, - .mode = UART_FULL, - .options = _BV(UART_OPT_TXWAIT) | _BV(UART_OPT_CALLBACK_RAW), - .baudrate = SERIAL_BAUD_RATE, - .config = UART_8N1, - .rx_size = 0, - .tx_size = 0}; - gdb_uart = uart_init_ex(cfg); - if(gdb_uart == nullptr) { - return false; - } - uart_set_callback(gdb_uart, gdb_uart_callback, nullptr); - -#if GDBSTUB_ENABLE_UART2 - // Virtualise user serial access via UART2 - uart_set_notify(UART2, userUartNotify); - Serial.setPort(UART2); -#endif - -#if GDBSTUB_ENABLE_DEBUG - auto uart1 = uart_init(UART1, SERIAL_BAUD_RATE, UART_8N1, UART_TX_ONLY, 1, 0, 0); - if(uart1 != nullptr) { - uart_set_debug(UART1); - - using namespace std::placeholders; - m_setPuts(std::bind(&uart_write, uart1, _1, _2)); - } - - debug_i("\n\nGDB STUB RUNNING"); -#endif - - return true; -} +/**** + * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. + * Created 2015 by Skurydin Alexey + * http://github.com/SmingHub/Sming + * All files of the Sming Core are provided under the LGPL v3 license. + * + * gdbuart.cpp + * + * @author: 2019 - Mikee47 + * + ****/ + +#include "gdbuart.h" +#include "GdbPacket.h" +#include "driver/uart.h" +#include "Data/Buffer/SerialBuffer.h" +#include "Platform/System.h" +#include "HardwareSerial.h" +#include "HardwareTimer.h" +#include "gdbsyscall.h" + +#define GDB_UART UART0 // Only UART0 supports for debugging as RX/TX required + +static uart_t* gdb_uart; // Port debugger is attached to + +#if GDBSTUB_ENABLE_UART2 +static uart_t* user_uart; // If open, virtual port being used for user passthrough +static uint32_t user_uart_status; // See gdb_uart_callback (ISR handler) +static volatile bool userDataSending; // Transmit completion callback invoked on user uart +static bool sendUserDataQueued; // Ensures only one call to gdbSendUserData() is queued at a time +static uint8_t break_requests; ///< How many times Ctrl+C was received before actually breaking +#endif + +// Get number of characters in receive FIFO +__forceinline static uint8_t uart_rxfifo_count(uint8_t nr) +{ + return (USS(nr) >> USRXC) & 0xff; +} + +// Get number of characters in transmit FIFO +__forceinline static uint8_t uart_txfifo_count(uint8_t nr) +{ + return (USS(nr) >> USTXC) & 0xff; +} + +// Get available free characters in transmit FIFO +__forceinline static uint8_t uart_txfifo_free(uint8_t nr) +{ + return UART_TX_FIFO_SIZE - uart_txfifo_count(nr) - 1; +} + +// Return true if transmit FIFO is full +__forceinline static bool uart_txfifo_full(uint8_t nr) +{ + return uart_txfifo_count(nr) >= (UART_TX_FIFO_SIZE - 1); +} + +/* + * Minimal version of uart_read_char() + */ +static int ATTR_GDBEXTERNFN gdb_uart_read_char() +{ + int c; + if(uart_rxfifo_count(GDB_UART) == 0) { + c = -1; + } else { + c = USF(GDB_UART) & 0xff; + } + return c; +} + +/* + * Minimal version of uart_write(). Blocks until all data queued. + */ +static size_t ATTR_GDBEXTERNFN gdb_uart_write(const void* data, size_t length) +{ + if(data == nullptr || length == 0) { + return 0; + } + + for(unsigned i = 0; i < length; ++i) { + while(uart_txfifo_full(GDB_UART)) { + // + } + USF(GDB_UART) = static_cast(data)[i]; + } + + // Enable TX FIFO EMPTY interrupt + bitSet(USIE(GDB_UART), UIFE); + + return length; +} + +/* + * Minimal version of uart_write_char(). Blocks until data queued. + */ +static size_t ATTR_GDBEXTERNFN gdb_uart_write_char(char c) +{ + while(uart_txfifo_full(GDB_UART)) { + // + } + USF(GDB_UART) = c; + + // Enable TX FIFO EMPTY interrupt + bitSet(USIE(GDB_UART), UIFE); + + return 1; +} + +int ATTR_GDBEXTERNFN gdbReceiveChar() +{ +#if GDBSTUB_UART_READ_TIMEOUT + auto timeout = usToTimerTicks(GDBSTUB_UART_READ_TIMEOUT * 1000U); + auto startTicks = NOW(); +#define checkTimeout() (NOW() - startTicks >= timeout) +#else +#define checkTimeout() (false) +#endif + + do { + wdt_feed(); + system_soft_wdt_feed(); + int c = gdb_uart_read_char(); + if(c >= 0) { +#if GDBSTUB_ENABLE_DEBUG >= 3 + m_putc(c); +#endif + return c; + } + } while(!checkTimeout()); + + return -1; +} + +size_t ATTR_GDBEXTERNFN gdbSendData(const void* data, size_t length) +{ +#if GDBSTUB_ENABLE_DEBUG >= 3 + m_nputs(static_cast(data), length); +#endif + return gdb_uart_write(data, length); +} + +size_t ATTR_GDBEXTERNFN gdbSendChar(char c) +{ +#if GDBSTUB_ENABLE_DEBUG >= 3 + m_putc(c); +#endif + return gdb_uart_write_char(c); +} + +size_t ATTR_GDBEXTERNFN gdbWriteConsole(const char* data, size_t length) +{ + GdbPacket packet; + packet.writeChar('O'); + packet.writeHexBlock(data, length); + return length; +} + +size_t ATTR_GDBEXTERNFN gdbSendUserData() +{ +#if GDBSTUB_ENABLE_UART2 + auto txbuf = user_uart == nullptr ? nullptr : user_uart->tx_buffer; + if(txbuf == nullptr) { + return 0; + } + + size_t avail; + void* data; + while((avail = txbuf->getReadData(data)) != 0) { + size_t charCount; + unsigned used = uart_txfifo_count(GDB_UART); + unsigned space = UART_TX_FIFO_SIZE - used - 1; + if(gdb_state.attached) { + // $Onn#CC is smallest packet, for a single character, but we want to avoid that as it's inefficient + if(used >= 8) { + break; + } + + charCount = std::min((space - 3) / 2, avail); + gdbWriteConsole(static_cast(data), charCount); + } else { + charCount = gdb_uart_write(data, std::min(space, avail)); + } + + userDataSending = true; + + user_uart->tx_buffer->skipRead(charCount); + if(charCount != avail) { + break; // That's all for now + } + } + + return avail; +#else + // UART2 disabled, no user data to send + return 0; +#endif +} + +void ATTR_GDBEXTERNFN gdbFlushUserData() +{ +#if GDBSTUB_ENABLE_UART2 + while(gdbSendUserData() != 0) { + wdt_feed(); + system_soft_wdt_feed(); + } +#endif +} + +#if GDBSTUB_ENABLE_UART2 + +static void sendUserDataTask(uint32_t) +{ + sendUserDataQueued = false; + + if(gdbSendUserData() == 0) { +#if GDBSTUB_ENABLE_SYSCALL + // When all data has been sent, see if there's a pending syscall to send + gdbstub_syscall_execute(); +#endif + } +} + +__forceinline void queueSendUserData() +{ + if(!sendUserDataQueued) { + System.queueCallback(sendUserDataTask); + sendUserDataQueued = true; + } +} + +/** + * @brief Notify callback for user uart, called from uart driver + */ +static void userUartNotify(uart_t* uart, uart_notify_code_t code) +{ + switch(code) { + case UART_NOTIFY_AFTER_OPEN: + user_uart = uart; + break; + + case UART_NOTIFY_BEFORE_CLOSE: + user_uart = nullptr; + break; + + case UART_NOTIFY_AFTER_WRITE: { + /* + * Driver calls here from uart_write() after data has been written to tx buffer. + * Mostly we rely on task callback to transfer data from buffer to serial port, + * but we need to send some data directly if the buffer is full otherwise we'll + * loop indefinitely if UART_OPT_TXWAIT is set. + */ + if(uart->tx_buffer->isFull()) { + gdbSendUserData(); + } else { + queueSendUserData(); + } + break; + } + + case UART_NOTIFY_WAIT_TX: { + gdbFlushUserData(); + break; + } + + case UART_NOTIFY_BEFORE_READ: + break; + } +} +#endif + +static void IRAM_ATTR doCtrlBreak() +{ + if(break_requests != 0) { + break_requests = 0; + gdbstub_break_internal(DBGFLAG_CTRL_BREAK); + } +} + +static void IRAM_ATTR gdb_uart_callback(uart_t* uart, uint32_t status) +{ +#if GDBSTUB_ENABLE_UART2 + user_uart_status = status; + + // TX FIFO empty ? + if(bitRead(status, UIFE)) { + // Disable TX FIFO EMPTY interrupt to stop it recurring - re-enabled by uart_write() + if(uart_txfifo_count(GDB_UART) == 0) { + bitClear(USIE(GDB_UART), UIFE); + } + + auto txbuf = user_uart == nullptr ? nullptr : user_uart->tx_buffer; + if(txbuf != nullptr) { + // More user data to send? + if(!txbuf->isEmpty()) { + // Yes - send it via task callback (because packetising code may not be in IRAM) + queueSendUserData(); + bitClear(user_uart_status, UIFE); + } else if(userDataSending) { + // User data has now all been sent - UIFE will remain set + userDataSending = false; + } else { + // No user data was in transit, so this event doesn't apply to user uart + bitClear(user_uart_status, UIFE); + } + } + } +#else + bitClear(USIE(GDB_UART), UIFE); +#endif + + // RX FIFO Full or RX FIFO Timeout ? + if(status & (_BV(UIFF) | _BV(UITO))) { +#if GDBSTUB_ENABLE_UART2 + auto rxbuf = user_uart == nullptr ? nullptr : user_uart->rx_buffer; +#endif + + while(uart_rxfifo_count(GDB_UART) != 0) { + char c = USF(GDB_UART); +#if GDBSTUB_CTRLC_BREAK + bool breakCheck = gdb_state.enabled; +#if GDBSTUB_CTRLC_BREAK == 1 + if(!gdb_state.attached) { + breakCheck = false; + } +#endif + if(breakCheck && c == '\x03') { + if(break_requests++ == 0) { + // First attempt, break within a task callback + System.queueCallback(TaskCallback(doCtrlBreak)); + } else if(break_requests == 3) { + // Application failed to stop, break immediately + doCtrlBreak(); + } + continue; + } +#endif + +#if GDBSTUB_ENABLE_SYSCALL + // If packet start detected whilst handling a system call, break into debugger to process it + if(c == '$' && gdb_state.syscall == syscall_active) { + gdbstub_break_internal(DBGFLAG_PACKET_STARTED); + continue; + } +#endif + +#if GDBSTUB_ENABLE_UART2 + // When attached, nothing gets routed to UART2 + if(!gdb_state.attached && rxbuf != nullptr) { + if(rxbuf->writeChar(c) == 0) { + bitSet(user_uart_status, UIOF); // Overflow + } + } +#endif + } + +#if GDBSTUB_ENABLE_UART2 + if(rxbuf != nullptr) { + if(rxbuf->isEmpty()) { + // This event doesn't apply to user uart + bitClear(user_uart_status, UIFF); + bitClear(user_uart_status, UITO); + } else if(rxbuf->getFreeSpace() > size_t(UART_RX_FIFO_SIZE) + user_uart->rx_headroom) { + bitClear(user_uart_status, UIFF); + } + } +#endif + } + +#if GDBSTUB_ENABLE_UART2 + if(user_uart_status != 0 && user_uart != nullptr) { + user_uart->status |= user_uart_status; + if(user_uart->callback != nullptr) { + user_uart->callback(user_uart, user_uart_status); + } + } +#endif +} + +bool ATTR_GDBINIT gdb_uart_init() +{ + uart_set_debug(UART_NO); + + // Additional buffering not supported because interrupts are disabled when debugger halted + uart_config cfg = {.uart_nr = GDB_UART, + .tx_pin = 1, + .mode = UART_FULL, + .options = _BV(UART_OPT_TXWAIT) | _BV(UART_OPT_CALLBACK_RAW), + .baudrate = SERIAL_BAUD_RATE, + .config = UART_8N1, + .rx_size = 0, + .tx_size = 0}; + gdb_uart = uart_init_ex(cfg); + if(gdb_uart == nullptr) { + return false; + } + uart_set_callback(gdb_uart, gdb_uart_callback, nullptr); + +#if GDBSTUB_ENABLE_UART2 + // Virtualise user serial access via UART2 + uart_set_notify(UART2, userUartNotify); + Serial.setPort(UART2); +#endif + +#if GDBSTUB_ENABLE_DEBUG + auto uart1 = uart_init(UART1, SERIAL_BAUD_RATE, UART_8N1, UART_TX_ONLY, 1, 0, 0); + if(uart1 != nullptr) { + uart_set_debug(UART1); + + using namespace std::placeholders; + m_setPuts(std::bind(&uart_write, uart1, _1, _2)); + } + + debug_i("\n\nGDB STUB RUNNING"); +#endif + + return true; +} diff --git a/Sming/Arch/Esp8266/Components/gdbstub/gdbuart.h b/Sming/Arch/Esp8266/Components/gdbstub/gdbuart.h index 20a4b17e15..2d96607351 100644 --- a/Sming/Arch/Esp8266/Components/gdbstub/gdbuart.h +++ b/Sming/Arch/Esp8266/Components/gdbstub/gdbuart.h @@ -1,54 +1,54 @@ -/**** - * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. - * Created 2015 by Skurydin Alexey - * http://github.com/SmingHub/Sming - * All files of the Sming Core are provided under the LGPL v3 license. - * - * gdbuart.h - * - ****/ - -#pragma once - -#include "gdbstub.h" - -bool gdb_uart_init(); - -/* - * Receive a char from the uart. Uses polling and feeds the watchdog. - */ -int gdbReceiveChar(); - -/* - * Send a block of data to the uart - */ -size_t gdbSendData(const void* data, size_t length); - -/* - * Send a char to the uart - */ -size_t gdbSendChar(char c); - -/** - * @brief Write a block of data to the GDB console - * @param data - * @param length - * @retval size_t Always returns length - * @note Data is encoded as a single 'O' packet. Should only be used when GDB is attached. - */ -size_t ATTR_GDBEXTERNFN gdbWriteConsole(const char* data, size_t length); - -/** - * @brief Send some user data from the user_uart TX buffer to the GDB serial port, - * packetising it if necessary. - * @retval size_t Number of characters still remaining in buffer - * @note Data flows from user uart TX buffer to UART0 either during uart_write() call - * (via notify callback) or via task callback queued from ISR. We don't do this inside - * the ISR as all the code (including packetising) would need to be in IRAM. - */ -size_t gdbSendUserData(); - -/** - * @brief Ensure all user data has been written to serial port - */ -void gdbFlushUserData(); +/**** + * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. + * Created 2015 by Skurydin Alexey + * http://github.com/SmingHub/Sming + * All files of the Sming Core are provided under the LGPL v3 license. + * + * gdbuart.h + * + ****/ + +#pragma once + +#include "gdbstub.h" + +bool gdb_uart_init(); + +/* + * Receive a char from the uart. Uses polling and feeds the watchdog. + */ +int gdbReceiveChar(); + +/* + * Send a block of data to the uart + */ +size_t gdbSendData(const void* data, size_t length); + +/* + * Send a char to the uart + */ +size_t gdbSendChar(char c); + +/** + * @brief Write a block of data to the GDB console + * @param data + * @param length + * @retval size_t Always returns length + * @note Data is encoded as a single 'O' packet. Should only be used when GDB is attached. + */ +size_t ATTR_GDBEXTERNFN gdbWriteConsole(const char* data, size_t length); + +/** + * @brief Send some user data from the user_uart TX buffer to the GDB serial port, + * packetising it if necessary. + * @retval size_t Number of characters still remaining in buffer + * @note Data flows from user uart TX buffer to UART0 either during uart_write() call + * (via notify callback) or via task callback queued from ISR. We don't do this inside + * the ISR as all the code (including packetising) would need to be in IRAM. + */ +size_t gdbSendUserData(); + +/** + * @brief Ensure all user data has been written to serial port + */ +void gdbFlushUserData(); diff --git a/Sming/Arch/Esp8266/Components/gdbstub/xtensa/xtruntime-frames.h b/Sming/Arch/Esp8266/Components/gdbstub/xtensa/xtruntime-frames.h index 793a69f0ce..4d0cde9f36 100644 --- a/Sming/Arch/Esp8266/Components/gdbstub/xtensa/xtruntime-frames.h +++ b/Sming/Arch/Esp8266/Components/gdbstub/xtensa/xtruntime-frames.h @@ -1,160 +1,160 @@ -/* xtruntime-frames.h - exception stack frames for single-threaded run-time */ -/* $Id: //depot/rel/Boreal/Xtensa/OS/include/xtensa/xtruntime-frames.h#2 $ */ - -/* - * Copyright (c) 2002-2007 Tensilica Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef _XTRUNTIME_FRAMES_H_ -#define _XTRUNTIME_FRAMES_H_ - -#include - -/* Macros that help define structures for both C and assembler: */ -#if defined(_ASMLANGUAGE) || defined(__ASSEMBLER__) -#define STRUCT_BEGIN .pushsection .text; .struct 0 -#define STRUCT_FIELD(ctype,size,pre,name) pre##name: .space size -#define STRUCT_AFIELD(ctype,size,pre,name,n) pre##name: .space (size)*(n) -#define STRUCT_END(sname) sname##Size:; .popsection -#else /*_ASMLANGUAGE||__ASSEMBLER__*/ -#define STRUCT_BEGIN typedef struct { -#define STRUCT_FIELD(ctype,size,pre,name) ctype name; -#define STRUCT_AFIELD(ctype,size,pre,name,n) ctype name[n]; -#define STRUCT_END(sname) } sname; -#endif /*_ASMLANGUAGE||__ASSEMBLER__*/ - - -/* - * Kernel vector mode exception stack frame. - * - * NOTE: due to the limited range of addi used in the current - * kernel exception vector, and the fact that historically - * the vector is limited to 12 bytes, the size of this - * stack frame is limited to 128 bytes (currently at 64). - */ -STRUCT_BEGIN -STRUCT_FIELD (long,4,KEXC_,pc) /* "parm" */ -STRUCT_FIELD (long,4,KEXC_,ps) -STRUCT_AFIELD(long,4,KEXC_,areg, 4) /* a12 .. a15 */ -STRUCT_FIELD (long,4,KEXC_,sar) /* "save" */ -#if XCHAL_HAVE_LOOPS -STRUCT_FIELD (long,4,KEXC_,lcount) -STRUCT_FIELD (long,4,KEXC_,lbeg) -STRUCT_FIELD (long,4,KEXC_,lend) -#endif -#if XCHAL_HAVE_MAC16 -STRUCT_FIELD (long,4,KEXC_,acclo) -STRUCT_FIELD (long,4,KEXC_,acchi) -STRUCT_AFIELD(long,4,KEXC_,mr, 4) -#endif -STRUCT_END(KernelFrame) - - -/* - * User vector mode exception stack frame: - * - * WARNING: if you modify this structure, you MUST modify the - * computation of the pad size (ALIGNPAD) accordingly. - */ -STRUCT_BEGIN -STRUCT_FIELD (long,4,UEXC_,pc) -STRUCT_FIELD (long,4,UEXC_,ps) -STRUCT_FIELD (long,4,UEXC_,sar) -STRUCT_FIELD (long,4,UEXC_,vpri) -#ifdef __XTENSA_CALL0_ABI__ -STRUCT_FIELD (long,4,UEXC_,a0) -#endif -STRUCT_FIELD (long,4,UEXC_,a2) -STRUCT_FIELD (long,4,UEXC_,a3) -STRUCT_FIELD (long,4,UEXC_,a4) -STRUCT_FIELD (long,4,UEXC_,a5) -#ifdef __XTENSA_CALL0_ABI__ -STRUCT_FIELD (long,4,UEXC_,a6) -STRUCT_FIELD (long,4,UEXC_,a7) -STRUCT_FIELD (long,4,UEXC_,a8) -STRUCT_FIELD (long,4,UEXC_,a9) -STRUCT_FIELD (long,4,UEXC_,a10) -STRUCT_FIELD (long,4,UEXC_,a11) -STRUCT_FIELD (long,4,UEXC_,a12) -STRUCT_FIELD (long,4,UEXC_,a13) -STRUCT_FIELD (long,4,UEXC_,a14) -STRUCT_FIELD (long,4,UEXC_,a15) -#endif -STRUCT_FIELD (long,4,UEXC_,exccause) /* NOTE: can probably rid of this one (pass direct) */ -#if XCHAL_HAVE_LOOPS -STRUCT_FIELD (long,4,UEXC_,lcount) -STRUCT_FIELD (long,4,UEXC_,lbeg) -STRUCT_FIELD (long,4,UEXC_,lend) -#endif -#if XCHAL_HAVE_MAC16 -STRUCT_FIELD (long,4,UEXC_,acclo) -STRUCT_FIELD (long,4,UEXC_,acchi) -STRUCT_AFIELD(long,4,UEXC_,mr, 4) -#endif -/* ALIGNPAD is the 16-byte alignment padding. */ -#ifdef __XTENSA_CALL0_ABI__ -# define CALL0_ABI 1 -#else -# define CALL0_ABI 0 -#endif -#define ALIGNPAD ((3 + XCHAL_HAVE_LOOPS*1 + XCHAL_HAVE_MAC16*2 + CALL0_ABI*1) & 3) -#if ALIGNPAD -STRUCT_AFIELD(long,4,UEXC_,pad, ALIGNPAD) /* 16-byte alignment padding */ -#endif -/*STRUCT_AFIELD(char,1,UEXC_,ureg, (XCHAL_CPEXTRA_SA_SIZE_TOR2+3)&-4)*/ /* not used, and doesn't take alignment into account */ -STRUCT_END(UserFrame) - - -#if defined(_ASMLANGUAGE) || defined(__ASSEMBLER__) - - -/* Check for UserFrameSize small enough not to require rounding...: */ - /* Skip 16-byte save area, then 32-byte space for 8 regs of call12 - * (which overlaps with 16-byte GCC nested func chaining area), - * then exception stack frame: */ - .set UserFrameTotalSize, 16+32+UserFrameSize - /* Greater than 112 bytes? (max range of ADDI, both signs, when aligned to 16 bytes): */ - .ifgt UserFrameTotalSize-112 - /* Round up to 256-byte multiple to accelerate immediate adds: */ - .set UserFrameTotalSize, ((UserFrameTotalSize+255) & 0xFFFFFF00) - .endif -# define ESF_TOTALSIZE UserFrameTotalSize - -#endif /* _ASMLANGUAGE || __ASSEMBLER__ */ - - -#if XCHAL_NUM_CONTEXTS > 1 -/* Structure of info stored on new context's stack for setup: */ -STRUCT_BEGIN -STRUCT_FIELD (long,4,INFO_,sp) -STRUCT_FIELD (long,4,INFO_,arg1) -STRUCT_FIELD (long,4,INFO_,funcpc) -STRUCT_FIELD (long,4,INFO_,prevps) -STRUCT_END(SetupInfo) -#endif - - -#define KERNELSTACKSIZE 1024 - - -#endif /* _XTRUNTIME_FRAMES_H_ */ - +/* xtruntime-frames.h - exception stack frames for single-threaded run-time */ +/* $Id: //depot/rel/Boreal/Xtensa/OS/include/xtensa/xtruntime-frames.h#2 $ */ + +/* + * Copyright (c) 2002-2007 Tensilica Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef _XTRUNTIME_FRAMES_H_ +#define _XTRUNTIME_FRAMES_H_ + +#include + +/* Macros that help define structures for both C and assembler: */ +#if defined(_ASMLANGUAGE) || defined(__ASSEMBLER__) +#define STRUCT_BEGIN .pushsection .text; .struct 0 +#define STRUCT_FIELD(ctype,size,pre,name) pre##name: .space size +#define STRUCT_AFIELD(ctype,size,pre,name,n) pre##name: .space (size)*(n) +#define STRUCT_END(sname) sname##Size:; .popsection +#else /*_ASMLANGUAGE||__ASSEMBLER__*/ +#define STRUCT_BEGIN typedef struct { +#define STRUCT_FIELD(ctype,size,pre,name) ctype name; +#define STRUCT_AFIELD(ctype,size,pre,name,n) ctype name[n]; +#define STRUCT_END(sname) } sname; +#endif /*_ASMLANGUAGE||__ASSEMBLER__*/ + + +/* + * Kernel vector mode exception stack frame. + * + * NOTE: due to the limited range of addi used in the current + * kernel exception vector, and the fact that historically + * the vector is limited to 12 bytes, the size of this + * stack frame is limited to 128 bytes (currently at 64). + */ +STRUCT_BEGIN +STRUCT_FIELD (long,4,KEXC_,pc) /* "parm" */ +STRUCT_FIELD (long,4,KEXC_,ps) +STRUCT_AFIELD(long,4,KEXC_,areg, 4) /* a12 .. a15 */ +STRUCT_FIELD (long,4,KEXC_,sar) /* "save" */ +#if XCHAL_HAVE_LOOPS +STRUCT_FIELD (long,4,KEXC_,lcount) +STRUCT_FIELD (long,4,KEXC_,lbeg) +STRUCT_FIELD (long,4,KEXC_,lend) +#endif +#if XCHAL_HAVE_MAC16 +STRUCT_FIELD (long,4,KEXC_,acclo) +STRUCT_FIELD (long,4,KEXC_,acchi) +STRUCT_AFIELD(long,4,KEXC_,mr, 4) +#endif +STRUCT_END(KernelFrame) + + +/* + * User vector mode exception stack frame: + * + * WARNING: if you modify this structure, you MUST modify the + * computation of the pad size (ALIGNPAD) accordingly. + */ +STRUCT_BEGIN +STRUCT_FIELD (long,4,UEXC_,pc) +STRUCT_FIELD (long,4,UEXC_,ps) +STRUCT_FIELD (long,4,UEXC_,sar) +STRUCT_FIELD (long,4,UEXC_,vpri) +#ifdef __XTENSA_CALL0_ABI__ +STRUCT_FIELD (long,4,UEXC_,a0) +#endif +STRUCT_FIELD (long,4,UEXC_,a2) +STRUCT_FIELD (long,4,UEXC_,a3) +STRUCT_FIELD (long,4,UEXC_,a4) +STRUCT_FIELD (long,4,UEXC_,a5) +#ifdef __XTENSA_CALL0_ABI__ +STRUCT_FIELD (long,4,UEXC_,a6) +STRUCT_FIELD (long,4,UEXC_,a7) +STRUCT_FIELD (long,4,UEXC_,a8) +STRUCT_FIELD (long,4,UEXC_,a9) +STRUCT_FIELD (long,4,UEXC_,a10) +STRUCT_FIELD (long,4,UEXC_,a11) +STRUCT_FIELD (long,4,UEXC_,a12) +STRUCT_FIELD (long,4,UEXC_,a13) +STRUCT_FIELD (long,4,UEXC_,a14) +STRUCT_FIELD (long,4,UEXC_,a15) +#endif +STRUCT_FIELD (long,4,UEXC_,exccause) /* NOTE: can probably rid of this one (pass direct) */ +#if XCHAL_HAVE_LOOPS +STRUCT_FIELD (long,4,UEXC_,lcount) +STRUCT_FIELD (long,4,UEXC_,lbeg) +STRUCT_FIELD (long,4,UEXC_,lend) +#endif +#if XCHAL_HAVE_MAC16 +STRUCT_FIELD (long,4,UEXC_,acclo) +STRUCT_FIELD (long,4,UEXC_,acchi) +STRUCT_AFIELD(long,4,UEXC_,mr, 4) +#endif +/* ALIGNPAD is the 16-byte alignment padding. */ +#ifdef __XTENSA_CALL0_ABI__ +# define CALL0_ABI 1 +#else +# define CALL0_ABI 0 +#endif +#define ALIGNPAD ((3 + XCHAL_HAVE_LOOPS*1 + XCHAL_HAVE_MAC16*2 + CALL0_ABI*1) & 3) +#if ALIGNPAD +STRUCT_AFIELD(long,4,UEXC_,pad, ALIGNPAD) /* 16-byte alignment padding */ +#endif +/*STRUCT_AFIELD(char,1,UEXC_,ureg, (XCHAL_CPEXTRA_SA_SIZE_TOR2+3)&-4)*/ /* not used, and doesn't take alignment into account */ +STRUCT_END(UserFrame) + + +#if defined(_ASMLANGUAGE) || defined(__ASSEMBLER__) + + +/* Check for UserFrameSize small enough not to require rounding...: */ + /* Skip 16-byte save area, then 32-byte space for 8 regs of call12 + * (which overlaps with 16-byte GCC nested func chaining area), + * then exception stack frame: */ + .set UserFrameTotalSize, 16+32+UserFrameSize + /* Greater than 112 bytes? (max range of ADDI, both signs, when aligned to 16 bytes): */ + .ifgt UserFrameTotalSize-112 + /* Round up to 256-byte multiple to accelerate immediate adds: */ + .set UserFrameTotalSize, ((UserFrameTotalSize+255) & 0xFFFFFF00) + .endif +# define ESF_TOTALSIZE UserFrameTotalSize + +#endif /* _ASMLANGUAGE || __ASSEMBLER__ */ + + +#if XCHAL_NUM_CONTEXTS > 1 +/* Structure of info stored on new context's stack for setup: */ +STRUCT_BEGIN +STRUCT_FIELD (long,4,INFO_,sp) +STRUCT_FIELD (long,4,INFO_,arg1) +STRUCT_FIELD (long,4,INFO_,funcpc) +STRUCT_FIELD (long,4,INFO_,prevps) +STRUCT_END(SetupInfo) +#endif + + +#define KERNELSTACKSIZE 1024 + + +#endif /* _XTRUNTIME_FRAMES_H_ */ + diff --git a/Sming/Arch/Esp8266/Platform/RTC.cpp b/Sming/Arch/Esp8266/Platform/RTC.cpp index 0a39e0be69..832f604443 100644 --- a/Sming/Arch/Esp8266/Platform/RTC.cpp +++ b/Sming/Arch/Esp8266/Platform/RTC.cpp @@ -1,85 +1,85 @@ -/**** - * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. - * Created 2015 by Skurydin Alexey - * http://github.com/anakod/Sming - * All files of the Sming Core are provided under the LGPL v3 license. - * - * RTC.cpp - * - ****/ - -#include "Platform/RTC.h" - -RtcClass::RtcClass() -{ - rst_info* info = system_get_rst_info(); - hardwareReset = (info->reason == REASON_WDT_RST); -} - -uint64_t RtcClass::getRtcNanoseconds() -{ - RtcData rtcTime; - loadTime(rtcTime); - updateTime(rtcTime); - saveTime(rtcTime); - return rtcTime.time; -} - -uint32_t RtcClass::getRtcSeconds() -{ - return (getRtcNanoseconds() / NS_PER_SECOND); -} - -bool RtcClass::setRtcNanoseconds(uint64_t nanoseconds) -{ - RtcData rtcTime; - loadTime(rtcTime); - updateTime(rtcTime); - rtcTime.time = nanoseconds; - return saveTime(rtcTime); -} - -bool RtcClass::setRtcSeconds(uint32_t seconds) -{ - return setRtcNanoseconds((uint64_t)seconds * NS_PER_SECOND); -} - -void RtcClass::updateTime(RtcData& data) -{ - uint32 rtc_cycles; - uint32 cal, cal1, cal2; - cal1 = system_rtc_clock_cali_proc(); - __asm__ __volatile__("memw" : : : "memory"); // Just for fun - cal2 = system_rtc_clock_cali_proc(); - cal = (cal1 + cal2) / 2; // get average cal in case one is out - rtc_cycles = system_get_rtc_time(); - - // hardware reset causes rtc cycles to start at 0 so we need to check and act accordingly - uint32_t delta = hardwareReset ? rtc_cycles : rtc_cycles - data.cycles; - - // reset hardware flag so we can deal with the next overflow as a reset needs to be dealt differently - hardwareReset = false; - // increment number of nano seconds that have elapsed since last update - data.time += delta * ((uint64)((cal * 1000) >> 12)); - // update last number of cycles - data.cycles = rtc_cycles; -} - -bool RtcClass::saveTime(RtcData& data) -{ - return system_rtc_mem_write(RTC_DES_ADDR, &data, sizeof(data)); -} -void RtcClass::loadTime(RtcData& data) -{ - system_rtc_mem_read(RTC_DES_ADDR, &data, sizeof(data)); - - // Initialise the time struct - if(data.magic != RTC_MAGIC) { - debugf("rtc time init..."); - data.magic = RTC_MAGIC; - data.time = 0; - data.cycles = 0; - } -} - -RtcClass RTC = RtcClass(); +/**** + * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. + * Created 2015 by Skurydin Alexey + * http://github.com/anakod/Sming + * All files of the Sming Core are provided under the LGPL v3 license. + * + * RTC.cpp + * + ****/ + +#include "Platform/RTC.h" + +RtcClass::RtcClass() +{ + rst_info* info = system_get_rst_info(); + hardwareReset = (info->reason == REASON_WDT_RST); +} + +uint64_t RtcClass::getRtcNanoseconds() +{ + RtcData rtcTime; + loadTime(rtcTime); + updateTime(rtcTime); + saveTime(rtcTime); + return rtcTime.time; +} + +uint32_t RtcClass::getRtcSeconds() +{ + return (getRtcNanoseconds() / NS_PER_SECOND); +} + +bool RtcClass::setRtcNanoseconds(uint64_t nanoseconds) +{ + RtcData rtcTime; + loadTime(rtcTime); + updateTime(rtcTime); + rtcTime.time = nanoseconds; + return saveTime(rtcTime); +} + +bool RtcClass::setRtcSeconds(uint32_t seconds) +{ + return setRtcNanoseconds((uint64_t)seconds * NS_PER_SECOND); +} + +void RtcClass::updateTime(RtcData& data) +{ + uint32 rtc_cycles; + uint32 cal, cal1, cal2; + cal1 = system_rtc_clock_cali_proc(); + __asm__ __volatile__("memw" : : : "memory"); // Just for fun + cal2 = system_rtc_clock_cali_proc(); + cal = (cal1 + cal2) / 2; // get average cal in case one is out + rtc_cycles = system_get_rtc_time(); + + // hardware reset causes rtc cycles to start at 0 so we need to check and act accordingly + uint32_t delta = hardwareReset ? rtc_cycles : rtc_cycles - data.cycles; + + // reset hardware flag so we can deal with the next overflow as a reset needs to be dealt differently + hardwareReset = false; + // increment number of nano seconds that have elapsed since last update + data.time += delta * ((uint64)((cal * 1000) >> 12)); + // update last number of cycles + data.cycles = rtc_cycles; +} + +bool RtcClass::saveTime(RtcData& data) +{ + return system_rtc_mem_write(RTC_DES_ADDR, &data, sizeof(data)); +} +void RtcClass::loadTime(RtcData& data) +{ + system_rtc_mem_read(RTC_DES_ADDR, &data, sizeof(data)); + + // Initialise the time struct + if(data.magic != RTC_MAGIC) { + debugf("rtc time init..."); + data.magic = RTC_MAGIC; + data.time = 0; + data.cycles = 0; + } +} + +RtcClass RTC = RtcClass(); diff --git a/Sming/Arch/Esp8266/Platform/WifiSniffer.cpp b/Sming/Arch/Esp8266/Platform/WifiSniffer.cpp index cc5a0510f3..77320e45a0 100644 --- a/Sming/Arch/Esp8266/Platform/WifiSniffer.cpp +++ b/Sming/Arch/Esp8266/Platform/WifiSniffer.cpp @@ -1,176 +1,176 @@ -/**** - * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. - * Created 2015 by Skurydin Alexey - * http://github.com/anakod/Sming - * All files of the Sming Core are provided under the LGPL v3 license. - * - * WifiSniffer.cpp - * - * Original code by Ray Burnette http://www.hackster.io/rayburne/projects - * - * Adapted for use with Sming March 2019 mikee47 - * - ****/ - -#include "Platform/WifiSniffer.h" -#include "esp_wifi_sniffer.h" - -WifiSnifferCallback WifiSniffer::snifferCallback; -WifiBeaconCallback WifiSniffer::beaconCallback; -WifiClientCallback WifiSniffer::clientCallback; - -static const uint8_t broadcast1[3] = {0x01, 0x00, 0x5e}; -static const uint8_t broadcast2[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; -static const uint8_t broadcast3[3] = {0x33, 0x33, 0x00}; - -static void parseClientInfo(ClientInfo& ci, uint8_t* frame, uint16_t framelen, int rssi, unsigned channel) -{ - ci.channel = channel; - ci.err = 0; - ci.rssi = rssi; - - uint8_t* bssid; - uint8_t* station; - uint8_t* ap; - - uint8_t ds = frame[1] & 3; - switch(ds) { - // p[1] - xxxx xx00 => NoDS p[4]-DST p[10]-SRC p[16]-BSS - case 0: - bssid = frame + 16; - station = frame + 10; - ap = frame + 4; - break; - // p[1] - xxxx xx01 => ToDS p[4]-BSS p[10]-SRC p[16]-DST - case 1: - bssid = frame + 4; - station = frame + 10; - ap = frame + 16; - break; - // p[1] - xxxx xx10 => FromDS p[4]-DST p[10]-BSS p[16]-SRC - case 2: - bssid = frame + 10; - // hack - don't know why it works like this... - if(memcmp(frame + 4, broadcast1, 3) || memcmp(frame + 4, broadcast2, 3) || memcmp(frame + 4, broadcast3, 3)) { - station = frame + 16; - ap = frame + 4; - } else { - station = frame + 4; - ap = frame + 16; - } - break; - // p[1] - xxxx xx11 => WDS p[4]-RCV p[10]-TRM p[16]-DST p[26]-SRC - case 3: - default: - bssid = frame + 10; - station = frame + 4; - ap = frame + 4; - break; - } - - memcpy(ci.station, station, ETH_MAC_LEN); - memcpy(ci.bssid, bssid, ETH_MAC_LEN); - memcpy(ci.ap, ap, ETH_MAC_LEN); - - ci.seq_n = (frame[23] * 0xFF) + (frame[22] & 0xF0); -} - -static void parseBeaconInfo(BeaconInfo& bi, uint8_t* frame, uint16_t framelen, int rssi) -{ - bi.ssid_len = 0; - bi.channel = 0; - bi.err = 0; - bi.rssi = rssi; - int pos = 36; - - if(frame[pos] == 0x00) { - while(pos < framelen) { - switch(frame[pos]) { - case 0x00: //SSID - bi.ssid_len = (int)frame[pos + 1]; - if(bi.ssid_len == 0) { - memset(bi.ssid, '\0', sizeof(bi.ssid)); - break; - } - if(bi.ssid_len < 0) { - bi.err = -1; - break; - } - if(bi.ssid_len > 32) { - bi.err = -2; - break; - } - memset(bi.ssid, '\0', sizeof(bi.ssid)); - memcpy(bi.ssid, frame + pos + 2, bi.ssid_len); - bi.err = 0; // before was error?? - break; - case 0x03: //Channel - bi.channel = (int)frame[pos + 2]; - pos = -1; - break; - default: - break; - } - if(pos < 0) - break; - pos += (int)frame[pos + 1] + 2; - } - } else { - bi.err = -3; - } - - bi.capa[0] = frame[34]; - bi.capa[1] = frame[35]; - memcpy(bi.bssid, frame + 10, ETH_MAC_LEN); -} - -void WifiSniffer::parseData(uint8_t* buf, uint16_t len) -{ - if(snifferCallback) { - snifferCallback(buf, len); - } - - if(len == 12) { - //auto data = reinterpret_cast(buf); - } else if(len == 128) { - if(beaconCallback) { - auto data = reinterpret_cast(buf); - BeaconInfo beacon; - parseBeaconInfo(beacon, data->buf, 112, data->rx_ctrl.rssi); - beaconCallback(beacon); - } - } else { - auto data = reinterpret_cast(buf); - //Is data or QOS? - if(data->buf[0] == 0x08 || data->buf[0] == 0x88) { - if(clientCallback) { - ClientInfo ci; - parseClientInfo(ci, data->buf, 36, data->rx_ctrl.rssi, data->rx_ctrl.channel); - // Check BSSID and station don't match (why ?) - if(memcmp(ci.bssid, ci.station, ETH_MAC_LEN) != 0) { - clientCallback(ci); - } - } - } - } -} - -void WifiSniffer::begin() -{ - wifi_set_opmode_current(STATION_MODE); // Promiscuous works only with station mode - System.onReady(this); -} - -void WifiSniffer::onSystemReady() -{ - // Set up promiscuous callback - wifi_station_disconnect(); // As per Espressif docs. - wifi_promiscuous_enable(false); - wifi_set_promiscuous_rx_cb(parseData); - wifi_promiscuous_enable(true); -} - -void WifiSniffer::end() -{ - wifi_promiscuous_enable(false); -} +/**** + * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. + * Created 2015 by Skurydin Alexey + * http://github.com/anakod/Sming + * All files of the Sming Core are provided under the LGPL v3 license. + * + * WifiSniffer.cpp + * + * Original code by Ray Burnette http://www.hackster.io/rayburne/projects + * + * Adapted for use with Sming March 2019 mikee47 + * + ****/ + +#include "Platform/WifiSniffer.h" +#include "esp_wifi_sniffer.h" + +WifiSnifferCallback WifiSniffer::snifferCallback; +WifiBeaconCallback WifiSniffer::beaconCallback; +WifiClientCallback WifiSniffer::clientCallback; + +static const uint8_t broadcast1[3] = {0x01, 0x00, 0x5e}; +static const uint8_t broadcast2[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; +static const uint8_t broadcast3[3] = {0x33, 0x33, 0x00}; + +static void parseClientInfo(ClientInfo& ci, uint8_t* frame, uint16_t framelen, int rssi, unsigned channel) +{ + ci.channel = channel; + ci.err = 0; + ci.rssi = rssi; + + uint8_t* bssid; + uint8_t* station; + uint8_t* ap; + + uint8_t ds = frame[1] & 3; + switch(ds) { + // p[1] - xxxx xx00 => NoDS p[4]-DST p[10]-SRC p[16]-BSS + case 0: + bssid = frame + 16; + station = frame + 10; + ap = frame + 4; + break; + // p[1] - xxxx xx01 => ToDS p[4]-BSS p[10]-SRC p[16]-DST + case 1: + bssid = frame + 4; + station = frame + 10; + ap = frame + 16; + break; + // p[1] - xxxx xx10 => FromDS p[4]-DST p[10]-BSS p[16]-SRC + case 2: + bssid = frame + 10; + // hack - don't know why it works like this... + if(memcmp(frame + 4, broadcast1, 3) || memcmp(frame + 4, broadcast2, 3) || memcmp(frame + 4, broadcast3, 3)) { + station = frame + 16; + ap = frame + 4; + } else { + station = frame + 4; + ap = frame + 16; + } + break; + // p[1] - xxxx xx11 => WDS p[4]-RCV p[10]-TRM p[16]-DST p[26]-SRC + case 3: + default: + bssid = frame + 10; + station = frame + 4; + ap = frame + 4; + break; + } + + memcpy(ci.station, station, ETH_MAC_LEN); + memcpy(ci.bssid, bssid, ETH_MAC_LEN); + memcpy(ci.ap, ap, ETH_MAC_LEN); + + ci.seq_n = (frame[23] * 0xFF) + (frame[22] & 0xF0); +} + +static void parseBeaconInfo(BeaconInfo& bi, uint8_t* frame, uint16_t framelen, int rssi) +{ + bi.ssid_len = 0; + bi.channel = 0; + bi.err = 0; + bi.rssi = rssi; + int pos = 36; + + if(frame[pos] == 0x00) { + while(pos < framelen) { + switch(frame[pos]) { + case 0x00: //SSID + bi.ssid_len = (int)frame[pos + 1]; + if(bi.ssid_len == 0) { + memset(bi.ssid, '\0', sizeof(bi.ssid)); + break; + } + if(bi.ssid_len < 0) { + bi.err = -1; + break; + } + if(bi.ssid_len > 32) { + bi.err = -2; + break; + } + memset(bi.ssid, '\0', sizeof(bi.ssid)); + memcpy(bi.ssid, frame + pos + 2, bi.ssid_len); + bi.err = 0; // before was error?? + break; + case 0x03: //Channel + bi.channel = (int)frame[pos + 2]; + pos = -1; + break; + default: + break; + } + if(pos < 0) + break; + pos += (int)frame[pos + 1] + 2; + } + } else { + bi.err = -3; + } + + bi.capa[0] = frame[34]; + bi.capa[1] = frame[35]; + memcpy(bi.bssid, frame + 10, ETH_MAC_LEN); +} + +void WifiSniffer::parseData(uint8_t* buf, uint16_t len) +{ + if(snifferCallback) { + snifferCallback(buf, len); + } + + if(len == 12) { + //auto data = reinterpret_cast(buf); + } else if(len == 128) { + if(beaconCallback) { + auto data = reinterpret_cast(buf); + BeaconInfo beacon; + parseBeaconInfo(beacon, data->buf, 112, data->rx_ctrl.rssi); + beaconCallback(beacon); + } + } else { + auto data = reinterpret_cast(buf); + //Is data or QOS? + if(data->buf[0] == 0x08 || data->buf[0] == 0x88) { + if(clientCallback) { + ClientInfo ci; + parseClientInfo(ci, data->buf, 36, data->rx_ctrl.rssi, data->rx_ctrl.channel); + // Check BSSID and station don't match (why ?) + if(memcmp(ci.bssid, ci.station, ETH_MAC_LEN) != 0) { + clientCallback(ci); + } + } + } + } +} + +void WifiSniffer::begin() +{ + wifi_set_opmode_current(STATION_MODE); // Promiscuous works only with station mode + System.onReady(this); +} + +void WifiSniffer::onSystemReady() +{ + // Set up promiscuous callback + wifi_station_disconnect(); // As per Espressif docs. + wifi_promiscuous_enable(false); + wifi_set_promiscuous_rx_cb(parseData); + wifi_promiscuous_enable(true); +} + +void WifiSniffer::end() +{ + wifi_promiscuous_enable(false); +} diff --git a/Sming/Core/Data/Buffer/LineBuffer.h b/Sming/Core/Data/Buffer/LineBuffer.h index 2ce0f6172f..88dd6cf62a 100644 --- a/Sming/Core/Data/Buffer/LineBuffer.h +++ b/Sming/Core/Data/Buffer/LineBuffer.h @@ -1,114 +1,114 @@ -/**** - * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. - * Created 2015 by Skurydin Alexey - * http://github.com/SmingHub/Sming - * All files of the Sming Core are provided under the LGPL v3 license. - * - * LineBuffer.h - support for buffering/editing a line of text - * - * author mikee47 Feb 2019 - * - ****/ - -#pragma once - -#include - -/** - * @brief Class to enable buffering of a single line of text, with simple editing - * @note We define this as a template class for simplicity, no need for separate buffer memory management - */ -template class LineBuffer -{ -public: - /** - * @brief Add a character to the buffer - * @retval char Character added to buffer, '\0' if ignored, '\n' if line is complete - */ - char addChar(char c); - - /** - * @brief Clear contents of buffer - */ - void clear() - { - length = 0; - } - - /** - * @brief Get the text, nul-terminated - */ - char* getBuffer() - { - return buffer; - } - - /** - * @brief Get number of characters in the text line - */ - unsigned getLength() const - { - return length; - } - - /** - * @brief Check for matching text at start of line, case-sensitive - * @param text - * @retval bool true if match found - */ - bool startsWith(const char* text) const; - - /** - * @brief Check for matching text anywhere in line, case-sensitive - * @param text - * @retval bool true if match found - */ - bool contains(const char* text) const; - - /** - * @brief Remove last character from buffer - * @retval bool true if character was removed, false if buffer is empty - */ - bool backspace(); - -private: - char buffer[BUFSIZE] = {'\0'}; ///< The text buffer - uint16_t length = 0; ///< Number of characters stored -}; - -template char LineBuffer::addChar(char c) -{ - if(c == '\n' || c == '\r') { - return '\n'; - } - - if(c >= 0x20 && c < 0x7f && length < (BUFSIZE - 1)) { - buffer[length++] = c; - buffer[length] = '\0'; - return c; - } - - return '\0'; -} - -template bool LineBuffer::backspace() -{ - if(length == 0) { - return false; - } else { - --length; - buffer[length] = '\0'; - return true; - } -} - -template bool LineBuffer::startsWith(const char* text) const -{ - auto len = strlen(text); - return memcmp(buffer, text, len) == 0; -} - -template bool LineBuffer::contains(const char* text) const -{ - return strstr(buffer, text) != nullptr; -} +/**** + * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. + * Created 2015 by Skurydin Alexey + * http://github.com/SmingHub/Sming + * All files of the Sming Core are provided under the LGPL v3 license. + * + * LineBuffer.h - support for buffering/editing a line of text + * + * author mikee47 Feb 2019 + * + ****/ + +#pragma once + +#include + +/** + * @brief Class to enable buffering of a single line of text, with simple editing + * @note We define this as a template class for simplicity, no need for separate buffer memory management + */ +template class LineBuffer +{ +public: + /** + * @brief Add a character to the buffer + * @retval char Character added to buffer, '\0' if ignored, '\n' if line is complete + */ + char addChar(char c); + + /** + * @brief Clear contents of buffer + */ + void clear() + { + length = 0; + } + + /** + * @brief Get the text, nul-terminated + */ + char* getBuffer() + { + return buffer; + } + + /** + * @brief Get number of characters in the text line + */ + unsigned getLength() const + { + return length; + } + + /** + * @brief Check for matching text at start of line, case-sensitive + * @param text + * @retval bool true if match found + */ + bool startsWith(const char* text) const; + + /** + * @brief Check for matching text anywhere in line, case-sensitive + * @param text + * @retval bool true if match found + */ + bool contains(const char* text) const; + + /** + * @brief Remove last character from buffer + * @retval bool true if character was removed, false if buffer is empty + */ + bool backspace(); + +private: + char buffer[BUFSIZE] = {'\0'}; ///< The text buffer + uint16_t length = 0; ///< Number of characters stored +}; + +template char LineBuffer::addChar(char c) +{ + if(c == '\n' || c == '\r') { + return '\n'; + } + + if(c >= 0x20 && c < 0x7f && length < (BUFSIZE - 1)) { + buffer[length++] = c; + buffer[length] = '\0'; + return c; + } + + return '\0'; +} + +template bool LineBuffer::backspace() +{ + if(length == 0) { + return false; + } else { + --length; + buffer[length] = '\0'; + return true; + } +} + +template bool LineBuffer::startsWith(const char* text) const +{ + auto len = strlen(text); + return memcmp(buffer, text, len) == 0; +} + +template bool LineBuffer::contains(const char* text) const +{ + return strstr(buffer, text) != nullptr; +} diff --git a/Sming/Core/Data/Buffer/SerialBuffer.cpp b/Sming/Core/Data/Buffer/SerialBuffer.cpp index 10d95d2da0..8bf0a7fbfd 100644 --- a/Sming/Core/Data/Buffer/SerialBuffer.cpp +++ b/Sming/Core/Data/Buffer/SerialBuffer.cpp @@ -1,66 +1,66 @@ -/**** - * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. - * Created 2015 by Skurydin Alexey - * http://github.com/anakod/Sming - * All files of the Sming Core are provided under the LGPL v3 license. - * - * SerialBuffer.cpp - * - * @author 22 Aug 2018 - mikee47 - * - ****/ - -#include "SerialBuffer.h" - -/** @brief find a character in the buffer - * @param c - * @retval int position relative to current read pointer, -1 if character not found - */ -int SerialBuffer::find(uint8_t c) -{ - size_t offset = readPos; - size_t pos = 0; - size_t avail = available(); - while(pos < avail) { - if(buffer[offset + pos] == c) { - return pos; - } - - pos++; - if(pos + offset == writePos) { - break; - } - - if(pos + offset == size) { - offset = -pos; - } - } - - return -1; -} - -// Must be called with interrupts disabled -size_t SerialBuffer::resize(size_t newSize) -{ - if(size == newSize) { - return size; - } - - auto new_buf = new char[newSize]; - if(new_buf == nullptr) { - return size; - } - - size_t new_wpos = 0; - size_t avail = available(); - while(avail-- && new_wpos < newSize) { - new_buf[new_wpos++] = readChar(); - } - - delete[] buffer; - buffer = new_buf; - size = newSize; - readPos = 0; - writePos = new_wpos; - return size; -} +/**** + * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. + * Created 2015 by Skurydin Alexey + * http://github.com/anakod/Sming + * All files of the Sming Core are provided under the LGPL v3 license. + * + * SerialBuffer.cpp + * + * @author 22 Aug 2018 - mikee47 + * + ****/ + +#include "SerialBuffer.h" + +/** @brief find a character in the buffer + * @param c + * @retval int position relative to current read pointer, -1 if character not found + */ +int SerialBuffer::find(uint8_t c) +{ + size_t offset = readPos; + size_t pos = 0; + size_t avail = available(); + while(pos < avail) { + if(buffer[offset + pos] == c) { + return pos; + } + + pos++; + if(pos + offset == writePos) { + break; + } + + if(pos + offset == size) { + offset = -pos; + } + } + + return -1; +} + +// Must be called with interrupts disabled +size_t SerialBuffer::resize(size_t newSize) +{ + if(size == newSize) { + return size; + } + + auto new_buf = new char[newSize]; + if(new_buf == nullptr) { + return size; + } + + size_t new_wpos = 0; + size_t avail = available(); + while(avail-- && new_wpos < newSize) { + new_buf[new_wpos++] = readChar(); + } + + delete[] buffer; + buffer = new_buf; + size = newSize; + readPos = 0; + writePos = new_wpos; + return size; +} diff --git a/Sming/Core/Data/Buffer/SerialBuffer.h b/Sming/Core/Data/Buffer/SerialBuffer.h index d98b5551da..06b9cebaa3 100644 --- a/Sming/Core/Data/Buffer/SerialBuffer.h +++ b/Sming/Core/Data/Buffer/SerialBuffer.h @@ -1,166 +1,166 @@ -/**** - * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. - * Created 2015 by Skurydin Alexey - * http://github.com/anakod/Sming - * All files of the Sming Core are provided under the LGPL v3 license. - * - * SerialBuffer.h - * - * @author 22 Aug 2018 - mikee47 - * - ****/ - -#pragma once - -#include - -/** @brief FIFO buffer used for both receive and transmit data - * @note For receive operations, data is written via ISR and read via task - * For transmit operations, data is written via task and read via ISR - * Only routines marked with __forceinline or IRAM_ATTR may be called from interrupt context. - */ -struct SerialBuffer { -public: - ~SerialBuffer() - { - delete buffer; - } - - size_t getSize() - { - return size; - } - - /** @brief get number of bytes stored in the buffer - * @retval size_t - */ - __forceinline size_t available() - { - int ret = writePos - readPos; - if(ret < 0) { - ret += size; - } - return ret; - } - - /** @brief get number of bytes of space available in this buffer - * @retval size_t - */ - __forceinline size_t getFreeSpace() - { - if(buffer == nullptr) { - return 0; - } - int ret = readPos - writePos - 1; - if(ret < 0) { - ret += size; - } - return ret; - } - - __forceinline bool isEmpty() - { - return (buffer == nullptr) || (writePos == readPos); - } - - __forceinline bool isFull() - { - return getFreeSpace() == 0; - } - - /** @brief see if there's anything in the buffer - * @retval int first available character, or -1 if buffer's empty - */ - __forceinline int peekChar() - { - return isEmpty() ? -1 : buffer[readPos]; - } - - /* - * Take a peek at the last character written into the buffer - */ - __forceinline int peekLastChar() - { - return isEmpty() ? -1 : buffer[getPrevPos(writePos)]; - } - - __forceinline int readChar() - { - if(isEmpty()) { - return -1; - } - - uint8_t c = buffer[readPos]; - readPos = getNextPos(readPos); - return c; - } - - __forceinline size_t writeChar(uint8_t c) - { - size_t nextPos = getNextPos(writePos); - if(nextPos == readPos) { - return 0; - } - - buffer[writePos] = c; - writePos = nextPos; - return 1; - } - - /** @brief find a character in the buffer - * @param c - * @retval int position relative to current read pointer, -1 if character not found - */ - int find(uint8_t c); - - // Must be called with interrupts disabled - size_t resize(size_t newSize); - - void clear() - { - readPos = writePos = 0; - } - - /** @brief Access data directly within buffer - * @param void*& OUT: the data - * @retval size_t number of chars available - */ - __forceinline size_t getReadData(void*& data) - { - data = buffer + readPos; - auto wp = writePos; // Guard against ISR changing value - return (wp < readPos) ? size - readPos : wp - readPos; - } - - /** @brief Skip a number of chars starting at the given read position - * @param length MUST be <= value returned from peek() - * @note Provided for efficient buffer access - */ - __forceinline void skipRead(size_t length) - { - readPos += length; - if(readPos == size) { - readPos = 0; - } - } - -private: - /** @brief Get the offset for the position before the current one */ - __forceinline size_t getNextPos(size_t pos) - { - size_t n = pos + 1; - return (n == size) ? 0 : n; - } - - /** @brief Get the offset for the position after the current one */ - __forceinline size_t getPrevPos(size_t pos) - { - return (pos != 0 ? pos : size) - 1; - } - -private: - size_t size = 0; - size_t readPos = 0; - size_t writePos = 0; - char* buffer = nullptr; -}; +/**** + * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. + * Created 2015 by Skurydin Alexey + * http://github.com/anakod/Sming + * All files of the Sming Core are provided under the LGPL v3 license. + * + * SerialBuffer.h + * + * @author 22 Aug 2018 - mikee47 + * + ****/ + +#pragma once + +#include + +/** @brief FIFO buffer used for both receive and transmit data + * @note For receive operations, data is written via ISR and read via task + * For transmit operations, data is written via task and read via ISR + * Only routines marked with __forceinline or IRAM_ATTR may be called from interrupt context. + */ +struct SerialBuffer { +public: + ~SerialBuffer() + { + delete buffer; + } + + size_t getSize() + { + return size; + } + + /** @brief get number of bytes stored in the buffer + * @retval size_t + */ + __forceinline size_t available() + { + int ret = writePos - readPos; + if(ret < 0) { + ret += size; + } + return ret; + } + + /** @brief get number of bytes of space available in this buffer + * @retval size_t + */ + __forceinline size_t getFreeSpace() + { + if(buffer == nullptr) { + return 0; + } + int ret = readPos - writePos - 1; + if(ret < 0) { + ret += size; + } + return ret; + } + + __forceinline bool isEmpty() + { + return (buffer == nullptr) || (writePos == readPos); + } + + __forceinline bool isFull() + { + return getFreeSpace() == 0; + } + + /** @brief see if there's anything in the buffer + * @retval int first available character, or -1 if buffer's empty + */ + __forceinline int peekChar() + { + return isEmpty() ? -1 : buffer[readPos]; + } + + /* + * Take a peek at the last character written into the buffer + */ + __forceinline int peekLastChar() + { + return isEmpty() ? -1 : buffer[getPrevPos(writePos)]; + } + + __forceinline int readChar() + { + if(isEmpty()) { + return -1; + } + + uint8_t c = buffer[readPos]; + readPos = getNextPos(readPos); + return c; + } + + __forceinline size_t writeChar(uint8_t c) + { + size_t nextPos = getNextPos(writePos); + if(nextPos == readPos) { + return 0; + } + + buffer[writePos] = c; + writePos = nextPos; + return 1; + } + + /** @brief find a character in the buffer + * @param c + * @retval int position relative to current read pointer, -1 if character not found + */ + int find(uint8_t c); + + // Must be called with interrupts disabled + size_t resize(size_t newSize); + + void clear() + { + readPos = writePos = 0; + } + + /** @brief Access data directly within buffer + * @param void*& OUT: the data + * @retval size_t number of chars available + */ + __forceinline size_t getReadData(void*& data) + { + data = buffer + readPos; + auto wp = writePos; // Guard against ISR changing value + return (wp < readPos) ? size - readPos : wp - readPos; + } + + /** @brief Skip a number of chars starting at the given read position + * @param length MUST be <= value returned from peek() + * @note Provided for efficient buffer access + */ + __forceinline void skipRead(size_t length) + { + readPos += length; + if(readPos == size) { + readPos = 0; + } + } + +private: + /** @brief Get the offset for the position before the current one */ + __forceinline size_t getNextPos(size_t pos) + { + size_t n = pos + 1; + return (n == size) ? 0 : n; + } + + /** @brief Get the offset for the position after the current one */ + __forceinline size_t getPrevPos(size_t pos) + { + return (pos != 0 ? pos : size) - 1; + } + +private: + size_t size = 0; + size_t readPos = 0; + size_t writePos = 0; + char* buffer = nullptr; +}; diff --git a/Sming/Core/Data/ObjectMap.h b/Sming/Core/Data/ObjectMap.h index e679ce31e8..719b63ae23 100644 --- a/Sming/Core/Data/ObjectMap.h +++ b/Sming/Core/Data/ObjectMap.h @@ -1,341 +1,341 @@ -/**** - * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. - * Created 2015 by Skurydin Alexey - * http://github.com/SmingHub/Sming - * All files of the Sming Core are provided under the LGPL v3 license. - * - * ObjectMap.h - * - * @author: 31 Jul 2018 - Mikee47 - * - */ - -#pragma once - -#include "WVector.h" - -/** - * @brief Implementation of a HashMap for owned objects, i.e. anything created with new(). - * @note Once added to the map the object is destroyed when no longer required. - * - * Example: - * - * ``` - * void test() - * { - * ObjectMap map; - * MyType* object1 = new MyType(); - * if (map["key1"] == nullptr) { // Does NOT create entry in map - * map["key1"] = object1; // Entry now created, "key1" -> object1 - * } - * MyType* object2 = new MyType(); - * map["key1"] = object2; // object1 is destroyed, "key1" -> object2 - * - * // Demonstrate use of value reference - * auto value = map["key1"]; // Returns ObjectMap::Value object - * value = new MyType(); // "key1" -> new object - * value = nullptr; // Free object, "key1" -> nullptr (but still in map) - * value.remove(); // Free object1 and remove from map - * - * // As soon as `map` goes out of scope, all contained objects are detroyed - * map["key1"] = new MyType(); - * map["key2"] = new MyType(); - * } - * ``` - * - */ -template class ObjectMap -{ -public: - ObjectMap() - { - } - - ~ObjectMap() - { - clear(); - } - - /** - * @brief Class to provide safe access to mapped value - * @note ObjectMap `operator[]` returns one of these, which provides behaviour consistent with V* - */ - class Value - { - public: - Value(ObjectMap& map, const K& key) : map(map), key(key) - { - } - - const K& getKey() const - { - return key; - } - - V* getValue() const - { - return map.find(key); - } - - Value& operator=(V* newValue) - { - map.set(key, newValue); - return *this; - } - - operator V*() const - { - return getValue(); - } - - V* operator->() const - { - return getValue(); - } - - /** - * @brief Remove this value from the map - * @retval bool true if the value was found and removed - */ - bool remove() - { - return map.remove(key); - } - - /** - * @brief Get the value for a given key and remove it from the map, without destroying it - * @retval V* - * @note The returned object must be freed by the caller when no longer required - */ - V* extract() - { - return map.extract(key); - } - - private: - ObjectMap& map; - K key; - }; - - /** - * @brief Get the number of entries in this map - * @retval int Entry count - */ - unsigned count() const - { - return entries.count(); - } - - /* - * @brief Get a key at a specified index, non-modifiable - * @param idx the index to get the key at - * @return The key at index idx - */ - const K& keyAt(unsigned idx) const - { - return entries[idx].key; - } - - /* - * @brief Get a key at a specified index - * @param idx the index to get the key at - * @return Reference to the key at index idx - */ - K& keyAt(unsigned idx) - { - return entries[idx].key; - } - - /* - * @brief Get a value at a specified index, non-modifiable - * @param idx the index to get the value at - * @retval The value at index idx - * @note The caller must not use `delete` on the returned value - */ - const V* valueAt(unsigned idx) const - { - return entries[idx].value; - } - - /* - * @brief Get a value at a specified index - * @param idx the index to get the value at - * @retval Value Reference to value at index idx - * @see `operator[]` - */ - Value valueAt(unsigned idx) - { - return Value(*this, entries[idx].key); - } - - /** - * @brief Get value for given key, if it exists - * @param key - * @retval const V* Will be null if not found in the map - * @note The caller must not use `delete` on the returned value - */ - const V* operator[](const K& key) const - { - return find(key); - } - - /** @brief Access map entry by reference - * @param key - * @retval Value Guarded access to mapped value corresponding to given key - * @note If the given key does not exist in the map it will NOT be created - * @see `valueAt()` - * - */ - Value operator[](const K& key) - { - return get(key); - } - - /** @brief Get map entry value - * @param key - * @retval Value - * @see `operator[]` - */ - Value get(const K& key) - { - return Value(*this, key); - } - - /** @brief Set a key value - * @param key - * @param value - */ - void set(const K& key, V* value) - { - int i = indexOf(key); - if(i >= 0) { - delete entries[i].value; - entries[i].value = value; - } else { - entries.addElement(new Entry(key, value)); - } - } - - /** - * @brief Find the value for a given key, if it exists - * @param key - * @retval V* Points to the object if it exists, otherwise nullptr - * @note If you need to modify the existing map entry, use `operator[]` or `valueAt()` - */ - V* find(const K& key) const - { - int index = indexOf(key); - return (index < 0) ? nullptr : entries[index].value; - } - - /** - * @brief Get the index of a key - * @param key - * @retval int The index of the key, or -1 if key does not exist - */ - int indexOf(const K& key) const - { - for(unsigned i = 0; i < entries.count(); i++) { - if(entries[i].key == key) { - return i; - } - } - return -1; - } - - /** - * @brief Check if a key is contained within this map - * @param key the key to check - * @retval bool true if key exists - */ - bool contains(const K& key) const - { - return indexOf(key) >= 0; - } - - /** - * @brief Remove entry at given index - * @param index location to remove from this map - */ - void removeAt(unsigned index) - { - entries.remove(index); - } - - /** - * @brief Remove a key from this map - * @param key The key identifying the entry to remove - * @retval bool true if the value was found and removed - */ - bool remove(const K& key) - { - int index = indexOf(key); - if(index < 0) { - return false; - } else { - removeAt(index); - return true; - } - } - - /** - * @brief Get the value for a given key and remove it from the map, without destroying it - * @param key - * @retval V* - * @note The returned object must be freed by the caller when no longer required - */ - V* extract(const K& key) - { - int i = indexOf(key); - return (i < 0) ? nullptr : extractAt(i); - } - - /** - * @brief Get the value at a given index and remove it from the map, without destroying it - * @param index - * @retval V* - * @note The returned object must be freed by the caller when no longer required - */ - V* extractAt(unsigned index) - { - V* value = nullptr; - if(index < entries.count()) { - value = entries[index].value; - entries[index].value = nullptr; - entries.remove(index); - } - return value; - } - - /** - * @brief Clear the map of all entries - */ - void clear() - { - entries.clear(); - } - -protected: - /** - * @brief An entry in the ObjectMap - */ - struct Entry { - K key; - V* value = nullptr; - - Entry(const K& key, V* value) : key(key), value(value) - { - } - - ~Entry() - { - delete value; - } - }; - - Vector entries; - -private: - // Copy constructor unsafe, so prevent access - ObjectMap(ObjectMap& that); -}; +/**** + * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. + * Created 2015 by Skurydin Alexey + * http://github.com/SmingHub/Sming + * All files of the Sming Core are provided under the LGPL v3 license. + * + * ObjectMap.h + * + * @author: 31 Jul 2018 - Mikee47 + * + */ + +#pragma once + +#include "WVector.h" + +/** + * @brief Implementation of a HashMap for owned objects, i.e. anything created with new(). + * @note Once added to the map the object is destroyed when no longer required. + * + * Example: + * + * ``` + * void test() + * { + * ObjectMap map; + * MyType* object1 = new MyType(); + * if (map["key1"] == nullptr) { // Does NOT create entry in map + * map["key1"] = object1; // Entry now created, "key1" -> object1 + * } + * MyType* object2 = new MyType(); + * map["key1"] = object2; // object1 is destroyed, "key1" -> object2 + * + * // Demonstrate use of value reference + * auto value = map["key1"]; // Returns ObjectMap::Value object + * value = new MyType(); // "key1" -> new object + * value = nullptr; // Free object, "key1" -> nullptr (but still in map) + * value.remove(); // Free object1 and remove from map + * + * // As soon as `map` goes out of scope, all contained objects are detroyed + * map["key1"] = new MyType(); + * map["key2"] = new MyType(); + * } + * ``` + * + */ +template class ObjectMap +{ +public: + ObjectMap() + { + } + + ~ObjectMap() + { + clear(); + } + + /** + * @brief Class to provide safe access to mapped value + * @note ObjectMap `operator[]` returns one of these, which provides behaviour consistent with V* + */ + class Value + { + public: + Value(ObjectMap& map, const K& key) : map(map), key(key) + { + } + + const K& getKey() const + { + return key; + } + + V* getValue() const + { + return map.find(key); + } + + Value& operator=(V* newValue) + { + map.set(key, newValue); + return *this; + } + + operator V*() const + { + return getValue(); + } + + V* operator->() const + { + return getValue(); + } + + /** + * @brief Remove this value from the map + * @retval bool true if the value was found and removed + */ + bool remove() + { + return map.remove(key); + } + + /** + * @brief Get the value for a given key and remove it from the map, without destroying it + * @retval V* + * @note The returned object must be freed by the caller when no longer required + */ + V* extract() + { + return map.extract(key); + } + + private: + ObjectMap& map; + K key; + }; + + /** + * @brief Get the number of entries in this map + * @retval int Entry count + */ + unsigned count() const + { + return entries.count(); + } + + /* + * @brief Get a key at a specified index, non-modifiable + * @param idx the index to get the key at + * @return The key at index idx + */ + const K& keyAt(unsigned idx) const + { + return entries[idx].key; + } + + /* + * @brief Get a key at a specified index + * @param idx the index to get the key at + * @return Reference to the key at index idx + */ + K& keyAt(unsigned idx) + { + return entries[idx].key; + } + + /* + * @brief Get a value at a specified index, non-modifiable + * @param idx the index to get the value at + * @retval The value at index idx + * @note The caller must not use `delete` on the returned value + */ + const V* valueAt(unsigned idx) const + { + return entries[idx].value; + } + + /* + * @brief Get a value at a specified index + * @param idx the index to get the value at + * @retval Value Reference to value at index idx + * @see `operator[]` + */ + Value valueAt(unsigned idx) + { + return Value(*this, entries[idx].key); + } + + /** + * @brief Get value for given key, if it exists + * @param key + * @retval const V* Will be null if not found in the map + * @note The caller must not use `delete` on the returned value + */ + const V* operator[](const K& key) const + { + return find(key); + } + + /** @brief Access map entry by reference + * @param key + * @retval Value Guarded access to mapped value corresponding to given key + * @note If the given key does not exist in the map it will NOT be created + * @see `valueAt()` + * + */ + Value operator[](const K& key) + { + return get(key); + } + + /** @brief Get map entry value + * @param key + * @retval Value + * @see `operator[]` + */ + Value get(const K& key) + { + return Value(*this, key); + } + + /** @brief Set a key value + * @param key + * @param value + */ + void set(const K& key, V* value) + { + int i = indexOf(key); + if(i >= 0) { + delete entries[i].value; + entries[i].value = value; + } else { + entries.addElement(new Entry(key, value)); + } + } + + /** + * @brief Find the value for a given key, if it exists + * @param key + * @retval V* Points to the object if it exists, otherwise nullptr + * @note If you need to modify the existing map entry, use `operator[]` or `valueAt()` + */ + V* find(const K& key) const + { + int index = indexOf(key); + return (index < 0) ? nullptr : entries[index].value; + } + + /** + * @brief Get the index of a key + * @param key + * @retval int The index of the key, or -1 if key does not exist + */ + int indexOf(const K& key) const + { + for(unsigned i = 0; i < entries.count(); i++) { + if(entries[i].key == key) { + return i; + } + } + return -1; + } + + /** + * @brief Check if a key is contained within this map + * @param key the key to check + * @retval bool true if key exists + */ + bool contains(const K& key) const + { + return indexOf(key) >= 0; + } + + /** + * @brief Remove entry at given index + * @param index location to remove from this map + */ + void removeAt(unsigned index) + { + entries.remove(index); + } + + /** + * @brief Remove a key from this map + * @param key The key identifying the entry to remove + * @retval bool true if the value was found and removed + */ + bool remove(const K& key) + { + int index = indexOf(key); + if(index < 0) { + return false; + } else { + removeAt(index); + return true; + } + } + + /** + * @brief Get the value for a given key and remove it from the map, without destroying it + * @param key + * @retval V* + * @note The returned object must be freed by the caller when no longer required + */ + V* extract(const K& key) + { + int i = indexOf(key); + return (i < 0) ? nullptr : extractAt(i); + } + + /** + * @brief Get the value at a given index and remove it from the map, without destroying it + * @param index + * @retval V* + * @note The returned object must be freed by the caller when no longer required + */ + V* extractAt(unsigned index) + { + V* value = nullptr; + if(index < entries.count()) { + value = entries[index].value; + entries[index].value = nullptr; + entries.remove(index); + } + return value; + } + + /** + * @brief Clear the map of all entries + */ + void clear() + { + entries.clear(); + } + +protected: + /** + * @brief An entry in the ObjectMap + */ + struct Entry { + K key; + V* value = nullptr; + + Entry(const K& key, V* value) : key(key), value(value) + { + } + + ~Entry() + { + delete value; + } + }; + + Vector entries; + +private: + // Copy constructor unsafe, so prevent access + ObjectMap(ObjectMap& that); +}; diff --git a/Sming/Core/Data/Stream/JsonObjectStream.cpp b/Sming/Core/Data/Stream/JsonObjectStream.cpp index c0289988a5..11c824bd5e 100644 --- a/Sming/Core/Data/Stream/JsonObjectStream.cpp +++ b/Sming/Core/Data/Stream/JsonObjectStream.cpp @@ -1,21 +1,21 @@ -/**** - * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. - * Created 2015 by Skurydin Alexey - * http://github.com/anakod/Sming - * All files of the Sming Core are provided under the LGPL v3 license. - * - * JsonObjectStream.cpp - * - ****/ - -#include "JsonObjectStream.h" - -uint16_t JsonObjectStream::readMemoryBlock(char* data, int bufSize) -{ - if(send && rootNode.success()) { - rootNode.printTo(*this); - send = false; - } - - return MemoryDataStream::readMemoryBlock(data, bufSize); -} +/**** + * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. + * Created 2015 by Skurydin Alexey + * http://github.com/anakod/Sming + * All files of the Sming Core are provided under the LGPL v3 license. + * + * JsonObjectStream.cpp + * + ****/ + +#include "JsonObjectStream.h" + +uint16_t JsonObjectStream::readMemoryBlock(char* data, int bufSize) +{ + if(send && rootNode.success()) { + rootNode.printTo(*this); + send = false; + } + + return MemoryDataStream::readMemoryBlock(data, bufSize); +} diff --git a/Sming/Core/Network/Http/HttpCommon.cpp b/Sming/Core/Network/Http/HttpCommon.cpp index a19c860405..a64fed0602 100644 --- a/Sming/Core/Network/Http/HttpCommon.cpp +++ b/Sming/Core/Network/Http/HttpCommon.cpp @@ -1,71 +1,71 @@ -/**** - * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. - * Created 2015 by Skurydin Alexey - * http://github.com/SmingHub/Sming - * All files of the Sming Core are provided under the LGPL v3 license. - * - * HttpCommon.cpp - * - * @author: 2018 - Mikee47 - * - * httpGetErrorName(), httpGetErrorDescription() and httpGetStatusText() functions added - * - ****/ - -#include "HttpCommon.h" - -// Define flash strings and lookup table for HTTP error names -#define XX(_n, _s) static DEFINE_FSTR(hpename_##_n, "HPE_" #_n); -HTTP_ERRNO_MAP(XX) -#undef XX - -static FSTR_TABLE(hpeNames) = { -#define XX(_n, _s) FSTR_PTR(hpename_##_n), - HTTP_ERRNO_MAP(XX) -#undef XX -}; - -String httpGetErrorName(enum http_errno err) -{ - if(err > HPE_UNKNOWN) - return F("HPE_#") + String(err); - - return *hpeNames[err]; -} - -// Define flash strings and lookup table for HTTP error descriptions -#define XX(_n, _s) static DEFINE_FSTR(hpedesc_##_n, _s); -HTTP_ERRNO_MAP(XX) -#undef XX - -static FSTR_TABLE(hpeDescriptions) = { -#define XX(_n, _s) FSTR_PTR(hpedesc_##_n), - HTTP_ERRNO_MAP(XX) -#undef XX -}; - -String httpGetErrorDescription(enum http_errno err) -{ - if(err > HPE_UNKNOWN) - return F("HPE_#") + String(err); - - return *hpeDescriptions[err]; -} - -// Define flash strings for HTTP status codes -#define XX(_num, _name, _string) static DEFINE_FSTR(hpsText_##_num, #_string); -HTTP_STATUS_MAP(XX) -#undef XX - -String httpGetStatusText(enum http_status code) -{ - switch(code) { -#define XX(_num, _name, _string) \ - case _num: \ - return hpsText_##_num; - HTTP_STATUS_MAP(XX) -#undef XX - default: - return F("'; - } -} +/**** + * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. + * Created 2015 by Skurydin Alexey + * http://github.com/SmingHub/Sming + * All files of the Sming Core are provided under the LGPL v3 license. + * + * HttpCommon.cpp + * + * @author: 2018 - Mikee47 + * + * httpGetErrorName(), httpGetErrorDescription() and httpGetStatusText() functions added + * + ****/ + +#include "HttpCommon.h" + +// Define flash strings and lookup table for HTTP error names +#define XX(_n, _s) static DEFINE_FSTR(hpename_##_n, "HPE_" #_n); +HTTP_ERRNO_MAP(XX) +#undef XX + +static FSTR_TABLE(hpeNames) = { +#define XX(_n, _s) FSTR_PTR(hpename_##_n), + HTTP_ERRNO_MAP(XX) +#undef XX +}; + +String httpGetErrorName(enum http_errno err) +{ + if(err > HPE_UNKNOWN) + return F("HPE_#") + String(err); + + return *hpeNames[err]; +} + +// Define flash strings and lookup table for HTTP error descriptions +#define XX(_n, _s) static DEFINE_FSTR(hpedesc_##_n, _s); +HTTP_ERRNO_MAP(XX) +#undef XX + +static FSTR_TABLE(hpeDescriptions) = { +#define XX(_n, _s) FSTR_PTR(hpedesc_##_n), + HTTP_ERRNO_MAP(XX) +#undef XX +}; + +String httpGetErrorDescription(enum http_errno err) +{ + if(err > HPE_UNKNOWN) + return F("HPE_#") + String(err); + + return *hpeDescriptions[err]; +} + +// Define flash strings for HTTP status codes +#define XX(_num, _name, _string) static DEFINE_FSTR(hpsText_##_num, #_string); +HTTP_STATUS_MAP(XX) +#undef XX + +String httpGetStatusText(enum http_status code) +{ + switch(code) { +#define XX(_num, _name, _string) \ + case _num: \ + return hpsText_##_num; + HTTP_STATUS_MAP(XX) +#undef XX + default: + return F("'; + } +} diff --git a/Sming/Core/Network/Http/HttpHeaderBuilder.h b/Sming/Core/Network/Http/HttpHeaderBuilder.h index d14ffae978..7c5ccdf2a9 100644 --- a/Sming/Core/Network/Http/HttpHeaderBuilder.h +++ b/Sming/Core/Network/Http/HttpHeaderBuilder.h @@ -1,53 +1,53 @@ -/**** - * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. - * Created 2015 by Skurydin Alexey - * http://github.com/anakod/Sming - * All files of the Sming Core are provided under the LGPL v3 license. - * - * HttpHeaderBuilder.h - * - ****/ - -#pragma once - -#include "HttpHeaders.h" - -/** @brief Re-assembles headers from fragments via onHeaderField / onHeaderValue callbacks */ -class HttpHeaderBuilder -{ -public: - int onHeaderField(const char* at, size_t length) - { - if(lastWasValue) { - // we are starting to process new header - setLength keeps allocated memory - lastData.setLength(0); - lastWasValue = false; - } - lastData.concat(at, length); - - return 0; - } - - int onHeaderValue(HttpHeaders& headers, const char* at, size_t length) - { - if(!lastWasValue) { - currentField = lastData; - headers[currentField] = nullptr; - lastWasValue = true; - } - headers[currentField].concat(at, length); - return 0; - } - - void reset() - { - lastWasValue = true; - lastData = nullptr; - currentField = nullptr; - } - -private: - bool lastWasValue = true; ///< Indicates whether last callback was Field or Value - String lastData; ///< Content of field or value, may be constructed over several callbacks - String currentField; ///< Header field name -}; +/**** + * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. + * Created 2015 by Skurydin Alexey + * http://github.com/anakod/Sming + * All files of the Sming Core are provided under the LGPL v3 license. + * + * HttpHeaderBuilder.h + * + ****/ + +#pragma once + +#include "HttpHeaders.h" + +/** @brief Re-assembles headers from fragments via onHeaderField / onHeaderValue callbacks */ +class HttpHeaderBuilder +{ +public: + int onHeaderField(const char* at, size_t length) + { + if(lastWasValue) { + // we are starting to process new header - setLength keeps allocated memory + lastData.setLength(0); + lastWasValue = false; + } + lastData.concat(at, length); + + return 0; + } + + int onHeaderValue(HttpHeaders& headers, const char* at, size_t length) + { + if(!lastWasValue) { + currentField = lastData; + headers[currentField] = nullptr; + lastWasValue = true; + } + headers[currentField].concat(at, length); + return 0; + } + + void reset() + { + lastWasValue = true; + lastData = nullptr; + currentField = nullptr; + } + +private: + bool lastWasValue = true; ///< Indicates whether last callback was Field or Value + String lastData; ///< Content of field or value, may be constructed over several callbacks + String currentField; ///< Header field name +}; diff --git a/Sming/Core/Network/Http/HttpHeaders.cpp b/Sming/Core/Network/Http/HttpHeaders.cpp index 6235e008dd..89a608d567 100644 --- a/Sming/Core/Network/Http/HttpHeaders.cpp +++ b/Sming/Core/Network/Http/HttpHeaders.cpp @@ -1,66 +1,66 @@ -/**** - * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. - * Created 2015 by Skurydin Alexey - * http://github.com/SmingHub/Sming - * All files of the Sming Core are provided under the LGPL v3 license. - * - * HttpHeaders.cpp - * - * @author: 2018 - Mikee47 - * - ****/ - -#include "HttpHeaders.h" - -// Define field name strings and a lookup table -#define XX(_tag, _str, _comment) static DEFINE_FSTR(hhfnStr_##_tag, _str); -HTTP_HEADER_FIELDNAME_MAP(XX) -#undef XX - -static FSTR_TABLE(FieldNameStrings) = { -#define XX(_tag, _str, _comment) FSTR_PTR(hhfnStr_##_tag), - HTTP_HEADER_FIELDNAME_MAP(XX) -#undef XX -}; - -String HttpHeaders::toString(HttpHeaderFieldName name) const -{ - if(name == HTTP_HEADER_UNKNOWN) - return nullptr; - - if(name < HTTP_HEADER_CUSTOM) - return *FieldNameStrings[name - 1]; - - return customFieldNames[name - HTTP_HEADER_CUSTOM]; -} - -String HttpHeaders::toString(const String& name, const String& value) -{ - String s; - s.reserve(name.length() + 2 + value.length() + 2); - s.concat(name); - s.concat(": "); - s.concat(value); - s.concat("\r\n"); - return s; -} - -HttpHeaderFieldName HttpHeaders::fromString(const String& name) const -{ - // 0 is reserved for UNKNOWN - for(unsigned i = 1; i < HTTP_HEADER_CUSTOM; ++i) { - if(name.equalsIgnoreCase(*FieldNameStrings[i - 1])) - return static_cast(i); - } - - return findCustomFieldName(name); -} - -HttpHeaderFieldName HttpHeaders::findCustomFieldName(const String& name) const -{ - auto index = customFieldNames.indexOf(name); - if(index >= 0) - return static_cast(HTTP_HEADER_CUSTOM + index); - - return HTTP_HEADER_UNKNOWN; -} +/**** + * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. + * Created 2015 by Skurydin Alexey + * http://github.com/SmingHub/Sming + * All files of the Sming Core are provided under the LGPL v3 license. + * + * HttpHeaders.cpp + * + * @author: 2018 - Mikee47 + * + ****/ + +#include "HttpHeaders.h" + +// Define field name strings and a lookup table +#define XX(_tag, _str, _comment) static DEFINE_FSTR(hhfnStr_##_tag, _str); +HTTP_HEADER_FIELDNAME_MAP(XX) +#undef XX + +static FSTR_TABLE(FieldNameStrings) = { +#define XX(_tag, _str, _comment) FSTR_PTR(hhfnStr_##_tag), + HTTP_HEADER_FIELDNAME_MAP(XX) +#undef XX +}; + +String HttpHeaders::toString(HttpHeaderFieldName name) const +{ + if(name == HTTP_HEADER_UNKNOWN) + return nullptr; + + if(name < HTTP_HEADER_CUSTOM) + return *FieldNameStrings[name - 1]; + + return customFieldNames[name - HTTP_HEADER_CUSTOM]; +} + +String HttpHeaders::toString(const String& name, const String& value) +{ + String s; + s.reserve(name.length() + 2 + value.length() + 2); + s.concat(name); + s.concat(": "); + s.concat(value); + s.concat("\r\n"); + return s; +} + +HttpHeaderFieldName HttpHeaders::fromString(const String& name) const +{ + // 0 is reserved for UNKNOWN + for(unsigned i = 1; i < HTTP_HEADER_CUSTOM; ++i) { + if(name.equalsIgnoreCase(*FieldNameStrings[i - 1])) + return static_cast(i); + } + + return findCustomFieldName(name); +} + +HttpHeaderFieldName HttpHeaders::findCustomFieldName(const String& name) const +{ + auto index = customFieldNames.indexOf(name); + if(index >= 0) + return static_cast(HTTP_HEADER_CUSTOM + index); + + return HTTP_HEADER_UNKNOWN; +} diff --git a/Sming/Core/Network/Http/HttpHeaders.h b/Sming/Core/Network/Http/HttpHeaders.h index 1f379a4c46..c64f0f3b37 100644 --- a/Sming/Core/Network/Http/HttpHeaders.h +++ b/Sming/Core/Network/Http/HttpHeaders.h @@ -1,227 +1,227 @@ -/**** - * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. - * Created 2015 by Skurydin Alexey - * http://github.com/SmingHub/Sming - * All files of the Sming Core are provided under the LGPL v3 license. - * - * HttpHeaders.h - * - * @author: 2018 - Mikee47 - * - * Encapsulate encoding and decoding of HTTP header fields - * Used for HTTP connections and SMTP mail - * - * The HttpHeaders class was an empty HashMap class living in 'Structures.h'. - * It has been expanded here to simplify code, and to provide enumerated keys - * for common field names. - * - ****/ - -#pragma once - -#include "Data/CStringArray.h" -#include "WString.h" -#include "WHashMap.h" -#include "DateTime.h" - -/* - * Common HTTP header field names. Enumerating these simplifies matching - * and generating headers. The strings themselves are stored in flash to - * save RAM. - * - * According to RFC 2616: 4.2, field names are case-insensitive. - * - * A brief description of each header field is given for information purposes. - * For details see https://www.iana.org/assignments/message-headers/message-headers.xhtml - * - */ -#define HTTP_HEADER_FIELDNAME_MAP(XX) \ - XX(ACCESS_CONTROL_ALLOW_ORIGIN, "Access-Control-Allow-Origin", "") \ - XX(AUTHORIZATION, "Authorization", "Basic user agent authentication") \ - XX(CC, "Cc", "email field") \ - XX(CONNECTION, "Connection", "Indicates sender's desired control options") \ - XX(CONTENT_DISPOSITION, "Content-Disposition", "Additional information about how to process response payload") \ - XX(CONTENT_ENCODING, "Content-Encoding", "Applied encodings in addition to content type") \ - XX(CONTENT_LENGTH, "Content-Length", "Anticipated size for payload when not using transfer encoding") \ - XX(CONTENT_TYPE, "Content-Type", \ - "Payload media type indicating both data format and intended manner of processing by recipient") \ - XX(CONTENT_TRANSFER_ENCODING, "Content-Transfer-Encoding", "Coding method used in a MIME message body part") \ - XX(CACHE_CONTROL, "Cache-Control", "Directives for caches along the request/response chain") \ - XX(DATE, "Date", "Message originating date/time") \ - XX(ETAG, "ETag", \ - "Validates resource, such as a file, so recipient can confirm whether it has changed - generally more " \ - "reliable than Date") \ - XX(FROM, "From", "email address of human user who controls the requesting user agent") \ - XX(HOST, "Host", \ - "Request host and port information for target URI; allows server to service requests for multiple hosts on a " \ - "single IP address") \ - XX(IF_MATCH, "If-Match", \ - "Precondition check using ETag to avoid accidental overwrites when servicing multiple user requests. Ensures " \ - "resource entity tag matches before proceeding.") \ - XX(IF_MODIFIED_SINCE, "If-Modified-Since", "Precondition check using Date") \ - XX(LAST_MODIFIED, "Last-Modified", "Server timestamp indicating date and time resource was last modified") \ - XX(LOCATION, "Location", "Used in redirect responses, amongst other places") \ - XX(SEC_WEBSOCKET_ACCEPT, "Sec-WebSocket-Accept", "Server response to opening Websocket handshake") \ - XX(SEC_WEBSOCKET_VERSION, "Sec-WebSocket-Version", \ - "Websocket opening request indicates acceptable protocol version. Can appear more than once.") \ - XX(SEC_WEBSOCKET_KEY, "Sec-WebSocket-Key", "Websocket opening request validation key") \ - XX(SEC_WEBSOCKET_PROTOCOL, "Sec-WebSocket-Protocol", \ - "Websocket opening request indicates supported protocol(s), response contains negotiated protocol(s)") \ - XX(SERVER, "Server", "Identifies software handling requests") \ - XX(SET_COOKIE, "Set-Cookie", "Server may pass name/value pairs and associated metadata to user agent (client)") \ - XX(SUBJECT, "Subject", "email subject line") \ - XX(TO, "To", "email intended recipient address") \ - XX(TRANSFER_ENCODING, "Transfer-Encoding", "e.g. Chunked, compress, deflate, gzip") \ - XX(UPGRADE, "Upgrade", \ - "Used to transition from HTTP to some other protocol on the same connection. e.g. Websocket") \ - XX(USER_AGENT, "User-Agent", "Information about the user agent originating the request") \ - XX(WWW_AUTHENTICATE, "WWW-Authenticate", "Indicates HTTP authentication scheme(s) and applicable parameters") - -enum HttpHeaderFieldName { - HTTP_HEADER_UNKNOWN = 0, -#define XX(_tag, _str, _comment) HTTP_HEADER_##_tag, - HTTP_HEADER_FIELDNAME_MAP(XX) -#undef XX - HTTP_HEADER_CUSTOM // First custom header tag value -}; - -/** @brief Encapsulates a set of HTTP header information - * @note fields are stored as a map of field names vs. values. - * Standard fields may be accessed using enumeration tags. - * Behaviour is as for HashMap, with the addition of methods to support enumerated field names. - * - * @todo add name and/or value escaping - */ -class HttpHeaders : private HashMap -{ -public: - HttpHeaders() = default; - - HttpHeaders(const HttpHeaders& headers) - { - *this = headers; - } - - String toString(HttpHeaderFieldName name) const; - - /** @brief Produce a string for output in the HTTP header, with line ending - * @param name - * @param value - * @retval String - */ - static String toString(const String& name, const String& value); - - String toString(HttpHeaderFieldName name, const String& value) const - { - return toString(toString(name), value); - } - - /** @brief Find the enumerated value for the given field name string - * @param name - * @retval HttpHeaderFieldName field name code, HTTP_HEADER_UNKNOWN if not recognised - * @note comparison is not case-sensitive - */ - HttpHeaderFieldName fromString(const String& name) const; - - using HashMap::operator[]; - - /** @brief Fetch a reference to the header field value by name - * @param name - * @retval const String& Reference to value - * @note if the field doesn't exist a null String reference is returned - */ - const String& operator[](const String& name) const - { - auto field = fromString(name); - if(field == HTTP_HEADER_UNKNOWN) { - return nil; - } - return operator[](field); - } - - /** @brief Fetch a reference to the header field value by name - * @param name - * @retval String& Reference to value - * @note if the field doesn't exist it is created with the default null value - */ - String& operator[](const String& name) - { - auto field = fromString(name); - if(field == HTTP_HEADER_UNKNOWN) { - field = static_cast(HTTP_HEADER_CUSTOM + customFieldNames.count()); - customFieldNames.add(name); - } - return operator[](field); - } - - /** @brief Return the HTTP header line for the value at the given index - * @param index - * @retval String - * @note if the index is invalid, - */ - String operator[](unsigned index) const - { - return toString(keyAt(index), valueAt(index)); - } - - using HashMap::contains; - - bool contains(const String& name) const - { - return contains(fromString(name)); - } - - using HashMap::remove; - - void remove(const String& name) - { - remove(fromString(name)); - } - - void setMultiple(const HttpHeaders& headers) - { - for(unsigned i = 0; i < headers.count(); i++) { - HttpHeaderFieldName fieldName = headers.keyAt(i); - auto fieldNameString = headers.toString(fieldName); - operator[](fieldNameString) = headers.valueAt(i); - } - } - - HttpHeaders& operator=(const HttpHeaders& headers) - { - clear(); - setMultiple(headers); - return *this; - } - - void clear() - { - customFieldNames.clear(); - HashMap::clear(); - } - - using HashMap::count; - - DateTime getLastModifiedDate() const - { - DateTime dt; - String strLM = operator[](HTTP_HEADER_LAST_MODIFIED); - return dt.fromHttpDate(strLM) ? dt : DateTime(); - } - - DateTime getServerDate() const - { - DateTime dt; - String strSD = operator[](HTTP_HEADER_DATE); - return dt.fromHttpDate(strSD) ? dt : DateTime(); - } - -private: - /** @brief Try to match a string against the list of custom field names - * @param name - * @retval HttpHeaderFieldName HTTP_HEADER_UNKNOWN if not found - */ - HttpHeaderFieldName findCustomFieldName(const String& name) const; - - CStringArray customFieldNames; -}; +/**** + * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. + * Created 2015 by Skurydin Alexey + * http://github.com/SmingHub/Sming + * All files of the Sming Core are provided under the LGPL v3 license. + * + * HttpHeaders.h + * + * @author: 2018 - Mikee47 + * + * Encapsulate encoding and decoding of HTTP header fields + * Used for HTTP connections and SMTP mail + * + * The HttpHeaders class was an empty HashMap class living in 'Structures.h'. + * It has been expanded here to simplify code, and to provide enumerated keys + * for common field names. + * + ****/ + +#pragma once + +#include "Data/CStringArray.h" +#include "WString.h" +#include "WHashMap.h" +#include "DateTime.h" + +/* + * Common HTTP header field names. Enumerating these simplifies matching + * and generating headers. The strings themselves are stored in flash to + * save RAM. + * + * According to RFC 2616: 4.2, field names are case-insensitive. + * + * A brief description of each header field is given for information purposes. + * For details see https://www.iana.org/assignments/message-headers/message-headers.xhtml + * + */ +#define HTTP_HEADER_FIELDNAME_MAP(XX) \ + XX(ACCESS_CONTROL_ALLOW_ORIGIN, "Access-Control-Allow-Origin", "") \ + XX(AUTHORIZATION, "Authorization", "Basic user agent authentication") \ + XX(CC, "Cc", "email field") \ + XX(CONNECTION, "Connection", "Indicates sender's desired control options") \ + XX(CONTENT_DISPOSITION, "Content-Disposition", "Additional information about how to process response payload") \ + XX(CONTENT_ENCODING, "Content-Encoding", "Applied encodings in addition to content type") \ + XX(CONTENT_LENGTH, "Content-Length", "Anticipated size for payload when not using transfer encoding") \ + XX(CONTENT_TYPE, "Content-Type", \ + "Payload media type indicating both data format and intended manner of processing by recipient") \ + XX(CONTENT_TRANSFER_ENCODING, "Content-Transfer-Encoding", "Coding method used in a MIME message body part") \ + XX(CACHE_CONTROL, "Cache-Control", "Directives for caches along the request/response chain") \ + XX(DATE, "Date", "Message originating date/time") \ + XX(ETAG, "ETag", \ + "Validates resource, such as a file, so recipient can confirm whether it has changed - generally more " \ + "reliable than Date") \ + XX(FROM, "From", "email address of human user who controls the requesting user agent") \ + XX(HOST, "Host", \ + "Request host and port information for target URI; allows server to service requests for multiple hosts on a " \ + "single IP address") \ + XX(IF_MATCH, "If-Match", \ + "Precondition check using ETag to avoid accidental overwrites when servicing multiple user requests. Ensures " \ + "resource entity tag matches before proceeding.") \ + XX(IF_MODIFIED_SINCE, "If-Modified-Since", "Precondition check using Date") \ + XX(LAST_MODIFIED, "Last-Modified", "Server timestamp indicating date and time resource was last modified") \ + XX(LOCATION, "Location", "Used in redirect responses, amongst other places") \ + XX(SEC_WEBSOCKET_ACCEPT, "Sec-WebSocket-Accept", "Server response to opening Websocket handshake") \ + XX(SEC_WEBSOCKET_VERSION, "Sec-WebSocket-Version", \ + "Websocket opening request indicates acceptable protocol version. Can appear more than once.") \ + XX(SEC_WEBSOCKET_KEY, "Sec-WebSocket-Key", "Websocket opening request validation key") \ + XX(SEC_WEBSOCKET_PROTOCOL, "Sec-WebSocket-Protocol", \ + "Websocket opening request indicates supported protocol(s), response contains negotiated protocol(s)") \ + XX(SERVER, "Server", "Identifies software handling requests") \ + XX(SET_COOKIE, "Set-Cookie", "Server may pass name/value pairs and associated metadata to user agent (client)") \ + XX(SUBJECT, "Subject", "email subject line") \ + XX(TO, "To", "email intended recipient address") \ + XX(TRANSFER_ENCODING, "Transfer-Encoding", "e.g. Chunked, compress, deflate, gzip") \ + XX(UPGRADE, "Upgrade", \ + "Used to transition from HTTP to some other protocol on the same connection. e.g. Websocket") \ + XX(USER_AGENT, "User-Agent", "Information about the user agent originating the request") \ + XX(WWW_AUTHENTICATE, "WWW-Authenticate", "Indicates HTTP authentication scheme(s) and applicable parameters") + +enum HttpHeaderFieldName { + HTTP_HEADER_UNKNOWN = 0, +#define XX(_tag, _str, _comment) HTTP_HEADER_##_tag, + HTTP_HEADER_FIELDNAME_MAP(XX) +#undef XX + HTTP_HEADER_CUSTOM // First custom header tag value +}; + +/** @brief Encapsulates a set of HTTP header information + * @note fields are stored as a map of field names vs. values. + * Standard fields may be accessed using enumeration tags. + * Behaviour is as for HashMap, with the addition of methods to support enumerated field names. + * + * @todo add name and/or value escaping + */ +class HttpHeaders : private HashMap +{ +public: + HttpHeaders() = default; + + HttpHeaders(const HttpHeaders& headers) + { + *this = headers; + } + + String toString(HttpHeaderFieldName name) const; + + /** @brief Produce a string for output in the HTTP header, with line ending + * @param name + * @param value + * @retval String + */ + static String toString(const String& name, const String& value); + + String toString(HttpHeaderFieldName name, const String& value) const + { + return toString(toString(name), value); + } + + /** @brief Find the enumerated value for the given field name string + * @param name + * @retval HttpHeaderFieldName field name code, HTTP_HEADER_UNKNOWN if not recognised + * @note comparison is not case-sensitive + */ + HttpHeaderFieldName fromString(const String& name) const; + + using HashMap::operator[]; + + /** @brief Fetch a reference to the header field value by name + * @param name + * @retval const String& Reference to value + * @note if the field doesn't exist a null String reference is returned + */ + const String& operator[](const String& name) const + { + auto field = fromString(name); + if(field == HTTP_HEADER_UNKNOWN) { + return nil; + } + return operator[](field); + } + + /** @brief Fetch a reference to the header field value by name + * @param name + * @retval String& Reference to value + * @note if the field doesn't exist it is created with the default null value + */ + String& operator[](const String& name) + { + auto field = fromString(name); + if(field == HTTP_HEADER_UNKNOWN) { + field = static_cast(HTTP_HEADER_CUSTOM + customFieldNames.count()); + customFieldNames.add(name); + } + return operator[](field); + } + + /** @brief Return the HTTP header line for the value at the given index + * @param index + * @retval String + * @note if the index is invalid, + */ + String operator[](unsigned index) const + { + return toString(keyAt(index), valueAt(index)); + } + + using HashMap::contains; + + bool contains(const String& name) const + { + return contains(fromString(name)); + } + + using HashMap::remove; + + void remove(const String& name) + { + remove(fromString(name)); + } + + void setMultiple(const HttpHeaders& headers) + { + for(unsigned i = 0; i < headers.count(); i++) { + HttpHeaderFieldName fieldName = headers.keyAt(i); + auto fieldNameString = headers.toString(fieldName); + operator[](fieldNameString) = headers.valueAt(i); + } + } + + HttpHeaders& operator=(const HttpHeaders& headers) + { + clear(); + setMultiple(headers); + return *this; + } + + void clear() + { + customFieldNames.clear(); + HashMap::clear(); + } + + using HashMap::count; + + DateTime getLastModifiedDate() const + { + DateTime dt; + String strLM = operator[](HTTP_HEADER_LAST_MODIFIED); + return dt.fromHttpDate(strLM) ? dt : DateTime(); + } + + DateTime getServerDate() const + { + DateTime dt; + String strSD = operator[](HTTP_HEADER_DATE); + return dt.fromHttpDate(strSD) ? dt : DateTime(); + } + +private: + /** @brief Try to match a string against the list of custom field names + * @param name + * @retval HttpHeaderFieldName HTTP_HEADER_UNKNOWN if not found + */ + HttpHeaderFieldName findCustomFieldName(const String& name) const; + + CStringArray customFieldNames; +}; diff --git a/Sming/Core/Network/Http/HttpParams.cpp b/Sming/Core/Network/Http/HttpParams.cpp index 391681fcb1..236b2e43d3 100644 --- a/Sming/Core/Network/Http/HttpParams.cpp +++ b/Sming/Core/Network/Http/HttpParams.cpp @@ -1,135 +1,135 @@ -/**** - * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. - * Created 2015 by Skurydin Alexey - * http://github.com/SmingHub/Sming - * All files of the Sming Core are provided under the LGPL v3 license. - * - * HttpParams.cpp - * - * @author: 2018 - Mikee47 - * - ****/ - -#include "HttpParams.h" -#include "WebHelpers/escape.h" -#include "Print.h" -#include "libyuarel/yuarel.h" - -// Set a reasonable limit on the number of expected parameters in a query string -static const unsigned MAX_PARAMS = 16; - -void HttpParams::parseQuery(char* query) -{ - clear(); - - if(query == nullptr) { - return; - } - // Accept query strings with or without '?' prefix - if(*query == '?') { - ++query; - } - - struct yuarel_param params[MAX_PARAMS]; - int paramCount = yuarel_parse_query(query, '&', params, MAX_PARAMS); - if(paramCount <= 0) { - return; - } - - allocate(paramCount); - if(keys == nullptr || values == nullptr) { - // Allocation failure - return; - } - - for(int i = 0; i < paramCount; ++i) { - String key = uri_unescape_inplace(params[i].key); - String value = uri_unescape_inplace(params[i].val); - operator[](key) = value; - } -} - -String HttpParams::toString() const -{ - if(count() == 0) { - return nullptr; - } - - /* - - The following code is an optimised version of this: - - String result; - for (unsigned i = 0; i < count(); ++i) { - if (i > 0) - result += '&'; - result += uri_escape(keyAt(i)); - result += '='; - result += uri_escape(valueAt(i)); - } - - */ - - // Calculate length of result so we can reserve result String memory in one go - unsigned resultLength = 0; - for(unsigned i = 0; i < count(); ++i) { - resultLength += uri_escape_len(keyAt(i)) + 1 + uri_escape_len(valueAt(i)) + 1; // Allow for '?', '=' and '&' - } - - String result; - if(!result.setLength(resultLength)) { - return nullptr; - } - - // Write out the string content - char* resultPtr = result.begin(); - *resultPtr++ = '?'; - for(unsigned i = 0; i < count(); ++i) { - if(i > 0) { - *resultPtr++ = '&'; - } - - // result += uri_escape(keyAt(i)); - const String& key = keyAt(i); - uri_escape(resultPtr, 1 + result.end() - resultPtr, key.c_str(), key.length()); - resultPtr += strlen(resultPtr); - - // result += '='; - *resultPtr++ = '='; - - // result += uri_escape(valueAt(i)); - const String& value = valueAt(i); - uri_escape(resultPtr, 1 + result.end() - resultPtr, value.c_str(), value.length()); - resultPtr += strlen(resultPtr); - } - - assert(resultPtr == result.end()); - - return result; -} - -size_t HttpParams::printTo(Print& p) const -{ - size_t charsPrinted = 0; - for(unsigned i = 0; i < count(); i++) { - if(i > 0) { - charsPrinted += p.print('&'); - } - charsPrinted += p.print(uri_escape(keyAt(i))); - charsPrinted += p.print('='); - charsPrinted += p.print(uri_escape(valueAt(i))); - } - - return charsPrinted; -} - -void HttpParams::debugPrintTo(Print& p) const -{ - for(unsigned i = 0; i < count(); i++) { - p.print(' '); - p.print(keyAt(i)); - p.print(_F(" = [")); - p.print(valueAt(i)); - p.println(']'); - } -} +/**** + * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. + * Created 2015 by Skurydin Alexey + * http://github.com/SmingHub/Sming + * All files of the Sming Core are provided under the LGPL v3 license. + * + * HttpParams.cpp + * + * @author: 2018 - Mikee47 + * + ****/ + +#include "HttpParams.h" +#include "WebHelpers/escape.h" +#include "Print.h" +#include "libyuarel/yuarel.h" + +// Set a reasonable limit on the number of expected parameters in a query string +static const unsigned MAX_PARAMS = 16; + +void HttpParams::parseQuery(char* query) +{ + clear(); + + if(query == nullptr) { + return; + } + // Accept query strings with or without '?' prefix + if(*query == '?') { + ++query; + } + + struct yuarel_param params[MAX_PARAMS]; + int paramCount = yuarel_parse_query(query, '&', params, MAX_PARAMS); + if(paramCount <= 0) { + return; + } + + allocate(paramCount); + if(keys == nullptr || values == nullptr) { + // Allocation failure + return; + } + + for(int i = 0; i < paramCount; ++i) { + String key = uri_unescape_inplace(params[i].key); + String value = uri_unescape_inplace(params[i].val); + operator[](key) = value; + } +} + +String HttpParams::toString() const +{ + if(count() == 0) { + return nullptr; + } + + /* + + The following code is an optimised version of this: + + String result; + for (unsigned i = 0; i < count(); ++i) { + if (i > 0) + result += '&'; + result += uri_escape(keyAt(i)); + result += '='; + result += uri_escape(valueAt(i)); + } + + */ + + // Calculate length of result so we can reserve result String memory in one go + unsigned resultLength = 0; + for(unsigned i = 0; i < count(); ++i) { + resultLength += uri_escape_len(keyAt(i)) + 1 + uri_escape_len(valueAt(i)) + 1; // Allow for '?', '=' and '&' + } + + String result; + if(!result.setLength(resultLength)) { + return nullptr; + } + + // Write out the string content + char* resultPtr = result.begin(); + *resultPtr++ = '?'; + for(unsigned i = 0; i < count(); ++i) { + if(i > 0) { + *resultPtr++ = '&'; + } + + // result += uri_escape(keyAt(i)); + const String& key = keyAt(i); + uri_escape(resultPtr, 1 + result.end() - resultPtr, key.c_str(), key.length()); + resultPtr += strlen(resultPtr); + + // result += '='; + *resultPtr++ = '='; + + // result += uri_escape(valueAt(i)); + const String& value = valueAt(i); + uri_escape(resultPtr, 1 + result.end() - resultPtr, value.c_str(), value.length()); + resultPtr += strlen(resultPtr); + } + + assert(resultPtr == result.end()); + + return result; +} + +size_t HttpParams::printTo(Print& p) const +{ + size_t charsPrinted = 0; + for(unsigned i = 0; i < count(); i++) { + if(i > 0) { + charsPrinted += p.print('&'); + } + charsPrinted += p.print(uri_escape(keyAt(i))); + charsPrinted += p.print('='); + charsPrinted += p.print(uri_escape(valueAt(i))); + } + + return charsPrinted; +} + +void HttpParams::debugPrintTo(Print& p) const +{ + for(unsigned i = 0; i < count(); i++) { + p.print(' '); + p.print(keyAt(i)); + p.print(_F(" = [")); + p.print(valueAt(i)); + p.println(']'); + } +} diff --git a/Sming/Core/Network/Http/HttpParams.h b/Sming/Core/Network/Http/HttpParams.h index 027f1edd52..1d9b91780c 100644 --- a/Sming/Core/Network/Http/HttpParams.h +++ b/Sming/Core/Network/Http/HttpParams.h @@ -1,76 +1,76 @@ -/**** - * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. - * Created 2015 by Skurydin Alexey - * http://github.com/SmingHub/Sming - * All files of the Sming Core are provided under the LGPL v3 license. - * - * HttpParams.h - * - * @author: 2018 - Mikee47 - * - * Class to manage HTTP URI query parameters - * - * The HttpParams class was an empty HashMap class living in 'Structures.h'. - * It has been expanded to incorporate escaping and unescaping. - * Custom URL parsing code has been replaced with the yuarel library https://github.com/jacketizer/libyuarel - * - ****/ - -#pragma once - -#include "WString.h" -#include "WHashMap.h" -#include "Printable.h" - -/** @brief - * - * @todo values stored in escaped form, unescape return value and escape provided values. - * Revise HttpBodyParser.cpp as it will no longer do this job. - * - */ -class HttpParams : public HashMap, public Printable -{ -public: - HttpParams() = default; - - HttpParams(const HttpParams& params) - { - *this = params; - } - - HttpParams(String query) - { - parseQuery(query.begin()); - } - - /** @brief Called from URL class to process query section of a URI - * @param query extracted from URI, with or without '?' prefix - * @retval bool true on success, false if parsing failed - * @note query string is modified by this call - */ - void parseQuery(char* query); - - /** @brief Return full escaped content for incorporation into a URI */ - String toString() const; - - operator String() const - { - return toString(); - } - - HttpParams& operator=(const HttpParams& params) - { - clear(); - setMultiple(params); - return *this; - } - - // Printable - size_t printTo(Print& p) const override; - - /** - * @brief Printable output for debugging - * @param p - */ - void debugPrintTo(Print& p) const; -}; +/**** + * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. + * Created 2015 by Skurydin Alexey + * http://github.com/SmingHub/Sming + * All files of the Sming Core are provided under the LGPL v3 license. + * + * HttpParams.h + * + * @author: 2018 - Mikee47 + * + * Class to manage HTTP URI query parameters + * + * The HttpParams class was an empty HashMap class living in 'Structures.h'. + * It has been expanded to incorporate escaping and unescaping. + * Custom URL parsing code has been replaced with the yuarel library https://github.com/jacketizer/libyuarel + * + ****/ + +#pragma once + +#include "WString.h" +#include "WHashMap.h" +#include "Printable.h" + +/** @brief + * + * @todo values stored in escaped form, unescape return value and escape provided values. + * Revise HttpBodyParser.cpp as it will no longer do this job. + * + */ +class HttpParams : public HashMap, public Printable +{ +public: + HttpParams() = default; + + HttpParams(const HttpParams& params) + { + *this = params; + } + + HttpParams(String query) + { + parseQuery(query.begin()); + } + + /** @brief Called from URL class to process query section of a URI + * @param query extracted from URI, with or without '?' prefix + * @retval bool true on success, false if parsing failed + * @note query string is modified by this call + */ + void parseQuery(char* query); + + /** @brief Return full escaped content for incorporation into a URI */ + String toString() const; + + operator String() const + { + return toString(); + } + + HttpParams& operator=(const HttpParams& params) + { + clear(); + setMultiple(params); + return *this; + } + + // Printable + size_t printTo(Print& p) const override; + + /** + * @brief Printable output for debugging + * @param p + */ + void debugPrintTo(Print& p) const; +}; diff --git a/Sming/Core/Network/Http/HttpResourceTree.cpp b/Sming/Core/Network/Http/HttpResourceTree.cpp index 435e8f04ee..95c4951c05 100644 --- a/Sming/Core/Network/Http/HttpResourceTree.cpp +++ b/Sming/Core/Network/Http/HttpResourceTree.cpp @@ -1,44 +1,44 @@ -/****` - * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. - * Created 2015 by Skurydin Alexey - * http://github.com/anakod/Sming - * All files of the Sming Core are provided under the LGPL v3 license. - * - * HttpResourceTree.cpp - * - * @author: 2017 - Slavey Karadzhov - * - ****/ - -#include "HttpResourceTree.h" - -class HttpCompatResource : public HttpResource -{ -public: - explicit HttpCompatResource(const HttpPathDelegate& callback) : callback(callback) - { - onRequestComplete = HttpResourceDelegate(&HttpCompatResource::requestComplete, this); - } - -private: - int requestComplete(HttpServerConnection& connection, HttpRequest& request, HttpResponse& response) - { - callback(request, response); - return 0; - } - -private: - HttpPathDelegate callback; -}; - -/* HttpResourceTree */ - -void HttpResourceTree::set(String path, const HttpPathDelegate& callback) -{ - if(path.length() > 1 && path.endsWith("/")) { - path.remove(path.length() - 1); - } - debug_i("'%s' registered", path.c_str()); - - set(path, new HttpCompatResource(callback)); -} +/****` + * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. + * Created 2015 by Skurydin Alexey + * http://github.com/anakod/Sming + * All files of the Sming Core are provided under the LGPL v3 license. + * + * HttpResourceTree.cpp + * + * @author: 2017 - Slavey Karadzhov + * + ****/ + +#include "HttpResourceTree.h" + +class HttpCompatResource : public HttpResource +{ +public: + explicit HttpCompatResource(const HttpPathDelegate& callback) : callback(callback) + { + onRequestComplete = HttpResourceDelegate(&HttpCompatResource::requestComplete, this); + } + +private: + int requestComplete(HttpServerConnection& connection, HttpRequest& request, HttpResponse& response) + { + callback(request, response); + return 0; + } + +private: + HttpPathDelegate callback; +}; + +/* HttpResourceTree */ + +void HttpResourceTree::set(String path, const HttpPathDelegate& callback) +{ + if(path.length() > 1 && path.endsWith("/")) { + path.remove(path.length() - 1); + } + debug_i("'%s' registered", path.c_str()); + + set(path, new HttpCompatResource(callback)); +} diff --git a/Sming/Core/Network/Http/HttpResourceTree.h b/Sming/Core/Network/Http/HttpResourceTree.h index bae79decf9..1681fd9ea1 100644 --- a/Sming/Core/Network/Http/HttpResourceTree.h +++ b/Sming/Core/Network/Http/HttpResourceTree.h @@ -1,81 +1,81 @@ -/****` - * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. - * Created 2015 by Skurydin Alexey - * http://github.com/anakod/Sming - * All files of the Sming Core are provided under the LGPL v3 license. - * - * HttpResourceTree.h - * - * @author: 2017 - Slavey Karadzhov - * - ****/ - -#pragma once - -#include "HttpResource.h" - -typedef Delegate HttpPathDelegate; - -/** @brief Identifies the default resource path */ -#define RESOURCE_PATH_DEFAULT String('*') - -/** @brief Class to map URL paths to classes which handle them - */ -class HttpResourceTree : public ObjectMap -{ -public: - /** @brief Set the default resource handler - * @param resource The default resource handler - */ - void setDefault(HttpResource* resource) - { - set(RESOURCE_PATH_DEFAULT, resource); - } - - /** @brief Set the default resource handler, identified by "*" wildcard - * @param resource The default resource handler - */ - void setDefault(const HttpResourceDelegate& onRequestComplete) - { - set(RESOURCE_PATH_DEFAULT, onRequestComplete); - } - - /** @brief Set the default resource handler, identified by "*" wildcard */ - void setDefault(const HttpPathDelegate& callback) - { - set(RESOURCE_PATH_DEFAULT, callback); - } - - /** @brief Get the current default resource handler, if any - * @retval HttpResource* - */ - HttpResource* getDefault() - { - return find(RESOURCE_PATH_DEFAULT); - } - - using ObjectMap::set; - - /** - * @brief Set a callback to handle the given path - * @param path URL path - * @param onRequestComplete Delegate to handle this path - * @note Path should start with slash. Trailing slashes will be removed. - * @note Any existing handler for this path is replaced - */ - void set(const String& path, const HttpResourceDelegate& onRequestComplete) - { - HttpResource* resource = new HttpResource; - resource->onRequestComplete = onRequestComplete; - set(path, resource); - } - - /** - * @brief Add a new path resource with a callback - * @param path URL path - * @param callback The callback that will handle this path - * @note Path should start with slash. Trailing slashes will be removed - * @note Any existing handler for this path is replaced - */ - void set(String path, const HttpPathDelegate& callback); -}; +/****` + * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. + * Created 2015 by Skurydin Alexey + * http://github.com/anakod/Sming + * All files of the Sming Core are provided under the LGPL v3 license. + * + * HttpResourceTree.h + * + * @author: 2017 - Slavey Karadzhov + * + ****/ + +#pragma once + +#include "HttpResource.h" + +typedef Delegate HttpPathDelegate; + +/** @brief Identifies the default resource path */ +#define RESOURCE_PATH_DEFAULT String('*') + +/** @brief Class to map URL paths to classes which handle them + */ +class HttpResourceTree : public ObjectMap +{ +public: + /** @brief Set the default resource handler + * @param resource The default resource handler + */ + void setDefault(HttpResource* resource) + { + set(RESOURCE_PATH_DEFAULT, resource); + } + + /** @brief Set the default resource handler, identified by "*" wildcard + * @param resource The default resource handler + */ + void setDefault(const HttpResourceDelegate& onRequestComplete) + { + set(RESOURCE_PATH_DEFAULT, onRequestComplete); + } + + /** @brief Set the default resource handler, identified by "*" wildcard */ + void setDefault(const HttpPathDelegate& callback) + { + set(RESOURCE_PATH_DEFAULT, callback); + } + + /** @brief Get the current default resource handler, if any + * @retval HttpResource* + */ + HttpResource* getDefault() + { + return find(RESOURCE_PATH_DEFAULT); + } + + using ObjectMap::set; + + /** + * @brief Set a callback to handle the given path + * @param path URL path + * @param onRequestComplete Delegate to handle this path + * @note Path should start with slash. Trailing slashes will be removed. + * @note Any existing handler for this path is replaced + */ + void set(const String& path, const HttpResourceDelegate& onRequestComplete) + { + HttpResource* resource = new HttpResource; + resource->onRequestComplete = onRequestComplete; + set(path, resource); + } + + /** + * @brief Add a new path resource with a callback + * @param path URL path + * @param callback The callback that will handle this path + * @note Path should start with slash. Trailing slashes will be removed + * @note Any existing handler for this path is replaced + */ + void set(String path, const HttpPathDelegate& callback); +}; diff --git a/Sming/Core/Network/Ssl/SslFingerprints.cpp b/Sming/Core/Network/Ssl/SslFingerprints.cpp index be9f64928b..e5079e2165 100644 --- a/Sming/Core/Network/Ssl/SslFingerprints.cpp +++ b/Sming/Core/Network/Ssl/SslFingerprints.cpp @@ -1,83 +1,83 @@ -/**** - * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. - * Created 2015 by Skurydin Alexey - * http://github.com/anakod/Sming - * All files of the Sming Core are provided under the LGPL v3 license. - * - * SslFingerprints.cpp - * - ****/ - -#ifdef ENABLE_SSL - -#include "SslFingerprints.h" -#include - -static inline void freeValue(const uint8_t*& ptr) -{ - delete[] ptr; - ptr = nullptr; -} - -void SslFingerprints::free() -{ - freeValue(certSha1); - freeValue(pkSha256); -} - -bool SslFingerprints::setValue(const uint8_t*& value, unsigned requiredLength, const uint8_t* newValue, - unsigned newLength) -{ - if(newValue == nullptr || newLength == 0) { - freeValue(value); - return true; - } else { - if(newLength != requiredLength) { - debug_w("Warning: Invalid fingerprint length"); - // Copy data anyway to prevent false positive validation - } - if(value == nullptr) { - value = new uint8_t[requiredLength]; - if(value == nullptr) { - return false; - } - } - // If new value is longer than buffer, copy short - unsigned length = std::min(newLength, requiredLength); - // Behave properly when source is flash memory and length is wrong or buffers misaligned - if(isFlashPtr(newValue)) { - memcpy_P(const_cast(value), newValue, length); - } else { - memcpy(const_cast(value), newValue, length); - } - return true; - } -} - -SslFingerprints& SslFingerprints::operator=(SslFingerprints& source) -{ - if(this != &source) { - freeValue(certSha1); - certSha1 = source.certSha1; - source.certSha1 = nullptr; - - freeValue(pkSha256); - pkSha256 = source.pkSha256; - source.pkSha256 = nullptr; - } - - return *this; -} - -/** @brief Make copy of values from source */ -SslFingerprints& SslFingerprints::operator=(const SslFingerprints& source) -{ - if(this != &source) { - setSha1(source.certSha1, SHA1_SIZE); - setSha256(source.pkSha256, SHA256_SIZE); - } - - return *this; -} - -#endif // ENABLE_SSL +/**** + * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. + * Created 2015 by Skurydin Alexey + * http://github.com/anakod/Sming + * All files of the Sming Core are provided under the LGPL v3 license. + * + * SslFingerprints.cpp + * + ****/ + +#ifdef ENABLE_SSL + +#include "SslFingerprints.h" +#include + +static inline void freeValue(const uint8_t*& ptr) +{ + delete[] ptr; + ptr = nullptr; +} + +void SslFingerprints::free() +{ + freeValue(certSha1); + freeValue(pkSha256); +} + +bool SslFingerprints::setValue(const uint8_t*& value, unsigned requiredLength, const uint8_t* newValue, + unsigned newLength) +{ + if(newValue == nullptr || newLength == 0) { + freeValue(value); + return true; + } else { + if(newLength != requiredLength) { + debug_w("Warning: Invalid fingerprint length"); + // Copy data anyway to prevent false positive validation + } + if(value == nullptr) { + value = new uint8_t[requiredLength]; + if(value == nullptr) { + return false; + } + } + // If new value is longer than buffer, copy short + unsigned length = std::min(newLength, requiredLength); + // Behave properly when source is flash memory and length is wrong or buffers misaligned + if(isFlashPtr(newValue)) { + memcpy_P(const_cast(value), newValue, length); + } else { + memcpy(const_cast(value), newValue, length); + } + return true; + } +} + +SslFingerprints& SslFingerprints::operator=(SslFingerprints& source) +{ + if(this != &source) { + freeValue(certSha1); + certSha1 = source.certSha1; + source.certSha1 = nullptr; + + freeValue(pkSha256); + pkSha256 = source.pkSha256; + source.pkSha256 = nullptr; + } + + return *this; +} + +/** @brief Make copy of values from source */ +SslFingerprints& SslFingerprints::operator=(const SslFingerprints& source) +{ + if(this != &source) { + setSha1(source.certSha1, SHA1_SIZE); + setSha256(source.pkSha256, SHA256_SIZE); + } + + return *this; +} + +#endif // ENABLE_SSL diff --git a/Sming/Core/Network/Ssl/SslFingerprints.h b/Sming/Core/Network/Ssl/SslFingerprints.h index c6d235fdb6..4e5b833f64 100644 --- a/Sming/Core/Network/Ssl/SslFingerprints.h +++ b/Sming/Core/Network/Ssl/SslFingerprints.h @@ -1,102 +1,102 @@ -/**** - * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. - * Created 2015 by Skurydin Alexey - * http://github.com/anakod/Sming - * All files of the Sming Core are provided under the LGPL v3 license. - * - * SslFingerprints.h - * - ****/ - -#pragma once - -#include "ssl/ssl.h" - -/** - * @brief SSL Certificate fingerprint type - */ -enum SslFingerprintType { - /** @brief Fingerprint based on the SHA1 value of the certificate - * @note The SHA1 hash of the entire certificate. This changes on each certificate renewal so needs - * to be updated every time the remote server updates its certificate. - * Advantages: Takes less time to verify than SHA256 - * Disadvantages: Likely to change periodically - */ - eSFT_CertSha1 = 0, - - /** @brief Fingerprint based on the SHA256 value of the Public Key Subject in the certificate - * @note For HTTP public key pinning (RFC7469), the SHA-256 hash of the Subject Public Key Info - * (which usually only changes when the public key changes) is used. - * Advantages: Doesn't change frequently - * Disadvantages: Takes more time (in ms) to verify. - */ - eSFT_PkSha256, -}; - -/** @brief Contains SSL fingerprint data - * @note Lifetime as follows: - * - Constructed by application, using appropriate setXXX method; - * - Passed into HttpRequest by application, using pinCertificate method - request is then queued; - * - Passed into HttpClientConnection (TcpClient descendant) by HttpClient, using pinCertificate method - * - When certificate validated, memory is released - * - */ -struct SslFingerprints { - const uint8_t* certSha1 = nullptr; ///< certificate SHA1 fingerprint - const uint8_t* pkSha256 = nullptr; ///< public key SHA256 fingerprint - - ~SslFingerprints() - { - free(); - } - - void free(); - - /** @brief Set the SHA1 fingerprint - * @param cert data to copy - * @param length for checking - * @retval bool false on length check or allocation failure - */ - bool setSha1(const uint8_t* cert, unsigned length) - { - return setValue(certSha1, SHA1_SIZE, cert, length); - } - - /** @brief Make copy of SHA1 certificate from data stored in flash */ - bool setSha1_P(const uint8_t* cert, unsigned length) - { - return setValue(certSha1, SHA1_SIZE, cert, length); - } - - /** @brief Set the SHA256 fingerprint - * @param cert data to copy - * @param length for checking - * @retval bool false on length check or allocation failure - */ - bool setSha256(const uint8_t* cert, unsigned length) - { - return setValue(pkSha256, SHA256_SIZE, cert, length); - } - - /** @brief Make copy of SHA256 certificate from data stored in flash */ - bool setSha256_P(const uint8_t* cert, unsigned length) - { - return setValue(pkSha256, SHA256_SIZE, cert, length); - } - - /** @brief Moves values out of source */ - SslFingerprints& operator=(SslFingerprints& source); - - /** @brief Make copy of values from source */ - SslFingerprints& operator=(const SslFingerprints& source); - -private: - /** @brief Internal method to set a fingerprint - * @param value Reference to fingerprint value in this structure - * @param requiredLength Expected length for value - * @param newValue - * @param newLength - * @retval bool true on success, false on invalid length or memory allocation failure - */ - bool setValue(const uint8_t*& value, unsigned requiredLength, const uint8_t* newValue, unsigned newLength); -}; +/**** + * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. + * Created 2015 by Skurydin Alexey + * http://github.com/anakod/Sming + * All files of the Sming Core are provided under the LGPL v3 license. + * + * SslFingerprints.h + * + ****/ + +#pragma once + +#include "ssl/ssl.h" + +/** + * @brief SSL Certificate fingerprint type + */ +enum SslFingerprintType { + /** @brief Fingerprint based on the SHA1 value of the certificate + * @note The SHA1 hash of the entire certificate. This changes on each certificate renewal so needs + * to be updated every time the remote server updates its certificate. + * Advantages: Takes less time to verify than SHA256 + * Disadvantages: Likely to change periodically + */ + eSFT_CertSha1 = 0, + + /** @brief Fingerprint based on the SHA256 value of the Public Key Subject in the certificate + * @note For HTTP public key pinning (RFC7469), the SHA-256 hash of the Subject Public Key Info + * (which usually only changes when the public key changes) is used. + * Advantages: Doesn't change frequently + * Disadvantages: Takes more time (in ms) to verify. + */ + eSFT_PkSha256, +}; + +/** @brief Contains SSL fingerprint data + * @note Lifetime as follows: + * - Constructed by application, using appropriate setXXX method; + * - Passed into HttpRequest by application, using pinCertificate method - request is then queued; + * - Passed into HttpClientConnection (TcpClient descendant) by HttpClient, using pinCertificate method + * - When certificate validated, memory is released + * + */ +struct SslFingerprints { + const uint8_t* certSha1 = nullptr; ///< certificate SHA1 fingerprint + const uint8_t* pkSha256 = nullptr; ///< public key SHA256 fingerprint + + ~SslFingerprints() + { + free(); + } + + void free(); + + /** @brief Set the SHA1 fingerprint + * @param cert data to copy + * @param length for checking + * @retval bool false on length check or allocation failure + */ + bool setSha1(const uint8_t* cert, unsigned length) + { + return setValue(certSha1, SHA1_SIZE, cert, length); + } + + /** @brief Make copy of SHA1 certificate from data stored in flash */ + bool setSha1_P(const uint8_t* cert, unsigned length) + { + return setValue(certSha1, SHA1_SIZE, cert, length); + } + + /** @brief Set the SHA256 fingerprint + * @param cert data to copy + * @param length for checking + * @retval bool false on length check or allocation failure + */ + bool setSha256(const uint8_t* cert, unsigned length) + { + return setValue(pkSha256, SHA256_SIZE, cert, length); + } + + /** @brief Make copy of SHA256 certificate from data stored in flash */ + bool setSha256_P(const uint8_t* cert, unsigned length) + { + return setValue(pkSha256, SHA256_SIZE, cert, length); + } + + /** @brief Moves values out of source */ + SslFingerprints& operator=(SslFingerprints& source); + + /** @brief Make copy of values from source */ + SslFingerprints& operator=(const SslFingerprints& source); + +private: + /** @brief Internal method to set a fingerprint + * @param value Reference to fingerprint value in this structure + * @param requiredLength Expected length for value + * @param newValue + * @param newLength + * @retval bool true on success, false on invalid length or memory allocation failure + */ + bool setValue(const uint8_t*& value, unsigned requiredLength, const uint8_t* newValue, unsigned newLength); +}; diff --git a/Sming/Core/Network/Ssl/SslKeyCertPair.h b/Sming/Core/Network/Ssl/SslKeyCertPair.h index d771593e33..169d896c70 100644 --- a/Sming/Core/Network/Ssl/SslKeyCertPair.h +++ b/Sming/Core/Network/Ssl/SslKeyCertPair.h @@ -1,112 +1,112 @@ -/**** - * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. - * Created 2015 by Skurydin Alexey - * http://github.com/anakod/Sming - * All files of the Sming Core are provided under the LGPL v3 license. - * - * SslKeyCertPair.h - * - ****/ - -#pragma once - -#include "ssl/ssl.h" -#include "WString.h" - -/** @brief Class to manage an SSL key certificate with optional password - */ -class SslKeyCertPair -{ -public: - bool isValid() - { - return key && certificate; - } - - /** @brief Create certificate using provided values - * @param newKey - * @param newKeyLength - * @param newCertificate - * @param newCertificateLength - * @param newKeyPassword - * @retval bool false on memory allocation failure - * @note We take a new copy of the certificate - */ - bool assign(const uint8_t* newKey, unsigned newKeyLength, const uint8_t* newCertificate, - unsigned newCertificateLength, const char* newKeyPassword = nullptr) - { - free(); - - if(newKeyLength != 0 && newKey != nullptr) { - if(!key.setLength(newKeyLength)) { - return false; - } - memcpy(key.begin(), newKey, newKeyLength); - } - - if(newCertificateLength != 0 && newCertificate != nullptr) { - if(!certificate.setLength(newCertificateLength)) { - return false; - } - memcpy(certificate.begin(), newCertificate, newCertificateLength); - } - - unsigned passwordLength = (newKeyPassword == nullptr) ? 0 : strlen(newKeyPassword); - if(passwordLength != 0) { - keyPassword.setString(newKeyPassword, passwordLength); - if(!keyPassword) { - return false; - } - } - - return true; - } - - /** @brief Assign another certificate to this structure - * @param keyCert - * @retval bool false on memory allocation failure - * @note We take a new copy of the certificate - */ - bool assign(const SslKeyCertPair& keyCert) - { - *this = keyCert; - return (key == keyCert.key) && (keyPassword == keyCert.keyPassword) && (certificate == keyCert.certificate); - } - - void free() - { - key = nullptr; - keyPassword = nullptr; - certificate = nullptr; - } - - const uint8_t* getKey() - { - return reinterpret_cast(key.c_str()); - } - - unsigned getKeyLength() - { - return key.length(); - } - - const char* getKeyPassword() - { - return keyPassword.c_str(); - } - - const uint8_t* getCertificate() - { - return reinterpret_cast(certificate.c_str()); - } - - unsigned getCertificateLength() - { - return certificate.length(); - } - -private: - String key; - String keyPassword; - String certificate; -}; +/**** + * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. + * Created 2015 by Skurydin Alexey + * http://github.com/anakod/Sming + * All files of the Sming Core are provided under the LGPL v3 license. + * + * SslKeyCertPair.h + * + ****/ + +#pragma once + +#include "ssl/ssl.h" +#include "WString.h" + +/** @brief Class to manage an SSL key certificate with optional password + */ +class SslKeyCertPair +{ +public: + bool isValid() + { + return key && certificate; + } + + /** @brief Create certificate using provided values + * @param newKey + * @param newKeyLength + * @param newCertificate + * @param newCertificateLength + * @param newKeyPassword + * @retval bool false on memory allocation failure + * @note We take a new copy of the certificate + */ + bool assign(const uint8_t* newKey, unsigned newKeyLength, const uint8_t* newCertificate, + unsigned newCertificateLength, const char* newKeyPassword = nullptr) + { + free(); + + if(newKeyLength != 0 && newKey != nullptr) { + if(!key.setLength(newKeyLength)) { + return false; + } + memcpy(key.begin(), newKey, newKeyLength); + } + + if(newCertificateLength != 0 && newCertificate != nullptr) { + if(!certificate.setLength(newCertificateLength)) { + return false; + } + memcpy(certificate.begin(), newCertificate, newCertificateLength); + } + + unsigned passwordLength = (newKeyPassword == nullptr) ? 0 : strlen(newKeyPassword); + if(passwordLength != 0) { + keyPassword.setString(newKeyPassword, passwordLength); + if(!keyPassword) { + return false; + } + } + + return true; + } + + /** @brief Assign another certificate to this structure + * @param keyCert + * @retval bool false on memory allocation failure + * @note We take a new copy of the certificate + */ + bool assign(const SslKeyCertPair& keyCert) + { + *this = keyCert; + return (key == keyCert.key) && (keyPassword == keyCert.keyPassword) && (certificate == keyCert.certificate); + } + + void free() + { + key = nullptr; + keyPassword = nullptr; + certificate = nullptr; + } + + const uint8_t* getKey() + { + return reinterpret_cast(key.c_str()); + } + + unsigned getKeyLength() + { + return key.length(); + } + + const char* getKeyPassword() + { + return keyPassword.c_str(); + } + + const uint8_t* getCertificate() + { + return reinterpret_cast(certificate.c_str()); + } + + unsigned getCertificateLength() + { + return certificate.length(); + } + +private: + String key; + String keyPassword; + String certificate; +}; diff --git a/Sming/Core/Network/Ssl/SslSessionId.h b/Sming/Core/Network/Ssl/SslSessionId.h index d2858687fd..af9fc67771 100644 --- a/Sming/Core/Network/Ssl/SslSessionId.h +++ b/Sming/Core/Network/Ssl/SslSessionId.h @@ -1,49 +1,49 @@ -/**** - * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. - * Created 2015 by Skurydin Alexey - * http://github.com/anakod/Sming - * All files of the Sming Core are provided under the LGPL v3 license. - * - * SslSessionId.h - * - ****/ - -#pragma once - -#include "ssl/ssl.h" -#include "WString.h" - -/** @brief Manages buffer to store SSL Session ID - */ -class SslSessionId -{ -public: - /** @brief May be called even when object is null */ - const uint8_t* getValue() - { - return this ? reinterpret_cast(value.c_str()) : nullptr; - } - - /** @brief May be called even when object is null */ - unsigned getLength() - { - return this ? value.length() : 0; - } - - bool isValid() - { - return getLength() != 0; - } - - bool assign(const uint8_t* newValue, unsigned newLength) - { - if(!value.setLength(newLength)) { - return false; - } - memcpy(value.begin(), newValue, newLength); - return true; - } - -private: - String value; -}; +/**** + * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. + * Created 2015 by Skurydin Alexey + * http://github.com/anakod/Sming + * All files of the Sming Core are provided under the LGPL v3 license. + * + * SslSessionId.h + * + ****/ + +#pragma once + +#include "ssl/ssl.h" +#include "WString.h" + +/** @brief Manages buffer to store SSL Session ID + */ +class SslSessionId +{ +public: + /** @brief May be called even when object is null */ + const uint8_t* getValue() + { + return this ? reinterpret_cast(value.c_str()) : nullptr; + } + + /** @brief May be called even when object is null */ + unsigned getLength() + { + return this ? value.length() : 0; + } + + bool isValid() + { + return getLength() != 0; + } + + bool assign(const uint8_t* newValue, unsigned newLength) + { + if(!value.setLength(newLength)) { + return false; + } + memcpy(value.begin(), newValue, newLength); + return true; + } + +private: + String value; +}; diff --git a/Sming/Core/Network/Ssl/SslStructs.h b/Sming/Core/Network/Ssl/SslStructs.h index b3a06dcb9b..5646058555 100644 --- a/Sming/Core/Network/Ssl/SslStructs.h +++ b/Sming/Core/Network/Ssl/SslStructs.h @@ -1,23 +1,23 @@ -/**** - * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. - * Created 2015 by Skurydin Alexey - * http://github.com/anakod/Sming - * All files of the Sming Core are provided under the LGPL v3 license. - * - * SslStructs.h - * - ****/ - -#pragma once - -#include "SslFingerprints.h" -#include "SslKeyCertPair.h" -#include "SslSessionId.h" - -/* - * These structures have been renamed, please use the revised convention SslXXX - */ -typedef SslKeyCertPair SSLKeyCertPair SMING_DEPRECATED; ///< @deprecated Use SslKeyCertPair instead -typedef SslSessionId SSLSessionId SMING_DEPRECATED; ///< @deprecated Use SslSessionId instead -typedef SslFingerprints SSLFingerprints SMING_DEPRECATED; ///< @deprecated Use SslFingerprints instead -typedef SslFingerprintType SSLFingerprintType SMING_DEPRECATED; ///< @deprecated Use SslFingerprintType instead +/**** + * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. + * Created 2015 by Skurydin Alexey + * http://github.com/anakod/Sming + * All files of the Sming Core are provided under the LGPL v3 license. + * + * SslStructs.h + * + ****/ + +#pragma once + +#include "SslFingerprints.h" +#include "SslKeyCertPair.h" +#include "SslSessionId.h" + +/* + * These structures have been renamed, please use the revised convention SslXXX + */ +typedef SslKeyCertPair SSLKeyCertPair SMING_DEPRECATED; ///< @deprecated Use SslKeyCertPair instead +typedef SslSessionId SSLSessionId SMING_DEPRECATED; ///< @deprecated Use SslSessionId instead +typedef SslFingerprints SSLFingerprints SMING_DEPRECATED; ///< @deprecated Use SslFingerprints instead +typedef SslFingerprintType SSLFingerprintType SMING_DEPRECATED; ///< @deprecated Use SslFingerprintType instead diff --git a/Sming/Core/Network/WebConstants.cpp b/Sming/Core/Network/WebConstants.cpp index 7dfaf58fd8..ed825fed5c 100644 --- a/Sming/Core/Network/WebConstants.cpp +++ b/Sming/Core/Network/WebConstants.cpp @@ -1,71 +1,71 @@ -/**** - * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. - * Created 2015 by Skurydin Alexey - * http://github.com/anakod/Sming - * All files of the Sming Core are provided under the LGPL v3 license. - * - * WebConstants.cpp - * - ****/ - -#include "WebConstants.h" -#include "FakePgmSpace.h" - -namespace ContentType -{ -// MIME type strings -#define XX(_name, _ext, _mime) static DEFINE_FSTR(mimestr_##_name, _mime); -MIME_TYPE_MAP(XX) -#undef XX - -static FSTR_TABLE(mimeStrings) = { -#define XX(_name, _ext, _mime) FSTR_PTR(mimestr_##_name), - MIME_TYPE_MAP(XX) -#undef XX -}; - -// File extensions -#define XX(_name, _ext, _mime) static DEFINE_FSTR(extstr_##_name, _ext); -MIME_TYPE_MAP(XX) -#undef XX - -static FSTR_TABLE(extensionStrings) = { -#define XX(_name, _ext, _mime) FSTR_PTR(extstr_##_name), - MIME_TYPE_MAP(XX) -#undef XX -}; - -String fromFileExtension(const char* extension) -{ - // We accept 'htm' or 'html', but the latter is preferred - if(strcasecmp(extension, _F("htm")) == 0) - return mimestr_HTML; - - for(unsigned i = 0; i < ARRAY_SIZE(extensionStrings); ++i) { - if(*extensionStrings[i] == extension) - return *mimeStrings[i]; - } - - // Type undefined - if (String) will return false - return nullptr; -} - -String toString(enum MimeType m) -{ - if(m >= ARRAY_SIZE(mimeStrings)) - return nullptr; - - return *mimeStrings[m]; -} - -String fromFullFileName(const char* fileName) -{ - if(!fileName) - return nullptr; - - const char* extension = strrchr(fileName, '.'); - - return extension ? fromFileExtension(extension + 1) : nullptr; -} - -}; // namespace ContentType +/**** + * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. + * Created 2015 by Skurydin Alexey + * http://github.com/anakod/Sming + * All files of the Sming Core are provided under the LGPL v3 license. + * + * WebConstants.cpp + * + ****/ + +#include "WebConstants.h" +#include "FakePgmSpace.h" + +namespace ContentType +{ +// MIME type strings +#define XX(_name, _ext, _mime) static DEFINE_FSTR(mimestr_##_name, _mime); +MIME_TYPE_MAP(XX) +#undef XX + +static FSTR_TABLE(mimeStrings) = { +#define XX(_name, _ext, _mime) FSTR_PTR(mimestr_##_name), + MIME_TYPE_MAP(XX) +#undef XX +}; + +// File extensions +#define XX(_name, _ext, _mime) static DEFINE_FSTR(extstr_##_name, _ext); +MIME_TYPE_MAP(XX) +#undef XX + +static FSTR_TABLE(extensionStrings) = { +#define XX(_name, _ext, _mime) FSTR_PTR(extstr_##_name), + MIME_TYPE_MAP(XX) +#undef XX +}; + +String fromFileExtension(const char* extension) +{ + // We accept 'htm' or 'html', but the latter is preferred + if(strcasecmp(extension, _F("htm")) == 0) + return mimestr_HTML; + + for(unsigned i = 0; i < ARRAY_SIZE(extensionStrings); ++i) { + if(*extensionStrings[i] == extension) + return *mimeStrings[i]; + } + + // Type undefined - if (String) will return false + return nullptr; +} + +String toString(enum MimeType m) +{ + if(m >= ARRAY_SIZE(mimeStrings)) + return nullptr; + + return *mimeStrings[m]; +} + +String fromFullFileName(const char* fileName) +{ + if(!fileName) + return nullptr; + + const char* extension = strrchr(fileName, '.'); + + return extension ? fromFileExtension(extension + 1) : nullptr; +} + +}; // namespace ContentType diff --git a/Sming/Libraries/ArduCAM/ArduCAM.h b/Sming/Libraries/ArduCAM/ArduCAM.h index f0f77d188c..d1c7004251 100644 --- a/Sming/Libraries/ArduCAM/ArduCAM.h +++ b/Sming/Libraries/ArduCAM/ArduCAM.h @@ -1,348 +1,348 @@ -/* - /* - ArduCAM.h - Arduino library support for CMOS Image Sensor - Copyright (C)2011-2015 ArduCAM.com. All right reserved - - Basic functionality of this library are based on the demo-code provided by - ArduCAM.com. You can find the latest version of the library at - http://www.ArduCAM.com - - Now supported controllers: - - OV7670 - - MT9D111 - - OV7675 - - OV2640 - - OV3640 - - OV5642 - - OV7660 - - OV7725 - - MT9M112 - - MT9V111 - - OV5640 - - MT9M001 - - MT9T112 - - MT9D112 - - We will add support for many other sensors in next release. - - Supported MCU platform - - Theoretically support all Arduino families - - Arduino UNO R3 (Tested) - - Arduino MEGA2560 R3 (Tested) - - Arduino Leonardo R3 (Tested) - - Arduino Nano (Tested) - - Arduino DUE (Tested) - - Arduino Yun (Tested) - - Raspberry Pi (Tested) - - ESP8266-12 (Tested) - - If you make any modifications or improvements to the code, I would appreciate - that you share the code with me so that I might include it in the next release. - I can be contacted through http://www.ArduCAM.com - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -/*------------------------------------ - Revision History: - 2012/09/20 V1.0.0 by Lee first release - 2012/10/23 V1.0.1 by Lee Resolved some timing issue for the Read/Write Register - 2012/11/29 V1.1.0 by Lee Add support for MT9D111 sensor - 2012/12/13 V1.2.0 by Lee Add support for OV7675 sensor - 2012/12/28 V1.3.0 by Lee Add support for OV2640,OV3640,OV5642 sensors - 2013/02/26 V2.0.0 by Lee New Rev.B shield hardware, add support for FIFO control - and support Mega1280/2560 boards - 2013/05/28 V2.1.0 by Lee Add support all drawing functions derived from UTFT library - 2013/08/24 V3.0.0 by Lee Support ArudCAM shield Rev.C hardware, features SPI interface and low power mode. - Support almost all series of Arduino boards including DUE. - 2014/03/09 V3.1.0 by Lee Add the more impressive example sketches. - Optimise the OV5642 settings, improve image quality. - Add live preview before JPEG capture. - Add play back photos one by one after BMP capture. - 2014/05/01 V3.1.1 by Lee Minor changes to add support Arduino IDE for linux distributions. - 2014/09/30 V3.2.0 by Lee Improvement on OV5642 camera dirver. - 2014/10/06 V3.3.0 by Lee Add OV7660,OV7725 camera support. - 2015/02/27 V3.4.0 by Lee Add the support for Arduino Yun board, update the latest UTFT library for ArduCAM. - 2015/06/09 V3.4.1 by Lee Minor changes and add some comments - 2015/06/19 V3.4.2 by Lee Add support for MT9M112 camera. - 2015/06/20 V3.4.3 by Lee Add support for MT9V111 camera. - 2015/06/22 V3.4.4 by Lee Add support for OV5640 camera. - 2015/06/22 V3.4.5 by Lee Add support for MT9M001 camera. - 2015/08/05 V3.4.6 by Lee Add support for MT9T112 camera. - 2015/08/08 V3.4.7 by Lee Add support for MT9D112 camera. - 2015/09/20 V3.4.8 by Lee Add support for ESP8266 processor. ---------------------------------------*/ - - -#ifndef ArduCAM_H -#define ArduCAM_H - -#include "Arduino.h" -#include - -#if defined (__AVR__) -#define cbi(reg, bitmask) *reg &= ~bitmask -#define sbi(reg, bitmask) *reg |= bitmask -#define pulse_high(reg, bitmask) sbi(reg, bitmask); cbi(reg, bitmask); -#define pulse_low(reg, bitmask) cbi(reg, bitmask); sbi(reg, bitmask); - -#define cport(port, data) port &= data -#define sport(port, data) port |= data - -#define swap(type, i, j) {type t = i; i = j; j = t;} - -#define fontbyte(x) pgm_read_byte(&cfont.font[x]) - -#define regtype volatile uint8_t -#define regsize uint8_t - -#endif - -#if defined(__arm__) - -#define cbi(reg, bitmask) *reg &= ~bitmask -#define sbi(reg, bitmask) *reg |= bitmask -#define pulse_high(reg, bitmask) sbi(reg, bitmask); cbi(reg, bitmask); -#define pulse_low(reg, bitmask) cbi(reg, bitmask); sbi(reg, bitmask); - -#define cport(port, data) port &= data -#define sport(port, data) port |= data - -#define swap(type, i, j) {type t = i; i = j; j = t;} - -#define fontbyte(x) cfont.font[x] - -#define regtype volatile uint32_t -#define regsize uint32_t -#define PROGMEM - - - #define pgm_read_byte(x) (*((char *)x)) -// #define pgm_read_word(x) (*((short *)(x & 0xfffffffe))) - #define pgm_read_word(x) ( ((*((unsigned char *)x + 1)) << 8) + (*((unsigned char *)x))) - #define pgm_read_byte_near(x) (*((char *)x)) - #define pgm_read_byte_far(x) (*((char *)x)) -// #define pgm_read_word_near(x) (*((short *)(x & 0xfffffffe)) -// #define pgm_read_word_far(x) (*((short *)(x & 0xfffffffe))) - #define pgm_read_word_near(x) ( ((*((unsigned char *)x + 1)) << 8) + (*((unsigned char *)x))) - #define pgm_read_word_far(x) ( ((*((unsigned char *)x + 1)) << 8) + (*((unsigned char *)x)))) - #define PSTR(x) x - #if defined F - #undef F - #endif - #define F(X) (X) - - -#endif - -#if defined(ESP8266) || defined(__ESP8266_EX__) - -#define cbi(reg, bitmask) digitalWrite(bitmask, LOW) -#define sbi(reg, bitmask) digitalWrite(bitmask, HIGH) -#define pulse_high(reg, bitmask) sbi(reg, bitmask); cbi(reg, bitmask); -#define pulse_low(reg, bitmask) cbi(reg, bitmask); sbi(reg, bitmask); - -#define cport(port, data) port &= data -#define sport(port, data) port |= data - -#define swap(type, i, j) {type t = i; i = j; j = t;} - -#define fontbyte(x) cfont.font[x] - -#define regtype volatile uint32_t -#define regsize uint32_t - -#endif - -/****************************************************/ -/* Sensor related definition */ -/****************************************************/ -#define BMP 0 -#define JPEG 1 - -#define OV7670 0 -#define MT9D111_A 1 -#define OV7675 2 -#define OV5642 3 -#define OV3640 4 -#define OV2640 5 -#define OV9655 6 -#define MT9M112 7 -#define OV7725 8 -#define OV7660 9 -#define MT9M001 10 -#define OV5640 11 -#define MT9D111_B 12 -#define OV9650 13 -#define MT9V111 14 -#define MT9T112 15 -#define MT9D112 16 - -#define OV2640_160x120 0 //160x120 -#define OV2640_176x144 1 //176x144 -#define OV2640_320x240 2 //320x240 -#define OV2640_352x288 3 //352x288 -#define OV2640_640x480 4 //640x480 -#define OV2640_800x600 5 //800x600 -#define OV2640_1024x768 6 //1024x768 -#define OV2640_1280x1024 7 //1280x1024 -#define OV2640_1600x1200 8 //1600x1200 - -#define OV5642_320x240 1 //320x240 -#define OV5642_640x480 2 //640x480 -#define OV5642_1280x720 3 //1280x720 -#define OV5642_1920x1080 4 //1920x1080 -#define OV5642_2048x1563 5 //2048x1563 -#define OV5642_2592x1944 6 //2592x1944 - -/****************************************************/ -/* I2C Control Definition */ -/****************************************************/ -#define I2C_ADDR_8BIT 0 -#define I2C_ADDR_16BIT 1 -#define I2C_REG_8BIT 0 -#define I2C_REG_16BIT 1 -#define I2C_DAT_8BIT 0 -#define I2C_DAT_16BIT 1 - -/* Register initialization tables for SENSORs */ -/* Terminating list entry for reg */ -#define SENSOR_REG_TERM_8BIT 0xFF -#define SENSOR_REG_TERM_16BIT 0xFFFF -/* Terminating list entry for val */ -#define SENSOR_VAL_TERM_8BIT 0xFF -#define SENSOR_VAL_TERM_16BIT 0xFFFF - -/****************************************************/ -/* ArduChip related definition */ -/****************************************************/ -#define RWBIT 0x80 //READ AND WRITE BIT IS BIT[7] - -#define ARDUCHIP_TEST1 0x00 //TEST register -#define ARDUCHIP_TEST2 0x01 //TEST register - -#define ARDUCHIP_FRAMES 0x01 //Bit[2:0]Number of frames to be captured - -#define ARDUCHIP_MODE 0x02 //Mode register -#define MCU2LCD_MODE 0x00 -#define CAM2LCD_MODE 0x01 -#define LCD2MCU_MODE 0x02 - -#define ARDUCHIP_TIM 0x03 //Timming control -#define HREF_LEVEL_MASK 0x01 //0 = High active , 1 = Low active -#define VSYNC_LEVEL_MASK 0x02 //0 = High active , 1 = Low active -#define LCD_BKEN_MASK 0x04 //0 = Enable, 1 = Disable -#define DELAY_MASK 0x08 //0 = no delay, 1 = delay one clock -#define MODE_MASK 0x10 //0 = LCD mode, 1 = FIFO mode -#define FIFO_PWRDN_MASK 0x20 //0 = Normal operation, 1 = FIFO power down -#define LOW_POWER_MODE 0x40 //0 = Normal mode, 1 = Low power mode - -#define ARDUCHIP_FIFO 0x04 //FIFO and I2C control -#define FIFO_CLEAR_MASK 0x01 -#define FIFO_START_MASK 0x02 -#define FIFO_RDPTR_RST_MASK 0x10 -#define FIFO_WRPTR_RST_MASK 0x20 - -#define ARDUCHIP_GPIO 0x06 //GPIO Write Register -#define GPIO_RESET_MASK 0x01 //0 = default state, 1 = Sensor reset IO value -#define GPIO_PWDN_MASK 0x02 //0 = Sensor power down IO value, 1 = Sensor power enable IO value - -#define BURST_FIFO_READ 0x3C //Burst FIFO read operation -#define SINGLE_FIFO_READ 0x3D //Single FIFO read operation - -#define ARDUCHIP_REV 0x40 //ArduCHIP revision -#define VER_LOW_MASK 0x3F -#define VER_HIGH_MASK 0xC0 - -#define ARDUCHIP_TRIG 0x41 //Trigger source -#define VSYNC_MASK 0x01 -#define SHUTTER_MASK 0x02 -#define CAP_DONE_MASK 0x08 - -#define FIFO_SIZE1 0x42 //Camera write FIFO size[7:0] for burst to read -#define FIFO_SIZE2 0x43 //Camera write FIFO size[15:8] -#define FIFO_SIZE3 0x44 //Camera write FIFO size[18:16] - - -/****************************************************/ - - -/****************************************************************/ -/* define a structure for sensor register initialization values */ -/****************************************************************/ -struct sensor_reg { - uint16_t reg; - uint16_t val; -}; - -class ArduCAM -{ - public: - ArduCAM(); - ArduCAM(byte model,int CS); - void InitCAM(); - - void CS_HIGH(void); - void CS_LOW(void); - - void flush_fifo(void); - void start_capture(void); - void clear_fifo_flag(void); - uint8_t read_fifo(void); - - uint8_t read_reg(uint8_t addr); - void write_reg(uint8_t addr, uint8_t data); - - uint32_t read_fifo_length(void); - void set_fifo_burst(void); - void set_bit(uint8_t addr, uint8_t bit); - void clear_bit(uint8_t addr, uint8_t bit); - uint8_t get_bit(uint8_t addr, uint8_t bit); - void set_mode(uint8_t mode); - - int wrSensorRegs(const struct sensor_reg*); - int wrSensorRegs8_8(const struct sensor_reg*); - int wrSensorRegs8_16(const struct sensor_reg*); - int wrSensorRegs16_8(const struct sensor_reg*); - int wrSensorRegs16_16(const struct sensor_reg*); - - byte wrSensorReg(int regID, int regDat); - byte wrSensorReg8_8(int regID, int regDat); - byte wrSensorReg8_16(int regID, int regDat); - byte wrSensorReg16_8(int regID, int regDat); - byte wrSensorReg16_16(int regID, int regDat); - - byte rdSensorReg8_8(uint8_t regID, uint8_t* regDat); - byte rdSensorReg16_8(uint16_t regID, uint8_t* regDat); - byte rdSensorReg8_16(uint8_t regID, uint16_t* regDat); - byte rdSensorReg16_16(uint16_t regID, uint16_t* regDat); - - void OV2640_set_JPEG_size(uint8_t size); - void OV5642_set_JPEG_size(uint8_t size); - void set_format(byte fmt); - byte get_format(); - - int bus_write(int address, int value); - uint8_t bus_read(int address); - protected: - regtype *P_CS; - regsize B_CS; - byte m_fmt; - byte sensor_model; - byte sensor_addr; - -}; - -#endif +/* + /* + ArduCAM.h - Arduino library support for CMOS Image Sensor + Copyright (C)2011-2015 ArduCAM.com. All right reserved + + Basic functionality of this library are based on the demo-code provided by + ArduCAM.com. You can find the latest version of the library at + http://www.ArduCAM.com + + Now supported controllers: + - OV7670 + - MT9D111 + - OV7675 + - OV2640 + - OV3640 + - OV5642 + - OV7660 + - OV7725 + - MT9M112 + - MT9V111 + - OV5640 + - MT9M001 + - MT9T112 + - MT9D112 + + We will add support for many other sensors in next release. + + Supported MCU platform + - Theoretically support all Arduino families + - Arduino UNO R3 (Tested) + - Arduino MEGA2560 R3 (Tested) + - Arduino Leonardo R3 (Tested) + - Arduino Nano (Tested) + - Arduino DUE (Tested) + - Arduino Yun (Tested) + - Raspberry Pi (Tested) + - ESP8266-12 (Tested) + + If you make any modifications or improvements to the code, I would appreciate + that you share the code with me so that I might include it in the next release. + I can be contacted through http://www.ArduCAM.com + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +/*------------------------------------ + Revision History: + 2012/09/20 V1.0.0 by Lee first release + 2012/10/23 V1.0.1 by Lee Resolved some timing issue for the Read/Write Register + 2012/11/29 V1.1.0 by Lee Add support for MT9D111 sensor + 2012/12/13 V1.2.0 by Lee Add support for OV7675 sensor + 2012/12/28 V1.3.0 by Lee Add support for OV2640,OV3640,OV5642 sensors + 2013/02/26 V2.0.0 by Lee New Rev.B shield hardware, add support for FIFO control + and support Mega1280/2560 boards + 2013/05/28 V2.1.0 by Lee Add support all drawing functions derived from UTFT library + 2013/08/24 V3.0.0 by Lee Support ArudCAM shield Rev.C hardware, features SPI interface and low power mode. + Support almost all series of Arduino boards including DUE. + 2014/03/09 V3.1.0 by Lee Add the more impressive example sketches. + Optimise the OV5642 settings, improve image quality. + Add live preview before JPEG capture. + Add play back photos one by one after BMP capture. + 2014/05/01 V3.1.1 by Lee Minor changes to add support Arduino IDE for linux distributions. + 2014/09/30 V3.2.0 by Lee Improvement on OV5642 camera dirver. + 2014/10/06 V3.3.0 by Lee Add OV7660,OV7725 camera support. + 2015/02/27 V3.4.0 by Lee Add the support for Arduino Yun board, update the latest UTFT library for ArduCAM. + 2015/06/09 V3.4.1 by Lee Minor changes and add some comments + 2015/06/19 V3.4.2 by Lee Add support for MT9M112 camera. + 2015/06/20 V3.4.3 by Lee Add support for MT9V111 camera. + 2015/06/22 V3.4.4 by Lee Add support for OV5640 camera. + 2015/06/22 V3.4.5 by Lee Add support for MT9M001 camera. + 2015/08/05 V3.4.6 by Lee Add support for MT9T112 camera. + 2015/08/08 V3.4.7 by Lee Add support for MT9D112 camera. + 2015/09/20 V3.4.8 by Lee Add support for ESP8266 processor. +--------------------------------------*/ + + +#ifndef ArduCAM_H +#define ArduCAM_H + +#include "Arduino.h" +#include + +#if defined (__AVR__) +#define cbi(reg, bitmask) *reg &= ~bitmask +#define sbi(reg, bitmask) *reg |= bitmask +#define pulse_high(reg, bitmask) sbi(reg, bitmask); cbi(reg, bitmask); +#define pulse_low(reg, bitmask) cbi(reg, bitmask); sbi(reg, bitmask); + +#define cport(port, data) port &= data +#define sport(port, data) port |= data + +#define swap(type, i, j) {type t = i; i = j; j = t;} + +#define fontbyte(x) pgm_read_byte(&cfont.font[x]) + +#define regtype volatile uint8_t +#define regsize uint8_t + +#endif + +#if defined(__arm__) + +#define cbi(reg, bitmask) *reg &= ~bitmask +#define sbi(reg, bitmask) *reg |= bitmask +#define pulse_high(reg, bitmask) sbi(reg, bitmask); cbi(reg, bitmask); +#define pulse_low(reg, bitmask) cbi(reg, bitmask); sbi(reg, bitmask); + +#define cport(port, data) port &= data +#define sport(port, data) port |= data + +#define swap(type, i, j) {type t = i; i = j; j = t;} + +#define fontbyte(x) cfont.font[x] + +#define regtype volatile uint32_t +#define regsize uint32_t +#define PROGMEM + + + #define pgm_read_byte(x) (*((char *)x)) +// #define pgm_read_word(x) (*((short *)(x & 0xfffffffe))) + #define pgm_read_word(x) ( ((*((unsigned char *)x + 1)) << 8) + (*((unsigned char *)x))) + #define pgm_read_byte_near(x) (*((char *)x)) + #define pgm_read_byte_far(x) (*((char *)x)) +// #define pgm_read_word_near(x) (*((short *)(x & 0xfffffffe)) +// #define pgm_read_word_far(x) (*((short *)(x & 0xfffffffe))) + #define pgm_read_word_near(x) ( ((*((unsigned char *)x + 1)) << 8) + (*((unsigned char *)x))) + #define pgm_read_word_far(x) ( ((*((unsigned char *)x + 1)) << 8) + (*((unsigned char *)x)))) + #define PSTR(x) x + #if defined F + #undef F + #endif + #define F(X) (X) + + +#endif + +#if defined(ESP8266) || defined(__ESP8266_EX__) + +#define cbi(reg, bitmask) digitalWrite(bitmask, LOW) +#define sbi(reg, bitmask) digitalWrite(bitmask, HIGH) +#define pulse_high(reg, bitmask) sbi(reg, bitmask); cbi(reg, bitmask); +#define pulse_low(reg, bitmask) cbi(reg, bitmask); sbi(reg, bitmask); + +#define cport(port, data) port &= data +#define sport(port, data) port |= data + +#define swap(type, i, j) {type t = i; i = j; j = t;} + +#define fontbyte(x) cfont.font[x] + +#define regtype volatile uint32_t +#define regsize uint32_t + +#endif + +/****************************************************/ +/* Sensor related definition */ +/****************************************************/ +#define BMP 0 +#define JPEG 1 + +#define OV7670 0 +#define MT9D111_A 1 +#define OV7675 2 +#define OV5642 3 +#define OV3640 4 +#define OV2640 5 +#define OV9655 6 +#define MT9M112 7 +#define OV7725 8 +#define OV7660 9 +#define MT9M001 10 +#define OV5640 11 +#define MT9D111_B 12 +#define OV9650 13 +#define MT9V111 14 +#define MT9T112 15 +#define MT9D112 16 + +#define OV2640_160x120 0 //160x120 +#define OV2640_176x144 1 //176x144 +#define OV2640_320x240 2 //320x240 +#define OV2640_352x288 3 //352x288 +#define OV2640_640x480 4 //640x480 +#define OV2640_800x600 5 //800x600 +#define OV2640_1024x768 6 //1024x768 +#define OV2640_1280x1024 7 //1280x1024 +#define OV2640_1600x1200 8 //1600x1200 + +#define OV5642_320x240 1 //320x240 +#define OV5642_640x480 2 //640x480 +#define OV5642_1280x720 3 //1280x720 +#define OV5642_1920x1080 4 //1920x1080 +#define OV5642_2048x1563 5 //2048x1563 +#define OV5642_2592x1944 6 //2592x1944 + +/****************************************************/ +/* I2C Control Definition */ +/****************************************************/ +#define I2C_ADDR_8BIT 0 +#define I2C_ADDR_16BIT 1 +#define I2C_REG_8BIT 0 +#define I2C_REG_16BIT 1 +#define I2C_DAT_8BIT 0 +#define I2C_DAT_16BIT 1 + +/* Register initialization tables for SENSORs */ +/* Terminating list entry for reg */ +#define SENSOR_REG_TERM_8BIT 0xFF +#define SENSOR_REG_TERM_16BIT 0xFFFF +/* Terminating list entry for val */ +#define SENSOR_VAL_TERM_8BIT 0xFF +#define SENSOR_VAL_TERM_16BIT 0xFFFF + +/****************************************************/ +/* ArduChip related definition */ +/****************************************************/ +#define RWBIT 0x80 //READ AND WRITE BIT IS BIT[7] + +#define ARDUCHIP_TEST1 0x00 //TEST register +#define ARDUCHIP_TEST2 0x01 //TEST register + +#define ARDUCHIP_FRAMES 0x01 //Bit[2:0]Number of frames to be captured + +#define ARDUCHIP_MODE 0x02 //Mode register +#define MCU2LCD_MODE 0x00 +#define CAM2LCD_MODE 0x01 +#define LCD2MCU_MODE 0x02 + +#define ARDUCHIP_TIM 0x03 //Timming control +#define HREF_LEVEL_MASK 0x01 //0 = High active , 1 = Low active +#define VSYNC_LEVEL_MASK 0x02 //0 = High active , 1 = Low active +#define LCD_BKEN_MASK 0x04 //0 = Enable, 1 = Disable +#define DELAY_MASK 0x08 //0 = no delay, 1 = delay one clock +#define MODE_MASK 0x10 //0 = LCD mode, 1 = FIFO mode +#define FIFO_PWRDN_MASK 0x20 //0 = Normal operation, 1 = FIFO power down +#define LOW_POWER_MODE 0x40 //0 = Normal mode, 1 = Low power mode + +#define ARDUCHIP_FIFO 0x04 //FIFO and I2C control +#define FIFO_CLEAR_MASK 0x01 +#define FIFO_START_MASK 0x02 +#define FIFO_RDPTR_RST_MASK 0x10 +#define FIFO_WRPTR_RST_MASK 0x20 + +#define ARDUCHIP_GPIO 0x06 //GPIO Write Register +#define GPIO_RESET_MASK 0x01 //0 = default state, 1 = Sensor reset IO value +#define GPIO_PWDN_MASK 0x02 //0 = Sensor power down IO value, 1 = Sensor power enable IO value + +#define BURST_FIFO_READ 0x3C //Burst FIFO read operation +#define SINGLE_FIFO_READ 0x3D //Single FIFO read operation + +#define ARDUCHIP_REV 0x40 //ArduCHIP revision +#define VER_LOW_MASK 0x3F +#define VER_HIGH_MASK 0xC0 + +#define ARDUCHIP_TRIG 0x41 //Trigger source +#define VSYNC_MASK 0x01 +#define SHUTTER_MASK 0x02 +#define CAP_DONE_MASK 0x08 + +#define FIFO_SIZE1 0x42 //Camera write FIFO size[7:0] for burst to read +#define FIFO_SIZE2 0x43 //Camera write FIFO size[15:8] +#define FIFO_SIZE3 0x44 //Camera write FIFO size[18:16] + + +/****************************************************/ + + +/****************************************************************/ +/* define a structure for sensor register initialization values */ +/****************************************************************/ +struct sensor_reg { + uint16_t reg; + uint16_t val; +}; + +class ArduCAM +{ + public: + ArduCAM(); + ArduCAM(byte model,int CS); + void InitCAM(); + + void CS_HIGH(void); + void CS_LOW(void); + + void flush_fifo(void); + void start_capture(void); + void clear_fifo_flag(void); + uint8_t read_fifo(void); + + uint8_t read_reg(uint8_t addr); + void write_reg(uint8_t addr, uint8_t data); + + uint32_t read_fifo_length(void); + void set_fifo_burst(void); + void set_bit(uint8_t addr, uint8_t bit); + void clear_bit(uint8_t addr, uint8_t bit); + uint8_t get_bit(uint8_t addr, uint8_t bit); + void set_mode(uint8_t mode); + + int wrSensorRegs(const struct sensor_reg*); + int wrSensorRegs8_8(const struct sensor_reg*); + int wrSensorRegs8_16(const struct sensor_reg*); + int wrSensorRegs16_8(const struct sensor_reg*); + int wrSensorRegs16_16(const struct sensor_reg*); + + byte wrSensorReg(int regID, int regDat); + byte wrSensorReg8_8(int regID, int regDat); + byte wrSensorReg8_16(int regID, int regDat); + byte wrSensorReg16_8(int regID, int regDat); + byte wrSensorReg16_16(int regID, int regDat); + + byte rdSensorReg8_8(uint8_t regID, uint8_t* regDat); + byte rdSensorReg16_8(uint16_t regID, uint8_t* regDat); + byte rdSensorReg8_16(uint8_t regID, uint16_t* regDat); + byte rdSensorReg16_16(uint16_t regID, uint16_t* regDat); + + void OV2640_set_JPEG_size(uint8_t size); + void OV5642_set_JPEG_size(uint8_t size); + void set_format(byte fmt); + byte get_format(); + + int bus_write(int address, int value); + uint8_t bus_read(int address); + protected: + regtype *P_CS; + regsize B_CS; + byte m_fmt; + byte sensor_model; + byte sensor_addr; + +}; + +#endif diff --git a/Sming/Platform/OsMessageInterceptor.cpp b/Sming/Platform/OsMessageInterceptor.cpp index 90e00979a9..28824c0697 100644 --- a/Sming/Platform/OsMessageInterceptor.cpp +++ b/Sming/Platform/OsMessageInterceptor.cpp @@ -1,40 +1,40 @@ -/**** - * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. - * Created 2015 by Skurydin Alexey - * http://github.com/SmingHub/Sming - * All files of the Sming Core are provided under the LGPL v3 license. - * - * OsMessageInterceptor.h - * - * author mikee47 Feb 2019 - * - ****/ - -#include "Platform/OsMessageInterceptor.h" - -extern void uart_debug_putc(char); - -OsMessageInterceptor* OsMessageInterceptor::self; - -void OsMessageInterceptor::putc(char c) -{ - c = message.addChar(c); - if(c == '\n' && callback) { - callback(message); - message.clear(); - } -} - -void OsMessageInterceptor::begin(OsMessageCallback callback) -{ - this->callback = callback; - message.clear(); - self = this; - ets_install_putc1(static_putc); - system_set_os_print(true); -} - -void OsMessageInterceptor::end() -{ - ets_install_putc1(uart_debug_putc); -} +/**** + * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. + * Created 2015 by Skurydin Alexey + * http://github.com/SmingHub/Sming + * All files of the Sming Core are provided under the LGPL v3 license. + * + * OsMessageInterceptor.h + * + * author mikee47 Feb 2019 + * + ****/ + +#include "Platform/OsMessageInterceptor.h" + +extern void uart_debug_putc(char); + +OsMessageInterceptor* OsMessageInterceptor::self; + +void OsMessageInterceptor::putc(char c) +{ + c = message.addChar(c); + if(c == '\n' && callback) { + callback(message); + message.clear(); + } +} + +void OsMessageInterceptor::begin(OsMessageCallback callback) +{ + this->callback = callback; + message.clear(); + self = this; + ets_install_putc1(static_putc); + system_set_os_print(true); +} + +void OsMessageInterceptor::end() +{ + ets_install_putc1(uart_debug_putc); +} diff --git a/Sming/Platform/OsMessageInterceptor.h b/Sming/Platform/OsMessageInterceptor.h index 3b16f0013b..1f1d4ac4bc 100644 --- a/Sming/Platform/OsMessageInterceptor.h +++ b/Sming/Platform/OsMessageInterceptor.h @@ -1,99 +1,99 @@ -/**** - * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. - * Created 2015 by Skurydin Alexey - * http://github.com/SmingHub/Sming - * All files of the Sming Core are provided under the LGPL v3 license. - * - * OsMessageInterceptor.h - * Support for intercepting OS debug output (calls to os_printf, etc.) - * - * author mikee47 Feb 2019 - * - * Provided to assist with tracking down the origin of error messages output by SDK. - * This is usually done in conjunction with the debugger or by performing a stack dump - * to establish the origin of the problem code. - * - * Example usage: - - static OsMessageInterceptor osMessageInterceptor; - - void handleOsMessage(OsMessage& msg) - { - debug_w("[OS] %s", msg.getBuffer()); - if(msg.startsWith("E:M ")) { - // Handle memory error - } else if(msg.contains(" assert ")) { - // Handle 'assert' message - } - } - - void init() - { - ... - - osMessageInterceptor.begin(handleOsMessage); - - // Example of 'bad' system call, generates "E:M 0" message - os_malloc(0); - - ... - } - - * - * - ****/ - -#pragma once - -#include "Data/Buffer/LineBuffer.h" - -/** - * @brief Fixed-size buffer for OS messages - */ -typedef LineBuffer<128> OsMessage; - -/** - * @brief Callback to receive OS message line - * @param msg The message - * @note We don't use std::function because it produces a more elaborate stack trace without any real benefit - */ -typedef void (*OsMessageCallback)(OsMessage& message); - -/** - * @brief Class to handle interception of OS messages - * @note Messages are output character-by-character so must be reassembled into lines - * before passing to callback function - */ -class OsMessageInterceptor -{ -public: - ~OsMessageInterceptor() - { - end(); - } - - /** - * @brief Enable message interception - * @param callback Function to receive messages - * @note Messages are suppressed from output during interception. If you wish to send them to - * the uart, etc. then do this in the callback. - */ - void begin(OsMessageCallback callback); - - /** - * @brief Stop message interception and revert to output via uart driver - */ - void end(); - -protected: - void putc(char c); - - static void static_putc(char c) - { - self->putc(c); - } - -private: - OsMessage message; - OsMessageCallback callback = nullptr; ///< User-provided callback - static OsMessageInterceptor* self; -}; +/**** + * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. + * Created 2015 by Skurydin Alexey + * http://github.com/SmingHub/Sming + * All files of the Sming Core are provided under the LGPL v3 license. + * + * OsMessageInterceptor.h - * Support for intercepting OS debug output (calls to os_printf, etc.) + * + * author mikee47 Feb 2019 + * + * Provided to assist with tracking down the origin of error messages output by SDK. + * This is usually done in conjunction with the debugger or by performing a stack dump + * to establish the origin of the problem code. + * + * Example usage: + + static OsMessageInterceptor osMessageInterceptor; + + void handleOsMessage(OsMessage& msg) + { + debug_w("[OS] %s", msg.getBuffer()); + if(msg.startsWith("E:M ")) { + // Handle memory error + } else if(msg.contains(" assert ")) { + // Handle 'assert' message + } + } + + void init() + { + ... + + osMessageInterceptor.begin(handleOsMessage); + + // Example of 'bad' system call, generates "E:M 0" message + os_malloc(0); + + ... + } + + * + * + ****/ + +#pragma once + +#include "Data/Buffer/LineBuffer.h" + +/** + * @brief Fixed-size buffer for OS messages + */ +typedef LineBuffer<128> OsMessage; + +/** + * @brief Callback to receive OS message line + * @param msg The message + * @note We don't use std::function because it produces a more elaborate stack trace without any real benefit + */ +typedef void (*OsMessageCallback)(OsMessage& message); + +/** + * @brief Class to handle interception of OS messages + * @note Messages are output character-by-character so must be reassembled into lines + * before passing to callback function + */ +class OsMessageInterceptor +{ +public: + ~OsMessageInterceptor() + { + end(); + } + + /** + * @brief Enable message interception + * @param callback Function to receive messages + * @note Messages are suppressed from output during interception. If you wish to send them to + * the uart, etc. then do this in the callback. + */ + void begin(OsMessageCallback callback); + + /** + * @brief Stop message interception and revert to output via uart driver + */ + void end(); + +protected: + void putc(char c); + + static void static_putc(char c) + { + self->putc(c); + } + +private: + OsMessage message; + OsMessageCallback callback = nullptr; ///< User-provided callback + static OsMessageInterceptor* self; +}; diff --git a/Sming/Platform/WifiSniffer.h b/Sming/Platform/WifiSniffer.h index 8a8a91ed1f..e4fde58572 100644 --- a/Sming/Platform/WifiSniffer.h +++ b/Sming/Platform/WifiSniffer.h @@ -1,143 +1,143 @@ -/**** - * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. - * Created 2015 by Skurydin Alexey - * http://github.com/anakod/Sming - * All files of the Sming Core are provided under the LGPL v3 license. - * - * WifiSniffer.h - * - * Original code by Ray Burnette http://www.hackster.io/rayburne/projects - * - * Adapted for use with Sming March 2019 mikee47 - * - * See ESP8266 non-OS SDK Version 3.0, section 3.11: Sniffer Related APIs - * - ****/ - -#pragma once - -#include "System.h" -#include "WVector.h" - -#define ETH_MAC_LEN 6 - -/** - * @brief Decoded Wifi beacon (Access Point) information - */ -struct BeaconInfo { - uint8_t bssid[ETH_MAC_LEN]; - uint8_t ssid[33]; - uint8_t ssid_len; - uint8_t channel; - int8_t err; - int8_t rssi; - uint8_t capa[2]; -}; - -/** - * @brief Decoded Wifi client information - */ -struct ClientInfo { - uint8_t bssid[ETH_MAC_LEN]; - uint8_t station[ETH_MAC_LEN]; - uint8_t ap[ETH_MAC_LEN]; - uint8_t channel; - int8_t err; - int8_t rssi; - uint16_t seq_n; -}; - -/** - * @brief For applications to use to manage list of unique beacons - */ -class BeaconInfoList : public Vector -{ -public: - int indexOf(const uint8_t bssid[]) - { - for(unsigned i = 0; i < count(); ++i) { - if(memcmp(elementAt(i).bssid, bssid, ETH_MAC_LEN) == 0) { - return i; - } - } - - return -1; - } -}; - -/** - * @brief For applications to use to manage list of unique clients - */ -class ClientInfoList : public Vector -{ -public: - int indexOf(const uint8_t station[]) - { - for(unsigned i = 0; i < count(); ++i) { - if(memcmp(elementAt(i).station, station, ETH_MAC_LEN) == 0) { - return i; - } - } - - return -1; - } -}; - -typedef std::function WifiSnifferCallback; -typedef std::function WifiBeaconCallback; -typedef std::function WifiClientCallback; - -class WifiSniffer : public ISystemReadyHandler -{ -public: - /** @brief Initialise the sniffer */ - void begin(); - - /** @brief Stop the sniffer */ - void end(); - - /** @brief Register notification for beacon (AP) info */ - void onBeacon(WifiBeaconCallback callback) - { - beaconCallback = callback; - } - - /** @brief Register notification for client info */ - void onClient(WifiClientCallback callback) - { - clientCallback = callback; - } - - /** @brief Register notification for all incoming data - * @note Callback invoked for all packet types, including beacon/client - */ - void onSniff(WifiSnifferCallback callback) - { - snifferCallback = callback; - } - - /** @brief Set the channel to listen on - * @param channel - */ - void setChannel(unsigned channel) - { - wifi_set_channel(channel); - } - - /** @brief Get the current channel being listened on */ - unsigned getChannel() - { - return wifi_get_channel(); - } - -private: - /** @brief Perform actual initialisation only when system has been fully initialised */ - void onSystemReady() override; - - /** @brief Parse received Wifi data */ - static void parseData(uint8_t* buf, uint16_t len); - - static WifiSnifferCallback snifferCallback; - static WifiBeaconCallback beaconCallback; - static WifiClientCallback clientCallback; -}; +/**** + * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. + * Created 2015 by Skurydin Alexey + * http://github.com/anakod/Sming + * All files of the Sming Core are provided under the LGPL v3 license. + * + * WifiSniffer.h + * + * Original code by Ray Burnette http://www.hackster.io/rayburne/projects + * + * Adapted for use with Sming March 2019 mikee47 + * + * See ESP8266 non-OS SDK Version 3.0, section 3.11: Sniffer Related APIs + * + ****/ + +#pragma once + +#include "System.h" +#include "WVector.h" + +#define ETH_MAC_LEN 6 + +/** + * @brief Decoded Wifi beacon (Access Point) information + */ +struct BeaconInfo { + uint8_t bssid[ETH_MAC_LEN]; + uint8_t ssid[33]; + uint8_t ssid_len; + uint8_t channel; + int8_t err; + int8_t rssi; + uint8_t capa[2]; +}; + +/** + * @brief Decoded Wifi client information + */ +struct ClientInfo { + uint8_t bssid[ETH_MAC_LEN]; + uint8_t station[ETH_MAC_LEN]; + uint8_t ap[ETH_MAC_LEN]; + uint8_t channel; + int8_t err; + int8_t rssi; + uint16_t seq_n; +}; + +/** + * @brief For applications to use to manage list of unique beacons + */ +class BeaconInfoList : public Vector +{ +public: + int indexOf(const uint8_t bssid[]) + { + for(unsigned i = 0; i < count(); ++i) { + if(memcmp(elementAt(i).bssid, bssid, ETH_MAC_LEN) == 0) { + return i; + } + } + + return -1; + } +}; + +/** + * @brief For applications to use to manage list of unique clients + */ +class ClientInfoList : public Vector +{ +public: + int indexOf(const uint8_t station[]) + { + for(unsigned i = 0; i < count(); ++i) { + if(memcmp(elementAt(i).station, station, ETH_MAC_LEN) == 0) { + return i; + } + } + + return -1; + } +}; + +typedef std::function WifiSnifferCallback; +typedef std::function WifiBeaconCallback; +typedef std::function WifiClientCallback; + +class WifiSniffer : public ISystemReadyHandler +{ +public: + /** @brief Initialise the sniffer */ + void begin(); + + /** @brief Stop the sniffer */ + void end(); + + /** @brief Register notification for beacon (AP) info */ + void onBeacon(WifiBeaconCallback callback) + { + beaconCallback = callback; + } + + /** @brief Register notification for client info */ + void onClient(WifiClientCallback callback) + { + clientCallback = callback; + } + + /** @brief Register notification for all incoming data + * @note Callback invoked for all packet types, including beacon/client + */ + void onSniff(WifiSnifferCallback callback) + { + snifferCallback = callback; + } + + /** @brief Set the channel to listen on + * @param channel + */ + void setChannel(unsigned channel) + { + wifi_set_channel(channel); + } + + /** @brief Get the current channel being listened on */ + unsigned getChannel() + { + return wifi_get_channel(); + } + +private: + /** @brief Perform actual initialisation only when system has been fully initialised */ + void onSystemReady() override; + + /** @brief Parse received Wifi data */ + static void parseData(uint8_t* buf, uint16_t len); + + static WifiSnifferCallback snifferCallback; + static WifiBeaconCallback beaconCallback; + static WifiClientCallback clientCallback; +}; diff --git a/Sming/SmingCore/SmingCore.h b/Sming/SmingCore/SmingCore.h index 8a298d6664..db67dcea05 100644 --- a/Sming/SmingCore/SmingCore.h +++ b/Sming/SmingCore/SmingCore.h @@ -1,3 +1,3 @@ -#include -#pragma warning "Please update to #include " -#pragma warning "See https://github.com/SmingHub/Sming/wiki/migrate-v3.8-v4.0" +#include +#pragma warning "Please update to #include " +#pragma warning "See https://github.com/SmingHub/Sming/wiki/migrate-v3.8-v4.0" diff --git a/Sming/System/include/gdb/gdb_syscall.h b/Sming/System/include/gdb/gdb_syscall.h index 6ba7cda779..4ee90ce0b7 100644 --- a/Sming/System/include/gdb/gdb_syscall.h +++ b/Sming/System/include/gdb/gdb_syscall.h @@ -1,422 +1,422 @@ -/**** - * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. - * Created 2015 by Skurydin Alexey - * http://github.com/SmingHub/Sming - * All files of the Sming Core are provided under the LGPL v3 license. - * - * gdb_syscall.h - Support for GDB file I/O - * - * @author: 2019 - Mikee47 - * - * An API is defined for communicating with GDB using the 'file-I/O protocol', but the name is misleading - * as it can also perform functions not related to file (or console) I/O. The functions are generally - * POSIX compatible so for further details consult the appropriate reference for your operating system. - * - * This is a synchronous protocol, so only one request may be in progress at a time. - * While a request is in progress GDB will not respond to any notifications from the target - including debug output. - * - * All functions are implemented with an optional callback routine, which is essential when reading the - * console as it can take a considerable time to execute. - * - * To use in your application, build with GDBSTUB_ENABLE_SYSCALL=1 and #include this header. - * - * @see https://sourceware.org/gdb/current/onlinedocs/gdb/File_002dI_002fO-Remote-Protocol-Extension.html - * - ****/ - -#pragma once - -#include -#include -#include -#include -#include - -/** @defgroup gdb_syscall GDB system call API - * @ingroup GDB - * @{ -*/ - -#pragma pack(push, 4) - -/** - * @brief GDB uses a specific version of the stat structure, 64 bytes in size - */ -struct gdb_stat_t { - uint32_t st_dev; // device - uint32_t st_ino; // inode - mode_t st_mode; // protection - uint32_t st_nlink; // number of hard links - uint32_t st_uid; // user ID of owner - uint32_t st_gid; // group ID of owner - uint32_t st_rdev; // device type (if inode device) - uint64_t st_size; // total size, in bytes - uint64_t st_blksize; // blocksize for filesystem I/O - uint64_t st_blocks; // number of blocks allocated - time_t st_atime; // time of last access - time_t st_mtime; // time of last modification - time_t st_ctime; // time of last change -}; - -/** - * @brief GDB uses a specific version of the timeval structure, 12 bytes in size (manual says 8, which is wrong) - */ -struct gdb_timeval_t { - time_t tv_sec; // second - uint64_t tv_usec; // microsecond -}; - -#pragma pack(pop) - -/* GDB Syscall interface */ - -/** - * @brief Enumeration defining available commands - */ -enum GdbSyscallCommand { - eGDBSYS_open, - eGDBSYS_close, - eGDBSYS_read, - eGDBSYS_write, - eGDBSYS_lseek, - eGDBSYS_rename, - eGDBSYS_unlink, - eGDBSYS_stat, - eGDBSYS_fstat, - eGDBSYS_gettimeofday, - eGDBSYS_isatty, - eGDBSYS_system, -}; - -struct GdbSyscallInfo; - -/** - * @brief GDB Syscall completion callback function - * @param info Reference to request information, containing result code and user-provided 'param' - */ -typedef void (*gdb_syscall_callback_t)(const GdbSyscallInfo& info); - -/** - * @brief GDB Syscall request information - */ -struct GdbSyscallInfo { - GdbSyscallCommand command; ///< The syscall command - gdb_syscall_callback_t callback; ///< User-supplied callback (if any) - void* param; ///< User-supplied parameter for callback - int result; ///< Final result of syscall - // Command parameters - union { - struct { - const char* filename; - int flags; - int mode; - } open; - struct { - int fd; - } close; - struct { - int fd; - void* buffer; - size_t bufSize; - } read; - struct { - int fd; - const void* buffer; - size_t count; - } write; - struct { - int fd; - long offset; - int whence; - } lseek; - struct { - const char* oldpath; - const char* newpath; - } rename; - struct { - const char* pathname; - } unlink; - struct { - const char* pathname; - gdb_stat_t* buf; - } stat; - struct { - int fd; - struct gdb_stat_t* buf; - } fstat; - struct { - gdb_timeval_t* tv; - void* tz; - } gettimeofday; - struct { - int fd; - } isatty; - struct { - const char* command; - } system; - }; -}; - -/** - * @brief Stub function to perform a syscall. Implemented by GDB stub. - * @param info Call request information - * @retval Error code, < 0 for error or >= 0 for success - * - * @note If info.callback is null then the function waits until the request has been completed, - * and returns the result of the syscall. - * If info.callback is not null, then this function returns 0 to indicate the request is in progress, - * or a negative error value to indicate the request could not be started. - * - * @note A copy of the request information is made and a reference passed to the completion callback - * function if one is used. Note that this is _not_ the original structure, so it does not have to be - * persisent, although any char* or other pointers MUST remain valid until the call is completed. - */ -int gdb_syscall(const GdbSyscallInfo& info); - -/** - * @brief Open a file on the host - * @param filename Name of file to open, relative to current directory (typically the Sming application folder) - * @param flags A combination of O_* flags defined in fcntl.h (e.g. O_RDONLY, O_CREAT, etc) - * @param mode See sys/stat.h - * @param callback - * @param param - * @retval int - * @see https://sourceware.org/gdb/current/onlinedocs/gdb/open.html - */ -static inline int gdb_syscall_open(const char* filename, int flags, int mode, gdb_syscall_callback_t callback = nullptr, - void* param = nullptr) -{ - GdbSyscallInfo info = {eGDBSYS_open, callback, param}; - info.open.filename = filename; - info.open.flags = flags; - info.open.mode = mode; - return gdb_syscall(info); -} - -/** - * @brief Close a host file - * @param fd File handle - * @param flags A combination of O_* flags defined in fcntl.h (e.g. O_RDONLY, O_CREAT, etc) - * @param callback - * @param param - * @retval int - * @see https://sourceware.org/gdb/current/onlinedocs/gdb/close.html - */ -static inline int gdb_syscall_close(int fd, gdb_syscall_callback_t callback = nullptr, void* param = nullptr) -{ - GdbSyscallInfo info = {eGDBSYS_close, callback, param}; - info.close.fd = fd; - return gdb_syscall(info); -} - -/** - * @brief Read data from a host file - * @param fd File handle - * @param buffer - * @param bufSize - * @param callback - * @param param - * @retval int - * @see https://sourceware.org/gdb/current/onlinedocs/gdb/read.html - */ -static inline int gdb_syscall_read(int fd, void* buffer, size_t bufSize, gdb_syscall_callback_t callback = nullptr, - void* param = nullptr) -{ - GdbSyscallInfo info = {eGDBSYS_read, callback, param}; - info.read.fd = fd; - info.read.buffer = buffer; - info.read.bufSize = bufSize; - return gdb_syscall(info); -} - -/** - * @brief Write data from a host file - * @param fd File handle - * @param buffer - * @param count - * @param callback - * @param param - * @retval int - * @see https://sourceware.org/gdb/current/onlinedocs/gdb/write.html - */ -static inline int gdb_syscall_write(int fd, const void* buffer, size_t count, gdb_syscall_callback_t callback = nullptr, - void* param = nullptr) -{ - GdbSyscallInfo info = {eGDBSYS_write, callback, param}; - info.write.fd = fd; - info.write.buffer = buffer; - info.write.count = count; - return gdb_syscall(info); -} - -/** - * @brief Get/set current file pointer position in a host file - * @param fd File handle - * @param offset Relative to whence - * @param whence SEEK_SET, SEEK_CUR or SEEK_END - * @param callback - * @param param - * @retval int - * @see https://sourceware.org/gdb/current/onlinedocs/gdb/lseek.html - */ -static inline int gdb_syscall_lseek(int fd, long offset, int whence, gdb_syscall_callback_t callback = nullptr, - void* param = nullptr) -{ - GdbSyscallInfo info = {eGDBSYS_lseek, callback, param}; - info.lseek.fd = fd; - info.lseek.offset = offset; - info.lseek.whence = whence; - return gdb_syscall(info); -} - -/** - * @brief Rename a host file - * @param oldpath - * @param newpath - * @param callback - * @param param - * @retval int - * @see https://sourceware.org/gdb/current/onlinedocs/gdb/rename.html - */ -static inline int gdb_syscall_rename(const char* oldpath, const char* newpath, - gdb_syscall_callback_t callback = nullptr, void* param = nullptr) -{ - GdbSyscallInfo info = {eGDBSYS_rename, callback, param}; - info.rename.oldpath = oldpath; - info.rename.newpath = newpath; - return gdb_syscall(info); -} - -/** - * @brief Unlink/remove/delete a host file - * @param pathname - * @param callback - * @param param - * @retval int - * @see https://sourceware.org/gdb/current/onlinedocs/gdb/unlink.html - */ -static inline int gdb_syscall_unlink(const char* pathname, gdb_syscall_callback_t callback = nullptr, - void* param = nullptr) -{ - GdbSyscallInfo info = {eGDBSYS_unlink, callback, param}; - info.unlink.pathname = pathname; - return gdb_syscall(info); -} - -/** - * @brief Obtain information about a host file given its name/path - * @param pathname - * @param buf - * @param callback - * @param param - * @retval int - * @see https://sourceware.org/gdb/current/onlinedocs/gdb/stat_002ffstat.html - */ -static inline int gdb_syscall_stat(const char* pathname, gdb_stat_t* buf, gdb_syscall_callback_t callback = nullptr, - void* param = nullptr) -{ - GdbSyscallInfo info = {eGDBSYS_stat, callback, param}; - info.stat.pathname = pathname; - info.stat.buf = buf; - return gdb_syscall(info); -} - -/** - * @brief Obtain information about a host file given its file handle - * @param fd - * @param buf - * @param callback - * @param param - * @retval int - * @see https://sourceware.org/gdb/current/onlinedocs/gdb/stat_002ffstat.html - */ -static inline int gdb_syscall_fstat(int fd, struct gdb_stat_t* buf, gdb_syscall_callback_t callback = nullptr, - void* param = nullptr) -{ - GdbSyscallInfo info = {eGDBSYS_fstat, callback, param}; - info.fstat.fd = fd; - info.fstat.buf = buf; - return gdb_syscall(info); -} - -/** - * @brief Get current time of day from host, in UTC - * @param tv - * @param tz Not used, must be null - * @param callback - * @param param - * @retval int - * @see https://sourceware.org/gdb/current/onlinedocs/gdb/gettimeofday.html - */ -static inline int gdb_syscall_gettimeofday(gdb_timeval_t* tv, void* tz, gdb_syscall_callback_t callback = nullptr, - void* param = nullptr) -{ - GdbSyscallInfo info = {eGDBSYS_gettimeofday, callback, param}; - info.gettimeofday.tv = tv; - info.gettimeofday.tz = tz; - return gdb_syscall(info); -} - -/** - * @brief Determine if the given file handle refers to a console/tty - * @param fd - * @param callback - * @param param - * @retval int - * @see https://sourceware.org/gdb/current/onlinedocs/gdb/isatty.html - */ -static inline int gdb_syscall_isatty(int fd, gdb_syscall_callback_t callback = nullptr, void* param = nullptr) -{ - GdbSyscallInfo info = {eGDBSYS_isatty, callback, param}; - info.isatty.fd = fd; - return gdb_syscall(info); -} - -/** - * @brief Invoke the 'system' command on the host - * @param command - * @param callback - * @param param - * @retval int - * @note For security reasons this command must specifically be enabled using 'set remote system-call-allowed 1' - * @see https://sourceware.org/gdb/current/onlinedocs/gdb/system.html - */ -static inline int gdb_syscall_system(const char* command, gdb_syscall_callback_t callback = nullptr, - void* param = nullptr) -{ - GdbSyscallInfo info = {eGDBSYS_system, callback, param}; - info.system.command = command; - return gdb_syscall(info); -} - -/** - * @brief Read a line of text from the GDB console - * @param buffer - * @param bufSize - * @param callback - * @param param - * @retval int - * @note IMPORTANT: Reading console will not complete until user types return (or Ctrl+D, Ctrl+C). - * It must therefore be an asynchronous call or a watchdog reset will occur. - */ -static inline int gdb_console_read(void* buffer, size_t bufSize, gdb_syscall_callback_t callback = nullptr, - void* param = nullptr) -{ - return gdb_syscall_read(STDIN_FILENO, buffer, bufSize, callback, param); -} - -/** - * @brief Write text to the GDB console - * @param buffer - * @param count - * @param callback - * @param param - * @retval int - */ -static inline int gdb_console_write(const void* buffer, size_t count, gdb_syscall_callback_t callback = nullptr, - void* param = nullptr) -{ - return gdb_syscall_write(STDOUT_FILENO, buffer, count, callback, param); -} - -/** @} */ +/**** + * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. + * Created 2015 by Skurydin Alexey + * http://github.com/SmingHub/Sming + * All files of the Sming Core are provided under the LGPL v3 license. + * + * gdb_syscall.h - Support for GDB file I/O + * + * @author: 2019 - Mikee47 + * + * An API is defined for communicating with GDB using the 'file-I/O protocol', but the name is misleading + * as it can also perform functions not related to file (or console) I/O. The functions are generally + * POSIX compatible so for further details consult the appropriate reference for your operating system. + * + * This is a synchronous protocol, so only one request may be in progress at a time. + * While a request is in progress GDB will not respond to any notifications from the target - including debug output. + * + * All functions are implemented with an optional callback routine, which is essential when reading the + * console as it can take a considerable time to execute. + * + * To use in your application, build with GDBSTUB_ENABLE_SYSCALL=1 and #include this header. + * + * @see https://sourceware.org/gdb/current/onlinedocs/gdb/File_002dI_002fO-Remote-Protocol-Extension.html + * + ****/ + +#pragma once + +#include +#include +#include +#include +#include + +/** @defgroup gdb_syscall GDB system call API + * @ingroup GDB + * @{ +*/ + +#pragma pack(push, 4) + +/** + * @brief GDB uses a specific version of the stat structure, 64 bytes in size + */ +struct gdb_stat_t { + uint32_t st_dev; // device + uint32_t st_ino; // inode + mode_t st_mode; // protection + uint32_t st_nlink; // number of hard links + uint32_t st_uid; // user ID of owner + uint32_t st_gid; // group ID of owner + uint32_t st_rdev; // device type (if inode device) + uint64_t st_size; // total size, in bytes + uint64_t st_blksize; // blocksize for filesystem I/O + uint64_t st_blocks; // number of blocks allocated + time_t st_atime; // time of last access + time_t st_mtime; // time of last modification + time_t st_ctime; // time of last change +}; + +/** + * @brief GDB uses a specific version of the timeval structure, 12 bytes in size (manual says 8, which is wrong) + */ +struct gdb_timeval_t { + time_t tv_sec; // second + uint64_t tv_usec; // microsecond +}; + +#pragma pack(pop) + +/* GDB Syscall interface */ + +/** + * @brief Enumeration defining available commands + */ +enum GdbSyscallCommand { + eGDBSYS_open, + eGDBSYS_close, + eGDBSYS_read, + eGDBSYS_write, + eGDBSYS_lseek, + eGDBSYS_rename, + eGDBSYS_unlink, + eGDBSYS_stat, + eGDBSYS_fstat, + eGDBSYS_gettimeofday, + eGDBSYS_isatty, + eGDBSYS_system, +}; + +struct GdbSyscallInfo; + +/** + * @brief GDB Syscall completion callback function + * @param info Reference to request information, containing result code and user-provided 'param' + */ +typedef void (*gdb_syscall_callback_t)(const GdbSyscallInfo& info); + +/** + * @brief GDB Syscall request information + */ +struct GdbSyscallInfo { + GdbSyscallCommand command; ///< The syscall command + gdb_syscall_callback_t callback; ///< User-supplied callback (if any) + void* param; ///< User-supplied parameter for callback + int result; ///< Final result of syscall + // Command parameters + union { + struct { + const char* filename; + int flags; + int mode; + } open; + struct { + int fd; + } close; + struct { + int fd; + void* buffer; + size_t bufSize; + } read; + struct { + int fd; + const void* buffer; + size_t count; + } write; + struct { + int fd; + long offset; + int whence; + } lseek; + struct { + const char* oldpath; + const char* newpath; + } rename; + struct { + const char* pathname; + } unlink; + struct { + const char* pathname; + gdb_stat_t* buf; + } stat; + struct { + int fd; + struct gdb_stat_t* buf; + } fstat; + struct { + gdb_timeval_t* tv; + void* tz; + } gettimeofday; + struct { + int fd; + } isatty; + struct { + const char* command; + } system; + }; +}; + +/** + * @brief Stub function to perform a syscall. Implemented by GDB stub. + * @param info Call request information + * @retval Error code, < 0 for error or >= 0 for success + * + * @note If info.callback is null then the function waits until the request has been completed, + * and returns the result of the syscall. + * If info.callback is not null, then this function returns 0 to indicate the request is in progress, + * or a negative error value to indicate the request could not be started. + * + * @note A copy of the request information is made and a reference passed to the completion callback + * function if one is used. Note that this is _not_ the original structure, so it does not have to be + * persisent, although any char* or other pointers MUST remain valid until the call is completed. + */ +int gdb_syscall(const GdbSyscallInfo& info); + +/** + * @brief Open a file on the host + * @param filename Name of file to open, relative to current directory (typically the Sming application folder) + * @param flags A combination of O_* flags defined in fcntl.h (e.g. O_RDONLY, O_CREAT, etc) + * @param mode See sys/stat.h + * @param callback + * @param param + * @retval int + * @see https://sourceware.org/gdb/current/onlinedocs/gdb/open.html + */ +static inline int gdb_syscall_open(const char* filename, int flags, int mode, gdb_syscall_callback_t callback = nullptr, + void* param = nullptr) +{ + GdbSyscallInfo info = {eGDBSYS_open, callback, param}; + info.open.filename = filename; + info.open.flags = flags; + info.open.mode = mode; + return gdb_syscall(info); +} + +/** + * @brief Close a host file + * @param fd File handle + * @param flags A combination of O_* flags defined in fcntl.h (e.g. O_RDONLY, O_CREAT, etc) + * @param callback + * @param param + * @retval int + * @see https://sourceware.org/gdb/current/onlinedocs/gdb/close.html + */ +static inline int gdb_syscall_close(int fd, gdb_syscall_callback_t callback = nullptr, void* param = nullptr) +{ + GdbSyscallInfo info = {eGDBSYS_close, callback, param}; + info.close.fd = fd; + return gdb_syscall(info); +} + +/** + * @brief Read data from a host file + * @param fd File handle + * @param buffer + * @param bufSize + * @param callback + * @param param + * @retval int + * @see https://sourceware.org/gdb/current/onlinedocs/gdb/read.html + */ +static inline int gdb_syscall_read(int fd, void* buffer, size_t bufSize, gdb_syscall_callback_t callback = nullptr, + void* param = nullptr) +{ + GdbSyscallInfo info = {eGDBSYS_read, callback, param}; + info.read.fd = fd; + info.read.buffer = buffer; + info.read.bufSize = bufSize; + return gdb_syscall(info); +} + +/** + * @brief Write data from a host file + * @param fd File handle + * @param buffer + * @param count + * @param callback + * @param param + * @retval int + * @see https://sourceware.org/gdb/current/onlinedocs/gdb/write.html + */ +static inline int gdb_syscall_write(int fd, const void* buffer, size_t count, gdb_syscall_callback_t callback = nullptr, + void* param = nullptr) +{ + GdbSyscallInfo info = {eGDBSYS_write, callback, param}; + info.write.fd = fd; + info.write.buffer = buffer; + info.write.count = count; + return gdb_syscall(info); +} + +/** + * @brief Get/set current file pointer position in a host file + * @param fd File handle + * @param offset Relative to whence + * @param whence SEEK_SET, SEEK_CUR or SEEK_END + * @param callback + * @param param + * @retval int + * @see https://sourceware.org/gdb/current/onlinedocs/gdb/lseek.html + */ +static inline int gdb_syscall_lseek(int fd, long offset, int whence, gdb_syscall_callback_t callback = nullptr, + void* param = nullptr) +{ + GdbSyscallInfo info = {eGDBSYS_lseek, callback, param}; + info.lseek.fd = fd; + info.lseek.offset = offset; + info.lseek.whence = whence; + return gdb_syscall(info); +} + +/** + * @brief Rename a host file + * @param oldpath + * @param newpath + * @param callback + * @param param + * @retval int + * @see https://sourceware.org/gdb/current/onlinedocs/gdb/rename.html + */ +static inline int gdb_syscall_rename(const char* oldpath, const char* newpath, + gdb_syscall_callback_t callback = nullptr, void* param = nullptr) +{ + GdbSyscallInfo info = {eGDBSYS_rename, callback, param}; + info.rename.oldpath = oldpath; + info.rename.newpath = newpath; + return gdb_syscall(info); +} + +/** + * @brief Unlink/remove/delete a host file + * @param pathname + * @param callback + * @param param + * @retval int + * @see https://sourceware.org/gdb/current/onlinedocs/gdb/unlink.html + */ +static inline int gdb_syscall_unlink(const char* pathname, gdb_syscall_callback_t callback = nullptr, + void* param = nullptr) +{ + GdbSyscallInfo info = {eGDBSYS_unlink, callback, param}; + info.unlink.pathname = pathname; + return gdb_syscall(info); +} + +/** + * @brief Obtain information about a host file given its name/path + * @param pathname + * @param buf + * @param callback + * @param param + * @retval int + * @see https://sourceware.org/gdb/current/onlinedocs/gdb/stat_002ffstat.html + */ +static inline int gdb_syscall_stat(const char* pathname, gdb_stat_t* buf, gdb_syscall_callback_t callback = nullptr, + void* param = nullptr) +{ + GdbSyscallInfo info = {eGDBSYS_stat, callback, param}; + info.stat.pathname = pathname; + info.stat.buf = buf; + return gdb_syscall(info); +} + +/** + * @brief Obtain information about a host file given its file handle + * @param fd + * @param buf + * @param callback + * @param param + * @retval int + * @see https://sourceware.org/gdb/current/onlinedocs/gdb/stat_002ffstat.html + */ +static inline int gdb_syscall_fstat(int fd, struct gdb_stat_t* buf, gdb_syscall_callback_t callback = nullptr, + void* param = nullptr) +{ + GdbSyscallInfo info = {eGDBSYS_fstat, callback, param}; + info.fstat.fd = fd; + info.fstat.buf = buf; + return gdb_syscall(info); +} + +/** + * @brief Get current time of day from host, in UTC + * @param tv + * @param tz Not used, must be null + * @param callback + * @param param + * @retval int + * @see https://sourceware.org/gdb/current/onlinedocs/gdb/gettimeofday.html + */ +static inline int gdb_syscall_gettimeofday(gdb_timeval_t* tv, void* tz, gdb_syscall_callback_t callback = nullptr, + void* param = nullptr) +{ + GdbSyscallInfo info = {eGDBSYS_gettimeofday, callback, param}; + info.gettimeofday.tv = tv; + info.gettimeofday.tz = tz; + return gdb_syscall(info); +} + +/** + * @brief Determine if the given file handle refers to a console/tty + * @param fd + * @param callback + * @param param + * @retval int + * @see https://sourceware.org/gdb/current/onlinedocs/gdb/isatty.html + */ +static inline int gdb_syscall_isatty(int fd, gdb_syscall_callback_t callback = nullptr, void* param = nullptr) +{ + GdbSyscallInfo info = {eGDBSYS_isatty, callback, param}; + info.isatty.fd = fd; + return gdb_syscall(info); +} + +/** + * @brief Invoke the 'system' command on the host + * @param command + * @param callback + * @param param + * @retval int + * @note For security reasons this command must specifically be enabled using 'set remote system-call-allowed 1' + * @see https://sourceware.org/gdb/current/onlinedocs/gdb/system.html + */ +static inline int gdb_syscall_system(const char* command, gdb_syscall_callback_t callback = nullptr, + void* param = nullptr) +{ + GdbSyscallInfo info = {eGDBSYS_system, callback, param}; + info.system.command = command; + return gdb_syscall(info); +} + +/** + * @brief Read a line of text from the GDB console + * @param buffer + * @param bufSize + * @param callback + * @param param + * @retval int + * @note IMPORTANT: Reading console will not complete until user types return (or Ctrl+D, Ctrl+C). + * It must therefore be an asynchronous call or a watchdog reset will occur. + */ +static inline int gdb_console_read(void* buffer, size_t bufSize, gdb_syscall_callback_t callback = nullptr, + void* param = nullptr) +{ + return gdb_syscall_read(STDIN_FILENO, buffer, bufSize, callback, param); +} + +/** + * @brief Write text to the GDB console + * @param buffer + * @param count + * @param callback + * @param param + * @retval int + */ +static inline int gdb_console_write(const void* buffer, size_t count, gdb_syscall_callback_t callback = nullptr, + void* param = nullptr) +{ + return gdb_syscall_write(STDOUT_FILENO, buffer, count, callback, param); +} + +/** @} */ diff --git a/Sming/Wiring/FlashString.h b/Sming/Wiring/FlashString.h index c75ddb4004..8100c095b4 100644 --- a/Sming/Wiring/FlashString.h +++ b/Sming/Wiring/FlashString.h @@ -1,255 +1,255 @@ -/**** - * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. - * Created 2015 by Skurydin Alexey - * http://github.com/SmingHub/Sming - * All files of the Sming Core are provided under the LGPL v3 license. - * - * @author: 2018 - Mikee47 - * - * Defines the FlashString structure and associated macros for efficient flash memory string access. - * - ****/ - -/* - * Note on storing strings in flash memory - * - * A string literal (e.g. "string") used in code gets emitted to the .rodata segment by the compiler. - * That means it gets read into RAM at startup and remains there. - * To avoid this, and reclaim the RAM, the data must be stored in a different segment. This is done - * using the PROGMEM macro, defined in FakePgmSpace.h. - * - * Once in flash memory, string data must be read into RAM before it can be used. Accessing the flash - * memory directly is awkard. If locations are not strictly accessed as 4-byte words the system will probably - * crash; I say 'probably' because sometimes it just behaves weirdly if the RAM address isn't aligned. - * - * _FakePgmSpace_ provides the basic mechanisms for storing and reading flash strings, including - * general-purpose string library functions. These are well-documented Arduino-compatible routines. - * Some additions have been made to Sming to cater for the ESP8266 use of these strings. - * - * F(string_literal) - loads a String object with the given text, which is allocated to flash. - * String s = F("test"); - * - * _F(string_literal) - Like F() except buffer is allocated on stack. Most useful where nul-terminated data is required. - * m_printf(_F("C-style string\n")); - * - * DEFINE_PSTR(_name, _str) - declares a PSTR stored in flash. The variable (_name) points to flash - * memory so must be accessed using the appropriate xxx_P function. - * - * LOAD_PSTR(_name, _flash_str) - loads pre-defined PSTR into buffer on stack - * static DEFINE_PSTR(testFlash, "This is a test string\n"); // Function scope requires static allocation - * LOAD_PSTR(test, testFlash) - * m_printf(test); - * - * PSTR_ARRAY(_name, _str) - creates and loads string into named stack buffer - * Ensures loaded string stays in scope, unlike _F() - * String testfunc() { - * PSTR_ARRAY(test, "This is the test string"); - * m_printf(test); - * ... - * return test; - * } - * - * IMPORT_FSTR(name, file) - binds a file into the firmware image as a FlashString object - * This needs to be used at file scope, example: - * IMPORT_FSTR(myFlashData, "files/myFlashData.bin") - * - * Both DEFINE_PSTR and PSTR_ARRAY load a PSTR into a stack buffer, but using sizeof() on that buffer will return - * a larger value than the string itself because it's aligned. Calling sizeof() on the original flash data will - * get the right value. If it's a regular nul-terminated string then strlen_P() will get the length, although it's - * time-consuming. - * - * FlashString - * - * A 'counted string' defined as a C++ structure with a length field. - * Requires only a single flash read to get the length; no strlen_P, etc. - * Stores arbitrary data including nuls. - * A global instance can be shared amongst modules with no loss of efficiency. - * The data is word-aligned so reading is as fast as possible; there are no alignment issues to deal with. - * Structure-based, so can add methods to the structure instead of using macros. - * Strongly typed, so support can be added to other modules for implicit conversions, etc. (e.g. ArduinoJson) - * Works with updated String class to provide the simplest string/data management. - * - * Macros are consistent with the PSTR types, but named 'FSTR'. - * - * Notes on usage - * - * Best practice is usually to define constant data at the top of a module. Non-trivial strings are no different. - * The mechanisms offered here provide a way to help do that. - * - */ - -#pragma once - -#include "WString.h" - -/** @Brief Define a FlashString - * @param _name variable to identify the string - * @param _str content of the string - * @note the whole thing is word-aligned - * Example: DEFINE_FSTR(test, "This is a test\0Another test\0hello") - * The data includes the nul terminator but the length does not. - */ -#define DEFINE_FSTR(_name, _str) \ - DEFINE_FSTR_STRUCT(_##_name, _str) \ - const FlashString& _name = _##_name.fstr; - -#define DEFINE_FSTR_STRUCT(_name, _str) \ - constexpr struct { \ - FlashString fstr; \ - char data[ALIGNUP(sizeof(_str))]; \ - } _name PROGMEM = {{sizeof(_str) - 1}, _str}; - -// Declare a global reference to a FlashString instance -#define DECLARE_FSTR(_name) extern const FlashString& _name; - -// Get a pointer to the actual FlashString, used when creating tables -#define FSTR_PTR(_struct) &_##_struct.fstr - -/** @brief declare a table of FlashStrings - * @param _name name of the table - * @note Declares a lookup table stored in flash memory. Example: - * - * DEFINE_FSTR(fstr1, "Test string #1"); - * DEFINE_FSTR(fstr2, "Test string #2"); - * - * FSTR_TABLE(table) = { - * FSTR_PTR(fstr1), - * FSTR_PTR(fstr2), - * }; - * - * Table entries may be accessed directly as they are word-aligned. Examples: - * debugf("fstr1 = '%s'", String(*table[0]).c_str()); - * debugf("fstr2.length() = %u", table[1]->length()); - * - */ -#define FSTR_TABLE(_name) const FlashString* const _name[] PROGMEM - -/* - * Load a FlashString object into a named local (stack) buffer - * - * For example: - * - * DEFINE_FSTR(globalTest, "This is a testing string") - * ... - * LOAD_FSTR(local, globalTest) - * printf("%s, %u characters, buffer is %u bytes\n", local, globalTest.length, sizeof(local)); - */ -#define LOAD_FSTR(_name, _fstr) \ - char _name[(_fstr).size()] __attribute__((aligned(4))); \ - memcpy_aligned(_name, (_fstr).data(), sizeof(_name)); - -/* - * Define a flash string and load it into a named char[] buffer on the stack. - * This allows sizeof(_name) to work as if the string were defined thus: - * - * char _name[] = "text"; - */ -#define FSTR_ARRAY(_name, _str) \ - static DEFINE_FSTR(_##_name, _str); \ - LOAD_FSTR(_name, _##_name) - -/** @brief Define a FlashString containing data from an external file - * @note This provides a more efficient way to read constant (read-only) file data. - * The file content is bound into firmware image at link time. - * @note The FlashString object must be referenced or the linker won't emit it. - */ -#define IMPORT_FSTR(name, file) \ - __asm__(".section .irom.text\n" \ - ".global " #name "\n" \ - ".type " #name ", @object\n" \ - ".align 4\n" #name ":\n" \ - ".word _" #name "_end - " #name " - 4\n" \ - ".incbin \"" file "\"\n" \ - "_" #name "_end:\n"); \ - extern const __attribute__((aligned(4))) FlashString name; - -/** @brief describes a counted string stored in flash memory - * @note because the string length is stored there is no need to call strlen_P before reading the - * content into RAM. Data is stored word-aligned so it can be read as efficiently as possible. - */ -struct FlashString { - // Do NOT access these directly - use member functions - uint32_t flashLength; ///< Only needs to be uint16_t but ensures data is aligned - char flashData[]; - - uint32_t length() const - { - return flashLength; - } - - uint32_t size() const - { - return ALIGNUP(flashLength + 1); - } - - flash_string_t data() const - { - return FPSTR(flashData); - } - - /** @brief Check for equality with a C-string - * @param str - * @retval bool true if strings are identical - * @note loads string into a stack buffer for the comparison, no heap required - */ - bool isEqual(const char* cstr) const - { - // Unlikely we'd want an empty flash string, but check anyway - if(cstr == nullptr) - return flashLength == 0; - // Don't use strcmp as our data may contain nuls - size_t cstrlen = strlen(cstr); - if(cstrlen != flashLength) - return false; - LOAD_FSTR(buf, *this); - return memcmp(buf, cstr, cstrlen) == 0; - } - - /** @brief Check for equality with another FlashString - * @param str - * @retval bool true if strings are identical - */ - bool isEqual(const FlashString& str) const - { - if(flashLength != str.flashLength) - return false; - if(flashData == str.flashData) - return true; - return memcmp_aligned(flashData, str.flashData, ALIGNUP(flashLength)) == 0; - } - - bool isEqual(const String& str) const - { - return str.equals(*this); - } - - bool operator==(const char* str) const - { - return isEqual(str); - } - - bool operator==(const FlashString& str) const - { - return isEqual(str); - } - - bool operator==(const String& str) const - { - return isEqual(str); - } - - bool operator!=(const char* str) const - { - return !isEqual(str); - } - - bool operator!=(const FlashString& str) const - { - return !isEqual(str); - } - - bool operator!=(const String& str) const - { - return !isEqual(str); - } -}; +/**** + * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. + * Created 2015 by Skurydin Alexey + * http://github.com/SmingHub/Sming + * All files of the Sming Core are provided under the LGPL v3 license. + * + * @author: 2018 - Mikee47 + * + * Defines the FlashString structure and associated macros for efficient flash memory string access. + * + ****/ + +/* + * Note on storing strings in flash memory + * + * A string literal (e.g. "string") used in code gets emitted to the .rodata segment by the compiler. + * That means it gets read into RAM at startup and remains there. + * To avoid this, and reclaim the RAM, the data must be stored in a different segment. This is done + * using the PROGMEM macro, defined in FakePgmSpace.h. + * + * Once in flash memory, string data must be read into RAM before it can be used. Accessing the flash + * memory directly is awkard. If locations are not strictly accessed as 4-byte words the system will probably + * crash; I say 'probably' because sometimes it just behaves weirdly if the RAM address isn't aligned. + * + * _FakePgmSpace_ provides the basic mechanisms for storing and reading flash strings, including + * general-purpose string library functions. These are well-documented Arduino-compatible routines. + * Some additions have been made to Sming to cater for the ESP8266 use of these strings. + * + * F(string_literal) - loads a String object with the given text, which is allocated to flash. + * String s = F("test"); + * + * _F(string_literal) - Like F() except buffer is allocated on stack. Most useful where nul-terminated data is required. + * m_printf(_F("C-style string\n")); + * + * DEFINE_PSTR(_name, _str) - declares a PSTR stored in flash. The variable (_name) points to flash + * memory so must be accessed using the appropriate xxx_P function. + * + * LOAD_PSTR(_name, _flash_str) - loads pre-defined PSTR into buffer on stack + * static DEFINE_PSTR(testFlash, "This is a test string\n"); // Function scope requires static allocation + * LOAD_PSTR(test, testFlash) + * m_printf(test); + * + * PSTR_ARRAY(_name, _str) - creates and loads string into named stack buffer + * Ensures loaded string stays in scope, unlike _F() + * String testfunc() { + * PSTR_ARRAY(test, "This is the test string"); + * m_printf(test); + * ... + * return test; + * } + * + * IMPORT_FSTR(name, file) - binds a file into the firmware image as a FlashString object + * This needs to be used at file scope, example: + * IMPORT_FSTR(myFlashData, "files/myFlashData.bin") + * + * Both DEFINE_PSTR and PSTR_ARRAY load a PSTR into a stack buffer, but using sizeof() on that buffer will return + * a larger value than the string itself because it's aligned. Calling sizeof() on the original flash data will + * get the right value. If it's a regular nul-terminated string then strlen_P() will get the length, although it's + * time-consuming. + * + * FlashString + * + * A 'counted string' defined as a C++ structure with a length field. + * Requires only a single flash read to get the length; no strlen_P, etc. + * Stores arbitrary data including nuls. + * A global instance can be shared amongst modules with no loss of efficiency. + * The data is word-aligned so reading is as fast as possible; there are no alignment issues to deal with. + * Structure-based, so can add methods to the structure instead of using macros. + * Strongly typed, so support can be added to other modules for implicit conversions, etc. (e.g. ArduinoJson) + * Works with updated String class to provide the simplest string/data management. + * + * Macros are consistent with the PSTR types, but named 'FSTR'. + * + * Notes on usage + * + * Best practice is usually to define constant data at the top of a module. Non-trivial strings are no different. + * The mechanisms offered here provide a way to help do that. + * + */ + +#pragma once + +#include "WString.h" + +/** @Brief Define a FlashString + * @param _name variable to identify the string + * @param _str content of the string + * @note the whole thing is word-aligned + * Example: DEFINE_FSTR(test, "This is a test\0Another test\0hello") + * The data includes the nul terminator but the length does not. + */ +#define DEFINE_FSTR(_name, _str) \ + DEFINE_FSTR_STRUCT(_##_name, _str) \ + const FlashString& _name = _##_name.fstr; + +#define DEFINE_FSTR_STRUCT(_name, _str) \ + constexpr struct { \ + FlashString fstr; \ + char data[ALIGNUP(sizeof(_str))]; \ + } _name PROGMEM = {{sizeof(_str) - 1}, _str}; + +// Declare a global reference to a FlashString instance +#define DECLARE_FSTR(_name) extern const FlashString& _name; + +// Get a pointer to the actual FlashString, used when creating tables +#define FSTR_PTR(_struct) &_##_struct.fstr + +/** @brief declare a table of FlashStrings + * @param _name name of the table + * @note Declares a lookup table stored in flash memory. Example: + * + * DEFINE_FSTR(fstr1, "Test string #1"); + * DEFINE_FSTR(fstr2, "Test string #2"); + * + * FSTR_TABLE(table) = { + * FSTR_PTR(fstr1), + * FSTR_PTR(fstr2), + * }; + * + * Table entries may be accessed directly as they are word-aligned. Examples: + * debugf("fstr1 = '%s'", String(*table[0]).c_str()); + * debugf("fstr2.length() = %u", table[1]->length()); + * + */ +#define FSTR_TABLE(_name) const FlashString* const _name[] PROGMEM + +/* + * Load a FlashString object into a named local (stack) buffer + * + * For example: + * + * DEFINE_FSTR(globalTest, "This is a testing string") + * ... + * LOAD_FSTR(local, globalTest) + * printf("%s, %u characters, buffer is %u bytes\n", local, globalTest.length, sizeof(local)); + */ +#define LOAD_FSTR(_name, _fstr) \ + char _name[(_fstr).size()] __attribute__((aligned(4))); \ + memcpy_aligned(_name, (_fstr).data(), sizeof(_name)); + +/* + * Define a flash string and load it into a named char[] buffer on the stack. + * This allows sizeof(_name) to work as if the string were defined thus: + * + * char _name[] = "text"; + */ +#define FSTR_ARRAY(_name, _str) \ + static DEFINE_FSTR(_##_name, _str); \ + LOAD_FSTR(_name, _##_name) + +/** @brief Define a FlashString containing data from an external file + * @note This provides a more efficient way to read constant (read-only) file data. + * The file content is bound into firmware image at link time. + * @note The FlashString object must be referenced or the linker won't emit it. + */ +#define IMPORT_FSTR(name, file) \ + __asm__(".section .irom.text\n" \ + ".global " #name "\n" \ + ".type " #name ", @object\n" \ + ".align 4\n" #name ":\n" \ + ".word _" #name "_end - " #name " - 4\n" \ + ".incbin \"" file "\"\n" \ + "_" #name "_end:\n"); \ + extern const __attribute__((aligned(4))) FlashString name; + +/** @brief describes a counted string stored in flash memory + * @note because the string length is stored there is no need to call strlen_P before reading the + * content into RAM. Data is stored word-aligned so it can be read as efficiently as possible. + */ +struct FlashString { + // Do NOT access these directly - use member functions + uint32_t flashLength; ///< Only needs to be uint16_t but ensures data is aligned + char flashData[]; + + uint32_t length() const + { + return flashLength; + } + + uint32_t size() const + { + return ALIGNUP(flashLength + 1); + } + + flash_string_t data() const + { + return FPSTR(flashData); + } + + /** @brief Check for equality with a C-string + * @param str + * @retval bool true if strings are identical + * @note loads string into a stack buffer for the comparison, no heap required + */ + bool isEqual(const char* cstr) const + { + // Unlikely we'd want an empty flash string, but check anyway + if(cstr == nullptr) + return flashLength == 0; + // Don't use strcmp as our data may contain nuls + size_t cstrlen = strlen(cstr); + if(cstrlen != flashLength) + return false; + LOAD_FSTR(buf, *this); + return memcmp(buf, cstr, cstrlen) == 0; + } + + /** @brief Check for equality with another FlashString + * @param str + * @retval bool true if strings are identical + */ + bool isEqual(const FlashString& str) const + { + if(flashLength != str.flashLength) + return false; + if(flashData == str.flashData) + return true; + return memcmp_aligned(flashData, str.flashData, ALIGNUP(flashLength)) == 0; + } + + bool isEqual(const String& str) const + { + return str.equals(*this); + } + + bool operator==(const char* str) const + { + return isEqual(str); + } + + bool operator==(const FlashString& str) const + { + return isEqual(str); + } + + bool operator==(const String& str) const + { + return isEqual(str); + } + + bool operator!=(const char* str) const + { + return !isEqual(str); + } + + bool operator!=(const FlashString& str) const + { + return !isEqual(str); + } + + bool operator!=(const String& str) const + { + return !isEqual(str); + } +}; diff --git a/Sming/build.mk b/Sming/build.mk index 120f004797..7bcb40f220 100644 --- a/Sming/build.mk +++ b/Sming/build.mk @@ -1,243 +1,243 @@ -# Build environment definitions - -# Add configuration variable names to CONFIG_VARS as they are encountered (see ListConfig macro) -CONFIG_VARS := - -# -CONFIG_VARS += SMING_ARCH -SMING_ARCH ?= Esp8266 - -MAKECMDGOALS ?= all -$(info Invoking '$(MAKECMDGOALS)' for '$(SMING_ARCH)' architecture) - -LIBS ?= -CUSTOM_TARGETS ?= -CLEAN ?= -TOOLS ?= -TOOLS_CLEAN ?= - -# Detect OS and build environment -UNAME := $(shell uname -s) - -CONFIG_VARS += UNAME -ifneq ($(filter MINGW32_NT%,$(UNAME)),) - UNAME := Windows -else ifneq ($(filter CYGWIN%,$(UNAME)),) - # Cygwin Detected - UNAME := Linux -else ifneq ($(filter CYGWIN%WOW,$(UNAME)),) - #Cygwin32 - UNAME := Linux -else ifneq ($(filter MSYS%WOW,$(UNAME)),) - #Msys32 - UNAME := Linux -else ifeq ($(UNAME), Linux) - #Linux -else ifeq ($(UNAME), Darwin) - #OS X -else ifeq ($(UNAME), Freebsd) - #BSD -endif - - -# Convert Windows paths to POSIX paths -CONFIG_VARS += OS -ifeq ($(OS),Windows_NT) -FixPath = $(subst //,/,$(subst \,/,$(addprefix /,$(subst :,,$1)))) -else -FixPath = $1 -endif - -CONFIG_VARS += SMING_HOME -SMING_HOME := $(call FixPath,$(realpath $(SMING_HOME))) - -# OS specific configuration -ifeq ($(UNAME),Windows) - # Windows detected - include $(SMING_HOME)/Makefile-windows.mk - TOOL_EXT := .exe -else - ifeq ($(UNAME),Darwin) - # MacOS Detected - UNAME := MacOS - include $(SMING_HOME)/Makefile-macos.mk - else ifeq ($(UNAME),Linux) - # Linux Detected - include $(SMING_HOME)/Makefile-linux.mk - else ifeq ($(UNAME),FreeBSD) - # Freebsd Detected - include $(SMING_HOME)/Makefile-bsd.mk - endif -endif - -export SMING_HOME -export COMPILE := gcc - -ARCH_BASE := Arch/$(SMING_ARCH) -ARCH_SYS = $(ARCH_BASE)/System -ARCH_CORE = $(ARCH_BASE)/Core -ARCH_TOOLS = $(ARCH_BASE)/Tools -ARCH_COMPONENTS = $(ARCH_BASE)/Components -USER_LIBDIR = $(ARCH_BASE)/Compiler/lib -COMPONENTS := Components - -# Git command -GIT ?= git - -### Debug output parameters -# By default `debugf` does not print file name and line number. If you want this enabled set the directive below to 1 -CONFIG_VARS += DEBUG_PRINT_FILENAME_AND_LINE -DEBUG_PRINT_FILENAME_AND_LINE ?= 0 - -# Default debug verbose level is INFO, where DEBUG=3 INFO=2 WARNING=1 ERROR=0 -CONFIG_VARS += DEBUG_VERBOSE_LEVEL -DEBUG_VERBOSE_LEVEL ?= 2 - -# Disable CommandExecutor functionality if not used and save some ROM and RAM -CONFIG_VARS += ENABLE_CMD_EXECUTOR -ENABLE_CMD_EXECUTOR ?= 1 - -V ?= $(VERBOSE) -ifeq ("$(V)","1") -Q := -vecho := @true -else -Q := @ -vecho := @echo -endif - -# Common flags passed to user libraries -CFLAGS_COMMON = -Wl,-EL -finline-functions -fdata-sections -ffunction-sections -# compiler flags using during compilation of source files. Add '-pg' for debugging -CFLAGS = -Wall -Wundef -Wpointer-arith -Wno-comment $(CFLAGS_COMMON) \ - -DARDUINO=106 -DENABLE_CMD_EXECUTOR=$(ENABLE_CMD_EXECUTOR) -DSMING_INCLUDED=1 -CONFIG_VARS += STRICT -ifneq ($(STRICT),1) - CFLAGS += -Werror -Wno-sign-compare -Wno-parentheses -Wno-unused-variable -Wno-unused-but-set-variable -Wno-strict-aliasing -Wno-return-type -Wno-maybe-uninitialized -endif - -CONFIG_VARS += ENABLE_GDB -ifeq ($(ENABLE_GDB), 1) - CFLAGS += -ggdb -DENABLE_GDB=1 -endif - -CONFIG_VARS += SMING_RELEASE -ifeq ($(SMING_RELEASE),1) - # See: https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html - # for full list of optimization options - CFLAGS += -Os -DSMING_RELEASE=1 -DLWIP_NOASSERT -else ifeq ($(ENABLE_GDB), 1) - CFLAGS += -Og -else - CFLAGS += -Os -g -endif - -#Append debug options -CONFIG_VARS += SMING_RELEASE -CFLAGS += -DCUST_FILE_BASE=$$* -DDEBUG_VERBOSE_LEVEL=$(DEBUG_VERBOSE_LEVEL) -DDEBUG_PRINT_FILENAME_AND_LINE=$(DEBUG_PRINT_FILENAME_AND_LINE) - -CXXFLAGS = $(CFLAGS) -fno-rtti -fno-exceptions -std=c++11 -felide-constructors -ifneq ($(STRICT),1) - CXXFLAGS += -Wno-reorder -endif - -# => LOCALE -ifdef LOCALE - CFLAGS += -DLOCALE=$(LOCALE) -endif - -include $(SMING_HOME)/$(ARCH_BASE)/build.mk - -AS := $(Q)$(AS) -CC := $(Q)$(CC) -CXX := $(Q)$(CXX) -AR := $(Q)$(AR) -LD := $(Q)$(LD) - -# Declare target for user library -# $1 -> Name of library -define UserLibPath - $(USER_LIBDIR)/lib$1.a -endef - -# Fetch full path for submodules matching given pattern -# $1 -> Path pattern to match -define ListSubmodules - $(shell git submodule status $1 | cut -c2- | cut -f2 -d ' ') -endef - -# Display variable and list values, e.g. $(call PrintVariable,LIBS) -# $1 -> Name of variable containing values -define PrintVariable - $(info $1) - $(foreach item,$(sort $($1)),$(info - $(item))) -endef - -# Display list of variable references with their values e.g. $(call PrintVariableRefs,CONFIG_VARS) -# $1 -> Name of variable containing list of variable names -define PrintVariableRefs - $(info $1) - $(foreach item,$(sort $($1)),$(info - $(item) = $($(item))) ) -endef - -# Display some internal configuration information -define ListConfig - $(info ) - $(info ** Sming internal build configuration **) - $(info ) - $(call PrintVariable,MAKEFILE_LIST) - $(call PrintVariable,CUSTOM_TARGETS) - $(call PrintVariable,LIBSMING) - $(call PrintVariable,LIBS) - $(call PrintVariable,ARDUINO_LIBRARIES) - $(call PrintVariable,SUBMODULES) - $(call PrintVariableRefs,CONFIG_VARS) - $(info ) - $(info ) -endef - -# Extract commented target information from makefiles and display -# Based on code from https://suva.sh/posts/well-documented-makefiles/ -define PrintHelp - $(info ) - $(info Welcome to the Sming build system!) - @awk 'BEGIN { \ - FS = "(:.*##)|(##@)"; \ - printf "Usage:\n make \033[1;36m\033[0m\n"; \ - } /^##@/ { \ - group = $$2; \ - groups[group] = group; \ - } /^[a-zA-Z_-]+:.*?##/ { \ - targets[$$1, group] = $$2; \ - } \ - END { \ - for (g in groups) { \ - printf "\n\033[1m%s\033[0m\n", g; \ - for (t in targets) { \ - split(t, sep, SUBSEP); \ - if (sep[2] == g) \ - printf " \033[1;36m%-18s\033[0m %s\n", sep[1], targets[t] \ - } \ - } \ - } ' $(MAKEFILE_LIST) - $(info ) -endef - - -# => Main Sming library -CONFIG_VARS += ENABLE_SSL -ifeq ($(ENABLE_SSL),1) - LIBSMING = smingssl - SMING_FEATURES = SSL -else - LIBSMING = sming - SMING_FEATURES = none -endif -LIBSMING_DST = $(call UserLibPath,$(LIBSMING)) - -# => MQTT -# Flags for compatability with old versions (most of them should disappear with the next major release) -CONFIG_VARS += MQTT_NO_COMPAT -ifeq ($(MQTT_NO_COMPAT),1) - CFLAGS += -DMQTT_NO_COMPAT=1 -endif +# Build environment definitions + +# Add configuration variable names to CONFIG_VARS as they are encountered (see ListConfig macro) +CONFIG_VARS := + +# +CONFIG_VARS += SMING_ARCH +SMING_ARCH ?= Esp8266 + +MAKECMDGOALS ?= all +$(info Invoking '$(MAKECMDGOALS)' for '$(SMING_ARCH)' architecture) + +LIBS ?= +CUSTOM_TARGETS ?= +CLEAN ?= +TOOLS ?= +TOOLS_CLEAN ?= + +# Detect OS and build environment +UNAME := $(shell uname -s) + +CONFIG_VARS += UNAME +ifneq ($(filter MINGW32_NT%,$(UNAME)),) + UNAME := Windows +else ifneq ($(filter CYGWIN%,$(UNAME)),) + # Cygwin Detected + UNAME := Linux +else ifneq ($(filter CYGWIN%WOW,$(UNAME)),) + #Cygwin32 + UNAME := Linux +else ifneq ($(filter MSYS%WOW,$(UNAME)),) + #Msys32 + UNAME := Linux +else ifeq ($(UNAME), Linux) + #Linux +else ifeq ($(UNAME), Darwin) + #OS X +else ifeq ($(UNAME), Freebsd) + #BSD +endif + + +# Convert Windows paths to POSIX paths +CONFIG_VARS += OS +ifeq ($(OS),Windows_NT) +FixPath = $(subst //,/,$(subst \,/,$(addprefix /,$(subst :,,$1)))) +else +FixPath = $1 +endif + +CONFIG_VARS += SMING_HOME +SMING_HOME := $(call FixPath,$(realpath $(SMING_HOME))) + +# OS specific configuration +ifeq ($(UNAME),Windows) + # Windows detected + include $(SMING_HOME)/Makefile-windows.mk + TOOL_EXT := .exe +else + ifeq ($(UNAME),Darwin) + # MacOS Detected + UNAME := MacOS + include $(SMING_HOME)/Makefile-macos.mk + else ifeq ($(UNAME),Linux) + # Linux Detected + include $(SMING_HOME)/Makefile-linux.mk + else ifeq ($(UNAME),FreeBSD) + # Freebsd Detected + include $(SMING_HOME)/Makefile-bsd.mk + endif +endif + +export SMING_HOME +export COMPILE := gcc + +ARCH_BASE := Arch/$(SMING_ARCH) +ARCH_SYS = $(ARCH_BASE)/System +ARCH_CORE = $(ARCH_BASE)/Core +ARCH_TOOLS = $(ARCH_BASE)/Tools +ARCH_COMPONENTS = $(ARCH_BASE)/Components +USER_LIBDIR = $(ARCH_BASE)/Compiler/lib +COMPONENTS := Components + +# Git command +GIT ?= git + +### Debug output parameters +# By default `debugf` does not print file name and line number. If you want this enabled set the directive below to 1 +CONFIG_VARS += DEBUG_PRINT_FILENAME_AND_LINE +DEBUG_PRINT_FILENAME_AND_LINE ?= 0 + +# Default debug verbose level is INFO, where DEBUG=3 INFO=2 WARNING=1 ERROR=0 +CONFIG_VARS += DEBUG_VERBOSE_LEVEL +DEBUG_VERBOSE_LEVEL ?= 2 + +# Disable CommandExecutor functionality if not used and save some ROM and RAM +CONFIG_VARS += ENABLE_CMD_EXECUTOR +ENABLE_CMD_EXECUTOR ?= 1 + +V ?= $(VERBOSE) +ifeq ("$(V)","1") +Q := +vecho := @true +else +Q := @ +vecho := @echo +endif + +# Common flags passed to user libraries +CFLAGS_COMMON = -Wl,-EL -finline-functions -fdata-sections -ffunction-sections +# compiler flags using during compilation of source files. Add '-pg' for debugging +CFLAGS = -Wall -Wundef -Wpointer-arith -Wno-comment $(CFLAGS_COMMON) \ + -DARDUINO=106 -DENABLE_CMD_EXECUTOR=$(ENABLE_CMD_EXECUTOR) -DSMING_INCLUDED=1 +CONFIG_VARS += STRICT +ifneq ($(STRICT),1) + CFLAGS += -Werror -Wno-sign-compare -Wno-parentheses -Wno-unused-variable -Wno-unused-but-set-variable -Wno-strict-aliasing -Wno-return-type -Wno-maybe-uninitialized +endif + +CONFIG_VARS += ENABLE_GDB +ifeq ($(ENABLE_GDB), 1) + CFLAGS += -ggdb -DENABLE_GDB=1 +endif + +CONFIG_VARS += SMING_RELEASE +ifeq ($(SMING_RELEASE),1) + # See: https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html + # for full list of optimization options + CFLAGS += -Os -DSMING_RELEASE=1 -DLWIP_NOASSERT +else ifeq ($(ENABLE_GDB), 1) + CFLAGS += -Og +else + CFLAGS += -Os -g +endif + +#Append debug options +CONFIG_VARS += SMING_RELEASE +CFLAGS += -DCUST_FILE_BASE=$$* -DDEBUG_VERBOSE_LEVEL=$(DEBUG_VERBOSE_LEVEL) -DDEBUG_PRINT_FILENAME_AND_LINE=$(DEBUG_PRINT_FILENAME_AND_LINE) + +CXXFLAGS = $(CFLAGS) -fno-rtti -fno-exceptions -std=c++11 -felide-constructors +ifneq ($(STRICT),1) + CXXFLAGS += -Wno-reorder +endif + +# => LOCALE +ifdef LOCALE + CFLAGS += -DLOCALE=$(LOCALE) +endif + +include $(SMING_HOME)/$(ARCH_BASE)/build.mk + +AS := $(Q)$(AS) +CC := $(Q)$(CC) +CXX := $(Q)$(CXX) +AR := $(Q)$(AR) +LD := $(Q)$(LD) + +# Declare target for user library +# $1 -> Name of library +define UserLibPath + $(USER_LIBDIR)/lib$1.a +endef + +# Fetch full path for submodules matching given pattern +# $1 -> Path pattern to match +define ListSubmodules + $(shell git submodule status $1 | cut -c2- | cut -f2 -d ' ') +endef + +# Display variable and list values, e.g. $(call PrintVariable,LIBS) +# $1 -> Name of variable containing values +define PrintVariable + $(info $1) + $(foreach item,$(sort $($1)),$(info - $(item))) +endef + +# Display list of variable references with their values e.g. $(call PrintVariableRefs,CONFIG_VARS) +# $1 -> Name of variable containing list of variable names +define PrintVariableRefs + $(info $1) + $(foreach item,$(sort $($1)),$(info - $(item) = $($(item))) ) +endef + +# Display some internal configuration information +define ListConfig + $(info ) + $(info ** Sming internal build configuration **) + $(info ) + $(call PrintVariable,MAKEFILE_LIST) + $(call PrintVariable,CUSTOM_TARGETS) + $(call PrintVariable,LIBSMING) + $(call PrintVariable,LIBS) + $(call PrintVariable,ARDUINO_LIBRARIES) + $(call PrintVariable,SUBMODULES) + $(call PrintVariableRefs,CONFIG_VARS) + $(info ) + $(info ) +endef + +# Extract commented target information from makefiles and display +# Based on code from https://suva.sh/posts/well-documented-makefiles/ +define PrintHelp + $(info ) + $(info Welcome to the Sming build system!) + @awk 'BEGIN { \ + FS = "(:.*##)|(##@)"; \ + printf "Usage:\n make \033[1;36m\033[0m\n"; \ + } /^##@/ { \ + group = $$2; \ + groups[group] = group; \ + } /^[a-zA-Z_-]+:.*?##/ { \ + targets[$$1, group] = $$2; \ + } \ + END { \ + for (g in groups) { \ + printf "\n\033[1m%s\033[0m\n", g; \ + for (t in targets) { \ + split(t, sep, SUBSEP); \ + if (sep[2] == g) \ + printf " \033[1;36m%-18s\033[0m %s\n", sep[1], targets[t] \ + } \ + } \ + } ' $(MAKEFILE_LIST) + $(info ) +endef + + +# => Main Sming library +CONFIG_VARS += ENABLE_SSL +ifeq ($(ENABLE_SSL),1) + LIBSMING = smingssl + SMING_FEATURES = SSL +else + LIBSMING = sming + SMING_FEATURES = none +endif +LIBSMING_DST = $(call UserLibPath,$(LIBSMING)) + +# => MQTT +# Flags for compatability with old versions (most of them should disappear with the next major release) +CONFIG_VARS += MQTT_NO_COMPAT +ifeq ($(MQTT_NO_COMPAT),1) + CFLAGS += -DMQTT_NO_COMPAT=1 +endif diff --git a/Sming/building.md b/Sming/building.md index 25f8c88b9e..417c15f077 100644 --- a/Sming/building.md +++ b/Sming/building.md @@ -1,138 +1,138 @@ -# Sming makefiles - -## Introduction - -This guide is provided to assist with developing and modifying the build system. - -There are two main makefiles: - -> **Makefile** to build the Sming framework libraries - -> **Makefile-app.mk** to build an application - -There are also specific makefiles for each supported host environment: - -> **Makefile-bsd.mk** - -> **Makefile-linux.mk** - -> **Makefile-macos.mk** - -> **Makefile-windows.mk** - -The following are internal makefiles containing shared script for both framework and application: - -> **build.mk** Defines the build environment - -> **modules.mk** Parses defined MODULES, etc. and creates target rules - -In addition, `Sming/Arch/$(ARCH)` must contain: - -> **sming.mk** to define architecture-specific modules and libraries - -> **app.mk** to build an application - -`SMING_ARCH` may be defined as - -> **Esp8266** - -> **Esp32** {todo} - -> **Host** {todo} builds a version of the library for native host debugging (e.g. Linux/Windows) - - -## Directories - -``` -Directory Contents ---------- -------- - -Arch/ Architecture-specific makefiles and code - Esp8266/ - Compiler/ - Components/ - Core/ - out/ - Platform/ - System/ - Tools/ - Esp32/ - ... - Host/ - ... - -Components/ Framework support code, not to be used directly by applications - -Core/ Main framework core - -Libraries/ Arduino Libraries - -Platform/ System-level classes - -Services/ Modules not considered as part of Core - -System/ Common framework low-level system code - esp8266/ - include/ - -Wiring/ - -``` - - -## Environment Setup - -You must provide `SMING_HOME` and any architecture-specific ones. For the Esp8266 you must define `ESP_HOME` for SDK & tools. - -# Building the framework - -## Makefile - -Flags: - -> ** ARDUINO_LIBRARIES** Specify which Arduino Libraries are to be built. Default: unspecified, builds them all. Example: `make ARDUINO_LIBRARIES="ArduinoJson SI7021 BMP180"` -This can be set in the platform `sming.mk` file. - -## GIT Submodules - -These are used in various places throughout the framework. A single `%/.submodule` rule takes care of updating and optionally patching the code. -A patch file with the same name as the submodule must be present in `..` or `../.patches`. -After updating and patching, an `.submodule` file is created to confirm this has been done. - -# Building applications - -## Makefile-app.mk - -This does not contain any targets, but sets up the common build environment, configures Sming variables then invokes the platform-specific makefile in `Platform$/$(PLATFORM)/app.mk`. - -## Application Code (APPCODE) - -Some code is recompiled for every application (e.g. `gdbstub`, `rboot`). -Code must be placed in a separate sub-directory of the corresponding module or component, then added to the `APPCODE` variable within the makefiles. -This mechanism is appropriate for files with multiple configurable options and avoids the need to rebuild the framework. - -# Known Issues - -## Parallel build - -i.e. Using `make -j` doesn't work for rules which pull in submodules from GIT, so this must be done as a first step: - -`make submodules` - -then you can - -`make -j` - -to compile the framework or application. Ensure that any options (`ENABLE_SSL`, `ARDUINO_LIBRARIES`) are set identically for both. - - -## Cleaning - -Optional libraries are not cleaned unless defined. e.g. `make axtls-clean` will fail unless you also specify `ENABLE_SSL=1`. - - -## Custom heap - -Changing the heap allocator requires a rebuild of the framework. -TODO: Implement as separate user library. - +# Sming makefiles + +## Introduction + +This guide is provided to assist with developing and modifying the build system. + +There are two main makefiles: + +> **Makefile** to build the Sming framework libraries + +> **Makefile-app.mk** to build an application + +There are also specific makefiles for each supported host environment: + +> **Makefile-bsd.mk** + +> **Makefile-linux.mk** + +> **Makefile-macos.mk** + +> **Makefile-windows.mk** + +The following are internal makefiles containing shared script for both framework and application: + +> **build.mk** Defines the build environment + +> **modules.mk** Parses defined MODULES, etc. and creates target rules + +In addition, `Sming/Arch/$(ARCH)` must contain: + +> **sming.mk** to define architecture-specific modules and libraries + +> **app.mk** to build an application + +`SMING_ARCH` may be defined as + +> **Esp8266** + +> **Esp32** {todo} + +> **Host** {todo} builds a version of the library for native host debugging (e.g. Linux/Windows) + + +## Directories + +``` +Directory Contents +--------- -------- + +Arch/ Architecture-specific makefiles and code + Esp8266/ + Compiler/ + Components/ + Core/ + out/ + Platform/ + System/ + Tools/ + Esp32/ + ... + Host/ + ... + +Components/ Framework support code, not to be used directly by applications + +Core/ Main framework core + +Libraries/ Arduino Libraries + +Platform/ System-level classes + +Services/ Modules not considered as part of Core + +System/ Common framework low-level system code + esp8266/ + include/ + +Wiring/ + +``` + + +## Environment Setup + +You must provide `SMING_HOME` and any architecture-specific ones. For the Esp8266 you must define `ESP_HOME` for SDK & tools. + +# Building the framework + +## Makefile + +Flags: + +> ** ARDUINO_LIBRARIES** Specify which Arduino Libraries are to be built. Default: unspecified, builds them all. Example: `make ARDUINO_LIBRARIES="ArduinoJson SI7021 BMP180"` +This can be set in the platform `sming.mk` file. + +## GIT Submodules + +These are used in various places throughout the framework. A single `%/.submodule` rule takes care of updating and optionally patching the code. +A patch file with the same name as the submodule must be present in `..` or `../.patches`. +After updating and patching, an `.submodule` file is created to confirm this has been done. + +# Building applications + +## Makefile-app.mk + +This does not contain any targets, but sets up the common build environment, configures Sming variables then invokes the platform-specific makefile in `Platform$/$(PLATFORM)/app.mk`. + +## Application Code (APPCODE) + +Some code is recompiled for every application (e.g. `gdbstub`, `rboot`). +Code must be placed in a separate sub-directory of the corresponding module or component, then added to the `APPCODE` variable within the makefiles. +This mechanism is appropriate for files with multiple configurable options and avoids the need to rebuild the framework. + +# Known Issues + +## Parallel build + +i.e. Using `make -j` doesn't work for rules which pull in submodules from GIT, so this must be done as a first step: + +`make submodules` + +then you can + +`make -j` + +to compile the framework or application. Ensure that any options (`ENABLE_SSL`, `ARDUINO_LIBRARIES`) are set identically for both. + + +## Cleaning + +Optional libraries are not cleaned unless defined. e.g. `make axtls-clean` will fail unless you also specify `ENABLE_SSL=1`. + + +## Custom heap + +Changing the heap allocator requires a rebuild of the framework. +TODO: Implement as separate user library. + diff --git a/Sming/modules.mk b/Sming/modules.mk index b3e02e42a5..8f7653c426 100644 --- a/Sming/modules.mk +++ b/Sming/modules.mk @@ -1,72 +1,72 @@ -##### -# -# Module support -# -# Both Sming and Application makefiles include this once all modules, libs, etc. have been defined -# -##### - -# List of directories containing object files -BUILD_DIR := - -# List of object files -OBJ := - -APP_AR := $(addprefix $(BUILD_BASE)/,$(TARGET)_app.a) -TARGET_OUT := $(addprefix $(BUILD_BASE)/,$(TARGET).out) - -INCDIR := -I$(SDK_INCDIR) $(addprefix -I,$(APPCODE) $(MODULES)) -EXTRA_INCDIR := $(addprefix -I,$(EXTRA_INCDIR)) - -# $1 -> directory containing source files -# $2 -> output build directory -define GenerateCompileTargets -$2/%.o: $1/%.s - $(vecho) "AS $$<" - $(AS) $(INCDIR) -I$1/include $(EXTRA_INCDIR) $(CFLAGS) -c $$< -o $$@ -$2/%.o: $1/%.S - $(vecho) "AS $$<" - $(AS) $(INCDIR) -I$1/include $(EXTRA_INCDIR) $(CFLAGS) -c $$< -o $$@ -$2/%.o: $1/%.c $2/%.c.d - $(vecho) "CC $$<" - $(CC) $(INCDIR) -I$1/include $(EXTRA_INCDIR) $(CFLAGS) -c $$< -o $$@ -$2/%.o: $1/%.cpp $2/%.cpp.d - $(vecho) "C+ $$<" - $(CXX) $(INCDIR) -I$1/include $(EXTRA_INCDIR) $(CXXFLAGS) -c $$< -o $$@ -$2/%.c.d: $1/%.c - $(CC) $(INCDIR) -I$1/include $(EXTRA_INCDIR) $(CFLAGS) -MM -MT $2/$$*.o $$< -o $$@ -$2/%.cpp.d: $1/%.cpp - $(CXX) $(INCDIR) -I$1/include $(EXTRA_INCDIR) $(CXXFLAGS) -MM -MT $2/$$*.o $$< -o $$@ - -.PRECIOUS: $2/%.c.d $2/%.cpp.d -endef - - -# Append target object file paths to OBJ -# $1 -> directory containing source files -# $2 -> output build directory -# $3 -> file extension -define ScanObjectFiles - OBJ += $(addprefix $2/,$(patsubst $(SMING_HOME)/%,%,$(patsubst %$3,%.o,$(wildcard $1/*$3)))) -endef - -# Generate all the compile target patterns and update object list for all source files in a module directory -# $1 -> directory containing source files -# $2 -> output build directory -define ScanModule - $(if $(V), $(info Scan $1)) - BUILD_DIR += $2/$(patsubst $(SMING_HOME)/%,%,$1) - $(eval $(call ScanObjectFiles,$1,$2,.s)) - $(eval $(call ScanObjectFiles,$1,$2,.S)) - $(eval $(call ScanObjectFiles,$1,$2,.c)) - $(eval $(call ScanObjectFiles,$1,$2,.cpp)) - $(eval $(call GenerateCompileTargets,$1,$(BUILD_BASE)/$(patsubst $(SMING_HOME)/%,%,$1))) -endef - -# $1 -> directory containing source files -define ScanModules - $(foreach sdir,$1,$(eval $(call ScanModule,$(sdir),$(BUILD_BASE)))) -endef - -# Generate all the compile target patterns and object references -$(call ScanModules,$(MODULES)) +##### +# +# Module support +# +# Both Sming and Application makefiles include this once all modules, libs, etc. have been defined +# +##### + +# List of directories containing object files +BUILD_DIR := + +# List of object files +OBJ := + +APP_AR := $(addprefix $(BUILD_BASE)/,$(TARGET)_app.a) +TARGET_OUT := $(addprefix $(BUILD_BASE)/,$(TARGET).out) + +INCDIR := -I$(SDK_INCDIR) $(addprefix -I,$(APPCODE) $(MODULES)) +EXTRA_INCDIR := $(addprefix -I,$(EXTRA_INCDIR)) + +# $1 -> directory containing source files +# $2 -> output build directory +define GenerateCompileTargets +$2/%.o: $1/%.s + $(vecho) "AS $$<" + $(AS) $(INCDIR) -I$1/include $(EXTRA_INCDIR) $(CFLAGS) -c $$< -o $$@ +$2/%.o: $1/%.S + $(vecho) "AS $$<" + $(AS) $(INCDIR) -I$1/include $(EXTRA_INCDIR) $(CFLAGS) -c $$< -o $$@ +$2/%.o: $1/%.c $2/%.c.d + $(vecho) "CC $$<" + $(CC) $(INCDIR) -I$1/include $(EXTRA_INCDIR) $(CFLAGS) -c $$< -o $$@ +$2/%.o: $1/%.cpp $2/%.cpp.d + $(vecho) "C+ $$<" + $(CXX) $(INCDIR) -I$1/include $(EXTRA_INCDIR) $(CXXFLAGS) -c $$< -o $$@ +$2/%.c.d: $1/%.c + $(CC) $(INCDIR) -I$1/include $(EXTRA_INCDIR) $(CFLAGS) -MM -MT $2/$$*.o $$< -o $$@ +$2/%.cpp.d: $1/%.cpp + $(CXX) $(INCDIR) -I$1/include $(EXTRA_INCDIR) $(CXXFLAGS) -MM -MT $2/$$*.o $$< -o $$@ + +.PRECIOUS: $2/%.c.d $2/%.cpp.d +endef + + +# Append target object file paths to OBJ +# $1 -> directory containing source files +# $2 -> output build directory +# $3 -> file extension +define ScanObjectFiles + OBJ += $(addprefix $2/,$(patsubst $(SMING_HOME)/%,%,$(patsubst %$3,%.o,$(wildcard $1/*$3)))) +endef + +# Generate all the compile target patterns and update object list for all source files in a module directory +# $1 -> directory containing source files +# $2 -> output build directory +define ScanModule + $(if $(V), $(info Scan $1)) + BUILD_DIR += $2/$(patsubst $(SMING_HOME)/%,%,$1) + $(eval $(call ScanObjectFiles,$1,$2,.s)) + $(eval $(call ScanObjectFiles,$1,$2,.S)) + $(eval $(call ScanObjectFiles,$1,$2,.c)) + $(eval $(call ScanObjectFiles,$1,$2,.cpp)) + $(eval $(call GenerateCompileTargets,$1,$(BUILD_BASE)/$(patsubst $(SMING_HOME)/%,%,$1))) +endef + +# $1 -> directory containing source files +define ScanModules + $(foreach sdir,$1,$(eval $(call ScanModule,$(sdir),$(BUILD_BASE)))) +endef + +# Generate all the compile target patterns and object references +$(call ScanModules,$(MODULES)) From c929c93148ffd2ee136f9ea5ffe432ddba8168fd Mon Sep 17 00:00:00 2001 From: mikee47 Date: Tue, 30 Apr 2019 15:49:53 +0100 Subject: [PATCH 22/22] Merge SmingCore warning #pragmas --- Sming/SmingCore/SmingCore.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Sming/SmingCore/SmingCore.h b/Sming/SmingCore/SmingCore.h index db67dcea05..4fd28d8f81 100644 --- a/Sming/SmingCore/SmingCore.h +++ b/Sming/SmingCore/SmingCore.h @@ -1,3 +1,2 @@ #include -#pragma warning "Please update to #include " -#pragma warning "See https://github.com/SmingHub/Sming/wiki/migrate-v3.8-v4.0" +#pragma warning "Please update to #include - see https://github.com/SmingHub/Sming/wiki/migrate-v3.8-v4.0"