2015年7月26日 星期日

在 Linux Debian 8.1 系統安裝及編譯 OpenWrt Trunk 程式:

Linux Debian 8.1 系統安裝及編譯 OpenWrt Trunk 程式:

筆者利用這台高效能的微星(MSIGS60 2QD Ghost 龍魂電競筆電(Gaming Notebook)來作 OpenWrt 程式的開發,可以減低在編譯所花費的時候,加快開發速度編譯是 OpenWrt 的最新版本 Chaos Calmer 15.05 RC320150626 SVNr46133)編譯Compile的時候,發現從已往大約 9.5小時減至 1.3小時,令筆者再不用在深夜開始編譯,明天早上看結果,不再浪費時間!

OpenWrt 網頁
步驟1Debian Linux 操作系統 
首先當然要進入 Debian Linux 操作系統,用 root 用戶登錄。
root 用戶登錄
步驟2安裝不同的套裝軟體:
由於在安裝 Debian 8.1 GNU/Linux 有些程式是沒有的,需要手動安裝。
#apt-get install build-essential (GCC)
#apt-get install subversion (SVC)
#apt-get install libncurses5-dev (ncurses)
#apt-get install zlib1g-dev (zlib)
#apt-get install gawk(GNU awk)
#apt-get install flex(flex)
#apt-get install unzip(unzip)
#apt-get install git-core (git-core)
#apt-get install lzma (lzma)

可選擇一次性安裝所需套裝軟體。
#apt-get install build-essential subversion libncurses5-dev zlib1g-dev gawk flex unzip git-core lzma

 步驟3創建一個 openwrt 目錄:
#mkdir openwrt

步驟4進入 openwrt 目錄:
#cd openwrt

步驟5下載 OpenWrt Trunk 源程式碼 (大約60:00分鐘 → 1:44分鐘)
OpenWrt 2015626日發布 Stable 版本為 (Revision46133)
#svn checkout svn://svn.openwrt.org/openwrt/trunk | tee file.txt

※注意:backfire trunk 是兩個不同分支的 OpenWrt 源程式碼,據說 backfire 較為穩定,但是支持的路由器沒有 trunk 多,trunk 更多稱之為測試版,編譯的時候只需執行一條命令即可。執行完成後,會在 openwrt 下生成目錄,使用 backfire/trunk 源碼生成 backfire/trunk bin 目錄。 

步驟6更改目錄權限:
#chmod -R 777 /home/alpha/openwrt/

步驟7不能使用 root 作編譯之用,要更改為非 root 用戶登錄。
#su alpha

更改為非 root 用戶登錄
步驟8進入 trunk 目錄:
$cd trunk

步驟9更新軟體包 (大約 5分鐘 → 1:10分鐘)
$./scripts/feeds update -a

步驟10安裝新軟體包 (大約 5分鐘 → 0:23分鐘)
$./scripts/feeds install -a | tee file_install.txt

步驟11:更新版本號 (大約 0:07分鐘)::
$svn up

用以下的命令可以提供現在的 OpenWrt 版本和資料。
$svn info

svc info
步驟12進入定制介面(可以選擇晶片的型號,集成的元件等等,根據實際情況選擇)
$make menuconfig

步驟13配置固件功能:
1.          Target System <*> Atheros AR7xxx/AR9xxx
2.          Target Profile <*> TP-Link TL-WR703N
3.          Base System <*> block-mount
4.          Kernel modules Block Device <*> kmod-scsi-core
5.          Kernel modules Filesystems <*> kmod-fs-ext4Kmod-vfat
6.          Kernel modules Native Language Support <*>kmod-nls-utf8
7.          Kernel modules Network Support <*>kmod-iptunnel4kmod-iptunnel6kmod-ipv6kmod-sitkmod-tun
8.          Kernel modules USB Support <*>kmod-usb-storage
9.          Kernel modules Video Support <*>kmod-video-core
10.      Kernel modules Video Support <*>Kmod-videe-uvc
11.      LuCI - Collection <*>luciluci-ssl
12.      LuCI - Translations <*>luci-i18n-chinese
13.      Multimedia <*>mjpeg-streamer
14.      Network Firewall <*> iptables
15.      Network Routing and Redirection <*>ip
16.      Network <*>ser2net
如果還有什麼喜歡的功能,自己勾選就可以。

make menuconfig
然後《Save》《OK》《Exit》《YES

儲存設定後, ~/openwrt/trunk/.config 會依據你所選的設定產生。
恢復編譯環境:
$make defconfig

