修理日記。

修理は楽しく自己責任で!

【自分用】H8linux覚え書き2

2011-06-09 00:06:27 | 組み込み系
初回投稿 : 2011-06-09 00:06:27

ターゲットで Hello World

■ホストで実行

# mkdir /opt/uClinux-dist/myapp
# cd /opt/uClinux-dist/myapp
# vi hello.c
---
#include <stdio.h>
int main(void)
{
printf("Hello, uClinux/H8!!(^o^)/\n");
return 0;
}
---

# vi makefile
---
TARGET=hello
SRCS=hello.c

CC=h8300-linux-elf-gcc
CFLAGS=-mh -mint32 -Os -fno-builtin -nostartfiles -nostdinc
LDFLAGS=-Wl,-elf2flt
STARTUP=../lib/crt0.o
INCLUDES=-I../include -I../include/include
LIBS=-L../lib -lc

OBJS=$(SRCS:.c=.o)

.c.o :
$(CC) $(CFLAGS) $(INCLUDES) $(SRCS) -c $<

$(TARGET) : $(OBJS)
$(CC) $(CFLAGS) $(INCLUDES) $(LDFLAGS) $(STARTUP) $(LIBS) $(OBJS) -o $(TARGET)
---

# make
h8300-linux-elf-gcc -mh -mint32 -Os -fno-builtin -nostartfiles -nostdinc -I../include -I../include/include hello.c -c hello.c
hello.c:6:2: warning: no newline at end of file
hello.c:6:2: warning: no newline at end of file
h8300-linux-elf-gcc -mh -mint32 -Os -fno-builtin -nostartfiles -nostdinc -I../include -I../include/include -Wl,-elf2flt ../lib/crt0.o -L../lib -lc hello.o -o hello

# cp hello /tftpboot/nfsroot/bin


■ターゲットで実行

# cd bin
# hello
Hello, uClinux/H8!!(^o^)/
#

【自分用】H8linux覚え書き

2011-06-08 22:33:28 | 組み込み系
初回投稿 : 2011-05-01 00:59:13
最終更新 : 2011-06-08 22:33:28


■ホストの情報
ディストリビューション : Vine Linux 5.2
IPアドレス : 192.168.1.100


■必要なファイルがあるところ(AE3069)
http://uclinux.quake4.jp/uClinux/

★最低限必要なもの
h8tools_bin.tar.gz (クロス開発環境)
redboot_std_2mb.srec (2MB用RedBoot)
uClinux-dist-sbcrbook20070218.tar.gz (uClinuxカーネル一式)
h8write_bin.tar.gz (H8書き込みツール/Linux用)

# uclinux_root.tar.gz (ルート)


■必要なファイルがあるところ(KaneBeBe)
http://csun.co.jp/hpgen/HPB/entries/3.html

★最低限必要なもの
h8tools_bin.tar.gz (クロス開発環境)
redboot4m.mot (4MB対応RedBoot)
uClinux-dist-h8kane20081001.tar.gz (uClinuxカーネル一式)
write-flash.zip (H8書き込みツール/Windows用)

# h8nfs26.bin (NFS対応カーネル2.6/バイナリ)
# rootfs.tar.gz (ルート)



■開発環境のインストールとuClinux-H8のビルド(ホスト)

# tar xzvpf h8tools_bin.tar.gz -C /opt
# tar xzvpf uClinux-dist-sbcrbook20070218.tar.gz -C /opt

# vi /root/.bashrc
export PATH=$PATH:/opt/bin

# vi /opt/uClinux-dist/uClibc/.config
UCLIBC_HAS_GLOB=y ←変更

# vi /opt/uClinux-dist/vendors/Akizuki/AE3068/config.uClibc
UCLIBC_HAS_GLOB=y ←変更



# cd /opt/uClinux-dist
# make clean
# make menuconfig

Vendor/Product Selection
→Vender (Akizuki)
→Akizuki Products (AE3068)
[Exit]で抜ける

