先来看看SDHC定义:
SDHC是"Secure Digital High Capacity“的缩写,即“高容量SD存储卡”。2006年5月SD协会发布了最新版的SD 2.0的系统规范,在其中规定SDHC是符合新的规范、且容量大于2GB小于等于32GB的SD卡。(引自百度百科)
方法主要参考gooogleman的博客文章:http://blog.csdn.net/gooogleman/archive/2009/05/07/4154020.aspx
1、更新pb。(这步没做,我的pb已经打了08、09年的补丁了)
2、在platform->setting->environment 中设置IMGSDBUS2 = 1
之所以要设置这个环境变量是因为sdbus2.dll 才支持大容量的SD的。
在common.bib中
#if defined IMGSDBUS2
; @CESYSGEN IF CE_MODULES_SDBUS2
sdbus.dll $(_FLATRELEASEDIR)\sdbus2.dll NK SH
; @CESYSGEN ENDIF CE_MODULES_SDBUS2
#else
; @CESYSGEN IF CE_MODULES_SDBUS
sdbus.dll $(_FLATRELEASEDIR)\sdbus.dll NK SH
; @CESYSGEN ENDIF CE_MODULES_SDBUS
#endif
3、修改BSP下的代码(蓝色为添加部分)
(1)SendCommand(UINT16 Cmd, UINT32 Arg, UINT16 respType, BOOL bDataTransfer)函数:
case ResponseR1: // Short response required
case ResponseR1b:
case ResponseR3:
case ResponseR4:
case ResponseR5:
case ResponseR6:
case ResponseR7:
DEBUGMSG (SDHC_RESPONSE_ZONE,(TEXT("sendSDICommand short response required\r\n")));
//vm_pSDIReg->SDICCON = uiNewCmdRegVal | WAIT_FOR_RESPONSE | START_COMMAND | COMMAND_START_BIT | (Cmd & MAX_CMD_VALUE); vm_pSDIReg->SDICCON = WAIT_FOR_RESPONSE | START_COMMAND | COMMAND_START_BIT | (Cmd & MAX_CMD_VALUE);
break;
(2)函数GetCommandResponse(PSD_BUS_REQUEST pRequest)中:
case ResponseR5:
case ResponseR6:
//--- SHORT RESPONSE (48 bits total)---
// Format: { START_BIT(1) | TRANSMISSION_BIT(1) | COMMAND_INDEX(6) | RCA(16) | CARD_STATUS(16) | CRC7(7) | END_BIT(1) }
//
*(respBuff ) = (BYTE)(START_BIT | TRANSMISSION_BIT | pRequest->CommandCode);
*(respBuff + 1) = (BYTE)(vm_pSDIReg->SDIRSP0 );
*(respBuff + 2) = (BYTE)(vm_pSDIReg->SDIRSP0 >> 8 );
*(respBuff + 3) = (BYTE)(vm_pSDIReg->SDIRSP0 >> 16);
*(respBuff + 4) = (BYTE)(vm_pSDIReg->SDIRSP0 >> 24);
*(respBuff + 5) = (BYTE)(vm_pSDIReg->SDIRSP1 >> 24);
break;
case ResponseR7:
//--- SHORT RESPONSE (48 bits total)---
// Format: { START_BIT(1) | TRANSMISSION_BIT(1) | COMMAND_INDEX(6) | CARD_STATUS(32) | CRC7(7) | END_BIT(1) }
// NOTE: START_BIT and TRANSMISSION_BIT = 0, END_BIT = 1
*(respBuff ) = (BYTE)(START_BIT | TRANSMISSION_BIT | pRequest->CommandCode);
*(respBuff + 1) = (BYTE)(vm_pSDIReg->SDIRSP0 );
*(respBuff + 2) = (BYTE)(vm_pSDIReg->SDIRSP0 >> 8 );
*(respBuff + 3) = (BYTE)(vm_pSDIReg->SDIRSP0 >> 16);
*(respBuff + 4) = (BYTE)(vm_pSDIReg->SDIRSP0 >> 24);
*(respBuff + 5) = (BYTE)(END_RESERVED | END_BIT);
break;
主要是要添加对cmd8的支持。
4、重新sysgen整个工程即可。
好像不是很复杂,可是开始按此步骤执行完后,插入4G卡就是无法识别。仔细检查后发现ce.bib文件中仍有这么一行:
sdbus.dll E:\WINCE500\PBWorkspaces\JEJA01\RelDir\SMDK2440A_Paul_ARMV4I_Release\sdbus.dll NK SH
看来设置的环境变量对common.bib没起作用!索性把common.bib中的
sdbus.dll $(_FLATRELEASEDIR)\sdbus.dll NK SH
改为
sdbus.dll $(_FLATRELEASEDIR)\sdbus2.dll NK SH
重新make run-time image, 结果就成功了! :)
另:
为啥设置的环境变量没起作用呢?无意中看到一篇文章:空格带来的郁闷---让Pxa270支持大容量SD卡
果然发现IMGSDBUS2后面有一个空格,汗!