I am trying to play with baremetal Zig on ESP32-C3 RISC-V MCU.
I am using ESP-IDF blinky example with Zig 0.12 (1856+94c63f31f). When it was built with default GCC and cmake it will compile and link without problems.
But now I am trying to build it like Zig project it fails to link with messages like:
Even when I am using vectors.o built by GCC problem is same.
All object files and static libraries built with Zig can be linked with GCC, eg:
Disclosure: I havenât tested these myself because I donât understand how to run the examples, but I thought Iâd share in case they make more sense to you.
Finally I was able to fix this!
Minimal reproducer available at github
It wasnât as much as Zigâ s problem as it is LLVMâs.
Fix was to include ââaxâ, %progbitsâ in asm file (otherwise whole â.ram.vector_tableâ section would be discarded):
I saw MicroZig but I was unable to compile even simpliest example. At least that is what I thought.
build output
rm -rf zig-cache zig-out
unset ZIG_LOCAL_CACHE_DIR
zig build
run regz (chip.zig): error: warning(svd): failed to load register: error.TodoDimElementsExtended
warning(svd): failed to load register: error.TodoDimElementsExtended
warning(svd): failed to load register: error.TodoDimElementsExtended
warning(svd): failed to load register: error.TodoDimElementsExtended
warning(svd): failed to load register: error.TodoDimElementsExtended
warning(svd): failed to load register: error.TodoDimElementsExtended
warning(svd): failed to load register: error.TodoDimElementsExtended
warning(svd): failed to load register: error.TodoDimElementsExtended
warning(svd): failed to load register: error.TodoDimElementsExtended
warning(svd): failed to load register: error.TodoDimElementsExtended
warning(svd): failed to load register: error.TodoDimElementsExtended
warning(svd): failed to load register: error.TodoDimElementsExtended
warning(svd): failed to load register: error.TodoDimElementsExtended
warning(svd): failed to load register: error.TodoDimElementsExtended
warning(svd): failed to load register: error.TodoDimElementsExtended
warning(svd): failed to load register: error.TodoDimElementsExtended
warning(svd): failed to load register: error.TodoDimElementsExtended
warning(svd): failed to load register: error.TodoDimElementsExtended
warning(svd): failed to load register: error.TodoDimElementsExtended
warning(svd): failed to load register: error.TodoDimElementsExtended
warning(svd): failed to load register: error.TodoDimElementsExtended
warning(svd): failed to load register: error.TodoDimElementsExtended
warning(svd): failed to load register: error.TodoDimElementsExtended
warning(svd): failed to load register: error.TodoDimElementsExtended
warning(svd): failed to load register: error.TodoDimElementsExtended
warning(svd): failed to load register: error.TodoDimElementsExtended
warning(svd): failed to load register: error.TodoDimElementsExtended
warning(svd): failed to load register: error.TodoDimElementsExtended
It âfailsâ but .bin and .elf files are available in zig-out/firmware folder.
To flash it, I use Rust tool (which is much quicker than ESP IDFâs tool):