diff mbox series

Enabling SATA via SATA_DWC on Meraki MX60W / APM82181

Message ID CANA18Ux+E=AtT0ROFQtt09ZRKKub+T5BnYOhfFDuuX10HewJ3w@mail.gmail.com
State Not Applicable
Headers show
Series Enabling SATA via SATA_DWC on Meraki MX60W / APM82181 | expand

Commit Message

Martin Kennedy Feb. 21, 2021, 7:54 p.m. UTC
I would like to get the HDD port on the MX60 / MX60W working.

Knowing that the APM82181 muxes PCIe and SATA, I tried replacing the
PCIe WLAN module with an mSATA one, and disabling PCIe in the MX60
device tree, but enabling SATA0/1:


I have soldered a SATA power+data header onto an MX60W's pads; I have
bridged solder on four points where 1nF 0102 SMD capacitor should have
been placed to avoid DC bias. Still, despite a WG Green 3.5" drive,
Sandisk U100 8GB 2.5" drive and Toshiba 250GB 2.5" HDD all certainly
powering on on boot, none of these were recognized; instead, I only
got a 'SATA link down' once the port had been probed and IRQs set up.

Does DesignWare SATA on the APM82181 require U-boot's involvement to
initialize? Or am I missing something from the OpenWrt side? Would
attempting to boot Debian instead be a good idea?

Comments

Christian Lamparter Feb. 22, 2021, 8:16 p.m. UTC | #1
Hello,

On Sun, Feb 21, 2021 at 8:56 PM Martin Kennedy <hurricos@gmail.com> wrote:
>
> I would like to get the HDD port on the MX60 / MX60W working.

This is odd... didn't know there is a HDD port on the MX60/MX60W....

>
> Knowing that the APM82181 muxes PCIe and SATA, I tried replacing the
> PCIe WLAN module with an mSATA one, and disabling PCIe in the MX60
> device tree, but enabling SATA0/1:

Ok...

[...]

> I have soldered a SATA power+data header onto an MX60W's pads; I have
> bridged solder on four points where 1nF 0102 SMD capacitor should have
> been placed to avoid DC bias. Still, despite a WG Green 3.5" drive,
> Sandisk U100 8GB 2.5" drive and Toshiba 250GB 2.5" HDD all certainly
> powering on on boot, none of these were recognized; instead, I only
> got a 'SATA link down' once the port had been probed and IRQs set up.

This is a very odd request. I could see this as a "challenge" just to
see what it takes
and if it's possible... Maybe make a forum thread too?

Since you went for 2,5" and 3,5" drivers, you could get cheapish
(~10-20 € on ebay)
ready-made minipcie<->sata adaptors available with Marvell brand chips that have
2/4 SATA-Ports (whatever fits). With those you should be able to just
fire up OpenWrt
and load kmod-ata-ahci to get access to the connected SATA drivers
with much less
hassle.

(And the Marvell chips should support SATA-3 + NCQ. The DesignWare
IP-Core inside
the APM82181 can only do SATA-2 and the driver does not have support for NCQ).

