OpenWrt Forum Archive

Topic: ath79: SD-card on SPI-bus

The content of this topic has been archived between 6 Feb 2018 and 18 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Interesting, that site talks about desoldering the onboard resistor. I wonder if that would help.

Deoptim wrote:

By the way, you can patch the kernel in another way.
http://www.right.com.cn/Forum/thread-136884-1-1.html
(where we change only dev-m25p80.c driver)

That's ok, if it's all the same end result I'll stick with the original mod smile I'm guessing the code is correct and it's a hardware problem. I'll try messing with resistors I suppose.

(Last edited by lobonse on 5 Feb 2017, 18:15)

lobonse wrote:

Another concern I have is the WPS LED being lit constantly. If it is active low, this would indicate that the CS line is constantly being pulled low, no?

Looking at the image. I see that the LEDs powered by low signal (common plus "+" and logic minus via GPIO).
If you want to use LED as CS indicator, it is better to kept switched it on in parallel or just remove it!
Series connection is incorrect, since on the diode we have a significant voltage drop.

(Last edited by Deoptim on 5 Feb 2017, 19:10)

If you want to use LED as CS indicator, it is better to kept switched it on in parallel or just remove it!

Sorry, you lost me on that one. So the wire is soldered wrong? Where should it go, on the positive pole? I just want this sd card to work, I don't care which pin I need to use. I'd probably prefer not using the LED as an indicator since it just uses more power.

Anyhow, I changed to TP29 ( which I traced to gpio 11)which is a raw test point located between SoC and uart pins. I had tested it at boot, it went from ~0V to ~2.4v at the time the mmc was accessed and back low again. I then pulled it high to the SPI 3v3. Same result. Curiously, I have never seen a voltage above ~2.4V even with pullup resistors.

(Last edited by lobonse on 5 Feb 2017, 20:12)

About picture.
http://rs1378.pbsrc.com/albums/ah81/Deoptim/picture_zpsokntmogy.jpg?w=280&h=210&fit=crop
but as you change to another pin, it no longer makes sense

Ah I see, ok, I'll try that. On TP29 with all 4 pins pulled high (MOSI MISO SCK AND CS), still no love.

No luck, apart from more consistent failure( at least the mmc messages are showing up fairly consistently ):

[    2.380000] mmc0: host does not support reading read-only switch, assuming write-enable
[    2.390000] mmc0: new SDHC card on SPI
[    2.400000] jffs2: Empty flash at 0x000000a4 ends at 0x000000c0
[    2.410000] jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x000000c0: 0xfa67 instead
[    2.420000] jffs2: Empty flash at 0x000000c4 ends at 0x000000e0
[    2.420000] jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x000000e0: 0xfa67 instead
[    2.430000] mmcblk0: mmc0:0000 SA08G 7.21 GiB
[    2.440000] jffs2: Empty flash at 0x000000e4 ends at 0x00001120
[    2.450000] jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00001120: 0xfb67 instead
[    2.460000] mmcblk0: timed out sending r/w cmd command, card status 0x0
[    2.470000] blk_update_request: I/O error, dev mmcblk0, sector 0
[    2.470000] Buffer I/O error on dev mmcblk0, logical block 0, async page read
[    2.480000] jffs2: Empty flash at 0x00001124 ends at 0x00002140
[    2.490000] jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00002140: 0xfbff instead
[    2.500000] jffs2: Further such events for this erase block will not be printed
[    2.510000] mmcblk0: timed out sending r/w cmd command, card status 0x0
[    2.510000] blk_update_request: I/O error, dev mmcblk0, sector 0
[    2.520000] Buffer I/O error on dev mmcblk0, logical block 0, async page read
[    2.530000]  mmcblk0: unable to read partition table

(Last edited by lobonse on 5 Feb 2017, 21:07)

Insert mad scientist laughter! https://www.youtube.com/watch?v=MP2oWvh6I44

[   13.630000] mmc_spi spi0.1: SD/MMC host mmc0, no DMA, no WP, no poweroff
[   13.840000] mmc0: host does not support reading read-only switch. assuming write-enable.
[   13.850000] mmc0: new SDHC card on SPI
[   13.920000] mmcblk0: mmc0:0000 SA08G 7.21 GiB
[   13.940000]  mmcblk0: p1


