Exploring the Embedded Controller

Hey Dustin, I haven’t been able to find any license in the fork on your GitLab, I assume it’s still BSD 3-clause? Do you think you could manage cutting releases out of it? Just version tags is enough, but that way it’s more approachable for downstream inclusion: I’ve just made a Guix package for myself but it could probably end up upstream easily.

Thanks for the tool by the way, easy to build and use!

Last time I looked during 6.9-rc4, it had just landed in linux-next so it will have to wait until the 6.10 merge window iiuc.

Today I got this when charging, is there anything wrong with this fairly new battery?

$ sudo ectool battery
Battery 0 info:
  OEM name:               NVT
  Model number:           FRANGWAT01
  Chemistry   :           LION
  Serial number:          0035
  Design capacity:        3915 mAh
  Last full charge:       3971 mAh
  Design output voltage   15480 mV
  Cycle count             45
  Present voltage         16712 mV
  Present current         742 mA
  Remaining capacity      2796 mAh
  Desired voltage         17800 mV
  Desired current         783 mA
  Flags                   0x0b AC_PRESENT BATT_PRESENT CHARGING

The Desired current is abnormally low. Fortunately this only occurred temporarily

Just wanted to quickly report on my quest to make ectool available on Windows 11 with Secure Boot enabled.

After lots of struggles with various drivers and libraries, I managed to make WinRing0 work using the C# implementation of Libre Hardware Monitor (a fork of Open Hardware Monitor).
The driver is signed and seems to allow reading and writing at the necessary memory addresses.

As a proof of concept, I managed to read the ‘E’ and ‘C’ bytes on addresses 0xE00+0x20 and 0xE00+0x21, where 0xE00 is the address to the memory-mapped EC data in Framework 13 AMD. I also managed to read the four available temperature sensors at addresses 0xE00-0xE03, I just had to dig around a bit to figure out that when you read t, the temperature is actually t+200 Kelvin (200 is a constant offset in EC_TEMP_SENSOR_OFFSET).

Everything works with Secure Boot enabled, it just needs admin permissions.

My long-term goal would be to port ectool to support WinRing0 and hence be able to execute it with Secure Boot. My idea would be to create comm-winring0.cc by rewriting comm-lpc.cc using the ReadIoPort and WriteIoPort functions of the driver. This would then get compiled on Windows alongside comm-win32.cc, which would then become optional for people with test signing who have the original driver installed.

@DHowett Does this sound reasonable to you? This is the first time I am touching communication with EC. The only resources I have are the original source codes and this thread.

There’s something gravely wrong with the battery mamagement system (BMS). After reading @ByteBender 's BIOS power measurement I attempted to re-create the “cold boot” on my FW13. Unfortunately the slow charging is replicateable, as shown.

$ sudo ectool battery
Battery 0 info:
  OEM name:               NVT
  Model number:           FRANGWAT01
  Chemistry   :           LION
  Serial number:          0035
  Design capacity:        3915 mAh
  Last full charge:       3983 mAh
  Design output voltage   15480 mV
  Cycle count             46
  Present voltage         15141 mV
  Present current         737 mA
  Remaining capacity      575 mAh
  Desired voltage         17800 mV
  Desired current         783 mA
  Flags                   0x0b AC_PRESENT BATT_PRESENT CHARGING

This occurs in both suspend and shutdown. If you left the computer “cold” for a few hours. And this time, unlike previous one, the current stayed low for about 20 minutes.

Before anyone saying “charging cold is bad for battery life and the BMS reduced current to protect the battery”, I would like to say that this is not even the case. The weather is 15C and the room temperature is 20C. This is anything but cold. The safe operating temps are -20C to 60C discharging and 0C to 40C charging. Both my smartphone charge at half speed at 7C and full speed above 10C(battery temp, when the weather is -10C)

Also I know that at lower temps the battery performance is reduced(and higher temperature wears down the battery faster), this is also not the case. As shown the “Present voltage” is far from even 4.0V/cell. This is NOT “cold temperature increase internal resistance so the battery reaches constant voltage charging earlier”.

OK, but that battery charging topic belongs in a different thread.

It looks like that it landed again (second time) in linux-next.

https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?h=next-20240506&id=c8f460d991df93d87de01a96b783cad5a2da9616

Besides that, I notice that a seperate Framework EC driver is in progress “implement battery charge thresholds”.

https://lkml.org/lkml/2024/5/6/148

or

https://lore.kernel.org/all/613369f9-42c5-4a59-b83f-45bd1773ffe4@t-8ch.de/T/#t

Can someone test this command on a 13th gen intel cpu?

sudo ectool led power red

I’m trying to update the nixos package to the 2024-04-25 commit, but it was reported that the 2023-12-15 commit broke it. I don’t have a 13th gen system to test it.

The original issue was reported on github.

sudo nix run nixpkgs#fw-ectool led power red            
Missing Chromium EC memory map.
Cannot find I2C adapter
Unable to establish host communication
Couldn't find EC

Specifying the other interfaces didn’t help either.

See also https://www.phoronix.com/news/Framework-Laptop-EC-Driver

Absolutely. Sorry about the delay in replying! I’ll get that done this weekend.

