I continue to try on it today. At first, my best guess is that some initialization procedures of mbed are not called. For example, when in debug mode, the uC doesn't break at software_init_hook(). It makes me strongly believe that the startup script is the main mistake here.
After skimming through the startup scripts of different targets, to my surprise, some of them uncomment libc_init_array and call "bl _start" while the other boards call both libc_init_array and _start link. Thus, I made my script calling both libc_init_array and _start. As the result of that, it began to work correctly.
If you want to port a new target, i would like to summarize my experiment here:
- use mbedcli to export the project to use and debug on the supported ide (i use coide in my experiment). By using mbedcli, the project contains the whole source code of mbed-os (if u use the online ide, the exported project only has the mbed-os lib file, not source)
- the exported proj will require some modifications before it can compile successfully.
- fix the deviceID in .coproj.
- add the macro in mbed_config.h into coocox proj configuration (tab compile->defined symbols)
- after it can be compiled and works correctly on the mbed board, u can start to port by adding the target driver of ur port and put inside the folder mbed-os/target/target-stm/target_stmf4/target_<boardName>
- change PinNames.h and PeripheralPins.c, PortNames.h according to ur board.
- change system_stm32f4xx.c
- change startup script
- there may be smt else need to change as well. However, the key is that only the target folder is one that s matter. So just make sure every line of code in that folder is changed correctly, the mbed code should work correctly as well.
==> by now, ur board should run the mbed program gracefully with blinking led, but still left the serial print
I am writing a target port for pixhawk stm32f427vit6 board and add it inside the mbed-os source. The main routine is as following
main.cpp
In debug mode, it can go to wait > wait_us > Thread::wait > svcDelay > scvHandler > svcUser > defaultHandler. Can anyone tell me where the problem is and how to fix it?? If you can, can you explain how the svcHandler involves into the delay routine of os???