Kernel/Library/Defaults Selection
→Kernel Version (linux-2.4.x)
→Libc Version (uClibc)
[*] Default all settings
[*] Customize Kernel Settings
[*] Customize Vendor/User Settings
[ ] Update Default Vendor Settings

[Exit]で抜ける
[Exit]で抜ける
[Y]で新しい設定を保存

Block devices
[ ] ROM disk memory block device(blkmem)
[Exit]で抜ける

Networking options
[*] TCP/IP networking
[*] IP: kernel level autoconfiguration
[*] IP: DHCP support (NEW)
[Exit]で抜ける

File systems
[ ] ROM file system support
Network File Systems
[*] NFS file system support
[*] Provide NFSv3 client support
[*] Root file system on NFS

[Exit]で抜ける
[Exit]で抜ける
[Exit]で抜ける
[Y]で新しい設定を保存

CoreApplecations
(sash) Shell Program
( ) Sash
(X) nwsh
[Exit]で抜ける

Network Applications
[*] thttpd
[Exit]で抜ける

BusyBox
[*] echo
[*] echo: fancy (NEW)
[*] free

[Exit]で抜ける
[Exit]で抜ける
[Y]で新しい設定を保存

# make dep
# make


■カーネルを/tftpbootにコピー(ホスト)

# mkdir /tftpboot
# chown nobody:nobody /tftpboot
# objcopy -I srec -O binary /opt/uClinux-dist/linux-2.4.x/linux /tftpboot/linux_nfsroot.bin


■tftp-server 0.42-4vl5のインストールと設定(ホスト)
(Synaptic Install)

# vi /etc/xinetd.d/tftp

service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /tftpboot
disable = no
per_source = 11
cps = 100 2
flags = IPv4
}

# /etc/init.d/xinetd restart
xinetdを停止中: [ OK ]
xinetdを起動中: [ OK ]

Windowsで確認する場合は、ファイアウォールを止めておくこと。
WindowsからTFTPClient LEでファイルを取得できることを確認。


■DHCP Server 4.1.0p1の設定(ホスト)
(Preinstalled)

# vi /etc/dhcp/dhcpd.conf

default-lease-time 21600;
max-lease-time 43200;
ddns-update-style ad-hoc;

subnet 192.168.1.0 netmask 255.255.255.0 {
option broadcast-address 192.168.1.255;
option subnet-mask 255.255.255.0;
option routers 192.168.1.100;
option domain-name-servers 192.168.1.100;
option netbios-name-servers 192.168.1.100;
range 192.168.1.101 192.168.1.110;
}

host kanebebe {
hardware ethernet 00:02:cb:02:1e:2c;
fixed-address 192.168.1.105;
}

# /etc/init.d/dhcpd start
dhcpdを起動中: [ OK ]

# mv /etc/rc5.d/k35dhcpd /etc/rc5.d/S35dhcpd


■nfs-utils 1.1.5-3vl5の設定(ホスト)
# vi /etc/exports

/tftpboot/nfsroot 192.168.1.0/255.255.255.0(rw,insecure,sync,no_root_squash)

# mkdir /tftpboot/nfsroot
# cp --archive /opt/uClinux-dist/romfs/* /tftpboot/nfsroot/

# cd /tftpboot/nfsroot/dev
# mknod console c 5 1
# mknod ttySC0 c 204 8
# mknod ttySC1 c 204 9
# mknod ttySC2 c 204 10
# mknod null c 1 3
# rm -f \@*

# vi /etc/hosts.allow
rpc.mountd: ALL
portmap: ALL
rquotad: ALL
mountd: ALL
statd: ALL

# exportfs -a

# /etc/rc.d/init.d/nfs restart
NFS mountdを停止中: [ OK ]
NFSデーモンを停止中: [ OK ]
NFS quotaを停止中: [ OK ]
NFSサービスを停止中: [ OK ]
NFSサービスを起動中: [ OK ]
NFS quotaを起動中: [ OK ]
NFSデーモンを起動中: [ OK ]
NFS mountdを起動中: [ OK ]

# showmount -e localhost
Export list for localhost:
/tftpboot/nfsroot 192.168.1.0/255.255.255.0


