いろんなシステムを開発する時に、カーネルソフトがあるとたいへん便利である。
調べたら、TOPPERSというフリーのiTron4カーネルソフトがあった。
http://www.toppers.jp/index.html
すでにH8/300H 3052Fにポーティングされているので、きっと簡単にインストールできるだろう。
http://www.toppers.jp/download.cgi/jsp-1.4.1.tar.gz
をダウンロードして、展開する。
まずは、コンフィギュレーションツールの作成。
% cd cfg
% make depend
% make
コンパイルがむちゃくちゃ遅いが、なんとか終了。
次に、サンプルプログラムの構築。
% cd ..
% mkdir sampleobj
% cd sampleobj
% ../configure -C h8 -S akih8_3052f
Makefileを少々修正する。
CPU = h8
SYS = akih8_3052f
TOOL =
% make depend
rm -f Makefile.depend
h8300-hms-gcc -S -mh -mint32 -mrelax -O2 -DCPU_CLOCK=25000000 -DLABEL_ASM -DAKI_MONITOR -I. -I../include -I/Users/shibuya/work/h8/include -I../config/h8/akih8_3052f -I../config/h8 -I../kernel ../config/h8/makeoffset.c
make: h8300-hms-gcc: Command not found
make: *** [makeoffset.s] Error 127
私がインストールしたクロスコンパイラの位置を無視しているので、jsp/config/h8/Makefile.configを修正。
TARGET = h8300-hms
を
TARGET = /Users/shibuya/work/h8/bin/h8300-hms
に変える。
あらためて、sampleobjディレクトリ内で、
% make depend
% make
.....
../cfg/chk -m jsp.syms,jsp.srec \
-obj -cs jsp.chk -cpu h8 -system akih8_3052f
Program failed in its process by following reason.
Internal error: Unknown symbol (Probably, Symbol table was stripped)
make: *** [jsp] Error 1
と、エラーを起こして止まった。
このエラーメッセージをgoogleで検索したら、TOPPERSのメーリングリストでも話題になっていた。
http://www.toppers.jp/TOPPERS-USERS/200501/msg00018.html
なるほど。
jsp/config/h8/Makefile.configを再び修正。
COPTS := $(COPTS) -mh -mint32 -mrelax -O2
を
COPTS := $(COPTS) -mh -mint32 -mrelax -O1
に修正。
% make clean;make
無事コンパイル完了。jsp.srecというファイルが出来上がった。
これを、
% h8load jsp.srec
でAKI-LANに送り込み、
% minicom
とやったら、
E_OBJ reported by `serial_rea_dat(TASK_PORTID, &c, 1)' in line 288 of `sample1..
というのが延々と出続けていた。まぁ、とりあえずなんか動いてはいるようだ。
もっとシンプルなサンプルプログラムを作ってみよう。
% /Users/shibuya/work/h8/jsp
% mkdir mysample
% cd mysample
% ../configure -C h8 -S akih8_3052f
これで出来たsample1.c, sample1.h, sample1.cfgを次のようにばっさりと書き換える。
File: sample1.c
#include <t_services.h>
#include "kernel_id.h"
#include "lcd.h"
#include "3052.h"
/* Main Task */
void main_task(VP_INT exinf)
{
int pa;
char str[16];
PA.DDR = 0x00;
PB.DDR = 0xff;
PB.DR.BYTE = 0x0f;
LCDInit();
LCDDisplay("Hello my boy!",0);
while(1){
pa = PA.DR.BYTE&0x0f;
sprintf(str,"PA=%1X",0x0f&~pa);
LCDDisplay(str,1);
PB.DR.BYTE = pa;
}
kernel_exit();
}
File: sample1.h
#ifndef SAMPLE1_H
#define SAMPLE1_H
#include <t_services.h>
#define MAIN_PRIORITY 5
#ifndef _MACRO_ONLY
extern void main_task(VP_INT exinf);
#endif /* _MACRO_ONLY */
#endif /* SAMPLE1_H */
File: sample1.cfg
#define _MACRO_ONLY
#include "sample1.h"
INCLUDE("\"sample1.h\"");
CRE_TSK(MAIN_TASK, { TA_HLNG|TA_ACT, 0, main_task, MAIN_PRIORITY,
STACK_SIZE, NULL });
#include "../systask/timer.cfg"
#include "../systask/serial.cfg"
#include "../systask/logtask.cfg"
また、Makefileは次のように変える。
あと、タイマ割り込み実験をする前の古いlcd.c, lcd.hをコピーしてくる。
さて。
% make depend; make
これで、jsp.srecが出来上がるので、
% h8load jsp.srec
でAKI-LANにダウンロード、実行。
ちゃんと動いているようだ。