Help - Search - Members - Calendar
Full Version: [SOLVED] JMicron SATA/IDE PCIe Card eSATA problem
InsanelyMac Forum > OSx86 Project > Hardware and Drivers > SATA/IDE Controllers
ApexDE
After hours of trying to make eSATA work with my new JMB363 PCIe Card i am frustrated. There seems to be no way to configure it to use pure AHCI, the card uses Legacy-IDE-AHCI on the eSATA ports. In pure AHCI Mode there should be two PCI Devices (one SATA, one IDE), mine is recognised as ONE device:
CODE
02:00.0 SATA controller: JMicron Technologies, Inc. JMicron 20360/20363 AHCI Controller (rev 03) (prog-if 01 [AHCI 1.0])
    Subsystem: JMicron Technologies, Inc. JMicron 20360/20363 AHCI Controller
    Flags: bus master, fast devsel, latency 0, IRQ 16
    I/O ports at c000
    I/O ports at c100
    I/O ports at c200
    I/O ports at c300
    I/O ports at c400
    Memory at f8000000 (32-bit, non-prefetchable)
    Capabilities: [68] Power Management version 2
    Capabilities: [50] Express Legacy Endpoint, MSI 01
    Capabilities: [100] #197b
    Capabilities: [236] #68



This way, SATA and IDE is mixed sad.gif. There is no way to switch to AHCI in the Controller BIOS. Using the JMicronATA.kext Driver, connected SATA Devices are detected as IDE Drives!


Anyone knows if it is possible to make the card work in pure AHCI Mode? Otherwise pure SATA / eSATA Hotplug won't work sad.gif
ApexDE
For the Archives:

After many hours of reading and trying i got my JMicron JMB363 PCIe Card working as wanted. Some PCI Registers need to be set, so that the Card works in Dual Function Mode. One PCI Device has the SATA AHCI Function, the other one the Legacy IDE Function. This Dual Function Mode is needed to get AHCI working.

lspci:
CODE
02:00.0 SATA controller: JMicron Technologies, Inc. JMicron 20360/20363 AHCI Controller (rev 03)
02:00.1 IDE interface: JMicron Technologies, Inc. JMicron 20360/20363 AHCI Controller (rev 03)


You can archive that using the setpci command to write the PCI Registers of the Card:

sudo setpci -s 02:0.0 40.b=b3 41.b=a1 42.b=c2 (adapt 02:0.0 to your PCI Device number)

I also managed to built a DSDT Patch, which is needed cause you need to have the Card in Dual Function Mode on boot time so that the Apple AHCI Driver recognises the two eSATA Ports. If anyone wants the DSDT Patch, just post here, i subscribed this topic.
THe KiNG
Hi I have the same problem on my lappie:
06:00.0 IDE interface [0101]: JMicron Technologies, Inc. JMicron 20360/20363 AHCI Controller [197b:2360] (rev 02)

As you can see is set in legacy ide mode noexpression.gif
I'd love to see that DSDT fix.

Thanks!

L.E. That command works! smile.gif

CODE
sudo setpci -s 06:0.0 40.b=b3 41.b=a1 42.b=c2 //in my case

And the result is:

06:00.0 SATA controller [0106]: JMicron Technologies, Inc. JMicron 20360/20363 AHCI Controller [197b:2360] (rev 02)


So it moved from legacy [0101] to AHCI [0106]

Wonder if I can do same thing for my desktop marvell crap(there i can set only legacy/raid in bios)

