From 983d9974ceef13f7980088bc7b80965d61bb5793 Mon Sep 17 00:00:00 2001 From: mikee47 Date: Wed, 24 Mar 2021 17:10:53 +0000 Subject: [PATCH] Add `host_debug_X()` functions and associated `debug` command-line parameter --- .../Arch/Host/Components/driver/hw_timer.cpp | 2 +- .../Host/Components/driver/uart_server.cpp | 12 ++++---- Sming/Arch/Host/Components/esp_hal/tasks.cpp | 8 +++--- Sming/Arch/Host/Components/hostlib/hostmsg.c | 2 ++ Sming/Arch/Host/Components/hostlib/hostmsg.h | 16 +++++++++++ Sming/Arch/Host/Components/hostlib/options.h | 4 ++- .../Arch/Host/Components/hostlib/sockets.cpp | 10 +++---- .../Arch/Host/Components/hostlib/startup.cpp | 28 +++++++++++-------- .../Host/Components/lwip/Linux/host_lwip.c | 21 +++++++------- .../Host/Components/lwip/Windows/host_lwip.c | 16 +++++------ .../Host/Components/spi_flash/flashmem.cpp | 16 +++++------ Sming/Arch/Host/Platform/StationImpl.cpp | 10 +++---- .../Components/rboot/src/Arch/Host/rboot.cpp | 12 ++++---- samples/Basic_Utility/README.rst | 7 ++++- 14 files changed, 98 insertions(+), 66 deletions(-) diff --git a/Sming/Arch/Host/Components/driver/hw_timer.cpp b/Sming/Arch/Host/Components/driver/hw_timer.cpp index 2b6b04f638..6e8abc7172 100644 --- a/Sming/Arch/Host/Components/driver/hw_timer.cpp +++ b/Sming/Arch/Host/Components/driver/hw_timer.cpp @@ -168,7 +168,7 @@ void* CTimerThread::thread_routine() continue; // state changed } if(errno != ETIMEDOUT) { - hostmsg("Warning! Timer thread errno = %u", errno); + host_debug_w("Timer thread errno = %u", errno); break; } } diff --git a/Sming/Arch/Host/Components/driver/uart_server.cpp b/Sming/Arch/Host/Components/driver/uart_server.cpp index 5da69e90fa..08e9d4f74b 100644 --- a/Sming/Arch/Host/Components/driver/uart_server.cpp +++ b/Sming/Arch/Host/Components/driver/uart_server.cpp @@ -183,7 +183,7 @@ void CUartServer::terminate() { close(); join(); - hostmsg("UART%u server destroyed", uart_nr); + host_debug_i("UART%u server destroyed", uart_nr); } void CUartServer::onNotify(smg_uart_t* uart, smg_uart_notify_code_t code) @@ -271,7 +271,7 @@ int CUartServer::serviceWrite() do { int sent = socket->send(data, avail); if(sent < 0) { - hostmsg("Uart send returned %d", sent); + host_debug_w("Uart send returned %d", sent); result = sent; break; } @@ -295,11 +295,11 @@ void* CUartServer::thread_routine() auto port = portBase + uart_nr; CSockAddr addr(nullptr, port); if(!listen(addr, 1)) { - hostmsg("Listen %s failed", addr.text().c_str()); + host_debug_e("Listen %s failed", addr.text().c_str()); return nullptr; } - hostmsg("UART%u server listening on port %u", uart_nr, port); + host_debug_i("UART%u server listening on port %u", uart_nr, port); while(active()) { socket = try_connect(); @@ -308,7 +308,7 @@ void* CUartServer::thread_routine() continue; } - hostmsg("Uart #%u socket open", uart_nr); + host_debug_i("Uart #%u socket open", uart_nr); while(socket->active()) { if(txsem.timedwait(IDLE_SLEEP_MS)) { @@ -335,7 +335,7 @@ void* CUartServer::thread_routine() } socket->close(); - hostmsg("Uart #%u socket closed", uart_nr); + host_debug_i("Uart #%u socket closed", uart_nr); } return nullptr; diff --git a/Sming/Arch/Host/Components/esp_hal/tasks.cpp b/Sming/Arch/Host/Components/esp_hal/tasks.cpp index eec99b5bb7..064fe7e860 100644 --- a/Sming/Arch/Host/Components/esp_hal/tasks.cpp +++ b/Sming/Arch/Host/Components/esp_hal/tasks.cpp @@ -55,12 +55,12 @@ const uint8_t HOST_TASK_PRIO = USER_TASK_PRIO_MAX; bool system_os_task(os_task_t callback, uint8_t prio, os_event_t* events, uint8_t qlen) { if(prio >= USER_TASK_PRIO_MAX) { - hostmsg("Invalid priority %u", prio); + host_debug_e("Invalid priority %u", prio); return false; } auto& queue = task_queues[prio]; if(queue != nullptr) { - hostmsg("Queue %u already initialised", prio); + host_debug_e("Queue %u already initialised", prio); return false; } @@ -71,12 +71,12 @@ bool system_os_task(os_task_t callback, uint8_t prio, os_event_t* events, uint8_ bool system_os_post(uint8_t prio, os_signal_t sig, os_param_t par) { if(prio >= USER_TASK_PRIO_MAX) { - hostmsg("Invalid priority %u", prio); + host_debug_e("Invalid priority %u", prio); return false; } auto& queue = task_queues[prio]; if(queue == nullptr) { - hostmsg("Task queue %u not initialised", prio); + host_debug_e("Task queue %u not initialised", prio); return false; } diff --git a/Sming/Arch/Host/Components/hostlib/hostmsg.c b/Sming/Arch/Host/Components/hostlib/hostmsg.c index 6076a9fefe..c4be9a91c4 100644 --- a/Sming/Arch/Host/Components/hostlib/hostmsg.c +++ b/Sming/Arch/Host/Components/hostlib/hostmsg.c @@ -22,6 +22,8 @@ #include #include "hostmsg.h" +int host_debug_level = 2; + /* * e.g. from "void a::sub(int)" we just want "a::sub" */ diff --git a/Sming/Arch/Host/Components/hostlib/hostmsg.h b/Sming/Arch/Host/Components/hostlib/hostmsg.h index 1fd6537dc4..149c62335c 100644 --- a/Sming/Arch/Host/Components/hostlib/hostmsg.h +++ b/Sming/Arch/Host/Components/hostlib/hostmsg.h @@ -36,6 +36,22 @@ void host_puts(const char* str); #define hostmsg(fmt, ...) host_printfp(fmt "\n", __func__, ##__VA_ARGS__) #endif +/** + * @brief Emit message only if host_debug_level >= level + */ +#define host_debug(level, fmt, ...) \ + do { \ + if(host_debug_level >= (level)) { \ + host_printf(fmt "\n", ##__VA_ARGS__); \ + } \ + } while(0) + +#define host_debug_e(fmt, ...) host_debug(0, "Error! " fmt, ##__VA_ARGS__) +#define host_debug_w(fmt, ...) host_debug(1, "Warning! " fmt, ##__VA_ARGS__) +#define host_debug_i(fmt, ...) host_debug(2, fmt, ##__VA_ARGS__) + +extern int host_debug_level; + #ifdef __cplusplus } #endif diff --git a/Sming/Arch/Host/Components/hostlib/options.h b/Sming/Arch/Host/Components/hostlib/options.h index f148b70847..a7371993b6 100644 --- a/Sming/Arch/Host/Components/hostlib/options.h +++ b/Sming/Arch/Host/Components/hostlib/options.h @@ -48,7 +48,9 @@ XX(flashsize, required_argument, "Change default flash size if file doesn't exist", "SIZE", \ "Size of flash in bytes (e.g. 512K, 524288, 0x80000)", nullptr) \ XX(initonly, no_argument, "Initialise only, do not start Sming", nullptr, nullptr, nullptr) \ - XX(nonet, no_argument, "Skip network initialisation", nullptr, nullptr, nullptr) + XX(nonet, no_argument, "Skip network initialisation", nullptr, nullptr, nullptr) \ + XX(debug, required_argument, "Set debug verbosity", "LEVEL", "Maximum debug message level to print", \ + "0 = errors only, 1 = +warnings, 2 = +info\0") enum option_tag_t { #define XX(tag, has_arg, desc, argname, arghelp, examples) opt_##tag, diff --git a/Sming/Arch/Host/Components/hostlib/sockets.cpp b/Sming/Arch/Host/Components/hostlib/sockets.cpp index 41c4a3fbb5..5be1025302 100644 --- a/Sming/Arch/Host/Components/hostlib/sockets.cpp +++ b/Sming/Arch/Host/Components/hostlib/sockets.cpp @@ -147,20 +147,20 @@ bool CSocket::create() // creation of the socket m_fd = ::socket(AF_INET, m_type, 0); if(m_fd <= 0) { - hostmsg("%s", socket_strerror().c_str()); + host_debug_e("%s", socket_strerror().c_str()); return false; } int reuse = 1; if(setsockopt(m_fd, SOL_SOCKET, SO_REUSEADDR, (sock_ptr_t)&reuse, sizeof(reuse)) < 0) { - hostmsg("REUSEADDR: %s", socket_strerror().c_str()); + host_debug_e("REUSEADDR: %s", socket_strerror().c_str()); close(); return false; } #ifdef SO_REUSEPORT if(setsockopt(m_fd, SOL_SOCKET, SO_REUSEPORT, (sock_ptr_t)&reuse, sizeof(reuse)) < 0) { - hostmsg("REUSEPORT: %s", socket_strerror().c_str()); + host_debug_e("REUSEPORT: %s", socket_strerror().c_str()); close(); return false; } @@ -212,7 +212,7 @@ void CSocket::close() return; } - hostmsg("%s", addr().text().c_str()); + host_debug_i("%s", addr().text().c_str()); socket_close(m_fd); m_fd = 0; @@ -375,7 +375,7 @@ CSocket* CSocketList::recv(void* buf, size_t& n) #endif if(errno != EPIPE) { // Broken pipe - hostmsg("%s", socket_strerror().c_str()); + host_debug_e("%s", socket_strerror().c_str()); } skt->close(); } diff --git a/Sming/Arch/Host/Components/hostlib/startup.cpp b/Sming/Arch/Host/Components/hostlib/startup.cpp index dc918e8fd8..7b09ea3797 100644 --- a/Sming/Arch/Host/Components/hostlib/startup.cpp +++ b/Sming/Arch/Host/Components/hostlib/startup.cpp @@ -51,19 +51,19 @@ static void cleanup() CUartServer::shutdown(); sockets_finalise(); host_lwip_shutdown(); - hostmsg("Goodbye!"); + host_debug_i("Goodbye!"); } void host_exit(int code) { static unsigned exit_count; - hostmsg("returning %d", code); + host_debug_i("returning %d", code); exitCode = code; done = true; if(exit_count++) { - hostmsg("Forcing exit"); + host_debug_w("Forcing exit"); exit(exitCode); } } @@ -108,8 +108,6 @@ int main(int argc, char* argv[]) { trap_exceptions(); - host_printf("\nWelcome to the Sming Host emulator\n\n"); - static struct { int pause; int exitpause; @@ -197,10 +195,16 @@ int main(int argc, char* argv[]) config.enable_network = false; break; + case opt_debug: + host_debug_level = atoi(arg); + break; + default:; } } + host_debug_i("\nWelcome to the Sming Host emulator\n\n"); + auto i = get_first_non_option(); commandLine.parse(argc - i, &argv[i]); @@ -213,7 +217,7 @@ int main(int argc, char* argv[]) atexit(cleanup); if(config.initonly) { - hostmsg("Initialise-only requested"); + host_debug_i("Initialise-only requested"); } else { Storage::initialize(); @@ -233,13 +237,15 @@ int main(int argc, char* argv[]) host_wifi_lwip_init_complete(); } } else { - hostmsg("Network initialisation skipped as requested"); + host_debug_i("Network initialisation skipped as requested"); } - hostmsg("If required, you may start terminal application(s) now"); - pause(config.pause); + if(config.pause != 0) { + hostmsg("If required, you may start terminal application(s) now"); + pause(config.pause); + } - hostmsg(">> Starting Sming <<\n"); + host_debug_i(">> Starting Sming <<\n"); System.initialize(); @@ -257,7 +263,7 @@ int main(int argc, char* argv[]) system_soft_wdt_feed(); } - hostmsg(">> Normal Exit <<\n"); + host_debug_i(">> Normal Exit <<\n"); } pause(config.exitpause); diff --git a/Sming/Arch/Host/Components/lwip/Linux/host_lwip.c b/Sming/Arch/Host/Components/lwip/Linux/host_lwip.c index d5c38414c4..9c84f4fe9a 100644 --- a/Sming/Arch/Host/Components/lwip/Linux/host_lwip.c +++ b/Sming/Arch/Host/Components/lwip/Linux/host_lwip.c @@ -75,7 +75,7 @@ static bool getifaddr(const char* ifname, struct net_config* netcfg) { struct ifaddrs* list; if(getifaddrs(&list) < 0) { - hostmsg("getifaddrs: %s", strerror(errno)); + host_debug_e("getifaddrs: %s", strerror(errno)); return false; } @@ -111,26 +111,26 @@ static bool getifaddr(const char* ifname, struct net_config* netcfg) bool host_lwip_init(const struct lwip_param* param) { - hostmsg("%s", "Initialising LWIP"); + host_debug_i("%s", "Initialising LWIP"); struct net_config netcfg = {0}; if(!getifaddr(param->ifname, &netcfg)) { if(param->ifname == NULL) { - hostmsg("%s", "No compatible interface found"); + host_debug_e("%s", "No compatible interface found"); } else { - hostmsg("Interface '%s' not found", param->ifname); + host_debug_e("Interface '%s' not found", param->ifname); } return false; } if(param->gateway != NULL && ip4addr_aton(param->gateway, &netcfg.gw) != 1) { - hostmsg("Failed to parse provided Gateway address '%s'", param->gateway); + host_debug_e("Failed to parse provided Gateway address '%s'", param->gateway); return false; } if(param->netmask != NULL && ip4addr_aton(param->netmask, &netcfg.netmask) != 1) { - hostmsg("Failed to parse provided Network Mask '%s'", param->netmask); + host_debug_e("Failed to parse provided Network Mask '%s'", param->netmask); return false; } @@ -139,7 +139,7 @@ bool host_lwip_init(const struct lwip_param* param) IP4_ADDR(&netcfg.ipaddr, (uint32_t)ip4_addr1(&netcfg.gw), (uint32_t)ip4_addr2(&netcfg.gw), (uint32_t)ip4_addr3(&netcfg.gw), 10U); } else if(ip4addr_aton(param->ipaddr, &netcfg.ipaddr) != 1) { - hostmsg("Failed to parse provided IP address '%s'", param->ipaddr); + host_debug_e("Failed to parse provided IP address '%s'", param->ipaddr); return false; } @@ -149,7 +149,8 @@ bool host_lwip_init(const struct lwip_param* param) ip4addr_ntoa_r(&netcfg.netmask, nm_str, sizeof(nm_str)); char gw_str[IP4ADDR_STRLEN_MAX]; ip4addr_ntoa_r(&netcfg.gw, gw_str, sizeof(gw_str)); - hostmsg("Using interface '%s', gateway = %s, netmask = %s; using ip = %s", netcfg.ifname, gw_str, nm_str, ip_str); + host_debug_i("Using interface '%s', gateway = %s, netmask = %s; using ip = %s", netcfg.ifname, gw_str, nm_str, + ip_str); setenv("PRECONFIGURED_TAPIF", netcfg.ifname, true); @@ -158,8 +159,8 @@ bool host_lwip_init(const struct lwip_param* param) netif_add(&netif, &netcfg.ipaddr, &netcfg.netmask, &netcfg.gw, NULL, tapif_init, ethernet_input); getMacAddress(netcfg.ifname, netif.hwaddr); - hostmsg("MAC: %02x:%02x:%02x:%02x:%02x:%02x", netif.hwaddr[0], netif.hwaddr[1], netif.hwaddr[2], netif.hwaddr[3], - netif.hwaddr[4], netif.hwaddr[5]); + host_debug_i("MAC: %02x:%02x:%02x:%02x:%02x:%02x", netif.hwaddr[0], netif.hwaddr[1], netif.hwaddr[2], + netif.hwaddr[3], netif.hwaddr[4], netif.hwaddr[5]); netif_set_default(&netif); diff --git a/Sming/Arch/Host/Components/lwip/Windows/host_lwip.c b/Sming/Arch/Host/Components/lwip/Windows/host_lwip.c index 521be8507b..4c9751d1df 100644 --- a/Sming/Arch/Host/Components/lwip/Windows/host_lwip.c +++ b/Sming/Arch/Host/Components/lwip/Windows/host_lwip.c @@ -84,7 +84,7 @@ static bool find_adapter(const struct lwip_param* param, struct net_config* netc pcap_if_t* alldevs; char errbuf[PCAP_ERRBUF_SIZE + 1]; if(pcap_findalldevs(&alldevs, errbuf) < 0) { - hostmsg("Error in pcap_findalldevs: %s", errbuf); + host_debug_e("Error in pcap_findalldevs: %s", errbuf); return false; } @@ -163,7 +163,7 @@ static bool find_adapter(const struct lwip_param* param, struct net_config* netc bool host_lwip_init(const struct lwip_param* param) { - hostmsg("%s", "Initialising LWIP"); + host_debug_i("%s", "Initialising LWIP"); if(!npcap_init()) { return false; @@ -172,17 +172,17 @@ bool host_lwip_init(const struct lwip_param* param) struct net_config netcfg = {0}; if(param->ipaddr != NULL && ip4addr_aton(param->ipaddr, &netcfg.ipaddr) != 1) { - hostmsg("Failed to parse IP address '%s'", param->ipaddr); + host_debug_e("Failed to parse IP address '%s'", param->ipaddr); return false; } if(param->netmask != NULL && ip4addr_aton(param->netmask, &netcfg.netmask) != 1) { - hostmsg("Failed to parse Network Mask '%s'", param->netmask); + host_debug_e("Failed to parse Network Mask '%s'", param->netmask); return false; } if(param->gateway != NULL && ip4addr_aton(param->gateway, &netcfg.gw) != 1) { - hostmsg("Failed to parse Gateway address '%s'", param->gateway); + host_debug_e("Failed to parse Gateway address '%s'", param->gateway); return false; } @@ -196,7 +196,7 @@ bool host_lwip_init(const struct lwip_param* param) ip4addr_ntoa_r(&netcfg.netmask, nm_str, sizeof(nm_str)); char gw_str[IP4ADDR_STRLEN_MAX]; ip4addr_ntoa_r(&netcfg.gw, gw_str, sizeof(gw_str)); - hostmsg("gateway = %s, netmask = %s; using ip = %s", gw_str, nm_str, ip_str); + host_debug_i("gateway = %s, netmask = %s; using ip = %s", gw_str, nm_str, ip_str); // Even though we're running as NO_SYS, stuff like crypt needs initialising sys_init(); @@ -206,8 +206,8 @@ bool host_lwip_init(const struct lwip_param* param) netif_add(&netif, &netcfg.ipaddr, &netcfg.netmask, &netcfg.gw, state, pcapif_init, ethernet_input); netif_set_default(&netif); - hostmsg("MAC: %02x:%02x:%02x:%02x:%02x:%02x", netif.hwaddr[0], netif.hwaddr[1], netif.hwaddr[2], netif.hwaddr[3], - netif.hwaddr[4], netif.hwaddr[5]); + host_debug_i("MAC: %02x:%02x:%02x:%02x:%02x:%02x", netif.hwaddr[0], netif.hwaddr[1], netif.hwaddr[2], + netif.hwaddr[3], netif.hwaddr[4], netif.hwaddr[5]); return true; } diff --git a/Sming/Arch/Host/Components/spi_flash/flashmem.cpp b/Sming/Arch/Host/Components/spi_flash/flashmem.cpp index 6fead07de7..ae479fbcba 100644 --- a/Sming/Arch/Host/Components/spi_flash/flashmem.cpp +++ b/Sming/Arch/Host/Components/spi_flash/flashmem.cpp @@ -40,7 +40,7 @@ constexpr uint32_t FLASHMEM_REAL_MASK{~FLASHMEM_REAL_BIT}; #define CHECK_RANGE(_addr, _size) \ if((_addr) + (_size) > flashFileSize) { \ - hostmsg("addr = 0x%08x, size = 0x%08x", _addr, _size); \ + host_debug_e("addr = 0x%08x, size = 0x%08x", _addr, _size); \ return false; \ } @@ -59,13 +59,13 @@ bool host_flashmem_init(FlashmemConfig& config) } if(!flashFile.open(flashFileName, IFS::File::Create | IFS::File::ReadWrite)) { - hostmsg("Error opening \"%s\"", flashFileName); + host_debug_e("Error opening \"%s\"", flashFileName); return false; } int res = flashFile.seek(0, SeekOrigin::End); if(res < 0) { - hostmsg("Error seeking \"%s\": %s", flashFileName, flashFile.getErrorString(res).c_str()); + host_debug_e("Error seeking \"%s\": %s", flashFileName, flashFile.getErrorString(res).c_str()); flashFile.close(); return false; } @@ -74,14 +74,14 @@ bool host_flashmem_init(FlashmemConfig& config) size_t size = config.createSize ?: flashFileSize; res = flashFile.seek(size, SeekOrigin::Start); if(res != int(size)) { - hostmsg("Error seeking beyond end of file \"%s\"", flashFileName); + host_debug_e("Error seeking beyond end of file \"%s\"", flashFileName); } else if(!flashFile.truncate(size)) { - hostmsg("Error truncating \"%s\" to %u bytes", flashFileName, size); + host_debug_e("Error truncating \"%s\" to %u bytes", flashFileName, size); } else { - hostmsg("Created blank \"%s\", %u bytes", flashFileName, size); + host_debug_i("Created blank \"%s\", %u bytes", flashFileName, size); } } else { - hostmsg("Opened \"%s\", size = 0x%08x", flashFileName, res); + host_debug_i("Opened \"%s\", size = 0x%08x", flashFileName, res); } flashFileSize = res; @@ -93,7 +93,7 @@ bool host_flashmem_init(FlashmemConfig& config) void host_flashmem_cleanup() { flashFile.close(); - hostmsg("Closed \"%s\"", flashFileName); + host_debug_i("Closed \"%s\"", flashFileName); } static int readFlashFile(uint32_t offset, void* buffer, size_t count) diff --git a/Sming/Arch/Host/Platform/StationImpl.cpp b/Sming/Arch/Host/Platform/StationImpl.cpp index caca7f7934..4128401682 100644 --- a/Sming/Arch/Host/Platform/StationImpl.cpp +++ b/Sming/Arch/Host/Platform/StationImpl.cpp @@ -124,10 +124,10 @@ void StationImpl::statusCallback(netif* nif) if(changed_flags & NETIF_FLAG_UP) { assert(currentAp != nullptr); if(nif->flags & NETIF_FLAG_UP) { - host_printf("IF_UP, AP: %s\n", currentAp->ssid); + host_debug_i("IF_UP, AP: %s", currentAp->ssid); wifiEventsImpl.stationConnected(*currentAp); } else { - host_printf("IF_DOWN, AP: %s\n", currentAp->ssid); + host_debug_i("IF_DOWN, AP: %s", currentAp->ssid); wifiEventsImpl.stationDisconnected(*currentAp, WIFI_DISCONNECT_REASON_CONNECTION_FAIL); } } @@ -138,12 +138,12 @@ void StationImpl::statusCallback(netif* nif) ipaddr = nif->ip_addr; netmask = nif->netmask; gateway = nif->gw; - host_printf("IP_CHANGE, ip: %s, netmask: %s, gateway: %s\n", ipaddr.toString().c_str(), - netmask.toString().c_str(), gateway.toString().c_str()); + host_debug_i("IP_CHANGE, ip: %s, netmask: %s, gateway: %s", ipaddr.toString().c_str(), + netmask.toString().c_str(), gateway.toString().c_str()); wifiEventsImpl.stationGotIp(ipaddr, netmask, gateway); } } else { - hostmsg("No IP address"); + host_debug_w("No IP address"); connectionStatus = eSCS_ConnectionFailed; } } diff --git a/Sming/Components/rboot/src/Arch/Host/rboot.cpp b/Sming/Components/rboot/src/Arch/Host/rboot.cpp index 3eec026938..a75031fb6f 100644 --- a/Sming/Components/rboot/src/Arch/Host/rboot.cpp +++ b/Sming/Components/rboot/src/Arch/Host/rboot.cpp @@ -19,7 +19,7 @@ static uint32_t SPIRead(uint32_t addr, void* outptr, uint32_t len) } #define SPIEraseSector(sector) flashmem_erase_sector(sector) -#define echof(fmt, ...) host_printf(fmt, ##__VA_ARGS__) +#define echof(fmt, ...) host_debug_i(fmt, ##__VA_ARGS__) #include @@ -33,10 +33,10 @@ void host_init_bootloader() // fresh install or old version? bool init = false; if(romconf.magic != BOOT_CONFIG_MAGIC) { - hostmsg("MAGIC mismatch"); + host_debug_w("MAGIC mismatch"); init = true; } else if(romconf.version != BOOT_CONFIG_VERSION) { - hostmsg("VERSION mismatch: %u found, current %u", romconf.version, BOOT_CONFIG_VERSION); + host_debug_w("VERSION mismatch: %u found, current %u", romconf.version, BOOT_CONFIG_VERSION); init = true; } @@ -54,13 +54,13 @@ void host_init_bootloader() } if(romconf.count == 0) { - hostmsg("ERROR! No App partitions found\r\n"); + host_debug_w("Note: No App partitions found\r\n"); return; } if(init || config_changed) { bool ok = rboot_set_config(&romconf); - hostmsg("Update rBoot config: %s", ok ? "OK" : "FAIL"); + host_debug_i("Update rBoot config: %s", ok ? "OK" : "FAIL"); } String addr; @@ -70,5 +70,5 @@ void host_init_bootloader() } addr += '#' + String(i) + ": 0x" + String(romconf.roms[i], 16); } - hostmsg("ROM count = %u, current = %u, %s", romconf.count, romconf.current_rom, addr.c_str()); + host_debug_i("ROM count = %u, current = %u, %s", romconf.count, romconf.current_rom, addr.c_str()); } diff --git a/samples/Basic_Utility/README.rst b/samples/Basic_Utility/README.rst index 613614d5ae..02827fb11d 100644 --- a/samples/Basic_Utility/README.rst +++ b/samples/Basic_Utility/README.rst @@ -15,6 +15,11 @@ To run the application directly, you can do this:: out/Host/debug/firmware/app --nonet command=testWebConstants -``--nonet`` is optional. Use ``--help`` to see available emulator options. +``--nonet`` is optional. + +You may find ``--debug=0`` useful to suppress all but host error messages. +Specify ``1`` to include warnings. + +Use ``--help`` to see available emulator options. See :envvar:`HOST_PARAMETERS` for further details.