烏龍的 Uboot 使用記

話說一直忙著其他的事, 我的開發板有好一陣子沒升級了, 有天抽空想把它升級看看, 卻發生了一些烏龍事, 順便把它記下來.

首先要升級 bootcode, 結果發現 bootcode 位置改了. 沒關係, 這小事. 不過把 bootcode load 到 memory 的過程中,  卻把網路驅動打死了, 所以呈現出 tftp 上傳不了的狀態. 其實跟網路一點關係也沒有, 就是位置不對, 像是下面的 BAD ADD2 (R).

tftp 0xBADADD2 my_bootcode.bin

升好了 bootcode, 想練習一下 USB 安裝. 我這邊一直看到 FAE 同仁發 mail 給客戶教學, 但是自己卻沒有實做過. 因為直接按 hot key 升級實在簡單多了! 要從 USB 升級, 首先在 uboot 下打 usb start — 成功! 果然看到很多 USB device, 主要是接 HUB 的關係.  舉例來說 [1], 可能一口氣出現一堆.

=> usb start
(Re)start USB…
USB0:   USB EHCI 1.00
scanning bus 0 for devices… cannot reset port 1!?
1 USB Device(s) found
USB1:   USB EHCI 1.00
scanning bus 1 for devices… 1 USB Device(s) found
       scanning usb for storage devices… 0 Storage Device(s) found
=> usb info
1: Hub,  USB Revision 2.0
– u-boot EHCI Host Controller
– Class: Hub
– PacketSize: 64  Configurations: 1
– Vendor: 0x0000  Product 0x0000 Version 1.0
   Configuration: 1
   – Interfaces: 1 Self Powered 0mA
     Interface: 0
     – Alternate Setting 0, Endpoints: 1
     – Class Hub
     – Endpoint 1 In Interrupt MaxPacket 2048 Interval 255ms

2: Hub,  USB Revision 2.0
– u-boot EHCI Host Controller
– Class: Hub
– PacketSize: 64  Configurations: 1
– Vendor: 0x0000  Product 0x0000 Version 1.0
   Configuration: 1
   – Interfaces: 1 Self Powered 0mA
     Interface: 0
     – Alternate Setting 0, Endpoints: 1
     – Class Hub
     – Endpoint 1 In Interrupt MaxPacket 2048 Interval 255ms

下一步是 fatload usb 0:1 XXX, 從網路上抓個例子 [2].

fatload usb 0:1 0x1000000 launchu3.exe

也就是想把 launchu3.exe 載入到 0x1000000, 這個動作會失敗. 我想起 FAE 跟客戶說, 那個 0:1 不一定是 0:1, 要試試看別的組合. 到底是什麼組合呢? 第一個參數是 device, 第二個參數是 partition. 我們可以根據 usb start 或是 usb reset, usb info 的結果來決定參數. 我選的指令是這個, 簡簡單單, 就算不下參數都可以, 下參數還可以從 0 開始盲測, 哈!

usb part 0

看到 partition table 之後, 找到 device 也沒問題了. 但是 fatload 依然不成功. Console 無情地吐出:

** Unable to use usb 0:1 for fatload **

** Invalid boot device **

這時我發現 usb part 的結果會有一個 type 的數字. 例如 ref [3] 上說的.

Marvell>> usb part 0

Partition Map for USB device 0  --   Partition Type: DOS

Partition     Start Sector     Num Sectors     Type
    1                 2048          317440      83
    2               319488         3211264      83
    3              3532798          499714       5 Extd
    5              3532800          499712      82

可以看出每個 partition 都有一個 type, 其中 83h 就是 EXT2/EXT4 的 file system, 82h 是 swap space. 而我的 USB 呈現的是 type 7h, 這表示它的格式是 ExFat. 啊! 難怪認不到, 沒 port driver. 立馬換個 FAT32 的隨身碟, type 變成 bh, 就 OK 了. 至於那一種 type 對應到哪一種 file system 呢? 可以參考 WIKI 上的 partition type [4], WIKI 內容真是豐富啊!

