Author Topic: Mmc Soldered. Driver Almost Working  (Read 33306 times)

albertr

  • Hero Member
  • *****
  • Posts: 535
    • View Profile
    • http://
Mmc Soldered. Driver Almost Working
« Reply #15 on: September 17, 2005, 06:31:20 pm »
The same problem with 128MB SD card made by Sandisk.
Code: [Select]
mmc: GPIO init
mmc: initialising MMC
GPIO_SD_CS dir: 1 alt: 0
GPIO_SD_DI dir: 1 alt: 0
GPIO_SD_DO dir: 0 alt: 0
GPIO_SD_CS dir: 1 alt: 0
mmc: card init 1/2
mmc: card init 2/2
mmc: card init 3/3
Size = 123008, hardsectsize = 512, sectors = 246016
Partition check:
 mmca:end_request: I/O error, dev 79:00 (mmc), sector 0
end_request: I/O error, dev 79:00 (mmc), sector 2
end_request: I/O error, dev 79:00 (mmc), sector 4
end_request: I/O error, dev 79:00 (mmc), sector 6
end_request: I/O error, dev 79:00 (mmc), sector 0
end_request: I/O error, dev 79:00 (mmc), sector 2
end_request: I/O error, dev 79:00 (mmc), sector 4
end_request: I/O error, dev 79:00 (mmc), sector 6
 unable to read partition table

This one has a primary partition type "b" - W95 FAT32.

Guylhem, what card do you use? Can you post its partition table info?
-albertr

niv

  • Full Member
  • ***
  • Posts: 237
    • View Profile
Mmc Soldered. Driver Almost Working
« Reply #16 on: October 04, 2005, 02:10:04 pm »
[img]http://ak.buy.com/db_assets/prod_images/490/10359490.jpg\" border=\"0\" class=\"linked-image\" /]

