2014-05-24

修改 Blogger 的字型、行距、字距

要改 Blogger 的字型,首先先來認識中文字型的英文名稱

◎Linux作業系統
       文泉驛正黑    :WenQuanYi Zen Hei
       全字庫正楷體:TW-Kai
◎Mac OS作業系統
       黑體-繁  :Heiti TC
       儷黑 Pro :LiHei Pro
       標楷體   :BiauKai
◎Windows作業系統
       微軟正黑體 :Microsoft JhengHei
       新細明體  :PMingLiU
       細明體   : MingLiU
       標楷體   :DFKai-sb

了解之後,開始來改字型,到【範本】→【編輯HTML】中,按【Ctrl】鍵+【F】鍵,輸入關鍵字 px ,按【Enter】鍵,如下圖

2014-05-24_125840

就搜尋出的第一個結果的重點來解釋一下
<Variable name="body.font" description="Font" type="font"
default="normal normal 13px Arial, Tahoma, Helvetica, FreeSans, sans-serif"value="normal normal 16px Arial, Tahoma, Helvetica, FreeSans, sans-serif"/>
body.font是內文字型,default是預設值,value是指定值,會優先執行value,若找不到,再執行default,所以我們若要改內文的字型為,在Linux作業系統顯示全字庫正楷體 (TW-Kai),在Mac OS作業系統顯示標楷體 (BiauKai),在Windows作業系統顯示微軟正黑體 (Microsoft JhengHei),就要改value值。
將原本的
value="normal normal 16px Arial, Tahoma, Helvetica, FreeSans, sans-serif"
改為
value="normal normal 16px Arial, TW-Kai, BiauKai, Microsoft JhengHei, sans-serif"
若只要優先顯示微軟正黑體,則只要在, sans-serif前插入, Microsoft JhengHei即可,如下
value="normal normal 16px Arial, Tahoma, Helvetica, FreeSans, Microsoft JhengHei, sans-serif"
要注意在字型前要空一格,這樣就可以了。下面還有各區塊,可依此類推改字型。
header.font
description.font
tabs.font
date.font
post.title.font
widget.title.font
widget.font
要改行距、字距。到【範本】→【自訂】→【進階】→【新增CSS】中新增以下字串
.post-body {
font-size:100%;
color:#222222;
line-height: 1.8em;
letter-spacing: 0.8px;
}
font-size:文字大小
color:文字顏色
line-height:行距
letter-spacing:字距
以上數值皆可依您需要做更改,改好後,按【套用至網誌】就完成了,如下圖

2014-05-24_130202

若只要改行距、字距,新增以下字串即可
.post-body {
line-height: 1.8em;
letter-spacing: 0.8px;
}
line-height:行距
letter-spacing:字距
以上數值皆可依您需要做更改

2014-05-22

How does a kernel mount the root partition?

非常值得參考的一份文件為 Jserv 所寫的深入理解 Linux 2.6 的 initramfs 機制 (上). 以下是對 initrd 與 initramfs 的概念性比較:

  initrd initramfs
Image 壓縮過的檔案系統 (如 ext2 + gzip) 封裝過的檔案 (cpio + gzip)
實做途徑 block device (RAM disk) tmpfs
首先執行的程式 /linuxrc /init

掛載 rootfs 方式

將欲載入的 rootfs 掛載於某個目錄,再 pivot_root 切換 rootfs 使用 switch_root

 

In ancient times, the kernel was hard coded to know the device major/minor number of the root fs and mounted that device after initializing all device drivers, which were built into the kernel. The rdev utility could be used to modify the root device number in the kernel image without having to recompile it.

Eventually boot loaders came along and could pass a command line to the kernel. If the init= argument was passed, that told the kernel where the root fs was instead of the built in value. The drivers needed to access that still had to be built into the kernel. While the argument looks like a normal device node in the /dev directory, there obviously is no /dev directory before the root fs is mounted, so the kernel can not look up a dev node there. Instead, certain well known device names are hard coded into the kernel so the string can be translated to the device number. Because of this, the kernel can recognize things like /dev/sda1, but not more exotic things like /dev/mapper/vg0-root or a volume UUID.

Later, the initrd came into the picture. Along with the kernel, the boot loader would load the initrdimage, which was some kind of compressed filesystem image ( gzipped ext2 image, gzipped romfs image, squashfs finally became dominant ). The kernel would decompress this image into a ramdisk and mount the ramdisk as the root fs. This image contained some additional drivers and boot scripts instead of a real init. These boot scripts performed various tasks to recognize hardware, activate things like raid arrays and LVM, detect UUIDs, and parse the kernel command line to find the real root, which could now be specified by UUID, volume label and other advanced things. It then mounted the real root fs in /initrd, then executed the pivot_root system call to have the kernel swap / and /initrd, then exec /sbin/init on the real root, which would then unmount /initrd and free the ramdisk.

