convert bin to mem for Verilog $readmemh

使用 Linux 內建的指令 hexdump 就可以將 *.bin 轉換成 *.mem
讓 verilog 的 $readmemh 直接讀取

範例:8051 的 program : test.bin 轉換成 test.mem

$ hexdump -e '"@%07.7_ax " 8/1 "%02x " "n"' test.bin > test.mem

compile 32-bit hex2bin application on 64-bit Linux OS

因工作上需要 hex2bin 的工具 又懶得自己寫
在網路上發現一個寫的還不錯的 hex2bin source code : hex2bin-1.0.9

其中包含了兩個程式 hex2bin and mot2bin
但使用時出現了錯誤的情形,
原來是 compile 時必須是 32-bit 架構,而我卻是在 64-bit Linux 下編譯的,
為了解決這問題,
首先安裝 32-bit gcc compiler

$ sudo zypper in libstdc++47-devel-32bit
$ sudo zypper in gcc47-32bit 

接下來修改 hex2bin 的 Makefile,在 gcc 後面加上 -m32 參數
重新編譯後即可正常使用!

OpenVPN and NAT

在公司用 OpenSuSE 架設了一個 OpenVPN Server
做好之後,發現從家裡除了 VPN Server 之外
其他與 VPN Server 同一網段的機器都連不上
後來發現,原來還需要設定 NAT!
首先編輯 NAT 設定擋

$ vi /root/openvpn_nat.sh
#! /bin/bash

# 清除所有規則
iptables -F
iptables -X
iptables -Z
iptables -t nat -F
iptables -t nat -X
iptables -t nat -Z
iptables -t mangle -F
iptables -t mangle -X
iptables -t mangle -Z

# 定義防火牆政策
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -t nat -P PREROUTING ACCEPT
iptables -t nat -P POSTROUTING ACCEPT
iptables -t nat -P OUTPUT ACCEPT

# 讓 OpenVPN 能進去 LAN
echo "1" > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o eth0 -s 10.8.0.0/24 -j MASQUERADE

測試OK,其他的機器都可以連上了!
接下來更改設定擋,以後不需要在手動啟動了

$ vi /etc/init.d/boot.local
# NAT for OpenVPN
/root/openvpn_nat.sh

重新開機後,測試OK!
搞定,收工!

Upgrade OpenSuSE 12.1 to 12.2

最近這幾次升級 OpenSuSE 時都遇到一些問題
不過還好都有順利解決
這次仍然使用 command line 的 方式

$ zypper modifyrepo --all --disable
$ zypper addrepo --name "openSUSE-12.2-OSS" http://download.opensuse.org/distribution/12.2/repo/oss/ repo-12.2-oss
$ zypper addrepo --name "openSUSE-12.2-Non-Oss" http://download.opensuse.org/distribution/12.2/repo/non-oss/ repo-12.2-non-oss
$ zypper addrepo --refresh --name "openSUSE-12.2 Update-Oss" http://download.opensuse.org/update/12.2/ repo-12.2-update
$ zypper addrepo --refresh --name "openSUSE-12.2-Update-Non-Oss" http://download.opensuse.org/update/12.2-non-oss/ repo-12.2-non-oss-update
$ zypper dup --download "in-advance"

經過漫長下載與安裝後,重新開機…. 但是
居然 GRUB 開機失敗!
錯誤訊息:

....
Kernel (hd0,0)/grub2/core.img root=/dev/system/root resume=/dev/system/swap splash=silent quiet showopts vga=0x31a
Error 15: File not found
Press any key to continue...

似乎是從 GRUB 到 GRUB2 升級失敗?
後來發現 /grub2/core.img 這路徑不對,應該是 /grub2/i386-pc/core.img 才對

先進到 GRUB 將啟動參數路徑修改正確 press “e”

Kernel (hd0,0)/grub2/i386-pc/core.img root=/dev/system/root resume=/dev/system/swap splash=silent quiet showopts vga=0x31a

and than press “b” to boot:
結果,似乎只將 GRUB2 啟動,OpenSuSE 沒動靜??
只好 press “c” 進到命令列,手動啟動 OpenSuSE

