goo blog サービス終了のお知らせ 

つれづれなるまゝに

単なる作業メモ。主に、Linux, arduino, raspberry piとか?

Macのgccをバージョンアップ

2014-09-25 22:21:57 | mac
mruby向けにGR SAKURAのクロスコンパイル環境の構築にトライ。
ちょうど今日はKyoto.rbだったので、そこで作業開始。

まずは、Macのgccを新しくしようと思って少しつまずいた。

入れ方としては、MacPortsをつかう方法とhomebrewをつかう方法の2つがある。
どっちにしようかまよったが、Homebrewを使うことにした。

MacPortsを使う方法は、こちらかな。

Homebrewを使う方法だが、最初、こちらを参考にしていた。
が、現在はhomebrew-dupesからgccはなくなっているもよう。

curl: (22) The requested URL returned error: 404 Not Found
Error: Failure while executing: /usr/bin/curl -f#LA Homebrew\ 0.9.5\ (Ruby\ 2.0.0-451;\ Mac\ OS\ X\ 10.9.4) https://raw.github.com/Homebrew/homebrew-dupes/master/gcc.rb -o /Library/Caches/Homebrew/Formula/gcc.rb

どうしたものかと思っていたら、隣の席のマイケルさんがhomebrew-versionsを使うのにかわったみたいだよ!と教えてくれた。ありがとうマイケルさん。
homebrew-versions使うと異なるバージョンのgccが入れれるようだ。便利~

brew tap homebrew/versions
brew install <flag> gcc48

今回はこんな感じでいれてみた。
brew install --enable-all-languages --use-llvm gcc48

この作業中で、勉強会は終了。いったん、レジューム。
帰って再開、ただいまmake中。時間はかかるなぁ。

(つづき)
1時間ちょいくらいで問題なくコンパイル完了して使えるようになりました。

次回は、クロス環境構築編です^^;

MacにRails環境

2014-08-04 19:54:02 | mac
Macにはデフォルトで2.0が入っていたが、Homebrewでrbenvつかって、最新の2.1.2を入れてみる。

ちょっと心配なのは、HomeBrew以外にも、armのクロス環境用にMacPortsを使っていてこちらを消せない(共存)する必要がある点。
まぁ、問題が起きたときに考えるか。

こちらを参考にインストール。
Ruby 2.1.0 install for Mac OSX

1点注意。readlineを入れておかないと、irbで日本語が使えない。なので、

brew install readline

も実行してからrubyをインストールする。

その後、railsをインストール。

gem install rails --version="4.1.4"

Shirasagiを試してみたいので、その環境にあわせた。<ruby & Rails

うーん、らくちん。

MacBook AirでのSTMicro Nucleoのデバッグ環境構築

2014-07-11 23:23:45 | mac
MacBook Airでマイコンの環境を構築してみる。

ターゲットボードとしては、STMicroのSTM32F401 Nucleoを選択。
最初としては、情報が多いDiscoveryにしておくのが無難だったかもしれないが、Nucleoは
1. mbed対応
2. Arduino互換
ということだったので。。。

mbedは使うかどうかわからない。(mbed対応のFRDM-KL25Zを持っていたが手をだしてない)
が、Arduino互換が決め手。とりあえず、SPI制御の勉強をしてみようとおもったので、WIZ550ioioShield for Arduinoを一緒に購入。

コアをCortex-M3にするかM4にするか悩んだが、持ってないM4を選んだ。DSPやMMUまで使う機会があるかはわからないが。。。

基本、以下のサイトを参考にした。
STM32F3DISCOVERY on Mac OS X using Eclipse, GCC ARM and OpenOCD

で、問題になってくるのはopenocdの設定。
こちらについては、以下のサイトを参考。
Openocd meets a NUCLEO-F030R8 board
上記サイトでは、M0のNUCLEOボードだが、基本接続はSTLink/V2-1経由なのでその辺りは流用でるかなと。

cfgファイルは以下のようにした。

stm32f4nucleo.cfg
--------------------
# Script for connecting with the STM32F4NCLEO board
source [find interface/stlink-v2-1.cfg]

# SRAM 96KB version chip
set WORKAREASIZE 0x18000
source [find target/stm32f4x_stlink.cfg]

reset_config srst_only srst_nogate
--------------------

変更点は、
1. SRAMサイズをF401用に96KBに変更
2. targetをSTM32F4に変更

まずは、openocdで接続

$ sudo openocd -f stm32f4nucleo.cfg
Open On-Chip Debugger 0.8.0 (2014-07-11-17:35)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.sourceforge.net/doc/doxygen/bugs.html
srst_only separate srst_nogate srst_open_drain connect_deassert_srst
Info : This adapter doesn't support configurable speed
Info : STLINK v2 JTAG v19 API v2 SWIM v3 VID 0x0483 PID 0x374B
Info : using stlink api v2
Info : Target voltage: 3.266094
Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints

で、gdbを動作させてみる。

$ arm-none-eabi-gdb -ex 'target extended-remote :3333'
GNU gdb (GDB) 7.5.1
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-apple-darwin13.3.0 --target=arm-none-eabi".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Remote debugging using :3333
0x00000000 in ?? ()
(gdb) monitor reset init
target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x08001f58 msp: 0x20002160
(gdb) monitor flash info 0
#0 : stm32f2x at 0x08000000, size 0x00080000, buswidth 0, chipwidth 0
# 0: 0x00000000 (0x4000 16kB) not protected
# 1: 0x00004000 (0x4000 16kB) not protected
# 2: 0x00008000 (0x4000 16kB) not protected
# 3: 0x0000c000 (0x4000 16kB) not protected
# 4: 0x00010000 (0x10000 64kB) not protected
# 5: 0x00020000 (0x20000 128kB) not protected
# 6: 0x00040000 (0x20000 128kB) not protected
# 7: 0x00060000 (0x20000 128kB) not protected
STM32F4xx (Low Power) - Rev: A
(gdb)

ということで、動いてる感じ。

今日はここまで