步驟14開始編譯:
筆者的第一次編譯需要時間 (大約 9.5小時 → 1:17小時) 相對比較長,但第二次編譯的時間 (大約1.25小時 → 0:12小時) 已經縮短了,V=99 表示輸出詳細的 debug 資訊,編譯後固件放於 /openwrt/trunk/bin/ 下。
$make V=99

使用 beep 聲提示 
依照你的使用的 CPU,建置程序需要一些時間或更久。你可以使用 echo -e '\a'來做聲音的提示。
$ make V=s ; echo -e '\a'
如果需要知道編譯失敗的原因,可輸入下面的命令,將編譯的所有輸出資訊保存在 build.log中,將 error 資訊列印在螢幕上。

$make V=99 2>&1 | tee build.log |grep -i error
在後台進行編譯,使用空閒的 I/O 資源和 CPU 性能,可使用(例如使用雙核處理器)。

$onice -c 3 nice -n 20 make -j 2


編譯一個單獨的套裝軟體(例如在 helloworld 軟體)。
$make package/helloworld/compile V=99
 

編譯後的檔案
步驟15清除編譯過程產生的暫存檔案:

清除中間檔等,buxxx_dir 的都會被刪除,而且看起來 bin 目錄裏編譯好的固件也沒了。
$make clean


步驟16恢復編譯環境:
$make defconfig

步驟17使用 WinSCP 登錄下載進行檔案管理和刷機。
WinSCP 登錄
WinSCP 下載
※注意:
如果您希望自己開發一下,後面用 C 語言直接寫程式並在 703N 運行,請在主功能表裏面選中一個 SDK 的選項,這個會在編譯時候生成交叉編譯用的工具。 

相關網址:
※ 安裝 OpenWrt 及編譯 TP-Link TL-WR703N 路由器固件步驟 


相關網址:
※ 在 Linux Debian 8.1 系統安裝及編譯 OpenWrt Trunk 程式
※ 在 Linux Debian 8.1 系統編譯 OpenWrt Trunk 8MB 固件程式
※ 如何將 OperWrt 8MB 固件程式寫入 8MB 閃存(Flash Memory)

※ 在 Linux Debian 8.1 系統安裝及編譯 OpenWrt Attitude Adjustment 程式
※ Subversion (SVN) 1.8.10 版本不兼容,錯誤編譯 OpenWrt Attitude Adjustment 程式

相關網址:
※ 微星(MSI)GS60 2QD Ghost 龍魂電競筆電(Gaming Notebook)- Debian(八)
※ 測試 Debian 8.1 Linux 系統的網絡功能設置
※ 修改 Debian 8.1 Linux 系統的 GRUB 和 80×25 文字解像度


※ 安裝 OpenSSH 在 Debian 8.1 Linux 系統
※ 在 Debian 8.1 Linux 系統讀寫 USB 手指

2015 年 7月 26日 天氣報告

氣溫:28.5@ 22:30

相對濕度:百分之 78%

天氣:微雨

2015年7月5日 星期日

在 Debian 8.1 Linux 系統讀寫 USB 手指

Debian 8.1 Linux 系統讀寫 USB 手指: 

USB 手指(USB Flash Drive / 隨身碟 / U盤)是非常普及的外置存儲裝置,所以日常都會在 Windows 操作系統使用 USB 手指作資料或程式讀寫,但在 Debian 8.1 Linux 系統使用比較少,所以將指令(Command)記錄下來,方便查閱使用。

