内存布局图更新到09-21最新:任务栈预算含实测峰值与判定,RAM双区/Flash布局同步

This commit is contained in:
2026-09-21 05:10:01 +08:00
parent 80fc7ffaa5
commit 96855f6b6b
4 changed files with 266 additions and 194 deletions
+42 -26
View File
@@ -1,4 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 740 340" width="740" height="340" style="font-family:Consolas,'Courier New',monospace; font-size:12px; background:#fff"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 880 440" width="880" height="440" style="font-family:Consolas,'Courier New',monospace; font-size:12px; background:#fff">
<defs> <defs>
<style> <style>
.title { font-size:14px; font-weight:bold; } .title { font-size:14px; font-weight:bold; }
@@ -7,29 +7,45 @@
.bar-seg { stroke:#fff; stroke-width:0.5; } .bar-seg { stroke:#fff; stroke-width:0.5; }
</style> </style>
</defs> </defs>
<text x="370.0" y="24" text-anchor="middle" class="title">FreeRTOS 任务栈分配 (48KB 堆池)</text> <text x="440.0" y="22" text-anchor="middle" class="title">FreeRTOS 任务栈预算(48KB 堆,2026-09-21 已迁 CCM)</text>
<text x="180" y="54" class="legend-text" fill="#555">分配栈大小 (Bytes)</text> <text x="440.0" y="40" text-anchor="middle" class="legend-text" fill="#777">数据: 2026-09-21 @build + FTP 128KB 实测(data/stack_report_20260921.md)</text>
<text x="176" y="75.0" text-anchor="end" dominant-baseline="central" class="label" fill="#333">defaultTask</text> <text x="190" y="54" class="legend-text" fill="#555">浅色条 = 分配栈 深色条 = 最坏占用(max(静态最坏, 实测峰值)) 下方文字 = 实测余量/判定</text>
<rect class="bar-seg" x="180" y="60" width="65.0" height="30" fill="#2196F3" rx="3"/> <text x="186" y="72" text-anchor="end" dominant-baseline="central" class="label" fill="#333">defaultTask</text>
<text x="212.5" y="75.0" text-anchor="middle" dominant-baseline="central" class="label" fill="#fff">2048B (2.0KB)</text> <rect class="bar-seg" x="190" y="64" width="162.5" height="16" fill="#BBDEFB" rx="3"/>
<text x="176" y="109.0" text-anchor="end" dominant-baseline="central" class="label" fill="#333">netTask</text> <rect x="190" y="64" width="110.1" height="16" fill="#2196F3" rx="3"/>
<rect class="bar-seg" x="180" y="94" width="130.0" height="30" fill="#2196F3" rx="3"/> <text x="190" y="91" dominant-baseline="central" class="legend-text" fill="#333">配置 4096B | 实测峰值 2136B | 最坏 2776B | 余量 1320B (32%) <tspan fill="#2E7D32" font-weight="bold">PASS</tspan></text>
<text x="245.0" y="109.0" text-anchor="middle" dominant-baseline="central" class="label" fill="#fff">4096B (4.0KB)</text> <text x="186" y="112" text-anchor="end" dominant-baseline="central" class="label" fill="#333">netTask</text>
<text x="176" y="143.0" text-anchor="end" dominant-baseline="central" class="label" fill="#333">ftpTask</text> <rect class="bar-seg" x="190" y="104" width="162.5" height="16" fill="#BBDEFB" rx="3"/>
<rect class="bar-seg" x="180" y="128" width="130.0" height="30" fill="#2196F3" rx="3"/> <rect x="190" y="104" width="23.3" height="16" fill="#2196F3" rx="3"/>
<text x="245.0" y="143.0" text-anchor="middle" dominant-baseline="central" class="label" fill="#fff">4096B (4.0KB)</text> <text x="190" y="131" dominant-baseline="central" class="legend-text" fill="#333">配置 4096B | 实测峰值 588B | 最坏 588B | 余量 3508B (85%) <tspan fill="#2E7D32" font-weight="bold">PASS</tspan></text>
<text x="176" y="177.0" text-anchor="end" dominant-baseline="central" class="label" fill="#333">testTask</text> <text x="186" y="152" text-anchor="end" dominant-baseline="central" class="label" fill="#333">ftpTask</text>
<rect class="bar-seg" x="180" y="162" width="130.0" height="30" fill="#2196F3" rx="3"/> <rect class="bar-seg" x="190" y="144" width="162.5" height="16" fill="#BBDEFB" rx="3"/>
<text x="245.0" y="177.0" text-anchor="middle" dominant-baseline="central" class="label" fill="#fff">4096B (4.0KB)</text> <rect x="190" y="144" width="47.0" height="16" fill="#2196F3" rx="3"/>
<text x="176" y="211.0" text-anchor="end" dominant-baseline="central" class="label" fill="#333">uiTask</text> <text x="190" y="171" dominant-baseline="central" class="legend-text" fill="#333">配置 4096B | 实测峰值 1184B | 最坏 1184B | 余量 2912B (71%) <tspan fill="#2E7D32" font-weight="bold">PASS</tspan></text>
<rect class="bar-seg" x="180" y="196" width="520.0" height="30" fill="#2196F3" rx="3"/> <text x="186" y="192" text-anchor="end" dominant-baseline="central" class="label" fill="#333">testTask</text>
<text x="440.0" y="211.0" text-anchor="middle" dominant-baseline="central" class="label" fill="#fff">16384B (16.0KB)</text> <rect class="bar-seg" x="190" y="184" width="325.0" height="16" fill="#FFE0B2" rx="3"/>
<text x="176" y="245.0" text-anchor="end" dominant-baseline="central" class="label" fill="#333">timeSyncTask</text> <rect x="190" y="184" width="13.8" height="16" fill="#FF9800" rx="3"/>
<rect class="bar-seg" x="180" y="230" width="65.0" height="30" fill="#2196F3" rx="3"/> <text x="190" y="211" dominant-baseline="central" class="legend-text" fill="#333">配置 8192B | 实测峰值 348B | 最坏 348B | 余量 7844B (95%) <tspan fill="#2E7D32" font-weight="bold">PASS</tspan></text>
<text x="212.5" y="245.0" text-anchor="middle" dominant-baseline="central" class="label" fill="#fff">2048B (2.0KB)</text> <text x="186" y="232" text-anchor="end" dominant-baseline="central" class="label" fill="#333">uiTask</text>
<text x="180" y="268" class="label" fill="#555">堆总量: 49,152B (48KB) 任务栈合计: ~34304B (33.5KB) 空闲: ~13736B (13.4KB)</text> <rect class="bar-seg" x="190" y="224" width="650.0" height="16" fill="#FFE0B2" rx="3"/>
<rect x="180" y="286" width="10" height="10" fill="#2196F3" rx="2"/> <rect x="190" y="224" width="151.7" height="16" fill="#FF9800" rx="3"/>
<text x="194" y="294" class="legend-text" fill="#333">Normal 优先级</text> <text x="190" y="251" dominant-baseline="central" class="legend-text" fill="#333">配置 16384B | 实测峰值 3824B | 最坏 3824B | 余量 12560B (76%) <tspan fill="#2E7D32" font-weight="bold">PASS</tspan></text>
<rect x="310" y="286" width="10" height="10" fill="#FF9800" rx="2"/> <text x="186" y="272" text-anchor="end" dominant-baseline="central" class="label" fill="#333">timeSyncTask</text>
<text x="324" y="294" class="legend-text" fill="#333">BelowNormal 优先级</text> <rect class="bar-seg" x="190" y="264" width="81.2" height="16" fill="#BBDEFB" rx="3"/>
<rect x="190" y="264" width="16.7" height="16" fill="#2196F3" rx="3"/>
<text x="190" y="291" dominant-baseline="central" class="legend-text" fill="#333">配置 2048B | 实测峰值 420B | 最坏 420B | 余量 1628B (79%) <tspan fill="#2E7D32" font-weight="bold">PASS</tspan></text>
<text x="186" y="314" text-anchor="end" dominant-baseline="central" class="label" fill="#333">idle</text>
<rect class="bar-seg" x="190" y="308" width="20.3" height="12" fill="#90A4AE" rx="2"/>
<text x="214.3125" y="314" dominant-baseline="central" class="legend-text" fill="#333">512B(未实测)</text>
<text x="186" y="336" text-anchor="end" dominant-baseline="central" class="label" fill="#333">timer</text>
<rect class="bar-seg" x="190" y="330" width="40.6" height="12" fill="#90A4AE" rx="2"/>
<text x="234.625" y="336" dominant-baseline="central" class="legend-text" fill="#333">1024B(未实测)</text>
<text x="190" y="360" class="label" fill="#555">堆总量: 49152B (48KB, RW_CCM) 任务栈合计: 38912B (38.0KB) + 内核栈 1536B</text>
<text x="190" y="376" class="label" fill="#555">实测: free=8784B / min_ever=4848B(2026-09-21,含 FTP 负载) 判定: 6/6 PASS(余量 ≥ max(1024B, 配置×30%))</text>
<rect x="190" y="400" width="10" height="10" fill="#2196F3" rx="2"/>
<text x="204" y="408" class="legend-text" fill="#333">Normal 优先级</text>
<rect x="320" y="400" width="10" height="10" fill="#FF9800" rx="2"/>
<text x="334" y="408" class="legend-text" fill="#333">BelowNormal 优先级</text>
<rect x="480" y="400" width="10" height="10" fill="#90A4AE" rx="2"/>
<text x="494" y="408" class="legend-text" fill="#333">内核任务栈 (idle/timer)</text>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

+28 -25
View File
@@ -7,29 +7,32 @@
.bar-seg { stroke:#fff; stroke-width:0.5; } .bar-seg { stroke:#fff; stroke-width:0.5; }
</style> </style>
</defs> </defs>
<text x="410.0" y="24" text-anchor="middle" class="title">Flash (1MB) 使用布局</text> <text x="410.0" y="24" text-anchor="middle" class="title">Flash (1MB) 使用布局 — 2026-09-21 @build</text>
<rect class="bar-seg" x="60" y="50" width="155.2" height="40" fill="#2196F3" rx="2"/> <rect class="bar-seg" x="60" y="50" width="165.8" height="40" fill="#2196F3" rx="2"/>
<text x="137.6" y="70.0" text-anchor="middle" dominant-baseline="central" class="label" fill="#000">代码段 (Code) 214.8KB</text> <text x="142.9" y="70.0" text-anchor="middle" dominant-baseline="central" class="label" fill="#000">代码段 (Code) 229.5KB</text>
<rect class="bar-seg" x="215.24124145507812" y="50" width="8.1" height="40" fill="#4CAF50" rx="2"/> <rect class="bar-seg" x="225.8270263671875" y="50" width="9.8" height="40" fill="#4CAF50" rx="2"/>
<text x="227.4" y="70.0" text-anchor="start" dominant-baseline="central" class="legend-text" fill="#333">只读数据 (RO) 11.2KB</text> <text x="239.6" y="70.0" text-anchor="start" dominant-baseline="central" class="legend-text" fill="#333">只读数据 (RO) 13.5KB</text>
<rect class="bar-seg" x="223.35418701171875" y="50" width="576.3" height="40" fill="#E0E0E0" rx="2"/> <rect class="bar-seg" x="235.5828857421875" y="50" width="564.0" height="40" fill="#E0E0E0" rx="2"/>
<text x="511.5" y="70.0" text-anchor="middle" dominant-baseline="central" class="label" fill="#000">Flash 空闲 797.4KB</text> <text x="517.6" y="70.0" text-anchor="middle" dominant-baseline="central" class="label" fill="#000">Flash 空闲 780.4KB</text>
<text x="60" y="108" class="label" fill="#333">已用: 226.6KB (22.1%) 空闲: 797.4KB (77.9%) 总量: 1024KB</text> <text x="60" y="108" class="label" fill="#333">已用: 243.6KB (23.8%) 空闲: 780.4KB (76.2%) 总量: 1024KB</text>
<text x="60" y="124" class="label" fill="#555">代码段明细 (214.8KB)</text> <text x="60" y="124" class="label" fill="#555">代码段明细 (229.5KB)</text>
<rect class="bar-seg" x="60" y="130" width="233.3" height="24" fill="#4CAF50" rx="2"/> <rect class="bar-seg" x="60" y="130" width="308.6" height="24" fill="#4CAF50" rx="2"/>
<text x="176.7" y="142.0" text-anchor="middle" dominant-baseline="central" class="label" fill="#000">LVGL 库 67.7KB</text> <text x="214.3" y="142.0" text-anchor="middle" dominant-baseline="central" class="label" fill="#000">LVGL 库 95.7KB</text>
<rect class="bar-seg" x="293.34072807942687" y="130" width="143.1" height="24" fill="#2196F3" rx="2"/> <rect class="bar-seg" x="368.6272640610105" y="130" width="107.4" height="24" fill="#2196F3" rx="2"/>
<text x="364.9" y="142.0" text-anchor="middle" dominant-baseline="central" class="label" fill="#000">应用代码/UI 41.5KB</text> <text x="422.3" y="142.0" text-anchor="middle" dominant-baseline="central" class="label" fill="#000">应用代码/UI 33.3KB</text>
<rect class="bar-seg" x="436.44543041059023" y="130" width="14.2" height="24" fill="#795548" rx="2"/> <rect class="bar-seg" x="476.0484475010214" y="130" width="25.7" height="24" fill="#9C27B0" rx="2"/>
<text x="454.7" y="142.0" text-anchor="start" dominant-baseline="central" class="legend-text" fill="#333">C 库 (microlib) 4.1KB</text> <text x="505.7" y="142.0" text-anchor="start" dominant-baseline="central" class="legend-text" fill="#333">FatFS 8.0KB</text>
<rect class="bar-seg" x="450.6751645634069" y="130" width="38.8" height="24" fill="#9C27B0" rx="2"/> <rect class="bar-seg" x="501.7023015116438" y="130" width="15.7" height="24" fill="#FF9800" rx="2"/>
<text x="493.5" y="142.0" text-anchor="start" dominant-baseline="central" class="legend-text" fill="#333">FatFS + dhara 11.3KB</text> <text x="521.4" y="142.0" text-anchor="start" dominant-baseline="central" class="legend-text" fill="#333">dhara / FTL 4.9KB</text>
<rect class="bar-seg" x="489.49576317416444" y="130" width="29.5" height="24" fill="#F44336" rx="2"/> <rect class="bar-seg" x="517.3919038540107" y="130" width="50.4" height="24" fill="#607D8B" rx="2"/>
<text x="523.0" y="142.0" text-anchor="start" dominant-baseline="central" class="legend-text" fill="#333">CH395F 网络 8.6KB</text> <text x="542.6" y="136.0" text-anchor="middle" dominant-baseline="central" class="label" fill="#000">HAL 驱动</text>
<rect class="bar-seg" x="519.0182565370768" y="130" width="31.6" height="24" fill="#607D8B" rx="2"/> <text x="542.6" y="148.0" text-anchor="middle" dominant-baseline="central" class="label" fill="#000">15.6KB</text>
<text x="554.6" y="142.0" text-anchor="start" dominant-baseline="central" class="legend-text" fill="#333">HAL 驱动 9.2KB</text> <rect class="bar-seg" x="567.7800285986655" y="130" width="31.9" height="24" fill="#00BCD4" rx="2"/>
<rect class="bar-seg" x="550.6398879877805" y="130" width="14.3" height="24" fill="#00BCD4" rx="2"/> <text x="603.7" y="142.0" text-anchor="start" dominant-baseline="central" class="legend-text" fill="#333">FreeRTOS 内核 9.9KB</text>
<text x="568.9" y="142.0" text-anchor="start" dominant-baseline="central" class="legend-text" fill="#333">FreeRTOS 4.1KB</text> <rect class="bar-seg" x="599.6883085932182" y="130" width="8.6" height="24" fill="#F44336" rx="2"/>
<rect class="bar-seg" x="564.9032621740554" y="130" width="235.1" height="24" fill="#E0E0E0" rx="2"/> <text x="612.3" y="142.0" text-anchor="start" dominant-baseline="central" class="legend-text" fill="#333">CH395F 网络 2.7KB</text>
<text x="682.5" y="142.0" text-anchor="middle" dominant-baseline="central" class="label" fill="#000">其他 68.2KB</text> <rect class="bar-seg" x="608.3109764401472" y="130" width="13.3" height="24" fill="#795548" rx="2"/>
<text x="625.6" y="142.0" text-anchor="start" dominant-baseline="central" class="legend-text" fill="#333">C 库 (microlib) 4.1KB</text>
<rect class="bar-seg" x="621.6323369195153" y="130" width="178.4" height="24" fill="#E0E0E0" rx="2"/>
<text x="710.8" y="142.0" text-anchor="middle" dominant-baseline="central" class="label" fill="#000">其他 (长尾) 55.3KB</text>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

+47 -42
View File
@@ -1,4 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 820 320" width="820" height="320" style="font-family:Consolas,'Courier New',monospace; font-size:12px; background:#fff"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 820 360" width="820" height="360" style="font-family:Consolas,'Courier New',monospace; font-size:12px; background:#fff">
<defs> <defs>
<style> <style>
.title { font-size:14px; font-weight:bold; } .title { font-size:14px; font-weight:bold; }
@@ -7,45 +7,50 @@
.bar-seg { stroke:#fff; stroke-width:0.5; } .bar-seg { stroke:#fff; stroke-width:0.5; }
</style> </style>
</defs> </defs>
<text x="410.0" y="24" text-anchor="middle" class="title">SRAM (128KB) 使用布局</text> <text x="410.0" y="24" text-anchor="middle" class="title">SRAM (192KB) 使用布局 — 2026-09-21 @build</text>
<rect class="bar-seg" x="60" y="50" width="277.5" height="50" fill="#2196F3" rx="2"/> <text x="60" y="42" class="label" fill="#555">主 SRAM RW_IRAM1 @0x20000000(128KB,DMA 可达)</text>
<text x="198.8" y="75.0" text-anchor="middle" dominant-baseline="central" class="label" fill="#000">FreeRTOS 堆 (48KB heap_4)</text> <rect class="bar-seg" x="60" y="50" width="234.1" height="44" fill="#4CAF50" rx="2"/>
<rect class="bar-seg" x="337.5" y="50" width="231.2" height="50" fill="#4CAF50" rx="2"/> <text x="177.0" y="72.0" text-anchor="middle" dominant-baseline="central" class="label" fill="#000">LVGL</text>
<text x="453.1" y="75.0" text-anchor="middle" dominant-baseline="central" class="label" fill="#000">LVGL 内存池 (40KB)</text> <rect class="bar-seg" x="294.0728759765625" y="50" width="76.4" height="44" fill="#FF9800" rx="2"/>
<rect class="bar-seg" x="568.75" y="50" width="74.3" height="50" fill="#FF9800" rx="2"/> <text x="332.3" y="72.0" text-anchor="middle" dominant-baseline="central" class="label" fill="#000">UI</text>
<text x="605.9" y="69.0" text-anchor="middle" dominant-baseline="central" class="label" fill="#000">UI 帧缓冲</text> <rect class="bar-seg" x="370.47119140625" y="50" width="49.8" height="44" fill="#9C27B0" rx="2"/>
<text x="605.9" y="81.0" text-anchor="middle" dominant-baseline="central" class="label" fill="#000">(~13KB)</text> <rect class="bar-seg" x="420.2215576171875" y="50" width="30.1" height="44" fill="#8BC34A" rx="2"/>
<rect class="bar-seg" x="643.0368041992188" y="50" width="70.1" height="50" fill="#9C27B0" rx="2"/> <rect class="bar-seg" x="450.279541015625" y="50" width="28.3" height="44" fill="#00BCD4" rx="2"/>
<text x="678.1" y="69.0" text-anchor="middle" dominant-baseline="central" class="label" fill="#000">FTL / 存储</text> <rect class="bar-seg" x="478.5986328125" y="50" width="25.1" height="44" fill="#F44336" rx="2"/>
<text x="678.1" y="81.0" text-anchor="middle" dominant-baseline="central" class="label" fill="#000">(~11KB)</text> <rect class="bar-seg" x="503.6940002441406" y="50" width="7.2" height="44" fill="#607D8B" rx="2"/>
<rect class="bar-seg" x="713.1344604492188" y="50" width="40.1" height="50" fill="#F44336" rx="2"/> <rect class="bar-seg" x="510.9205627441406" y="50" width="5.8" height="44" fill="#795548" rx="2"/>
<text x="733.2" y="63.0" text-anchor="middle" dominant-baseline="central" class="label" fill="#000">网络 /</text> <rect class="bar-seg" x="516.7018127441406" y="50" width="6.5" height="44" fill="#9E9E9E" rx="2"/>
<text x="733.2" y="75.0" text-anchor="middle" dominant-baseline="central" class="label" fill="#000">CH395F</text> <rect class="bar-seg" x="523.22265625" y="50" width="276.8" height="44" fill="#E0E0E0" rx="2"/>
<text x="733.2" y="87.0" text-anchor="middle" dominant-baseline="central" class="label" fill="#000">(~7KB)</text> <text x="661.6" y="72.0" text-anchor="middle" dominant-baseline="central" class="label" fill="#000">free</text>
<rect class="bar-seg" x="753.2757568359375" y="50" width="17.1" height="50" fill="#00BCD4" rx="2"/> <text x="60" y="112" class="label" fill="#333">已用: 82048B (62.6%) 空闲: 49024B (37.4%) 总量: 128KB</text>
<text x="774.3" y="75.0" text-anchor="start" dominant-baseline="central" class="legend-text" fill="#333">内核 / CMSIS (~3KB)</text> <text x="60" y="136" class="label" fill="#555">CCM RW_CCM @0x10000000(64KB,仅 CPU 可达,DMA 不可达)</text>
<rect class="bar-seg" x="770.3485107421875" y="50" width="7.9" height="50" fill="#607D8B" rx="2"/> <rect class="bar-seg" x="60" y="144" width="277.7" height="44" fill="#2196F3" rx="2"/>
<text x="782.3" y="75.0" text-anchor="start" dominant-baseline="central" class="legend-text" fill="#333">HAL 驱动 (~1.4KB)</text> <text x="198.8" y="166.0" text-anchor="middle" dominant-baseline="central" class="label" fill="#000">heap</text>
<rect class="bar-seg" x="778.2525634765625" y="50" width="2.8" height="50" fill="#795548" rx="2"/> <rect class="bar-seg" x="337.6806640625" y="144" width="92.3" height="44" fill="#E0E0E0" rx="2"/>
<text x="785.1" y="75.0" text-anchor="start" dominant-baseline="central" class="legend-text" fill="#333">其他静态 (~0.5KB)</text> <text x="383.8" y="166.0" text-anchor="middle" dominant-baseline="central" class="label" fill="#000">free</text>
<rect class="bar-seg" x="781.0641479492188" y="50" width="33.7" height="50" fill="#E0E0E0" rx="2"/> <text x="60" y="206" class="label" fill="#333">已用: 49184B (75.0%) 空闲: 16352B (25.0%) 总量: 64KB</text>
<rect x="60" y="130" width="12" height="12" fill="#2196F3" rx="2"/> <rect x="60" y="226" width="12" height="12" fill="#4CAF50" rx="2"/>
<text x="76" y="140" class="legend-text" fill="#333">FreeRTOS 堆 (48KB heap_4): 48.0KB (37.5%)</text> <text x="76" y="236" class="legend-text" fill="#333">主SRAM LVGL: 40.5KB (31.6%)</text>
<rect x="60" y="146" width="12" height="12" fill="#4CAF50" rx="2"/> <rect x="60" y="242" width="12" height="12" fill="#FF9800" rx="2"/>
<text x="76" y="156" class="legend-text" fill="#333">LVGL 内存池 (40KB): 40.0KB (31.2%)</text> <text x="76" y="252" class="legend-text" fill="#333">主SRAM UI: 13.2KB (10.3%)</text>
<rect x="60" y="162" width="12" height="12" fill="#FF9800" rx="2"/> <rect x="60" y="258" width="12" height="12" fill="#9C27B0" rx="2"/>
<text x="76" y="172" class="legend-text" fill="#333">UI 帧缓冲 (~13KB): 12.8KB (10.0%)</text> <text x="76" y="268" class="legend-text" fill="#333">主SRAM FTL/BBT: 8.6KB (6.7%)</text>
<rect x="60" y="178" width="12" height="12" fill="#9C27B0" rx="2"/> <rect x="60" y="274" width="12" height="12" fill="#8BC34A" rx="2"/>
<text x="76" y="188" class="legend-text" fill="#333">FTL / 存储 (~11KB): 12.1KB (9.5%)</text> <text x="76" y="284" class="legend-text" fill="#333">主SRAM lftpd: 5.2KB (4.1%)</text>
<rect x="60" y="194" width="12" height="12" fill="#F44336" rx="2"/> <rect x="60" y="290" width="12" height="12" fill="#00BCD4" rx="2"/>
<text x="76" y="204" class="legend-text" fill="#333">网络 / CH395F (~7KB): 6.9KB (5.4%)</text> <text x="76" y="300" class="legend-text" fill="#333">主SRAM CMSIS: 4.9KB (3.8%)</text>
<rect x="60" y="210" width="12" height="12" fill="#00BCD4" rx="2"/> <rect x="420" y="226" width="12" height="12" fill="#F44336" rx="2"/>
<text x="76" y="220" class="legend-text" fill="#333">内核 / CMSIS (~3KB): 3.0KB (2.3%)</text> <text x="436" y="236" class="legend-text" fill="#333">主SRAM NET: 4.3KB (3.4%)</text>
<rect x="60" y="226" width="12" height="12" fill="#607D8B" rx="2"/> <rect x="420" y="242" width="12" height="12" fill="#607D8B" rx="2"/>
<text x="76" y="236" class="legend-text" fill="#333">HAL 驱动 (~1.4KB): 1.4KB (1.1%)</text> <text x="436" y="252" class="legend-text" fill="#333">主SRAM HAL: 1.2KB (1.0%)</text>
<rect x="60" y="242" width="12" height="12" fill="#795548" rx="2"/> <rect x="420" y="258" width="12" height="12" fill="#795548" rx="2"/>
<text x="76" y="252" class="legend-text" fill="#333">其他静态 (~0.5KB): 0.5KB (0.4%)</text> <text x="436" y="268" class="legend-text" fill="#333">主SRAM C stack: 1.0KB (0.8%)</text>
<rect x="60" y="258" width="12" height="12" fill="#E0E0E0" rx="2"/> <rect x="420" y="274" width="12" height="12" fill="#9E9E9E" rx="2"/>
<text x="76" y="268" class="legend-text" fill="#333">SRAM 空闲: 5.8KB (4.6%)</text> <text x="436" y="284" class="legend-text" fill="#333">主SRAM other: 1.1KB (0.9%)</text>
<text x="60" y="120" class="label" fill="#333">已用: 122.2KB (95.4%) 空闲: 5.8KB (4.6%) 总量: 128KB</text> <rect x="420" y="290" width="12" height="12" fill="#E0E0E0" rx="2"/>
<text x="436" y="300" class="legend-text" fill="#333">主SRAM free: 47.9KB (37.4%)</text>
<rect x="60" y="322" width="12" height="12" fill="#2196F3" rx="2"/>
<text x="76" y="332" class="legend-text" fill="#333">CCM heap: 48.0KB (75.0%)</text>
<rect x="60" y="338" width="12" height="12" fill="#E0E0E0" rx="2"/>
<text x="76" y="348" class="legend-text" fill="#333">CCM free: 16.0KB (25.0%)</text>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

+149 -101
View File
@@ -17,28 +17,38 @@ import sys
# Diagram data # Diagram data
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# ── RAM breakdown (128KB = 131,072 B) ──────────────────────────────────────── # ── RAM breakdown (2026-09-21 @build, map Grand Totals; data/ram_report_20260921.md) ──
SRAM_TOTAL = 131072 # Region 1: main SRAM RW_IRAM1 @0x20000000 (128KB = 131,072 B, DMA-reachable)
SRAM_USED = 125104 SRAM1_TOTAL = 131072
SRAM_FREE = SRAM_TOTAL - SRAM_USED SRAM1_USED = 82048
SRAM1_FREE = SRAM1_TOTAL - SRAM1_USED
# Region 2: CCM RW_CCM @0x10000000 (64KB = 65,536 B, CPU only, DMA NOT reachable)
CCM_TOTAL = 65536
CCM_USED = 49184
CCM_FREE = CCM_TOTAL - CCM_USED
RAM_CATEGORIES = [ RAM1_CATEGORIES = [
("FreeRTOS 堆\n(48KB heap_4)", 49152, "#2196F3"), ("LVGL", 41460, "#4CAF50"),
("LVGL 内存池\n(40KB)", 40960, "#4CAF50"), ("UI", 13532, "#FF9800"),
("UI 帧缓冲\n(~13KB)", 13158, "#FF9800"), ("FTL/BBT", 8812, "#9C27B0"),
("FTL / 存储\n(~11KB)", 12416, "#9C27B0"), ("lftpd", 5324, "#8BC34A"),
("网络 / CH395F\n(~7KB)", 7110, "#F44336"), ("CMSIS", 5016, "#00BCD4"),
("内核 / CMSIS\n(~3KB)", 3024, "#00BCD4"), ("NET", 4445, "#F44336"),
("HAL 驱动\n(~1.4KB)", 1400, "#607D8B"), ("HAL", 1280, "#607D8B"),
("其他静态\n(~0.5KB)", 498, "#795548"), ("C stack", 1024, "#795548"),
("SRAM 空闲", SRAM_FREE, "#E0E0E0"), ("other", 1155, "#9E9E9E"),
("free", SRAM1_FREE, "#E0E0E0"),
]
RAM2_CATEGORIES = [
("heap", 49184, "#2196F3"),
("free", CCM_FREE, "#E0E0E0"),
] ]
# ── Flash breakdown (1MB = 1,048,576 B) ───────────────────────────────────── # ── Flash breakdown (1MB = 1,048,576 B; 2026-09-21 @build) ──────────────────
FLASH_TOTAL = 1048576 FLASH_TOTAL = 1048576
FLASH_CODE = 219976 FLASH_CODE = 234976
FLASH_RO = 11496 FLASH_RO = 13824
FLASH_RW = 528 FLASH_RW = 632
FLASH_USED = FLASH_CODE + FLASH_RO + FLASH_RW FLASH_USED = FLASH_CODE + FLASH_RO + FLASH_RW
FLASH_FREE = FLASH_TOTAL - FLASH_USED FLASH_FREE = FLASH_TOTAL - FLASH_USED
@@ -49,30 +59,37 @@ FLASH_CATEGORIES = [
("Flash 空闲", FLASH_FREE, "#E0E0E0"), ("Flash 空闲", FLASH_FREE, "#E0E0E0"),
] ]
# Flash code sub-breakdown (top categories from map analysis) # Flash code sub-breakdown (2026-09-21; top items from data/ram_report_20260921.md,
# long-tail .o objects below the report's top-44 threshold are counted in "其他")
FLASH_CODE_SUB = [ FLASH_CODE_SUB = [
("LVGL 库", 69364, "#4CAF50"), ("LVGL 库", 98000, "#4CAF50"),
("应用代码/UI", 42540, "#2196F3"), ("应用代码/UI", 34110, "#2196F3"),
("FatFS", 8146, "#9C27B0"),
("dhara / FTL", 4982, "#FF9800"),
("HAL 驱动", 16000, "#607D8B"),
("FreeRTOS 内核", 10132, "#00BCD4"),
("CH395F 网络", 2738, "#F44336"),
("C 库 (microlib)", 4230, "#795548"), ("C 库 (microlib)", 4230, "#795548"),
("FatFS + dhara", 11540, "#9C27B0"), ("其他 (长尾)", 56638, "#E0E0E0"), # remainder
("CH395F 网络", 8776, "#F44336"),
("HAL 驱动", 9400, "#607D8B"),
("FreeRTOS", 4240, "#00BCD4"),
("其他", 69886, "#E0E0E0"), # remainder
] ]
# ── Task stack budgets ───────────────────────────────────────────────────── # ── Task stack budgets (2026-09-21 @build + FTP 128KB 实测; data/stack_report_20260921.md) ──
# (name, cfg, prio, worst, peak_used, margin, margin_pct, verdict, desc)
# worst = max(静态最坏深度, 实测峰值); margin = cfg - worst
TASK_STACKS = [ TASK_STACKS = [
("defaultTask", 2048, "Normal", "FatFS 挂载、LED"), ("defaultTask", 4096, "Normal", 2776, 2136, 1320, 32, "PASS", "FatFS 挂载/探针 + 配置引擎 + syslog + 栈探针"),
("netTask", 4096, "Normal", "CH395F 轮询、消息处理"), ("netTask", 4096, "Normal", 588, 588, 3508, 85, "PASS", "CH395F 轮询、消息处理"),
("ftpTask", 4096, "Normal", "lftpd FTP 服务"), ("ftpTask", 4096, "Normal", 1184, 1184, 2912, 71, "PASS", "lftpd FTP 服务(大缓冲已静态化)"),
("testTask", 4096, "BelowNormal", "测试套件"), ("testTask", 8192, "BelowNormal", 348, 348, 7844, 95, "PASS", "测试套件(产品构建空转)"),
("uiTask", 16384, "BelowNormal", "LVGL UI 主循环"), ("uiTask", 16384, "BelowNormal", 3824, 3824, 12560, 76, "PASS", "LVGL UI 主循环"),
("timeSyncTask", 2048, "Normal", "TCP 时间同步"), ("timeSyncTask", 2048, "Normal", 420, 420, 1628, 79, "PASS", "TCP 时间同步"),
] ]
KERNEL_STACKS = [("idle", 512), ("timer", 1024)] # 128/256 words
HEAP_FREE = 49152 - (2048+4096+4096+4096+16384+2048+512+1024+80*8+448+24) HEAP_TOTAL = 49152 # configTOTAL_HEAP_SIZE(位于 RW_CCM)
# = 49152 - 35304 = 13848 (approximate; stacks+TCBs+queue+eventgroup) HEAP_FREE = 8784 # 2026-09-21 实测(含 FTP 负载)
HEAP_MIN_EVER = 4848
TOTAL_STACKS = sum(t[1] for t in TASK_STACKS) # 38,912
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# SVG helpers # SVG helpers
@@ -148,44 +165,69 @@ def _draw_bar_segment(x, y, w, h, fill, label_inside, label_outside="",
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
def gen_ram_svg(): def gen_ram_svg():
"""内存布局_RAM.svg — horizontal stacked bar with legend.""" """内存布局_RAM.svg — 两条堆叠条:主 SRAM(DMA 可达)+ CCM(仅 CPU)。"""
W, H = 820, 320 W, H = 820, 360
BAR_X, BAR_Y, BAR_H = 60, 50, 50 BAR_X, BAR_H = 60, 44
SCALE = (W - 80) / SRAM_TOTAL SCALE = (W - 80) / SRAM1_TOTAL # 128KB 占满宽;CCM (64KB) 占半宽
svg = svg_header(W, H) svg = svg_header(W, H)
svg += f'<text x="{W/2}" y="24" text-anchor="middle" class="title">SRAM (128KB) 使用布局</text>\n' svg += f'<text x="{W/2}" y="24" text-anchor="middle" class="title">SRAM (192KB) 使用布局 — 2026-09-21 @build</text>\n'
# Region 1: 主 SRAM
y1 = 50
svg += f'<text x="{BAR_X}" y="{y1-8}" class="label" fill="#555">主 SRAM RW_IRAM1 @0x20000000(128KB,DMA 可达)</text>\n'
x = BAR_X x = BAR_X
for label, size, color in RAM_CATEGORIES: for label, size, color in RAM1_CATEGORIES:
w = size * SCALE w = size * SCALE
if w < 1: if w < 1:
continue continue
inside = label.replace("\n", " ") if w > 30 else "" inside = label if w > _text_width(label) + 10 else ""
outside = "" if w > 30 else label.replace("\n", " ") svg += _draw_bar_segment(x, y1, w, BAR_H, color, inside, "")
svg += _draw_bar_segment(x, BAR_Y, w, BAR_H, color, inside, outside)
x += w x += w
svg += f'<text x="{BAR_X}" y="{y1+BAR_H+18}" class="label" fill="#333">'
# Legend svg += f'已用: {SRAM1_USED}B ({SRAM1_USED/SRAM1_TOTAL*100:.1f}%)'
lx, ly = 60, 130 svg += f' 空闲: {SRAM1_FREE}B ({SRAM1_FREE/SRAM1_TOTAL*100:.1f}%)'
for label, size, color in RAM_CATEGORIES:
pct = size / SRAM_TOTAL * 100
kb = size / 1024
display = label.replace("\n", " ")
svg += f' <rect x="{lx}" y="{ly}" width="12" height="12" fill="{color}" rx="2"/>\n'
svg += f' <text x="{lx+16}" y="{ly+10}" class="legend-text" fill="#333">'
svg += f'{display}: {kb:.1f}KB ({pct:.1f}%)</text>\n'
ly += 16
if ly > H - 20:
lx += 260
ly = 130
# Summary text
svg += f'<text x="{BAR_X}" y="{BAR_Y+BAR_H+20}" class="label" fill="#333">'
svg += f'已用: {SRAM_USED/1024:.1f}KB ({SRAM_USED/SRAM_TOTAL*100:.1f}%)'
svg += f' 空闲: {SRAM_FREE/1024:.1f}KB ({SRAM_FREE/SRAM_TOTAL*100:.1f}%)'
svg += f' 总量: 128KB</text>\n' svg += f' 总量: 128KB</text>\n'
# Region 2: CCM
y2 = y1 + BAR_H + 50
svg += f'<text x="{BAR_X}" y="{y2-8}" class="label" fill="#555">CCM RW_CCM @0x10000000(64KB,仅 CPU 可达,DMA 不可达)</text>\n'
x = BAR_X
for label, size, color in RAM2_CATEGORIES:
w = size * SCALE
if w < 1:
continue
inside = label if w > _text_width(label) + 10 else ""
svg += _draw_bar_segment(x, y2, w, BAR_H, color, inside, "")
x += w
svg += f'<text x="{BAR_X}" y="{y2+BAR_H+18}" class="label" fill="#333">'
svg += f'已用: {CCM_USED}B ({CCM_USED/CCM_TOTAL*100:.1f}%)'
svg += f' 空闲: {CCM_FREE}B ({CCM_FREE/CCM_TOTAL*100:.1f}%)'
svg += f' 总量: 64KB</text>\n'
# Legend(主 SRAM 两列 + CCM 两行)
ly = y2 + BAR_H + 40
lx = 60
half = (len(RAM1_CATEGORIES) + 1) // 2
for i, (label, size, color) in enumerate(RAM1_CATEGORIES):
pct = size / SRAM1_TOTAL * 100
kb = size / 1024
if i >= half:
lx2 = 420
else:
lx2 = 60
yy = 226 + (i % half) * 16
svg += f' <rect x="{lx2}" y="{yy}" width="12" height="12" fill="{color}" rx="2"/>\n'
svg += f' <text x="{lx2+16}" y="{yy+10}" class="legend-text" fill="#333">'
svg += f'主SRAM {label}: {kb:.1f}KB ({pct:.1f}%)</text>\n'
for i, (label, size, color) in enumerate(RAM2_CATEGORIES):
pct = size / CCM_TOTAL * 100
kb = size / 1024
yy = 322 + i * 16
svg += f' <rect x="{60}" y="{yy}" width="12" height="12" fill="{color}" rx="2"/>\n'
svg += f' <text x="{76}" y="{yy+10}" class="legend-text" fill="#333">'
svg += f'CCM {label}: {kb:.1f}KB ({pct:.1f}%)</text>\n'
svg += svg_footer() svg += svg_footer()
return svg return svg
@@ -197,7 +239,7 @@ def gen_flash_svg():
SCALE = (W - 80) / FLASH_TOTAL SCALE = (W - 80) / FLASH_TOTAL
svg = svg_header(W, H) svg = svg_header(W, H)
svg += f'<text x="{W/2}" y="24" text-anchor="middle" class="title">Flash (1MB) 使用布局</text>\n' svg += f'<text x="{W/2}" y="24" text-anchor="middle" class="title">Flash (1MB) 使用布局 — 2026-09-21 @build</text>\n'
x = BAR_X x = BAR_X
for label, size, color in FLASH_CATEGORIES: for label, size, color in FLASH_CATEGORIES:
@@ -234,57 +276,63 @@ def gen_flash_svg():
def gen_taskstack_svg(): def gen_taskstack_svg():
"""任务栈预算.svg — horizontal bars for each task's stack allocation.""" """任务栈预算.svg — 每任务:分配栈条 + 最坏占用叠加条 + 实测余量/判定。"""
W, H = 740, 340 W, H = 880, 440
BAR_X = 180 BAR_X = 190
MAX_STACK = 16384 MAX_STACK = 16384
SCALE = (W - BAR_X - 40) / MAX_STACK SCALE = (W - BAR_X - 40) / MAX_STACK
ROW_H = 30 Y_START = 64
Y_START = 60 ROW_PITCH = 40
BAR_H = 16
svg = svg_header(W, H) svg = svg_header(W, H)
svg += f'<text x="{W/2}" y="24" text-anchor="middle" class="title">FreeRTOS 任务栈分配 (48KB 堆池)</text>\n' svg += f'<text x="{W/2}" y="22" text-anchor="middle" class="title">FreeRTOS 任务栈预算(48KB 堆,2026-09-21 已迁 CCM)</text>\n'
svg += f'<text x="{W/2}" y="40" text-anchor="middle" class="legend-text" fill="#777">数据: 2026-09-21 @build + FTP 128KB 实测(data/stack_report_20260921.md)</text>\n'
# Header svg += f'<text x="{BAR_X}" y="{Y_START-10}" class="legend-text" fill="#555">浅色条 = 分配栈 深色条 = 最坏占用(max(静态最坏, 实测峰值)) 下方文字 = 实测余量/判定</text>\n'
svg += f'<text x="{BAR_X}" y="{Y_START-6}" class="legend-text" fill="#555">分配栈大小 (Bytes)</text>\n'
y = Y_START y = Y_START
for name, stack, prio, desc in TASK_STACKS: for name, cfg, prio, worst, peak, margin, pct, verdict, desc in TASK_STACKS:
w = stack * SCALE w = cfg * SCALE
color = "#2196F3" if "Normal" in prio else "#FF9800" wc = worst * SCALE
dark = "#2196F3" if prio == "Normal" else "#FF9800"
light = "#BBDEFB" if prio == "Normal" else "#FFE0B2"
vc = "#2E7D32" if verdict == "PASS" else "#C62828"
# Task name label # 任务名(左侧)
svg += f' <text x="{BAR_X-4}" y="{y+ROW_H/2}" text-anchor="end" ' svg += f' <text x="{BAR_X-4}" y="{y+8}" text-anchor="end" dominant-baseline="central" class="label" fill="#333">{name}</text>\n'
svg += f'dominant-baseline="central" class="label" fill="#333">{name}</text>\n' # 分配栈条(浅色)+ 最坏占用叠加条(深色)
svg += f' <rect class="bar-seg" x="{BAR_X}" y="{y}" width="{w:.1f}" height="{BAR_H}" fill="{light}" rx="3"/>\n'
svg += f' <rect x="{BAR_X}" y="{y}" width="{wc:.1f}" height="{BAR_H}" fill="{dark}" rx="3"/>\n'
# 数据行
svg += f' <text x="{BAR_X}" y="{y+BAR_H+11}" dominant-baseline="central" class="legend-text" fill="#333">'
svg += f'配置 {cfg}B | 实测峰值 {peak}B | 最坏 {worst}B | 余量 {margin}B ({pct}%) '
svg += f'<tspan fill="{vc}" font-weight="bold">{verdict}</tspan></text>\n'
y += ROW_PITCH
# Bar # 内核任务(静态小栈,未取句柄实测)
svg += f' <rect class="bar-seg" x="{BAR_X}" y="{y}" width="{w:.1f}" height="{ROW_H}" '
svg += f'fill="{color}" rx="3"/>\n'
# Size inside bar
if w > 60:
svg += f' <text x="{BAR_X+w/2}" y="{y+ROW_H/2}" text-anchor="middle" '
svg += f'dominant-baseline="central" class="label" fill="#fff">{stack}B ({stack/1024:.1f}KB)</text>\n'
else:
svg += f' <text x="{BAR_X+w+4}" y="{y+ROW_H/2}" text-anchor="start" '
svg += f'dominant-baseline="central" class="legend-text" fill="#333">{stack}B</text>\n'
y += ROW_H + 4
# FreeRTOS heap summary
total_stacks = sum(s for _, s, _, _ in TASK_STACKS) + 512 + 1024 # app + idle + timer
y += 4 y += 4
svg += f'<text x="{BAR_X}" y="{y}" class="label" fill="#555">' for name, stack in KERNEL_STACKS:
svg += f'堆总量: 49,152B (48KB) ' w = max(stack * SCALE, 2)
svg += f'任务栈合计: ~{total_stacks}B ({total_stacks/1024:.1f}KB) ' svg += f' <text x="{BAR_X-4}" y="{y+6}" text-anchor="end" dominant-baseline="central" class="label" fill="#333">{name}</text>\n'
svg += f'空闲: ~{HEAP_FREE}B ({HEAP_FREE/1024:.1f}KB)</text>\n' svg += f' <rect class="bar-seg" x="{BAR_X}" y="{y}" width="{w:.1f}" height="12" fill="#90A4AE" rx="2"/>\n'
svg += f' <text x="{BAR_X + w + 4}" y="{y+6}" dominant-baseline="central" class="legend-text" fill="#333">{stack}B(未实测)</text>\n'
y += 22
# Color legend # 堆汇总(实测值)
y += 18 y += 8
svg += f'<text x="{BAR_X}" y="{y}" class="label" fill="#555">'
svg += f'堆总量: {HEAP_TOTAL}B (48KB, RW_CCM) 任务栈合计: {TOTAL_STACKS}B ({TOTAL_STACKS/1024:.1f}KB) + 内核栈 {512+1024}B</text>\n'
y += 16
svg += f'<text x="{BAR_X}" y="{y}" class="label" fill="#555">'
svg += f'实测: free={HEAP_FREE}B / min_ever={HEAP_MIN_EVER}B(2026-09-21,含 FTP 负载) 判定: 6/6 PASS(余量 ≥ max(1024B, 配置×30%))</text>\n'
y += 24
# 颜色图例
svg += f' <rect x="{BAR_X}" y="{y}" width="10" height="10" fill="#2196F3" rx="2"/>\n' svg += f' <rect x="{BAR_X}" y="{y}" width="10" height="10" fill="#2196F3" rx="2"/>\n'
svg += f' <text x="{BAR_X+14}" y="{y+8}" class="legend-text" fill="#333">Normal 优先级</text>\n' svg += f' <text x="{BAR_X+14}" y="{y+8}" class="legend-text" fill="#333">Normal 优先级</text>\n'
svg += f' <rect x="{BAR_X+130}" y="{y}" width="10" height="10" fill="#FF9800" rx="2"/>\n' svg += f' <rect x="{BAR_X+130}" y="{y}" width="10" height="10" fill="#FF9800" rx="2"/>\n'
svg += f' <text x="{BAR_X+144}" y="{y+8}" class="legend-text" fill="#333">BelowNormal 优先级</text>\n' svg += f' <text x="{BAR_X+144}" y="{y+8}" class="legend-text" fill="#333">BelowNormal 优先级</text>\n'
svg += f' <rect x="{BAR_X+290}" y="{y}" width="10" height="10" fill="#90A4AE" rx="2"/>\n'
svg += f' <text x="{BAR_X+304}" y="{y+8}" class="legend-text" fill="#333">内核任务栈 (idle/timer)</text>\n'
svg += svg_footer() svg += svg_footer()
return svg return svg