0

English is not my native language, I apologize that.

Recently, I want to know detail about C lib initialization. The develop/debug environment as follow:

Hardware: QEMU simulator The GNU MCU Eclipse QEMU

Software: Examples of GNU Arm Embedded Toolchain

IO: Semihosting

CrossToolchian: GNU Arm Embedded Toolchain(gcc-arm-none-eabi-7-2017-q4-majo)

I have understand the principle and usage of Semihosting、Crosstoolchain and QEMU. I have write startup source code for Cortex-M3 without initialization of newlib, so I understand the cpu startup steps and the key poit of link script. In addition, I also write source code for semihosting with running in QEMU. I find GNU MCU Eclipse, a project about developing Coortex-M series's progams. I can get my aim using this project. But I want to know details of startup with newlib. So, I plan to write program from scratch . I get some helpful infomation from Readme of GNU Arm Embedded Toolchain. It provide newlib for Cortex-M3 when running on QEMU using Semihosting. I think I should use sample of qemu. Here is the designer's description about the example:

** qemu - Show how to build a Cortex-M bare-metal program running on qemu. This case builds a simple application that can run on qemu for ARM. It uses semihosting for file IO, which qemu supports.

I compile the example and run it on qemu, it print anything. I do not know why. Could anyone give me help ?

Compile:

make CORTEX_M=3

Run:

qemu-system-gnuarmeclipse  --verbose --verbose --nographic  --board STM32-P103 --image  hello-CM3.axf  --gdb tcp::1234

I find that the program not link startup_ARMCM3.S when see the detail of compile.

Compile detial:

arm-none-eabi-gcc hello.c -mthumb -mcpu=cortex-m0  -Os -flto -ffunction-sections -fdata-sections -g -v  --verbose --specs=nano.specs --specs=rdimon.specs -L../../ldscripts -T libs.ld -T mem.ld  -T sections.ld   -Wl,-Map=hello.map -g  -o hello-CM0.axf
artless noise
  • 21,212
  • 6
  • 68
  • 105
  • add `-d in_asm` flag to qemu command line to view which guest instructions were executed. What is destination sink that you program try to print to? Is it onboard UART controller? Maybe you use invalid controller addresses, valid for some another board? Add debug print functions to UART device used by [STM32-P103](https://github.com/gnu-mcu-eclipse/qemu/blob/0a892f52c3d25cb9c98ccb11020df563a85c43ee/hw/arm/beckus/stm32_p103.c) board implementation at qemu source code, recompile qemu, if you try to print through them. – Jettatura Jun 15 '18 at 13:52
  • I print messages using Semihosting in QEMU, not UART controller. – zhanglianpin Jun 16 '18 at 04:08

0 Answers0