mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-25 12:04:47 +00:00
LFS nits
This commit is contained in:
1 parent
f62f3545b4
commit
81f6acbce7
19 files changed
+258
-128
No files matched your search
@@ -1,23 +1,26 @@
|
||||
# Copyright (c) 2026 Cesanta Software Limited
|
||||
# Environment setup: https://mongoose.ws/docs/getting-started/build-environment/
|
||||
|
||||
MGDIR = ../../../..
|
||||
|
||||
CFLAGS = -W -Wall -Wextra -Wundef -Wshadow -Wdouble-promotion
|
||||
CFLAGS += -Wformat-truncation -fno-common -Wconversion -Wno-sign-conversion
|
||||
CFLAGS += -g3 -Os -ffunction-sections -fdata-sections
|
||||
CFLAGS += -I. -Icmsis_core/CMSIS/Core/Include -Icmsis_h5/Include -Imongoose
|
||||
CFLAGS += -I. -I$(MGDIR) -Icmsis_core/CMSIS/Core/Include -Icmsis_h5/Include -Imongoose
|
||||
CFLAGS += -mcpu=cortex-m33 -mthumb -mfpu=fpv5-sp-d16 -mfloat-abi=hard $(CFLAGS_EXTRA)
|
||||
LDFLAGS ?= -Tlink.ld -nostdlib -nostartfiles --specs nosys.specs -lc -lgcc -Wl,--gc-sections -Wl,-Map=$@.map
|
||||
|
||||
SOURCES = main.c hal.c
|
||||
SOURCES += littlefs/lfs.c littlefs/lfs_util.c
|
||||
SOURCES += cmsis_h5/Source/Templates/gcc/startup_stm32h563xx.s
|
||||
SOURCES += mongoose/mongoose.c
|
||||
SOURCES += $(MGDIR)/mongoose.c
|
||||
|
||||
# Disabled for littlefs/lfs.c
|
||||
CFLAGS += -Wno-conversion -Wno-shadow
|
||||
|
||||
all build example: firmware.bin
|
||||
|
||||
mongoose/mongoose.c mongoose/mongoose.h:
|
||||
cp ../../../../mongoose.[ch] mongoose/
|
||||
|
||||
firmware.elf: cmsis_core cmsis_h5 hal.h link.ld Makefile $(SOURCES) mongoose/mongoose.h
|
||||
firmware.elf: cmsis_core cmsis_h5 littlefs hal.h link.ld Makefile $(SOURCES) $(MGDIR)/mongoose.h
|
||||
arm-none-eabi-gcc $(SOURCES) $(CFLAGS) $(CFLAGS_EXTRA) $(LDFLAGS) -o $@
|
||||
|
||||
firmware.bin: firmware.elf
|
||||
@@ -42,6 +45,10 @@ cmsis_core:
|
||||
cmsis_h5:
|
||||
git clone -q -c advice.detachedHead=false --depth 1 -b v1.6.0 https://github.com/STMicroelectronics/cmsis-device-h5 $@
|
||||
|
||||
littlefs/lfs.c littlefs/lfs_util.c: littlefs
|
||||
littlefs:
|
||||
git clone -q -c advice.detachedHead=false --depth 1 -b v2.11.3 https://github.com/littlefs-project/littlefs $@
|
||||
|
||||
clean:
|
||||
rm -rf firmware.* cmsis_* mongoose/mongoose.*
|
||||
|
||||
|
||||
@@ -45,8 +45,20 @@ static void http_ev_handler(struct mg_connection *c, int ev, void *ev_data) {
|
||||
struct mg_http_message *hm = (struct mg_http_message *) ev_data;
|
||||
if (mg_match(hm->uri, mg_str("/api/tick"), NULL)) {
|
||||
mg_http_reply(c, 200, "", "{%m:%llu}\n", MG_ESC("tick"), hal_get_tick());
|
||||
} else if (mg_match(hm->uri, mg_str("/files/#"), NULL)) {
|
||||
struct mg_http_serve_opts opts = {
|
||||
.root_dir = "/files/=/fs/",
|
||||
.allow_delete = true,
|
||||
.allow_upload = true,
|
||||
};
|
||||
mg_http_serve_dir(c, hm, &opts);
|
||||
} else {
|
||||
mg_http_reply(c, 200, "", "Hi from Mongoose, tick %llu\n", hal_get_tick());
|
||||
size_t u = hal_ram_used(), t = u + hal_ram_free();
|
||||
mg_http_reply(c, 200, "",
|
||||
"Hi from Mongoose!\n"
|
||||
"Tick %llu\n"
|
||||
"RAM usage: %zu / %zu (%zu %%)\n",
|
||||
hal_get_tick(), u, t, (size_t) (100 * u / t));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -67,6 +79,14 @@ int main(void) {
|
||||
mg_mgr_init(&mgr);
|
||||
mg_http_listen(&mgr, "http://0.0.0.0", http_ev_handler, NULL);
|
||||
|
||||
// Create directory for Web file manager. Will be mapped to /files/ URL
|
||||
mkdir("/fs", 0755);
|
||||
MG_INFO(("File manager operations:"));
|
||||
MG_INFO(("Upload: curl IP/files/NAME --data-binary @FILE"));
|
||||
MG_INFO(("Delete: curl IP/files/NAME -X DELETE"));
|
||||
MG_INFO(("Show: curl IP/files/NAME"));
|
||||
MG_INFO(("List: curl IP/files/"));
|
||||
|
||||
for (;;) {
|
||||
mg_mgr_poll(&mgr, 0);
|
||||
blink_task();
|
||||
|
||||
+5
@@ -12,6 +12,11 @@
|
||||
#define MG_ENABLE_PACKED_FS 1
|
||||
#define MG_ENABLE_DRIVER_STM32H 1
|
||||
|
||||
#define MG_ENABLE_LFS 1 // Enable POSIX filesystem on interfal flash using LFS
|
||||
#define MG_LFS_SIZE (1024 * 128) // Must be multiple of H5 8Kb sectors
|
||||
#define MG_OTA MG_OTA_STM32H5 // MG_OTA required for LFS, for flash usage
|
||||
#define MG_ENABLE_LINES 1
|
||||
|
||||
// #define MG_DRIVER_MDC_CR 4 // RMII MDC clock divider, from 0 to 4
|
||||
// #define MG_TCPIP_PHY_ADDR 0 // PHY address
|
||||
|
||||
Whitespace-only changes.
Reference in new issue
Block a user