Skip to content

Initial support for the Lenovo Legion Y700 Gen4 (no ACPI, FDT platform for Linux) - #820

Closed
retro98boy wants to merge 10 commits into
Project-Aloha:mainfrom
retro98boy:lenovo-y700-gen4-initial-support-pr
Closed

retro98boy wants to merge 10 commits into
Project-Aloha:mainfrom
retro98boy:lenovo-y700-gen4-initial-support-pr

Conversation

@retro98boy

Copy link
Copy Markdown

This PR adds initial support for the Lenovo Legion Y700 Gen4 (lenovo-elden, SM8750).

Supported hardware includes:

  • Display output through the inherited framebuffer and UEFI GOP.
  • Power and volume buttons for firmware navigation.
  • UFS storage.
  • microSD cards.

Storage support is currently limited to UFS and SD cards. Both can provide EFI partitions and boot EFI applications, including GRUB.

The stock Lenovo ABL requires AVB metadata on the flashed Android boot image. Without a suitable AVB footer, the image may fail to boot from the boot partition and return to fastboot. This PR adds optional AVB footer generation to the shared packaging script and enables it for this device. Packaging for devices that do not request AVB metadata remains unchanged.

The platform also marks the active Android boot slot successful after reaching BDS, preventing ABL from exhausting its retry counter during normal UEFI use.

Tested on physical hardware:

  • Booting Armbian through Aloha → GRUB → Linux with a DTB.
  • EFI boot from both UFS and SD cards.
VID20261107155849-pr

Provide the SM8750 library bindings, GIC/timer settings and PrePi-to-DXE
HOB interfaces required by Qualcomm firmware services. Supply configuration,
memory and fixed-library lookup interfaces without starting the stock scheduler.
Use an empty ACPI update implementation for device-tree boot.

Declare the Pakala package for the platform and its board components.
Extract the EFI payloads from the Lenovo Y700 Gen4 stock firmware with
UEFIReader. Keep the twelve drivers required for the DAL/environment,
clock, power, SPMI and shared-memory services, together with their original
DEPEX sections where used by INF imports. Keep PE payloads unchanged.

From the extracted stock firmware directory, run:

  UEFIReader image/uefi.elf extracted

Retain the required modules from the extracted tree. Record hashes of the
imported files and maintained INF wrappers in binary-sha256.json. Drivers
packaged with FILE DRIVER sections receive their dispatch dependencies
in the platform configuration.

Declare the protocol GUIDs consumed from these board firmware services
in the Pakala package.
Define the board memory map, early DXE allocation arena, stack and firmware
reservations for the common Andromeda PrePi and MemoryInitPeiLib. Keep the
stack as a lookup alias so common PrePi emits its allocation HOB once.

Publish high RAM from the stock RAM-partition protocol in a board-local
RamPartitionDxe. Leave low DDR ownership with the platform map, preserve
existing GCD reservations, and establish write-back mappings before exposing
memory to DXE allocations. Walk banks directly without a fixed descriptor
array and propagate mapping or publication failures.

The reserved high-memory tail is based on the live device tree, /proc/iomem
and debugfs memblock maps exported by Linux booted through stock ABL on
Lenovo Y700 Gen4. Keep that reservation and the RAM handling board-local;
do not change the shared Andromeda RamPartitionDxe.

Provide the integer settings consumed by the retained vendor services and
record firmware provenance and memory addresses in memory-layout.json.
Expose the power and volume buttons through the standard simple-text input
protocols and common keypad device path. Implement debouncing, long presses
and key notifications without changing PMIC power-on or reset configuration.
Register SDCC2 as a non-discoverable coherent DMA controller for the common
SDHCI/SD stack. Configure its clocks and board power votes, read card detection
through TLMM and acknowledge controller power events.

Retain ADMA64 and inherited identity mappings, restrict UEFI operation to 3V,
four data lines and 25 MHz, and quiesce DMA at ExitBootServices. Gate MMIO after
failed setup and handle repeated callbacks and recreated PCI I/O interfaces.
Register the on-board UFS controller for the common UFS/SCSI stack, retaining
the inherited PHY, clock/power state and identity DMA mapping. Guard takeover,
enable DMA64 and quiesce request lists at ExitBootServices.

Save the negotiated HS profile before the standard HCE reset and restore it
after Link Startup, checking completion and readback. This avoids leaving
storage at PWM speed. Handle controller reconnect without reusing stale PCI
I/O readiness or skipping per-interface DMA setup.

Access link status and interrupts through the UFS host controller
protocol and propagate register-access errors.
Wire the board services and source SD/UFS stacks into the Pakala DSC/FDF.
Reuse common Andromeda PrePi, MemoryInitPeiLib and SimpleFbDxe, together
with the common PartitionDxe, GptLib, GraphicsConsoleDxe, FrameBufferBltLib
and sample platform theme. Add DEBUG/RELEASE Stuart entry points and
shared Android boot-image configuration.

Use the common RngDxe with CPU RNDR and Arm firmware TRNG backends. This
provides the standard algorithm-list size query required by DxeRngLib,
allowing its constructor to succeed in both DEBUG and RELEASE builds.

Use common DeviceBootManagerLib for default boot options, ReadyToBoot
callbacks, power/thermal/TPM checks and startup key policy. Select a board
MsPlatformDevicesLib in BdsDxe for console endpoints, preferred-GOP lookup
and storage connection. Use GpioButtons to bridge PMIC text input to
MS_BUTTON_SERVICES_PROTOCOL and retain the on-screen keyboard endpoint.