[ref]

1. https://community.freescale.com/thread/327088

2. http://blackfin.uclinux.org/doku.php?id=bootloaders:u-boot:usb

3. http://www.cyrius.com/debian/kirkwood/sheevaplug/troubleshooting/

4. http://en.wikipedia.org/wiki/Partition_type

VUDU Spark Unboxing

As everybody knows [1], VUDU annouced her own streaming dongle – VUDU Spark just like Google Comcast and Amazon Fire TV did recently. By noticing the famous “PREFIX", you can easily find out that each dongle has a rich father stands behind it. Google has ECO system advantage, Amazon has on-line stires. How about VUDU? VUDU dongle is now available in 2400 Walmart stores because Walmart acquired VUDU in 2010. So VUDU Spark has off-line store to support it.

VUDU Spark is sold at only $25, it is the most inexpensive product in the market comparing to Comcast ($30), Amazon’s Fire TV ($40), Ruku’s streaming Stick ($50)…etc. However, VUDU Spark is also bundled with $25 credit for movie rental, so it is actually free of charge.

After you open your pack, you can also see a USB power cord and and a RF remote controller. If your TV set does not have a USB port, you can use your mobile phone adapter instead. As to the Zigbee remote controller, it is very convenient for users to control the dongle from 10 meters aways. Even the HDMI dongle is usually plugged behind the huge TV panel.

The playback style of VUDU Spark can be explained by the pciture below. At the upper left corner, you can find out the move title is “Alice in Wonderland". The control bar is placed below and the cyan bar above it is the progress bar. Since the movie almost ends, the bar is also almost full. The center area of the screen is for the (big) subnails. You can use directional keys to browse interested scenes forward or backward, when you press OK, the highlight scene will start to play from here.

At the upper right corn of the screen shot above, you can see VUDU Spark provides DDP and WIFI signal strength indicator, and HDX sign (means higher than HD quality). 

Each movie title and TV show has 3 levels of qualities. It all depends how well the WIFI strength is. How do you know that? You can use the embedded Network Speed Test to measure the bit rate from your TV to VUDU servers. Just like it shown in the pciture below.  

Then ,what happened if the WIFI quality becomes worse during the playback? In this case, VUDU Spark will try to rebuffering enough data for about 3 times. If it fails too often, system will recommend you to try lower bit rates. The selection button of video quality is the 3rd icon (from left side) of the control bar in the previous picture.

Of course, VUDU Spark is not the only dongle in the market. and VUDU is not exclusively existed in SPARK. But the number of HDMI port of a TV is limited, if user gets used to play VUDU Spark, it will occupy one HDMI port for a long time. That will be good to VUDU. Otherwise, users may also broswse some Netflix, some HULU+, some Youtube,…, this kind of thinking may explain why VUDU is willing to sell this VUDU Spark for “free". 

[REF]

1. Walmart’s $25 Vudu Spark streaming stick is now available to the masses

2. Walmart acquired Vudu in 2010

好的和壞的 Multi-path

以我們電信系的專業來說, multi-path (多重路徑)是不好的. 它意味著一個訊號, 分別走了很多不同的路徑,才到達接收端.在同一個環境中, 因為訊號路徑的不同,有的訊號先到, 有的晚到. 雖然大家都是 "對的", 不過路徑比較長的那一組訊號通常會比較弱, 弱的訊號又會干擾強的那組.假如我的訊號一秒鐘才變一次,那麼 multi-path 對我們幾乎沒啥影響.好比搭高鐵或是自強號從台北到高雄, 假如要求 6 小時之內到達, 訊號都能夠鎖定. 假如要求 3 小時要到, 搭自強號的訊號和搭第二班高鐵的人差不多時間到, 他就變成干擾源了.