On a lark I went back to Barrier Breaker, and it worked!
Now to find out why. Thanks so much for your help!

In my case the card wasn't found until about 10 seconds later than before. I wonder if it's related to timing?

As I might've guessed, I am having a little trouble with (pivot overlay) extroot. First, df -h:

Filesystem                Size      Used Available Use% Mounted on
rootfs                  512.0K    240.0K    272.0K  47% /
/dev/root                 2.0M      2.0M         0 100% /rom
tmpfs                    14.0M     52.0K     13.9M   0% /tmp
/dev/mtdblock5            3.4G      7.4M      3.2G   0% /overlay
overlayfs:/overlay      512.0K    240.0K    272.0K  47% /
tmpfs                   512.0K         0    512.0K   0% /dev
/dev/mmcblk0p1            3.4G      7.4M      3.2G   0% /overlay

/etc/config/fstab:

config 'global'
        option  anon_swap       '0'
        option  anon_mount      '0'
        option  auto_swap       '1'
        option  auto_mount      '1'
        option  delay_root      '15'
        option  check_fs        '0'

config 'mount'
        option  target  'overlay'
#       option  target  '/mnt/mmcblk0p1'
        option  uuid    '3944f3ce-5217-4a04-b066-459e4e4022b4'
        option  enabled '1'
        option  fstype  'ext4'

#config 'mount'
#       option  target  '/mnt/mmcblk0p2'
#       option  uuid    '2aa96367-00c4-4bae-a79e-a5998b872f10'
#       option  enabled '0'

Is this relevant:

[   12.370000] block: attempting to load /tmp/jffs_cfg/upper/etc/config/fstab
[   12.380000] block: unable to load configuration (fstab: Entry not found)
[   12.380000] block: attempting to load /tmp/jffs_cfg/etc/config/fstab
[   12.390000] block: extroot: not configured

Also, you said:

The integration of the required modules into the kernel, allows us to use detected SD-card on one level with NOR flash memory. For example: we can mount root-fs at kernel level by setting: CONFIG_CMDLINE="rootfstype=squashfs,jffs2,ext3 noinitrd root=/dev/mmcblk0p1 rootwait"

Which is ext4 for me. I put this in the config file in target/linux/ar71xx/config-3.10, but it doesn't show up in printenv bootargs. I also installed block mount separately in order to get the uuid of the partition. I've always found extroot finicky..I apologize if this is out of context for this thread.

(Last edited by lobonse on 6 Feb 2017, 01:26)

Ok so I found somebody on another thread who realised that there is another config file, target/linux/ar71xx/generic/config-default that passes the updated arguments. Now I get:

Kernel panic - not syncing: No init found.  Try passing init= option to kernel. See Linux Documentation/init.txt for guidance.

According to printenv, bootargs has init=/sbin/init which I changed to init=/etc/preinit which also failed. Lots of walls to scale.

ar7240> printenv
bootargs=console=ttyS0,115200 root=31:03 rootfstype=squashfs,jffs2 init=/sbin/init mtdparts=ar7240-nor0:192k(u-boot),64k(nvram),960k(linux),2752k(rootfs),64k(MAC),64k(ART)
bootcmd=bootm 0xbf040000
bootdelay=1
baudrate=115200
ethaddr=0x00:0xaa:0xbb:0xcc:0xdd:0xee
ipaddr=192.168.1.10
serverip=192.168.1.27
stdin=serial
stdout=serial
stderr=serial
ethact=eth0

(Last edited by lobonse on 6 Feb 2017, 02:20)

Aha, make kernel_menuconfig under Kernel Hacking -> built in kernel command line. Should I have an entry for init?

Good morning. smile

lobonse wrote:

As I might've guessed, I am having a little trouble with (pivot overlay) extroot. First, df -h:

Also, you said:

The integration of the required modules into the kernel, allows us to use detected SD-card on one level with NOR flash memory. For example: we can mount root-fs at kernel level by setting: CONFIG_CMDLINE="rootfstype=squashfs,jffs2,ext3 noinitrd root=/dev/mmcblk0p1 rootwait"

Which is ext4 for me. I put this in the config file in target/linux/ar71xx/config-3.10, but it doesn't show up in printenv bootargs. I also installed block mount separately in order to get the uuid of the partition. I've always found extroot finicky..I apologize if this is out of context for this thread.

