Toggle navigation
首页
问答
文章
积分商城
专家
专区
更多专区...
文档中心
返回主站
搜索
提问
会员
中心
登录
注册
RT-Thread Studio
为啥rtthread studio 的map文件没有Image component sizes
发布于 2023-12-01 16:58:09 浏览:286
订阅该版
标准rtthread怎么查看各类文件的ZI-data。
查看更多
1
个回答
默认排序
按发布时间排序
聚散无由
2023-12-01
https://jswyll.com/
# 根据map文件统计各个文件的bss段占用空间 ## 问题分析 1. 一个常见的链接脚本的BSS段信息如下: ```linkscript .bss : { /* 对当前地址4字节对齐 */ . = ALIGN(4); /* BSS段起始地址 */ _sbss = .; *(.bss) *(.bss.*) *(COMMON) /* 对当前地址4字节对齐 */ . = ALIGN(4); /* BSS端结束地址 */ _ebss = . ; *(.bss.init) } > RAM ``` 2. 产生的map文件关于bss段信息如下: ``` .bss 0x20000b08 0x8f8 load address 0x0800dc48 0x20000b08 . = ALIGN (0x4) 0x20000b08 _sbss = . *(.bss) .bss 0x20000b08 0x1c XXX/lib/gcc/arm-none-eabi/5.4.1/armv7e-m/fpu/crtbegin.o *(.bss.*) .bss.rt_tick 0x20000b24 0x4 ./rt-thread/src/clock.o .bss.idle 0x20000b28 0x80 ./rt-thread/src/idle.o .bss.rt_thread_stack 0x20000ba8 0x100 ./rt-thread/src/idle.o .bss.idle_hook_list 0x20000ca8 0x10 ./rt-thread/src/idle.o .bss.rt_interrupt_enter_hook 0x20000cb8 0x4 ./rt-thread/src/irq.o .bss.rt_interrupt_leave_hook 0x20000cbc 0x4 ./rt-thread/src/irq.o .bss.rt_interrupt_nest 0x20000cc0 0x1 ./rt-thread/src/irq.o 0x20000cc0 rt_interrupt_nest *fill* 0x20000cc1 0x3 .bss.__rt_errno 0x20000cc4 0x4 ./rt-thread/src/kservice.o .bss._console_device 0x20000cc8 0x4 ./rt-thread/src/kservice.o .bss.rt_log_buf.5951 0x20000ccc 0x100 ./rt-thread/src/kservice.o .bss.rt_malloc_hook 0x20000dcc 0x4 ./rt-thread/src/mem.o .bss.rt_free_hook 0x20000dd0 0x4 ./rt-thread/src/mem.o .bss.heap_ptr 0x20000dd4 0x4 ./rt-thread/src/mem.o .bss.heap_end 0x20000dd8 0x4 ./rt-thread/src/mem.o .bss.lfree 0x20000ddc 0x4 ./rt-thread/src/mem.o .bss.heap_sem 0x20000de0 0x20 ./rt-thread/src/mem.o .bss.mem_size_aligned 0x20000e00 0x4 ./rt-thread/src/mem.o .bss.used_mem 0x20000e04 0x4 ./rt-thread/src/mem.o .bss.max_mem 0x20000e08 0x4 ./rt-thread/src/mem.o .bss.rt_object_attach_hook 0x20000e0c 0x4 ./rt-thread/src/object.o .bss.rt_object_detach_hook 0x20000e10 0x4 ./rt-thread/src/object.o .bss.rt_scheduler_lock_nest 0x20000e14 0x2 ./rt-thread/src/scheduler.o *fill* 0x20000e16 0x2 .bss.rt_current_thread 0x20000e18 0x4 ./rt-thread/src/scheduler.o 0x20000e18 rt_current_thread .bss.rt_scheduler_hook 0x20000e1c 0x4 ./rt-thread/src/scheduler.o .bss.rt_thread_suspend_hook 0x20000e20 0x4 ./rt-thread/src/thread.o .bss.rt_thread_resume_hook 0x20000e24 0x4 ./rt-thread/src/thread.o .bss.rt_thread_inited_hook 0x20000e28 0x4 ./rt-thread/src/thread.o .bss.rt_timer_list 0x20000e2c 0x8 ./rt-thread/src/timer.o .bss.rt_soft_timer_list 0x20000e34 0x8 ./rt-thread/src/timer.o .bss.timer_thread 0x20000e3c 0x80 ./rt-thread/src/timer.o .bss.timer_thread_stack 0x20000ebc 0x200 ./rt-thread/src/timer.o .bss.rt_timer_enter_hook 0x200010bc 0x4 ./rt-thread/src/timer.o .bss.rt_timer_exit_hook 0x200010c0 0x4 ./rt-thread/src/timer.o .bss.random_nr.5750 0x200010c4 0x4 ./rt-thread/src/timer.o .bss.rt_exception_hook 0x200010c8 0x4 ./rt-thread/libcpu/arm/cortex-m4/cpuport.o .bss._syscall_table_begin 0x200010cc 0x4 ./rt-thread/components/finsh/shell.o 0x200010cc _syscall_table_begin .bss._syscall_table_end 0x200010d0 0x4 ./rt-thread/components/finsh/shell.o 0x200010d0 _syscall_table_end .bss._sysvar_table_begin 0x200010d4 0x4 ./rt-thread/components/finsh/shell.o 0x200010d4 _sysvar_table_begin .bss._sysvar_table_end 0x200010d8 0x4 ./rt-thread/components/finsh/shell.o 0x200010d8 _sysvar_table_end .bss.finsh_prompt_custom 0x200010dc 0x4 ./rt-thread/components/finsh/shell.o .bss.finsh_prompt.7213 0x200010e0 0x101 ./rt-thread/components/finsh/shell.o *fill* 0x200011e1 0x3 .bss.already_output.6118 0x200011e4 0x4 ./rt-thread/components/drivers/serial/serial.o .bss._hw_pin 0x200011e8 0x44 ./rt-thread/components/drivers/misc/pin.o .bss.pin_irq_enable_mask 0x2000122c 0x4 ./drivers/drv_gpio.o .bss.uart_obj 0x20001230 0x9c ./drivers/drv_usart.o *(COMMON) COMMON 0x200012cc 0x4 ./rt-thread/src/kservice.o 0x200012cc rt_assert_hook COMMON 0x200012d0 0xc ./rt-thread/src/object.o 0x200012d0 rt_object_put_hook 0x200012d4 rt_object_take_hook 0x200012d8 rt_object_trytake_hook COMMON 0x200012dc 0x110 ./rt-thread/src/scheduler.o 0x200012dc rt_thread_priority_table 0x200013dc rt_current_priority 0x200013e0 rt_thread_ready_priority_group 0x200013e4 rt_thread_defunct COMMON 0x200013ec 0xc ./rt-thread/libcpu/arm/cortex-m4/cpuport.o 0x200013ec rt_interrupt_to_thread 0x200013f0 rt_interrupt_from_thread 0x200013f4 rt_thread_switch_interrupt_flag COMMON 0x200013f8 0x4 ./rt-thread/components/finsh/shell.o 0x200013f8 shell ``` 可以看到,规则是: - `.bss 变量地址 变量大小 变量所在文件` - `.bss.变量名 变量地址 变量大小 变量所在文件` - `*fill* 变量地址 变量大小 变量所在文件` - `COMMON 变量地址 变量大小 变量所在文件` ## 解决方案 ### 方式一 你可以在VS Code安装插件: ``` 名称: GNU Linker Map files ID: trond-snekvik.gnu-mapfiles 说明: Syntax highlighting and symbol listing for GNU linker .map files 版本: 1.1.0 发布者: Trond Snekvik VS Marketplace 链接: https://marketplace.visualstudio.com/items?itemName=trond-snekvik.gnu-mapfiles ``` 用VS Code打开map文件,结合大纲视图面板和高亮效果手动查看, ### 方式二 这是一个用python实现的示例代码,主要分为以下几个步骤: 1. 打开map文件,读取文件内容 2. 遍历文件内容,根据正则表达式匹配出BSS段信息 3. 统计每个文件BSS段的大小,并将结果存储到bss_file_info字典中 4. 打印结果 ```python # -*- coding: utf-8 -*- """ 统计BSS段信息 """ import re # MAP文件路径 MAP_FILAPATH = 'Debug/rtthread.map' # hex正则表达式 HEX_PATTERN = r'0x[0-9a-fA-F]+' # 每个文件的BSS段大小信息,其中key为文件名,value为BSS段的总字节数 bss_file_info = {} with open(MAP_FILAPATH, 'r') as f: # 以空格分割整个文件的字符串 strings = f.read().split() # print('strings: ', strings) bss_var_count = 0 for i in range(len(strings)): if re.match(r'^(\.bss|(\.bss\.[_0-9a-zA-Z\.]+)|(COMMON))|(\.bss\.init)$', strings[i]) and \ re.match(HEX_PATTERN, strings[i+1]) and len(strings[i+1]) == 10 and\ re.match(HEX_PATTERN, strings[i+2]) and \ (strings[i+3].endswith('.o') or '.a' in strings[i+3]): bss_var_count += 1 bss_var = strings[i] bss_addr = strings[i+1] bss_size = strings[i+2] bss_file = strings[i+3] # 计算每个文件的BSS段的大小 bss_size_in_bytes = int(bss_size, 16) if bss_size_in_bytes != 0: # print('%10s %10s %-80s %s' %(bss_addr, bss_size, bss_var, bss_file)) if bss_file not in bss_file_info: bss_file_info[bss_file] = bss_size_in_bytes else: bss_file_info[bss_file] += bss_size_in_bytes # 将字典转换为列表 list_example = list(bss_file_info.items()) # 根据值(int类型)的大小对键(字符串)进行排序 sorted_list = sorted(list_example, key=lambda x: x[1], reverse=True) # 将排序后的列表重新转换回字典 bss_file_info_sorted = dict(sorted_list) # 打印排序后的结果 total_bss_size = 0 for k, v in bss_file_info_sorted.items(): print('%10d bytes: %s' %(v, k)) total_bss_size += v print('known total bss size: %d bytes' %total_bss_size) ``` 这个代码没有统计填充部分`*fill*`的大小。输出如下: ``` 16200 bytes: build/test/gcov/gcov_public.o 4096 bytes: build/bsp/m_printf.o 2048 bytes: build/test/src/test_settings.o 1533 bytes: build/app/app_uart.o 1061 bytes: build/rt-thread/bsp/rt_kprintf.o 589 bytes: build/bsp/m_settings.o 497 bytes: build/app/app_protocol.o 409 bytes: build/test/src/test_all.o 392 bytes: build/rt-thread/src/idle.o 332 bytes: build/backtrace/cm_backtrace.o 282 bytes: build/rt-thread/src/scheduler.o 232 bytes: build/app/app_errno.o 212 bytes: build/app/app_main.o 195 bytes: build/app/app_flash.o 148 bytes: build/test/unity/unity.o 130 bytes: build/rt-thread/components/libc/pthreads/pthread.o 112 bytes: build/app/app_settings.o 108 bytes: build/app/app_msg.o 68 bytes: build/Core/Src/usart.o 64 bytes: build/rt-thread/src/mem.o 64 bytes: build/rt-thread/components/libc/pthreads/pthread_tls.o 44 bytes: build/bsp/m_button.o 40 bytes: build/bsp/m_event.o 38 bytes: build/rt-thread/components/libc/pthreads/semaphore.o 36 bytes: build/rt-thread/components/libc/pthreads/mqueue.o 32 bytes: build/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.o 28 bytes: d:/gcc-arm-none-eabi-4_9-2015q3-20150921/bin/../lib/gcc/arm-none-eabi/4.9.3/armv7e-m/fpu/crtbegin.o 23 bytes: build/components/cJSON/cJSON.o 20 bytes: build/rt-thread/src/object.o 20 bytes: build/rt-thread/src/timer.o 16 bytes: build/app/app_crc.o 16 bytes: build/rt-thread/libcpu/cpuport.o 12 bytes: d:/gcc-arm-none-eabi-4_9-2015q3-20150921/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/arm 12 bytes: build/rt-thread/src/thread.o 12 bytes: build/test/src/test_protocol.o 12 bytes: build/Core/Src/iwdg.o 9 bytes: build/rt-thread/src/irq.o 8 bytes: build/rt-thread/components/libc/time/clock_time.o 8 bytes: build/rt-thread/src/kservice.o 8 bytes: d:/gcc-arm-none-eabi-4_9-2015q3-20150921/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/arm 4 bytes: build/rt-thread/src/clock.o 4 bytes: d:/gcc-arm-none-eabi-4_9-2015q3-20150921/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/arm 4 bytes: build/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.o 4 bytes: d:/gcc-arm-none-eabi-4_9-2015q3-20150921/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/arm 2 bytes: build/rt-thread/components/libc/pthreads/pthread_cond.o 2 bytes: build/rt-thread/components/libc/pthreads/pthread_mutex.o known total bss size: 29186 bytes ``` 这个代码统计思路有点简易,可能不那么准确,建议你在VS Code打开原始的map文件的,然后复制`Linker script and memory map`中的.bss段的全部内容到一个新的文件,然后用上面的代码来统计新文件的bss段大小信息。
撰写答案
登录
注册新账号
关注者
0
被浏览
286
关于作者
兮子南
这家伙很懒,什么也没写!
提问
3
回答
1
被采纳
0
关注TA
发私信
相关问题
1
rt_thread studio 啥时候能用呢
2
RT_Thread使用反馈帖子
3
RTT studio 下的 AT指令问题。
4
什么时候RTT Sdudio支持Ubuntu,Deepin和UOS操作系统
5
rt thread Studio 关于J-LINK下载问题
6
RT-Thread studio 调试设置问题
7
RTT-Studio 如何设置调试配置参数?
8
rt_thread studio 软件包配置
9
RT-Studio目前只能开发STM32的项目吗?
10
rtt studio 生成hex名字修改
推荐文章
1
RT-Thread应用项目汇总
2
玩转RT-Thread系列教程
3
国产MCU移植系列教程汇总,欢迎查看!
4
机器人操作系统 (ROS2) 和 RT-Thread 通信
5
五分钟玩转RT-Thread新社区
6
【技术三千问】之《玩转ART-Pi》,看这篇就够了!干货汇总
7
关于STM32H7开发板上使用SDIO接口驱动SD卡挂载文件系统的问题总结
8
STM32的“GPU”——DMA2D实例详解
9
RT-Thread隐藏的宝藏之completion
10
【ART-PI】RT-Thread 开启RTC 与 Alarm组件
最新文章
1
freemodbus主机在freertos的适配,参考rtthread例程
2
开源共生 商业共赢 | RT-Thread 2024开发者大会议程正式发布!
3
【24嵌入式设计大赛】基于RT-Thread星火一号的智慧家居系统
4
RT-Thread EtherKit开源以太网硬件正式发布
5
还在担心bsp不好维护吗?快使用yml管理主线bsp
热门标签
RT-Thread Studio
串口
Env
LWIP
SPI
AT
Bootloader
Hardfault
CAN总线
FinSH
ART-Pi
USB
DMA
文件系统
RT-Thread
SCons
RT-Thread Nano
线程
MQTT
STM32
RTC
FAL
rt-smart
ESP8266
I2C_IIC
WIZnet_W5500
UART
ota在线升级
PWM
cubemx
freemodbus
flash
packages_软件包
BSP
潘多拉开发板_Pandora
定时器
ADC
GD32
flashDB
socket
中断
Debug
编译报错
msh
SFUD
rt_mq_消息队列_msg_queue
keil_MDK
ulog
MicroPython
C++_cpp
本月问答贡献
a1012112796
20
个答案
3
次被采纳
张世争
12
个答案
3
次被采纳
踩姑娘的小蘑菇
7
个答案
3
次被采纳
用户名由3_15位
13
个答案
2
次被采纳
rv666
9
个答案
2
次被采纳
本月文章贡献
程序员阿伟
9
篇文章
2
次点赞
hhart
3
篇文章
4
次点赞
RTT_逍遥
1
篇文章
8
次点赞
大龄码农
1
篇文章
5
次点赞
ThinkCode
1
篇文章
1
次点赞
回到
顶部
发布
问题
分享
好友
手机
浏览
扫码手机浏览
投诉
建议
回到
底部