通訊上為了消除 muti-path, 有各種不同的手法. 例如用多根天線來定位真正的主要訊號來源. 好比我在台南多設一個檢查站, 我就可以依時間差推算出誰是搭自強號, 誰搭高鐵? 當然, 我會希望找到搭高鐵的人, 因為他還精神奕奕, 訊號比較強, 也比較不容易變成速度上的瓶頸. 萬一我改成兩個小時就要到, 當然更不想要慢到的人來搗亂.

有趣的是, 這個電信上的名詞, 到了網路通訊竟然大變調. 網路通訊裡的 multi-path, 變成個好東西了. IPMP (IP Network Multipathing) 裡面的多重路徑就是備援路徑的意思. 假如我有兩張網路卡 – 當然就有兩個 MAC address, 假設其中一張卡突然被拔掉了,我希望原來屬於這張卡的 IP address 能夠無痛地轉移到另外一張網卡上面去, 這就是 IPMP 的精神.雖然是 "無痛", 那麼 IP address 是不變的, 但 MAC address 還是會變.

根據 [ref 1] 的描述, 我要對兩張網卡各自設一個正常的 IP, 和一個備援的 IP. 備援的 IP 因為有 deprecated (棄用) 的屬性, 表示它是測試專用的, 不會拿來對外使用.另外它還要有一個屬性是 -failover, 表示這個 IP 會做 fail detection. 當網卡發生問題後,測試 IP 會發現正常 IP 已經不通了. 此時系統會去 /etc 下的 hotname.xxx 裡面去查,哪一張網卡和壞掉的網卡屬於同一個 group. 然後把壞掉的 MAC address 的正常 IP 指定給同 group 中正常的 MAC address.

那麼正常的 MAC address 不就會有兩個 IP 了嗎? 此事要靠邏輯介面來解決. 雖然好的網卡只有一個實體, 此時它會模擬出 3 個邏輯介面. 標準的邏輯介面給自己正常的 IP 用, 衍生邏輯介面 1 給自己的備援 IP 用, 衍生邏輯介面 2 給受難的 IP 用. 當壞掉的卡的網線重新插回來的話, IP 也會回到自己原來的 MAC address. 

上面介紹的觀念屬於有兩張網卡的例子, 實際上, IPMP 還可以延伸到 [2]:

A. Link-Based IPMP with a Single Interface

B. IPMP with Multiple Interfaces

1. ACTIVE-STANDBY

a) 2 NICs, 1 IP (Link-Based)

b) 2 NICs + 1 Logical IF, 2 IP (Probe-Based)

c) 2 NICs + 1 Logical IF and 3 IPs (Probe-Based) – Classical Solaris  Active/Standby IPMP 

2.  Active-ACTIVE IPMP

a) 2 NICs, 1 IP (Link-Based)

b)2 NICs + Logical IF, 2 IP (Probe-Based)

c)2 NICs + 1 Logical IF and 3 IPs (Probe-Based) – Classical Solaris Active/Active IPMP

d)3 NICs + 1 IP (Link-Based)

前面介紹的那一種, 算是 ACTIVE-ACTIVE 的 2 NICs + 1 logical IF + 3 個 IPs. 只有一張網卡的時候, 符合 case A. 此時依然把這張網卡加到 group, 只是多賦予它 failover 的特性 [3] . 那 link-based 又和 probe-based 有何不同呢? Link-based 最基本的保護, [ref 2] 說它 always on. 倒是 probe-based 的偵測需要設定檢查的時間, 例如 FAILURE_DETECTION_TIME = 10 秒,這樣 in.mpathd daemon 才能每隔 10 秒送 ICMP (Internet Control Message Protocol) echo 去檢查一下網路.這看起來很有學問的 ICMP echo, 呃, 其實只會需要用到 request ping (type = 8) 和 reply ping (type = 0) 吧!

[REF]

1. Solaris10 – IP Network Multipathing (IPMP)

