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

configs: apple: Add custom bootcmd to boot from preferred ESP #3

Closed

Conversation

jannau
Copy link
Member

@jannau jannau commented Mar 16, 2022

AsahiLinux uses a distinct EFI system partition per OS installation 1).
To boot the intended system u-boot has to prefer the intended partition
for booting. The previous stage bootloader specifies in UUID of the
partition in the device tree as "/chosen/asahi,efi-system-partition".
'apple_bootcmd' reads the UUID from the device tree and uses modified
distro boot scripts to only boot from a partition with a matching UUID.
If it fails it tries to boot from the first USB device.

1: https://github.com/AsahiLinux/docs/wiki/Open-OS-Ecosystem-on-Apple-Silicon-Macs

Signed-off-by: Janne Grunau j@jannau.net

kettenis and others added 9 commits March 3, 2022 19:07
When the device tree indicates support for role switching through
the "usb-role-switch" property, take the "role-switch-default-mode"
property into account when deciding which role to put the
controller into.

This makes USB devices work on Apple M1 systems where the device
tree may include a "dr_mode" property that is set to "otg", but
where we need to put the controller into "host" mode to see
devices connected to the type-C ports.

Signed-off-by: Mark Kettenis <kettenis@openbsd.org>
This synchronizes the device trees with those that are in the
process of being upstreamed into Linux. These now match the
current state of the device trees on the asahi branch of the
Asahi Linux github repository.

Signed-off-by: Mark Kettenis <kettenis@openbsd.org>
Device trees for the 14" and 16" MacBook Pro models. Taken from
the asahi branch of the Asahi Linux github reporsitory.

Signed-off-by: Mark Kettenis <kettenis@openbsd.org>
Unless you have a spare Apple Silicon machine, getting access to
the serial port on Apple Silicon machines requires special
hardware. Given that most machines come with a built-in screen
the framebuffer is likely to be the most convenient output device
for most users. While U-Boot will output to both serial and
framebuffer, OSes might not. Therefore set stdout-path to point
at /chosen/framebuffer when a keyboard is connected to the machine.

This behaviour can be overridden by setting the "stdout" variable
in the U-Boot environment. I addition to that keep the serial
console as the default when running under the m1n1 hypervisor.
The m1n1 hypervisor virtualizes the serial port such that it
can be easily accessed from any other machine with a USB port.

Signed-off-by: Mark Kettenis <kettenis@openbsd.org>
Reviewed-by: Janne Grunau <j@jannau.net>
Tested-by: Janne Grunau <j@jannau.net>
Enable CONFIG_NO_FB_CLEAR to preserve the Asahi logo. Since that
logo is drawn on a black background also enable
CONFIG_SYS_WHITE_ON_BLACK such that text printed by U-Boot is still
visible.

Signed-off-by: Mark Kettenis <kettenis@openbsd.org>
Fixes the display of the u-boot logo on Apple silicon devices.

Signed-off-by: Janne Grunau <j@jannau.net>
Reviewed-by: Simon Glass <sjg@chromium.org>
To be dropped when PCIe USB support is back such that a keyboard
connected to the type-A ports on the Mac mini can be detected.

Signed-off-by: Mark Kettenis <kettenis@openbsd.org>
The brute-force controller disable method can end up racing controller
initilization and causing a crash when we shut down Apple ANS2 NVMe
controllers. Do a proper controlled shutdown, which does block until
things are quiesced properly.

Signed-off-by: Hector Martin <marcan@marcan.st>
AsahiLinux uses a distinct EFI system partition per OS installation 1).
To boot the intended system u-boot has to prefer the intended partition
for booting. The previous stage bootloader specifies in UUID of the
partition in the device tree as "/chosen/asahi,efi-system-partition".
'apple_bootcmd' reads the UUID from the device tree and uses modified
distro boot scripts to only boot from a partition with a matching UUID.
If it fails it tries to boot from the first USB device.

1: https://github.com/AsahiLinux/docs/wiki/Open-OS-Ecosystem-on-Apple-Silicon-Macs

Closes AsahiLinux#2.

Signed-off-by: Janne Grunau <j@jannau.net>
kettenis pushed a commit that referenced this pull request Sep 6, 2022
There are three different kinds of EEPROM possibly present on boards.
  1. 1byte address. For those we should avoid 2byte address in order
     not to rewrite the data. Second byte of the address can potentially
     be interpreted as the data to write.
  2. 2byte address with defined behaviour. When we try to use 1byte
     address they just return "FF FF FF FF ... FF"
  3. 2byte address with undefined behaviour (for instance, 24LC32AI).
     When we try to use 1byte address, then their internal read
     pointer is changed to some value. Subsequential reads may be
     broken.

To gracefully handle both case #1 and case #3 we read all required
data from EEPROM at once (about 80 bytes). So either all the data is
valid or we fallback to 2byte address.

Cc: Nishanth Menon <nm@ti.com>
Fixes: a58147c ("board: ti: common: board_detect: Do 1byte address checks first.")
Reference: https://lore.kernel.org/all/CAJs94Ebdd4foOjhGFu9Bop0v=B1US9neDLxfhgcY23ukgLzFOQ@mail.gmail.com/
Signed-off-by: Matwey V. Kornilov <matwey.kornilov@gmail.com>
Acked-by: Nishanth Menon <nm@ti.com>
@jannau jannau closed this Dec 2, 2023
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.

None yet

3 participants