> linux /boot/vmlinuz-...[press TAB] ro root=/dev/system/root
> initrd /boot/initrd-...[press TAB]
> boot

好耶,OpenSuSE 12.1 順利啟動!
立刻進到 YaST 看看 bootloader 的設定
發先仍是 GRUB
將他改成 GRUB2 ,儲存,重新開機後 OK 了!

非常離譜的花旗銀行

10月1日上班時,我以為我的信用卡遺失
(事實上沒有,只是掉在家裡某個地方)
我當下立刻打電話到花旗銀行掛失,
也與花旗客服確認最後一筆交易金額,並確認沒被盜刷,
客服說新卡會立刻寄出,並要我聽一段「信用卡掛失注意事項」
接下來離譜的事發生了:
到了10/12,掛失經過了十一天了,都還沒收到新卡,
我打電話到花旗銀行去詢問,
結果花旗客服回答:『先生,沒有您信用卡掛失的紀錄耶。』
天哪!我開始罵人了… (太離譜了!!)
當然客服不斷的道歉…..
說因為他們最近在做系統更新,所以才會發生這事…(最好是)
接下來,又再次與花旗客服確認最後一筆交易金額,並確認還是沒被盜刷…
當客服要再次幫我掛失時
我說:不用掛失了,我找到了。
掛斷話前,在多罵幾句… 因為實在太離譜了!
接著,我又繼續用舊卡了。

license error: 0x3f2 ???

最近常遇到 “License: Error, 0x3f2” 的問題,可是不知道什麼意思?
後來找到一些資料,留著參考先:

error info:
1
No “VENDOR_STRING=ES=XXXXXXXXXXXXXXXXXXXX"
License: Error, 0x3e9, Contact customer support. Program will now exit.

2
ES length < 0×14 and ES length != 0x0F
License: Error, 0x3ea, Contact customer support. Program will now exit.

3
“VENDOR_STRING=MAC=XXXXXXXXXXXXXXX" length error
License: Error, 0x3eb, Contact customer support. Program will now exit.

4
“VENDOR_STRING=ES=XXXXXXXXXXXXXXXXXXXX" ES mismatch
License: Error, 0x3ec, Contact customer support. Program will now exit.

5
count=uncounted or count=0
License: Error, 0x3ed, Contact customer support. Program will now exit.

6
No SERVER line (License server = null string)
License: Error, 0x3ee, Contact customer support. Program will now exit.

7
FEATURE HOSTID type error
License: Error, 0x3ef, Contact customer support. Program will now exit.

8
lc_isadmin error
License: Error, 0x3f0, Contact customer support. Program will now exit.

9
SERVER HOSTID type error
License: Error, 0x3f1, Contact customer support. Program will now exit.

0A
FEATURE desktop_main exists, but its version > 5.300000000000000
License: Error, 0x3f2, Contact customer support. Program will now exit.

0B
FEATURE desktop_main doesn’t exist, and some fields in the feature line are wrong
License: Error, 0x3f3, Contact customer support. Program will now exit.

0C
expiration date = permanent or (expiration date – today) > 0x2dc
License: Error, 0x3f4, Contact customer support. Program will now exit.

0D, 0E, 0F
expiration date format error
License: Error, 0x3f5, 0x3f6, 0x3f7 Contact customer support. Program will now exit.

Subaru Outback MY12音響 收到

7/10 訂購,7/12 就收到,真是迅速(廣州到台灣)
接下來要來研究研究如何改裝

DIY 計畫: 將 Subaru MY10 Outback 的 音響 升級到 MY12 型式

因為 Subaru MY10 Outback 的 音響 沒有 USB 的功能
可是 原廠的 Media Hub 又太貴了
最後發現 掏寶有賣超便宜(RMB$190)的 MY12 型式 具有 USB 功能的原廠音響主機

等收到貨後 就可以開始動手了,
希望改裝不會太困難…

不過還少一個 USB Jack
目前查到兩種形式
86257AJ200:

以及
H621SAJ220

不知道這東西好不好買?