OpenWrt Forum Archive

Topic: [SOLVED] Help needed with SD over SPI on tl-wr1043nd v1

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

As the title says I'm planning to add a SD card to my router and while the hardware is on its way I stuck a bit at the software part.

First off I'm wondering what to set as target for the builder, simply ar71xx or something special?
Second anything to note while configuring except defconfig?
Then I wonder if it's still needet to have anything in squashfs or if flashing the patched kernel is enough (chaos calmer) and if flashing the kernel is enough: Is that possible without reflashing squashfs/jffs2 ?

(Last edited by v10lator on 13 Apr 2016, 14:59)

v10lator wrote:

First off I'm wondering what to set as target for the builder, simply ar71xx or something special?

Yes, you should select (in make menuconfig):

  • Select your platform for Target System (Atheros AR71xx) Target System (Atheros AR7xxx/AR9xxx)  --->

  • Target Profile (TP-LINK TL-WR1043N/ND)  --->

  • Then other packages and Luci install --->
    ...
    (by default you have no Luci setup)


v10lator wrote:

Second anything to note while configuring except defconfig?

As i said by default you have no Luci setup.
To add web access Luci must be added, LuCI -> collection -> select luci
If you have no LuCI in menuconfig then you must install feeds of packages:

./scripts/feeds update -a
./scripts/feeds install luci

If you want additional feeds you can install all of them:

./scripts/feeds update -a
./scripts/feeds install -a

Then put again:

make menuconfig

v10lator wrote:

Then I wonder if it's still needet to have anything in squashfs or if flashing the patched kernel is enough (chaos calmer) and if flashing the kernel is enough: Is that possible without reflashing squashfs/jffs2 ?

Yes, in theory you can do it without any consequences.
Keep in mind that there sysupgrade images for that.
But in my experience, I know that it is not all the saves that should be (if we using internal sysupgrade resources).

(Last edited by Deoptim on 12 Apr 2016, 19:21)

Deoptim wrote:

Then put again:

make menuconfig

Thanks, so this is what I did now:

git clone git://git.openwrt.org/15.05/openwrt.git
cd openwrt
./scripts/feeds update -a
./scripts/feeds install -a
make menuconfig
  -> Target Profile (TP-LINK TL-WR1043N/ND)
make defconfig
make menuconfig
  -> LuCI  ---> 1. Collections  ---> <*> luci
  -> Base system  ---> <*> block-mount
  -> Kernel modules  ---> Filesystems  ---> <*> kmod-fs-f2fs
                          Other modules  ---> <*> kmod-mmc
                          SPI Support  ---> <*> kmod-mmc-spi
make prereq
patch -p0 < /path/to/patchfile.patch
make V=s

I hope this was correct? The last command is still running while we speak, guess it will need some time. smile

Yes, in theory you can do it without any consequences.
Keep in mind that there sysupgrade images for that.
But in my experience, I know that it is not all the saves that should be (if we using internal sysupgrade resources).

Could you give me some more infos on that, please? I would like to try to flash the kernel only before flashing a whole image.

v10lator wrote:

Could you give me some more infos on that, please? I would like to try to flash the kernel only before flashing a whole image.

If use standard sysupgrade image:
In Luci:
System --> Backup / Flash Firmware --> Configuration tab
Edit this tab and include files/dirs what you want to save:

/etc/config
...

Then back to Actions tab and Flash new firmware image (sysupgrade)
(with Keep settings)

In Console:
Edit /etc/sysupgrade.conf and include files/dirs what you want to save then execute:

sysupgrade -v /tmp/filename-of-downloaded-sysupgrade.bin

(Last edited by Deoptim on 12 Apr 2016, 20:12)

Deoptim wrote:

If use standard sysupgrade image:
In Luci:
System --> Backup / Flash Firmware --> Configuration tab
Edit this tab and include files/dirs what you want to save:

/etc/config
...

Then back to Actions tab and Flash new firmware image (sysupgrade)
(with Keep settings)

In Console:
Edit /etc/sysupgrade.conf and include files/dirs what you want to save then execute:

sysupgrade -v /tmp/filename-of-downloaded-sysupgrade.bin

That sounds highly error prone (why do I need to specify files/dirs in mtd2 when I want to flash mtd1?). Isn't there a better way like uploading the kernel image and using dd to directly flash it into mtd1 (which would even give me the chance to backup the original flash content first) ?

