I can build the c-files from my WCH CH32V003F4P6
microcontroller project with the GNU RISC-V Embedded GCC v8.2.0
toolchain shipped with the Eclipse IDE from WCH (MounRiver Studio). However, if I try to build the same c-files with a similar toolchain downloaded here (see https://xpack.github.io/dev-tools/riscv-none-elf-gcc/releases/), then I get incomprehensible errors like:
Error: x ISA extension 'xw' must be set with the versions
or
cc1.exe: error: -march=rv32ecxw: unsupported ISA substring 'xw'
To reproduce the problem, you should:
First install MounRiver Studio (see http://www.mounriver.com/download)
Second, download the microcontroller sample projects from http://www.wch-ic.com/products/CH32V003.html (see the CH32V003EVT.ZIP
file at the bottom of the webpage). Unzip it to your C:/
drive. The GPIO_Toggle
sample project is now at "C:/CH32V003EVT/EVT/EXAM/GPIO/GPIO_Toggle/"
.
Let's now compile the main.c
file from the GPIO_Toggle
project, like this:
> "C:/MounRiver/MounRiver_Studio/toolchain/RISC-V Embedded GCC/bin/riscv-none-embed-gcc"
-march=rv32ecxw
-mabi=ilp32e
-msmall-data-limit=0
-msave-restore
-fsigned-char
-fno-common
-Wunused
-Wuninitialized
-Og
-g3
-fmessage-length=0
-ffunction-sections
-fdata-sections
-Wno-comment
-Wno-unused-function
-std=gnu99
-Werror-implicit-function-declaration
-I"C:/CH32V003EVT/EVT/EXAM/SRC/Core"
-I"C:/CH32V003EVT/EVT/EXAM/SRC/Debug"
-I"C:/CH32V003EVT/EVT/EXAM/SRC/Peripheral/inc"
-I"C:/CH32V003EVT/EVT/EXAM/GPIO/GPIO_Toggle/User"
"C:/CH32V003EVT/EVT/EXAM/GPIO/GPIO_Toggle/User/main.c"
-o "C:/CH32V003EVT/EVT/EXAM/GPIO/GPIO_Toggle/build/main.o"
-c
This should work.
Let's try with a few other toolchains. Download some GNU RISC-V Embedded GCC
toolchains from here: https://xpack.github.io/dev-tools/riscv-none-elf-gcc/releases/
Unzip them to your C:/
drive:
Now invoke the same compilation command with each of these toolchains:
> "C:/xpack-riscv-none-embed-gcc-8.2.0-3.1-win32-x32/bin/riscv-none-embed-gcc"
-march=rv32ecxw
-mabi=ilp32e
-...
> "C:/xpack-riscv-none-embed-gcc-8.2.0-3.1-win32-x64/bin/riscv-none-embed-gcc"
-march=rv32ecxw
-mabi=ilp32e
-...
> "C:/xpack-riscv-none-elf-gcc-12.2.0-3-win32-x64/bin/riscv-none-elf-gcc"
-march=rv32ecxw
-mabi=ilp32e
-...
I got these obscure errors:
Error: x ISA extension 'xw' must be set with the versions
cc1.exe: error: -march=rv32ecxw: unsupported ISA substring 'xw'
I can't wrap my head around them.
As a first reaction, I compare the toolchains. The one from MounRiver Studio outputs the following for --version
:
> "C:/MounRiver/MounRiver_Studio/toolchain/RISC-V Embedded GCC/bin/riscv-none-embed-gcc" --version
riscv-none-embed-gcc (xPack GNU RISC-V Embedded GCC, 32-bit) 8.2.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
I get the exact same output from one of the other toolchains:
> "C:/xpack-riscv-none-embed-gcc-8.2.0-3.1-win32-x32/bin/riscv-none-embed-gcc" --version
riscv-none-embed-gcc (xPack GNU RISC-V Embedded GCC, 32-bit) 8.2.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
So they must be identical, no? How then is it possible that the one from MounRiver works and the other one doesn't?
The xPack GNU RISC-V Embedded GCC supports only the standard RISC-V extensions. The 'xw' extension is custom one, added by WCH for their own designs, and is supported only by their custom toolchain.