Skip to content

Instantly share code, notes, and snippets.

@kyab
Created April 13, 2014 15:42
Show Gist options
  • Save kyab/10589251 to your computer and use it in GitHub Desktop.
Save kyab/10589251 to your computer and use it in GitHub Desktop.
build_config.rb for STM32F4Discovery with my modified AeroQuad. 2014,4, April
MRuby::CrossBuild.new("STM32F4") do |conf|
toolchain :gcc
ARM_TOOLCHAIN_PATH = "/Applications/MapleIDE.app/Contents/Resources/Java/hardware/tools/arm/bin"
LIBMAPLE_PATH = "/Users/koji/tools/AeroQuad/Libmaple/libmaple"
conf.cc do |cc|
cc.command = "#{ARM_TOOLCHAIN_PATH}/arm-none-eabi-gcc"
cc.include_paths << ["#{LIBMAPLE_PATH}/libmaple",
"#{LIBMAPLE_PATH}/wirish",
"#{LIBMAPLE_PATH}/wirish/comm",
"#{LIBMAPLE_PATH}/wirish/boards",
"#{LIBMAPLE_PATH}/libraries"
]
cc.flags = %w(-Os -g3 -gdwarf-2 -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -ffunction-sections
-nostdlib -fdata-sections -Wl,--gc-sections -DVECT_TAB_BASE -DBOARD_discovery_f4 -DMCU_STM32F406VG
-DERROR_LED_PORT=GPIOD -DERROR_LED_PIN=14
-DSTM32_HIGH_DENSITY -DSTM32F2 -DF_CPU=168000000UL -D__FPU_PRESENT=1)
#some adjustment to reduce heap usage.
cc.defines << %w(MRB_HEAP_PAGE_SIZE=64)
cc.defines << %w(MRB_IREP_ARRAY_INIT_SIZE=128u)
cc.defines << %w(MRB_USE_IV_SEGLIST)
cc.defines << %w(KHASH_DEFAULT_SIZE=8)
cc.defines << %w(MRB_STR_BUF_MIN_SIZE=20)
end
conf.cxx do |cxx|
cxx.command = conf.cc.command.dup
cxx.include_paths = cc.include_paths.dup
cxx.flags = conf.cc.flags.dup << %w(-fno-rtti -fno-exceptions)
#cxx.flags = conf.cc.flags.dup << %w(-fno-rtti)
cxx.defines = conf.cc.defines.dup
cxx.compile_options = conf.cc.compile_options.dup
end
conf.archiver do |archiver|
archiver.command = "#{ARM_TOOLCHAIN_PATH}/arm-none-eabi-ar"
end
conf.bins = []
#do not build executable test
conf.build_mrbtest_lib_only
#should be before any conf.gem line.
disable_cxx_exception
conf.gem :core => "mruby-toplevel-ext"
conf.gem :core => "mruby-string-ext"
#conf.gem "/Users/koji/work/mruby/mruby-arduino"
conf.gem :github => "kyab/mruby-arduino", :branch => "master"
conf.gem :github => "masamitsu-murase/mruby-hs-regexp", :branch => "master"
#include debug info
#conf.mrbc.compile_options << " -g"
#testing experimental thread support
# conf.cc.defines << ["ENABLE_THREAD"]
# conf.cxx.defines << ["ENABLE_THREAD"]
# conf.gem "/Users/koji/work/mruby/mruby-thread-freertos" do |g|
# #g.cc.include_paths << ["#{LIBMAPLE_PATH}/libraries/FreeRTOS"]
# g.cxx.include_paths << ["#{LIBMAPLE_PATH}/libraries/FreeRTOS"]
# end
end
MRuby::Build.new do |conf|
toolchain :clang
conf.gembox "default"
conf.cc.flags << %w(-DENABLE_READLINE -O0 -m64) #-arch i386 -arch x86_64
conf.cc.compile_options = "%{flags} -o %{outfile} -c %{infile}" #building universal binary dont allow -M
conf.linker.flags << %(-m64)
conf.linker.libraries << "edit" #OSX readline compatible library
# conf.gem "/Users/koji/work/mruby/mruby-bin-mirb-hostbased"
# conf.gem "/Users/koji/work/mruby/mruby-kycocoa"
#include debug info
conf.mrbc.compile_options << " -g"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment