Modify

Opened 4 years ago

Closed 3 years ago

Last modified 21 months ago

#12349 closed defect (fixed)

RB493G: MicroSD card-reader doesn't work

Reported by: renne Owned by: jogo
Priority: normal Milestone: Barrier Breaker 14.07
Component: kernel Version: Attitude Adjustment 12.09 Beta
Keywords: rb493g 493g micro-sd microsd I/O error Cc: rene@…

Description

Even with kmod-mmc and kmod-mmc-spi packages installed I cannot find the 16 GByte microSD-card installed in the microSD-socket. There are no mmcx-devices in /dev.

dmesg often shows

[511749.960000] Buffer I/O error on device mtdblock4, logical block 3
[511749.970000] end_request: I/O error, dev mtdblock4, sector 0

with different block and sector numbers. So I assume this is the microSD-card. But fdisk doesn't show any information about /dev/mtdblock4.

OpenWrt is the generic ar71xx-nand 12.09-BETA-image downloaded from the OpenWrt-download-server.

Attachments (3)

register_microsd.patch (618 bytes) - added by jogo 4 years ago.
config (137.5 KB) - added by renne 3 years ago.
OpenWrt .config with a lot of SPI/MMC/SD(HCI) modules enabled - works with patch and modified kernel config
config-3.6 (6.8 KB) - added by renne 3 years ago.
OpenWrt kernel .config with a lot of SPI/MMC/SD(HCI) modules enabled - works with patch and modified OpenWrt config

Download all attachments as: .zip

Change History (29)

comment:1 Changed 4 years ago by Del <delonly@…>

It seems to me that the mmc and mmc-spi modules are not sufficient. I suppose the card reader works from RouterOS, are you able to get a list of loaded modules from there? Should also be possible to track down the card reader by finding some info on the reader itself. Looking at kernel documentation, e.g., here http://cateee.net/lkddb/web-lkddb/MMC.html it seems you need both mmc and the specific driver for your card reader. Gentoo has a walk-through on setting this up in the make menuconfig step (not sure what is currently available as OpenWrt packages though, but I guess we can expand on that to include the relevant driver if missing) here: http://en.gentoo-wiki.com/wiki/SD_and_MMC_card_readers

Changed 4 years ago by jogo

comment:2 Changed 4 years ago by jogo

  • Owner changed from developers to jogo
  • Status changed from new to accepted

Can you try to build an image with the attached patch applied? It should apply to both trunk and AA branches.

comment:3 Changed 4 years ago by Del <delonly@…>

I will have to get the device first, but maybe rene can test the patch now.

comment:4 Changed 4 years ago by renne

As internet-connection and (W)LAN are run by the 493G

  1. Can I somehow create a snapshot of the current NAND-content with config and all changes and re-flash it after testing?
  1. Can I patch e.g. the SDK or ImageBuilder and re-compile only the patched code instead of all the kernel and packages?

comment:5 Changed 4 years ago by renne

I'm running AA-BETA. I just saw BETA2 is out for three days. Have there been any changes with the microSD-support I should consider when testing?

comment:6 Changed 4 years ago by jogo

Yes and no to 1: You can luci and sysupgrade to backup your settings, but not the whole nand content; everything else no.

But what you can do for testing is instead compile a ramdisk image with everything necessary included (i.e. kmod-mmc-spi etc) and then boot it from network. That way you keep your config and don't need to flash anything. If it works I'll add it for the next beta/release candidate.

comment:7 Changed 3 years ago by renne

I've downloaded and uncompressed the AA-BETA2-SDK.

Which package definitions do I have to obtain to apply the patch to?

I've experience with compiling Gentoo, but none with the Toolchain/SDK of OpenWrt ...

comment:8 Changed 3 years ago by Del <delonly@…>

For a gentoo user the build process is a breeze. First install the buildroot like described here:
http://wiki.openwrt.org/doc/howto/buildroot.exigence
Then move on to the build instructions here:
http://wiki.openwrt.org/doc/howto/build
The patching is a bit involved. The openwrt build system typically downloads software upstream, and hence maintains patches to the upstream sources. This is done in a generic manner described here:
http://wiki.openwrt.org/doc/devel/packages
you will need to track down the one you want to patch and check what the state is for that one, and then adapt the patch. Shout if you want help in doing that.

comment:9 Changed 3 years ago by renne

I've tried several times, now.
But compiling the buildroot of the most current trunk version breaks with uClibc every time.

