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

Firmware: Add support for retrieving firmware from macOS Recovery Image #540

Merged
merged 25 commits into from
Jun 2, 2024

Conversation

AdityaGarg8
Copy link
Member

No description provided.

@AdityaGarg8
Copy link
Member Author

@soopyc , you may want to consider this PR when updating nixos guide

@AdityaGarg8
Copy link
Member Author

AdityaGarg8 commented May 27, 2024

@soopyc , can you test this on nixos?

@AdityaGarg8
Copy link
Member Author

@sharpenedblade , can you test on fedora?

@AdityaGarg8
Copy link
Member Author

@NoaHimesaka1873 @Redecorating , can you check the code for Arch. I couldn't find a better way to get dmg2img from aur.

@NoaHimesaka1873
Copy link
Member

That seems like the most sane way to install AUR package without helper.

@AdityaGarg8
Copy link
Member Author

That seems like the most sane way to install AUR package without helper.

Nice!

Sometimes python starts before mount completes
@AdityaGarg8
Copy link
Member Author

The macOS recovery image method occasionally fails with python showing error with wifi. I've noticed that symlinks are being affected in such cases, most probably due to bad support for hfsplus on Linux. The script shows a message to try again with some other macOS version in such cases.

@AdityaGarg8
Copy link
Member Author

In case someone tests and it fails at 1st attempt, but succeeds on automatic retry, do share the no of retries.

@soopyc
Copy link
Contributor

soopyc commented May 28, 2024

@soopyc , can you test this on nixos?

The script does not work OOTB (expected), but fortunately it's possible to temporarily make packages available to use with one of the following commands.

  • nix shell nixpkgs#dmg2img -c bash ./firmware.sh
  • nix-shell -p dmg2img --run bash ./firmware.sh

While possible, the notion of installing packages with commands is discouraged on NixOS so I personally think the script should halt when it detects both the distro and missing packages.

Nevertheless, with this method the same thing about manually creating /lib/firmware/brcm applies. Apart from these 2 issues, the script works on both the installation environment and installed NixOS. (N.B.: The script took 5 automatic attempts and a re-run to succeed on the Live environment.)

Instructions could be added to the package manager checks, and one can detect NixOS by checking if /etc/NIXOS exists.

Minor nitpick - when creating temporary directories, prefixing them with something like firmware-{work,mount} makes things easier to manage while testing.

@AdityaGarg8
Copy link
Member Author

@soopyc , can you test this on nixos?

The script does not work OOTB (expected), but fortunately it's possible to temporarily make packages available to use with one of the following commands.

  • nix shell nixpkgs#dmg2img -c bash ./firmware.sh
  • nix-shell -p dmg2img --run bash ./firmware.sh

While possible, the notion of installing packages with commands is discouraged on NixOS so I personally think the script should halt when it detects both the distro and missing packages.

Nevertheless, with this method the same thing about manually creating /lib/firmware/brcm applies. Apart from these 2 issues, the script works on both the installation environment and installed NixOS. (N.B.: The script took 5 automatic attempts and a re-run to succeed on the Live environment.)

I'll have to fix this thing first. Thanks for testing!

Instructions could be added to the package manager checks, and one can detect NixOS by checking if /etc/NIXOS exists.

I'm not very sure what to put here.

Minor nitpick - when creating temporary directories, prefixing them with something like firmware-{work,mount} makes things easier to manage while testing.

Previously we were making python bit to directly rename firmware from the mounted image. This was causing failures for unknown reasons. Lets try copying the firmware to the work directory and make the script rename firmware from there
@AdityaGarg8 AdityaGarg8 force-pushed the firmware branch 4 times, most recently from 331e672 to cad5b1b Compare May 31, 2024 11:01
@AdityaGarg8
Copy link
Member Author

I believe the bug has finally been fixed. Apparently if a temp directory had a "C" in its name, the lstrip command broke the code by removing "C" from the folder names in the wifi folder of source firmware. My previous assumption of broken symlinks was wrong.

Still I need tests and feedbacks from more people. @soopyc , it would be nice if you could test, since you were able to reproduce the bug before.

@soopyc
Copy link
Contributor

soopyc commented May 31, 2024

Thanks for figuring out the bug! I wouldn't have been able to figure that out myself without a few more days :P

Anyways, I've tried running the script normally and forcing a C into the tmpdir. Both runs correctly, so unless I've messed up the position of the C, this looks good from my side.

@AdityaGarg8
Copy link
Member Author

Thanks for figuring out the bug! I wouldn't have been able to figure that out myself without a few more days :P

Anyways, I've tried running the script normally and forcing a C into the tmpdir. Both runs correctly, so unless I've messed up the position of the C, this looks good from my side.

Can you try running the way you did before, maybe there could be some other hidden bug.

@AdityaGarg8
Copy link
Member Author

@soopyc , can you test this now. Also share how many retries it took.

I will agree that this issue is very annoying to debug as the errors happen inconsistently. I've tried the [latest revision of the] script on various occasions, and the success rate is 80%, where the script works first try without any re-attempts. The other 20% fails completely and no automatic retries work, just like before. A re-run of the script after a while usually works. I'm starting to wonder if this is an image problem.

This way

@AdityaGarg8
Copy link
Member Author

Thanks for figuring out the bug! I wouldn't have been able to figure that out myself without a few more days :P
Anyways, I've tried running the script normally and forcing a C into the tmpdir. Both runs correctly, so unless I've messed up the position of the C, this looks good from my side.

Can you try running the way you did before, maybe there could be some other hidden bug.

My bad, I just read your tried to run normally.

@AdityaGarg8
Copy link
Member Author

Thanks for testing @soopyc !

@AdityaGarg8
Copy link
Member Author

Is anything nixos specific required over here?

@soopyc
Copy link
Contributor

soopyc commented May 31, 2024

The only other NixOS specific thing is to check for /lib/firmware/brcm and not just /lib/firmware with this method, as tar errors and quits if that doesn't exist.

@AdityaGarg8
Copy link
Member Author

The only other NixOS specific thing is to check for /lib/firmware/brcm and not just /lib/firmware with this method, as tar errors and quits if that doesn't exist.

You probably can then update your other pr to add instructions to run this way then.

@AdityaGarg8
Copy link
Member Author

Also, 8f1e8bc

@AdityaGarg8
Copy link
Member Author

Updated the wiki. Preview on https://adityagarg8.github.io/wiki/guides/wifi-bluetooth/

A review is required.

Copy link
Contributor

@sharpenedblade sharpenedblade left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just mention that you need a wired internet connection for method 4 This was already there, I didnt notice

@AdityaGarg8
Copy link
Member Author

Just mention that you need a wired internet connection for method 4

https://github.com/t2linux/wiki/pull/540/files#diff-b12df5aa5ceba67e40ea53c7f633b0d49c17a5ee909608930f740b3cbd77fd23R188

Copy link
Contributor

@soopyc soopyc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. The part about NixOS could come in a later PR.

@AdityaGarg8 AdityaGarg8 merged commit 3f6c242 into master Jun 2, 2024
1 check passed
@AdityaGarg8 AdityaGarg8 deleted the firmware branch June 2, 2024 04:41
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

Successfully merging this pull request may close these issues.

4 participants