上一篇《x210项目重新回顾之三.....》只是基础部分移动(包含两阶段,重定位),这节移植mmc,细节可看朱老师课程2.12.19.SD卡驱动移植3_2.12.U-Boot移植2-官方标准移植-U-Boot和系统移植阶段第十二部分_嵌入式开发视频-51CTO学堂。
直接拷贝三星官方uboot里的mmc驱动,做修改
代码链接:https://github.com/jimingkang/news5pv210/tree/master/u-boot-2013.10
代码变动如下:
>git status
1.修改 : board/samsung/goni/Makefile
增加 COBJS-y := goni.o setup_hsmmc.o
2. 修改: board/samsung/goni/goni.c
直接修改int board_mmc_init(bd_t *bis)函数内容:
{
#ifdef CONFIG_S3C_HSMMC
setup_hsmmc_clock();
setup_hsmmc_cfg_gpio();
return smdk_s3c_hsmmc_init();
#else
return 0;
#endif
}
3.直接替换: common/cmd_mmc.c
4.修改: drivers/mmc/Makefile
添加:COBJS-$(CONFIG_S3C_HSMMC) += s3c_hsmmc.o
注释#COBJS-$(CONFIG_GENERIC_MMC) += mmc_write.o
5.直接替换: drivers/mmc/mmc.c
6.修改: include/configs/s5p_goni.h
/* MMC */
#define CONFIG_GENERIC_MMC
#define CONFIG_MMC
//#define CONFIG_SDHCI
//#define CONFIG_S5P_SDHCI
//jimmy add for mmc
#define CONFIG_S3C_HSMMC // 添加这一行添加上新的移植过来的驱动文件
/* IROM specific data */
#define SDMMC_BLK_SIZE (0xD003A500)
#define COPY_SDMMC_TO_MEM (0xD003E008)
/* The macro for MMC channel 0 is defined by default and can't be undefined */
#define USE_MMC0
#define USE_MMC2
#define MMC_MAX_CHANNEL 4
7. 直接替换: include/mmc.h
8.(新增)
board/samsung/goni/setup_hsmmc.c
drivers/mmc/s3c_hsmmc.c
include/s3c_hsmmc.h
烧些后,输出:
-------------------------------------------------
CPU: S5PC110@400MHz
Board: Goni
I2C: ready
DRAM: 464 MiB
Board PMIC init
MMC: 3776MB (显示了卡槽2的sd大小)
In: serial
Out: serial
Err: serial
Net: Net Initialization Skipped
No ethernet found.
Hit any key to stop autoboot: 0
Goni # mmc
Usage:
MMC sub system
Goni # mmc read 300000000 1# 1
MMC Device 300000000 not found
Goni # mmc read 1 300000000 1# 1
MMC read: dev # 1, block # 1, count 1 ...1 blocks read: OK
Goni # print
baudrate=115200
bootargs=root=/dev/nfs rw nfsroot=172.16.96.215:/arm-nfs,proto=tcp,nfsvers=3,nolock ip=172.16.96.253:172.16.96.215:172.16.96.1:255.255.254.0::eth0:off console=ttySAC2,115200 init=/linuxrc
bootcmd=movi read kernel 30008000; movi read rootfs 30B00000 300000; bootm 30008000 30B00000
bootdelay=3
ethaddr=00:40:5c:26:0a:5b
gatewayip=172.16.96.215
ipaddr=172.16.96.253
mtdpart=80000 400000 3000000
netmask=255.255.254.0
serverip=172.16.96.215
Environment size: 476/16380 bytes
Goni # movi
Unknown command 'movi' - try 'help'
Goni # md 300000000 4
00000000: ea00002a eafffffe eafffffe eafffffe *...............
Goni # mmc help
Goni # mmc read 1 30000000 1# 1
MMC read: dev # 1, block # 1, count 1 ...1 blocks read: OK
Goni # md 30000000
30000000: 00002000 00000000 000d8a67 00000000 . ......g.......
Goni # mmc list
S3C_HSMMC0_dev0
S3C_HSMMC2_dev1(这个就是卡槽2的卡,也就是我们烧写用的)
Goni # help mmc
mmc - MMC sub system
Usage:
mmc read
mmc write
mmc rescan
mmc list - list available devices
Goni # md 31000000 (显示内存31000000处内容)
31000000: a4251c3d 90a83015 0c254e2c 904a1206 =.%..0..,N%...J.
Goni # mw.l 31000000 12345678 (修改内存31000000处内容)
Goni # md 31000000
31000000: 12345678 90a83015 0c254e2c 904a1206 xV4..0..,N%...J.
Goni # mmc write 1 31000000 1# 1 (把修改的内存31000000处内容,写入卡槽2的sd中,覆盖了uboot,下次启动出错)
MMC write: dev # 1, block # 1, count 1 ... 1 blocks written: OK
Goni # mmc read 1 33000000 1# 1 (再把卡槽2的sd中1扇区的内容读到33000000处)
Goni # md 33000000 (显示内存33000000处内容)
33000000: 12345678 90a83015 0c254e2c 904a1206 xV4..0..,N%...J.