2. IPMP, Bonding, Link Aggregation, vLAN Tagging on Solaris, Linux, HP-UX and IBM AIX

3. How to Configure a Single Interface IPMP Group

Apple Air 更換 SSD 硬碟小筆記

前幾天到大陸出差,就在出發前筆電變得怪怪的- 非常地慢,好像哪不對勁.本來這個問題也不難解決, 上次就是直接買一顆新硬碟來重灌. 不過這次馬上就要出差, 似乎沒那麼多時間可以把這些事情做完, 只好把笨重的 Apple 的 Time machine 大硬碟也 hand carry 到大陸去施工.

沒想到真正有問題的應該是 time machine, 被它重灌過以後, 我三歲的 macbook pro 就不會動了. 一開始 time machine 還能 copy 出一點東西, 所以我勉強拷貝了兩個重要的資料夾出來.最後它就完全罷工,連磁碟工具也修復不了.這給了我一個啟示,time machine 如果怪怪的, 一定要趕快備份, 愈拖愈危險!

因此第一天上工只能靠手機回 mail, 到了第二天午餐時間, 我就冒雨衝到北京的五道口購物中心買了一台 13″ Apple Air 回來.什麼規格都還沒摸清楚, 反正就刷卡買了號稱可以 12 小時不充電的. 在大陸蘋果店買東西不算貴, 但是刷 “外卡" (外國卡?) 要加 3% 手續費,這樣一來就貴了不少! 回到客戶公司用了之後,發現我這型號比較低規. 記憶體少只有 4GB.測試了一下, 其實基本夠用.不過還是手癢把 swapfile 設到 SD 卡上.

sudo launchctl unload /Library/LaunchDaemons/dynamic_dns_updater.plist

sudo vi dynamic_dns_updater.plist

把最後的 private/var/vm 改為 /Volumes/32GB/vm

sudo launchctl load /Library/LaunchDaemons/dynamic_dns_updater.plist 

試過不重新開機真的可以用, 但重新開機後就不行了, 還不知道為什麼? 推測是 SD card driver 比 sleepimage 還要挽起來的關係.

至於內建硬碟不但小 (128GB),而且和一般 SSD 規格不相容, 使我原本的 1TB SSD 毫無用武之地,必須要另外買特殊規格的 SSD 卡, 以及梅花形的螺絲起子.今天買的東西都送來了, 於是開始施工.首先拿出在露天拍賣買的五星 (更像是梅花) 螺絲起子! 一開始起子滑牙拆不下螺絲, 還以為自己買錯了? 看到另外一個賣家的圖片才領悟到我應該要換 1.2mm 那頭.Apple 真的相當狡猾, 螺絲是用梅花形的, 乍看之下很像是被轉壞掉一樣.

ddd  

用對工具之後, Air 的後蓋就輕鬆地被拆下來了! 我買的 200 工具組還附了一個撬棒,讓我們把 SSD 挖起來.這 SSD 的上方全部都是電池, 難怪可以號稱用 12 小時.

aaa

兩隻 SSD 排排站.原本的顆粒是 SanDisk 的, 控制 IC 是 Marvell 的. 新買的 SSD, 控制晶片和顆粒都是 Samsung 的.Apple Air 13 年式的 SSD 和 13 年上半年以前的形式不相容, 比較短一點.這點我有注意到, 要是買錯就悲劇了. 基本上 768 GB 和 1TB 的 SSD 都只有 12 年式的 Apple Air 才適用, 13 年式的最大也看到 512 GB.

kkk

換了 SSD 之後, Apple Air 就被視為一台新的電腦.此時可以從 (新的) time machine 中把以前的環境都還原回來.

不過悲慘的部分是 Office 又要啟動一次. 我很不想讓微軟賺我兩次錢. 除了等到上班日打電話到微軟客服中心電話啟動之外,我也再調校一下系統字形吧! 有好幾天都有人說我寄的信變亂碼, 這在我第一用 Macbook Pro 的時候也發生過, 當時是用安裝新細明字形解決的, 最近微軟似乎不給下載新細明字形了,趁這個假期好好研究一下!