v10lator wrote:

That sounds highly error prone (why do I need to specify files/dirs in mtd2 when I want to flash mtd1?). Isn't there a better way like uploading the kernel image and using dd to directly flash it into mtd1 (which would even give me the chance to backup the original flash content first) ?

if you look on https://wiki.openwrt.org/toh/tp-link/tl … ash_layout
mtd1 kernel 1280KiB size can be variable(and will be) for each build
if size of <new image> is less / or / larger then mtd1 on your device
between <new image> and <mtd2> partition may occur a free space / or / other way around there will be overlay
so we need to re-create mtd2..

(Last edited by Deoptim on 12 Apr 2016, 20:36)

Deoptim wrote:

so we need to re-create mtd2..

That makes sense, thanks.

Now I have a new problem, the make command fails with http://pastie.org/10795498

v10lator wrote:

Now I have a new problem, the make command fails with http://pastie.org/10795498

You need to install in system ncurses dependence.
for example in my OS (Ububntu) i use this:

sudo apt-get install g++ libncurses5 ncurses-dev gawk git-core zlib1g-dev libssl-dev subversion
Deoptim wrote:

You need to install in system ncurses dependence.

All of that is installed and I think the error is more around here:

sed: file /tmp/csfr4YOR/subs-1.sed line 27: unterminated `s' command

or here:

Makefile:1: *** recipe commences before first target.  Stop.

//EDIT: I guess they are both the error: sed fails and as a result creates this invalid Makefile: http://pastie.org/10795524 (build_dir/target-mips_34kc_uClibc-0.9.33.2/libncurses/ncurses-5.9/Makefile)

(Last edited by v10lator on 12 Apr 2016, 22:53)

errors in the Makefile can not be, everything worked out

If I have builded, and you have error - it means something is missing, and most likely some kind of dependence library.

Deoptim wrote:

If I have builded, and you have error - it means something is missing, and most likely some kind of dependence library.

No, read the error message. If your sed produces a valid output while mine does not we should check what's the difference, so a first thing to do is comparing our sed versions:

$ sed --version
GNU sed version 4.2.1

//EDIT: Changing line 19826 in build_dir/target-mips_34kc_uClibc-0.9.33.2/libncurses/ncurses-5.9/configure from

s,@ECHO_C@,$ECHO_C,;t t

to

s,@ECHO_C@,\n,;t t

fixed this. Not sure if this was the right thing to do through...

(Last edited by v10lator on 12 Apr 2016, 22:53)

Sorry for double post, just wanted to get sure this gets readed.

With the above workaround the image compiled and after some tweaking/recompiling/reflashing it finally worked. Anyway, no sign of spi0.1 / mmc in the kernel:

root@OpenWrt:~# lsmod | grep -e mmc -e spi && dmesg | grep -e mmc -e spi
crc7                     745  1 mmc_spi
crc_itu_t               1019  2 mmc_spi
mmc_block              21473  0 
mmc_core               71745  2 mmc_spi
mmc_spi                 7088  0 
[    0.540000] m25p80 spi0.0: found s25sl064p, expected m25p80
[    0.550000] m25p80 spi0.0: s25sl064p (8192 Kbytes)
[    0.550000] 5 tp-link partitions found on MTD device spi0.0
[    0.560000] Creating 5 MTD partitions on "spi0.0":

I tried the patch from https://wiki.openwrt.org/toh/tp-link/tl … pio_as_cs1 as well as my own patch (http://pastie.org/10795721). Please note that there is no hardware in place but I guess I should at least see https://wiki.openwrt.org/toh/tp-link/tl … .hack#logs (Error type in the case that system has NOT detected the SD-card), no?

(Last edited by v10lator on 13 Apr 2016, 00:37)

The only thing that comes to mind.
You could apply patch on target when it was .prepared (with no changes).

You've used make process (before patching the target)?
try

make target/linux/{clean,prepare} V=s QUILT=1
make target/install V=s

BTW
Did You know what external modules (like kmod-mmc and kmod-mmc-spi) do not allow using extroot?

(Last edited by Deoptim on 13 Apr 2016, 08:56)

I don't know what exactly did the trick but:

[   17.700000] mmc_spi spi0.1: SD/MMC host mmc0, no DMA, no WP, no poweroff

Thanks a lot for all your help @Deoptim. smile

The discussion might have continued from here.