How to interface a second sd card (that operates in SPI mode) under the 4.1 kernel?

462 views
Skip to first unread message

thom...@googlemail.com

unread,
Aug 4, 2015, 4:57:28 PM8/4/15
to BeagleBoard, Thomas Turner
I am using the Digilent PmodSD as the second sd card for the BBB: http://www.digilentinc.com/Products/Detail.cfm?Prod=PMOD-SD


but assumes that i have the mmc_spi driver, which isnt found in the 4.1.2-ti-r4 kernel on my beaglebone: mmc_spi.c source file doesnt exist also.

root@beaglebone:~# find /lib/modules/`uname -r` -type f -name "*.ko" | grep mmc

/lib/modules/4.1.2-ti-r4/kernel/drivers/media/mmc/siano/smssdio.ko
/lib/modules/4.1.2-ti-r4/kernel/drivers/mmc/host/sdhci.ko
/lib/modules/4.1.2-ti-r4/kernel/drivers/mmc/host/vub300.ko
/lib/modules/4.1.2-ti-r4/kernel/drivers/mmc/host/dw_mmc-exynos.ko
/lib/modules/4.1.2-ti-r4/kernel/drivers/mmc/host/dw_mmc-pltfm.ko
/lib/modules/4.1.2-ti-r4/kernel/drivers/mmc/host/ushc.ko
/lib/modules/4.1.2-ti-r4/kernel/drivers/mmc/host/dw_mmc.ko
/lib/modules/4.1.2-ti-r4/kernel/drivers/mmc/host/sdhci-pltfm.ko
/lib/modules/4.1.2-ti-r4/kernel/drivers/mmc/host/rtsx_usb_sdmmc.ko
/lib/modules/4.1.2-ti-r4/kernel/drivers/mmc/card/sdio_uart.ko


 root@beaglebone:~# find /lib/modules/`uname -r` -type f -name "*.ko" | grep spi


/lib/modules/4.1.2-ti-r4/kernel/drivers/misc/ad525x_dpot-spi.ko
/lib/modules/4.1.2-ti-r4/kernel/drivers/spi/spi-butterfly.ko
/lib/modules/4.1.2-ti-r4/kernel/drivers/spi/spi-lm70llp.ko
/lib/modules/4.1.2-ti-r4/kernel/drivers/spi/spi-omap2-mcspi.ko
/lib/modules/4.1.2-ti-r4/kernel/drivers/mtd/spi-nor/spi-nor.ko
/lib/modules/4.1.2-ti-r4/kernel/drivers/scsi/scsi_transport_spi.ko
/lib/modules/4.1.2-ti-r4/kernel/drivers/net/wireless/ti/wl1251/wl1251_spi.ko
/lib/modules/4.1.2-ti-r4/kernel/drivers/net/wireless/ti/wlcore/wlcore_spi.ko
/lib/modules/4.1.2-ti-r4/kernel/drivers/net/can/spi/mcp251x.ko
/lib/modules/4.1.2-ti-r4/kernel/drivers/mfd/mc13xxx-spi.ko


 In another forum, a person solved this by actually interfacing the second SD to the mmc lines:  SPI-SD Card

I dont see how this will work since mmc1 lines on the p8 header are used by the board. And when i wire my sd card to these lines the Beaglebone doesnt boot up.  Also the mmc2 on the p8 header doesnt have a cmd mode pin (mmc2_cmd), so i cant use these lines.  There are another set of mmc2 lines on the p9 header but its also missing a mmc2_cmd and a  mmc2_clk mode pin. 

  Any insight on how to add a second SD card?

Robert Nelson

unread,
Aug 4, 2015, 5:07:25 PM8/4/15
to Beagle Board, Thomas Turner
CONFIG_HIGHMEM=y i set...

472 config MMC_SPI
473 tristate "MMC/SD/SDIO over SPI"
474 depends on SPI_MASTER && !HIGHMEM && HAS_DMA
475 select CRC7
476 select CRC_ITU_T
477 help
478 Some systems access MMC/SD/SDIO cards using a SPI controller
479 instead of using a "native" MMC/SD/SDIO controller. This has a
480 disadvantage of being relatively high overhead, but a compensating
481 advantage of working on many systems without dedicated MMC/SD/SDIO
482 controllers.
483
484 If unsure, or if your system has no SPI master driver, say N.

So rebuild the kernel without HIGHMEM, then you can enable MMC_SPI..

Regards,

--
Robert Nelson
https://rcn-ee.com/

Robert Nelson

unread,
Aug 4, 2015, 5:15:41 PM8/4/15
to Beagle Board, Thomas Turner

thom...@googlemail.com

