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