トップ «前の日記(2014-12-21) 最新 次の日記(2014-12-23)» 編集

ヨタの日々

2001|08|09|10|11|12|
2002|01|02|03|04|05|06|07|08|09|10|11|12|
2003|01|02|03|04|05|06|07|08|09|10|11|12|
2004|01|02|03|04|05|06|07|08|09|10|11|12|
2005|01|02|03|04|05|06|07|08|09|10|11|12|
2006|01|02|03|04|05|06|07|08|09|10|11|12|
2007|01|02|03|04|05|06|07|08|09|10|11|12|
2008|01|02|03|04|05|06|07|08|09|10|11|12|
2009|01|02|03|04|05|06|07|08|09|10|11|12|
2010|01|02|03|04|05|06|07|08|09|10|11|12|
2011|01|02|03|04|05|06|07|08|09|10|11|12|
2012|01|02|03|04|05|06|07|08|09|10|11|12|
2013|01|02|03|04|05|06|07|08|09|10|11|12|
2014|01|02|03|04|05|06|07|08|09|10|11|12|
2015|01|02|03|04|05|06|07|08|09|10|11|12|
2016|01|02|03|04|05|06|07|08|09|10|11|12|
2017|01|02|03|04|05|06|07|08|09|10|11|12|
2018|01|02|03|04|05|06|07|08|09|10|11|12|
2019|01|02|03|04|05|06|07|08|09|10|11|12|
2020|01|02|03|04|05|06|07|08|09|10|11|12|
2021|01|02|03|04|05|06|07|08|09|10|11|12|
2022|01|02|03|04|05|06|07|08|09|10|11|12|
2023|01|02|03|04|05|06|07|08|12|
2024|01|02|03|04|05|06|07|08|09|10|11|12|
2025|01|02|03|04|

