How to compile the FW16 EC from open source code

New features already implemented this github repo:

  1. 3 level thresholds for battery charge / discharge control. Prevents battery flipping.
  2. multi profile 3 level battery control thresholds
  3. charge transition counter, so one can detect “battery flipping”
  4. fine level monitoring/data capture of voltage/current using the various sensors available to the EC. Useful for discovering peak watts power draw by gpu/cpu and measuring idle watts more accurately.
  5. ectool command to read the battery temp using the smart battery internal temp sensor. The EC has always used this, but never before made it accessible to user space.
  6. Made i2c writes more reliable. Improves battery monitoring, power adapter detection, and EC → APU SMU reliability.

Future features i wish to add to the EC:

  1. the mainboard can potentially supply 15W to more than one usb devices. One on the left, one on the right. The use case is when plugging in two NVME enclosures to copy data between them.
    The FW16 has a 81Wh battery. Powering 2 x15W of usb devices is going to drain that pretty quickly. So, obviously only reasonable to do when a power adapter is connected.
  2. the ports on the FW16 are dual mode power, so they can source and sink. When connecting some external power bricks that can source and sink power.
    When both sides are dual mode like this, confusion and problems happen. Make an ectool command so one can force the FW16 side to be the source or the sink, thus removing the confusion.
  3. add an ectool command to adjust the 3A vs 1.5A Rp resistor on each usb c port. The FW16 defaults to the 1.5A Rp, but the 3A Rp improves compatibility with some problem devices out there. I.e. some iphones. E.g. set the slot 1 to be 3A Rp, and then just use that slot with the problem usb devices.
    Common devices this helps with are the ones that cycle through connect/disconnect about once a second.
  4. Game mode.
    Game performance suffers when charging the battery. During the game the battery will discharge slightly during peak loads. Game mode would limit the charge current to a low trickle, thus ensuring max power to the game for long periods. Otherwise, the battery charge will happilly use 80W, that causes game stutter.
    Note: i don’t actually know if this will actually reduce stutter, it might instead need different charger chips.
  5. Improver power transitions when plugging in and removing power adapter.
    Currently, when transitioning from SRP 20V mode to ERP 36V mode, it goes via a 2.5W step. I.e. switches power off while switching volts. This shows user detectable slowdown when plugging and unplugging the power adapter. There are also use cases when this causes failure to boot or reboot.
    Experiment with other transitions not currently implemented. E.g. from SRP 20V to ERP 20V, and then gradually step up the voltage over time to 36V. Thus not needing the 2.5W step.
  6. (See below)
  7. currently on FW16 AMD 7840HS, BIOS 4.0.4, “reboot rw” and “sysjump rw” do not work reliably. A few attempts from an EC CCD are needed before it works. Previously “reboot rw” worked from the EFI shell on BIOS 3.0.5. Investigate why this fails.
  8. (See below)

ROOT CAUSE analysis complete. UNABLE to fix in EC source code:
6) if one uses the 36V FW power adapter. When it is supplying 36V, the linux kernel only registers it as 5V and shows only 5V in lmsensors/sensors output. Find where the 36V information is getting lost, and get lmsensors to report it. ← Root Cause: Bug in CYPD USB PD firmware. See (8)
8) Try to fix “ucsi_acpi USBC000:00: unknown error 256”. This is a bug associated with enumerating PDOs from any device that has more than 4 PDOs.
For example, the FW16 Power adapter has 7 PDOs, but Linux only sees 4 PDOs and 1 corrupt/bogus PDO. ← Root Cause: Bug in CYPD USB PD firmware.

Note: (8) is a problem. The CYPD USB PD chip is buggy, and does not respond to the UCSI command: “0x0000 0007 0482 0010” I.e. Command 0x10:GET_PDOS with PDO offset 4.
It deals with this GET_PDOS command correctly: “0x0000 0007 0082 0010”
Test case, is using the FW16 180W power adapter, and doing UCSI GET_PDOS commands to it. It should return 7 PDOs, but only gets the first 4 PDOs correctly. (from the first GET PDOS command, then the second GET PDOS command should get the next 3 PDOs, but it does not.
So, not fixable with either Linux kernel or EC source code changes. Its a CYPD USB PD firmware bug.

Any other suggestions on future EC features ?

4 Likes