mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-14 10:20:01 +00:00
Rename MG_OTA_FIRMWARE_VERSION -> MG_FIRMWARE_VERSION, rw612 nits
This commit is contained in:
1 parent
8a116d9289
commit
1b0906510b
11 files changed
+29
-30
No files matched your search
@@ -486,7 +486,7 @@ embedded devices and needs only a few lines added to `mongoose_config.h`:
|
||||
|
||||
```c
|
||||
#define MG_OTA_URL "https://mongoose.ws/ota/u/PREFIX/ota.json" // Copy from instructions panel
|
||||
#define MG_OTA_FIRMWARE_VERSION "MY_PRODUCT_1.4.2" // Change this
|
||||
#define MG_FIRMWARE_VERSION "MY_PRODUCT_1.4.2" // Change this
|
||||
```
|
||||
|
||||
No backend programming required. The device registers itself and checks in at
|
||||
|
||||
+3
-3
@@ -7033,7 +7033,7 @@ static void mg_mdash_rpc_get_info(struct mg_rpc_req *r) {
|
||||
"{%m:%m,%m:%llu,%m:%m,%m:\"mws.%d\",%m:{%m:true,"
|
||||
"%m:{%m:\"0x%08lx\",%m:\"0x%08lx\",%m:\"0x%08lx\"},"
|
||||
"%m:{%m:\"0x%08lx\",%m:%m}}}",
|
||||
MG_ESC("fw_version"), MG_ESC(MG_MDASH_FIRMWARE_VERSION),
|
||||
MG_ESC("fw_version"), MG_ESC(MG_FIRMWARE_VERSION),
|
||||
MG_ESC("uptime"), (uint64_t) (mg_millis() / 1000),
|
||||
MG_ESC("reboot_reason"),
|
||||
MG_ESC(mg_health_reason_str(mg_health_reason())), MG_ESC("arch"),
|
||||
@@ -7046,7 +7046,7 @@ static void mg_mdash_rpc_get_info(struct mg_rpc_req *r) {
|
||||
(uint8_t *) &data[3]);
|
||||
} else {
|
||||
mg_rpc_ok(r, "{%m:%m,%m:%llu,%m:%m,%m:\"mws.%d\",%m:{%m:false}}",
|
||||
MG_ESC("fw_version"), MG_ESC(MG_MDASH_FIRMWARE_VERSION),
|
||||
MG_ESC("fw_version"), MG_ESC(MG_FIRMWARE_VERSION),
|
||||
MG_ESC("uptime"), (uint64_t) (mg_millis() / 1000),
|
||||
MG_ESC("reboot_reason"),
|
||||
MG_ESC(mg_health_reason_str(mg_health_reason())), MG_ESC("arch"),
|
||||
@@ -10852,7 +10852,7 @@ void mg_tcpip_mapip(struct mg_connection *c, struct mg_addr *ip) {
|
||||
|
||||
// Scannable version tag embedded in every firmware binary, for server-side
|
||||
// version extraction. The version string starts after the "MG_VERSION:" prefix.
|
||||
static const char s_fw_version[] = "MG_VERSION:" MG_OTA_FIRMWARE_VERSION;
|
||||
static const char s_fw_version[] = "MG_VERSION:" MG_FIRMWARE_VERSION;
|
||||
|
||||
static bool s_autocommit_ok; // True after OTA server confirms "same version"
|
||||
|
||||
|
||||
+3
-7
@@ -4859,7 +4859,7 @@ enum {
|
||||
// needs to be defined. Fetches metadata_url, which must
|
||||
// return a JSON object like:
|
||||
// { "version": "1.2.3", "url": "FIRMWARE_URL", "size": 324645 }
|
||||
// If the server version differs from MG_OTA_FIRMWARE_VERSION, downloads
|
||||
// If the server version differs from MG_FIRMWARE_VERSION, downloads
|
||||
// FIRMWARE_URL and performs the OTA update. fn is called on every outcome:
|
||||
// NULL on successful flash, "Same version" when already up to date, or an
|
||||
// error string on failure. Pass NULL to use the default handler which logs
|
||||
@@ -4886,8 +4886,8 @@ void mg_ota_url_check(struct mg_mgr *mgr, const char *metadata_url,
|
||||
#endif
|
||||
|
||||
// Firmware version for mg_ota_poll(). Settable in mongoose_config.h
|
||||
#ifndef MG_OTA_FIRMWARE_VERSION
|
||||
#define MG_OTA_FIRMWARE_VERSION "1.0.0"
|
||||
#ifndef MG_FIRMWARE_VERSION
|
||||
#define MG_FIRMWARE_VERSION "1.0.0"
|
||||
#endif
|
||||
|
||||
// Maximum version string length
|
||||
@@ -5050,10 +5050,6 @@ static inline void mg_health_init(void) {
|
||||
#define MG_MDASH_KEY ""
|
||||
#endif
|
||||
|
||||
#ifndef MG_MDASH_FIRMWARE_VERSION
|
||||
#define MG_MDASH_FIRMWARE_VERSION "1.0.0"
|
||||
#endif
|
||||
|
||||
#ifndef MG_ENABLE_MDASH
|
||||
#define MG_ENABLE_MDASH 0
|
||||
#endif
|
||||
|
||||
+2
-2
@@ -97,7 +97,7 @@ static void mg_mdash_rpc_get_info(struct mg_rpc_req *r) {
|
||||
"{%m:%m,%m:%llu,%m:%m,%m:\"mws.%d\",%m:{%m:true,"
|
||||
"%m:{%m:\"0x%08lx\",%m:\"0x%08lx\",%m:\"0x%08lx\"},"
|
||||
"%m:{%m:\"0x%08lx\",%m:%m}}}",
|
||||
MG_ESC("fw_version"), MG_ESC(MG_MDASH_FIRMWARE_VERSION),
|
||||
MG_ESC("fw_version"), MG_ESC(MG_FIRMWARE_VERSION),
|
||||
MG_ESC("uptime"), (uint64_t) (mg_millis() / 1000),
|
||||
MG_ESC("reboot_reason"),
|
||||
MG_ESC(mg_health_reason_str(mg_health_reason())), MG_ESC("arch"),
|
||||
@@ -110,7 +110,7 @@ static void mg_mdash_rpc_get_info(struct mg_rpc_req *r) {
|
||||
(uint8_t *) &data[3]);
|
||||
} else {
|
||||
mg_rpc_ok(r, "{%m:%m,%m:%llu,%m:%m,%m:\"mws.%d\",%m:{%m:false}}",
|
||||
MG_ESC("fw_version"), MG_ESC(MG_MDASH_FIRMWARE_VERSION),
|
||||
MG_ESC("fw_version"), MG_ESC(MG_FIRMWARE_VERSION),
|
||||
MG_ESC("uptime"), (uint64_t) (mg_millis() / 1000),
|
||||
MG_ESC("reboot_reason"),
|
||||
MG_ESC(mg_health_reason_str(mg_health_reason())), MG_ESC("arch"),
|
||||
|
||||
@@ -12,10 +12,6 @@
|
||||
#define MG_MDASH_KEY ""
|
||||
#endif
|
||||
|
||||
#ifndef MG_MDASH_FIRMWARE_VERSION
|
||||
#define MG_MDASH_FIRMWARE_VERSION "1.0.0"
|
||||
#endif
|
||||
|
||||
#ifndef MG_ENABLE_MDASH
|
||||
#define MG_ENABLE_MDASH 0
|
||||
#endif
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
// Scannable version tag embedded in every firmware binary, for server-side
|
||||
// version extraction. The version string starts after the "MG_VERSION:" prefix.
|
||||
static const char s_fw_version[] = "MG_VERSION:" MG_OTA_FIRMWARE_VERSION;
|
||||
static const char s_fw_version[] = "MG_VERSION:" MG_FIRMWARE_VERSION;
|
||||
|
||||
static bool s_autocommit_ok; // True after OTA server confirms "same version"
|
||||
|
||||
|
||||
@@ -154,7 +154,7 @@ enum {
|
||||
// needs to be defined. Fetches metadata_url, which must
|
||||
// return a JSON object like:
|
||||
// { "version": "1.2.3", "url": "FIRMWARE_URL", "size": 324645 }
|
||||
// If the server version differs from MG_OTA_FIRMWARE_VERSION, downloads
|
||||
// If the server version differs from MG_FIRMWARE_VERSION, downloads
|
||||
// FIRMWARE_URL and performs the OTA update. fn is called on every outcome:
|
||||
// NULL on successful flash, "Same version" when already up to date, or an
|
||||
// error string on failure. Pass NULL to use the default handler which logs
|
||||
@@ -181,8 +181,8 @@ void mg_ota_url_check(struct mg_mgr *mgr, const char *metadata_url,
|
||||
#endif
|
||||
|
||||
// Firmware version for mg_ota_poll(). Settable in mongoose_config.h
|
||||
#ifndef MG_OTA_FIRMWARE_VERSION
|
||||
#define MG_OTA_FIRMWARE_VERSION "1.0.0"
|
||||
#ifndef MG_FIRMWARE_VERSION
|
||||
#define MG_FIRMWARE_VERSION "1.0.0"
|
||||
#endif
|
||||
|
||||
// Maximum version string length
|
||||
|
||||
@@ -1,33 +1,31 @@
|
||||
# Environment setup: https://mongoose.ws/documentation/tutorials/tools/
|
||||
|
||||
MGDIR = ../../../..
|
||||
|
||||
CFLAGS = -W -Wall -Wextra -Werror -Wundef -Wshadow -Wdouble-promotion
|
||||
CFLAGS += -Wformat-truncation -fno-common -Wno-conversion -Wno-sign-conversion
|
||||
CFLAGS += -g3 -Os -ffunction-sections -fdata-sections
|
||||
CFLAGS += -Wno-cast-function-type -Wno-old-style-declaration
|
||||
CFLAGS += -Wno-unused-parameter
|
||||
CFLAGS += -I. -Imongoose -Icmsis_core/CMSIS/Core/Include/
|
||||
CFLAGS += -I. -I$(MGDIR) -Imongoose -Icmsis_core/CMSIS/Core/Include/
|
||||
CFLAGS += -Icmsis_rw612/devices/RW612/ -Icmsis_rw612/devices/RW612/periph/ -Icmsis_rw612/devices/RW612/drivers/
|
||||
CFLAGS += -DCPU_RW612ETA2I -DCPU_RW612ETA2I_cm33_no_dsp
|
||||
CFLAGS += -DBOOT_HEADER_ENABLE=1
|
||||
CFLAGS += -mcpu=cortex-m33+nodsp -mthumb -mfloat-abi=hard -mfpu=fpv5-sp-d16 $(CFLAGS_EXTRA)
|
||||
LDFLAGS ?= -Tlink.ld -nostdlib -nostartfiles --specs=nano.specs -lc -lgcc -Wl,--gc-sections -Wl,-Map=$@.map
|
||||
|
||||
SOURCES = main.c hal.c startup.c flexspi.c flash_config.c mongoose/mongoose.c
|
||||
SOURCES = main.c hal.c startup.c flexspi.c flash_config.c $(MGDIR)/mongoose.c
|
||||
SOURCES += cmsis_rw612/devices/RW612/drivers/fsl_clock.c
|
||||
SOURCES += cmsis_rw612/devices/RW612/drivers/fsl_trng.c
|
||||
SOURCES += cmsis_rw612/devices/RW612/drivers/fsl_reset.c
|
||||
|
||||
all build: firmware.bin
|
||||
|
||||
mongoose/mongoose.c mongoose/mongoose.h:
|
||||
mkdir -p mongoose
|
||||
cp ../../../../mongoose.[ch] mongoose/
|
||||
|
||||
firmware.bin: firmware.elf
|
||||
arm-none-eabi-objcopy -O binary $< $@
|
||||
arm-none-eabi-size --format=berkeley $<
|
||||
|
||||
firmware.elf: cmsis_core cmsis_rw612 $(SOURCES) $(wildcard *.h) link.ld Makefile
|
||||
firmware.elf: cmsis_core cmsis_rw612 $(SOURCES) $(wildcard *.h) link.ld Makefile mongoose_config.h
|
||||
arm-none-eabi-gcc $(SOURCES) $(CFLAGS) $(LDFLAGS) -o $@
|
||||
|
||||
cmsis_core:
|
||||
@@ -38,5 +36,9 @@ cmsis_rw612:
|
||||
unzip -q NXP.RW612_DFP.25.12.00.pack -d $@
|
||||
rm NXP.RW612_DFP.25.12.00.pack
|
||||
|
||||
flash: firmware.bin
|
||||
(echo 'loadfile firmware.elf'; echo 'reset'; echo 'exit';) | JLinkExe -device RW612 -if SWD -speed 4000 -autoconnect 1 -NoGui 1 -ExitOnError 1
|
||||
# JRun --nogui --device RW612 --if SWD firmware.elf
|
||||
|
||||
clean:
|
||||
rm -rf firmware.* cmsis_* mongoose/mongoose.*
|
||||
@@ -18,7 +18,7 @@ static void log_fn(char ch, void *param) {
|
||||
|
||||
static void blink_task(void) {
|
||||
static uint64_t blink_timer = 0;
|
||||
if (hal_timer_expired(&blink_timer, 500, hal_get_tick())) {
|
||||
if (hal_timer_expired(&blink_timer, 100, hal_get_tick())) {
|
||||
hal_gpio_toggle(LED1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,11 @@
|
||||
#define MG_ENABLE_CUSTOM_MILLIS 1
|
||||
#define MG_ENABLE_CUSTOM_RANDOM 1
|
||||
#define MG_OTA MG_OTA_RW612
|
||||
#define MG_TLS MG_TLS_BUILTIN
|
||||
|
||||
#define MG_ENABLE_MDASH 0 // Set to 1 to enable https://mdash.net
|
||||
#define MG_MDASH_KEY "..." // Edit, see https://mdash.net/docs/#mongoose-library
|
||||
#define MG_FIRMWARE_VERSION "1.0.1"
|
||||
|
||||
// #define MG_DRIVER_MDC_CR 51 // RMII MDC clock divider
|
||||
// #define MG_DRIVER_MDC_HOLDTIME 3 // RMII MDC Holdtime (valid values [0-7])
|
||||
|
||||
@@ -87,7 +87,7 @@ static double s_volume = 17.2;
|
||||
static int s_log_level = MG_LL_DEBUG;
|
||||
static char s_name[20] = "Dublin";
|
||||
static int s_ota_interval = 30;
|
||||
static char s_ota_version[] = MG_OTA_FIRMWARE_VERSION;
|
||||
static char s_ota_version[] = MG_FIRMWARE_VERSION;
|
||||
static char s_ota_status[40] = "No scans yet";
|
||||
static char s_ota_url[100] = "https://my-product.com/ota.json";
|
||||
|
||||
|
||||
Reference in new issue
Block a user