diff --git a/.gitignore b/.gitignore index 0b790b9e5..75fd65295 100644 --- a/.gitignore +++ b/.gitignore @@ -5,13 +5,11 @@ **/out/ **/out.gcc/ **/out.clang/ - **/temp/ # files **/gccLinksClangWarning.txt **/.mxproject - internal/receiver/trices.raw +**/.DS_store -.DS_Store diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 9135448c7..56501af8c 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -87,7 +87,7 @@ archives: # If format is `binary`, no archives are created and the binaries are instead # uploaded directly. # Default is `tar.gz`. - format: tar.gz + formats: tar.gz # use zip for windows archives # Can be used to change the archive formats for specific GOOSs. @@ -95,7 +95,7 @@ archives: # Default is empty. format_overrides: - goos: windows - format: zip + formats: [ 'zip' ] # Additional files/globs you want to add to the archive. # Defaults are any files matching `LICENCE*`, `LICENSE*`, # `README*` and `CHANGELOG*` (case-insensitive). @@ -117,15 +117,8 @@ archives: - src/* - third_party/* - _test/* - - AUTHORS.md - - CHANGELOG.md - - CODE_OF_CONDUCT.md - - CONTRIBUTING.md - - LICENSE.md - - README.md - - GoInfos.txt - - clang-format.sh - - FilesAndFolders.md + - ./*.sh + - ./*.md - go.mod - go.sum - super-linter.report/* diff --git a/.vscode/launch.json b/.vscode/launch.json index 6d78cbcbf..44530ace9 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,6 +1,19 @@ { "version": "0.2.0", "configurations": [ + { + "name": "generate", + "type": "go", + "request": "launch", + "mode": "auto", + "program": "${workspaceFolder}/cmd/trice", + "env": {}, + "args": ["generate", + "-c", + "-idlist", "${workspaceFolder}/examples/G0B1_inst/til.json", + "-verbose" + ] + }, { "name": "TCP4", "type": "go", @@ -93,7 +106,7 @@ ] }, { - "name": "-p com46", + "name": "G0B1 -p com6", "type": "go", "request": "launch", "mode": "auto", @@ -101,11 +114,12 @@ "env": {}, "args": ["log", "-port", - "com46", + "com6", + "-pf=cobs", "-i", - "${workspaceFolder}/../NAi2Development/SD3Modbus/SD3-HW-RevA-Lib_Modbus-STM32-HAL-FreeRTOS/til.json", + "${workspaceFolder}/examples/G0B1_inst/til.json", "-li", - "${workspaceFolder}/../NAi2Development/SD3Modbus/SD3-HW-RevA-Lib_Modbus-STM32-HAL-FreeRTOS/li.json" + "${workspaceFolder}/examples/G0B1_inst/li.json" ] }, { diff --git a/.vscode/settings.json b/.vscode/settings.json index d82de92c7..496fbf15c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -16,7 +16,8 @@ "NUCLEO", "Strg", "tcobs", - "TREX" + "TREX", + "vscode" ], "C_Cpp.errorSquiggles": "Disabled", "cmake.configureOnOpen": false, diff --git a/CHANGELOG.md b/CHANGELOG.md index 56e1cdce7..6b614c18d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,118 +1,152 @@ - +
Trice (Reference) + – License: MIT. Trice is an open-source C logging and tracing library +providing printf-like macros. At runtime it replaces format strings with + 16-bit IDs, keeping the firmware image under 1 KB and achieving very +low execution overhead. Trace data is COBS-encoded and sent via UART or +SEGGER RTT; a Go-based host tool decodes the IDs back into +human-readable messages. Trice is safe to use in interrupts (ISR-safe) +and supports log levels via channels with optional colored output on the + host.
+Embedded Logger (elog) + – License: MIT. Elog offloads all format strings from the firmware +binary: at runtime only an identifier plus parameters are stored in RAM, + while the actual format strings reside separately and are excluded from + the final image. A host-side decoder then reconstructs the original +messages. This approach minimizes both Flash and RAM usage and supports +custom transports for log retrieval.
+defmt (Rust)
+ – License: MIT/Apache 2.0 dual license. Defmt (“deferred formatting”)
+is a Rust-native framework that shifts all string formatting to the
+host. Macros like defmt::info!()
emit binary-encoded logs (e.g., over RTT), and a host tool (often via probe-run
)
+ uses the ELF symbols to decode them. It achieves very low footprint
+(e.g., ~1.6 KB Flash for panic logging vs. ~13.8 KB with printf) and
+supports log levels. Limitation: only available for Rust targets.
NanoLog (C++11) + – License: Apache 2.0. Originally designed for high-performance server +environments, NanoLog uses compile-time extraction of log metadata so +that at runtime only an ID and variables are emitted. Offline tools then + format the messages. It demonstrates nanosecond-scale latencies (≈7 ns) + and tens of millions of logs per second, but is more suited to powerful + systems rather than constrained MCUs.
+McuLog (McuOnEclipse) – License: BSD 3-Clause. A C-based logger offering traditional printf formatting with log levels (TRACE
to FATAL
).
+ Supports multiple outputs simultaneously (UART with ANSI colors, SEGGER
+ RTT, or logging to an SD card via FAT). Around 6 KB Flash footprint and
+ moderate CPU overhead, but no external tools required beyond a host RTT
+ viewer.
uLog (RD Poor)
+ – License: MIT. A minimalist single-file C logger inspired by Log4c:
+configurable log levels, pluggable back ends via callbacks (UART,
+memory, etc.), and full compile-time disabling of all logging code. It
+formats messages on the target (using vsnprintf
) but remains extremely lightweight and portable.
SEGGER SystemView + – Free from SEGGER (closed source). Includes a small C library (~2 KB +ROM, 600 B RAM) that streams timed events and user logs via SEGGER RTT +to a PC GUI. It visualizes interrupts, task switches, and custom events +with cycle-level timestamps, with under 1% CPU overhead at 10 000 +events/s on a Cortex-M4 @ 200 MHz.
+Percepio Tracealyzer (with TraceRecorder) + – Commercial (~1 700 USD/user). Provides deep trace and log analysis +for RTOS or bare-metal systems. The TraceRecorder library (2–3 KB +footprint) captures events and logs in a ring buffer, supporting:
+Printf mode (on-target formatting)
+Offloaded formatting (parameters sent to PC for formatting)
+Compact mode (ID + parameters, with format strings read from the ELF file).
+Compact mode reduces overhead by ~99.8% (from 1.9 ms to ≈3 µs per log)
+and is safe in IRQs. The PC software offers timeline views, CPU load,
+heap usage, and correlates logs with RTOS events.
Memfault + – SaaS platform (firmware SDK free; cloud subscription per device). Its + “Compact Log” feature replaces format strings with IDs on the device +(4.5 KB Flash, 1.5 KB RAM) and uploads logs or crash dumps to the cloud, + where they’re reconstructed using debug symbols. Achieves ~88% data +reduction and offloads CPU formatting. Includes log levels, +time-stamping, remote configuration, and OTA updates. Ideal for fleet +monitoring but requires Internet connectivity and a cloud service.
+Other Hardware-Native Approaches:
+ARM Keil Event Recorder (proprietary in MDK) uses ITM/SWO for low-overhead event tracing.
+ARM ITM/SWO can stream trace data with minimal CPU impact; custom protocols can shift formatting off the target.
+Name | License / Type | Logging Approach | Overhead & Resources | Output Channels | Special Features |
---|---|---|---|---|---|
Trice | Open Source (MIT) | Compile-time IDs, host formatting | < 1 KB Flash; very low runtime overhead | UART, RTT (COBS binary) | ISR-safe; Go host tool; log levels via channels; colored host output |
Embedded Logger | Open Source (MIT) | Offloaded format strings; ID + args in target | Minimal Flash/RAM (strings excluded) | Custom transport | Very low resource use; host decoder required |
defmt (Rust) | Open Source (MIT/Apache) | Deferred formatting; host decoding | ~ 1.6 KB Flash vs. ~13.8 KB with printf; low runtime impact | RTT, other transports | Rust only; integrated in probe-run ; active ecosystem |
NanoLog (C++11) | Open Source (Apache 2.0) | Compile-time extraction; offline formatting | ≈ 7 ns latency; tens of millions log entries/s | File post-processing | Ultra-high throughput; less common in MCU contexts |
McuLog | Open Source (BSD 3-Clause) | On-target printf formatting with log levels | ~ 6 KB Flash; moderate CPU load | UART (ANSI color), RTT, FAT file | Multiple concurrent outputs; easy integration; configurable |
uLog | Open Source (MIT) | On-target vsnprintf ; hierarchical log levels | Tiny footprint; overhead only when enabled | Any via callbacks | Single file; fully disable logging via compiler flag |
SystemView (SEGGER) | Closed Source (free with J-Link) | Binary events + optional user logs | ~ 2 KB ROM, 600 B RAM; < 1% CPU @10 k events/s | RTT (J-Link) | Real-time timeline; multi-thread tracing; precise timestamps |
Tracealyzer | Commercial (~ 1 700 USD/user) | On-target or host formatting (compact mode: ID + args) | ~ 2–3 KB Flash; 3 µs/log (compact) vs. 1.9 ms UART | RTT, ITM, USB, RAM buffer | Extensive visualization; RTOS support; higher cost |
Memfault | Commercial SaaS (SDK free; cloud paid) | Compact log (ID + args) with cloud decoding | ~ 4.5 KB Flash; 1.5 KB RAM; ~ 88% data reduction | UART, network upload | Fleet monitoring; cloud dashboard; requires connectivity |
this is my doc index.html
diff --git a/examples/F030R8_inst/2024-07-22.png b/docs/ref/2024-07-22.png similarity index 100% rename from examples/F030R8_inst/2024-07-22.png rename to docs/ref/2024-07-22.png diff --git a/docs/ref/2024-12-05_G0B1_inst_normalSpeed.png b/docs/ref/2024-12-05_G0B1_inst_normalSpeed.png new file mode 100644 index 000000000..d3b73ef34 Binary files /dev/null and b/docs/ref/2024-12-05_G0B1_inst_normalSpeed.png differ diff --git a/docs/ref/2024-12-05_G0B1_inst_slowSpeed.png b/docs/ref/2024-12-05_G0B1_inst_slowSpeed.png new file mode 100644 index 000000000..1c32b5121 Binary files /dev/null and b/docs/ref/2024-12-05_G0B1_inst_slowSpeed.png differ diff --git a/docs/ref/2024-12-05_L432_inst_maxSpeed.png b/docs/ref/2024-12-05_L432_inst_maxSpeed.png new file mode 100644 index 000000000..216adbdb4 Binary files /dev/null and b/docs/ref/2024-12-05_L432_inst_maxSpeed.png differ diff --git a/examples/Animation.gif b/docs/ref/Animation.gif similarity index 100% rename from examples/Animation.gif rename to docs/ref/Animation.gif diff --git a/docs/ref/ColorAlternatives.PNG b/docs/ref/ColorAlternatives.PNG index 0c4675f96..287927974 100644 Binary files a/docs/ref/ColorAlternatives.PNG and b/docs/ref/ColorAlternatives.PNG differ diff --git a/docs/ref/G0B1AliasExample.png b/docs/ref/G0B1AliasExample.png new file mode 100644 index 000000000..7ad378232 Binary files /dev/null and b/docs/ref/G0B1AliasExample.png differ diff --git a/examples/G0B1_inst/2024-07-22.png b/docs/ref/G0B1_2024-07-22.png similarity index 100% rename from examples/G0B1_inst/2024-07-22.png rename to docs/ref/G0B1_2024-07-22.png diff --git a/examples/F030R8_inst/IMG_20240722.jpg b/docs/ref/IMG_20240722.jpg similarity index 100% rename from examples/F030R8_inst/IMG_20240722.jpg rename to docs/ref/IMG_20240722.jpg diff --git a/docs/ref/JLinkConfig0.png b/docs/ref/JLinkConfig0.png new file mode 100644 index 000000000..4c805017b Binary files /dev/null and b/docs/ref/JLinkConfig0.png differ diff --git a/docs/ref/Nucleo_STM32L432KC.jpg b/docs/ref/Nucleo_STM32L432KC.jpg new file mode 100644 index 000000000..150171756 Binary files /dev/null and b/docs/ref/Nucleo_STM32L432KC.jpg differ diff --git a/docs/ref/generateColors.png b/docs/ref/generateColors.png new file mode 100644 index 000000000..c18ea7e8c Binary files /dev/null and b/docs/ref/generateColors.png differ diff --git a/docs/ref/triceHello.png b/docs/ref/triceHello.png new file mode 100644 index 000000000..ba4267300 Binary files /dev/null and b/docs/ref/triceHello.png differ diff --git a/docs/ref/triceHelloOKnoID.png b/docs/ref/triceHelloOKnoID.png new file mode 100644 index 000000000..cb2e26ef0 Binary files /dev/null and b/docs/ref/triceHelloOKnoID.png differ diff --git a/docs/ref/triceHelloOKwithID.png b/docs/ref/triceHelloOKwithID.png new file mode 100644 index 000000000..04b71334c Binary files /dev/null and b/docs/ref/triceHelloOKwithID.png differ diff --git a/examples/F030R8_gen/ReadMe.md b/examples/F030R8_gen/ReadMe.md deleted file mode 100644 index 3b01ab9dd..000000000 --- a/examples/F030R8_gen/ReadMe.md +++ /dev/null @@ -1,80 +0,0 @@ -# Example F030R8_gen - -This is a STMCubeMX generated project without TRICE instrumentation for easy compare with [../F030R8_inst](../F030R8_inst) to figure out the needed changes to set up trice. - -## Steps performed as potential guide - -- Install STM32CubeMX to `C:\SMT32SubeMX`. -- Select NUCLEO-F030R8 board. -- Initialize with default values. -- Optionally set system clock to 32MHz for faster target timestamps. -- Optionally set UART baud rate to 115200. -- Mantadory set UART data bits including parity to 9. -- Enable USART2 global interrupt. -- In Project Manager *Project*: - - Set toolchain folder location to `E:\repos\trice\examples\vsCode_NucleoF030R8_generated\`. - - Set project name to `vsCode_NucleoF030R8_generated`. - - Set toolchain / IDE to `Makefile`. -- In Project Manager *Code Generator*: - - Select "Copy only the necessary library files". -- In Project Manager *Advanced Settings*: - - In Driver Selector change all to *LL*. -- Generate Code -- Start vsCode and open generated with it. -- Start a terminal and type `make`. The output should be similar to: - -```bash -PS E:\repos\trice\examples\vsCode_NucleoF030R8_generated> make -j8 -mkdir build -arm-none-eabi-gcc -c -mcpu=cortex-m0 -mthumb -DUSE_FULL_LL_DRIVER -DHSE_VALUE=8000000 -DHSE_STARTUP_TIMEOUT=100 -DLSE_STARTUP_TIMEOUT=5000 -DLSE_VALUE=32768 -DHSI_VALUE=8000000 -DLSI_VALUE=40000 -DVDD_VALUE=3300 -DPREFETCH_ENABLE=1 -DINSTRUCTION_CACHE_ENABLE=0 -DDATA_CACHE_ENABLE=0 -DSTM32F030x8 -ICore/Inc -IDrivers/STM32F0xx_HAL_Driver/Inc -IDrivers/CMSIS/Device/ST/STM32F0xx/Include -IDrivers/CMSIS/Include -Og -Wall -fdata-sections -ffunction-sections -g -gdwarf-2 -MMD -MP -MF"build/main.d" -Wa,-a,-ad,-alms=build/main.lst Core/Src/main.c -o build/main.o - -... - -arm-none-eabi-gcc -x assembler-with-cpp -c -mcpu=cortex-m0 -mthumb -DUSE_FULL_LL_DRIVER -DHSE_VALUE=8000000 -DHSE_STARTUP_TIMEOUT=100 -DLSE_STARTUP_TIMEOUT=5000 -DLSE_VALUE=32768 -DHSI_VALUE=8000000 -DLSI_VALUE=40000 -DVDD_VALUE=3300 -DPREFETCH_ENABLE=1 -DINSTRUCTION_CACHE_ENABLE=0 -DDATA_CACHE_ENABLE=0 -DSTM32F030x8 -ICore/Inc -IDrivers/STM32F0xx_HAL_Driver/Inc -IDrivers/CMSIS/Device/ST/STM32F0xx/Include -IDrivers/CMSIS/Include -Og -Wall -fdata-sections -ffunction-sections -g -gdwarf-2 -MMD -MP -MF"build/startup_stm32f030x8.d" startup_stm32f030x8.s -o build/startup_stm32f030x8.o -arm-none-eabi-gcc build/main.o build/stm32f0xx_it.o build/stm32f0xx_ll_gpio.o build/stm32f0xx_ll_pwr.o build/stm32f0xx_ll_exti.o build/stm32f0xx_ll_usart.o build/stm32f0xx_ll_rcc.o build/stm32f0xx_ll_dma.o build/stm32f0xx_ll_utils.o build/system_stm32f0xx.o build/sysmem.o build/syscalls.o build/startup_stm32f030x8.o -mcpu=cortex-m0 -mthumb -specs=nano.specs -TSTM32F030R8Tx_FLASH.ld -lc -lm -lnosys -Wl,-Map=build/vsCode_NucleoF030R8_generated.map,--cref -Wl,--gc-sections -o build/vsCode_NucleoF030R8_generated.elf -C:/bin/ArmGNUToolchain/bin/../lib/gcc/arm-none-eabi/13.2.1/../../../../arm-none-eabi/bin/ld.exe: warning: build/vsCode_NucleoF030R8_generated.elf has a LOAD segment with RWX permissions -arm-none-eabi-size build/vsCode_NucleoF030R8_generated.elf - text data bss dec hex filename - 2428 12 1564 4004 fa4 build/vsCode_NucleoF030R8_generated.elf -arm-none-eabi-objcopy -O ihex build/vsCode_NucleoF030R8_generated.elf build/vsCode_NucleoF030R8_generated.hex -arm-none-eabi-objcopy -O binary -S build/vsCode_NucleoF030R8_generated.elf build/vsCode_NucleoF030R8_generated.bin -PS E:\repos\trice\examples\vsCode_NucleoF030R8_generated> -``` - -- If not done yet, install vsCode Cortex-Debug extension. -- Create a launch.json file inside the *.vscode* subfolder and edit it to get - -```json -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "Cortex Debug", - "cwd": "${workspaceFolder}", - "executable": "./build/vsCode_NucleoF030R8_generated.elf", - "request": "launch", - "type": "cortex-debug", - "runToEntryPoint": "main", - "servertype": "jlink", - "device": "STM32F030R8", - "svdFile": "./STM32F030R8.svd", - "runToMain": true - - } - ] -} -``` - -- Download [STM32G030.svd](https://github.com/fullyautomated/st-svd/blob/main/STM32G030.svd) or get it from the STMCubeIDE installation folder if you want to install this Eclipse IDE as well, but IMHO you do not need it. -- You may need to extract and install the STM32 USB drivers *"trice/third_party/st.com/en.stsw-link009_v2.0.2.zip"*. You can get them also from the STM site directly. -- It is assumed, that you converted the OB ST-Link to an OB J-Link already. See *trice/docs/TRICEOverRTT.md#J-Linkoption* for details. - -- Press the Debug-Button or "CTRL+SHIFT+D" and start debugging. - -## Hint - -- During the code generation, the CubeMX tool did not copy `syscalls.c` and `sysmem.c` but added them to the Makefile. This seems to be a STM32CubeMX "feature". - - You do not need these files for the example project, but you can add them manually to avoid some warnings. diff --git a/examples/F030R8_inst/Core/Inc/SEGGER_RTT_Conf.h b/examples/F030R8_inst/Core/Inc/SEGGER_RTT_Conf.h deleted file mode 100644 index 12941094c..000000000 --- a/examples/F030R8_inst/Core/Inc/SEGGER_RTT_Conf.h +++ /dev/null @@ -1,429 +0,0 @@ -/********************************************************************* -* SEGGER Microcontroller GmbH * -* The Embedded Experts * -********************************************************************** -* * -* (c) 1995 - 2021 SEGGER Microcontroller GmbH * -* * -* www.segger.com Support: support@segger.com * -* * -********************************************************************** -* * -* SEGGER RTT * Real Time Transfer for embedded targets * -* * -********************************************************************** -* * -* All rights reserved. * -* * -* SEGGER strongly recommends to not make any changes * -* to or modify the source code of this software in order to stay * -* compatible with the RTT protocol and J-Link. * -* * -* Redistribution and use in source and binary forms, with or * -* without modification, are permitted provided that the following * -* condition is met: * -* * -* o Redistributions of source code must retain the above copyright * -* notice, this condition and the following disclaimer. * -* * -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * -* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * -* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * -* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * -* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR * -* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * -* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * -* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * -* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * -* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * -* DAMAGE. * -* * -********************************************************************** -* * -* RTT version: 7.60g * -* * -********************************************************************** - ----------------------------END-OF-HEADER------------------------------ -File : SEGGER_RTT_Conf.h -Purpose : Implementation of SEGGER real-time transfer (RTT) which - allows real-time communication on targets which support - debugger memory accesses while the CPU is running. -Revision: $Rev: 24316 $ - -*/ - -#ifndef SEGGER_RTT_CONF_H -#define SEGGER_RTT_CONF_H - -#ifdef __IAR_SYSTEMS_ICC__ - #include