If some1 may want to use a mmc/SD socket here is a cheap choice (got it at 19$ from amazon :-( two weeks ago

linky

albertr

  • Hero Member
  • *****
  • Posts: 535
    • View Profile
    • http://
Mmc Soldered. Driver Almost Working
« Reply #17 on: October 05, 2005, 12:23:47 pm »
The price for a SD/MMC socket varies from $1 to $3 depending on make.

I would like to see someone else got the driver working, thou. I didn't have much time to debug it, but it doesn't seem to work in my setup, and I'm not sure what I'm doing wrong either...
-albertr
« Last Edit: October 05, 2005, 12:24:16 pm by albertr »

guylhem

  • Hero Member
  • *****
  • Posts: 577
    • View Profile
Mmc Soldered. Driver Almost Working
« Reply #18 on: October 06, 2005, 07:20:53 am »
albertr, you must reread the partition of the card with forcepart. It's a simple ioctl. Tell me if it's not on the site, I'll upload it.

This is due to a bug in the current driver - it tries to read the partition table too early. Yet after that it works fine. To try out, try fdisk : pretend to make changes (say delete and recreate the same partition) then exit. It will send this ioctl.

This bug will be fixed in the next version which will also bring power management (for now you must umount before suspend or you'll have fs corruption)

albertr

  • Hero Member
  • *****
  • Posts: 535
    • View Profile
    • http://
Mmc Soldered. Driver Almost Working
« Reply #19 on: October 06, 2005, 12:53:27 pm »
Guylhem, thanks for explanation. Do you mean BLKRRPART ioctl()? When/How should I issue it? I.e. load the driver, make ioctl() call, then re-load the driver? I'm not sure since when driver is unloaded, device is gone, so no ioctl's can be made.
I'll give it a shot tonight when get back home.
-albertr
« Last Edit: October 06, 2005, 01:53:54 pm by albertr »

albertr

  • Hero Member
  • *****
  • Posts: 535
    • View Profile
    • http://
Mmc Soldered. Driver Almost Working
« Reply #20 on: October 06, 2005, 11:29:46 pm »
Still no go...
Here's the simple code that I'm trying to execute as per your suggestion (it's borrowed from fdisk code):
Code: [Select]
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include

#define BLKRRPART    _IO(0x12,95)    /* re-read partition table */
#define BLKGETSIZE   _IO(0x12,96)    /* return device size */
#define BLKFLSBUF    _IO(0x12,97)    /* flush buffer cache */
#define BLKSSZGET    _IO(0x12,104)   /* get block device sector size */
#define BLKGETSIZE64 _IOR(0x12,114,size_t)      /* size in bytes */

int
main(int argc, char **argv) {
        int fd = 0, error = 0;
        int i;
        char name[] ="/dev/mmc/disc0";
//      char name[] ="/dev/mmcda";

        if ((fd = open(name, O_RDWR)) < 0) {
                if ((fd = open(name, O_RDONLY)) < 0) {
                        printf("Failed to open %s, error[%d]: %s\n",
                                name, error, strerror(error));
                        exit(1);
                }
        }


        printf("Calling ioctl() to re-read partition table.\n");
        sync();
        sleep(2);
        if ((i = ioctl(fd, BLKRRPART)) != 0) {
                error = errno;
        } else {
                /* give it another chance */
                sync();
                sleep(2);
                if ((i = ioctl(fd, BLKRRPART)) != 0)
                        error = errno;
        }

        if (i) {
                printf("Re-reading the partition table failed with error %d: %s.\n",
                        error, strerror(error));
        }


        if (fsync(fd) || close(fd)) {
                printf("Error closing %s\n", name);
                exit(1);
        }

        exit(0);
}

Here's the output I'm getting:

Code: [Select]
# ./fc
Calling ioctl() to re-read partition table.
Re-reading the partition table failed with error 25: Inappropriate ioctl for device.
Error closing /dev/mmc/disc0

What I'm doing wrong?

-albertr

guylhem

  • Hero Member
  • *****
  • Posts: 577
    • View Profile
Mmc Soldered. Driver Almost Working
« Reply #21 on: October 07, 2005, 04:02:09 pm »
Hello

It's not exactly what I use. My code is pasted below. Please send that ~ 1 to 2 seconds after the insmod. I use /dev/mmc because I don't like "dynamic" /dev filesystems.

Code: [Select]
#include
#include
#include
#include
#include
#include /* BLKRRPART */
#include

int main(void) {
        char *device = "/dev/mmc";
        int fd, err;

        fd = open(device, O_RDONLY | O_NONBLOCK);
        if (fd < 0) {
                fprintf(stderr, "cannot open %s\n", device);
                exit(1);
        }

        err=ioctl(fd, BLKRRPART);

        if (err) {
               if (EBUSY == err) {
                fprintf(stderr, "%s : device busy\n", device);
//                      perror("EBUSY");
                        exit(-1);
                }
               if (EIO == err) {
//                      perror("EBUSY");
                        fprintf(stderr, "%s : no partition defined\n", device);
                        exit(-1);
                }
                perror("BLKRRPART");
                exit(-1);
        }

        return 0;
}

albertr

  • Hero Member
  • *****
  • Posts: 535
    • View Profile
    • http://
Mmc Soldered. Driver Almost Working
« Reply #22 on: October 08, 2005, 10:25:04 am »
Hah! I'm a dumbass! I was using the wrong device name, it's /dev/mmc/disc0/disc, and I was trying to open /dev/mmc/disc0 which was a devfs directory

I'm happy to report that driver works. I didn't do much of the testing yet, but at least I can mount a partition and read/write files.
It definitely looks promising... Great work, Guylhem!
-albertr
« Last Edit: October 08, 2005, 10:58:16 am by albertr »

albertr

  • Hero Member
  • *****
  • Posts: 535
    • View Profile
    • http://
Mmc Soldered. Driver Almost Working
« Reply #23 on: October 09, 2005, 03:07:02 pm »
I put some pictures here:

http://www.iral.com/~albertr/linux/simpad/mmc/

-albertr

Tom61

  • Sr. Member
  • ****
  • Posts: 252
    • View Profile
Mmc Soldered. Driver Almost Working
« Reply #24 on: October 09, 2005, 07:57:08 pm »
Quote
I put some pictures here:

http://www.iral.com/~albertr/linux/simpad/mmc/

-albertr
[div align=\"right\"][a href=\"index.php?act=findpost&pid=98763\"][{POST_SNAPBACK}][/a][/div]

Looks good. Hard to tell the slot wasn't put there at the factory!

albertr

  • Hero Member
  • *****
  • Posts: 535
    • View Profile
    • http://
Mmc Soldered. Driver Almost Working
« Reply #25 on: October 09, 2005, 08:44:20 pm »
That's what dremel is capable of
-albertr

guylhem

  • Hero Member
  • *****
  • Posts: 577
    • View Profile
Mmc Soldered. Driver Almost Working
« Reply #26 on: October 12, 2005, 09:15:36 am »
Quote
Hah! I'm a dumbass! I was using the wrong device name, it's /dev/mmc/disc0/disc, and I was trying to open /dev/mmc/disc0 which was a devfs directory

I'm happy to report that driver works. I didn't do much of the testing yet, but at least I can mount a partition and read/write files.
It definitely looks promising... Great work, Guylhem!
-albertr
[div align=\"right\"][a href=\"index.php?act=findpost&pid=98658\"][{POST_SNAPBACK}][/a][/div]

Thanks for the compliment albert :-) I saw you where using 3.3 from the JTAG. If you use my schema, you can use cs3 to control the power - thus cutting power to the bluetooth and the MMC while on sleep mode.

BTW, I'd be very interested in making a beautiful hole like you did. Where are you located? May I bring you/send you my simpad? I suck at cutting hole in plastic, and I fear I'll do an awful job compared to what you did.

I'd also be very happy to discuss with you the project I'm currently working on- a GSM addon to the simpad. I've some prototypes around, and I'm wondering what's the best option (hooking the GSM module to the external serial port, or using another bluetooth chip, to connect to it via bluetooth serial profile, and have a SCO connection to the cellphone while keeping the 1st bluetooth chip bandwith totally available for other applications, such as network connection. In the latter case, I'd be like having a bluetooth cellphone inside the simpad, only using its power and smartcard slot to access the SIM)

Guylhem

albertr

  • Hero Member
  • *****
  • Posts: 535
    • View Profile
    • http://
Mmc Soldered. Driver Almost Working
« Reply #27 on: October 12, 2005, 09:54:49 am »
I'm not good in cutting thru plastic too, but dremel was very handy. I'm curious how much current idle SD/MMC card is consuming? Might try to measure it sometime later to be certain. I'm planning to modify serial driver to send the break signal when port is closed, this way CSR bluetooth module would enter deep sleep mode to save the power.

Not really sure about serial GSM module, I don't have any experience with these. Besides, I always carry a cell phone with me anyway, but using Simpad only once in a while as a GPS navigation device.
I'm located in Eastern PA, USA.
-albertr

guylhem

  • Hero Member
  • *****
  • Posts: 577
    • View Profile
Mmc Soldered. Driver Almost Working
« Reply #28 on: October 13, 2005, 04:31:26 am »
Well that's a bit far from Europe. I'll try to play with a dremel to see what I can do with some training :-)

Guylhem

sash

  • Newbie
  • *
  • Posts: 12
    • View Profile
Mmc Soldered. Driver Almost Working
« Reply #29 on: October 25, 2005, 12:32:49 pm »
@Guylhem: How did you compile the kernel module?
I used the kernel 2.4.25 from your homepage, but I got many errors.

Maybe you can post the command line or a Makefile?

thx
Sascha