unread,
Aug 5, 2015, 8:36:59 AM8/5/15
to BeagleBoard, thom...@gmail.com
I've managed to disable HIGHMEM from within the kernel.  However im having trouble compiling.  The usual 'make clean' and 'make all' gives me errors:

root@beaglebone:/usr/src/linux-headers-4.1.2-ti-r4# make all
  CHK     include/config/kernel.release
  UPD     include/config/kernel.release
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
  UPD     include/generated/utsrelease.h
make[1]: *** No rule to make target 'arch/arm/tools/gen-mach-types', needed by 'include/generated/mach-types.h'.  Stop.
arch/arm/Makefile:297: recipe for target 'archprepare' failed
make: *** [archprepare] Error 2


How do i compile the kernel with the changes made to .config?

Robert Nelson

unread,
Aug 5, 2015, 9:35:12 AM8/5/15
to Beagle Board, Thomas Turner
On Tue, Aug 4, 2015 at 7:32 PM, <thom...@googlemail.com> wrote:
> I've managed to disable HIGHMEM from within the kernel. However im having
> trouble compiling. The usual 'make clean' and 'make all' gives me errors:
>
> root@beaglebone:/usr/src/linux-headers-4.1.2-ti-r4# make all
> CHK include/config/kernel.release
> UPD include/config/kernel.release
> CHK include/generated/uapi/linux/version.h
> CHK include/generated/utsrelease.h
> UPD include/generated/utsrelease.h
> make[1]: *** No rule to make target 'arch/arm/tools/gen-mach-types', needed
> by 'include/generated/mach-types.h'. Stop.
> arch/arm/Makefile:297: recipe for target 'archprepare' failed
> make: *** [archprepare] Error 2

Sorry, that's "headers"....

> root@beaglebone:/usr/src/linux-"headers"-4.1.2-ti-r4# make all

Grab the source via:

git clone -b 4.1.2-ti-r4 https://github.com/beagleboard/linux --depth=1

thom...@googlemail.com

unread,
Aug 10, 2015, 3:00:12 PM8/10/15
to BeagleBoard, thom...@gmail.com
RCNelson, Thanks for you help so far.

When trying to compile the 4.1 kernel i'm running into an ftrace error:
...
arch/arm/kernel/ftrace.c: In function ‘ftrace_arch_code_modify_post_process’:
arch/arm/kernel/ftrace.c:93:2: error: implicit declaration of function ‘flush_tlb_all’ [-Werror=implicit-function-declaration]
  flush_tlb_all();
  ^
cc1: some warnings being treated as errors
scripts/Makefile.build:258: recipe for target 'arch/arm/kernel/ftrace.o' failed
make[1]: *** [arch/arm/kernel/ftrace.o] Error 1
Makefile:946: recipe for target 'arch/arm/kernel' failed
make: *** [arch/arm/kernel] Error 2


Is there any kernel patch i can install to fix this error?

Also I decided to use the mmc2 lines for the sd card instead of using the spi bus.  I believe that the pin configuration is correct but the beaglebone is still not detecting the sd card.

In the am335x-bone-common.dtsi file:

mmc2_pins: pinmux_mmc2_pins {
                pinctrl-single,pins = <
                        0x078 (PIN_OUTPUT_PULLUP | MUX_MODE3)           /* mmc2_dat3---CS, p9_12*/
                        0x044 (PIN_INPUT_PULLUP | MUX_MODE3)            /* mmc2_dat0---DO---MISO, p9_23 */
                        0x088 (PIN_OUTPUT_PULLUP | MUX_MODE3)           /* mmc2_cmd---T13---MOSI */
                        0x08c (PIN_OUTPUT_PULLUP | MUX_MODE3)           /* mmc2_clk, p8_18 */
                        0x040 (PIN_OUTPUT_PULLUP | MUX_MODE7)           /* R13 which is tied to T13, p9_15*/
                        0x074 (PIN_INPUT_PULLUP | MUX_MODE4)            /* mmc2_sdcd, p9_13 */
                        0x048 (PIN_INPUT_PULLUP | MUX_MODE3)            /* mmc2_dat1, p9_14 */
                        0x04c (PIN_INPUT_PULLUP | MUX_MODE3)            /* mmc2_dat2, p9_16 */

                >;


        };


&mmc2 {
        status = "okay";
        bus-width = <0x4>;
        pinctrl-names = "default";
        pinctrl-0 = <&mmc2_pins>;
};



and that the T13 line is tied to the R13 line, so i configured R13 to GPIO output pullup and T13 as mode 3 output pullup. 

Is there anything else in the device tree that needs to be edited in order to get mmc2 detected by the OS on the beaglebone?
Reply all
Reply to author
Forward
0 new messages