Nah, nothing wrong with it at all. Sometimes having too much data can make us worry! Pierce is correct though, you should start a new thread if you’re worried.

Wow! Absolutely, that would be so cool. You may actually prefer to adapt comm-lpc rather than comm-win32, as it implements the LPC protocol over native port I/O. It’s not built into the Windows version, but you could bang the two together until you have something.

It should (???) also support the MEC EC in the Framework Laptop 11th gen. If it doesn’t, I’ve dropped a patch somewhere along the way.

Unfortunately, the modern devices don’t expose support for red on the power LED. That having been said, you still shouldn’t get that error. Can you check whether the module cros_ec_lpcs is loaded? If not, no EC communication will work. :slight_smile:

Thomas has been helping out reviewing my patch series’ as well. His approach is a bit different from mine: where I want to put together a framework-specific platform driver, he wants to expose things that every ChromeOS EC laptop can do and then add a framework-specific driver for the things that not all of the aforementioned laptops can. I’m really looking forward to his work landing! However, it may be best to discuss it in a different thread.

2 Likes

I made a new thread, and it’s clearly something wrong with the battery, the charging speed is reduced 80% when the room temperature is 20 degrees , meaning it could take 4.5 to 5.5 hours to fully charge it. The very clear “wrong” is the “Desired Current” is very, very low, only 783mA

Desired current         783 mA

We need an official explanation of this

I am trying to get ectool working to more thoroughly test an issue I am having with the fan sound of my GPU module in my Framework 16.

I am running into this issue:

$ ./ectool version
Cannot open lockfile /run/lock/cros_ec_lockCould not acquire GEC lock.
$ sudo ./ectool version
Place your right index finger on the fingerprint reader
Missing Chromium EC memory map.
Cannot find I2C adapter
Unable to establish host communication
Couldn't find EC

I disabled secure boot in the settings and erased my secure boot but I am still running into this error.

This is using the ectool built from the framework EmbeddedController github. I am running on fedora 40.

Any tips to get ectool working?

EDIT: I downloaded your build of ectool from your gitlab repo and got things working!

Just get the prebuilt Linux x64 version from the Artifacts section of the GitLab repo:
https://gitlab.howett.net/DHowett/ectool/-/jobs/899/artifacts/download?file_type=archive

P.S. I have latest Ubuntu 24.04 and the binary works there.

$ sudo artifacts/_build/src/ectool pwmgetfanrpm all
Fan 0 RPM: 2184
$ sudo artifacts/_build/src/ectool temps all
--sensor name -------- temperature -------- ratio (fan_off and fan_max) --
local_f75303@4d       315 K (= 42 C)           6% (313 K and 343 K)
cpu_f75303@4d         312 K (= 39 C)           0% (319 K and 327 K)
ddr_f75303@4d         315 K (= 42 C)        N/A (fan_off=401 K, fan_max=401 K)
cpu@4c                313 K (= 40 C)           0% (376 K and 378 K)

Yup, I edited my post after I figured that out last night.

Hey @DHowett, I was very busy doing other things, but I found some free time this Saturday and I finally managed to rewrite comm-lpc to use WinRing0 and now ectool finally works with Secure Boot enabled:

Implementation details:

Because the internet is full of various versions of WinRing0 of questionable origin and safety, I decided to take a bit of a different approach. Specifically, I rely on a trusted software called Libre Hardware Monitor, which is an open-source C# app that runs an embedded WinRing0 in the background. What I do is that I hijack that and I connect to their WinRing0 while the Libre Hardware Monitor is running. So all that the user needs to do is to download Libre Hardware Monitor, execute it, and leave it running in the background. Then you can use ectool.exe --interface=winring0 <command> and it will use relay the communication.

I will try to publish a fork of your ectool later, so that you can have a look at the code and possibly merge it and republish it yourself.

9 Likes

FYI, I am waiting for @DHowett to coordinate on how to publish the changes. I noticed that his GitLab repository does not mention a license and I do not seem to have a permission to make a merge request there, so I do not want to publish my changes before that is sorted out. :slight_smile:

1 Like

This is great news for Windows users, looking forward to seeing a package come out of this. Thanks again!

2 Likes

Hey @TomsonTom! Sorry for the delay. I pushed a mirror to GitHub and brought in the BSD 3-clause license from the upstream repo.

Feel free to send in a pull request, and we can discuss it over there! :slightly_smiling_face:

2 Likes

Thank you @DHowett ! Great work on that repo, happy to see it mirrored on GitHub!

Here is the pull request for WinRing0 with Secure Boot:

2 Likes

Going to give this a go tomorrow! Really appreciate the work for the windows crowd!

1 Like

I don’t know if this is the right place for this. I was having issues with keylightd so I looked for something about the Error: No such file or directory (os error 2) it was giving me. I came here the find out what was wrong but everyone who got the

Missing Chromium EC memory map.
Cannot find I2C adapter
Unable to establish host communication
Couldn't find EC

was using AMD but I am on 11th Gen Intel. Does anyone have any ideas on why this is happening.

System:
CPU: 11th Gen Intel i7-1165G7
BIOS: 3.19
OS: EndeavourOS