MrChromebox / firmware

Issue tracker for firmware issues
75 stars 14 forks source link

TEEMO - Asus Chromebox 3 - replace wifi card by second ethernet adapter #512

Open namezys opened 11 months ago

namezys commented 11 months ago

I want to add 2.5Gb ethernet card to my chromebox. I added it and it doesn't work.

Some information about system:

firmware-util.sh output:

**   Device: Asus Chromebox 3 / CN65 (TEEMO)
** Platform: Intel KabyLake
**  Fw Type: Full ROM / UEFI
**   Fw Ver: MrChromebox-4.20.1 (07/21/2023)
**    Fw WP: Disabled

Replace WiFi card with ethernet card Realtek RTL8125B:

On-board ethernet: RTL8111:

There is no new device in lspci at all.

I did some investigation.

There is a significant difference:

Next is trying to look into overridetree.cb. Looks like it is incorrect: coreboot/src/mainboard/google/fizz/variants/fizz/overridetree.cb

BTW I can see something like:

        device pci 1c.3 on
            chip drivers/wifi/generic
                register "wake" = "GPE0_PCI_EXP"
                device pci 00.0 on end
            end
        end # PCI Express Port 4 for WLAN

My suggestion is that this PCI 02: can be used only with WiFi. In the case of another device class, it would not be accepted and this device is disabled.

Can you help me to realize what happened?

namezys commented 11 months ago

There are outputs for:

namezys commented 11 months ago

Some additional info

From here: variants/baseboard/devicetree.cb

        # PCI Express Port 3 for LAN, will be swapped to port 1 by FSP
        device pci 1c.2 on
            chip drivers/net
                register "customized_leds" = "0x0fa5"
                register "wake" = "GPE0_PCI_EXP"
                device pci 00.0 on end
                register "device_index" = "0"
            end
        end # PCI Express Port 3
        device pci 1c.3 on
            chip drivers/wifi/generic
                register "wake" = "GPE0_PCI_EXP"
                device pci 00.0 on end
            end
        end # PCI Express Port 4 for WLAN

I looked into src/device/pci_device.c

As I undertand, pci_probe_dev expect that there is a WiFi device on 1c.3.

I suppose that I can remove chip section:

        # PCI Express Port 3 for LAN, will be swapped to port 1 by FSP
        device pci 1c.2 on
            chip drivers/net
                register "customized_leds" = "0x0fa5"
                register "wake" = "GPE0_PCI_EXP"
                device pci 00.0 on end
                register "device_index" = "0"
            end
        end # PCI Express Port 3
        device pci 1c.3 on end # PCI Express Port 4 for WLAN
        device pci 1c.4 on end # PCI Express Port 5 for NVMe

In this case I can lost ability to wake on lan but it acceptable for me.

To be honest, I don't know how to build everything. If you have a build script, it would be very helpful.

MrChromebox commented 11 months ago

As I undertand, pci_probe_dev expect that there is a WiFi device on 1c.3.

that is not correct. The PCIe port is enabled, and that's it. the comment is simply to indicate what device is attached / why it's enabled. pci_probe_dev has no expectation as to what device is going to be connected to the root port.

coreboot is simply failing to detect any device attached to the port, for reasons unknown. There are no changes which we can make to the devicetree/overrridetree which will change that behavior. I'd likely need to add some more debug output to coreboot to determine the source of the issue

tirsojrp commented 11 months ago

Already tried... my card is a 2.5G Intel i225 v3 (M key). Tried on the NVME/SATA port and the WiFi port with an adapter. It works on any other pc I have tried.

MrChromebox commented 11 months ago

already tried...what?

your other PC may have the the m.2 sockets wired differently so it's not directly comparable to that on TEEMO

is this similar to what you're trying to use? www.amazon.com/dp/B0BPCT87MS

namezys commented 11 months ago

This is the card that I have: https://vi.aliexpress.com/item/1005005101361503.html

namezys commented 11 months ago

I want to add more logs to open core. @MrChromebox just to confirm that I can build ROM using your script: coreboot/build-uefi.sh Also, can I extract blobs from the current UEFI. I have not saved the original one.

Maybe I'm not correct (I started to dig into opencore code yesteday) but I suggest that:

BTW, if I can build it, I would be able to debug it.

