当前位置:网站首页>STM32 printf problem summary semihosting microlib understanding
STM32 printf problem summary semihosting microlib understanding
2022-07-29 08:02:00 【BobBobBao】
STM32 Use printf The problem summary
background : Use STM32F4 When developing board serial port , Want to use c The language comes with printf Function to output the string to the serial port debugging assistant .
- First, we need to redefine fputc()、fgetc() function
/// Redirect c Library function printf To serial port DEBUG_USART, After resetting, you can use printf function
int fputc(int ch, FILE *f)
{
/* Send a byte of data to the serial port DEBUG_USART */
HAL_UART_Transmit(&huart1, (uint8_t *)&ch, 1, 1000);
return (ch);
}
/// Redirect c Library function scanf To serial port DEBUG_USART, Override backward to use scanf、getchar Such as function
int fgetc(FILE *f)
{
int ch;
HAL_UART_Receive(&huart1, (uint8_t *)&ch, 1, 1000);
return (ch);
}
Check options for Target–>Target–>Use MicroLIB, Use MicroLIB library .
-microLIB It's a standard. C An alternative library to the Library , Used in embedded hardware with very little memory .
-microLIB Standard libraries are not supported
- Mainly complete the following work :
- Create an executable C The environment of the program : Create a stack 、 Create a heap ( if necessary )、 The library used by the initialization program
- call main() Start executionHalf host (semi-hosting): It's a mechanism , Make it run in ARM The code on the target can communicate , And use Input/Output Tools
- At the beginning of development , Developers may not know what to do ARM What input and output devices are there on the device , The semi host mechanism allows developers not to know ARM Device peripherals , Input and output debugging can be realized by using the peripherals of the host computer .
- If you want to use ARM Input on the device 、 Output devices , First of all, turn off semihosting. Then redirect the input and output to ARM On the device .

-microLIB Compile time through Low-Level Functions Connect with hardware , Adopt abridged version high-level functions, useless system I/O functions.If not used microLIB library , Use the standard library ( By default semihosting), call printf() Functions like that , Will cause a crash . resolvent :
- Add compilation settings to the program , Don't use semihosting
//C In language
#pragma import(__use_no_semihosting_swi)
// In assembly language
IMPORT __use_no_semihosting_swi
Reference resources :
边栏推荐
- What are the principles and methods of implementing functional automation testing?
- Monitor the bottom button of page scrolling position positioning (including the solution that page initialization positioning does not take effect on mouse sliding)
- C language problems
- [cryptography experiment] 0x00 install NTL Library
- Do you want to meet all the needs of customers
- Solve the problem that the disk is full due to large files
- Unity - default rendering pipeline - sculpt shader
- "Swiss Army Knife" -nc in network tools
- Cross domain problems when downloading webapi interface files
- [introduction to cryoelectron microscopy] Caltech open class course notes part 3:image formation
猜你喜欢

Some tools, plug-ins and software links are shared with you~

An Optimal Buffer Management Scheme with Dynamic Thresholds论文总结

JVM garbage collection mechanism (GC)

Day 014 二维数组练习
![[beauty of software engineering - column notes] 24 | technical debt: continue to make do with it, or overthrow it and start over?](/img/09/296185ae299bec898b8bbe9cfc993f.png)
[beauty of software engineering - column notes] 24 | technical debt: continue to make do with it, or overthrow it and start over?

Implementation of simple matcap+fresnel shader in unity
![[paper reading] tomoalign: a novel approach to correcting sample motion and 3D CTF in cryoet](/img/3a/75c211f21758ca2d9bb1a40d739d80.png)
[paper reading] tomoalign: a novel approach to correcting sample motion and 3D CTF in cryoet
![[beauty of software engineering - column notes] 21 | architecture design: can ordinary programmers also implement complex systems?](/img/db/ef33a111bcb543f9704706049bccc2.png)
[beauty of software engineering - column notes] 21 | architecture design: can ordinary programmers also implement complex systems?

@JsonSerialize注解的使用

Cyberpunk special effect shader
随机推荐
Data unit: bit, byte, word, word length
Resize2fs: bad magic number in super block
Unity - default rendering pipeline - sculpt shader
Excellent urban design ~ good! Design # visualization radio station will be broadcast soon
IonIcons图标大全
[cryoelectron microscope | paper reading] emclarity: software for high-resolution cryoelectron tomography and sub fault averaging
[cryoelectron microscope] relion4.0 pipeline command summary (self use)
Limitations of push down analysis
Day 014 2D array exercise
MySQL 45 talk | 07 line lock merits and demerits: how to reduce the impact of line lock on performance?
Unicode私人使用区域(Private Use Areas)
[beauty of software engineering - column notes] 23 | Architect: programmers who don't want to be architects are not good programmers
Record of problems caused by PIP upgrade damage
Ionicons icon Encyclopedia
Joseph Ring problem
Network Security Learning chapter
Ansible (automation software)
【学术相关】为什么很多国内学者的AI的论文复现不了?
Research on autojs wechat: the final product of wechat automatic information sending robot (effective demonstration)
Vmstat memory consumption query