2016年7月14日 星期四

ubuntu 16.04 systemctl console mode & graphic mode switch

ubuntu 16.04開始導入Fedora較早就開始使用的systemd system

除了要像之前一樣修改/etc/default/grub,增加text來進入console terminal。
還要透過systemctl來切換開機模式

文字介面模式 (boot to console mode)
$ sudo systemctl set-default multi-user.target
圖型化介面模式 (boot to graphic mode)
$ sudo systemctl set-default graphical.target

修改/etc/default/grub
#GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX="text"

systemd是目前ubuntu以及Fedora都在使用的service manager,之前也有增加systemd的服務,來執行常佇程式(像以前修改/etc/rc.local)一樣,日後也會慢慢增加這部份的內容。
新的功能總是要做一些備忘錄

2013年11月13日 星期三

RS232

RS232 電位
-3V ~ -25V = 負電位 = 邏輯 1 = Marking = 斷開
+3V ~ +25V = 正電位 = 邏輯 0 = Spacing = 導通

TTL 電位
0V = 邏輯 0 = Spacing = 導通
5V = 邏輯 1 = Marking = 斷開

Linux
status |= TIOCM_RTS:     +12V(RS232)  =  正電位  =  邏輯 0  =  0V(TTL)
status &= ~TIOCM_RTS:     -12V(RS232)  =  負電位  =  邏輯 1  =  5V(TTL)

RTS訊號為負動作



2012年10月1日 星期一

sun java 6 for ubuntu 12.04

Reference http://www.duinsoft.nl/packages.php?t=en#repo

Add new repo

~$ sudo vi /etc/apt/sources.list
Add new line
      deb http://www.duinsoft.n1.pkg debs all
 
~$ sudo apt-key adv --keyserver keys.gnupg.net --recv-keys 5CB26B26
~$ sudo apt-get update
~$ sudo apt-get install update-sun-jre

但是安裝好後是sun-java-7  (囧)

換個方式

~$ sudo apt-add-repository ppa:flexiondotorg/java
~$ sudo apt-key adv --keyserver keys.gnupg.net --recv-keys 93D8809A
~$ sudo apt-get update
~$ sudo apt-get install sun-java6-jdk sun-java6-jre

2011年12月2日 星期五

alsa-utils

我真的很討厭工具...一段時間沒用一定不會記得...
還是寫程式比較好...有良好的邏輯觀念就可以寫出我要用的功能...
函式用法man一下就知道了...我真的不想當個google廚阿 OTZ

抱怨到這邊...這篇是來記錄alsa-utils的一些使用記錄

aplay - alsa player
可以播放wav、voc、raw or au,不能播mp3

amixer - command-line mixer for ALSA soundcard driver
同alsamixer,只是是command-line,要在後面加參數
ex: 將左聲道靜音,將右聲道調到最大聲
amixer -c 1 (看一下card 1的資訊)
將card1的Playback,0上的左聲道聲音設為0%,右聲道為100%
amixer -c 1 sset Playback,0 0%,100%

alsamixer -soundcard mixer for ALSA soundcard driver, with ncurses interface
故名思義,就是有著簡易圖形介面的amixer,F6可以切換card number。

arecord - command-line sound recorder and player for ALSA sound-card driver
錄音程式,可以將line-in以及mic-in的聲音錄起來,再透過aplay來播放
ex: 錄10秒 Line-in/Mic-in的聲音,然後播放
先用alsamixer來切換capture的內容(mic-in or line-in)
alsamixer -c 1
錄製10秒,存成test.wav
arecord -d 10 test.wav
播放test.wav
aplay test.wav

2011年10月28日 星期五

mplayer for console mode and mplayer benchmark

# mplyaer -nosound -vo fbdev:/dev/fb2 -benchmark $FILE_NAME

用fb2來播影片,無聲,播放完畢後顯示benchmark

BENCHMARKs: VC: 99.066s VO: 24.192s A: 0.000s Sys: 1.214s = 124.472s

VC: video codec
VO: video output
A: audio codec
Sys: kerenl time

Total time

不要vo,只要單純測video codec的話,就加上 -vo null

2011年8月24日 星期三

PXE Server on Debian 6.0 (squeeze)

使用Linux的環境架設PXE Server
何謂PXE Server: Preboot Execution Environment

環境: Debian 6.0(代號: squeeze)
核心: Kernel 2.6.32-5-686
硬體: 945GSE晶片組

我是用Expert install來裝Debian 6.0,所以我無法保証是不是要額外裝其他的套件 XD

