February 10, 2014

uClinux-dist (nommu) for Nios II on custom design

自前の FPGA デザインで nommu 版の uClinux for Nios2 を動かそうとすると、Qsys ではなく .ptf を生成する SOPC Builder でないとすんなりいかない模様。Quartus II v12.x まで戻れば SOPC Builder が入っていたが、UniPHY を使うと Are there any issues with using the UniPHY EMIF toolkit with SOPC builder projects? [altera.com] という問題があるらしいので、v10.1 まで戻り(v11.0でもよさそうだが)デザインを作り、まず HAL を使った OS なしのプログラムが動くことを確認。先日の uClinux-dist (nommu) build for Nios II [blogspot.jp] と同様にカーネルとユーザランドをビルドし、JTAG で通常の ELF ファイルをロードするように nios2-download で images/zImage をダウンロード、実行(場合によりリセットも)すると uClinux がブートした。

February 7, 2014

Memory Leak Patch to Homebrew Emacs 24.3 on OS X Mavericks

OS X Mavericks 上の Emacs 24.3 で distnoted が暴走する問題、This is a patch (with commentary) that fixes a memory leak in 24.3 for OSX Mavericks (10.9) users who experience excessive resource consumption by distnoted. [github.com] のパッチを当てるという対策で落ち着いて来た模様(?)。Homebrew では他にも Backport of Emacs master's fullscreen mode to Emacs 24.3 [github.com] パッチや、--japanese オプションを付けてインストールすると File Details: /inline_patch/trunk/emacs-inline.patch (583) - macemacsjp (svn) - MacEmacs JP - SourceForge.JP [sourceforge.jp] パッチがあたる。パッチがあたるファイルが一部重複していたが、Hunk #n succeeded でなんとかパッチが適応でき、順番はあまり気にしなくてもよさそう。
$ brew edit emacs
$ brew reinstall emacs
参考文献
  1. distnoted が原因でEmacsが落ちるのを防ぐemacs.rb [qiita.com]
  2. emacsやdistnotedを安定させるパッチをhomebrewで適用した [n-z.jp]

(February 8, 2014 追記)
折角なので今回は Formula Cookbook [github.com] に従い Pull Request してみた。 (February 9, 2014 追記)
早速取り込んでいただけた模様。
commit message の英文法が間違ってるのが恥ずかしい。オープンソース活動はスヌープされても問題ないから、英文構成サービス使うべし。

February 5, 2014

uClinux-dist (nommu) build for Nios II

FPGA ボードで学ぶ組込みシステム開発入門 ~Altera編~サポートページ [gihyo.jp] の SOPC Builder 版 DE0 のデザインでカーネルとユーザランドをビルドしてみた。
ホスト環境: RedHat 5 x86_64

デザインをダウンロード、展開
$ wget http://image.gihyo.co.jp/assets/files/book/2011/978-4-7741-4839-7/download/DE0.ZIP
$ unzip DE0.ZIP

ビルドに必要なツールをインストール
# yum install git-all git-gui make gcc ncurses-devel bison byacc flex \
gawk gettext ccache zlib-devel gtk2-devel lzo-devel pax-utils libglade2-devel uboot-tools
Install Nios II Linux [alterawiki.com] のパッケージ指定にタイポがあり pax-utils と libglade2-devel の間にスペースが必要

クロスコンパイラをダウンロード、展開
$ wget ftp://ftp.altera.com/outgoing/nios2-linux/nios2gcc-20080203.tar.bz2
$ tar jxvf nios2gcc-20080203.tar.bz2
$ export PATH=$PWD/opt/unios2/bin:$PATH

uClinux-dist をビルド
Install Nios II Linux [alterawiki.com] や Downloading Linux Distribution [alterawiki.com] によると、nommu の場合は test-nios2 ブランチになっているらしい。
$ wget http://sopc.et.ntust.edu.tw/pub/linux/nios2-linux-20100621.tar
$ tar xvf nios2-linux-20100621.tar
$ cd nios2-linux/linux-2.6
$ git checkout test-nios2
$ cd ../uClinux-dist
$ git checkout test-nios2
$ make menuconfig
$ make vendor_hwselect SYSPTF=$HOME/DE0/dai9sho/uclinux/uclinux_sopc.ptf
$ make
$ file images/zImage
images/zImage: ELF 32-bit LSB executable, version 1 (embedded), statically linked, not stripped
ptf ファイルは絶対パスで指定する必要あり。