Waiting for DSDT fix smile.gif
ApexDE
OK. Check if you have a JMB Device in your DSDT (mine had, cause Gigabyte seems to use a generic DSDT for all Boards, some have the JMB363 onboard). I had to change "Device (\_SB.PCI0.PEX3.JMB0)" to "Device (\_SB.PCI0.PEX0.JMB0)" cause the PCIe Card is in PCIe Slot 0. Use IORegistryExplorer to look where your Card is. Then i adapted the entry to:
CODE
            Device (\_SB.PCI0.PEX0.JMB0)
            {
                Name (_ADR, 0x00)
                OperationRegion (BAR0, PCI_Config, 0x40, 0x04)
                Field (BAR0, WordAcc, NoLock, Preserve)
                {
                Offset (0x00),
                M1, 8,
                Offset (0x01),
                M2, 8,
                Offset (0x02),
                M3, 8
                }

                Method (_DSM, 4, NotSerialized)
                {
                Store (0xb3, M1)
                Store (0xa1, M2)
                Store (0xc2, M3)
                Return (0x00)
                }
....
....
....



I can now use the Controller with true SATA Hotplugging. Connecting a SATA Harddisk and turning it on results in showing on the Desktop just fine. After ejecting and turning it off, it also disappears from Harddiskutility.
THe KiNG
Thank you mate!

You made my day!
After DSDT fix:
QUOTE
06:00.0 SATA controller [0106]: JMicron Technologies, Inc. JMicron 20360/20363 AHCI Controller [197b:2360] (rev 02)
06:00.1 IDE interface [0101]: JMicron Technologies, Inc. JMicron 20360/20363 AHCI Controller [197b:2360] (rev 02)


One tip for those who used jmicronata.kext remove it! at least on me it cause panic.
For cosmetic stuff create a dummy.kext for it and add :
CODE
        <key>JMicron JMB360 AHCI</key>
        <dict>
            <key>CFBundleIdentifier</key>
            <string>com.apple.driver.AppleAHCIPort</string>
            <key>Chipset Name</key>
            <string>JMB360 eSATA AHCI</string>
            <key>IOClass</key>
            <string>AppleAHCI</string>
            <key>IOPCIClassMatch</key>
            <string>0x01060100&amp;0xffffff00</string>
            <key>IOPCIPrimaryMatch</key>
            <string>0x2360197b</string>
            <key>IOProbeScore</key>
            <integer>800</integer>
            <key>IOProviderClass</key>
            <string>IOPCIDevice</string>
            <key>Vendor Name</key>
            <string>JMicron</string>
        </dict>

IOPCIClassMatch is very important w/o it again panic!

If you don't mind can you explain how did you find the info/fix?
I tried to set the same thing on my desktop marvell but seems to not work, so i need more info biggrin.gif

Thanks again.
ApexDE
I got the infos from the Linux Driver Sources (drivers/pci/quirks.c), maybe you can get the needed infos from the linux sources too (drivers/ata/ahci.c has some marvell entries)
THe KiNG
Something like this? http://marc.info/?l=linux-ide&m=116986924301674&w=2 and this : http://www.mail-archive.com/linux-ide@vger...g/msg03281.html ?
To be honest I don't understand much...maybe you can explain in detail...
pharillion
Great work ApexDE. I'd really like to be able to do this with my onboard JMB363 which seems fixed in IDE mode:

05:00.0 IDE interface [0101]: JMicron Technology Corp. 20360/20363 Serial ATA Controller [197b:2363] (rev 03)

Running sudo setpci -s 05:0.0 40.b=b3 41.b=a1 42.b=c2 works exactly as you suggest and we're now in ACHI mode:

05:00.0 SATA controller [0106]: JMicron Technology Corp. 20360/20363 Serial ATA Controller [197b:2363] (rev 03)

IORegistryExplorer tells me the controller is on P0P5

Click to view attachment

However I'm having trouble adapting your DSDT patch for my DSDT. There's already a (Device) JMB0 and (Device) JMB1 section, quite an extensive one, here as dsdtclip.txt

Click to view attachment

I've tried removing much of this and replacing it with something closer to the suggested patch, but I'm getting errors which I don't completely understand. I'm sure I'm doing something wrong. Thus far I have only limited experience in editing DSDT.

Any help anyone can offer in fixing my DSDT to allow the JMicron controller to work in AHCI mode will be very much appreciated.

Many Thanks
ApexDE
@ the king

i guess there is no way to fix the marvell controller via dsdt patching sad.gif it seems you need a special driver for os x.

@ papi

try to insert this at the start of the JMB0 Device entry:
CODE
                Device (JMB0)
                {
                    Name (_ADR, Zero)
                OperationRegion (BAR0, PCI_Config, 0x40, 0x04)
                Field (BAR0, WordAcc, NoLock, Preserve)
                {
                Offset (0x00),
                M1, 8,
                Offset (0x01),
                M2, 8,
                Offset (0x02),
                M3, 8
                }

                Method (_DSM, 4, NotSerialized)
                {
                Store (0xb3, M1)
                Store (0xa1, M2)
                Store (0xc2, M3)
                Return (0x00)
                }

….
….



If you get errors, post the log
pharillion
Thanks very much ApexDE

What you very helpfully included was one of the possibilities I'd already tried as Click to view attachment but unfortunately at least in my hands this produces lots of errors which I've included here: Click to view attachment
Much of these errors seem unrelated to the JMB0 additions though perhaps I've got a misplaced bracket somewhere. The "^ Use of compiler reserved name (_T_0)" warning existed before I made any changes and seems harmless.

I'm also including the full dsdt.dsl in case this is useful. The only changes I've made to it are removing CPU aliases, HPET and RTC fixes, and adding a HDEF device and DTGP method. Apart from the warning mentioned above this compiles ok. It would be terrific if you could pinpoint where I'm going wrong.
Click to view attachment

Thanks again for your help.
ApexDE
Lets try two OperationRegion Definitions. Try if it works.
pharillion
QUOTE (ApexDE @ Oct 29 2009, 09:41 PM) *
Lets try two OperationRegion Definitions. Try if it works.

Brilliant! Thank you so much ApexDE. That works beautifully and I've now got my JMicron controller working perfectly in AHCI mode.

I would never have thought of duplicating the OperatorRegion definition but I've clearly got a lot to learn about dsdt editing.

Thank you very much indeed for your kind help.
pharillion
Hmm, unfortunately it seems I may have spoken too soon. sad.gif

Any disk connected to the JMicron controller ports in AHCI/eSATA mode seems fine to begin with but gradually accumulates errors which fsck and other utilities cannot repair.

If I revert to IDE non-removable mode with the same disk(s) and cabling after removing the dsdt patch and replacing LegacyJmicronAHCI.kext with JMicronATA.kext, such errors no longer accumulate.

I suspect I may have to go back to IDE mode for stability. I hope my problem is an isolated one and therefore doesn't cause problems for other users adopting this innovative dsdt patch.

Best regards,
THe KiNG
What kind of errors you get?
Paste some log or something, does that with any disk?

L.E. I restored my working install on eSATA disk and booted from it, all works OK so far...
pharillion
QUOTE (THe KiNG @ Oct 30 2009, 08:48 AM) *
What kind of errors you get?
Paste some log or something, does that with any disk?

from console.log

29/10/2009 23:39:01 kernel hfs_swap_HFSPlusBTInternalNode: unrecognized catalog record type (0x000A; record #6)
29/10/2009 23:39:01 kernel hfs: node=15502 fileID=4 volume=eSATA device=/dev/disk2s2
29/10/2009 23:39:01 kernel hfs: Runtime corruption detected on eSATA, fsck will be forced on next mount.
29/10/2009 23:39:01 kernel hfs: FindNextLeafNode: Error from hfs_swap_BTNode (node 15502)
29/10/2009 23:39:08 mdworker[316] (Error) SyncInfo: searchfs error (Result too large) -- falling back to fsw search /Volumes/eSATA

I've had unexplained hangs and slowness on two different disks connected to the JMicron controller in AHCI mode, but both disks work correctly when in IDE mode without the DSDT patch.

Turning on the eSATA/AHCI disk after boot and allowing it to automount seems to work better.
QUOTE
L.E. I restored my working install on eSATA disk and booted from it, all works OK so far...

I restored a bootable SuperDuper! disk image to an external disk connected to the JMicron controller in IDE mode and booted successfully from this. The same disk connected to the JMicron controller in AHCI mode would not boot and eventually hung with many disk I/O errors.

I'm glad your controller is working in AHCI mode without problems.
ApexDE
It might be a problem with the eSATA Case too. I tried 3 different HDs with two different eSATA Cases, no errors here, anything works as expected. If you are using the eSATA Ports, make sure there is NO JMicron kext loaded. You don't need a JMicron kext unless you want to use the IDE Port or SATA Ports in IDE Mode

Try hooking up a SATA HD directly to the eSATA Port without any Bridge Chip inbetween. My IcyBox Combocase with eSATA Port is very bitchy too wink.gif (sometimes HD is recognised, sometimes not). Best thing is to get a pure eSATA Case like this one IMHO: http://www.delock.com/produkte/gruppen/Geh...SATA_42406.html
THe KiNG
Try to cleanup the JMB0 section or remove both and make just one with the hacked registers, AHCI dosen't need all that code.
Look on mine, maybe that will help you:
CODE
                Device (EATA)
                {
                    Name (_ADR, Zero)
                    Name (_SUN, 0x06)
                    OperationRegion (BAR0, PCI_Config, 0x40, 0x04)
                    Field (BAR0, WordAcc, NoLock, Preserve)
                    {
                            Offset (0x00),
                        M1, 8,
                            Offset (0x01),
                        M2, 8,
                            Offset (0x02),
                        M3, 8
                    }

                    Method (_DSM, 4, NotSerialized)
                    {
                        Store (0xb3, M1)
                        Store (0xa1, M2)
                        Store (0xc2, M3)
                        Store (Package (0x02)
                            {
                                "name",
                                Buffer (0x16)
                                {
                                    "J-Micron JMB360 eSATA"
                                }
                            }, Local0)
                        DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))
                        Return (Local0)
                    }
                    OperationRegion (SATE, PCI_Config, Zero, 0xF0)
                    Field (SATE, DWordAcc, NoLock, Preserve)
                    {
                                Offset (0x2C),
                        SA2C,   32,
                                Offset (0x43),
                        SA43,   8,
                                Offset (0xD3),
                        SAD3,   8
                    }

                    Method (_INI, 0, NotSerialized)
                    {
                    }

                    Method (ESAT, 0, NotSerialized)
                    {
                        Notify (RP06, Zero)
                        And (SAD3, 0x7F, SAD3)
                        Or (SA43, 0x40, SA43)
                        Store (0x13481043, SA2C)
                        And (SA43, 0xBF, SA43)
                    }

                    Method (ESID, 0, NotSerialized)
                    {
                        Return (SA2C)
                    }
                }
ApexDE
@ the king

i just had this idea too wink.gif
pharillion
QUOTE (ApexDE @ Oct 30 2009, 03:18 PM) *
It might be a problem with the eSATA Case too. I tried 3 different HDs with two different eSATA Cases, no errors here, anything works as expected. If you are using the eSATA Ports, make sure there is NO JMicron kext loaded. You don't need a JMicron kext unless you want to use the IDE Port or SATA Ports in IDE Mode

Thanks, yes, I should have explained better. The only JMicron kext I have loaded is a cosmetic "legacy" one which simply changes "Unknown AHCI Controller" as reported by the standard AppleAHCIPort.kext to "JMicron JMB36x AHCI Controller". Without this loaded the same problems exist.
QUOTE
Try hooking up a SATA HD directly to the eSATA Port without any Bridge Chip inbetween. My IcyBox Combocase with eSATA Port is very bitchy too wink.gif (sometimes HD is recognised, sometimes not). Best thing is to get a pure eSATA Case like this one IMHO: http://www.delock.com/produkte/gruppen/Geh...SATA_42406.html

I'm using a pure eSATA case with no USB - the external eSATA connection goes straight to the drive backplane connector. This wasn't particularly expensive but I've had it working on Intel ICH10 and SiI 3132 without problems under Leopard.

Thanks again for your help.

QUOTE (THe KiNG @ Oct 30 2009, 03:23 PM) *
Try to cleanup the JMB0 section or remove both and make just one with the hacked registers, AHCI dosen't need all that code.
Look on mine, maybe that will help you:

Thanks THe KiNG (and ApexDE too), that's very helpful. I will try adding something following your dsdt code example and report back.

Something I have noticed is that with drive(s) mounted on the JMicron controller, either in AHCI/eSATA or IDE mode, NCQ is reported as "No" or unsupported. I wasn't expecting this in AHCI mode.
ApexDE
NCQ is working here. Try TheKings suggested changes and report back. You have loads of other changes in your JMB entry, maybe thats the cause of your problems.
pharillion
QUOTE (ApexDE @ Oct 30 2009, 05:04 PM) *
NCQ is working here. Try TheKings suggested changes and report back. You have loads of other changes in your JMB entry, maybe thats the cause of your problems.

Thank you ApexDE. I wish I had enough skill to do this properly. Unfortunately all my attempts to cut down my JMB0 and JMB1 device entries or even just to match my JMB0 device with the example given by THe KiNG just seem to produce lots of compilation errors and therefore no working dsdt.aml. Of course I'll keep trying, and continue my reading on ACPI and dsdt syntax, but really I think I'm rather out of my depth.
Removing almost anything from my existing and over-long Device (JMB0) entry seems to result in an error!
Thanks again.
THe KiNG
Now to complete this hack, how to disable the PATA port tongue.gif

Add a new device like in this example:
CODE
Device (EPTA)
{
Name (_ADR, One)
OperationRegion (BAR0, PCI_Config, 0x40, 0x04)
Field (BAR0, WordAcc, NoLock, Preserve)
{
Offset (0x00),
M1, 8,
Offset (0x01),
M2, 8,
Offset (0x02),
M3, 8
}

Method (_DSM, 4, NotSerialized)
{
Store (Zero, M1)
Store (Zero, M2)
Store (Zero, M3)
Return (Zero)
}
}

Compile, reboot and then look on lspci/ioreg the PATA is gone! rolleyes.gif

@pharillion
Try to add this 2 device instead of yours:
CODE
Device (EATA)
{
Name (_ADR, Zero)
OperationRegion (BAR0, PCI_Config, 0x40, 0x04)
Field (BAR0, WordAcc, NoLock, Preserve)
{
Offset (0x00),
M1, 8,
Offset (0x01),
M2, 8,
Offset (0x02),
M3, 8
}

Method (_DSM, 4, NotSerialized)
{
Store (0xb3, M1)
Store (0xa1, M2)
Store (0xc2, M3)
Store (Package (0x02)
{
"name",
Buffer (0x16)
{
"J-Micron JMB36x eSATA"
}
}, Local0)
DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))
Return (Local0)
}
}

