1

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'

Reproduce the problem

To reproduce the problem, you should:

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:

enter image description here

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.

Compare the toolchains

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?

K.Mulier
  • 8,069
  • 15
  • 79
  • 141
  • *So they must be identical, no?* - No. Evidently one is compiled with `xw` extension support and the other isn't. It is nit reflected in the version string. Run with `-v` and you should see something like `--with-arch=rv64imafdc` in the "Configured with" field – Eugene Sh. May 25 '23 at 17:59
  • @EugeneSh. Yes you are right, but what does that mean, explained in a way someone who is not familiar with gcc extensions can understand? Does that mean that to compile for a `CH32V003F4P6` microcontroller, one needs to compile gcc from source, configuring it with `--with-arch=rv64imafdc` ? Is there any documentation that helps to get a better understanding of this issue? – ygramoel May 25 '23 at 18:28
  • @ygramoel It's not gcc extensions, it's RiscV ISA extensions. If this microcontroller supports this specific extension and one wants the compiler to emit the corresponding instructions, then he needs a compiler with this capability. – Eugene Sh. May 25 '23 at 18:37
  • Actually, there is no `--with-arch` configuration in version 8.2.0 nor in 10.2.0. It looks like WCH did some custom modifications in the source code. – ygramoel May 25 '23 at 19:09
  • So, to compile with this 10.2.0 gcc, one could use a different `-march` option, like `-march=rv32ec` instead of `-march=rv32ecxw`? – ygramoel May 25 '23 at 19:11
  • It is probably some custom build as you say, as `xw` does not seem to be any standard extension (https://en.wikichip.org/wiki/risc-v/standard_extensions). So you should look at the processor datasheet if it is a thing and see if you are actually interested in using it, and if not, remove it from the compiler configuration string in your IDE – Eugene Sh. May 25 '23 at 19:25

0 Answers0