對了! 有人說為何不一次就攻頂買大容量的 Air 呢? 實在是因為它只有 128GB 和 256GB 兩款有現貨. 如果要買 512GB 的, 至少要等 3~5 天. 稍微拖一下我就回台灣了, 沒有必要等客製的版本. 再說, 一如我不想讓微軟賺我的軟體錢那樣, 我也不喜歡讓蘋果賺我的硬體錢.自己在淘寶買的 SSD  比蘋果賣的便宜不少!

只有個小東西非買蘋果出的不可,那就是我本來有兩隻 MBP 用的 MagSafe 變壓器, Apple Air 改用了 MagSafe 2,所以要多買個轉接頭,讓原本的變壓器延續它的生命! 

ccc

DivX 專利小整理

DivX 有哪些專利呢? 到 USPTO 找了一下, 一共有 14 篇, 其中有兩篇是延伸自他們先前的專利.

專利字號 專利名稱 極簡摘要 生效日
8,510,303 Singular, collective and automated creation of a media guide for online content 可以對 user 觀看的內如打 tag, 然後送特定資料給 user. i.e. push 廣告之類的. 2013/8/13
8,472,792 Multimedia distribution system 一個多媒體檔案中有兩種 index, 第一種指到 video frame, 第二種指到一群 video frame. i.e. 做 trick play. 2013/6/25
8,301,793 Chunk header incorporating binary flags and correlated variable-length fields 一個多媒體播放系統, 檔案中有 pointer 指到下一塊 data 的位置, 使得檔案能夠依不同的方式播放, 而不會讓檔案大小明顯增加. 2012/10/30
8,289,338 Systems and methods for font file optimization for multimedia files 檔案系統中的字形檔 (font file) i.e. 字幕等等的儲存方式 2012/19/16
8,233,768 Hierarchical and reduced index structures for multimedia files 用 index 技巧保護 content 2012/7/31
8,201,264 Federated digital rights management scheme including trusted systems 聯邦式的 DRM 保護, 延伸 7,515,710 2012/6/12
8,139,651 Video deblocking filter deblock filter, 延伸 7,886,069 2013/3/20
7,886,069 Video distribution system including progressive playback 根據 user 的指令更新遠端的媒體播放內容 2011/2/8
7,729,426 Video deblocking filter deblock filter 2010/6/1
7,664,872 Media transfer protocol 從 server 到 CE device, 根據特性使用不同的 data rtae 傳輸 2010/2/16
7,519,274 File format for multiple track digital data 多個 track 的檔案格式 2009/4/14
7,515,710 Federated digital rights management scheme including trusted systems 聯邦式的 DRM 保護 2009/4/7

7,460,668

Optimized secure media playback control 不用連到外部電腦就能註冊的的播放控制系統. 2008/12/2
7,295,673 Method and system for securing compressed digital video 加密某些 video frame, 但不用加密 reference  到加密 frame 的 frame, 2007/11/13

雖然大家對於 DivX 的認知是一個 video format, 或是一個有 DRM 保護的片商. 但是它主要的專利在於檔案格式, DRM, 以及 de-blocking. 真正和 video 播放有關的專利, 倒是付之闕如. 最有趣的是, 在專利  7,519,274 當中, 它以具體實施例偷渡了這麼幾段話:

DETAILED DESCRIPTION OF VARIOUS EMBODIMENTS 

In accordance with the present invention, the version of the video codec used in AVI files is signaled by the FourCC code in the fccHandler field or member of the AVISTREAMHEADER of the corresponding stream header `strh` chunks, and the FourCC code bicompression field or member in the BITMAPINFOHEADER of the corresponding `strf` chunks. 