Device (EPTA)
{
Name (_ADR, One)
OperationRegion (BAR0, PCI_Config, 0x40, 0x04)
Field (BAR0, WordAcc, NoLock, Preserve)
{
Offset (0x00),
M1, 8,
Offset (0x01),
M2, 8,
Offset (0x02),
M3, 8
}

Method (_DSM, 4, NotSerialized)
{
Store (Zero, M1)
Store (Zero, M2)
Store (Zero, M3)
Return (Zero)
}
}

If you don't want the PATA to be disabled just remove the second device(with what is in brackets)

Thanks ApexDE for opening my eyes on this, now the hack is complete angel.png
mamadou
QUOTE (THe KiNG @ Oct 31 2009, 01:59 AM) *
Now to complete this hack, how to disable the PATA port tongue.gif

Add a new device like in this example:
CODE
Device (EPTA)
{
Name (_ADR, One)
OperationRegion (BAR0, PCI_Config, 0x40, 0x04)
Field (BAR0, WordAcc, NoLock, Preserve)
{
Offset (0x00),
M1, 8,
Offset (0x01),
M2, 8,
Offset (0x02),
M3, 8
}

Method (_DSM, 4, NotSerialized)
{
Store (Zero, M1)
Store (Zero, M2)
Store (Zero, M3)
Return (Zero)
}
}

