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)