From b382726ed046ebf10c30bfdb6efb324b2e9e7c30 Mon Sep 17 00:00:00 2001 From: cpq Date: Thu, 18 Aug 2022 21:36:23 +0100 Subject: [PATCH] Build dashboard by default, fix FPU flag --- .../stm32/nucleo-f746zg-baremetal/Makefile | 18 ++++----- examples/stm32/nucleo-f746zg-baremetal/main.c | 40 +------------------ 2 files changed, 9 insertions(+), 49 deletions(-) diff --git a/examples/stm32/nucleo-f746zg-baremetal/Makefile b/examples/stm32/nucleo-f746zg-baremetal/Makefile index 63ef397d..ee2f73c2 100644 --- a/examples/stm32/nucleo-f746zg-baremetal/Makefile +++ b/examples/stm32/nucleo-f746zg-baremetal/Makefile @@ -5,12 +5,15 @@ DOCKER ?= $(D) run --rm -v $(ROOT):$(ROOT) -w $(CURDIR) mdashnet/armgcc CROSS ?= arm-none-eabi CFLAGS ?= -W -Wall -Wextra -Werror -Wundef -Wshadow -Wdouble-promotion \ -Wformat-truncation -fno-common -Wconversion \ - -g3 -Os -ffunction-sections -fdata-sections \ - -I. -I$(ROOT) -DMG_ARCH=MG_ARCH_NEWLIB -DMIP_DEBUG=1 \ - -DMG_ENABLE_CUSTOM_MILLIS=1 -DMG_ENABLE_LINES=1 -DMG_ENABLE_MIP=1 \ - -mcpu=cortex-m7 -mthumb -mfloat-abi=hard -mfpu=auto $(EXTRA_CFLAGS) + -g3 -Os -ffunction-sections -fdata-sections -I. -I$(ROOT) \ + -DMG_ARCH=MG_ARCH_NEWLIB -DMIP_DEBUG=1 -DMG_ENABLE_PACKED_FS=1 \ + -DMG_ENABLE_CUSTOM_MILLIS=1 -DxMG_ENABLE_LINES=1 -DMG_ENABLE_MIP=1 \ + -mcpu=cortex-m7 -mthumb -mfloat-abi=soft $(EXTRA_CFLAGS) LDFLAGS ?= -Tlink.ld -nostartfiles -nostdlib --specs nano.specs -lc -lgcc -Wl,--gc-sections -Wl,-Map=$@.map -SOURCES = boot.c main.c syscalls.c $(ROOT)/mongoose.c +SOURCES = boot.c main.c syscalls.c \ + $(ROOT)/mongoose.c \ + $(ROOT)/examples/device-dashboard/packed_fs.c \ + $(ROOT)/examples/device-dashboard/net.c all build example: $(TARGET).bin @@ -26,11 +29,6 @@ windows: $(TARGET).bin windows: CROSS = $(ARMGCC)/bin/arm-none-eabi windows: DOCKER = -# Build an interactive device dashboard -dash: $(TARGET).elf -dash: CFLAGS += -DDASH -DMG_ENABLE_PACKED_FS=1 -dash: SOURCES += $(ROOT)/examples/device-dashboard/packed_fs.c $(ROOT)/examples/device-dashboard/web.c - # Show top 10 stack-hungry functions su: CFLAGS += -fstack-usage su: $(TARGET).elf diff --git a/examples/stm32/nucleo-f746zg-baremetal/main.c b/examples/stm32/nucleo-f746zg-baremetal/main.c index 0dc9951b..65883dc5 100644 --- a/examples/stm32/nucleo-f746zg-baremetal/main.c +++ b/examples/stm32/nucleo-f746zg-baremetal/main.c @@ -36,7 +36,6 @@ static void sfn(struct mg_connection *c, int ev, void *ev_data, void *fn_data) { static void sntp_cb(void *param) { // SNTP timer function. Sync up time struct mg_mgr *mgr = (struct mg_mgr *) param; - return; // TODO(cpq): re-enable! if (s_sntp_conn == NULL && s_boot_timestamp == 0) { s_sntp_conn = mg_sntp_connect(mgr, NULL, sfn, NULL); } @@ -48,40 +47,6 @@ static void blink_cb(void *arg) { // Blink periodically (void) arg; } -// Server event handler -static void fn(struct mg_connection *c, int ev, void *ev_data, void *fn_data) { - if (ev == MG_EV_POLL) return; - // MG_DEBUG(("%lu %p %d %p %p", c->id, c, ev, ev_data, fn_data)); - if (ev == MG_EV_HTTP_MSG) { - struct mg_http_message *hm = (struct mg_http_message *) ev_data; - if (mg_http_match_uri(hm, "/api/stats")) { - // Print some statistics about currently established connections - mg_printf(c, "HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\n\r\n"); - mg_http_printf_chunk(c, "ID PROTO TYPE LOCAL REMOTE\n"); - for (struct mg_connection *t = c->mgr->conns; t != NULL; t = t->next) { - char loc[40], rem[40]; - mg_http_printf_chunk(c, "%-3lu %4s %s %-15s %s\n", t->id, - t->is_udp ? "UDP" : "TCP", - t->is_listening ? "LISTENING" - : t->is_accepted ? "ACCEPTED " - : "CONNECTED", - mg_straddr(&t->loc, loc, sizeof(loc)), - mg_straddr(&t->rem, rem, sizeof(rem))); - } - mg_http_printf_chunk(c, ""); // Don't forget the last empty chunk - } else { - mg_http_reply(c, 200, "", "hi\n"); -#if 0 - struct mg_http_serve_opts opts = {0}; - opts.root_dir = "/web_root"; - opts.fs = &mg_fs_packed; - mg_http_serve_dir(c, hm, &opts); -#endif - } - } - (void) fn_data; -} - uint64_t mg_millis(void) { // Declare our own uptime function return s_ticks; // Return number of milliseconds since boot } @@ -132,7 +97,6 @@ int main(void) { mg_log_set(MG_LL_DEBUG); // Set log level mg_timer_add(&mgr, 1000, MG_TIMER_REPEAT, blink_cb, &mgr); mg_timer_add(&mgr, 5000, MG_TIMER_REPEAT, sntp_cb, &mgr); - mg_http_listen(&mgr, "http://0.0.0.0:80", fn, NULL); // Initialise Mongoose network stack // Specify MAC address, and use 0 for IP, mask, GW - i.e. use DHCP @@ -142,10 +106,8 @@ int main(void) { mip_init(&mgr, &ipcfg, &mip_driver_stm32); MG_INFO(("Init done, starting main loop")); -#if defined(DASH) extern void device_dashboard_fn(struct mg_connection *, int, void *, void *); - mg_http_listen(&mgr, "http://0.0.0.0:8000", device_dashboard_fn, &mgr); -#endif + mg_http_listen(&mgr, "http://0.0.0.0", device_dashboard_fn, &mgr); for (;;) mg_mgr_poll(&mgr, 0); // Infinite event loop return 0;