Compile, reboot and then look on lspci/ioreg the PATA is gone! rolleyes.gif

@pharillion
Try to add this 2 device instead of yours:
CODE
Device (EATA)
{
Name (_ADR, Zero)
OperationRegion (BAR0, PCI_Config, 0x40, 0x04)
Field (BAR0, WordAcc, NoLock, Preserve)
{
Offset (0x00),
M1, 8,
Offset (0x01),
M2, 8,
Offset (0x02),
M3, 8
}

Method (_DSM, 4, NotSerialized)
{
Store (0xb3, M1)
Store (0xa1, M2)
Store (0xc2, M3)
Store (Package (0x02)
{
"name",
Buffer (0x16)
{
"J-Micron JMB36x eSATA"
}
}, Local0)
DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))
Return (Local0)
}
}

Device (EPTA)
{
Name (_ADR, One)
OperationRegion (BAR0, PCI_Config, 0x40, 0x04)
Field (BAR0, WordAcc, NoLock, Preserve)
{
Offset (0x00),
M1, 8,
Offset (0x01),
M2, 8,
Offset (0x02),
M3, 8
}

Method (_DSM, 4, NotSerialized)
{
Store (Zero, M1)
Store (Zero, M2)
Store (Zero, M3)
Return (Zero)
}
}

