Announcement

Collapse
No announcement yet.

Connecting a SDHC card

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Connecting a SDHC card

    Dear all,

    I have a SanDisk Ultra 4GB SDHC card and my laptop has a card reader which supports it. Unfortunately there is only one way I can get it to work and that is by booting my laptop with the card already inserted into the reader.

    This way it works perfectly even after dismounting and re-mounting. However if I boot my laptop without the card inserted into the reader, the card does not work (it does not connect, I do not get any messages, it simply does not exist according to my laptop).

    To get it working again I then need to re-boot my laptop with the card inserted into the reader. So there is a working solution however it is an inconvenient work-around.

    Might somebody know how I could get it to work no matter if I boot my laptop with or without the card inserted into the reader?

    Thank you for your help!

    Regards,

    Calubuntu

    #2
    As I'm no expert on this matter, just a hint that might point you in the right direction:

    It seems a kernel module gets loaded when you boot with the card inserted, but not when you boot without.
    "lsmod" tells you which modules are currently loaded,
    So, a crude approach would be to boot with the card inserted, do a lsmod and save the output in some file:
    lsmod > file1.
    Now reboot without the card and execute:
    lsmod > file2 (of course in the same directory where you created "file1".
    Now do a:
    diff file1 file2
    Look in the output for a line that is in file1, but not in file2.
    If you think you found a suspect, you can load the module with:
    modprobe some_module

    Gerhard

    Comment


      #3
      gerhard54 beat me to it. I would add that once you think you've located the module you can use

      modinfo modulename

      to get the info on it and see if there are any parameters you can set ("parm"s)
      "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
      – John F. Kennedy, February 26, 1962.

      Comment


        #4
        Thank you very much GreyGeek and gerhard54 for your support. I have done exactly as gerhard54 suggested. I indeed found a difference in modules loaded. However manually loading them myself did no good.

        With the SD card inserted, I get these extra modules:

        jmb38x_ms
        memstick
        mmc_block
        sdhci_pci
        sdhci

        These do not load if I booted my laptop without the SD card inserted into the reader. The exact output for lsmod without the SD card was:

        Code:
        carlos@nuitari:~$ lsmod
        Module                  Size  Used by
        rfcomm                 47946  8 
        bnep                   18436  2 
        bbswitch               13396  0 
        speedstep_lib          13195  0 
        parport_pc             36962  0 
        ppdev                  17113  0 
        binfmt_misc            17540  1 
        dm_crypt               23199  0 
        snd_hda_codec_hdmi     32040  1 
        snd_hda_codec_realtek   330815  1 
        joydev                 17693  0 
        snd_hda_intel          33390  2 
        snd_hda_codec         104968  3 snd_hda_codec_hdmi,snd_hda_codec_realtek,snd_hda_intel
        snd_hwdep              13668  1 snd_hda_codec
        snd_pcm                96714  3 snd_hda_codec_hdmi,snd_hda_intel,snd_hda_codec
        snd_timer              29991  1 snd_pcm
        snd                    68266  11 snd_hda_codec_hdmi,snd_hda_codec_realtek,snd_hda_intel,snd_hda_codec,snd_hwdep,snd_pcm,snd_timer
        arc4                   12529  2 
        soundcore              12680  1 snd
        iwlagn                314257  0 
        mac80211              462046  1 iwlagn
        cfg80211              199630  2 iwlagn,mac80211
        mei                    41480  0 
        uvcvideo               72711  0 
        videodev               93004  1 uvcvideo
        btusb                  18600  2 
        dell_laptop            13831  0 
        dcdbas                 14490  1 dell_laptop
        snd_page_alloc         18529  2 snd_hda_intel,snd_pcm
        dell_wmi               12681  0 
        psmouse                73882  0 
        v4l2_compat_ioctl32    17083  1 videodev
        serio_raw              13166  0 
        sparse_keymap          13890  1 dell_wmi
        bluetooth             166150  23 rfcomm,bnep,btusb
        lp                     17799  0 
        parport                46562  3 parport_pc,ppdev,lp
        usbhid                 47198  0 
        hid                    95463  1 usbhid
        i915                  571299  3 
        r8169                  52788  0 
        ahci                   26002  3 
        drm_kms_helper         42558  1 i915
        libahci                26861  1 ahci
        drm                   236290  4 i915,drm_kms_helper
        xhci_hcd               82820  0 
        i2c_algo_bit           13423  1 i915
        wmi                    19256  1 dell_wmi
        video                  19597  1 i915
        And with the SD card inserted lsmod gives:

        Code:
        carlos@nuitari:~$ lsmod
        Module                  Size  Used by
        bnep                   18436  2 
        rfcomm                 47946  8 
        bbswitch               13396  0 
        speedstep_lib          13195  0 
        parport_pc             36962  0 
        ppdev                  17113  0 
        binfmt_misc            17540  1 
        dm_crypt               23199  0 
        joydev                 17693  0 
        snd_hda_codec_hdmi     32040  1 
        snd_hda_codec_realtek   330815  1 
        uvcvideo               72711  0 
        videodev               93004  1 uvcvideo
        arc4                   12529  2 
        iwlagn                314257  0 
        snd_hda_intel          33390  2 
        snd_hda_codec         104968  3 snd_hda_codec_hdmi,snd_hda_codec_realtek,snd_hda_intel
        snd_hwdep              13668  1 snd_hda_codec
        snd_pcm                96714  3 snd_hda_codec_hdmi,snd_hda_intel,snd_hda_codec
        mac80211              462046  1 iwlagn
        cfg80211              199630  2 iwlagn,mac80211
        mei                    41480  0 
        snd_timer              29991  1 snd_pcm
        snd                    68266  11 snd_hda_codec_hdmi,snd_hda_codec_realtek,snd_hda_intel,snd_hda_codec,snd_hwdep,snd_pcm,snd_timer
        soundcore              12680  1 snd
        psmouse                73882  0 
        dell_laptop            13831  0 
        dcdbas                 14490  1 dell_laptop
        snd_page_alloc         18529  2 snd_hda_intel,snd_pcm
        btusb                  18600  2 
        jmb38x_ms              17646  0 
        dell_wmi               12681  0 
        memstick               16569  1 jmb38x_ms
        v4l2_compat_ioctl32    17083  1 videodev
        serio_raw              13166  0 
        sparse_keymap          13890  1 dell_wmi
        bluetooth             166150  23 bnep,rfcomm,btusb
        lp                     17799  0 
        parport                46562  3 parport_pc,ppdev,lp                                                                                                                                                     
        usbhid                 47198  0                                                                                                                                                                         
        hid                    95463  1 usbhid                                                                                                                                                                  
        mmc_block              22923  0                                                                                                                                                                         
        r8169                  52788  0                                                                                                                                                                         
        i915                  571299  3                                                                                                                                                                         
        ahci                   26002  3                                                                                                                                                                         
        libahci                26861  1 ahci                                                                                                                                                                    
        drm_kms_helper         42558  1 i915                                                                                                                                                                    
        sdhci_pci              14032  0                                                                                                                                                                         
        sdhci                  32166  1 sdhci_pci                                                                                                                                                               
        drm                   236290  4 i915,drm_kms_helper                                                                                                                                                     
        xhci_hcd               82820  0                                                                                                                                                                         
        wmi                    19256  1 dell_wmi                                                                                                                                                                
        i2c_algo_bit           13423  1 i915                                                                                                                                                                                             
        video                  19597  1 i915
        Are there any other things I need to check?

        Comment


          #5
          Hallo,

          A quick search showed you found the right moduels ;-)
          What is the output from the "modprobe" commands?

          You might try the following:
          When you boot with the card inserted, what is the coresponding entry for the card in the /dev directory?
          If in doubt, open it from dolphin and then look at the output of the "mount" command (with no arguments).
          (This will also tell you, what flags where given to the mount command and where the card gets mounted.)

          Now, if you boot without the card and insert the moduels manually:
          Does the entry in /dev exist?
          If yes, you may mount it manually (use the flags like above).
          If no: what is the output of "dmesg | tail" ?
          Hint:
          -) if you are not entirely shure you got the right messages, try dmesg | tail -20 os so...
          -) do it immedeatly after inserting the modules, otherwise the interesting lines might get burried some where deep inside the message file.

          Gerhard
          Last edited by gerhard54; May 21, 2012, 03:32 AM.

          Comment


            #6
            Thank you gerhard54 for your reply.

            The output your requested for booting with the card inserted into the reader are:

            Code:
            carlos@nuitari:~$ mount
            ---a lot of stuff---
            /dev/mmcblk0p1 on /media/3131-3238 type vfat (rw,nosuid,nodev,uid=1000,gid=1000,shortname=mixed,dmask=0077,utf8=1,showexec,uhelper=udisks)
            The output for booting without the card inserted into the reader is:

            Code:
            carlos@nuitari:~$ sudo modprobe jmb38x_ms
            [sudo] password for carlos: 
            carlos@nuitari:~$ sudo modprobe memstick
            carlos@nuitari:~$ sudo modprobe mmc_block
            carlos@nuitari:~$ sudo modprobe sdhci_pci
            carlos@nuitari:~$ sudo modprobe sdhci
            carlos@nuitari:~$ dmesg | tail -20
            [   19.382316] Bluetooth: RFCOMM TTY layer initialized
            [   19.382330] Bluetooth: RFCOMM socket layer initialized
            [   19.382336] Bluetooth: RFCOMM ver 1.11
            [   19.406113] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
            [   19.406117] Bluetooth: BNEP filters: protocol multicast
            [   19.953481] ADDRCONF(NETDEV_UP): wlan0: link is not ready
            [   20.213509] r8169 0000:06:00.0: eth0: link down
            [   20.214903] ADDRCONF(NETDEV_UP): eth0: link is not ready
            [   21.382195] EXT4-fs (sda3): re-mounted. Opts: errors=remount-ro,commit=0
            [   22.257237] init: plymouth-stop pre-start process (1375) terminated with status 1
            [   22.600039] wlan0: authenticate with 00:1e:e5:92:b1:ee (try 1)
            [   22.602670] wlan0: authenticated
            [   22.624183] wlan0: associate with 00:1e:e5:92:b1:ee (try 1)
            [   22.626659] wlan0: RX AssocResp from 00:1e:e5:92:b1:ee (capab=0x411 status=0 aid=2)
            [   22.626666] wlan0: associated
            [   22.634636] ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
            [   33.039642] wlan0: no IPv6 routers present
            [   35.064690] EXT4-fs (sda3): re-mounted. Opts: errors=remount-ro,commit=0
            [  141.158876] sdhci: Secure Digital Host Controller Interface driver
            [  141.158885] sdhci: Copyright(c) Pierre Ossman
            carlos@nuitari:~$ mount
            /dev/sda3 on / type ext4 (rw,errors=remount-ro,commit=0)
            proc on /proc type proc (rw,noexec,nosuid,nodev)
            sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
            fusectl on /sys/fs/fuse/connections type fusectl (rw)
            none on /sys/kernel/debug type debugfs (rw)
            none on /sys/kernel/security type securityfs (rw)
            udev on /dev type devtmpfs (rw,mode=0755)
            devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
            tmpfs on /run type tmpfs (rw,noexec,nosuid,size=10%,mode=0755)
            none on /run/lock type tmpfs (rw,noexec,nosuid,nodev,size=5242880)
            none on /run/shm type tmpfs (rw,nosuid,nodev)
            /dev/sda5 on /home type ext3 (rw,commit=0)
            binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noexec,nosuid,nodev)
            So the /dev point does not appear even after loading the modules manually.

            By looking around on some other sites, I have seen that this problem is encountered quite a lot on my type and some other type of laptops. A simple workaround (that work whether or not you boot with the card inserted into the reader) )is to execute the following command:

            Code:
            echo 1 > /sys/bus/pci/rescan
            To execute this command I need sudo rights. However the strange thing is that this does not work:

            Code:
            carlos@nuitari:~$ sudo echo 1 > /sys/bus/pci/rescan
            bash: /sys/bus/pci/rescan: Permission denied
            Yet this does work:

            Code:
            carlos@nuitari:~$ sudo -s
            [sudo] password for carlos: 
            root@nuitari:~# echo 1 > /sys/bus/pci/rescan
            root@nuitari:~#
            On the other sites they talked about compiling a c-code which would do that, however this did not work for me. Anyhow now I am wondering whether there is a way to put this in a shell script and to run this at startup by for example putting a symbolic link pointing to the shell script in ~/.kde/Autostart/ ?

            If you want to read more about this problem you can go to:

            https://bugs.launchpad.net/ubuntu/+s...ux/+bug/703180

            The c-code that did not work for me is:

            Code:
            #include <stdio.h>
            main(){
              FILE *outfile;
              outfile=fopen("/sys/bus/pci/rescan","w");
              if (outfile != NULL){
                fprintf(outfile,"1\n");
                fclose(outfile);
              }
              else printf("permission denied\n");
            }
            
            then compile with:
            gcc rescan.c -o rescan
            sudo cp rescan /usr/local/bin
            sudo chown root /usr/local/bin/rescan
            sudo chmod u+s /usr/local/bin/rescan
            So...the work around works fine however I would like to automate it by not having to do anything in the future.

            Comment


              #7
              Hello!

              To execute this command I need sudo rights. However the strange thing is that this does not work:
              sudo echo 1 > /sys/bus/pci/rescan
              Sudo runs the command ("echo") with root privileges only.
              I/O redirection applies to the current shell context (i.e. your rights as an "ordinary" user).
              Therfore you need to start a root shell. A simpler way might be:
              Code:
              sudo sh -c "echo 1 > /sys/bus/pci/rescan"
              (untested!)

              I would like to automate it by not having to do anything in the future.
              Full automation would be hard to achieve, as I cant think of a way to make the system aware, that a new pci-device was added.
              Putting some commands into a script that gets executed when KDE starts, would require the card to be present at startup of KDE.

              What you can automate is loading the additional modules at boot time.
              As I have no Kubuntu system at hand (at the office we run Redhat and Suse) I 'm not sure wich file you need to edit.
              To get the basic idea, look at this:
              http://www.linuxforums.org/forum/gen...ule-botup.html

              With the modules loaded, you will only have to rescan the bus as soon as you inserted your card.
              For this it would easiest to get c-code working.
              however this did not work for me
              In what way did it fail?
              As I dont know what experience with compiling c-code you have, forgive me if I mention something thats already clear to you

              Put this lines into a file called rescan.c
              Code:
              #include <stdio.h>
              main(){
                FILE *outfile;
                outfile=fopen("/sys/bus/pci/rescan","w");
                if (outfile != NULL){
                  fprintf(outfile,"1\n");
                  fclose(outfile);
                }
                else printf("permission denied\n");
              }
              Then run:
              Code:
              gcc rescan.c -o rescan
              sudo cp rescan /usr/local/bin
              sudo chown root /usr/local/bin/rescan
              sudo chmod u+s /usr/local/bin/rescan
              As soon as you get this working, the only thing left is creating a link to the "rescan"-executable on your desktop.
              After inserting the card, you would just click the icon....

              Hope that helps
              Gerhard

              Comment


                #8
                Thank you gerhard54!

                I tried the c-code again and I do not know why, but this time around it did work... Anyways that is great!

                I tried to automate this by putting a symbolic link in ~/.kde/Autostart/ however this does not work unfortunately.

                Anyways I am satisfied for now with the working c-code. I will now set this thread to solved.

                Thank you very much for your time and effort gerhard54!

                Comment


                  #9
                  You are welcome

                  BTW: as I pointed out: ~/.kde/Autostart/ gets executed only once, that is when KDE starts.
                  So if there is no card in the reader at that moment, it can't work!

                  Gerhard

                  Comment


                    #10
                    Well actually that's the thing. It does work without inserting the card. I have done it multiple times. However it does not work in combination with ~/.kde/Autostart/

                    Comment


                      #11
                      Did you use the autostart-manager (Systemsettings->Advanced)?
                      Take a look at:http://docs.kde.org/stable/en/kde-wo...art/index.html.

                      What I found out: a script to run at "Startup" it MUST have the extension ".sh".
                      The manual says, this is only necessary if it should run at "Pre-KDE startup" or "Shutdown".

                      I tested it with a small script:
                      Code:
                      date >> /home/gerhard/test_log
                      Naming it "testscript", it didn't work. But renaming it to "testscript.sh" (and changing the entry with the autostart manager) did the trick.

                      Gerhard

                      Comment

                      Working...
                      X