struct device *pci_probe_dev(struct device *dev, struct bus *bus,
                unsigned int devfn)
{
    u32 id, class;
    u8 hdr_type;

    /* Detect if a device is present. */
    if (!dev) {
        struct device dummy;
                ...
        id = pci_read_config32(&dummy, PCI_VENDOR_ID);
                ...
        dev = alloc_dev(bus, &dummy.path);
    } else {
                ...
        id = pci_read_config32(dev, PCI_VENDOR_ID);

        /*
         * If the device does not have a PCI ID disable it. Possibly
         * this is because we have already disabled the device. But
         * this also handles optional devices that may not always
         * show up.
         */
        /* If the chain is fully enumerated quit */
        if ((id == 0xffffffff) || (id == 0x00000000) ||
            (id == 0x0000ffff) || (id == 0xffff0000)) {
            if (dev->enabled) {
                printk(BIOS_INFO,
                       "PCI: Static device %s not found, disabling it.\n",
                       dev_path(dev));
                dev->enabled = 0;
            }
            return dev;
        }
    }
       ...

    /* Display the device. */
    printk(BIOS_DEBUG, "%s [%04x/%04x] %s%s\n", dev_path(dev),
           dev->vendor, dev->device, dev->enabled ? "enabled" : "disabled",
           dev->ops ? "" : " No operations");

    return dev;
}
tirsojrp commented 11 months ago

already tried...what?

Tried to add a second ethernet adapter to a CN65.

your other PC may have the the m.2 sockets wired differently so it's not directly comparable to that on TEEMO

Of course, tested to make sure card and adapter were working properly.

is this similar to what you're trying to use? www.amazon.com/dp/B0BPCT87MS

Different ethernet port breakout, but looks the same.

https://www.ebay.com/itm/204175573191

MrChromebox commented 11 months ago

@MrChromebox just to confirm that I can build ROM using your script:
coreboot/build-uefi.sh

you would build using: ./build-uefi.sh fizz

if you don't supply the board name, it will build all 100+ boards that I support

namezys commented 11 months ago

@MrChromebox just to confirm that I can build ROM using your script: coreboot/build-uefi.sh

you would build using: ./build-uefi.sh fizz

if you don't supply the board name, it will build all 100+ boards that I support

Got it. I tried but there were compatibility issues.

Can you tell me what environment do you use? I tried Ubuntu 22.04. And do I need any binaries? As I can see there almost all binaries except CPU microcode

MrChromebox commented 11 months ago

Ubuntu 2204 works fine. you need to properly set up the coreboot toolchain etc and clone submodules as per the setup instructions on coreboot.org. CPU microcode is included in the blobs submodule and will automatically be included in the build once the submodule is cloned

namezys commented 11 months ago

Thank you. It works on 22.04. Also, I looked into the build instructions for edk2 to add other packages.

namezys commented 10 months ago

Hey.

I have a great news:

01:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 15)
02:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8125 2.5GbE Controller (rev 05)
03:00.0 Non-Volatile memory controller: Samsung Electronics Co Ltd NVMe SSD Controller SM981/PM981/PM983

I built dozens of firmware with a lot of debugging and understood a lot about PCI probes/scans. However, nothing related to an attached device.

Next step I looked at the WiFi card and checked the pinout of M-2 A+E port.

intel_m2

One pin looked very promising: CLKREQ.

Next was RTL8125.

rtl_8125

Here this pin is unconnected therefore it's tri-state.

From some documentation (short description of PCI-E):

The card must drive the CLKREQ# signal low during power up, whenever it is reset, and whenever it requires the reference clock to be in the active clock state.

As a next step, I tapped this pin on the WiFi card. After boot this card is dissapered from PCI devices.