If you don't want the PATA to be disabled just remove the second device(with what is in brackets)

Thanks ApexDE for opening my eyes on this, now the hack is complete angel.png

Hi THe KiNG...It's a personnal request, could you please upload your patched dsdt lappy (I think we've the same Asus M50sv), it much needed for SL. Thanks in advance. rolleyes.gif
mamadou
QUOTE (THe KiNG @ Oct 31 2009, 03:10 PM) *
There is no difference in my DSDT for snow, I use the same DSDT as I posted in M50SV topic plus this changes for eSATA.
I use just one kext in plust to fix ioata panic.


@ THe KiNG, I tried to download it in your previous topic here:
http://www.insanelymac.com/forum/index.php...t&p=1106388
apparently, the link is deleted. unsure.gif
mamadou
QUOTE (THe KiNG @ Oct 31 2009, 09:24 PM) *
Then wait for the new guide.
I cant post the actual one since is in beta stage, and has on it a lot of crap.
I don't post unfinished crap like some does...is not me.

@ THe KiNG, all the credits is yours if I succeeded in installing Mac OS X in my lappy. Be sure, I'm patiently waiting the new guide. With my regards. smile.gif
Tristano
QUOTE (mamadou @ Oct 31 2009, 08:42 PM) *
@ THe KiNG, all the credits is yours if I succeeded in installing Mac OS X in my lappy. Be sure, I'm patiently waiting the new guide. With my regards. smile.gif

