Skip to content

newlib占用Flash空间过大 #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
2 tasks done
cxeo opened this issue Aug 3, 2023 · 7 comments
Closed
2 tasks done

newlib占用Flash空间过大 #32

cxeo opened this issue Aug 3, 2023 · 7 comments
Assignees
Labels
⚠描述属实 ❔提问 Further information is requested

Comments

@cxeo
Copy link

cxeo commented Aug 3, 2023

描述一下这个bug / Describe the bug

对字符串 string使用 string.toFloat()会编译报错
而string.toInt()则正常

复现步骤 / To Reproduce

用 String 定义一个浮点数,然后使用.toFloat()进行转换

String a="10.234";
Serial.println(a.toFloat());

只用这两行代码就会编译报错。

预期的行为 / Expected behavior

修复

截图 / Screenshots

日志 / Logs

系统 / System

win10

软件版本 / Version

Arduino IDE 2.1.0

验证

  • 检查该问题是否已被提过 / Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • 提供了最小可复现工程或详细的复现步骤,确保开发者可以复现 / The provided reproduction is a minimal reproducible example of the bug.
@HalfSweet
Copy link
Member

arm-none-eabi-gcc的libc采用的是newlib,因此浮点数相关的操作对于Flash的占用可能会略大

后期我们可能会考虑修改Arduino String以减小对资源的占用

@chenxuuu
Copy link
Contributor

chenxuuu commented Aug 3, 2023 via email

@HalfSweet HalfSweet changed the title String.toFloat() 编译报错 newlib占用的Flash空间过大 Aug 3, 2023
@HalfSweet HalfSweet self-assigned this Aug 3, 2023
@cxeo
Copy link
Author

cxeo commented Aug 4, 2023

用string flash占用可以用异常大来形容,没多少代码 flash就快满了

@cxeo
Copy link
Author

cxeo commented Aug 4, 2023

Air001开发板,加一句 printf("%d,%d,%d\n",xxx),Flash就会多占用13%

@chenxuuu chenxuuu added the ❔提问 Further information is requested label Aug 4, 2023
@chenxuuu
Copy link
Contributor

chenxuuu commented Aug 4, 2023

参考stm32duino/Arduino_Core_STM32#2036 ,只能重写标准库

@cxeo
Copy link
Author

cxeo commented Aug 4, 2023

.toFloat()进行转换 编译报错的原因是flash空间用满不够导致的,调用.toFloat()会占用大量Flash。

@HalfSweet
Copy link
Member

HalfSweet commented Aug 4, 2023

参考stm32duino/Arduino_Core_STM32#2036 ,只能重写标准库

如果是newlib造成的问题,我们恐怕得重新实现一份字符串格式化的库

也许mtfmt.cc是个不错的解决方案

@HalfSweet HalfSweet moved this from Todo to In Progress in AirMCU的发展路线 Aug 7, 2023
@chenxuuu chenxuuu changed the title newlib占用的Flash空间过大 fplib软件浮点库占用Flash空间过大 Aug 9, 2023
@chenxuuu chenxuuu changed the title fplib软件浮点库占用Flash空间过大 newlib占用Flash空间过大 Aug 9, 2023
@github-project-automation github-project-automation bot moved this from In Progress to Done in AirMCU的发展路线 Aug 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚠描述属实 ❔提问 Further information is requested
Projects
Development

No branches or pull requests

3 participants