Finally, today we have the initramfs. This is similar to the initrd, but instead of being a compressed filesystem image that is loaded into a ramdisk, it is a compressed cpio archive. A tmpfs is mounted as the root, and the archive is extracted there. Instead of using pivot_root, which was regarded as a dirty hack, the initramfs boot scripts mount the real root in /root, delete all files in the tmpfs root, then chroot into /root, and exec /sbin/init.

2014-05-15

MTD related

2014-05-15_064449

Reference :

1. Memory Technology Devices

2014-05-05

如何為嵌入式開發建立交叉編譯環境

隨著消費類電子產品的大量開發和應用和Linux操作系統的不斷健壯和強大,嵌入式系統越來越多的進入人們的生活之中,應用範圍越來越廣。

在裁減和定製Linux,運用於你的嵌入式系統之前,由於一般嵌入式開發系統存儲大小有限,通常你都要在你的強大的pc機 上建立一個用於目標機的交叉編譯環境。這是一個由編譯器、連接器和解釋器組成的綜合開發環境。交叉編譯工具主要由 binutils、gcc 和 glibc 幾個部分組成。有時出於減小 libc 庫大小的考慮,你也可以用別的 c 庫來代替 glibc,例如 uClibc、dietlibc 和 newlib。建立一個交叉編譯工具鏈是一個相當複雜的過程,如果你不想自己經歷複雜的編譯過程,網上有一些編譯好的可用的交叉編譯工具鏈可以下載。 ex : Introduction to Cross Compilation .

本文我們將以建立針對arm的交叉編譯開發環境為例來解說整個過程,其他的體系結構與這個相類似,只要作一些對應的改動。我的開發環境是,宿主機 i386-redhat-7.2,目標機 arm。

整個過程如下

1. 下載源文件、補丁和建立編譯的目錄
2. 建立內核頭文件
3. 建立二進制工具(binutils)-  GNU Binutils 的主要工具有兩個,一個是連接程序ld,另外一個是彙編程序as。其主要目的是為GNU 系統,提供彙編和連接工具。
4. 建立初始編譯器(bootstrap gcc)
5. 建立c庫(glibc)
6. 建立全套編譯器(full gcc)

2014-04-17

嵌入式系統 Boot Loader 技術內幕

1. 引言

在專用的嵌入式板子運行 GNU/Linux 系統已經變得越來越流行。一個嵌入式 Linux 系統從軟件的角度看通常可以分為四個層次:

1. 引導加載程序。包括燒錄在 firmware 中的 boot 代碼(可選),和 Boot Loader 兩大部分。

2. Linux 內核。特定於嵌入式板子的定製內核以及內核的啟動參數。

3. 文件系統。包括根文件系統和建立於 Flash 內存設備之上文件系統。通常用 ram disk 來作為 root fs。

4. 用戶應用程序。特定於用戶的應用程序。有時在用戶應用程序和內核層之間可能還會包括一個嵌入式圖形用戶界面。常用的嵌入式 GUI 有:MicroWindows 和 MiniGUI 。

2014-03-29

VirtualBox 與 Debian/Ubuntu 客端額外功能(Guest Additions)

來源 : 石頭閒語
本文的內容包括 :
  • 安裝客端額外功能(Guest Additions)
  • 滑鼠整合沒作用(Mouse pointer integration not work)
  • 螢幕解析度可調整項目變少了

必須要先安裝的套件

一、安裝 build-essential and module-assistant
安裝 build-essential ,這將用於編譯 VirtualBox 客端功能的 Linux 核心模組。
$ sudo apt-get install build-essential
$ sudo apt-get install module-assistant
$ sudo apt-get install linux-headers-$(uname -r)

 
二、安裝 dkms

若你的 Guest OS 是 Ubuntu 10.04 Lucid 或更新的散佈版本時,必須安裝 dkms。它是新的核心模組載入機制。已知 VirtualBox 的滑鼠整合功能模組依賴此機制載入。若未安裝 dkms ,則滑鼠整合功能不會發生作用。

$ sudo apt-get install dkms

如果你已經安裝了客端額外功能,才發現沒有安裝 dkms 且滑鼠整合功能沒作用,你必須安裝 dkms 之後,再重裝一次客端額外功能。更快捷的方式是在安裝 dkms 之後,直接執行指令 sudo /etc/init.d/vboxadd setup。裝好之後,須重新啟動 Guest OS.

三、下載 VirtualBox Guest Additions ISO

