Skip to content

Build for RISC-V chips? #53

@vickash

Description

@vickash

Has anyone gotten this working, or tried, on any of the RISC-V based chips (C3, C6, H2, etc.) yet? It seems like new products will be RISC-V going forward, so something to think about.

I tried compiling as-is for my esp32c3 at first. Got an error that the -mlongcalls flag wasn't recognized, so I removed all the flags and copied all I could find in the IDF's gcc config for the esp32c3:

cc.flags << '-march=rv32imc_zicsr_zifencei'
cc.flags << '-std=gnu17'
cc.flags << ["-ffunction-sections", "-fdata-sections", "-gdwarf-4", "-ggdb"]
cc.flags = cc.flags.flatten.collect { |x| x.gsub('-MP', '') }

In mruby_task I'm not even trying to load a file, just doing:

mrb_load_string(mrb, "puts \"mruby works!\"");

It does not work. This is the output:

Guru Meditation Error: Core  0 panic'ed (Load access fault). Exception was unhandled.

Stack dump detected
Core  0 register dump:
MEPC    : 0x40058eb6  RA      : 0x4202820e  SP      : 0x3fc9ed60  GP      : 0x3fc8d200  
0x40058eb6: strlen in ROM
0x4202820e: mrb_load_string_cxt at components/mruby_component/mruby/mrbgems/mruby-compiler/core/parse.y:7003
 (inlined by) mrb_load_string at components/mruby_component/mruby/mrbgems/mruby-compiler/core/parse.y:7009

TP      : 0x3fc5afcc  T0      : 0x4005890e  T1      : 0x10000000  T2      : 0x000009fd  
0x4005890e: memset in ROM

S0/FP   : 0x3fc9ef20  S1      : 0x3c0a4a94  A0      : 0x00000000  A1      : 0xffffffff  
A2      : 0x00000000  A3      : 0x7f7f7f7f  A4      : 0x00000000  A5      : 0x00000004  
A6      : 0x60023000  A7      : 0x0000000a  S2      : 0x00000000  S3      : 0x00000000  
S4      : 0x3fc9ef20  S5      : 0x00000000  S6      : 0x00000000  S7      : 0x00000000  
S8      : 0x00000000  S9      : 0x00000000  S10     : 0x00000000  S11     : 0x00000000  
T3      : 0x00000000  T4      : 0x0000000f  T5      : 0x3fcb567c  T6      : 0x0000000d  
MSTATUS : 0x00001881  MTVEC   : 0x40380001  MCAUSE  : 0x00000005  MTVAL   : 0x00000000  
0x40380001: _vector_table at ??:?

MHARTID : 0x00000000  

Backtrace:

0x40058eb6 in ?? ()
#0  0x40058eb6 in ?? ()
#1  0x4202820e in mrb_load_string_cxt (c=0x0, s=0x0, mrb=0x3c0a4a94) at mrbgems/mruby-compiler/core/parse.y:7003
#2  mrb_load_string (mrb=0x3c0a4a94, s=0x0) at mrbgems/mruby-compiler/core/parse.y:7009
#3  0x00000000 in ?? ()
Backtrace stopped: frame did not save the PC
ELF file SHA256: ec3ce0cb7

I think this might have something to do with RISC-V gcc not having an equivalent to Xtensa's -mlongcalls, but I'm out of my depth here. Any suggestions?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions