12.22.2006

?

新的防盜版機制:

推出有一堆bug的東西,然後要你認證,如果認證沒過,你就沒辦法修正這些bug。

新的business:

推出有一堆漏洞的東西,再賣給你補洞的工具。

新的?

這個東西我賣給你,但是盒子你可得收藏好,不然哪天我到你家去看,你沒這個盒子,我可以報警抓你。

12.21.2006

GET_DESCRIPTOR - TotalLebngth - XP's behave

在收到 GET_DESCRIPTOR 後,第一次,request length 是 9。剛好是 configuration descriptor 的size。

configuration descriptor 中有一個field 是"Total descriptor length" ,total 就是所有descriptor 的意思,包含這個device 所有的configuration, interface, endpoint。
所以要把這些descriptor 的長度都加起來。

XP 收到9 個byte 的configuration descriptor 後,會知道"totoal descriptor size",於是,會再送出一次相同的 GET_DESCRIPTOR request,但是這次request 的legth 就不只是 9了。

根據"USB complete" 說,XP 會送出你第一次傳給他的configuration descriptor 中total length 的值。

但是我收到的是 0xFF. - 不管我第一次的configuration descriptor 中total length 的值寫的是什麼。

USB 2.0 spec 說 ..(p.253 sec 9.4,3..)
The wLength field specifies the numbers of bytes to return. If the descriptor is longer than the wLength field, only the initial bytes of the descriptor are returned. If the descriptor is shorter than the wLength field, the device indicates the end of the control transfer by sending a short packet when further data is requested. A short packet is defined as a packet shorter than the maximum payload size or a zero length data packet(refer to Chapter 5).

也就是說,XP 第一次要求9 byte,第二次要求0xFF bytes 都是合理的。而且我還真的要follow request bytes length, 第一次只送9 bytes, 第二次送全部的,多的部份送 Null Data.