PXE Server,主要是由兩個最重要的功能所組成:
1. DHCP: 提供給 Target Board IP (Target Board本身必需將BIOS選項裡的Lan Boot功能打開)
2. TFTP: 提供Image,讓Target Board可以得到所需的Image. (pelinux.0)

DHCP Server: dhcp3-server
同時會安裝isc-dhcp-server,而在/etc/init.d下,是看到isc-dhcp-server。
需要修改設定檔,才可以讓dhcp server正確的運作。
設定檔名稱: /etc/dhcp/dhcpd.conf

下面是修改過的地方:
增加DNS,只是不曉得這樣有沒有問題就是了~XD 我只需要看到安裝的畫面就好~所以也沒測
option domain-name-servers 168.95.1.1, 8.8.8.8, 8.8.4.4;

第二段才是在述敘此DHCP Server的運作模式
subnet 10.1.199.0 netmask 255.255.255.0 {
range 10.1.199.50 10.1.199.200; >> Target board能拿到的ip範圍
filename "pxelinux.0"; >> DHCP到IP後,要跟TFTP討的檔案名稱
next-server 10.1.199.2; >> TFTP Server IP
option subnet-mask 255.255.255.0; >> netmask
option broadcast-address 10.1.199.255; >> broadcast
option routers 10.1.199.254; >> routers
}

TFTP Server: atftpd
因為一開始裝了其他的套件,所以並不確定atftpd是不是一開始就有

設定檔名稱: /etc/default/atfptd

設定檔內容:
USE_INETD=false >> 使tftpd不使用inetd(但是這邊我不是很確定,因為其實可以修改/etc/inetd.conf,但是將tftp那行註解掉後,tftp server也會有問題)

OPTIONS="--tftpd-timeout 300 --retry-timeout 5 --mcast-port 1758 --mcast-addr 10.1.199.0-255 --mcast-ttl 1 --maxthread 100 --verbose=5 /home/avalue/tftp"
一些設定就自己man一下atftpd,主要就是最後的參數/home/avalue/tftp。
這就是設定tftp的root directory.

嗯...除了設定atfptd之外,也要修改/etc/inetd.conf下的tftp設定,將tftp root改為/home/avalue/tftp (這邊應該是我有地方沒設定好才會需要修改這個地方)

PXE Server:
DHCP Server以及TFTP Server都設定好後,就只差PXE Server所需要的檔案了。
PXE Server會去找pxe loader >> pxelinux.0,而這個檔案會去讀取pxelinux.cfg下的default。
我一開始要笨...把pxelinux.cfg當一個檔案,所以我的PXE Server會一直說找不到pxelinux.cfg/default

這些相關的檔案可以至義守大學的FTP站 http://ftp.isu.edu.tw/pub/Linux/Debian/debian/dists/lenny/main/installer-i386/20090123lenny8/images/netboot/

裡面有所需的pxelinux.0,以及pxelinux.cfg用的default。
透過default,你可以修改你的PXE Server要做的事情。
例如在義大站台下載到的default,內容如下:

include debian/squeeze/i386/boot-screens/menu-cfg
default debian/squeeze/i386/boot-screens/vesamenu.c32

嗯...長得不一樣...因為這是我的tftp內的路徑 w
所以pxe server會去tftp server下的debian/squeeze/i386/boot-screens/menu-cfg讀取設定

假如使用義大的設定,那最後PXE跑起來會是Debian的安裝畫面~

有要補充的之後有空再補充

2011年8月3日 星期三

Add Kernel Configuration -- 「Select Option」

要加入kernel option的選項,讓編譯時可以選擇產品,讓程式碼變得比較有彈性。
參考kernel config裡的一些設定方式,試著做出想要的功能

原來的menuconfig如下,我想在MX51 BABBAGE那邊多加選項,變成可以選公板或我們自己的板子。


改變後如下兩張圖

點進去後長樣子


程式碼如下

choice 
    prompt "Board Selected:" 
    default RSC_IMX51 
    depends on MACH_MX51_BABBAGE 

    config RSC_IMX51 
        bool "Avalue RSC-IMX51" 
    help 
        This enables support for systems based on the Avalue RISC Product RSC-IMX51 Board 

    config EVK_IMX51 
        bool "Freescale EVK-IMX51" 
    help 
        This enables support for systems based on the Freescale i.MX51 EVK Board
endchoice

其實為何要用的那麼麻煩,因為我本來是直接加#define RSC_IMX51在code裡面,但是compile時,會該該叫(Warning),所以就循正規做法來實作。