lianzhong008 发表于 2014-12-20 17:58:07

资源共享:eMMC驱动源码

        经过一个星期的努力终于搞定了eMMC的驱动调试。调试的过程可谓坎坷曲折,代码粗陋简略,忽略了很多返回信息的解析。主要是和项目需求有关,只
需读的功能就ok了。所以也就不费神去折腾那么多的东西了。由于刚开始连eMMC这个概念都不知道是什么,所以上网搜了不少资料。百度的功能真厉害,不想
搜的出了一大堆,想要的没几篇,当然不是挑百度的刺,资料有没有帮助,这得看按需的啦,说实话工作了3年度娘的帮助不是盖的。eMMC的驱动和SD卡的
驱动有9分相似。个人觉得。感觉网上eMMC驱动的资料当真不多,特在此分享调试经验及相关驱动资料以及驱动源码,希望有需要的朋友少走弯路。单块读
写已经验证可以用。需要更复杂的功能的朋友,可以在此基础上添加。推荐多看资料里的MMC.CHM文档。

亲爱的混蛋 发表于 2014-12-20 19:05:19

我最近也在研究EMMC,不过是用来做优盘

lianzhong008 发表于 2015-1-27 17:31:03

{:victory:},自己顶一下。好久没到这里溜达溜达了。上来补充一下Emmc驱动的问题。一般emmc会分为以下几个区
BootAreaPartition1、BootAreaPartition2、RPMBPartition、UserDataArea。emmc复位或启动默认访问的UserDataArea,
要想访问其他区域必需使用Switch命令进行相关的配置。以下为访问BootAreaPartition1的读函数。
/**
* Function:                        Read a single block by SDR mode
* Arg:
*            busmode                       support 1bit and 8 bit bus mode
*           blk_length                set the block length ,but not detect the aligh now
*           addr                                this function not detect the validity of this parament
* return :                         No.
* Author:                                 zhangweixiang--datoudatou37@gmail.com 2013/05/29 version-1.0
**/
void emmc_sin_blk_read( unsigned int addr, uchar busmode, unsigned int blk_length,unsigned char *z_ReadDataBuff)
{

                emmc_sel_dis_card(0x02 ,ENABLE);

        time_delay_ms(1);

        /* select the 8 bit bus width without ddr mode */
        if (busmode == BUS8_SDR_MODE) {
       
                //emmc_set_switch_cmd(BUS8_SDR);

                time_delay_ms(3);
               
                emmc_set_switch_cmd(BUS8_SDR);//set buswith
               
                time_delay_ms(3);
                //0x03b30900
                emmc_set_switch_cmd(0x03b30900);//set bootpartion1 access
                time_delay_ms(3);
        }
        /* 2. send CMD16 to set the block length*/
#if 1



        emmc_set_block_length(blk_length);

        time_delay_ms(1);

#endif

        if (busmode == BUS8_SDR_MODE) {

       // while(1)
      {
                        single_block_read_8(addr,z_ReadDataBuff);
                        //printf("clc\r\n");
                        //time_delay_ms(5);
      }


                time_delay_ms(1);

        } else {

                single_block_read(addr);
                time_delay_ms(1);
        }
        /*
       * Send CMD12 Stop the data trans
       * Note: if the data tran finish
       *                this cmd don't affect
       *               anything
       */
        emmc_stop_tran_cmd();
        time_delay_ms(1);
        /* Send CMD7 with discard to disselect the card */
        emmc_cancel_sel_card();
        time_delay_ms(11);

        return ;
}

lianzhong008 发表于 2015-1-27 17:48:54

在调试访问BootAreaPartition1区时,参考研究了,平板端提供的linux如何访问emmc的驱动片段。后来还是靠研究EMMC协议标准4.4才知道怎么操作。哈,还是欠缺经验。

hexiaolong2009 发表于 2015-1-27 18:55:45

对我有用,非常感谢

huangqi412 发表于 2015-1-27 21:06:46

收下了,EMMC驱动。

mcuprogram 发表于 2015-1-27 21:30:13

RPMB这个区域怎么访问及有何意义。

LK9286 发表于 2015-2-4 11:07:17

收藏了谢谢

ecut 发表于 2015-2-4 21:04:24

收藏了,赞

richards 发表于 2015-2-4 22:37:54

以前我也写过 一直有问题参考下

一匹狼 发表于 2016-12-20 10:54:39

mark, 正需要,谢分享~

hefanghua 发表于 2017-4-24 20:47:10

感谢分享。{:handshake:}

502363916 发表于 2017-4-25 18:08:38

谢谢楼主 现在还没用过emmc呢 想之后自己玩玩

lworldstar 发表于 2018-6-6 18:57:15

想不到一早就有人分享了EMMC驱动,到现在网络上的资料还是挺少的
页: [1]
查看完整版本: 资源共享:eMMC驱动源码