Home > Software engineering >  PlatformIO build error on SiFive when adding an assembly file
PlatformIO build error on SiFive when adding an assembly file

Time:09-30

I have installed PlatformIO on my vscode, on Ubuntu. I have created a project with Freedom E SDK and added a simple main.c file:

int main(void)
{
    return 0;
}

Then, when I try to build, it works:

Processing hifive1 (platform: sifive; board: hifive1; framework: freedom-e-sdk)
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/sifive/hifive1.html
PLATFORM: SiFive (5.2.0) > HiFive1
HARDWARE: FE310 320MHz, 16KB RAM, 16MB Flash
DEBUG: Current (ftdi) On-board (ftdi, qemu, renode)
PACKAGES: 
 - framework-freedom-e-sdk @ 2.20050003.200818 (2005.0.3) 
 - toolchain-riscv @ 1.80300.190927 (8.3.0)
LDF: Library Dependency Finder -> ...
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 0 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio/build/hifive1/src/main.o
...
Compiling .pio/build/hifive1/metal/switch.o
/home/dan/.platformio/packages/framework-freedom-e-sdk/freedom-metal/src/shutdown.c:15:9: note: #pragma message: There is no defined shutdown mechanism, metal_shutdown() will spin.
 #pragma message(                                                               \
         ^~~~~~~
Compiling .pio/build/hifive1/metal/synchronize_harts.o
...
Archiving .pio/build/hifive1/libmetal-gloss.a
Indexing .pio/build/hifive1/libmetal-gloss.a
Linking .pio/build/hifive1/firmware.elf
Checking size .pio/build/hifive1/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [===       ]  27.1% (used 4444 bytes from 16384 bytes)
Flash: [          ]   0.1% (used 10994 bytes from 16777216 bytes)
Building .pio/build/hifive1/firmware.hex
======= [SUCCESS] Took 1.72 seconds ================

However, when I add an completely empty assembly file (I need to use assembly in this project), I get an error:

Processing hifive1 (platform: sifive; board: hifive1; framework: freedom-e-sdk)
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/sifive/hifive1.html
PLATFORM: SiFive (5.2.0) > HiFive1
HARDWARE: FE310 320MHz, 16KB RAM, 16MB Flash
DEBUG: Current (ftdi) On-board (ftdi, qemu, renode)
PACKAGES: 
 - framework-freedom-e-sdk @ 2.20050003.200818 (2005.0.3) 
 - toolchain-riscv @ 1.80300.190927 (8.3.0)
LDF: Library Dependency Finder -> ...
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 0 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio/build/hifive1/src/main.o
Compiling .pio/build/hifive1/src/test.o
riscv64-unknown-elf-as: unrecognized option '-mcmodel=medlow'
Compiling .pio/build/hifive1/metal/atomic.o
Compiling .pio/build/hifive1/metal/button.o
Compiling .pio/build/hifive1/metal/cache.o
Compiling .pio/build/hifive1/metal/clock.o
Compiling .pio/build/hifive1/metal/cpu.o
Compiling .pio/build/hifive1/metal/drivers/fixed-clock.o
Compiling .pio/build/hifive1/metal/drivers/fixed-factor-clock.o
Compiling .pio/build/hifive1/metal/drivers/inline.o
Compiling .pio/build/hifive1/metal/drivers/riscv_clint0.o
Compiling .pio/build/hifive1/metal/drivers/riscv_cpu.o
*** [.pio/build/hifive1/src/test.o] Error 1
====================== [FAILED] Took 0.96 seconds ===========

It looks like it is using a toolchain I had installed before (riscv64-unknown-elf*) and getting an error because of an unknown flag:

riscv64-unknown-elf-as: unrecognized option '-mcmodel=medlow'

What can I do?

CodePudding user response:

I have fixed the problem by adding build_unflags = -mcmodel=medlow to the platformio.ini file, so it is now:

[env:hifive1]
platform = sifive
board = hifive1
framework = freedom-e-sdk
build_unflags = -mcmodel=medlow
  • Related