cancel
Showing results for 
Search instead for 
Did you mean: 

What should I change in my project so the example code for UART-printf to work?

nyanish
Associate II

Hellow, I've been dealing with this problem:

I run the UART-printf example on my STM32L011T6 board and it works perfectly. But when I start a new project in System Workbench, name it however I like, add a Hardware Abstraction Layer (HAL) as a static external library, create it in a workspace and then add all the code from the UART-printf example as it should be + all the files and configurations set, I get a FLASH overflow by 25000 bytes and RAM overflow by 800 bytes. I've built the library, I do have the syscalls.c file in the same folder as the main.c file. All the include paths and library paths also seem to be completely fine.

Without the printf() part it's working well, it builds and runs, but when I add the printf lines it gets that messy with the overflow errors. I'm not quite sure what I'm doing wrong and I've been stuck for some time, so if someone could help I'd really appreciate it!

1 ACCEPTED SOLUTION

Accepted Solutions

Hard to know, check the memory settings for the project that fails, and perhaps the .MAP file to understand where the 25 KB is coming from. Sounds like a lot, every if it were pulling in the floating point libraries.

Perhaps consider some more professional/commercial tools? Keil has a free license for STM32 Cortex-M0/0+ parts, and would be far less of a circus.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

5 REPLIES 5
AvaTar
Lead

> ... and then add all the code from the UART-printf example as it should be + all the files and configurations set, I get a FLASH overflow by 25000 bytes and RAM overflow by 800 bytes.

You can only use the memory resources the MCU has.

Either prune your code/data, optimize it, or use an MCU variant with larger RAM/FLASH.

nyanish
Associate II

@Community member​  But the example works perfectly fine and doesn't overflow, so why doesn't the empty project with the added UART-printf code work as well?

Hard to know, check the memory settings for the project that fails, and perhaps the .MAP file to understand where the 25 KB is coming from. Sounds like a lot, every if it were pulling in the floating point libraries.

Perhaps consider some more professional/commercial tools? Keil has a free license for STM32 Cortex-M0/0+ parts, and would be far less of a circus.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
nyanish
Associate II

@Community member​  Fixed it! It was in the Linker's Miscellaneous settings, I haven't had the nosys.specs and nano.specs set at all. Thank you so much!

But I also got curious, because I saw the "check the .MAP file" suggestion a lot of times, but I'm not quite sure how to read that .MAP file. I found it in the Debug folder of the project, but it's preetty long. Where should I be able to see that 25KB overflow in that file? Is the 25K number in hex or something? o.o It's an additional question, so you don't have to answer it if you don't want to:) Thanks again!

AvaTar
Lead

> Where should I be able to see that 25KB overflow in that file? Is the 25K number in hex or something?

The map file is ... the map file. It shows how variables and functions are mapped to memory addresses, and the respective sizes.

You won't see an overflow directly, but you are able to identify what is hooking up most memory resources. An overflow is usually made up by "too many objects".

> Fixed it! It was in the Linker's Miscellaneous settings, I haven't had the nosys.specs and nano.specs set at all.

"Automatically" preset/selected libraries are toolchain specific. You will need to read the documentation/tutorials.

But this is one specific area where many free toolchains are lacking, both in options and documentation.