This is for a different need. For example, to not boot from a flash and just to replace it.
But and there the is problem: https://forum.openwrt.org/viewtopic.php … 33#p190733

You also need to make all of the steps in stages.
https://wiki.openwrt.org/doc/howto/extroot#steps

Try also the whole "/" root instead of "/overlay".

(Last edited by Deoptim on 6 Feb 2017, 10:26)

Good day, good sir smile Sorry about the late night blabbering! I will try pivot root!

So I did the pivot root, result:

[   12.670000] EXT4-fs (mmcblk0p1): mounted filesystem with ordered data mode. Opts: 
switched to extroot
[   12.900000] FPU emulator disabled, make sure your toolchainwas compiled with software floating point support (soft-float)
Segmentation fault
Bus error
[   17.670000] ath79_wdt: device closed unexpectedly, watchdog timer will not stop!
[   17.670000] Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b

Process:

mount -t ext4 /dev/mmcblk0p1 /mnt/mmcblk0p1

block detect > /etc/config/fstab;sed -i s/option$'\t'enabled$'\t'\'0\'/option$'\t'enabled$'\t'\'1\'/ /etc/config/fstab;sed -i s#/mnt/sda1#/overlay# /etc/config/fstab;cat /etc/config/fstab;

mkdir -p /tmp/cproot
mount --bind / /tmp/cproot
tar -C /tmp/cproot -cvf - . | tar -C /mnt/mmcblk0p1 -x
umount /tmp/cproot

/etc/config/fstab:

config 'global'
        option  anon_swap       '0'
        option  anon_mount      '0'
        option  auto_swap       '1'
        option  auto_mount      '1'
        option  delay_root      '5'
        option  check_fs        '0'

config 'mount'
        option  target  '/'             
        option  uuid    '3944f3ce-5217-4a04-b066-459e4e4022b4'
        option  enabled '1'

#config 'mount'
#       option  target  '/mnt/mmcblk0p2'
#       option  uuid    '2aa96367-00c4-4bae-a79e-a5998b872f10'
#       option  enabled '1'

(Last edited by lobonse on 7 Feb 2017, 01:20)

I think maybe I "kernel hack"ed myself into a corner, just checking kernel_menuconfig...

Hmm now it finishes boot, but I still get:

[   12.410000] EXT4-fs (mmcblk0p1): mounted filesystem with ordered data mode. Opts: 
fs-state: switched to extroot
Bus error
Segmentation fault
...
procd: Instance odhcpd::instance1 s in a crash loop 6 crashes, 0 seconds since last crash

df -h:

Filesystem                Size      Used Available Use% Mounted on
rootfs                    3.4G     14.1M      3.2G   0% /
/dev/root                 2.0M      2.0M         0 100% /rom
tmpfs                    14.0M     52.0K     13.9M   0% /tmp
/dev/mmcblk0p1            3.4G     14.1M      3.2G   0% /
tmpfs                   512.0K         0    512.0K   0% /dev

mount:

rootfs on / type rootfs (rw)
/dev/root on /rom type squashfs (ro,noatime)
proc on /proc type proc (rw,noatime)
sysfs on /sys type sysfs (rw,noatime)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime)
/dev/mmcblk0p1 on / type ext4 (rw,relatime,data=ordered)
tmpfs on /dev type tmpfs (rw,relatime,size=512k,mode=755)
devpts on /dev/pts type devpts (rw,relatime,mode=600)
debugfs on /sys/kernel/debug type debugfs (rw,noatime)

(Last edited by lobonse on 6 Feb 2017, 21:43)

So I'm confused, is everybody suffering from this kernel panic/segfault on extroot?

I went back to pivot overlay as I noticed I had a mistake in the fstab, 'overlay' instead of '/overlay'...

Working!

df -h:

rootfs                    3.4G      7.2M      3.2G   0% /
/dev/root                 2.0M      2.0M         0 100% /rom
tmpfs                    14.0M     24.0K     13.9M   0% /tmp
/dev/mmcblk0p1            3.4G      7.2M      3.2G   0% /overlay
overlayfs:/overlay        3.4G      7.2M      3.2G   0% /
tmpfs                   512.0K         0    512.0K   0% /dev

Thanks again for all your patient help!

Hi again, still something wrong, things are buggy, uhttpd crashes similar to odhcpd...crash loop. I think this sd card setup is going in the trash.

