Skip to content

fluxamp/mruby-test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is a playground project, exploring the integration of mruby with FreeRTOS and libopencm3 for the STM32F412ZG (available as a low-cost Nucleo developer board).

Dependencies

Building and flashing

Run the following command to build the firmware (omit the --info for less verbose output).

gradle build --info

The gradle script also checks for the presence of the necessary library and if needed checks out their source code and builds them. These steps can also be performed manually beforehand:

git submodule init
git submodule update
cd libs/libopencm3 && make

For building mruby, a configuration file (build_config.rb) needs to be copied to the mruby root directory before calling ./minirake inside the ruby directory. This repository supplies a build_config.rb example in the libs/config folder. The provided config file specifies the same compiler flags as used for building the rest of the firmware. It also configures the standard gems for math, printing and compiling mruby code.

Finally, the firmware can be flashed to the Nucleo board (using st-flash from the stlink project):

gradle flash

Porting to other microcontrollers

A number of changes need to be performed when porting this example project to other STM32 microcontrollers.

Note that the current configuration requires approximately 350kB of flash when building with debug symbols.

  1. RAM and ROM sizes need to be adapted in the linker script (generated.stm32f412zg.ld)
  2. The main.cpp file specifies the pins as used on the Nucleo-F412ZG board
  3. Inside the build.gradle file, the C definition for the correct chip needs to be changed (in the firmware(NativeExecutableSpec) block)

In case the target processor is part of a different processor family, e.g., the STM32F3 family:

  1. The definition of the family needs to be also changed inside the build.gradle file (similar to point 3 above).
  2. A different version of libopencm3 needs to be linked. This requires the definition of a new libs(PrebuiltLibraries) block with the new library file name (see below). Finally, both the C and C++ source sets need to be aware of the different library: c.lib library: "opencm3_f3", linkage: "static" and cpp.lib library: "opencm3_f3", linkage: "static".
opencm3_f3 {
    headers.srcDir "libs/libopencm3/include"
    binaries.withType(StaticLibraryBinary) {
        staticLibraryFile = file("libs/libopencm3/lib/libopencm3_stm32f3.a")
    }
}

About

playground project for exploring mruby

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published