微星(MSIGS60 2QD Ghost 龍魂電競筆電(Gaming Notebook)使用 USB 手指
1. 先查 USB 手指是被系統辨識成那個裝置:
# fdisk –l
Disk /dev/sdb: 60.0 GB, 60060155904 bytes
255 heads, 63 sectors/track, 7301 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x000b2b03

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        7301    58645251    b  W95 FAT32
sda 是硬碟,往下查容量可以找到 USB 手指的編號,USB 手指為 sdb

2. 建立 USB 手指的掛載點:
# mkdir /mnt/usb
 

3. 掛載 USB 手指:
# mount -v -t vfat /dev/sdb1 /mnt/usb
-v 顯示資訊
-t auto 讓系統自動分辯檔案系統

4. /mnt/usb 可看到 USB 的內容:
# ls /mnt/usb
# cp /mnt/usb/xxxx.tar /home/etc/yyyy.tar
 

5. 卸載 USB 手指:
# unmount /dev/sdb1
 

6. 格式化 USB 手指:
# mkfs vfat /dev/sdb1

相關網址:
※ 在 Linux Debian 8.1 系統安裝及編譯 OpenWrt Trunk 程式
※ 在 Linux Debian 8.1 系統編譯 OpenWrt Trunk 8MB 固件程式
※ 如何將 OperWrt 8MB 固件程式寫入 8MB 閃存(Flash Memory)

※ 在 Linux Debian 8.1 系統安裝及編譯 OpenWrt Attitude Adjustment 程式
※ Subversion (SVN) 1.8.10 版本不兼容,錯誤編譯 OpenWrt Attitude Adjustment 程式

相關網址:
※ 微星(MSI)GS60 2QD Ghost 龍魂電競筆電(Gaming Notebook)- Debian(八)
※ 測試 Debian 8.1 Linux 系統的網絡功能設置
※ 修改 Debian 8.1 Linux 系統的 GRUB 和 80×25 文字解像度

※ 安裝 OpenSSH 在 Debian 8.1 Linux 系統
※ 在 Debian 8.1 Linux 系統讀寫 USB 手指

2015 年 7月 5日 天氣報告
氣溫:27.9@ 21:50
相對濕度:百分之 78%
天氣:大致多雲

2015年7月4日 星期六

安裝 OpenSSH 在 Debian 8.1 Linux 系統

安裝 OpenSSH Debian 8.1 Linux 系統: 

筆者一般會使用另外一部電腦作為 Debian 8.1 Linux 系統的遠端連線,所以 Debian 8.1 Linux 系統的電腦一定有網絡功能,而連接 Debian 8.1 Linux 系統的 PC 電腦會使用 Telnet SSHSecure Shell),Telnet 1969年開始研發,是 Internet 遠端登錄服務的標準協議和主要方式,使用明碼的方式作收發通訊,很容易被監聽而遭竊取通訊。現在都會改用 SSH 作收發通訊,因為 SSH 是一種資料經過加密後的封包,即使被竊取了,該資料要經過解密才可以,相對比較安全,筆者選擇了 OpenSSH 作為遠端登錄服務。

Debian 8.1 Linux 系統的 OpenSSH Status
步驟 1安裝 OpenSSH 程式
# apt-get install ssh openssh-server
# apt-get install ssh openssh-clent

步驟 2修改 OpenSSH 程式設定
# nano /etc/ssh/sshd_config

##PermitRootLogin without-password
PermitRootLogin yes Line 31 Changed to yes

# ---- Add 20150623 Line 94 Added the following LINES in Bottom
# Keep client SSH connection alive by sending every 300 seconds a small
# keep-alive packet to the server in order to use ssh connection.
# 300 seconds equal 5 minutes.
ClientAliveInterval 300

# Disconnect client after 3333 "ClientAlive" requests.
# Format is (ClientAliveInterval x ClientAliveCountMax).
# Example  (300 seconds x 3333) = ~999,900 seconds = ~11 days.
ClientAliveCountMax 3333

# Ciphers
Ciphers aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,
aes256-gcm@openssh.com,chacha20-poly1305@openssh.com
# /etc/init.d/ssh restart
 
Debian 8.1 Linux 系統的 OpenSSH Configuration File
步驟 3PieTTY / Putty 連接 SSH 遠端登錄服務 

Windows PieTTY SSH 客端通訊程式
相關網址:
※ 在 Linux Debian 8.1 系統安裝及編譯 OpenWrt Trunk 程式
※ 在 Linux Debian 8.1 系統編譯 OpenWrt Trunk 8MB 固件程式
※ 如何將 OperWrt 8MB 固件程式寫入 8MB 閃存(Flash Memory)

※ 在 Linux Debian 8.1 系統安裝及編譯 OpenWrt Attitude Adjustment 程式
※ Subversion (SVN) 1.8.10 版本不兼容,錯誤編譯 OpenWrt Attitude Adjustment 程式

相關網址:
※ 微星(MSI)GS60 2QD Ghost 龍魂電競筆電(Gaming Notebook)- Debian(八)
※ 測試 Debian 8.1 Linux 系統的網絡功能設置
※ 修改 Debian 8.1 Linux 系統的 GRUB 和 80×25 文字解像度

※ 安裝 OpenSSH 在 Debian 8.1 Linux 系統
※ 在 Debian 8.1 Linux 系統讀寫 USB 手指

2015 年 7月 4日 天氣報告
氣溫:28.8@ 21:50
相對濕度:百分之 80%
天氣:大致多雲