$ ccache_cc -Os -pipe -mips32r2 -mtune=mips32r2 -fno-caller-saves -fhonour-copts -Wno-error=unused-but-set-variable -msoft-float -fno-strict-aliasing -fwrapv -flto=jobserver -std=gnu99 -Wall -fno-inline -Wno-overflow -I. -DMKSH_SMALL=1 -DMKSH_ASSUME_UTF8=0 -D_GNU_SOURCE -DSETUID_CAN_FAIL_WITH_EAGAIN -DHAVE_ATTRIBUTE_BOUNDED=0 -DHAVE_ATTRIBUTE_FORMAT=1 -DHAVE_ATTRIBUTE_NONNULL=1 -DHAVE_ATTRIBUTE_NORETURN=1 -DHAVE_ATTRIBUTE_UNUSED=1 -DHAVE_ATTRIBUTE_USED=1 -DHAVE_SYS_BSDTYPES_H=0 -DHAVE_SYS_FILE_H=1 -DHAVE_SYS_MKDEV_H=0 -DHAVE_SYS_MMAN_H=1 -DHAVE_SYS_PARAM_H=1 -DHAVE_SYS_SELECT_H=1 -DHAVE_SYS_SYSMACROS_H=1 -DHAVE_BSTRING_H=0 -DHAVE_GRP_H=1 -DHAVE_LIBGEN_H=1 -DHAVE_LIBUTIL_H=0 -DHAVE_PATHS_H=1 -DHAVE_STDINT_H=1 -DHAVE_STRINGS_H=1 -DHAVE_ULIMIT_H=1 -DHAVE_VALUES_H=1 -D_FILE_OFFSET_BITS=64 -DHAVE_CAN_INTTYPES=1 -DHAVE_CAN_UCBINTS=1 -DHAVE_CAN_INT8TYPE=1 -DHAVE_CAN_UCBINT8=1 -DHAVE_RLIM_T=1 -DHAVE_SIG_T=1 -DHAVE_SYS_SIGNAME=0 -DHAVE_SYS_SIGLIST=0 -DHAVE_STRSIGNAL=1 -DHAVE_GETRUSAGE=1 -DHAVE_KILLPG=1 -DHAVE_MKNOD=0 -DHAVE_MKSTEMP=1 -DHAVE_NICE=0 -DHAVE_REVOKE=0 -DHAVE_SETLOCALE_CTYPE=0 -DHAVE_LANGINFO_CODESET=0 -DHAVE_SELECT=1 -DHAVE_SETRESUGID=1 -DHAVE_SETGROUPS=1 -DHAVE_STRCASESTR=1 -DHAVE_STRLCPY=1 -DHAVE_FLOCK_DECL=0 -DHAVE_REVOKE_DECL=1 -DHAVE_SYS_SIGLIST_DECL=1 -DHAVE_PERSISTENT_HISTORY=0 -L/home/renne/Dokumente/Mikrotik_RB493G/OpenWRT/buildroot/trunk/staging_dir/target-mips_r2_uClibc-0.9.33.2/usr/lib -L/home/renne/Dokumente/Mikrotik_RB493G/OpenWRT/buildroot/trunk/staging_dir/target-mips_r2_uClibc-0.9.33.2/lib -L/home/renne/Dokumente/Mikrotik_RB493G/OpenWRT/buildroot/trunk/staging_dir/toolchain-mips_r2_gcc-4.6-linaro_uClibc-0.9.33.2/usr/lib -L/home/renne/Dokumente/Mikrotik_RB493G/OpenWRT/buildroot/trunk/staging_dir/toolchain-mips_r2_gcc-4.6-linaro_uClibc-0.9.33.2/lib -fuse-linker-plugin -Wno-error conftest.c  || for _f in ${tcfn}*; do test x"${_f}" = x"mksh.1" || rm -f "${_f}"; done
] conftest.c:22:1: error: variably modified 'ari_sign_32_bit_and_wrap' at file scope
==> whether compile-time assertions pass... no
make[3]: *** [/home/renne/Dokumente/Mikrotik_RB493G/OpenWRT/buildroot/trunk/build_dir/target-mips_r2_uClibc-0.9.33.2/mksh/.built] Error 1
make[3]: Leaving directory `/home/renne/Dokumente/Mikrotik_RB493G/OpenWRT/buildroot/trunk/feeds/packages/utils/mksh'
make[2]: *** [package/feeds/packages/mksh/compile] Error 2
make[2]: *** Waiting for unfinished jobs....
installing command scripts:   /home/renne/Dokumente/Mikrotik_RB493G/OpenWRT/buildroot/trunk/staging_dir/host/bin
installing library scripts:   /home/renne/Dokumente/Mikrotik_RB493G/OpenWRT/buildroot/trunk/staging_dir/host/lib/ruby/1.9.1
installing common headers:    /home/renne/Dokumente/Mikrotik_RB493G/OpenWRT/buildroot/trunk/staging_dir/host/include/ruby-1.9.1
installing manpages:          /home/renne/Dokumente/Mikrotik_RB493G/OpenWRT/buildroot/trunk/staging_dir/host/share/man/man1
installing default gems:      /home/renne/Dokumente/Mikrotik_RB493G/OpenWRT/buildroot/trunk/staging_dir/host/lib/ruby/gems/1.9.1 (cache, doc, gems, specifications)
                              rake 0.8.7
                              rdoc 2.5.8
                              minitest 1.6.0
make[4]: Leaving directory `/home/renne/Dokumente/Mikrotik_RB493G/OpenWRT/buildroot/trunk/build_dir/host/ruby-1.9.2-p0'
mkdir -p /home/renne/Dokumente/Mikrotik_RB493G/OpenWRT/buildroot/trunk/staging_dir/host/stamp
touch /home/renne/Dokumente/Mikrotik_RB493G/OpenWRT/buildroot/trunk/staging_dir/host/stamp/.ruby_installed
make[3]: Leaving directory `/home/renne/Dokumente/Mikrotik_RB493G/OpenWRT/buildroot/trunk/feeds/packages/lang/ruby'
make[2]: Leaving directory `/home/renne/Dokumente/Mikrotik_RB493G/OpenWRT/buildroot/trunk'
make[1]: *** [/home/renne/Dokumente/Mikrotik_RB493G/OpenWRT/buildroot/trunk/staging_dir/target-mips_r2_uClibc-0.9.33.2/stamp/.package_compile] Error 2
make[1]: Leaving directory `/home/renne/Dokumente/Mikrotik_RB493G/OpenWRT/buildroot/trunk'
make: *** [world] Fehler 2

comment:10 Changed 3 years ago by Del <delonly@…>

Are you sure you have all dependencies installed? To be sure you can try building an image that is known to build.

You can also follow the directions on how to spot build errors, i.e., by running:

make V=s 2>&1 | tee build.log | grep -i error

I have just ordered this device, so I will be able to join the effort once I get it.

comment:11 Changed 3 years ago by renne

I used the guide at http://wiki.openwrt.org/doc/howto/buildroot.exigence on a Ubuntu 12.10 64-bit Desktop, even "make defconfig", "make prereq" and "make menuconfig". Additionally I patched the file "target/linux/ar71xx/files/arch/mips/ath79/mach-rb4xx.c" manually with your "register_microsd.patch" and used the "config.ar71xx_nand" from AA-RC1 as ".config" + ramdisk enabled via "make menuconfig". After that I followed the guide at http://wiki.openwrt.org/doc/howto/build. The output of my former post is produced by "ionice -c 3 nice -n 20 make -j 2 V=s 2>&1 | tee build.log | egrep -i '(warn|error)'".

But after five runs still "error 2" with uClibc. :-(

comment:12 Changed 3 years ago by Del <delonly@…>

Just downloaded the latest trunk, configured ar71xx and the nand flash option in make menuconfig. Compiling as we speak (Kubuntu 12.04 amd64). I will report back if I reproduce your build error. My hunch is that the build problem is related to config.ar71xx_nand

Just prepaid the router today, so I should be able to play with it soon :)

comment:13 Changed 3 years ago by Del <delonly@…>

It built fine. I enabled the ramdisk, and manually applied Yogo's patch, again it built fine. This is with latest trunk, r34469.

What is up with the config file from RC1, is it needed?

comment:14 Changed 3 years ago by renne

No, I just wanted to use a valid default configuration. But after a "make clean" and manual configuration without the AR71xx-config from RC1, trunk of decembre, 2nd compiled fine. But the patch wasn't enough. I had to do a "make kernel_menuconfig" and I enabled anything I found containing the words "SD", "SDHC", "MMC" and "SPI". Once again it compiled fine.

And Tadaa, boot messages showed a 14.8 GByte SDHC-card (16 GByte Sandisk). Mounting doesn't work, yet, but the SDHC-card was in a Android-phone before, so reformatting may help. Unfortunately I have to take apart the router, again, to get to the SD-card.

I also soldered an extension board with a step-down-converter drawing USB-5-VDC from the fan headers. I'll add photos and a circuit-diagram to the Wiki. :-)

comment:15 follow-up: Changed 3 years ago by Del <delonly@…>

Great! Today I got notice from Mikrotik too, my router is on the way. This is shaping up to be a great day :-)

You probably need to install the package block-mount in addition to whatever filesystem you have on the SD-card.

Please consider testing without jogo's patch too, just to be sure it is really needed (a lot had changed in the code parts where the patch was applied). That is, unless jogo can confirm that the patch indeed still is needed.

Looking forward to seeing your pictures.

comment:16 in reply to: ↑ 15 Changed 3 years ago by renne

Replying to Del <delonly@…>:

Great! Today I got notice from Mikrotik too, my router is on the way. This is shaping up to be a great day :-)

I wish you much fun with the RB493G! :-)

You probably need to install the package block-mount in addition to whatever filesystem you have on the SD-card.

After installing block-mount, filesystem modules and native-language-support modules, I was able to mount the VFAT partition! :-) Write-speed was only 2 MByte/s, but at least it works. ;-)

Version of OpenWrt is Barrier Breaker r34436 from december, 2nd.

Please consider testing without jogo's patch too, just to be sure it is really needed (a lot had changed in the code parts where the patch was applied). That is, unless jogo can confirm that the patch indeed still is needed.

How can I make sure target/linux/ar71xx/files/arch/mips/ath79/mach-rb4xx.c will be recompiled after removing the patch?

Looking forward to seeing your pictures.

You don't have to wait anymore! Just have a look into the Wiki :-)

If you happen to know anyone with Cadsoft Eagle experience, you can encourage him to use the rudimentary circuit-diagram and the PCB-draft to create a ready-to-use PCB-layout! ;-)

comment:17 follow-up: Changed 3 years ago by Del <delonly@…>

Write-speed was only 2 MByte/s,

Not sure what to expect from VFAT, but that sounds too slow. Still, I would test ext4. With a 3.7 kernel, I will go with btrfs. Really cannot wait to see that filesystem mature.

How can I make sure target/linux/ar71xx/files/arch/mips/ath79/mach-rb4xx.c will be recompiled after removing the patch?

I believe by simply running make again. It should recompile changed files. You could also do a make clean first of course.

If you happen to know anyone with Cadsoft Eagle experience,

Sorry, not as far as I know. Who knows though, with my growing interest in OpenWrt there is no telling who I will meet :-)

I will have a look at the pictures, but I really need a good nights sleep first :-)

comment:18 in reply to: ↑ 17 Changed 3 years ago by renne

Replying to Del <delonly@…>:

Not sure what to expect from VFAT, but that sounds too slow. Still, I would test ext4. With a 3.7 kernel, I will go with btrfs. Really cannot wait to see that filesystem mature.

I already used BTRFS, but the lack of maintenance tools made it a No-Go. So I hope it leaves the vapor-ware state, soon.

I did some further testing:

  1. The patch is necessary
  2. Additional modules are necessary (.config and .config-3.6 attached)
  3. Can you do more testing which SPI/MMC/SD(HCI) modules are really necessary?
  4. Merry Christmas! :-)

Changed 3 years ago by renne

OpenWrt .config with a lot of SPI/MMC/SD(HCI) modules enabled - works with patch and modified kernel config

Changed 3 years ago by renne

OpenWrt kernel .config with a lot of SPI/MMC/SD(HCI) modules enabled - works with patch and modified OpenWrt config

comment:19 Changed 3 years ago by Del <delonly@…>

Would love to help out testing dependencies, but right now I have not gotten a serial console up and runnning:
https://forum.openwrt.org/viewtopic.php?pid=187026#p187026

OT: Suse marked btrfs production ready this summer. The tools have come around, but it is still the early days :)

comment:20 Changed 3 years ago by renne

@developers:

Please add the register_microsd.patch to 12.09 AA and trunk. In current versions the one-liner has to be added around line 420 in the file 'target/linux/ar71xx/files/arch/mips/ath79/mach-rb4xx.c'. It's definitely necessary to drive the SD-card reader of the Routerboard RB493G.

With that patch added the RB493G is FULLY supported in OpenWrt (AA and trunk)! :-)

comment:21 Changed 3 years ago by Del <delonly@…>

Fully supported is a bit of a stretch still I think. Have a look:
https://forum.openwrt.org/viewtopic.php?id=28889

comment:22 Changed 3 years ago by anonymous

@jogo

Please add support for Toshiba NAND and the register_microsd-patch to trunk and AA branch to get the RB493G fully supported in the AA 12.09 release! :)

comment:23 Changed 3 years ago by Del <delonly@…>

Just got to test the patch with my new microSD card, it works! I see it is already submitted, and should be available in trunk along with Toshiba NAND support, ref. https://dev.openwrt.org/changeset/35535

Thanks Jonas, please close this report.

comment:24 Changed 3 years ago by renne

Is it in AA-Branch, too?

comment:25 Changed 3 years ago by jogo

  • Resolution set to fixed
  • Status changed from accepted to closed

It has been added today with r35776 to AA, so I'm closing it now.

comment:26 Changed 21 months ago by jow

  • Milestone changed from Attitude Adjustment 12.09 to Barrier Breaker 14.07

Milestone Attitude Adjustment 12.09 deleted

Add Comment

Modify Ticket

Action
as closed .
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.