Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swap Fn and Ctrl key #1087

Closed
copyvar opened this issue Jan 2, 2022 · 9 comments
Closed

Swap Fn and Ctrl key #1087

copyvar opened this issue Jan 2, 2022 · 9 comments

Comments

@copyvar
Copy link

copyvar commented Jan 2, 2022

I successfully built heads x230-hotp-maximized for my X230. I installed classic keyboard (see https://www.thinkwiki.org/wiki/Install_Classic_Keyboard_on_xx30_Series_ThinkPads). I want to swap the Fn and Ctrl key. How can I do this?

Does heads support all types of authentic batteries or do I have to allow the use of "non official" batteries via thinkpad-ec beforehand? If so, is there an easy way to apply later on (after Heads building and external flashing)?

I am confused about this, because thinkpad-ec is not responsible for allowing the free use of any wifi card (Heads is). At least, that is my understanding.

@tlaurion
Copy link
Collaborator

tlaurion commented Jan 3, 2022

I successfully built heads x230-hotp-maximized for my X230. I installed classic keyboard (see https://www.thinkwiki.org/wiki/Install_Classic_Keyboard_on_xx30_Series_ThinkPads). I want to swap the Fn and Ctrl key. How can I do this?

Through nvramtool from your OS (debian deploys it) or by building it yourself inside of the coreboot tree.
This is standard cmos settings, and can be configured at build time by changing cmos.default or through nvramtool.

You can do this from EC, or through coreboot.

For your two other questions, those should be separate issues, linked to documentation, not code.

Better suited for heads-wiki. Still:

  • Battery whitelist is from EC, not firmware.
  • Wifi withelisting is from firmware, not EC. When using coreboot, you can use whatever wifi chipset you want. That is, flash first, then replace wifi.

@copyvar
Copy link
Author

copyvar commented Jan 8, 2022

@tlaurion Thanks for your reply. Could you please write a step by step instruction on what to do (which files to modify where and when) for building process? As I understand I can rebuild heads with specific options and flash it again via external programmer?

@tlaurion
Copy link
Collaborator

tlaurion commented Jan 8, 2022

@copyvar
Instructions are in board configs for normal instructions builds.

Using unapproved batteries is unsupported by Heads. thinkpad-ec project covers it.

For your use case of swapping FN and Ctrl keys, you can build normally, and then use nvramtool from OS, or modify built ROM with CMOS overrides prior of building the ROM.
Similar issue here for t430, which patched coreboot cmos.default for that model prior of building coreboot #711

So as you can see there, you could patch build/coreboot-4.13/src/mainboard/lenovo/x230/cmos.default

That means doing a first make BOARD=x230-hotp-maximized so that everything gets extracted and then modifying cmos.default according to your specific needs.

But recommended way is to modify CMOS config through nvramtool if coreboot is not configured to load only the defaults CMOS at each boot.

For your additional question here on how to build ROMs, please open additional issues.

This one is for swap of FN and Ctrl key. Let's keep issues separated otherwise nobody but you will find answer to their questions.

@copyvar
Copy link
Author

copyvar commented Jan 8, 2022

@tlaurion Thanks again. And thank you a lot for the hint using nvramtool. Could you please add a step by step instruction on how to do that? That would be great, if I would not have to flash it again, but I do not have the skills to understand how to apply nvramtool properly. I tried to understand, but I lack a lot of background knowledge I guess.

@copyvar
Copy link
Author

copyvar commented Jan 8, 2022

Btw: how can I find out, which EC options I flashed (to the BIOS/to the mainboard?)? You see I am still confused a bit about how everything works together.

@tlaurion
Copy link
Collaborator

tlaurion commented Jan 8, 2022

@copyvar : I do not use it. Doc should be written by community members having filled their own needs and writeup for documentation (heads-wiki). Unfortunately, I do not have time to answer all use cases and customizations and can only link to previous known issues and traces that touched subjects in the past. Again, please open other issues. This should be in heads-wiki (doc related) since not code/heads functionality related.

You could hijack t430 issue and ask users there to complete your understanding, or referred ticket to skulls to do the same, from above provided links.

As for nvramtool:
Doc https://www.coreboot.org/Nvramtool

Option to modify:
fn_ctrl_swap=Enable

@tlaurion
Copy link
Collaborator

tlaurion commented Jan 8, 2022

btw: how can I find out, which EC options I flashed (to the BIOS/to the mainboard?)? You see I am still confused a bit about how everything works together.

@copyvar : I do not understand the question.
If you used thinkpad-ec project, options chosen there when modifying original firmware should be known?

Flashing EC (Embedded Controller. Controls power, fan and other laptop specifics, keyboard etc) currently can only happen only through Lenovo BIOS upgrade over original firmware. If you are under Heads, you would have to flash back original Lenovo firmware backups, use thinkpad-ec tool to modify EC as needed, flash, and then flash back Heads.

That would be needed for removing battery whitelist.
EC flashing is not needed for FN CTRL keyboard key swap.

@tlaurion
Copy link
Collaborator

@copyvar (replying here for your #711 (comment) comment)

nano coreboot/src/mainboard/lenovo/x230/cmos.default

will modify the cmos.default to be included in a local coreboot build... Which in what you are doing, have nothing to do with Heads locally used coreboot version, which is found under heads/build/coreboot-VERSION/src/mainboard/lenovo/x230/cmos.default after having build the board at least once with make BOARD=x230-VARIANT

git diff cmos.default > ~/heads/patches/coreboot-4.14/0061-cmos-settings.patch

Not sure what is attempted there, since there is no git tracking of change there. As a result, i'm pretty sure

git diff cmos.default > ~/heads/patches/coreboot-4.14/0061-cmos-settings.patch

Results in an invalid patch under 0061-cmos-settings.patch (path for patched file is necessary invalid)

From what I understand, you want to local build a rom containing cmos.default with the swap of FN and CTRL keys, by modifying x230 board. You should then do:

  • make BOARD=x230-maximized (or x230-hotp-maximized)
  • cp heads/build/coreboot-4.13/src/mainboard/lenovo/x230/cmos.default heads/build/coreboot-4.13/src/mainboard/lenovo/x230/cmos.default.orig
  • modify heads/build/coreboot-4.13/src/mainboard/lenovo/x230/cmos.default
  • make BOARD=x230-maximized (or x230-hotp-maximized)

By doing so, you are changing the defaults values that coreboot reverts to in case CMOS memory is wiped (CMOS battery being dead for example), and its default. The better way is through nvramtool as said #1087 (comment) and #711 (comment)

Unfortunately, there is no way to modify heads/build/coreboot-4.13/src/mainboard/lenovo/x230/cmos.default only for one heads' board. (we could not create a x230-maximized-fn_ctrl_swap board, since that file is shared across all x230 board builds).
This is why, unless desired by all x230 owners, this change needs to be applied by local builders for advanced users.

If you want to use Heads upstream without modification, you should :

  • modify EC firmware by reflashing original lenovo firmware and following the thinkpad-ec project steps to swap keys.
  • modify CMOS values at runtime, taken into consideration by coreboot and next flashes, through nvramtool as said previously with nvramtool and Swap fn and Ctrl key (t430s) #711 (comment). That is, modifying not the defaults, but what is kept alive under CMOS memory until the CMOS battery dies, hwere your swap would revert to cmos.default values.

Short:

  1. Manually modifying cmos.default value will be valid only for local builds containing the change under heads' coreboot build directory, where board configuration file specifies the coreboot version to be used. You could create a local patch under patches/coreboot-version/NUMBER-keyboard-swap.patch but that patch could not be upstreamed nor applied to all x230 boards.
  2. You could go the thinkpad-ec way, so that your change is applied forever for that machine.
  3. You could go the nvramtool way.

Why are you taking 1 as being the best solution for you?

Is that correct? I am confused about "dirty".
Heads applies the dirty suffix for filenames and git tag of Heads included /etc/config to let the user know that there is something under its Heads tree that is being tracked but non committed. In your case, that dirty tag is related to the patch file that you created that is not commited to a branch.

Actually, Heads is right: your build environment is dirty. You mixed two ideas/goals here. Wanting to build nvramtool and patching Heads' coreboot' cmos.default file to contain proper defaults containing your key swap, valid only for this local build. Patches are applied right after decompression of an downloaded archive per Heads build system into its relative module decompressed directory.

So here on future builds, your modified cmos.default will be taken into consideration in building a rom.
Your created patch file won't be applied unless the build/module relative directory (coreboot-VERSION here) is deleted.

I would still recommend going 2 or 3 above, not 1.

@tlaurion
Copy link
Collaborator

tlaurion commented Mar 28, 2022

@copyvar ? This is not really related to Heads. Can we close?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants