#
✕ nick:cyrozap
#asahi-dev · 2022-11-23 03:58
cyrozapI wrote a bunch of stuff, but then realized it didn't apply :P
#asahi-dev · 2022-11-23 03:57
cyrozapActually, never mind.
#asahi-dev · 2022-11-23 03:46
cyrozapOh, and one more thing:
#asahi-dev · 2022-11-23 03:43
cyrozapAnd to be clear, those sleep values were obtained by experimentation and I just set them to "good enough to work reliably but not too slow", so you might want to experiment to see if you can get away with smaller delays.
#asahi-dev · 2022-11-23 03:42
cyrozapmuch issues (though I do remember adding the sleeps for the indirect MMIO writes), but C kernel code writing to PCI MMIO may simply be writing all the registers too fast for the chips internal busses to keep up.
#asahi-dev · 2022-11-23 03:41
cyrozapmarcan: Regarding instability, thinking again about what I needed to do to get direct firmware loading working on the older chips, I think you might need to confirm the writes to the address registers for both the indirect code RAM writes and the indirect MMIO writes. And yes, you might also need the sleeps, too. My Python code using PCI config space accesses is slow enough that I didn't experience
#asahi-dev · 2022-11-23 03:19
cyrozaphave someone decap and image both the 2142 and the 3142 so we can confirm if they really are the same die, and check the mask revision numbers to confirm what changed.
#asahi-dev · 2022-11-23 03:18
cyrozapthey support the same speeds on both USB and PCIe. Since ASMedia no longer lists the 2142 on their website, and the 2142 and 3142 have different chip version numbers (which you can access by doing an indirect read to byte 0x150B2), I'm pretty sure they just fixed something in the silicon and called it a new chip to avoid having to explain multiple 2142 revisions to their customers. I hope to eventually
#asahi-dev · 2022-11-23 03:18
cyrozapAccording to the product pages (https://web.archive.org/web/20181003174332/http://www.asmedia.com.tw/eng/e_show_products.php?cate_index=175&item=178 and https://web.archive.org/web/20181003174337/http://www.asmedia.com.tw/eng/e_show_products.php?cate_index=175&item=179), compared to the 2142, the 3142 supports "Multiple INs"--I don't know enough about USB to understand what that means. Other than that,
#asahi-dev · 2022-11-23 03:05
cyrozapAnd yes, you might need to confirm the writes.
#asahi-dev · 2022-11-23 03:05
cyrozapIf you do use the public part number, I'd use 2142 instead of 3142, since as far as I can tell the 3142 is just a newer die revision of the 2142. No idea what the _actual_ differences are, but they both use the same firmware images and have identical mask ROMs.
#asahi-dev · 2022-11-23 03:01
cyrozapI have a Kaitai Struct definition for their firmware images, in case you're curious: https://github.com/cyrozap/asmedia-xhc-re/blob/59708d5b5eb17593f6f5459f2bf20b73e90b159d/tools/asm_fw.ksy
#asahi-dev · 2022-11-23 03:00
cyrozapmarcan: "2214" comes from the RCFG/FW headers, which are "2214A_RCFG"/"2214A_FW" for the ASM2142 and ASM3142 (https://github.com/cyrozap/asmedia-xhc-re/blob/59708d5b5eb17593f6f5459f2bf20b73e90b159d/monitor/make_image.py#L32). I assume "2214A" is ASMedia's internal name for the chip, but I have no idea why they rotate the number right by one place compared to the model numbers they write on the chips.
#asahi-dev · 2022-11-23 01:50
cyrozapwrite to an address larger than 48 bits?
#asahi-dev · 2022-11-23 01:50
cyrozapI have some questions regarding the DART IOMMU. If my understanding is correct, some Apple SoCs only have a 36-bit address space, while others have a 42-bit address space. Is this just the physical limit, and the I/O virtual address can be larger (e.g., greater than 48 bits)? Or does this limit apply to the virtual addresses as well? Like, would Linux running on an Apple SoC ever tell a PCIe device to
#asahi-dev · 2022-11-23 01:03
cyrozappovik: Thanks again for your help--I've managed to successfully download and extract the ASMedia firmware. Interestingly, the firmware version ("191118_70_11_11") is newer than any other I've seen in the wild so far. I wonder if they fixed the bug where trying to read from two devices simultaneously can sometimes cause a bad DMA write...
#asahi-dev · 2022-11-22 22:31
cyrozapbtw, if anyone has any questions about the ASMedia USB host controllers, I've done a lot of in-depth RE of them, so feel free to ask!
#asahi-dev · 2022-11-22 22:28
cyrozapSo, uh, thanks, Apple, for using functionality in ASMedia's newer host controllers that no other system vendors seem to be using. And big thanks to marcan for doing the RE work on that--you've saved me a lot of time and energy :)
#asahi-dev · 2022-11-22 22:22
cyrozapcertain that those BAR0 registers are accessing MMIO because the registers accessed through them (e.g., https://github.com/AsahiLinux/linux/blob/893f672e78d075fbb7b4530ffc190173dc700871/drivers/usb/host/xhci-pci-asmedia.c#L222-L223) match the ones I've documented (https://github.com/cyrozap/asmedia-xhc-re/blob/59708d5b5eb17593f6f5459f2bf20b73e90b159d/data/regs-asm2142.yaml#L108-L173).
#asahi-dev · 2022-11-22 22:22
cyrozapOh, interesting... Looking at the kernel code, it looks like ASMedia moved the direct MMIO access functionality from the PCI config space to BAR0. And so the only other differences in the process are really just some MMIO address and bit field changes, which makes sense since the ASM2142 and later use a different range of addresses for their MMIO compared to the ASM1142 and earlier. And I know for
#asahi-dev · 2022-11-22 21:50
cyrozappovik, jannau: Thank you both, that's really helpful information! I'm surprised to see they're using a bog-standard ASM3142, and not some special part customized by Apple. And the mask ROM firmware version (0x010250090816, normally written like 160809_50_02_01) confirms that, since that's the same version I see with the ASM2142 and ASM3142 chips I have.
#asahi-dev · 2022-11-22 21:28
cyrozapfrom Apple and extract the firmware myself?
#asahi-dev · 2022-11-22 21:28
cyrozapor they have it disabled by default. So, I have a few questions: 1) Which ASmedia USB host controller is Apple using in their devices? 2) Has the firmware upload protocol that Apple is using been documented anywhere? 3) Which Apple models contain these ASMedia USB host controllers? 4) Is there a way to download the macOS XNU kernel binary (which the post said contains the ASMedia firmware) directly
#asahi-dev · 2022-11-22 21:28
cyrozapdocumented here: https://github.com/cyrozap/asmedia-xhc-re/blob/59708d5b5eb17593f6f5459f2bf20b73e90b159d/doc/src/index.adoc#code-ram-write-access, example code here: https://github.com/cyrozap/asmedia-xhc-re/blob/59708d5b5eb17593f6f5459f2bf20b73e90b159d/tools/asm_tool.py#L156-L213) are the ASM1042A and ASM1142--the others (ASM1042, ASM2142/ASM3142, and ASM3242) either lack the functionality in hardware
#asahi-dev · 2022-11-22 21:28
cyrozapHi, all! I just read the recent progress report, and the part about the ASMedia firmware loading functionality really interested me. I've been working on my own ASMedia USB host controller RE project for a couple years now (https://github.com/cyrozap/asmedia-xhc-re), and from my research, the only ASMedia USB host controllers I found that include hardware-based firmware upload over PCIe (functionality
#asahi-dev · 2021-07-18 18:30
cyrozapI think TheLink is referring to this: https://en.wikipedia.org/wiki/Black_company_(Japanese_term)