Skip to content

Commit b1848c9

Browse files
committed
Added additional details for flags used in Lab3
1 parent ee8a028 commit b1848c9

1 file changed

Lines changed: 54 additions & 1 deletion

File tree

Lab3/README.MD

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,57 @@ make run
2121
* To see Renode GUI terminal for logs and output:
2222
```
2323
renode renode/stm32.resc
24-
```
24+
```
25+
26+
---
27+
28+
# STM32 Build & Coverage Configuration Report
29+
This document outlines the flags and tools used to compile, simulate, and audit the `Lab3.elf` project.
30+
31+
## 1. Compiler Flags (CFLAGS)
32+
The `CFLAGS` define how the C source code is translated into machine instructions for the target microcontroller.
33+
34+
| Flag | Category | Description |
35+
| :--- | :--- | :--- |
36+
| `-mcpu=cortex-m4` | **Architecture** | Target the ARM Cortex-M4 processor and its specific instruction set. |
37+
| `-mthumb` | **Architecture** | Use the Thumb-2 instruction set (required for Cortex-M). |
38+
| `-O0` | **Optimization** | Disable optimizations. Ensures assembly matches C source 1-to-1 for accurate debugging and coverage. |
39+
| `-g` | **Debugging** | Include debug symbols for mapping memory addresses back to source code lines. |
40+
| `-ffreestanding` | **Environment** | Standard libraries may not be available; assumes no OS environment. |
41+
| `-fno-builtin` | **Environment** | Prevents compiler from replacing your functions with internal optimized versions. |
42+
| `-I<dir>` | **Search Path** | Adds `./src`, `./unity`, and `./stm32f4` to the header include search path. |
43+
| `-Wall -Wextra` | **Quality** | Enables almost all compiler warnings to catch potential bugs early. |
44+
45+
---
46+
47+
## 2. Linker Flags (LDFLAGS)
48+
The `LDFLAGS` define how object files are joined and where they are placed in the chip's memory.
49+
50+
| Flag | Description |
51+
| :--- | :--- |
52+
| `-T stm32f4/linker.ld` | Uses the Linker Script to define the memory map (Flash vs. RAM boundaries). |
53+
| `-nostartfiles` | Excludes standard C startup files; uses the project's custom `startup.c` instead. |
54+
| `-Wl,--gc-sections` | Tells the linker to "Garbage Collect" (remove) unused functions to save Flash space. |
55+
56+
---
57+
58+
## 3. Automated Coverage Reporting
59+
To view coverage results both in the terminal and on the GitHub Actions summary page, the following `Makefile` target is used.
60+
61+
### Makefile Target
62+
```makefile
63+
coverage:
64+
@# Run the Renode tracer reader and pipe output to AWK
65+
@python3 /opt/renode/tools/execution_tracer/execution_tracer_reader.py \
66+
coverage ./coverage/trace.bin \
67+
--binary Lab3.elf \
68+
--sources ./src/checksum.c | \
69+
awk -F',' '/DA:/ {found++; if($$2>0) hit++} END { \
70+
percent = (found > 0) ? (hit/found)*100 : 0; \
71+
msg = sprintf("\nTotal Coverage: %.2f%% (%d/%d lines hit)\n", percent, hit, found); \
72+
print msg; \
73+
if (ENVIRON["GITHUB_STEP_SUMMARY"] != "") { \
74+
printf "### 📊 Coverage Report\n- **Status:** %s\n- **Percentage:** %.2f%%\n- **Details:** %d out of %d lines executed\n", \
75+
(percent == 100 ? "✅ Pass" : "⚠️ Partial"), percent, hit, found >> ENVIRON["GITHUB_STEP_SUMMARY"]; \
76+
} \
77+
}'

0 commit comments

Comments
 (0)