By way of example, for videos encoded according to a codec developed by DivX Networks, Inc., 10350 Science Center Drive, Building 14, Suite 140, San Diego, Calif. 92121, the FourCC codes fccHandler in the stream header (`strh`) of the AVISTREAMHEADER is set to "divx" or "DIVX". Furthermore, the FourCC (DWORD) code biCompression in the BITMAPINFOHEADER of the corresponding `strf` chunks is set to signify the detailed codec version. 

Specifically by way of example, for version DivX 3.11, `div3` or `div4` is used in AVISTREAMHEADER, and `div3` or `div4` is used in BITMAPINFOHEADER; for version DivX 4.x, `divx` is used in AVISTREAMHEADER, and `divx` is used in BITMAPINFOHEADER; and for version DivX 5.x, `divx` is used in AVISTREAMHEADER, and `dx50` is used in BITMAPINFOHEADER. 

By now it should be appreciated that a file format for storing digital data with a high compression rate has been described. A file format in accordance with the present invention is compatible with high level data compressing algorithms, such as MPEG-4. Its data compression ratio is about six to ten times higher than a standard DVD format. In accordance with the present invention, the file format is capable of storing data in multiple streams or tracks. The file format is also able to encode and archive video, audio, and text data on easily accessible streams or tracks. Furthermore, the file format is able to provide protection of the copyright of the digitized content

While the invention is susceptible to various modifications and alternative constructions, certain illustrated embodiments thereof have been described above in detail. It should be understood, however, that there is no intention to limit the invention to the specific form or forms disclosed, but on the contrary, the intention is to cover all modifications, alternative constructions, and equivalents falling within the spirit and scope of the invention. The present invention is limited only by the claims that follow. 

儘管 DivX 努力在不具備專利效力的章節裡面幫自己打廣告, 重申 DivX encoder 的優點,還是難掩它沒有主流 encoder 專利的缺憾.畢竟 encoder 做得再好, 還是要和 decoder 相容. 就以 7,519,274 這個專利來說,它只能在檔案格式上做文章.雖然專利名稱有 multi track, 但申請專利的人並沒有忘記把一個 track 的狀況包括進去.以他們的第一條 claim 來說.

1. A playback device configured to play data encoded in a multimedia file, comprising: a processor configured to read the multimedia file; wherein the multimedia file has at least one video track and includes a video stream descriptor list comprising: a video stream header chunk; a video stream format chunk following said video stream header chunk; and a video stream name chunk including a string indicating a video stream in said at least one video track; said video stream descriptor list further comprising a video stream header data chunk in response to said at least one video track being a digital rights management (DRM) protected video, said video stream header data chunk following said video stream format chunk in said video stream descriptor list; said video stream header data chunk in said video stream descriptor list including a DRM information data block comprising: a first member specifying a version of the DRM; and a second member specifying a protection of the DRM said DRM information data block in said video stream header data chunk having a data structure defined as: TABLE-US-00020 typedef _DRMinfo { WORD wVersion; STR sDRMinfo; } DRMINFO. 

看了雖然很眼花, 但簡單講就是: 多媒體檔案在 video stream descriptor 裡面有至少一個 video track, track 裡面有 video stream descriptor. 其中又有 video stream header chunk, format chunk, name chunk, data chunk, format chunk. 在 data chunk 裡面有 DRM revision 和 DRM information data chunk.

以我的認知是, 如果只有一個 track, 而且不受 DRM 保護, 就不受這一條的限制 – 因為那樣把所有傳統的檔案都包括進去了.為了防堵那些不用 track 為單位的檔案, 本專利在 claim 42 強調包含 multiple chapter. 而 claim 43 涵蓋只有一個 chapter, 但是有多個 data chunk 的狀況. claim 45 規範有 subtitle 檔案, claim 46 則規範有 subtitle, 但分成多個 data chunk 的狀況. claim 48 又把前述的 subtile 狀況, 加上有 DRM 時的例子…, 目標很顯然就是想一網打盡, 能想的都想了…從這個角度來看, 還真是滿厲害的.