VMware上のVineにnfsrootをマウントできることを確認。

# mount -t nfs 192.168.1.100:/tftpboot/nfsroot /mnt/nfsroot
# ls
cdrom/ hgfs/ nfsroot/
# cd nfsroot/
# ls
bin/ dev/ etc/ home/ lib/ mnt/ proc/ sbin@ tmp@ usr/ var/


■秋月のUSBシリアル変換ケーブル(PL2303)の認識確認(ホスト)

# ls /dev/ttyUSB0
/dev/ttyUSB0


■minicom 2.5のインストール(ホスト)

# tar xzvpf minicom-2.5.tar.gz -C /opt

# ./configure
# make
# make install


■h8writeの展開(ホスト)

# tar xzvpf h8write_bin.tar.gz -C /opt


■RedBootの書き込み(ホスト)

H8ボードのDIP-SW設定(AE3069)
1 2 3 4
ON ON OFF ON

H8ボードのDIP-SW設定(KaneBeBe)
1 2 3 4
OFF OFF ON OFF

AE3069
# ./h8write -3069 -f20 redboot_std_2mb.srec /dev/ttyUSB0

KaneBeBe
# ./h8write -3069 -f25 redboot4m.mot /dev/ttyUSB0


H8/3069F is ready! 2002/5/20 Yukio Mituiwa.
writing
WARNING:This Line dosen't start with"S".
Address Size seems wrong
WARNING:This Line dosen't start with"S".
Address Size seems wrong
..............................................................................................................

..............................................................................................................

..............................................................................................................

..............................................................................................................

..............................................................................................................

..............................................................................................................

..............................................................................................................

..............................................................................................................

.................................................................................................
EEPROM Writing is successed.


■RedBootの起動(ターゲット)

# minicom
minicom の通信ポート設定
38400 8N1


H8ボードのDIP-SW設定(AE3069)
1 2 3 4
ON OFF ON OFF

H8ボードのDIP-SW設定(KaneBeBe)
1 2 3 4
OFF ON OFF ON


H8ボードの電源を入れる

**Warning** FLASH configuration checksum error or invalid key

Use 'fconfig -i' to [re]initialize database

DP83902A - eeprom ESA: 00:02:cb:03:16:15

... waiting for BOOTP information

Ethernet eth0: MAC address 00:02:cb:03:16:15

Can't get BOOTP info for device!



RedBoot(tm) bootstrap and debug environment [ROM]

Non-certified release, version UNKNOWN - built 14:54:02, Dec 21 2006



Platform: Akizuki H8/3068 Network micom (H8/300H)

Copyright (C) 2000, 2001, 2002, 2003, 2004 Red Hat, Inc.
RedBoot>


RAM: 0x00400000-0x005f4000, [0x00400000-0x005e1000] available

FLASH: 0x00000000 - 0x80000, 8 blocks of 0x00010000 bytes each.

RedBoot>


■デフォルトサーバ(ホスト)の指定(ターゲット)

> fconfig -i

Default server IP address: 192.168.1.100

※4MB版RedBootではfconfigは使えない


■uClinuxの起動(ターゲット)

AE3069
RedBoot> load -v linux_nfsroot.bin
RedBoot> exec -c "console=ttySC1,38400n81 nfsroot=192.168.1.100:/tftpboot/nfsroot"

KaneBeBe
RedBoot> load -r -v -b 0x400000 h8nfs26.bin -h 192.168.1.100
RedBoot> exec -c "console=ttySC1,38400n81 root=/dev/nfs nfsroot=192.168.1.100:/tftpboot/nfsroot

ip=192.168.1.105:192.168.1.100:192.168.1.100:255.255.255.0"

Now booting linux kernel:
Entry Address 0x00400000
Cmdline : console=ttySC1,38400n81 root=/dev/nfs nfsroot=192.168.1.100:/tftpboo0
Linux version 2.6.12-uc0 (zqing@ip4.dragonwake.net) (gcc version 3.4.3) #16 Sun8