當你使用 VirtualBox 選單的「安裝 Guest Additions ...」之後,VirtualBox 通常會自動下載客端額外功能軟體的 CD ISO 影像檔,並且自動掛載。若你碰到未自動下載的情形時,也可自行到官方網站下載。下載後,再自行透過 CD 裝置掛載該 ISO 影像。掛載 VBoxGuestAdditions CD ISO檔後,開啟它,並以 root 的權限執行其中的 VBoxLinuxAdditions.run。

I tried to install the VirtualBox Guest Additions on a virtual Debian machine. However when I tried executing the installer script I got this error:

bash: ./VBoxLinuxAdditions.run: Permission denied
The script uses /bin/sh as shell and on Debian Wheezy /bin/sh is symlinked to /bin/dash. Dash is a more light-weight replacement for Bash, and it turns out that the VirtualBox script does not work as it should when run with “dash”. An easy workaround is to explicitly run the script with “bash” with the following command:
sudo bash ./VBoxLinuxAdditions.run
or
sudo sh ./VboxLinuxAdditions.run

滑鼠整合沒作用(Mouse pointer integration not work)


Guest OS 為 Ubuntu 10.04 及之後的版本,請參考上一節第二項關於 dkms 的內容。

正常來說,新建的 Guest OS 在安裝「客端額外功能(Guest Additions)」並重新啟動 Guest OS 之後,「滑鼠整合」就會發揮功效。但若你碰到滑鼠整合功能沒有作用的詭異情形時,你需要編輯 /etc/X11/xorg.conf (*1*1. 若此文件不存在,則 Guest OS 應該是新版的,請參考上一節 dkms 的內容),手動加入下列的設定段落。

Section "InputDevice"
        Identifier      "vboxmouse"
        Driver          "vboxmouse"
        Option          "CorePointer"
        Option          "Device"        "/dev/input/mice"
EndSection


正常來說,就算 xorg.conf 沒有上述的 InputDevice 段落,滑鼠整合功能依然會作用。

我今天新裝了一個 Ubuntu 9.04 Desktop 的 guest 系統,安裝客端額外功能後,滑鼠整合功能竟然沒有發生作用。我覺得很奇怪,已經我先前安裝過數次 Ubuntu Desktop 作為 guest 系統,但都沒發生這問題。查詢後才知道,有時候要自己手動加入上述的設定內容。我開啟先前安裝的 Ubuntu Desktop guset ,把兩邊的 xorg.conf 比對一下,結果先前安裝的 Ubuntu Desktop guest 的 xorg.conf 沒有這一段,但滑鼠整合還是可作用。真是怪哉。

螢幕解析度可調整項目變少了


首先,如果是 Ubuntu 9.04 的使用者,可以參考我先前寫的使用筆記,按照裡面的步驟修正客端額外功能的安裝程式。 Ubuntu 9.10 的使用者,請參考 Logan 寫的Ubuntu 9.10 + VirtualBox Guest Additions修正。

當我安裝額外功能並重新啟動 guest 系統後的第一次晝面,我的螢幕解析度有 1280x768 (按預設 12MB 顯示記憶體)。我啟動 Ubuntu Desktop 的「顯示」控制台,一開始顯示我可以選擇從 1280x768 到 640x480 的5種解析度。接著我將螢幕解析度下調到 1024x768。調整完畢後,我很訝異地發現,在「顯示」控制台內,我可以選擇的解析度只剩下 1024x768 到 640x480 的3種解析度了。我沒有辦法再往上調整更高的解析度了。

如果你跟我一樣碰到這種情形,我們需要編輯 /etc/X11/xorg.conf ,手動在 Screen 段落中,加入 Display 的子段落,明確地列出我們希望能調整的解析度項目。如下所示:

Section "Screen"
   Identifier   "Default Screen"
   Monitor      "Configured Monitor"
   Device      "Configured Video Device"

   DefaultDepth    24
   SubSection      "Display"
      Depth           24
      Modes           "800x600" "1440x900" "1360x768" "1280x1024" "1280x960" "1152x864" "1024x768" 
   EndSubSection

EndSection

上例設定範例,列出7種解析度,那麼在「顯示」控制台中,就會至少出現這7種解析度供我們選擇。不再愈調愈少。

登入晝面(GDM)會取 Modes 中的第一個項目作為解析度。所以我把 800x600 放在第一個。

2014-03-28

嘗試構建自己的busybox

來源 : http://www.360doc.com/content/13/0829/19/7377734_310794205.shtml

1、一個作為宿主機的Linux;本文使用的是Redhat Enterprise Linux 5.4;
2、在宿主機上提供一塊額外的硬盤作為新系統的存儲盤,為了降低複雜度,這裡添加使用一塊IDE接口的新硬盤;
3、Linux內核源碼,busybox源碼;本文使用的是目前最新版的linux-2.6.34.1和busybox-1.16.1。

說明:本文是一個step by step的實做指南;