Come to think about it, I have one of those minipcie<->sata thingies
at home, I could try
this with a WNDAP620 and a WD HDD. (I don't have any of those mini
sata ssd, so I
can't try that).

> Does DesignWare SATA on the APM82181 require U-boot's involvement to
> initialize? Or am I missing something from the OpenWrt side?

Yes, there's some special sauce in Uboot. You could look at the Netgear's
WNDR4700 UBoot (uses both pcie + sata) and the MyBook Live DUO. Both
Uboots sources are part of their respective GPL drops. The MX60(W) also
has its uboot available on github... And I think (I don't know 100%) there was
some commented code about setting up SATA.

> Would attempting to boot Debian instead be a good idea?

If you are looking for Debian on APM82181, I've made a
"build-your-own-debian" for the MyBook Live (DUO).

<https://github.com/chunkeey/mbl-debian>

You cloud swap out the MyBookLive.dts with that of the MX60(W) and change
the uImage packaging a bit to get a kernel that you can put in the NAND to boot
off. But yea, you could have a good shot at running Debian SID on the MX60.

Cheers and Have fun with your SATA-on-MX60 Project,
Christian
Martin Kennedy Feb. 22, 2021, 9:54 p.m. UTC | #2
Hi there Christian,

I did make a post a good while ago to gauge interest (there was none).
It is here: https://forum.openwrt.org/t/mx60w-any-interest-in-a-diy-nas-guide-need-some-advice-for-sata-pads-and-msata-slot-compatibility/65718

I have actually tried kmod-ata-ahci out, but with a potentially
less-suitable ASM1061. Sadly, once the kmod-ata-ahci module has been
kmodloaded, the drives will `ata\d.00: failed to IDENTIFY` -- I
ascribed this to an issue with PCIe init on the platform as you
described on the linuxppc-dev mailing list, though I had not properly
poked the device tree to inform the device of this change. The ASM1061
chipset is known-working on other platforms using OpenWrt (I used two
ASM1061s in an Aerohive AP330 as my NAS for a while).

I can't seem to find Buckminster / MX60 anywhere in Chris's copy of
Meraki's u-boot sources (from
https://github.com/riptidewave93/meraki-uboot/). Given the easy JTAG
access, recompiling would be the first thing I'd like to try.

Otherwise, I suppose I'll try later with a Marvell chipset.

Thank you for the reply.

Martin

On Mon, Feb 22, 2021 at 3:16 PM Christian Lamparter <chunkeey@gmail.com> wrote:
>
> Hello,
>
> On Sun, Feb 21, 2021 at 8:56 PM Martin Kennedy <hurricos@gmail.com> wrote:
> >
> > I would like to get the HDD port on the MX60 / MX60W working.
>
> This is odd... didn't know there is a HDD port on the MX60/MX60W....
>
> >
> > Knowing that the APM82181 muxes PCIe and SATA, I tried replacing the
> > PCIe WLAN module with an mSATA one, and disabling PCIe in the MX60
> > device tree, but enabling SATA0/1:
>
> Ok...
>
> [...]
>
> > I have soldered a SATA power+data header onto an MX60W's pads; I have
> > bridged solder on four points where 1nF 0102 SMD capacitor should have
> > been placed to avoid DC bias. Still, despite a WG Green 3.5" drive,
> > Sandisk U100 8GB 2.5" drive and Toshiba 250GB 2.5" HDD all certainly
> > powering on on boot, none of these were recognized; instead, I only
> > got a 'SATA link down' once the port had been probed and IRQs set up.
>
> This is a very odd request. I could see this as a "challenge" just to
> see what it takes
> and if it's possible... Maybe make a forum thread too?
>
> Since you went for 2,5" and 3,5" drivers, you could get cheapish
> (~10-20 € on ebay)
> ready-made minipcie<->sata adaptors available with Marvell brand chips that have
> 2/4 SATA-Ports (whatever fits). With those you should be able to just
> fire up OpenWrt
> and load kmod-ata-ahci to get access to the connected SATA drivers
> with much less
> hassle.
>
> (And the Marvell chips should support SATA-3 + NCQ. The DesignWare
> IP-Core inside
> the APM82181 can only do SATA-2 and the driver does not have support for NCQ).
>
> Come to think about it, I have one of those minipcie<->sata thingies
> at home, I could try
> this with a WNDAP620 and a WD HDD. (I don't have any of those mini
> sata ssd, so I
> can't try that).
>
> > Does DesignWare SATA on the APM82181 require U-boot's involvement to
> > initialize? Or am I missing something from the OpenWrt side?
>
> Yes, there's some special sauce in Uboot. You could look at the Netgear's
> WNDR4700 UBoot (uses both pcie + sata) and the MyBook Live DUO. Both
> Uboots sources are part of their respective GPL drops. The MX60(W) also
> has its uboot available on github... And I think (I don't know 100%) there was
> some commented code about setting up SATA.
>
> > Would attempting to boot Debian instead be a good idea?
>
> If you are looking for Debian on APM82181, I've made a
> "build-your-own-debian" for the MyBook Live (DUO).
>
> <https://github.com/chunkeey/mbl-debian>
>
> You cloud swap out the MyBookLive.dts with that of the MX60(W) and change
> the uImage packaging a bit to get a kernel that you can put in the NAND to boot
> off. But yea, you could have a good shot at running Debian SID on the MX60.
>
> Cheers and Have fun with your SATA-on-MX60 Project,
> Christian
Christian Lamparter Feb. 25, 2021, 2:34 p.m. UTC | #3
Hello Martin,

On 22/02/2021 22:54, Martin Kennedy wrote:
> 
> I did make a post a good while ago to gauge interest (there was none).
> It is here: https://forum.openwrt.org/t/mx60w-any-interest-in-a-diy-nas-guide-need-some-advice-for-sata-pads-and-msata-slot-compatibility/65718
> 

Yeah, this is your personal hobby project, isn't it? There are basically no hardware
mods for the APM82181 as compared to the ath79/ramips/mediatek. For engagement, one
has to really invest there to make it popular.... Honestly, the APM82181 seems to
stagnate at the "working as intended" level.

> I have actually tried kmod-ata-ahci out, but with a potentially
> less-suitable ASM1061. Sadly, once the kmod-ata-ahci module has been
> kmodloaded, the drives will `ata\d.00: failed to IDENTIFY` -- I
> ascribed this to an issue with PCIe init on the platform as you
> described on the linuxppc-dev mailing list, though I had not properly
> poked the device tree to inform the device of this change. The ASM1061
> chipset is known-working on other platforms using OpenWrt (I used two
> ASM1061s in an Aerohive AP330 as my NAS for a while).

I found my minipcie<->sata 2-port thingy.  It's an ASMedia Technology Inc. ASM1062 Serial ATA Controller [1b21:0612]
I don't have a MX60(W) so I used a Netgear WNDAP660. Hope this still counts...

And would you look at that: :)

[   41.780183] IPv6: ADDRCONF(NETDEV_CHANGE): br-lan: link becomes ready
[  114.081146] kmodloader: loading kernel modules from /etc/modules.d/*
[  114.165797] ahci 0000:43:00.0: version 3.0
[  114.165836] ahci 0000:43:00.0: enabling device (0006 -> 0007)
[  114.234964] ahci 0000:43:00.0: SSS flag set, parallel bus scan disabled
[  114.314662] ahci 0000:43:00.0: AHCI 0001.0200 32 slots 2 ports 6 Gbps 0x3 impl SATA mode
[  114.411770] ahci 0000:43:00.0: flags: 64bit ncq sntf stag led clo pmp pio slum part ccc sxs
[  114.519719] scsi host0: ahci
[  114.556879] scsi host1: ahci
[  114.592747] ata1: SATA max UDMA/133 abar m512@0xe00010000 port 0xe00010100 irq 19
[  114.682614] ata2: SATA max UDMA/133 abar m512@0xe00010000 port 0xe00010180 irq 19
[  115.247864] ata1: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
[  115.322963] ata1.00: HPA detected: current 1953523055, native 1953525168
[  115.403754] ata1.00: ATA-8: Hitachi HDT721010SLA360, ST6OA3AA, max UDMA/133
[  115.487348] ata1.00: 1953523055 sectors, multi 0: LBA48 NCQ (depth 32), AA
[  115.661382] ata1.00: configured for UDMA/133
[  115.713002] scsi 0:0:0:0: Direct-Access     ATA      Hitachi HDT72101 A3AA PQ: 0 ANSI: 5
[  115.817054] sd 0:0:0:0: [sda] 1953523055 512-byte logical blocks: (1.00 TB/932 GiB)
[  115.909977] sd 0:0:0:0: [sda] Write Protect is off
[  115.967536] sd 0:0:0:0: [sda] Mode Sense: 00 3a 00 00
[  115.968179] sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[  116.134055]  sda: sda1
[  116.164790] sd 0:0:0:0: [sda] Attached SCSI disk
[  116.240626] ata2: SATA link down (SStatus 0 SControl 300)
[  116.308487] sd 0:0:0:0: Attached scsi generic sg0 type 0
[  116.375543] kmodloader: done loading kernel modules from /etc/modules.d/*
[  116.543762] kmodloader: loading kernel modules from /etc/modules.d/*
[  116.624340] kmodloader: done loading kernel modules from /etc/modules.d/*
[  116.792215] kmodloader: loading kernel modules from /etc/modules.d/*
[  116.872711] kmodloader: done loading kernel modules from /etc/modules.d/*

root@wndap660:/tmp# hdparm -t /dev/sda

/dev/sda:
  Timing buffered disk reads: 308 MB in  3.02 seconds = 101.87 MB/sec
(This 100 MB/sec is OK for a 1 GiB 3,5" Hitachi HDD Drive from 2009 I think).

I have the suspecion that your problem is caused by lack of proper to MSI(-X) there.
While the PCIE Hardware in the SoC has support for MSI (it's pcie) and the linux and
DTS has some MSI bits. The linux driver for it needs to be brought into 2021.
What I did was just editing the ahci.c driver in the linux kernel.

I swapped out the existing:

{ PCI_VDEVICE(ASMEDIA, 0x0612), board_ahci },     /* ASM1062 */

with:

{ PCI_VDEVICE(ASMEDIA, 0x0612), board_ahci_nomsi },     /* ASM1062 */

and it then loaded (before it was failing at the same NO_IDENTIFY).

/proc/interrupts also looks "healthy" (for a no-msi setup)

  19:        344       UIC  14 Level     ahci[0000:43:00.0]

(Maybe the pci=nomsi kernel parameter would do the trick as well. Could you
adding this to the bootargs in uboot and check if the ahci.c code now works?)

Cheers,
Christian
Martin Kennedy Feb. 25, 2021, 5:12 p.m. UTC | #4
> Yeah, this is your personal hobby project, isn't it?

For sure.

> ASM1062 Serial ATA Controller

Same as mine -- I think there may only be a firmware difference
between the ASM1061 and 1062, mine is silkscreened ASM1061 but
identifies as ASM1062.

> I have the suspecion that your problem is caused by lack of proper to MSI(-X) there.

Bingo. With pci=nomsi in cmdline:

[    9.438171] kmodloader: loading kernel modules from
/tmp/overlay/upper/etc/modules-boot.d/*
[    9.552867] ahci 0000:41:00.0: enabling device (0000 -> 0003)
[    9.558712] ahci 0000:41:00.0: SSS flag set, parallel bus scan disabled
[    9.565372] ahci 0000:41:00.0: AHCI 0001.0200 32 slots 2 ports 6
Gbps 0x3 impl SATA mode
[    9.573443] ahci 0000:41:00.0: flags: 64bit ncq sntf stag led clo
pmp pio slum part ccc sxs
[    9.587073] scsi host0: ahci
[    9.590640] scsi host1: ahci
[    9.593765] ata1: SATA max UDMA/133 abar m512@0xe00010000 port
0xe00010100 irq 19
[    9.601243] ata2: SATA max UDMA/133 abar m512@0xe00010000 port
0xe00010180 irq 19
[    9.918682] ata1: SATA link down (SStatus 0 SControl 300)
[   10.385618] ata2: SATA link up 6.0 Gbps (SStatus 133 SControl 300)
[   10.403649] ata2.00: ATA-8: KINGSTON SV300S37A60G, 580ABBF0, max UDMA/133
[   10.410427] ata2.00: 117231408 sectors, multi 1: LBA48 NCQ (depth 31/32), AA
[   10.423624] ata2.00: configured for UDMA/133
[   10.428252] scsi 1:0:0:0: Direct-Access     ATA      KINGSTON
SV300S3 BBF0 PQ: 0 ANSI: 5
[   10.437696] sd 1:0:0:0: [sda] 117231408 512-byte logical blocks:
(60.0 GB/55.9 GiB)
[   10.445675] sd 1:0:0:0: [sda] Write Protect is off
[   10.450572] sd 1:0:0:0: [sda] Write cache: enabled, read cache:
enabled, doesn't support DPO or FUA
[   10.461054]  sda: sda1 sda2
[   10.465177] sd 1:0:0:0: [sda] Attached SCSI disk

And:

root@mx60w:/# hdparm -t /dev/sda

/dev/sda:
 Timing buffered disk reads: 450 MB in  3.01 seconds = 149.35 MB/sec

Thanks again! Lots more to be tried now.

Martin

On Thu, Feb 25, 2021 at 9:34 AM Christian Lamparter <chunkeey@gmail.com> wrote:
>
> Hello Martin,
>
> On 22/02/2021 22:54, Martin Kennedy wrote:
> >
> > I did make a post a good while ago to gauge interest (there was none).
> > It is here: https://forum.openwrt.org/t/mx60w-any-interest-in-a-diy-nas-guide-need-some-advice-for-sata-pads-and-msata-slot-compatibility/65718
> >
>
> Yeah, this is your personal hobby project, isn't it? There are basically no hardware
> mods for the APM82181 as compared to the ath79/ramips/mediatek. For engagement, one
> has to really invest there to make it popular.... Honestly, the APM82181 seems to
> stagnate at the "working as intended" level.
>
> > I have actually tried kmod-ata-ahci out, but with a potentially
> > less-suitable ASM1061. Sadly, once the kmod-ata-ahci module has been
> > kmodloaded, the drives will `ata\d.00: failed to IDENTIFY` -- I
> > ascribed this to an issue with PCIe init on the platform as you
> > described on the linuxppc-dev mailing list, though I had not properly
> > poked the device tree to inform the device of this change. The ASM1061
> > chipset is known-working on other platforms using OpenWrt (I used two
> > ASM1061s in an Aerohive AP330 as my NAS for a while).
>
> I found my minipcie<->sata 2-port thingy.  It's an ASMedia Technology Inc. ASM1062 Serial ATA Controller [1b21:0612]
> I don't have a MX60(W) so I used a Netgear WNDAP660. Hope this still counts...
>
> And would you look at that: :)
>
> [   41.780183] IPv6: ADDRCONF(NETDEV_CHANGE): br-lan: link becomes ready
> [  114.081146] kmodloader: loading kernel modules from /etc/modules.d/*
> [  114.165797] ahci 0000:43:00.0: version 3.0
> [  114.165836] ahci 0000:43:00.0: enabling device (0006 -> 0007)
> [  114.234964] ahci 0000:43:00.0: SSS flag set, parallel bus scan disabled
> [  114.314662] ahci 0000:43:00.0: AHCI 0001.0200 32 slots 2 ports 6 Gbps 0x3 impl SATA mode
> [  114.411770] ahci 0000:43:00.0: flags: 64bit ncq sntf stag led clo pmp pio slum part ccc sxs
> [  114.519719] scsi host0: ahci
> [  114.556879] scsi host1: ahci
> [  114.592747] ata1: SATA max UDMA/133 abar m512@0xe00010000 port 0xe00010100 irq 19
> [  114.682614] ata2: SATA max UDMA/133 abar m512@0xe00010000 port 0xe00010180 irq 19
> [  115.247864] ata1: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
> [  115.322963] ata1.00: HPA detected: current 1953523055, native 1953525168
> [  115.403754] ata1.00: ATA-8: Hitachi HDT721010SLA360, ST6OA3AA, max UDMA/133
> [  115.487348] ata1.00: 1953523055 sectors, multi 0: LBA48 NCQ (depth 32), AA
> [  115.661382] ata1.00: configured for UDMA/133
> [  115.713002] scsi 0:0:0:0: Direct-Access     ATA      Hitachi HDT72101 A3AA PQ: 0 ANSI: 5
> [  115.817054] sd 0:0:0:0: [sda] 1953523055 512-byte logical blocks: (1.00 TB/932 GiB)
> [  115.909977] sd 0:0:0:0: [sda] Write Protect is off
> [  115.967536] sd 0:0:0:0: [sda] Mode Sense: 00 3a 00 00
> [  115.968179] sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
> [  116.134055]  sda: sda1
> [  116.164790] sd 0:0:0:0: [sda] Attached SCSI disk
> [  116.240626] ata2: SATA link down (SStatus 0 SControl 300)
> [  116.308487] sd 0:0:0:0: Attached scsi generic sg0 type 0
> [  116.375543] kmodloader: done loading kernel modules from /etc/modules.d/*
> [  116.543762] kmodloader: loading kernel modules from /etc/modules.d/*
> [  116.624340] kmodloader: done loading kernel modules from /etc/modules.d/*
> [  116.792215] kmodloader: loading kernel modules from /etc/modules.d/*
> [  116.872711] kmodloader: done loading kernel modules from /etc/modules.d/*
>
> root@wndap660:/tmp# hdparm -t /dev/sda
>
> /dev/sda:
>   Timing buffered disk reads: 308 MB in  3.02 seconds = 101.87 MB/sec
> (This 100 MB/sec is OK for a 1 GiB 3,5" Hitachi HDD Drive from 2009 I think).
>
> I have the suspecion that your problem is caused by lack of proper to MSI(-X) there.
> While the PCIE Hardware in the SoC has support for MSI (it's pcie) and the linux and
> DTS has some MSI bits. The linux driver for it needs to be brought into 2021.
> What I did was just editing the ahci.c driver in the linux kernel.
>
> I swapped out the existing:
>
> { PCI_VDEVICE(ASMEDIA, 0x0612), board_ahci },     /* ASM1062 */
>
> with:
>
> { PCI_VDEVICE(ASMEDIA, 0x0612), board_ahci_nomsi },     /* ASM1062 */
>
> and it then loaded (before it was failing at the same NO_IDENTIFY).
>
> /proc/interrupts also looks "healthy" (for a no-msi setup)
>
>   19:        344       UIC  14 Level     ahci[0000:43:00.0]
>
> (Maybe the pci=nomsi kernel parameter would do the trick as well. Could you
> adding this to the bootargs in uboot and check if the ahci.c code now works?)
>
> Cheers,
> Christian
Martin Kennedy March 1, 2021, 10:33 p.m. UTC | #5
For the internal SATA core: I noticed the SATA core actually needs
either a 120MHz[1] or 100MHz[2] clock to run. I did some tracing on my
MX60W and noticed a third, unpopulated junction of pads on the MX60W
near the ICS9FG104D[3] clock generator which lead directly to the SoC.
I populated them identically to the other pads, used i2c to poke the
clock up, and verified with an oscilloscope that the signal looked
more or less the same as that produced by the other two junctions (one
clock for mPCIe, one for the internal SoC PCIe core).

Sadly, still no SATA. Probably a few more things left to be poked
before I get it all working; for example, the SATA core init may need
to happen at a very specific point.

I emailed David Lam of Macom[4] for more spec sheets.

Christian, do you happen to have access to these spec sheets? Specifically:

- APM82181 Embedded Processor User Manual (referenced here:
https://www.spinics.net/lists/netdev/msg529450.html)
- APM82181 Embedded Processor Data Sheet (partially linked here:
http://mybookworld.wdfiles.com/local--files/mybook-live/APM82181_USB.pdf)

I might just be putting a clock on the wrong set of pins, too; there
is another quad of pads for what is, in the Hana NAS implementation,
an XpressO differential oscillator[5]. But that's why it'd be good to
have the full copy of the Data Sheet above, since I could then
confirm.

[1]: http://mybookworld.wdfiles.com/local--files/mybook-live/APM82181_USB.pdf
[2]: https://github.com/riptidewave93/meraki-uboot/blob/mx60w-20180413/board/amcc/bluestone/bluestone.c#L689
[3]: https://media.digikey.com/pdf/Data%20Sheets/IDT/ICS9FG104D.pdf
[4]: https://www.macom.com/files/live/sites/ma/files/contributed/support/Connectivity%20and%20Embedded%20EOL%20products3.pdf
[5]: http://static6.arrow.com/aropdfconversion/2f62d8eef3ab35ea29876a53dd64ce79ef1178c7/hana_pb_2010_0011.pdf

Martin

On Thu, Feb 25, 2021 at 12:12 PM Martin Kennedy <hurricos@gmail.com> wrote:
>
> > Yeah, this is your personal hobby project, isn't it?
>
> For sure.
>
> > ASM1062 Serial ATA Controller
>
> Same as mine -- I think there may only be a firmware difference
> between the ASM1061 and 1062, mine is silkscreened ASM1061 but
> identifies as ASM1062.
>
> > I have the suspecion that your problem is caused by lack of proper to MSI(-X) there.
>
> Bingo. With pci=nomsi in cmdline:
>
> [    9.438171] kmodloader: loading kernel modules from
> /tmp/overlay/upper/etc/modules-boot.d/*
> [    9.552867] ahci 0000:41:00.0: enabling device (0000 -> 0003)
> [    9.558712] ahci 0000:41:00.0: SSS flag set, parallel bus scan disabled
> [    9.565372] ahci 0000:41:00.0: AHCI 0001.0200 32 slots 2 ports 6
> Gbps 0x3 impl SATA mode
> [    9.573443] ahci 0000:41:00.0: flags: 64bit ncq sntf stag led clo
> pmp pio slum part ccc sxs
> [    9.587073] scsi host0: ahci
> [    9.590640] scsi host1: ahci
> [    9.593765] ata1: SATA max UDMA/133 abar m512@0xe00010000 port
> 0xe00010100 irq 19
> [    9.601243] ata2: SATA max UDMA/133 abar m512@0xe00010000 port
> 0xe00010180 irq 19
> [    9.918682] ata1: SATA link down (SStatus 0 SControl 300)
> [   10.385618] ata2: SATA link up 6.0 Gbps (SStatus 133 SControl 300)
> [   10.403649] ata2.00: ATA-8: KINGSTON SV300S37A60G, 580ABBF0, max UDMA/133
> [   10.410427] ata2.00: 117231408 sectors, multi 1: LBA48 NCQ (depth 31/32), AA
> [   10.423624] ata2.00: configured for UDMA/133
> [   10.428252] scsi 1:0:0:0: Direct-Access     ATA      KINGSTON
> SV300S3 BBF0 PQ: 0 ANSI: 5
> [   10.437696] sd 1:0:0:0: [sda] 117231408 512-byte logical blocks:
> (60.0 GB/55.9 GiB)
> [   10.445675] sd 1:0:0:0: [sda] Write Protect is off
> [   10.450572] sd 1:0:0:0: [sda] Write cache: enabled, read cache:
> enabled, doesn't support DPO or FUA
> [   10.461054]  sda: sda1 sda2
> [   10.465177] sd 1:0:0:0: [sda] Attached SCSI disk
>
> And:
>
> root@mx60w:/# hdparm -t /dev/sda
>
> /dev/sda:
>  Timing buffered disk reads: 450 MB in  3.01 seconds = 149.35 MB/sec
>
> Thanks again! Lots more to be tried now.
>
> Martin
>
> On Thu, Feb 25, 2021 at 9:34 AM Christian Lamparter <chunkeey@gmail.com> wrote:
> >
> > Hello Martin,
> >
> > On 22/02/2021 22:54, Martin Kennedy wrote:
> > >
> > > I did make a post a good while ago to gauge interest (there was none).
> > > It is here: https://forum.openwrt.org/t/mx60w-any-interest-in-a-diy-nas-guide-need-some-advice-for-sata-pads-and-msata-slot-compatibility/65718
> > >
> >
> > Yeah, this is your personal hobby project, isn't it? There are basically no hardware
> > mods for the APM82181 as compared to the ath79/ramips/mediatek. For engagement, one
> > has to really invest there to make it popular.... Honestly, the APM82181 seems to
> > stagnate at the "working as intended" level.
> >
> > > I have actually tried kmod-ata-ahci out, but with a potentially
> > > less-suitable ASM1061. Sadly, once the kmod-ata-ahci module has been
> > > kmodloaded, the drives will `ata\d.00: failed to IDENTIFY` -- I
> > > ascribed this to an issue with PCIe init on the platform as you
> > > described on the linuxppc-dev mailing list, though I had not properly
> > > poked the device tree to inform the device of this change. The ASM1061
> > > chipset is known-working on other platforms using OpenWrt (I used two
> > > ASM1061s in an Aerohive AP330 as my NAS for a while).
> >
> > I found my minipcie<->sata 2-port thingy.  It's an ASMedia Technology Inc. ASM1062 Serial ATA Controller [1b21:0612]
> > I don't have a MX60(W) so I used a Netgear WNDAP660. Hope this still counts...
> >
> > And would you look at that: :)
> >
> > [   41.780183] IPv6: ADDRCONF(NETDEV_CHANGE): br-lan: link becomes ready
> > [  114.081146] kmodloader: loading kernel modules from /etc/modules.d/*
> > [  114.165797] ahci 0000:43:00.0: version 3.0
> > [  114.165836] ahci 0000:43:00.0: enabling device (0006 -> 0007)
> > [  114.234964] ahci 0000:43:00.0: SSS flag set, parallel bus scan disabled
> > [  114.314662] ahci 0000:43:00.0: AHCI 0001.0200 32 slots 2 ports 6 Gbps 0x3 impl SATA mode
> > [  114.411770] ahci 0000:43:00.0: flags: 64bit ncq sntf stag led clo pmp pio slum part ccc sxs
> > [  114.519719] scsi host0: ahci
> > [  114.556879] scsi host1: ahci
> > [  114.592747] ata1: SATA max UDMA/133 abar m512@0xe00010000 port 0xe00010100 irq 19
> > [  114.682614] ata2: SATA max UDMA/133 abar m512@0xe00010000 port 0xe00010180 irq 19
> > [  115.247864] ata1: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
> > [  115.322963] ata1.00: HPA detected: current 1953523055, native 1953525168
> > [  115.403754] ata1.00: ATA-8: Hitachi HDT721010SLA360, ST6OA3AA, max UDMA/133
> > [  115.487348] ata1.00: 1953523055 sectors, multi 0: LBA48 NCQ (depth 32), AA
> > [  115.661382] ata1.00: configured for UDMA/133
> > [  115.713002] scsi 0:0:0:0: Direct-Access     ATA      Hitachi HDT72101 A3AA PQ: 0 ANSI: 5
> > [  115.817054] sd 0:0:0:0: [sda] 1953523055 512-byte logical blocks: (1.00 TB/932 GiB)
> > [  115.909977] sd 0:0:0:0: [sda] Write Protect is off
> > [  115.967536] sd 0:0:0:0: [sda] Mode Sense: 00 3a 00 00
> > [  115.968179] sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
> > [  116.134055]  sda: sda1
> > [  116.164790] sd 0:0:0:0: [sda] Attached SCSI disk
> > [  116.240626] ata2: SATA link down (SStatus 0 SControl 300)
> > [  116.308487] sd 0:0:0:0: Attached scsi generic sg0 type 0
> > [  116.375543] kmodloader: done loading kernel modules from /etc/modules.d/*
> > [  116.543762] kmodloader: loading kernel modules from /etc/modules.d/*
> > [  116.624340] kmodloader: done loading kernel modules from /etc/modules.d/*
> > [  116.792215] kmodloader: loading kernel modules from /etc/modules.d/*
> > [  116.872711] kmodloader: done loading kernel modules from /etc/modules.d/*
> >
> > root@wndap660:/tmp# hdparm -t /dev/sda
> >
> > /dev/sda:
> >   Timing buffered disk reads: 308 MB in  3.02 seconds = 101.87 MB/sec
> > (This 100 MB/sec is OK for a 1 GiB 3,5" Hitachi HDD Drive from 2009 I think).
> >
> > I have the suspecion that your problem is caused by lack of proper to MSI(-X) there.
> > While the PCIE Hardware in the SoC has support for MSI (it's pcie) and the linux and
> > DTS has some MSI bits. The linux driver for it needs to be brought into 2021.
> > What I did was just editing the ahci.c driver in the linux kernel.
> >
> > I swapped out the existing:
> >
> > { PCI_VDEVICE(ASMEDIA, 0x0612), board_ahci },     /* ASM1062 */
> >
> > with:
> >
> > { PCI_VDEVICE(ASMEDIA, 0x0612), board_ahci_nomsi },     /* ASM1062 */
> >
> > and it then loaded (before it was failing at the same NO_IDENTIFY).
> >
> > /proc/interrupts also looks "healthy" (for a no-msi setup)
> >
> >   19:        344       UIC  14 Level     ahci[0000:43:00.0]
> >
> > (Maybe the pci=nomsi kernel parameter would do the trick as well. Could you
> > adding this to the bootargs in uboot and check if the ahci.c code now works?)
> >
> > Cheers,
> > Christian
diff mbox series

Patch

--- a/target/linux/apm821xx/dts/meraki-mx60.dts
+++ b/target/linux/apm821xx/dts/meraki-mx60.dts
@@ -169,31 +169,46 @@ 
     };
 };

-&PCIE0 {
-    /* Leave this enabled as u-boot on the MX60 will disable it for us */
+&SATA0 {
     status = "okay";
+    drive0: sata-port@0 {
+        reg = <0>;
+    };
+};

-    /*
-     * relevant lspci topology:
-     *
-     *    -+-[0000:40]---00.0-[41-7f]----00.0
-     */
-
-    bridge@64,0 {
-        reg = <0x00400000 0 0 0 0>;
-        #address-cells = <3>;
-        #size-cells = <2>;
-        ranges;
-
-        wifi0: wifi@65,0 {
-            /* Atheros AR9380 2.4/5GHz */
-            compatible = "pci168c,0030";
-            reg = <0x00410000 0 0 0 0>;
-            interrupts = <1>; /* INTA */
-        };
+&SATA1 {
+    status = "okay";
+    drive1: sata-port@0 {
+        reg = <0>;
     };
 };

+
+/* &PCIE0 { */
+/*     /\* Leave this enabled as u-boot on the MX60 will disable it
for us *\/ */
+/*     status = "okay"; */
+
+/*     /\* */
+/*      * relevant lspci topology: */
+/*      * */
+/*      *    -+-[0000:40]---00.0-[41-7f]----00.0 */
+/*      *\/ */
+
+/*     bridge@64,0 { */
+/*         reg = <0x00400000 0 0 0 0>; */
+/*         #address-cells = <3>; */
+/*         #size-cells = <2>; */
+/*         ranges; */
+
+/*         wifi0: wifi@65,0 { */
+/*             /\* Atheros AR9380 2.4/5GHz *\/ */
+/*             compatible = "pci168c,0030"; */
+/*             reg = <0x00410000 0 0 0 0>; */
+/*             interrupts = <1>; /\* INTA *\/ */
+/*         }; */
+/*     }; */
+/* }; */
+
 &MSI {
     status = "okay";
 };

I also enabled CONFIG_SATA_DWC_DEBUG=y for all nand-boards before recompiling:

--- a/target/linux/apm821xx/nand/config-default
+++ b/target/linux/apm821xx/nand/config-default
@@ -14,7 +14,7 @@  CONFIG_ATA_BMDMA=y
 CONFIG_SATA_PMP=y
 CONFIG_GENERIC_PHY=y
 CONFIG_SATA_DWC=y
-# CONFIG_SATA_DWC_DEBUG is not set
+CONFIG_SATA_DWC_DEBUG=y
 CONFIG_SCSI=y
 CONFIG_BLK_DEV_SD=y
 CONFIG_GPIOLIB=y

I received repeated errors similar to those from a previous mailing list entry
on the AmigaOne (this line is approximate) : https://lkml.org/lkml/2016/4/23/116

sata-dwc 4bffd1000.sata: sata_dwc_error_intr SCR_ERROR=0x00020000
intpr=0x00000088 status=0x000000d0 dma_intp=187 pending=0 issued=0

These errors eventually triggered a kernel oops the first time
around. On the second boot, I removed the mSATA card after the
repeated errors began - they stopped temporarily, but restarted upon
reapplication of the drive.  They went away entirely after disabling
USB in the device tree, though still no drive appears.

--- a/target/linux/apm821xx/dts/meraki-mx60.dts
+++ b/target/linux/apm821xx/dts/meraki-mx60.dts
@@ -40,10 +40,10 @@ 
     status = "okay";
 };

-&USBOTG0 {
-    status = "okay";
-    dr_mode = "host";
-};
+/* &USBOTG0 { */
+/*     status = "okay"; */
+/*     dr_mode = "host"; */
+/* }; */

 &EBC0 {
     /* Buckminster has 1GiB of NAND */