uClinux H8/300H
Target Hardware: H8KANE LAN/USB
Flat model support (C) 1998,1999 Kenneth Albanowski, D. Jeff Dionne
H8/300 series support by Yoshinori Sato <ysato@users.sourceforge.jp>
Built 1 zonelists
Kernel command line: console=ttySC1,38400n81 root=/dev/nfs nfsroot=192.168.1.100
virtual vector at 0x00fffd20
PID hash table entries: 64 (order: 6, 1024 bytes)
Dentry cache hash table entries: 2048 (order: 1, 8192 bytes)
Inode-cache hash table entries: 1024 (order: 0, 4096 bytes)
Memory available: 2184k/575k RAM, 0k/0k ROM (1443k kernel code, 273k data)
Mount-cache hash table entries: 512
NET: Registered protocol family 16
SCSI subsystem initialized
usbcore: registered new driver usbfs
usbcore: registered new driver hub
SuperH SCI(F) driver initialized
ttySC0 at MMIO 0xffffb0 (irq = 54) is a sci
ttySC1 at MMIO 0xffffb8 (irq = 58) is a sci
io scheduler noop registered
ne-h8300.c:v1.00 2004/04/11 ysato
NE*000 ethercard probe at 00200000: 00 02 cb 02 1e 2c
eth0: NE1000 found at 0x200000, using IRQ 17.
sl811: driver sl811-hcd, 19 May 2005
sl811-hcd sl811-hcd: SL811HS v1.5
sl811-hcd sl811-hcd: new USB bus registered, assigned bus number 1
sl811-hcd sl811-hcd: irq 12, io mem 0x00800000
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 1 port detected
Initializing USB Mass Storage driver...
usbcore: registered new driver usb-storage
USB Mass Storage support registered.
h8mmc: H8/3069 SD/MMC card interface driver. Copyleft Qing Zhong
h8mmc : Media not found.
NET: Registered protocol family 2
IP: routing cache hash table of 512 buckets, 4Kbytes
TCP established hash table entries: 512 (order: 0, 4096 bytes)
TCP bind hash table entries: 512 (order: -1, 2048 bytes)
TCP: Hash tables configured (established 512 bind 512)
IP-Config: Complete:
device=eth0, addr=192.168.1.105, mask=255.255.255.0, gw=192.168.1.100,
host=192.168.1.105, domain=, nis-domain=(none),
bootserver=192.168.1.100, rootserver=192.168.1.100, rootpath=
Looking up port of RPC 100003/2 on 192.168.1.100
Looking up port of RPC 100005/1 on 192.168.1.100
VFS: Mounted root (nfs filesystem) readonly.
Freeing unused kernel memory: 60k freed (0x5a2000 - 0x5b0000)

Welcome to
____ _ _
/ __| ||_|
_ _| | | | _ ____ _ _ _ _
| | | | | | || | _ \| | | |\ \/ /
| |_| | |__| || | | | | |_| |/ \
| ___\____|_||_|_| |_|\____|\_/\_/
| |
|_|

Akizukidenshi/AE-3068 (aki3069net) port.
For further information check:
http://www.uclinux.org/

init: Failed to open /etc/inittab.#


※initが起動しない場合、/tftpboot/ftproot/bin に sh がないことがある。
 その場合は、sashやnwshなどのシェルをコピーするかリンクを張る。
ex)
# cp nwsh sh



■thttpdを起動する(ターゲット)

# thttpd -p 80 -d /var/www/ &
[1] 24
#


■index.htmlの作成(ホスト)

ホスト側でindex.htmlを作成する
# vi /tftpboot/nfsroot/var/www/index.html
<html>
<body>

Hello, uClinux-H8!! \(^o^)/


</body>
</html>


■ブラウザで確認(ホスト)
http://192.168.1.105/

日本ブログ村

にほんブログ村 PC家電ブログへ にほんブログ村 PC家電ブログ 家電・AV機器へ  にほんブログ村 PC家電ブログ パソコン・周辺機器へ にほんブログ村 PC家電ブログ デジモノへ