It's a long time since my last post. During these time, I solved the linking problem. It's caused by the default linker script provided by Zephyr.
The default linker script puts some sections generated by the swift compiler in a wrong address, that's why the final binary was that huge. After a little fix, the whole procedure works very well now! The final binary is around 1.1MB.
The good news, most swift codes can run on my cortex-m7 board now! I tried a lot of code snippets, most of them work very well(Different types, Functions, Classes, Structures, Protocols, etc.). But the print function still didn't work, after some time debugging. I found that when the program goes into the line if case let streamableObject as TextOutputStreamable = value
in _print_unlocked
function in OutputStream.swift
. The program would crash. Thanks to the Zephyr RTOS, it provides me some fault information. It's related to wrong memory access.
Till now, I found some similar problems. They all crashed when run into the swift_conformsToProtocolImpl
function in ProtocolConformance.cpp
. I've added a new topic on this problem.
Thanks for all your help @spevans, I plan to make my own board in recent months. I must send you one after I finished.