Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Steven! Ragnarök
    @nuclearsandwich

    I am trying to build mruby for the Atmel SAMD21-based Circuit Playground Express board. I'm compiling libmruby.a with this build_config.rb https://gist.github.com/nuclearsandwich/d18375a375acd703bf1687d97fe57d92 and trying to link it from an external project for now. So none of the include paths in the build_config are being used. When I try to link libmruby.a I get the error below:

    "arm-none-eabi-gcc" -o MRUBY_CPX.elf "hal/src/hal_io.o" "samd21a/gcc/gcc/startup_samd21.o" "hal/utils/src/utils_syscalls.o" "hal/src/hal_delay.o" "hpl/pm/hpl_pm.o" "hpl/core/hpl_init.o" "samd21a/gcc/system_samd21.o" "hpl/core/hpl_core_m0plus_base.o" "hal/utils/src/utils_assert.o" "hpl/dmac/hpl_dmac.o" "hpl/sysctrl/hpl_sysctrl.o" "hpl/gclk/hpl_gclk.o" "hal/src/hal_init.o" "main.o" "hal/utils/src/utils_list.o" "examples/driver_examples.o" "driver_init.o" "hal/src/hal_gpio.o" "hal/utils/src/utils_event.o" "hal/src/hal_sleep.o" "atmel_start.o" "hal/src/hal_atomic.o" ../../build/arm-none-eabi-cpx/lib/libmruby.a  -Wl,--start-group -lgcc -lc -lm  -Wl,--end-group -mthumb \
    -Wl,-Map="MRUBY_CPX.map" --specs=nano.specs -Wl,--gc-sections -mcpu=cortex-m0plus \
     \
    -T"../samd21a/gcc/gcc/samd21g18a_flash.ld" \
    -L"../samd21a/gcc/gcc"
    /usr/lib/gcc/arm-none-eabi/8.1.0/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libc_nano.a(lib_a-writer.o): In function `_write_r':                                                                                                                                            
    writer.c:(.text._write_r+0x10): undefined reference to `_write'                                                                                                                                                                                                                
    /usr/lib/gcc/arm-none-eabi/8.1.0/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libc_nano.a(lib_a-readr.o): In function `_read_r':                                                                                                                                              
    readr.c:(.text._read_r+0x10): undefined reference to `_read'                                                                                                                                                                                                                   
    collect2: error: ld returned 1 exit status                                                                                                                                                                                                                                     
    make: *** [Makefile:167: MRUBY_CPX.elf] Error 1

    I'm pretty unfamiliar with embedded toolchains so I'm not sure if these missing references are due to failing to properly disable functionality in mruby I don't need yet or if I have to find these functions to for this platform.

    Steven! Ragnarök
    @nuclearsandwich
    Well. I was able to use an atmel package that provides stdio functionality via the serial interface. But when I tried to fit the mruby-compiler on the board I ran out of room in the flash storage (256K).
    Tom Black
    @blacktm

    Hi @nuclearsandwich, I recently got a Circuit Playground Express, and an Arduboy, and micro:bit. Trying to get MRuby running on all of them, but haven’t gotten as far as you yet. I did notice that the memory sizes (program and SRAM) on these little microcontrollers is pretty small (Arduboy has a tiny 32K/2.5K ATmega32U4). Might have to use MRuby/c for the smallest of these, which might also be too big for some (~40K interpreter size I think, compared to ~400K for MRuby). For the Circuit Playground, we should be able to squeeze programs into the 2MB of SPI Flash (separate memory from the ATSAMD21 chip) — they were able to get CircuitPython on there, which perhaps has a similar footprint to MRuby. Also, I think we can compile and execute Ruby over the serial interface, rather than having to re-flash the entire thing, and that would be awesome.

    Should we open an issue on the MRuby repo to talk generally about microcontroller support?

    Steven! Ragnarök
    @nuclearsandwich
    Hey that's awesome! Glad others are havingg the same idea. I am trying to finish the write up of how far in I got.
    Regarding interpreter footprint, MicroPython, the basis for CircuitPython is explicitly optimized for microcontroller devices whereas MRuby's core focus is, I believe, in being a full computer Ruby that's a bit lighter weight and easier to embed. So I don't think the interpreter sizes are likely to be that close in size. On top of that, the Ruby parser has many more moving parts than a python parser needs.
    I'm not sure how much of the SPI flash we can utilize for the MRuby firmware as I don't think we can execute from it directly. The 2M SPI is also where the user code and data needs to go so if we use too much of it we'll limit what end users can do with it.
    Steven! Ragnarök
    @nuclearsandwich
    Unless someone from mruby core requests it, I think I'd like to have a precise request before opening an issue. Something like "Make it possible to run mruby-compiler in XXX RAM / ROM?" Then we can explore the feasibility of that.
    Tom Black
    @blacktm
    @nuclearsandwich Looking forward to your writeup! The MicroPython site says "compact enough to fit and run within just 256k of code space and 16k of RAM," so it looks like it's somewhere in between MRuby and MRuby/c. Maybe we could cut out gems from the default gembox, aggressively optimize (-Os), and fit it within the ATSAMD21's 256KB flash (not sure what RAM footprint is though). Otherwise if not, on to MRuby/c. As for the SPI flash, the Circuit Playground Express product site says "used primarily with CircuitPython to store code and libraries." Not sure what that means specifically though. A lot to figure out yet. 😞
    Steven! Ragnarök
    @nuclearsandwich

    Not sure what that means specifically though

    One of the cool things about circuitpython is that the firmware acts as a USB mass storage device when connected to a computer. The SPI flash is used as a FAT filesystem and you can drop files including your main.py or code.py right there and then once you unplug it the circuitpython firmware just runs your python!

    Tom Black
    @blacktm
    @nuclearsandwich So cool, if we could figure that out in Ruby... 😍
    Steven! Ragnarök
    @nuclearsandwich
    Is https://blog.mruby.sh/ affiliated with mruby? Their certificate has been expired for some time.
    Jonathan Dinu
    @jondinu
    hello all, just starting playing with embedding mruby in C and I was wondering if there is a straight forward way to convert mrb_value types to C types. For example say I know my mrb_value is always a string, can I cast it to a char * to use in standard C functions? I see in the API that there are a bunch of functions to make C types into a corresponding type in the mruby C API but I could find anything to go the other way. Any help is greatly appreciated 🙏
    Tom Black
    @blacktm
    Hi @jondinu, I’ve got a bunch of C <=> mruby (and also MRI) examples in this file: https://github.com/ruby2d/ruby2d/blob/master/ext/ruby2d/ruby2d.c
    Jonathan Dinu
    @jondinu
    oh awesome! you're the best @blacktm
    Piotr Usewicz
    @pusewicz
    Hi, how different are C extensions in mruby compared to ruby?
    I need SerialPort, but non of the mruby versions are complete
    I'd like to try to port this one to support mruby.
    Luke Reid
    @qume
    I have a microcontroller on a board which i've yet to write the code for, and would love to use mruby for it. It's not too late for me to change the chip - currently ATSAMD21 (the largest capacity one). Would love to know if anyone has made it work on this chip or a recommendation for a chip to sub it out for where I can use this. Thanks all for this awesome project
    Jonas Minnberg
    @sasq64
    How can I retain a ruby object in C that was created by ruby ?
    It seems to (naturally) get garbage collected since it does not now C keeps a reference to it.
    Jonas Minnberg
    @sasq64

    And forcing me to formulate a question helped me finding the right thing to google;

    mrb_gc_mark_value(mrb_state*, mrb_value)

    was the soloution

    Actually. mrb_gc_register() is more correct
    kotovalexarian0
    @kotovalexarian0:matrix.org
    [m]
    Hello. How can I compare mrb_value containing Symbol with different symbols?
    kotovalexarian0
    @kotovalexarian0:matrix.org
    [m]
    Oh, I've found it. mrb_obj_to_sym
    hfabre
    @hfabre
    Hi there, i'm new to mruby and there something i don't understand. I have written in C an initializer method for a custom class which simply set some instance variables (using mrb_iv_set). When i do c = MyClass.new and p c i can see my instance variable so it works. But when i pass this instance to a C function (my_c_func(c)) where i get it back this way mrb_get_args("o", &my_mrb_value), it looks like my instance variables are set to 0 (getting those back using mrb_get_integer(mrb_iv_get(mrb, my_symbol)) is this something expected ?
    Rick Hull
    @rickhull
    is there a good way to check if a .rb file is executed for/via mruby versus, say, MRI ? like a runtime check from within the .rb file
    e.g. if ENV['MRB_STUFF'] ?
    Tom Black
    @blacktm
    @rickhull I check RUBY_ENGINE
    1 reply