2014-12-22 :-(

_ this.age++;

37 歳のおっさんです。

恥の多い生涯を送って来ました。

_ 午前

0530 起床

0700 食堂

0830 労働

_ 午後

1300 労働

_

1700 残業アワー

2100 退勤

2200 飯

2300 aspうーん

_ [RTOS][μiTRON][TOPPERS/ASP][H3]TOPPERS/ASP のサンプルを動作させてみた

参考

TOPPERS/ASP on AKI-H8-3069

環境

  • Microsoft Windows7 64bit
  • VMware Player
  • NetBSD 6.1.5 i386

ようするに Windows 上の VMware Player のゲスト OS が NetBSD である[ 20120629#p07 ]。なお USB 変換ケーブルを接続した箇所を変えたためか、COM は 3 ではなく 5 になっていたので VMware の vmx ファイルを変更しておくべし。

serial0.present = "TRUE"
serial0.fileName = "COM5"

v01.png

コンフィギュレータの構築

手順は doc/user.txt の通りではある。予め /usr/pkgsrc/meta-pkgs/boost をインストールしておくこと。

% cd cfg
% ./configure --with-headers=/usr/pkg/include --with-libraries=/usr/pkg/lib

make すると怒られるのでいろいろ変更。

% gmake

 :

c++  -O2   -I/usr/pkg/include -I../.. -c static_api.cpp
ar rcs libitronx.a cfg1_out.o checker.o component.o factory.o preprocess.o static_api.o
make BOOST_DIR="/usr/pkg/include" LIBBOOST_SUFFIX="" CXXFLAGS="-O2 " -C cfg
make: "/home/rin/work/OS/asp/cfg/cfg/Makefile" line 20: Missing dependency operator
make: "/home/rin/work/OS/asp/cfg/cfg/Makefile" line 22: Need an operator
make: "/home/rin/work/OS/asp/cfg/cfg/Makefile" line 24: Need an operator
make: Fatal errors encountered -- cannot continue
make: stopped in /home/rin/work/OS/asp/cfg/cfg
gmake: *** [cfg] エラー 1

$OSTYPE は定義されている。しかし文法としてエラーになっている。わけわからん

% echo $OSTYPE
netbsdelf

msys じゃないし、コメントアウトして回避。

#ifeq ($(OSTYPE), msys)
#	BOOST_LIBFILES = /mingw/lib/libboost_system-mgw-mt-s.lib /mingw/lib/libboost_filesystem-mgw-mt-s.lib /mingw/lib/libboost_program_options-mgw-mt-s.lib
#else
#	BOOST_LIBFILES := $(BOOST_LIBFILES) -lboost_system$(LIBBOOST_SUFFIX) -lboost_filesystem$(LIBBOOST_SUFFIX) -lboost_program_options$(LIBBOOST_SUFFIX)
#endif

BOOST_LIBFILES := $(BOOST_LIBFILES) -lboost_system$(LIBBOOST_SUFFIX) -lboost_filesystem$(LIBBOOST_SUFFIX) -lboost_program_options$(LIBBOOST_SUFFIX)

ok

% gmake

サンプルプログラムの構築と実行

% cd asp
% mkdir OBJ
% cd OBJ
% perl ../configure -T akih8_3069f_gcc
Use of "do" to call subroutines is deprecated at ../configure line 77.
Use of "do" to call subroutines is deprecated at ../configure line 101.
Use of "do" to call subroutines is deprecated at ../configure line 169.
Use of "do" to call subroutines is deprecated at ../configure line 175.
Use of "do" to call subroutines is deprecated at ../configure line 182.
Use of "do" to call subroutines is deprecated at ../configure line 188.
Use of "do" to call subroutines is deprecated at ../configure line 212.
Use of "do" to call subroutines is deprecated at ../configure line 247.
Use of "do" to call subroutines is deprecated at ../configure line 263.
Use of "do" to call subroutines is deprecated at ../configure line 264.
Use of "do" to call subroutines is deprecated at ../configure line 265.
Use of "do" to call subroutines is deprecated at ../configure line 266.
Use of "do" to call subroutines is deprecated at ../configure line 267.
Can't locate getopt.pl in @INC (@INC contains: /home/rin/usr/local/lib/perl /usr/pkg/lib/perl5/site_perl/5.18.0/i386-netbsd-thread-multi /usr/pkg/lib/perl5/site_perl/5.18.0 /usr/pkg/lib/perl5/vendor_perl/5.18.0/i386-netbsd-thread-multi /usr/pkg/lib/perl5/vendor_perl/5.18.0 /usr/pkg/lib/perl5/5.18.0/i386-netbsd-thread-multi /usr/pkg/lib/perl5/5.18.0 .) at ../configure line 43.

getopt.pl はレガシーなので configure を変更( perl5120delta - perl v5.12.0 での変更点 - perldoc.jp Getopt::Std - perldoc.perl.org )

#require "getopt.pl";
use Getopt::Std;
#do Getopt("TAaULDltmdpg");
getopt("TAaULDltmdpg");

再度。ok

% perl ../configure -T akih8_3069f_gcc

さて、make すると怒られるのでいろいろ変更。

% gmake depend
if ! [ -f Makefile.depend ]; then \
        rm -f kernel_cfg.timestamp kernel_cfg.c kernel_cfg.h ; \
        rm -f cfg1_out.c cfg1_out.o cfg1_out cfg1_out.syms cfg1_out.srec; \
        rm -f makeoffset.s offset.h; \
fi
rm -f Makefile.depend
../cfg/cfg/cfg --pass 1 --kernel asp -I. -I../include -I../arch -I..  -I../target/akih8_3069f_gcc --api-table ../kernel/kernel_api.csv --cfg1-def-table ../kernel/kernel_def.csv  --cfg1-def-table ../arch/h8300h_gcc/core_def.csv sample1.cfg
Shared object "libboost_system.so.1.57.0" not found
gmake: *** [cfg1_out.c] エラー 1

boost ライブラリの位置を指定することにした。さっき configure 時に指定したのはなんなの....

% LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/pkg/lib; gmake depend
if ! [ -f Makefile.depend ]; then \
        rm -f kernel_cfg.timestamp kernel_cfg.c kernel_cfg.h ; \
        rm -f cfg1_out.c cfg1_out.o cfg1_out cfg1_out.syms cfg1_out.srec; \
        rm -f makeoffset.s offset.h; \
fi
rm -f Makefile.depend
../cfg/cfg/cfg --pass 1 --kernel asp -I. -I../include -I../arch -I..  -I../target/akih8_3069f_gcc --api-table ../kernel/kernel_api.csv --cfg1-def-table ../kernel/kernel_def.csv  --cfg1-def-table ../arch/h8300h_gcc/core_def.csv sample1.cfg
h8300-hms-gcc -c  -D__H8_3069F__ -mh -mint32 -mrelax  -g -Wall -O2  -DTNCT_MONITOR -I. -I../include -I../arch -I..  -I../target/akih8_3069f_gcc   -DALLFUNC  -I../kernel cfg1_out.c
h8300-hms-gcc -c  -D__H8_3069F__ -mh -mint32 -mrelax  -g -Wall -O2  -DTNCT_MONITOR -I. -I../include -I../arch -I..  -I../target/akih8_3069f_gcc -DALLFUNC  -I../kernel ../arch/h8300h_gcc/start.S
h8300-hms-gcc  -D__H8_3069F__ -mh -mint32 -mrelax  -g -Wall -O2  -DTNCT_MONITOR -I. -I../include -I../arch -I..  -I../target/akih8_3069f_gcc -nostdlib  -T ../target/akih8_3069f_gcc/debug.ld  -o cfg1_out \
                                         cfg1_out.o
h8300-hms-nm -C cfg1_out > cfg1_out.syms
h8300-hms-objcopy -O srec -S cfg1_out cfg1_out.srec
../cfg/cfg/cfg --pass 2 --kernel asp -I. -I../include -I../arch -I..  -I../target/akih8_3069f_gcc \
                        -T ../target/akih8_3069f_gcc/target.tf --api-table ../kernel/kernel_api.csv --cfg1-def-table ../kernel/kernel_def.csv  --cfg1-def-table ../arch/h8300h_gcc/core_def.csv sample1.cfg
touch kernel_cfg.timestamp
../cfg/cfg/cfg --pass 3 --kernel asp -I. -I../include -I../arch -I..  -I../target/akih8_3069f_gcc \
                        --rom-image cfg1_out.srec --symbol-table cfg1_out.syms \
                        -T ../arch/h8300h_gcc/core_offset.tf --api-table ../kernel/kernel_api.csv --cfg1-def-table ../kernel/kernel_def.csv  --cfg1-def-table ../arch/h8300h_gcc/core_def.csv sample1.cfg
check complete
Generating Makefile.depend.
sh: ../utils/makedep: not found
gmake: *** [cfg1_out.d] エラー 127

次のエラー。

utils/makedep のシェバングを変更

#! /usr/pkg/bin/perl

あと getopt.pl を使ってる箇所があるので変更

#require "getopt.pl";
use Getopt::Std;
#do Getopt("TAaULDltmdpg");
getopt("TAaULDltmdpg");

再度 make depend 。ok

% LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/pkg/lib; gmake depend

そして make depend

% LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/pkg/lib; gmake

生成されるのは asp というファイルである。

#
#  オブジェクトファイル名の定義
#
OBJNAME = asp
ifdef OBJEXT
  OBJFILE = $(OBJNAME).$(OBJEXT)
  CFG1_OUT = cfg1_out.$(OBJEXT)
else
  OBJFILE = $(OBJNAME)
  CFG1_OUT = cfg1_out
endif

はずなんだが。。。

asp.srec らしい。ふむ

% file asp.srec
asp.srec: Motorola S-Record; binary data in text format

簡易モニタを書き込む

失敗した。

mogu# kz_h8write -3069 -f20 mon3069.mot /dev/tty00
=================================================
 H8/3069F Flash Writer for KOZOS (Version 0.2.1)
 Copyright(C) 2011-2012 Shinichiro Nakamura
=================================================
Bitrate sequence failed. (code=0x04)

うーん?

試しに kz_h8write (H8/3069F writer for KOZOS (kz_h8write)) 付属の example を焼いてみる。成功した。うーん?

% cd kz_h8write-v0.2.1/PackageFiles/example
% sudo kz_h8write -3069 -f20 kzload.mot /dev/tty00
=================================================
 H8/3069F Flash Writer for KOZOS (Version 0.2.1)
 Copyright(C) 2011-2012 Shinichiro Nakamura
=================================================
Bitrate sequence: Done.
Inquiry device: Done.
Select device: Done.
Inquiry clock mode: Done.
Select clock mode: Done.
Select bitrate: Done.
Waiting for erase done:...
Programming:......................
Program: Done.
Complete.

じゃあさっきエラーになった箇所を追ってみる。メッセージからするとこの関数で失敗している。

kz_h8write.c

    /*
     * ビットレート合わせ込みのシーケンスを実行する。
     *
     * ビットレート合わせ込みシーケンスに初回時失敗する事がある。
     * マイコンの電源投入時やシリアルケーブル接続時に
     * プロセッサのUARTポートに意図しない信号が入る事が考えられる。
     *
     * そこで、本プログラムでは数回の試行を行うことにした。
     * これはユーザがかけている手間をプログラムが代行する事を意味する。
     */
    for (int i = 0; i < 2; i++) {
        ec = bitrate_sequence(serial);
        if (ec == NoError) {
            break;
        } else {
            /*
             * デバッグ用出力。
             *
             * ビットレートシーケンスは初回に失敗する可能性がある。
             * これに対してエラーを表示してしまうとユーザが混乱する。
             * よってデバッグ用出力としての位置づけにしておく。
             * リトライした結果として成功した事を知りたい時にのみ
             * 表示を有効にすると良い。
             */
            if (USER_OPTION_DEBUG(&user_option)) {
                fprintf(stderr, "Bitrate sequence failed.\n");
            }
        }
    }
    if (ec != NoError) {
        fprintf(stderr, "Bitrate sequence failed. (code=0x%02x)\n", (int)ec);
        PROGEXIT(1);
    }

bitrate_sequence() はこれ。しかし何が返ってるのか分からん。

/**
 * @brief ビットレート合わせ込みのシーケンスを実行する。
 *
 * @details
 * ビットレートの合わせ込みは以下のシーケンスで行う。
 * 1. 0x00を最大30回送信する。
 * 2. 合わせ込みが完了すると0x00が返る。
 * 3. この時点で0x55を送信する。
 * 4. レスポンスコードが返る。
 *    成功:0xE6
 *    失敗:0xFF
 *
 * @param serial シリアルハンドラ。
 *
 * @return エラーコード。
 */
enum ErrorCode bitrate_sequence(SERIAL *serial)
{
    unsigned char sc, rc;
    int i;
    for (i = 0; i < 30; i++) {
        /*
         * ビットレート計測用マーカを送信する。
         */
        sc = 0x00;
        if (serial_write(serial, &sc, 1) != 0) {
            return SerialWriteError;
        }
        /*
         * 何かを受信したらコードを確認する。
         * コードが正しければ応答を行い、そのレスポンスを検証する。
         */
        if (serial_read_with_timeout(serial, &rc, 1, SERIAL_TIMEOUT_MS) == 0) {
            if (rc != 0x00) {
                /*
                 * 最初の応答は0x00のはず。
                 */
                return InvalidPrimaryResponseCode;
            }
            sc = 0x55;
            if (serial_write(serial, &sc, 1) != 0) {
                return SerialWriteError;
            }
            if (serial_read_with_timeout(serial, &rc, 1, SERIAL_TIMEOUT_MS) != 0) {
                /*
                 * 0x55に対する応答があるはず。
                 */
                return NoSecondaryResponseCode;
            }
            if (rc == 0xe6) {
                return NoError;
            } else {
                /*
                 * 2回目の応答は0xe6のはず。
                 */
                return InvalidSecondaryResponseCode;
            }
        }
    }
    /*
     * レスポンスが全くない。
     */
    return NoPrimaryResponseCode;
}

SerialWriteError 等を grep してみるとこの enum に到達。NoPrimaryResponseCode を返していた。うーん? 電源は入ってるしなあ...

/**
 * @brief エラーコード。
 */
enum ErrorCode {
    NoError = 0,
    SerialOpenError,
    SerialWriteError,
    InvalidPrimaryResponseCode,
    NoPrimaryResponseCode,           <==== これ
    InvalidSecondaryResponseCode,
    NoSecondaryResponseCode,
    UnsupportedDevice,
    UnmatchedDeviceCode,
    UnsupportedClockMode,
    UnmatchedClockMode,
    InvalidBitrate,
    WriteEraseFail,
};

もう一回やってみる。成功した。えー

% cd h8mon/mon3069
% sudo kz_h8write -3069 -f20 mon3069.mot  /dev/tty00
=================================================
 H8/3069F Flash Writer for KOZOS (Version 0.2.1)
 Copyright(C) 2011-2012 Shinichiro Nakamura
=================================================
Bitrate sequence: Done.
Inquiry device: Done.
Select device: Done.
Inquiry clock mode: Done.
Select clock mode: Done.
Select bitrate: Done.
Waiting for erase done:....
Programming:................................................................
Program: Done.
Complete.

サンプルプログラムを書き込む

ビルドしたサンプルのディレクトリへ移動。

% cd asp/OBJ

接続。

% sudo cu -s 38400 -l /dev/tty00
Connected

基板のリセットを押す。ok

1:H8/3069F Monitor v1.12 Copyright (C) 1999-2004 CSE Tomakomai NCT

ロードさせる

1:ld
~>Local file name?asp.srec

go する。何か起動した

1:go

TOPPERS/ASP Kernel Release 1.7.0 for AKI-H8/3069F (Dec 21 2014, 19:47:12)
Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
                            Toyohashi Univ. of Technology, JAPAN
Copyright (C) 2004-2011 by Embedded and Real-Time Systems Laboratory
            Graduate School of Information Science, Nagoya Univ., JAPAN
Copyright (C) 2001-2010 by Industrial Technology Institute,
                            Miyagi Prefectural Government, JAPAN
Copyright (C) 2001-2004 by Dep. of Computer Science and Engineering
                 Tomakomai National College of Technology, JAPAN
Copyright (C) 2008 by GELJET Designing Center RICOH COMPANY,LTD.

System logging task is started on port 1.
Sample program starts (exinf = 0).
task1 is running (001).   |
task1 is running (002).   |
task1 is running (003).   |
task1 is running (004).   |
task1 is running (005).   |
task1 is running (006).   |
task1 is running (007).   |
task1 is running (008).   |
task1 is running (009).   |
task1 is running (010).   |
task1 is running (011).   |
task1 is running (012).   |
task1 is running (013).   |
task1 is running (014).   |
task1 is running (015).   |
task1 is running (016).   |
task1 is running (017).   |
-- buffered messages --             Ctrl-C 叩いた
Sample program ends.
本日のツッコミ(全2件) [ツッコミを入れる]
_ けなく (2014-12-23 07:46)

おめでとうございますm(_ _)m

_ みわ (2014-12-23 23:08)

かたじけない (´・ω・)