Keep board overrides in device configuration and apply board PCDs after
platform and UI defaults, without device-name conditions in shared code.
Unsupported USB/serial input and simulated buttons remain outside the FDF.
Mark the active boot slot successful after Aloha reaches BDS with
storage and consoles connected, independently of whether an EFI
operating system boots. Otherwise stock ABL can exhaust its retry
counter during otherwise usable UEFI boots, including visits to
firmware setup.

Handle this bootloader requirement in the board MsPlatformDevicesLib
connection callback. Validate the on-board UFS source, both GPT copies
and partition snapshots before changing only the successful bit. Flush
and read back backup metadata before primary metadata. Do not reset
retry counts or alter the other slot.
Pass optional avb_args to avbtool after packing the boot image and remove
the incomplete output if footer generation fails. Devices without these
arguments retain their existing image format.

Enable AVB metadata for Lenovo Y700 Gen4's 96 MiB boot partition using
the salt, rollback fields and Android properties from the stock boot image.

Install a pinned AOSP avbtool during host and Docker setup when the tool
is not already available. CI reuses the host setup path.
Add the Lenovo Y700 Gen4 target to the SM8750 device table.
@remtrik

remtrik commented Nov 7, 2026

Copy link
Copy Markdown
Member

Why the fuck exactly you have ufs and the other stuff as drivers with src?

@qaz6750

qaz6750 commented Nov 7, 2026

Copy link
Copy Markdown
Member

Why the fuck exactly you have ufs and the other stuff as drivers with src?

AI time (wish coding)

@sunflower2333

Copy link
Copy Markdown
Member

This repo will not accept sm8750.

@retro98boy

Copy link
Copy Markdown
Author

Why the fuck exactly you have ufs and the other stuff as drivers with src?

AI time (wish coding)

Yes. Getting the OEM UFS and SD DXE drivers to work requires patching their binaries, which I find rather unintuitive. So I had an LLM rewrite the source code based on the kernel drivers.

@retro98boy

Copy link
Copy Markdown
Author

This repo will not accept sm8750.

What's the reason it's not supported?

@remtrik

remtrik commented Nov 7, 2026

Copy link
Copy Markdown
Member

Why the fuck exactly you have ufs and the other stuff as drivers with src?

AI time (wish coding)

Yes. Getting the OEM UFS and SD DXE drivers to work requires patching their binaries, which I find rather unintuitive. So I had an LLM rewrite the source code based on the kernel drivers.

I'm sorry to inform you but you just found unintuitive the basic ability to find differences between 2 things

@remtrik

remtrik commented Nov 7, 2026

Copy link
Copy Markdown
Member

This repo will not accept sm8750.

What's the reason it's not supported?

This project doesn't support sm8750
Didn't support sm8750
And have no plans of ever supporting it

We do not provide support for random SoCs, if you want you can go to Project Silicium, but do note that your pr will be rejected there too, unless you change your approach

@sunflower2333

Copy link
Copy Markdown
Member

Because this repo only accept sm8550 and sm8850 which has similar gpu/pmics/etc with snapdragon computer platforms. We may add support for it once we finished windows drivers someday but not now.

If you want to submit your changes, pr to https://github.com/sunflower2333/mu_wide_platforms. Currently only accept patched drivers and generic driver source(like ufs, but your codes are not lean and tidy enough which is low quality).

@sunflower2333

Copy link
Copy Markdown
Member

Btw that repo already has y700 supports except a optional ufs patch missing.

@retro98boy

Copy link
Copy Markdown
Author

Because this repo only accept sm8550 and sm8850 which has similar gpu/pmics/etc with snapdragon computer platforms. We may add support for it once we finished windows drivers someday but not now.

If you want to submit your changes, pr to https://github.com/sunflower2333/mu_wide_platforms. Currently only accept patched drivers and generic driver source(like ufs, but your codes are not lean and tidy enough which is low quality).

Alright. I hadn't come across this repository before. Otherwise, I wouldn't have bothered working on Y700 Gen 4 support myself.

So, if I wanted to add support for other peripherals on the Y700 in this repository, using the OEM binaries or patching them would be the better approach, right?

@qaz6750

qaz6750 commented Nov 7, 2026

Copy link
Copy Markdown
Member

Because this repo only accept sm8550 and sm8850 which has similar gpu/pmics/etc with snapdragon computer platforms. We may add support for it once we finished windows drivers someday but not now.
If you want to submit your changes, pr to https://github.com/sunflower2333/mu_wide_platforms. Currently only accept patched drivers and generic driver source(like ufs, but your codes are not lean and tidy enough which is low quality).

Alright. I hadn't come across this repository before. Otherwise, I wouldn't have bothered working on Y700 Gen 4 support myself.

So, if I wanted to add support for other peripherals on the Y700 in this repository, using the OEM binaries or patching them would be the better approach, right?

Yes, but I don't think UEFI needs to add too many features, just ensure USBFN and UFS

@sunflower2333

Copy link
Copy Markdown
Member

yes.. or use crdk, but it's still under developmet. You can also make a driver to avoid the patch, like a driver only link up ufs/scsi and set gear etc. so you won't need to patch ufsdxe to wake ufs up.

i talked about the ufs problem in the ai opened issue:
sunflower2333/mu_wide_platforms#12 (comment)

But that guy only response with ai and don't understand what i mean. No idea lmao.

@NikkaGames

Copy link
Copy Markdown

@remtrik I patched storufs to get it working on 8845 😁

@retro98boy
retro98boy deleted the lenovo-y700-gen4-initial-support-pr branch November 9, 2026 02:06
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.

5 participants