Hello THe KiNG you could compile my DSDT I have the same PCI-Express controller has 2 SATA ports and one IDE port JMB363, my motherboard its asus p5k has built-in that controls the IDE port and two eSATA .
its lsci
03:00.0 SATA controller [0106]: JMicron Technologies, Inc. JMicron 20360/20363 AHCI Controller [197b:2363] (rev 03)
03:00.1 IDE interface [0101]: JMicron Technologies, Inc. JMicron 20360/20363 AHCI Controller [197b:2363] (rev 03)
04:00.0 RAID bus controller [0104]: JMicron Technologies, Inc. JMicron 20360/20363 AHCI Controller [197b:2363] (rev 03)
my dsdt.aml
thx in advance.
THe KiNG
Stop with offtopic stuff.
@mamadou i don't need any credits, no need to spam this topic, so I will delete offtopic stuff, do the same kthx.
@Tristano set up your controller in BIOS first, then learn how to compile your DSDT.

Thanks ApexDE for sharing the info, I'm out of here before someone else will not ask for God knows what else...
mitch_de
Would be helpful to show a bit of surrounding dsdt code above / below that eSATA dsdt stuff (Codebox ? / dsdt_part.zip) . Makes clearer where excat to include in the SATA part.

ApexDE
@ mitch

Check page 1 and post #11
sergest
great! the DSDT fix helped me to solve this: http://www.insanelymac.com/forum/index.php...t&p=1309387

though after system sleep/wake i have this kernel log message:
CODE
kernel[0]: pci restore waited for pci197b,2360 (8366) fail


however esata device keeps working well.
so does this message have any effect?


UPDATE:
i was too oblivious and didn't notice the solution is right above. disabling PATA port was the trick wink.gif
sergest
well, did some research.
in my case i have my esata working only after sleep/wake, so i compared registers before and after sleep.

before:
40: 11 11 02 20 00 00 7f 75 30 00 00 3f 00 00 00 00

after:
40: 11 f1 02 20 00 00 ff f0 30 00 00 3f 00 00 00 00

then i applied the following fix:
CODE
                         OperationRegion (BAR0, PCI_Config, 0x40, 0x04)
                         Field (BAR0, WordAcc, NoLock, Preserve)
                         {
                                 Offset (0x01),
                             M1, 8
                         }
    
                         Method (_INI, 0, NotSerialized)
                         {
                             Store (0xF1, M1)
                         }


and now esata works right after system start and there is no pata port i have to disable.
J Lamp
ApexDE

I bow to your genius wink.gif

Using DSDT on my Intel DP45SG board has been flakey at best compared to my Gigabyte board, but your solution nailed it.

Thank you!
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.