I am new to this forum . I am also a newbie in the feild of programming and i only know assembler. I tried to compile/build a led blink program written in riscv assembler for longan nano(example code from GitHub - theandrew168/bronzebeard: Minimal assembler and ecosystem for bare-metal RISC-V development) in platfromio . Platformio throws the following error - riscv-nuclei-elf-as: unrecognized option `-x’ – screen shot attached. The asm file was placed inside the src folder of platformio project. after failed to build i checked the build folder and found a .O file is output by the compiler/assembler but no .hex files… Requesting esteemed members to help me to resolve this issue. Is it possible to build asm files.
The behavior for compilling
.s was recently changed per Cannot use assembly files in MCS51 platform due to core issue · Issue #3917 · platformio/platformio-core · GitHub.
Can you try renaming the assembly files to
CC @ivankravets possible regression
Thankyou very much for the reply… I changed the file extension from .asm to .s as you have suggested. The previous Riscv-nuclei-elf-as: unrecognized option '-x’ message doesnt come anymore. At present I am getting the following message-----
c:/users/manama/.platformio/packages/toolchain-gd32v/bin/…/lib/gcc/riscv-nuclei-elf/9.2.0/…/…/…/…/riscv-nuclei-elf/bin/ld.exe: .pio\build\sipeed-longan-nano\libRISCV.a(start.o): in function
.L0 ': (.init+0x21c): undefined reference tomain’
Any help will be highly appreciated. I would like to assemble and link a dummy file (assembly) and program the longan device first before diving deep into study of RISCV.
Technically if you want a baremetal example with no other code than what you have in
src/, you should remove the
framework = ... line as this casues the
framework-gd32vf103-sdk code to be compiled into your project, but if you do that you would also have to provide the linker script and the
_start symbol as the entry point instead of the
main() function, and probably the interrupt vectors and do some stack init and all of that… so it might be okay to leave that now.
The project you’re pointing to has a custom Risc-V assembler implemented in bronzeboard package, so it was never intended to be compiled with a GNU toolchain. Luckily the needed changes don’t seem to be that many to get thish example compiling / assemblinbg.
I got it working by
- renaming all
.Sactually (so that
riscv-nuclei-elf-gcc -x assembler-with-cppis used)
- replaced all
- add the line
.global mainon top of the main
.Sfile so that the symbol
mainis globally visible to the linker (source of your "undefined reference to…) error
Dear @maxgerhardt ,
Thankyou very much,
I changed the longan_nano_led.asm to longan_nano_led.S with all comments starting with //.
I added “.global main” to the longan_nano_led.S and #include <GD32VF103.S> and pasted the file to src folder of the platforio project folder.
i changed GD32VF103.asm to GD32VF103.S and added it to the platform io project >> include folder.
clicked the build icon >>>>>>>> build succeeded.
downloaded GD32_Dfu_Tool_V18.104.22.16856.rar fromhttp://www.gd32mcu.com/en/download/
downloaded GD32DfuDrivers_V22.214.171.12467.rar from GigaDevice
installed 64x driver
extract tool GD32_Dfu_Tool
browse from tool to build directory C:\Users\Manama\Documents\PlatformIO\Projects\test asm.pio\build\sipeed-longan-nano and select firmware.hex
put longan in dfu mode by pressing reset >boot>release boot>release reset
tool shows board in DFU mode
click OK button to upload hex file
The LED on the longan board ligths up!!!
Thankyou so much once again. I can now start studying riscv assembly as it is doable.
I would like to request one more thing if I am not being a pain.
How to create a startup file with interrupt vectors to create a pure bare metal project without platformio framework as you have mentioned in your reply. Any reference example will also be helpful for me and any future user
Thanks and regards (1000 times)
@maxgerhardt, could you try the development version of GitHub - sipeed/platform-gd32v: GD32V: development platform for PlatformIO ? I’ve just updated dev-platforms and fixed ASM issues.
.s files should work if you don’t use preprocessor things. If it works, we release a new version of dev-platform.
P.S: Can’t test it on macOS no toolchain.