[Nexus 4 Q&A, Help & Troubleshooting] TounToun:
Hi xda-developers!

I'm new in xda! I request your help on how to build bootloader and baseband from AOSP. I'm not sure that it is possible. It's not the common thread to know how to unlock the bootloader, this is quite harder :cowboy:. I want to reproduce the bootloader.img like a Google's developer will do for the Nexus 4.

What I have done :

- Build and install CyanogenMod 10.1 Nightly for the Nexus 4(mako). It works fine, but the bootloader is not compiled.

- Build "full_mako" from AOSP.

- Updated the Nexus 4 with the official update of the Nexus 4: https://developers.google.com/android/nexus/images#occam

It contains what I want to recreate from source code:

- bootloader-mako-makoz10o.img

- radio-mako-m9615a-cefwmazm-2.0.1700.48.img

- flash-all.sh

- flash-all.bat

- flash-base.sh

I found the script which create the last 3 files but I need to have bootloader.img in TARGET_FILES. It means that I need to compile and generate it before. The script related is this one :

https://github.com/winner00/device-...ory-images/generate-factory-images-package.sh

This file launch the common file :

https://code.google.com/p/android-s...-factory-images-common.sh?repo=device--common

I also found one interesting file in device/lge/mako :

https://android.googlesource.com/device/lge/mako/+/android-4.2.2_r1/releasetools.py

This is a python script that I don't know where he is launched.

It seems that the purpose of thsi file is to write a realease bootloader.img and radio.img, from already builded img files.

However we have interesting information in it :

/* mako bootloader.img format */

define BOOTLDR_MAGIC "BOOTLDR!"
define BOOTLDR_MAGIC_SIZE 8

struct bootloader_images_header {
char magic[BOOTLDR_MAGIC_SIZE];
unsigned int num_images;
unsigned int start_offset;
unsigned int bootldr_size;
struct {
char name[64];
unsigned int size;
} img_info[];
};

Fortunately, this script can give us good informations in order to hack properly the bootloader.img. Enjoy :laugh:

What I want to do:

- Compile bootloader code from AOSP and generate the file: bootloader.img. By this way I will be able to flash it to my phone.

What I think I have understood:

I need to add variables to the BoardConfig.mk in https://android.googlesource.com/device/lge/mako/+/android-4.2.2_r1

Indeed the README from the bootable/bootloader source code is clear :

The product_config.mk defines three important build variables:

DEVICE_BOOTLOADER_LIBS := \
libboot_board_brick.a \
libboot_arch_65002.a \
libboot_arch_armv6.a

DEVICE_BOOTLOADER_LINK_SCRIPT := \
partner/semi/boot/boot.ld

DEVICE_BOOTLOADER_INIT := \
partner/semi/boot/init.S

What I found:

A .ld file for msm7k, but I don't know if it will works for Nexus 4. I don't want to brick my Nexus 4 :eek:

https://android.googlesource.com/platform/hardware/msm7k/+/android-4.2.2_r1/boot/boot.ld

A BoardConfig.mk for htc sapphire :

https://android.googlesource.com/de...b906b9424edd0232d121cca5161e06/BoardConfig.mk

It seems that variables are well configured to build the bootloader :

TARGET_BOOTLOADER_LIBS := \
libboot_board_dream_sapphire \
libboot_arch_msm7k \
libboot_arch_armv6

TARGET_BOOTLOADER_LINK_SCRIPT := \
hardware/msm7k/boot/boot.ld

I am not able to find a .ld file for the Nexus 4. This can be due to the fact that they use the msm7k boot.ld file

I found also two good threads from E:V:A about MSM8960 :

http://xdaforums.com/showthread.php?t=1856327.

http://xdaforums.com/showthread.php?p=33813888

But this is more about hacking the bootloader than building from sources. I might go this way if I have no choice.

My question : Do you think that it is possible to generate this bootloader.img with the public source code?

I will appreciate your help,

Thanks in advance,

TounToun.