Skip to content

[EFIDroid] Porting a new device

Michael Zimmermann edited this page Jul 5, 2020 · 50 revisions

This will probably not work because the project has been discontinued

https://github.com/efidroid/projectmanagement/issues/152#issuecomment-562019779


Important note

At the moment, only devices with Qualcomm chipsets are supported. If you are a developer with another device AND you got a good way to debug(UART, JTAG, ...) please contact me so we can try to make it work.

Environment setup

in case you haven't done so yet, run this command to setup your environment:

source build/envsetup.sh

See Build system for more information

Generating the initial device tree

You can automatically generate a basic device config from an existing Android or Recovery boot image of your device. If your device doesn't support boot.img's please get in contact with me because there are more things to fix then.

create_device /path/to/boot.img

This command asks for a few information you'll have to enter then.

Configure build system for the new device

lunch

and select your newly created device. Also, select DEBUG in build type:, since it'll generate a lot of debug messages to easily track what went wrong.

Compile NOUEFI variant of LK

Now you can build LK with the following command:

make -jX lk

The "X" stands for the number of jobs. A good value to use is the number of cores of your processor. (including virtual ones if you have Hyperthreading enabled). If error messages get scrambled you should use the number 1.

Boot NOUEFI LK

the previous command should produce a file called out/device/[vendor]/[codename]/lk.img which you can either flash or 'fastboot boot' to your device.

if everything went well you'll have your device in a custom fastboot state. The device may look like it's stuck at the splash screen, but that's ok. The main thing to check is that your device is detected when you run fastboot devices.

Update loading addresses

while your device is booted in NOUEFI mode and connected to your computer you can run the following command to do so:

finalize_device device/[VENDOR]/[CODENAME]

Cleanup and recompile LK

rm -Rf out/
make -jX lk

now you should be back to LK fastboot mode but with proper loading addresses. Also, you should see a linux logo or your device's default splash on your screen with lots of log messages on top of it. If you don't you have to fix your display driver.

Display driver (if it doesn't work)

There are two different drivers and they can be selected from your device's lk_inc.mk. The default one is DISPLAY_2NDSTAGE which relies on the stock bootloader having initialized the screen already. If that you doesn't work you can try DISPLAY_2NDSTAGE_DTB which uses information from your device's dt.img to initialize the screen. Of course, this only works if you device does use a device tree instead of classical atags.

If all screen information in LK are correct but the screen still doesn't work, you are using the DISPLAY_2NDSTAGE driver and your device has a panel operating in command mode, then you can try to add the following option to your lk_inc.mk:

DEFINES += WITH_2NDSTAGE_DISPLAY_DMA_TRIGGER

If that still doesn't work for you, you can get in contact with others on Slack to discuss the problem.

Compile UEFI

Now you can build the whole project with the following command:

make -jX uefi

Boot UEFI

the previous command should produce a file called out/device/[vendor]/[codename]/uefi_boot.img which you can either flash or 'fastboot boot' to your device.

if everything went well you'll see the UEFI UI and you're done porting.

Stability test

go through the stability checklist

Local OTA server for using EFIDroid Manager with a new device

  • add your device to ota/devices.json
  • run make otapackage
  • add a new device directory: ota/[VENDOR]/[DEVICE]
  • create ota/[VENDOR]/[DEVICE]/info.json and add a new release. example:
[
  {
    "file": "http://IP:PORT/builds/[VENDOR]/[DEVICE]/otapackage-20160825-[VENDOR]_[DEVICE].zip",
    "timestamp": 0
  }
]

make sure that you use the correct filename(the date part changes over time) and that the timestamp of the file you want to use is the highest in the file (in case you have multiple entries for some reason)

  • run start_local_otaserver PORT
  • open a root shell on your Android device and run setprop efidroid.server_url "http://IP:PORT"

Creating a GitHub server for delivering unofficial releases

If your build pass through all stability checks successfully, you can easily create a pull request for an official build. If it doesn't, and it won't in the first chance for most of the time, but you're certain to release the public beta, you'll need a server. You can easily use GitHub as your unofficial EFIDroid OTA server using the following steps :

  1. Create a new folder named git_ota (you can call it whatever you want)
  2. Create the following directory structure :
git_ota/ota/master
  1. Add a new devices.json file in the root of master with only your device in it
  2. Copy your device folder from efidroid/ota and paste it in git_ota/ota/master
  3. Again create the following directory structure for storing your builds
git_ota/builds/[vendor]/[codename]
  1. Copy the ota zip from out/device/[vendor]/[codename] to git_ota/builds/[vendor]/[codename]. It'll be named something like otapackage-*-*.zip
  2. Now create an empty repository in GitHub named efidroid_ota (again, you can call it whatever you want)
  3. Open git_ota/ota/master/[vendor]/[codename]/info.json and replace the file URL you set up in the previous step with the following
https://raw.githubusercontent.com/[your_github_username]/efidroid_ota/master/builds/[vendor]/[codename]/[ota_zipname].zip
  1. Initialize and push your build repo in git_ota with the following commands
git init
git add *
git commit -m "First build"
git remote add origin https://github.com/[your_username]/efidroid_ota.git
git push -u origin master

You'll be asked for your username and passsword. Fill them up and voila, you've successfully set up an unofficial EFIDroid OTA server for your device.

  1. Open /system/build.prop in your device and add the following line to point to your unofficial server (you can also do setprop in every reboot, your wish)
efidroid.server_url=https://raw.githubusercontent.com/[your_username]/efidroid_ota/master

You're all done. Just tell your beta testers or users to do the above step to get your unofficial builds.

  1. When adding a new build, just copy the ota zip from efidroid/out/device/[vendor]/[codename] to git_ota/builds/[vendor]/[codename], change the ota zip name in git_ota/ota/master/[vendor]/[codename]/info.json to the new zip, and do
git add *
git commit -m "New build"
git push

Your users will get the build delivered to their device when they tap Install in EFIDroid Manager.