And final step - just connect this to ground pin (right to CLKREQ#) on ethernet card.

rtl8125_mod

And it is in device list right now.

Testing through iperf

photo_2023-09-03 01 16 36

Next task:

And I can confirm that there is only PCI-E x1

MrChromebox commented 10 months ago

try to find if it's possible to disable checking CLKRTL# in firmware.

you can enable/disable/adjust CLKREQ for PCIe devices, see: /home/mattd/dev/coreboot/src/mainboard/google/fizz/variants/baseboard/devicetree.cb starting around line 161

namezys commented 10 months ago

Do you mean register "PcieRpClkReqSupport[3]" = "1".

I tried it. Looks like it's affects only devices and does not affect bus initialisation. So you can disable this feature on add-on card only. I should find the place there PCI bus initialisation. Also I'm looking where PCI lanes combined to links. I hope I can turn NVMe slot (x4) to two (2x2) PCI slots.

MrChromebox commented 10 months ago

Also I'm looking where PCI lanes combined to links. I hope I can turn NVMe slot (x4) to two (2x2) PCI slots.

that's controlled by the soft straps in the IFD, you need Intel's FIT tool to configure, and flash externally

namezys commented 10 months ago

@MrChromebox Thank you. If you have something to start, it would be great. I found few information but helpful would be appreciate. However, this investigation will be much slower.

Also, I check mini-pci SATA that I tried to use on my previous Chromebox.

Looks like same issue. unfortunately, I don't have this old Chromebox any more and can't check.

Actually I got old Chromebox and tried this card. It works

mPci SATA

mPci CLKREQ

I suppose that it would be great to write short manual how to enable this add-on card.

MrChromebox commented 10 months ago

look at the Win-raid forums for the download you'll need for the FIT tool

namezys commented 9 months ago

Hey, guys.

Win-raid is very helpful.

Right now I found how to disable checking CLKREQ.

Screenshot 2023-10-08 at 15 31 21

Continue to play around.

windsifter commented 8 months ago

Did you ever get it working? I was tempted to try and add a 2.5Gb ethernet adapter there as well, but if the hardware requires special software, I'd be at a loss. Did you punch another hole out the back or side for the ethernet cable?

namezys commented 8 months ago

@windsifter

Did you ever get it working?

Yes. It's actually easy. Just pull down CLK enable pin to ground (I suppose you can use conductive ink)

I was tempted to try and add a 2.5Gb ethernet adapter there as well

We did it (Realtek 2.5Gb) and it works better than embodied RTL controller

if the hardware requires special software

Nothing special, this is general PCI bus so you need only driver for your card (I suppose that you have Realtek or Intel)

Did you punch another hole out the back or side for the ethernet cable?

Right now it's open but we want to print a new case. So it is not a big issue for us.


PS: I'm thinking about bifurcation of NVMe but I need an adapter. It can be ordered from GLS PCB but the cost of one will be about $2-3 in case of order about 10 pieces and $20 in case of only one

wicadmin commented 2 days ago

@MrChromebox - is there a built-in firmware way of doing this now or do I still need to bridge that pin to ground? I'm on Kuldax and facing the same issue (card not detected) with an intel i226-v A+E m.2 2.5Gbps NIC card.

namezys commented 2 days ago

@wicadmin there is no way to modify this area of firmware from software, the only one way is to flash directly with programmer. And no general way to modify it - each case is unique and can depend on small hardware changes like revision.

Just as bridge between two pins with conduction ink and it will be enough.

wicadmin commented 2 days ago

@namezys - thanks. Do you know if just masking off the CLK REQ pin with plastic tape would work? I had done this with an HBA storage card a while back.

https://yannickdekoeijer.blogspot.com/2012/04/modding-dell-perc-6-sas-raidcontroller.html

namezys commented 2 days ago

@wicadmin the slot is too tight… so usually impossible

namezys commented 2 days ago

Oops. You can’t masked off this pin, it must be pull down to ground.

wicadmin commented 1 day ago

Oops. You can’t masked off this pin, it must be pull down to ground.

Yep, masked it and still it didn't show up :-)

OK, trying with what conductive paint I have. I found some cold galvanized paint (zinc only). See if it conducts when dried, no luck while still wet.

wicadmin commented 1 day ago

well, apparently the pin next to what is supposed to be the CLK REQ is not a ground pin (Only the tall square top pins are ground)

IMG_20240721_152426537

Per this, it appears the pins for A+E are different from B or M. https://w.electrodragon.com/w/M.2_Pins

image

wicadmin commented 1 day ago

Well, I overlayed the card that came with the chromebox (e-key) but most of the PCI pins not lining up. I assume this may be part of the issue.

IMG_20240721_162249645_HDR

namezys commented 1 day ago

@wicadmin I'm sure that this misplacement should not be an issue (95%, of course stupidness of engineer is possible).

However, It looks like SATA card. Missing pins are 2 data stream (up and down) and clock. I'm always mixed up different slots but I feel than 4 couples of missing pins are:

Also pairs of data and clock is separated by one ground.

Can you send pics of all cards, maybe I will be more precise because we are working on NSA for home and I read a lot.

wicadmin commented 19 hours ago

@namezys - these are the photos. The orginal wifi/bluetoothj combo that came with the chromebox and the A+E 2.5Gbps nic.

IMG_20240722_190908980~2

Screenshot from 2024-07-22 19-12-11