(Last edited by lobonse on 7 Feb 2017, 18:00)

So I pulled the mod out of the "trash" and tried the chaos calmer above. I must've screwed up the filesystem on the sd card, since it now works perfectly, no errors so far. Now to throw my brain in the trash.

Awesome!UPDATE: Luci fails again. Just waiting for more errors. If it does work well for a week I'll post back.

UPDATE 2 Segfault, Bus error, I'm done, thanks anyhow. To USB!

(Last edited by lobonse on 14 Feb 2017, 01:58)

I should note however that the mod itself is working well. There may be ( probably are ) voltage issues or something hardware related that is causing problems. Great job Deoptim, and thanks for all the help.

UPDATE: system working fine, no errors, as long as I don't intall luci at least. No idea why.

(Last edited by lobonse on 21 Mar 2018, 14:01)

Hello,

Sorry to bump a thread that's been inactive for the last couple of months, but I'm having a weird issue with the Deep MMC Hack and I was hoping you could help me.

I realize the hack doesn't work until I revert to the revision mentioned in the Deep MMC Hack link, however, I was able to get it working on the latest Chaos Calmer version.

It doesn't work normally though. I have to remove the microSD card during boot. When it's done booting, I insert the SD card, $ rmmod mmc_spi, $modprobe mmc_spi and then if I've setup the /etc/config/fstab correctly, it mounts.

However if the SD card stays in the SD card holder during boot, then I get the following messages.

[   17.600000] mmc0: host does not support reading read-only switch, assuming write-enable
[   17.610000] mmc0: new SDHC card on SPI
[   17.630000] mmcblk0: mmc0:0000 SD4GB 3.60 GiB
[   17.640000]  mmcblk0: p1
[   17.650000] xt_time: kernel timezone is -0000
[   17.750000] mmcblk0: unknown error -89 sending read/write command, card status 0x0
[   17.760000] blk_update_request: I/O error, dev mmcblk0, sector 0
[   17.760000] blk_update_request: I/O error, dev mmcblk0, sector 8
[   17.770000] blk_update_request: I/O error, dev mmcblk0, sector 16
[   17.770000] blk_update_request: I/O error, dev mmcblk0, sector 24
[   17.780000] SQUASHFS error: xz decompression failed, data probably corrupt
[   17.790000] SQUASHFS error: squashfs_read_data failed to read block 0xa84da
[   17.800000] SQUASHFS error: xz decompression failed, data probably corrupt
[   17.800000] SQUASHFS error: squashfs_read_data failed to read block 0xa84da
[   17.810000] mmcblk0: unknown error -89 sending read/write command, card status 0x0
[   17.820000] blk_update_request: I/O error, dev mmcblk0, sector 0
[   17.820000] Buffer I/O error on dev mmcblk0, logical block 0, async page read

Would you have any clue why this is happening? Is there any way I can prevent OpenWrt from trying to mount the SD Card before the entire boot process is complete?

Can I blacklist the kmod-mmc-spi and kmod-mmc so that they do not load during boot?

Oh by the way, I'm using the external modules. Would it help if I integrate them in the kernel as recommended? However I'm trying to mount the SD Card to /mnt so I'm guessing it doesn't matter?

Thanks a lot!

crashprone wrote:

...
I realize the hack doesn't work until I revert to the revision mentioned in the Deep MMC Hack link, however, I was able to get it working on the latest Chaos Calmer version.
...
Would you have any clue why this is happening? Is there any way I can prevent OpenWrt from trying to mount the SD Card before the entire boot process is complete?

That's why I wrote that it does not work on the last trunk - I had the same problem.
Why it does not work is described in the reference to the main change in the SPI driver (the author of the changes did not work with the modules with two Slave devices on one Bus).

crashprone wrote:

Can I blacklist the kmod-mmc-spi and kmod-mmc so that they do not load during boot?

I do not see the point in this, because, the conflict is with the ath79-spi driver.

crashprone wrote:

Oh by the way, I'm using the external modules. Would it help if I integrate them in the kernel as recommended? However I'm trying to mount the SD Card to /mnt so I'm guessing it doesn't matter?

Really it does not matter. Just initialization of the SD card is faster.

P.S.
My advice to you, try to apply this mod to the lede project - maybe it will work.