因為0xFF 這一段跟"USB complete" 說得不一樣,所以google 一下source code..
有一個比較近的.. http://www.google.com/codesearch?hl=zh-TW&q=+USB_DESCRIPTOR_TYPE_CONFIGURATION+show:_S5IVIQqAzc:jVtJyZxm8xs:2mzD8Tn8zNc&sa=N&cd=2&ct=rc&cs_p=http://cq.cx/dl/at91sam7sXXX.zip&cs_f=bootrom/usb.c#a0

 switch(usd.bRequest) {
case USB_REQUEST_GET_DESCRIPTOR:
.....
} else if((usd.wValue >> 8) == USB_DESCRIPTOR_TYPE_CONFIGURATION) {
UsbSendEp0((BYTE *)&ConfigurationDescriptor,
min(sizeof(ConfigurationDescriptor), usd.wLength));
} else if(...
...
..也是一樣。
. 所以是我看錯了 :P

Structure Padding in ARM Compiler (ADS)

USB 的standard configuration descriptor 宣告:
typedef __packed struct CONFIGURATION_DESCRIPTOR
{
char bLength;
char bDescriptorType;
unsigned short wTotalLength;
char bNumInterfaces;
char bConfigurationValue;
char iConfiguration;
char bmAttributes;
char MaxPower;
} CONFIGURATION_DESCRIPTOR;
嗯。size是9 (bytes)。奇數。

在code中,sizeof(this structure) 的話,會顯示 10 - 偶數。

這是因為ARM Compiler (ADS) 自動加上padding 的關係,可以在compiler 選項中enable "warning padding",就可以看到這個structure 出現warning。

如果要compiler 不加上padding 的話,就要將上"__packed " 這個修飾字 (ref DUI0067D_ADS1_2_CompLib.pdf )。

這樣,sizeof( this structure ) 就會是9了。

12.20.2006

Feescale MX31 bootloader Program : HAB Toolkit

MX31 內含一個ROM,boot ROM,裡面的code是Freescake預先寫好的。
boot rom code在boot時會detect boot config pin 的high low狀態,決定boot 的動作:
  1. 執行loader
  2. from NOR flash (8/16 bit)
  3. from NAND Flash (8/16 bit, 256/512 block)
利用rom 的loader 程序,可以用來dowload code/data到RAM。

loader 提供由UART和 USB download 的介面。

Freescale有將loader 的protocol, command open 出來。

Freescale 提供一個too : HAB Toolkit,方便和 rom loader溝通。

rom loader 啟動後,只會initial UART和USB週邊,所以在download之前,要另外下command 設定DDR controller。這部份由init file 提供。

HAB Kit 也提供將RAM DATA燒寫到flash 的功能,這部份是利用MX31的ARM Code執行一段code 來完成,燒寫flash 的command被包裝起來,放在RAM中,
所以當 designer 更換 flash 時,可以follow Freescale 的instruction ,implement 需要的flash command,包裝成bin 後讓HAB Toolkit download到RAM中讓 rom loader 使用。

HAB Toolkit 也可以作download and run 的動作,但是固定jmp 到download 的start address。

HAB toolkit 在download 時,出現 DDR Error的話,可能是 DDR controller設定不良,也可以是target board沒電,或是cable 沒接等問題。

Freescale MX31

FAE
Jim Lin 林良璟
0932023335

12.19.2006

USB 2.0 bus signal. device states on startup.

用示波器量 isp1582 pci 的 3.3 V power,在2440a cpu running時,noise 很大(4V p-p),break時noise 很小(200mV p-p幾乎沒有)。

將code 放到internal SRAM來run 也一樣。

所以把RESET pin 拉到Vcc 應該也無效。

請Ricky 加上粗一點的地線,連接targetboard和demoboard,並且加上大電容。

結果還是一樣。


USB D+/D- Signal Definition:

H.H : Single Ended One - 無效,不應該出現在bus上
H.L : Differential 1
L.H : Differential 0
L.L : Single Ended Zero - End of Packet, Disconnect, Reset。

其中Differential 0, 1被用來定義傳輸資料。
根據speed 不同,Differential 0/1的代表意義也不同。
USB 用J.K 狀態來代表通訊時bus的電壓狀態。
J. K 的定義在Low Speed, Full Speed, High Speed時不一樣。
其中Full Speed, High Speed的J, K定義是一樣的。

Low Speed
J : Differential 0
K : Differential 1

Full/High Speed
J : Differential 1
K : Differential 0

以下對Full/High Speed Bus 描述

BUS Idle : 維持Different 1 (J)

Reset : 當bus處於SingleEndedZero (D+/- both 0) 2.5us 之後,bus 轉換進入 Reset狀態。


USB 2.0 hub 在偵測到某device 是Idle時,就會進行HighSpeed Handshaking 偵測。

  1. Device偵測到VBUS有電壓,將D+接到High,作Softct。
  2. Device 作Softct (D+ high for 3ms?)讓Host偵測到。
  3. Host將bus 維持在SigleEndedZero(2.5us),讓device進入Reset。
  4. Host接著送出一串快速的J.K信號,讓 device 進入HighSpeed。
  5. Host送出Endpoint 0 Setup ,Request Descriptor。
所以device收到interrupt的順序是:
  1. VBUS
  2. BUS RESET
  3. HSpeed State
  4. SETUP0
ref : Book "Usb Complete 3rd edition" Chapter 18 : 信號與編碼。

12.18.2006

ISP1582 data..

DataSheet上說.. 在3.3V Vcc 下..

耗電:
high speed : 60mA
full speed : 25mA

Minimum High Voltage : 0.7V
Maximum Low Voltage : 0.3V

VBUS valid rage : 2.0 ~ 4.0V

Bus Timing :

Minimum WR width : 15ns
Minimim CS_L to WR_L delay : 2 ns
Minimum WR_H to CS_H delay : 0ns
所以CS最小寬度是15+2 = 17ns

也就是說,CS有低於0.3V 的 pulse 維持17ns 以上,就會被可為bus access。

另外RESET pin 腳,minimum pulse = 500us