|
本帖最后由 hackpascal 于 2014-4-3 12:52 编辑
参考 http://wiki.openwrt.org/ru/toh/tp-link/tl-mr3420/deep.mmc.hack (俄语),成功地在路由上添加了 SD/MMC 接口,使用的是 SPI 模式。
OpenWrt Wiki 上的接线图 (稍作修改):
简要说明:
SoC 是 AR7241,设备是 TP-LINK TL-WR841N v7.1。
根据接线图在 FLASH 焊盘上找到对应的 SCLK DI DO 针脚,并将其引出,接在 SD 的接口上(用卡套或插槽)
Vdd 需要 3.3V 电压,可选择 TTL 的 Vdd,也可直接使用 FLASH 的 Vdd。
GND 随便找个地方接
CS 针脚:
有两种选择,要么用 SoC 内部的 CS 针脚,要么使用普通的 GPIO 针脚。
这里建议使用普通的 GPIO,因为内部的 CS 一个被 SYS LED 占用了,一个被 QSS LED 占用了。
经网上查找和测试发现 WR841N v7.1 的 GPIO7 和 GPIO18 是可以用的。
GPIO7 对应的针脚为 82,对应的电阻为 R617。
GPIO18 对应的针脚为 85,对应的电阻为 R427。
图:
以 GPIO7 为例:
拆掉 R617 电阻,然后将 CS 接在靠近 SoC 的焊盘上。
以 GPIO18 为例:
拆掉 R427 电阻,然后将 CS 接在远离 SoC 的焊盘上。
CS 另需接一个 10K 的上拉电阻到 Vdd (3.3V) 上。
实际接线:
MicroSD 卡槽:
整体图:
背部:
编译代码:
直接安装驱动是不行的,必须要修改架构代码。
针对 OpenWrt Barrier Breaker:
- diff --git a/target/linux/ar71xx/files/arch/mips/ath79/dev-m25p80.c b/target/linux/ar71xx/files/arch/mips/ath79/dev-m25p80.c
- index 9323b31..50ea143 100644
- --- a/target/linux/ar71xx/files/arch/mips/ath79/dev-m25p80.c
- +++ b/target/linux/ar71xx/files/arch/mips/ath79/dev-m25p80.c
- @@ -7,14 +7,23 @@
- */
-
- #include <linux/init.h>
- +#include <linux/mmc/host.h>
- #include <linux/spi/spi.h>
- #include <linux/spi/flash.h>
- +#include <linux/spi/mmc_spi.h>
- #include <linux/mtd/mtd.h>
- #include <linux/mtd/partitions.h>
- #include <linux/mtd/concat.h>
-
- #include "dev-spi.h"
- #include "dev-m25p80.h"
- +
- +static struct mmc_spi_platform_data ath79_mmc_data = {
- + .get_ro = NULL,
- + .get_cd = NULL,
- + .detect_delay = 100, /* msecs */
- + .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
- +};
-
- static struct ath79_spi_controller_data ath79_spi0_cdata =
- {
- @@ -24,8 +33,8 @@ static struct ath79_spi_controller_data ath79_spi0_cdata =
-
- static struct ath79_spi_controller_data ath79_spi1_cdata =
- {
- - .cs_type = ATH79_SPI_CS_TYPE_INTERNAL,
- - .cs_line = 1,
- + .cs_type = ATH79_SPI_CS_TYPE_GPIO,
- + .cs_line = 7, /* GPIO 号,7 或 18 */
- };
-
- static struct spi_board_info ath79_spi_info[] = {
- @@ -40,7 +49,8 @@ static struct spi_board_info ath79_spi_info[] = {
- .bus_num = 0,
- .chip_select = 1,
- .max_speed_hz = 25000000,
- - .modalias = "m25p80",
- + .modalias = "mmc_spi",
- + .platform_data = &ath79_mmc_data,
- .controller_data = &ath79_spi1_cdata,
- }
- };
- @@ -50,10 +60,10 @@ static struct ath79_spi_platform_data ath79_spi_data;
- void __init ath79_register_m25p80(struct flash_platform_data *pdata)
- {
- ath79_spi_data.bus_num = 0;
- - ath79_spi_data.num_chipselect = 1;
- + ath79_spi_data.num_chipselect = 2;
- ath79_spi0_cdata.is_flash = true;
- ath79_spi_info[0].platform_data = pdata;
- - ath79_register_spi(&ath79_spi_data, ath79_spi_info, 1);
- + ath79_register_spi(&ath79_spi_data, ath79_spi_info, 2);
- }
-
- static struct flash_platform_data *multi_pdata;
复制代码
patch 格式,- 是删除行,+ 是添加行。
对照修改。
重新编译,并加上 kmod-mmc 和 kmod-mmc-spi 即可。
修改好之后:
内核日志:
[ 3.010000] TCP: cubic registered
[ 3.020000] NET: Registered protocol family 17
[ 3.020000] 8021q: 802.1Q VLAN Support v1.8
[ 3.030000] VFS: Mounted root (squashfs filesystem) readonly on device 31:2.
[ 3.040000] Freeing unused kernel memory: 220K (80329000 - 80360000)
[ 8.660000] mmc_spi spi0.1: SD/MMC host mmc0, no DMA, no WP, no poweroff
[ 8.810000] mmc0: host does not support reading read-only switch. assuming write-enable.
[ 8.810000] mmc0: new SDHC card on SPI
[ 8.820000] mmcblk0: mmc0:0000 SS08G 7.40 GiB
[ 8.830000] mmcblk0: p1 p2
[ 8.870000] SCSI subsystem initialized
[ 9.150000] usbcore: registered new interface driver usbfs
[ 9.160000] usbcore: registered new interface driver hub
[ 9.160000] usbcore: registered new device driver usb
[ 9.390000] Button Hotplug driver version 0.4.1
截图:
由于使用 SPI 接口,其时钟频率会受到 FLASH 的限制,及只能以低的时钟频率为准。由于 SPI FLASH 的时钟频率不能太高,一般在 UBoot 中都设在 25MHz 左右,传输速率远低于 SD 的最大传输速率。
因此在这种情况下对 SD 的读写效率不会太高。
使用测试:
SD卡: ADATA MicroSD 8G Class 4
网络:有线 LAN 100mbps
FTP上传:5~7Mbps (0.6MB/s ~ 0.9MB/s)
FTP 下载:8~9Mbps (大概 1MB/s)
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
×
评分
-
查看全部评分
|