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

WIP, DO NOT MERGE, Dualboot: Sos 3.x dualboot #1

Open
wants to merge 21 commits into
base: sos-3.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
b50fca4
Merge 3f8aa1070e6946c0cc47ff73df5811ba50678ab4 on remote branch
Feb 7, 2021
a3efd97
Merge ce876d98e6d9d8b5ff66304515d5b31636fd4e92 on remote branch
Mar 18, 2021
9c76a55
Merge 1259da7b59dbe4efe5e37ff3d3ac7f67b4455128 on remote branch
Apr 22, 2021
f81bf34
Merge b007693779e7aff4226470cd6cb9a86aa5227ce9 on remote branch
May 13, 2021
b2d0cfc
Merge 011b2a010f88a5c23dc85e54c4d18130fd7c151a on remote branch
Jun 10, 2021
40a1d11
Merge 4412bdfdebff8ad290b9475dd183461f7af77ede on remote branch
Jul 13, 2021
4196bc6
avb: replace oem public key with our avb-4096 key
amartinz Feb 13, 2020
c27b2a9
LinuxLoader: fix bootloader and recovery mode boot key combination
amartinz Jun 2, 2020
217bd7c
QcomModulePkg: allow boot/flash/unlock operations in user build
amartinz Apr 13, 2020
a614521
DeviceInfo: always enable offline charging
amartinz Jun 2, 2020
d0c51de
QcomModulePkg: allow retrieving oem partition guid
amartinz Jun 2, 2020
9fbb2e5
QcomModulePkg: Read SerialNumber from oem partition
amartinz Jun 2, 2020
b9de0fa
QcomModulePkg: Read HardwareRevision from oem partition
amartinz Jun 2, 2020
8bc4669
FastbootMenu: print HardwareRevision
amartinz Jun 2, 2020
80b2e2e
FastbootMenu: print PRODUCT_MODEL
amartinz Jun 2, 2020
7487038
FastbootMenu: use different colors
amartinz Feb 17, 2021
24e3744
BootLib: DeviceInfo: set bootloader version during compile time
amartinz Sep 10, 2021
9e7d0f9
Fix building
luka177 Oct 15, 2021
e5548a4
Add Abm
luka177 Oct 15, 2021
0947e78
disable werror
luka177 Oct 15, 2021
ebd4f5b
On screen log
luka177 Oct 15, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Build/
tags/
build_modulepkg.log
QcomModulePkg/Tools/elf_tools.pyc
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "AbmPkg"]
path = AbmPkg
url = https://github.com/Android-Boot-Manager/droidboot_generic_uefi
1 change: 1 addition & 0 deletions AbmPkg
Submodule AbmPkg added at 7b434c
13 changes: 13 additions & 0 deletions AndroidBoot.mk
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,17 @@ else
BOARD_BOOTLOADER_PRODUCT_NAME := QC_Reference_Phone
endif

ifneq ($(TARGET_BOOTLOADER_BOARD_MODEL),)
BOARD_BOOTLOADER_PRODUCT_MODEL := $(TARGET_BOOTLOADER_BOARD_MODEL)
else
BOARD_BOOTLOADER_PRODUCT_MODEL := unknown
endif
ifneq ($(TARGET_BOOTLOADER_VERSION),)
BOARD_BOOTLOADER_VERSION := $(TARGET_BOOTLOADER_VERSION)
else
BOARD_BOOTLOADER_VERSION := unknown
endif

ifneq ($(TARGET_BOARD_TYPE),auto)
TARGET_BOARD_TYPE_AUTO := TARGET_BOARD_TYPE_AUTO=0
else
Expand Down Expand Up @@ -167,4 +178,6 @@ $(TARGET_ABL): $(LOCAL_ABL_SRC_FILE) | $(ABL_OUT) $(INSTALLED_KEYSTOREIMAGE_TARG
CLANG_GCC_TOOLCHAIN=$(CLANG35_GCC_TOOLCHAIN)\
TARGET_ARCHITECTURE=$(TARGET_ARCHITECTURE) \
BOARD_BOOTLOADER_PRODUCT_NAME=$(BOARD_BOOTLOADER_PRODUCT_NAME) \
BOARD_BOOTLOADER_PRODUCT_MODEL=$(BOARD_BOOTLOADER_PRODUCT_MODEL) \
BOARD_BOOTLOADER_VERSION=$(BOARD_BOOTLOADER_VERSION) \
USERDATAIMAGE_FILE_SYSTEM_TYPE=$(USERDATAIMAGE_FILE_SYSTEM_TYPE)
2 changes: 1 addition & 1 deletion BaseTools/Source/C/GenVtf/GenVtf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1470,7 +1470,7 @@ Routine Description:
//
FitStartPtr = (FIT_TABLE *) RelativeAddress;

strncpy ((CHAR8 *) &FitStartPtr->CompAddress, FIT_SIGNATURE, 8); // "_FIT_ "
memcpy ((CHAR8 *) &FitStartPtr->CompAddress, FIT_SIGNATURE, 8); // "_FIT_ "
assert (((VtfInfo->CompSize & 0x00FFFFFF) % 16) == 0);
FitStartPtr->CompSize = (VtfInfo->CompSize & 0x00FFFFFF) / 16;
FitStartPtr->CompVersion = MAKE_VERSION (VtfInfo->MajorVer, VtfInfo->MinorVer);
Expand Down
4 changes: 2 additions & 2 deletions BaseTools/Source/C/Makefiles/header.makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ INCLUDE = $(TOOL_INCLUDE) -I $(MAKEROOT) -I $(MAKEROOT)/Include/Common -I $(MAKE
CPPFLAGS = $(INCLUDE)
ifeq ($(DARWIN),Darwin)
# assume clang or clang compatible flags on OS X
CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -Wno-shift-negative-value -Wno-self-assign -nostdlib -c -g
CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Wno-deprecated-declarations -Wno-shift-negative-value -Wno-self-assign -nostdlib -c -g
else
CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -Wno-shift-negative-value -nostdlib -c -g
CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Wno-deprecated-declarations -Wno-shift-negative-value -nostdlib -c -g
endif
LFLAGS =

Expand Down
46 changes: 23 additions & 23 deletions Conf/tools_def.txt

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions QcomModulePkg/Application/LinuxLoader/LinuxLoader.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,10 @@ LinuxLoaderEntry (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)

Status = GetKeyPress (&KeyPressed);
if (Status == EFI_SUCCESS) {
if (KeyPressed == SCAN_DOWN)
BootIntoFastboot = TRUE;
if (KeyPressed == SCAN_UP)
if ((KeyPressed == SCAN_DOWN) || (KeyPressed == SCAN_DELETE))
BootIntoRecovery = TRUE;
if ((KeyPressed == SCAN_UP) || (KeyPressed == SCAN_HOME))
BootIntoFastboot = TRUE;
if (KeyPressed == SCAN_ESC)
RebootDevice (EMERGENCY_DLOAD);
} else if (Status == EFI_DEVICE_ERROR) {
Expand Down
2 changes: 2 additions & 0 deletions QcomModulePkg/Application/LinuxLoader/LinuxLoader.inf
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
ArmPlatformPkg/ArmPlatformPkg.dec
MdeModulePkg/MdeModulePkg.dec
QcomModulePkg/QcomModulePkg.dec
AbmPkg/Abm.dec

[LibraryClasses]
DxeServicesTableLib
Expand All @@ -61,6 +62,7 @@
EfiFileLib
FastbootLib
UbsanLib
AbmLib

[Guids]
gEfiFileInfoGuid
Expand Down
2 changes: 2 additions & 0 deletions QcomModulePkg/Include/Library/Board.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ BoardPmicTarget (UINT32 PmicDeviceIndex);

EFI_STATUS BoardInit (VOID);

EFI_STATUS
BoardHardwareRevision (CHAR8 *StrHardwareRev, UINT32 Len);
EFI_STATUS
BoardSerialNum (CHAR8 *StrSerialNum, UINT32 Len);
UINT32 BoardPlatformRawChipId (VOID);
Expand Down
3 changes: 3 additions & 0 deletions QcomModulePkg/Include/Library/LinuxLoaderLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ LoadImageFromPartition (VOID *ImageBuffer, UINT32 *ImageSize, CHAR16 *Pname);
EFI_STATUS
ReadWriteDeviceInfo (vb_device_state_op_t Mode, void *DevInfo, UINT32 Sz);

EFI_STATUS
GetNandOemPartiGuid (EFI_GUID *Ptype);

EFI_STATUS
GetNandMiscPartiGuid (EFI_GUID *Ptype);
/**
Expand Down
9 changes: 9 additions & 0 deletions QcomModulePkg/Include/Library/Recovery.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@

#define FFBM_MODE_BUF_SIZE 8

#define READ_OEM_BUF_SIZE 512
#define READ_OEM_BUF_LEN 24

#define RECOVERY_BOOT_RECOVERY "boot-recovery"
#define RECOVERY_BOOT_FASTBOOT "boot-fastboot"

Expand Down Expand Up @@ -92,4 +95,10 @@ EFI_STATUS
SetSnapshotMergeStatus (VirtualAbMergeStatus MergeStatus);
EFI_STATUS
ReadFromPartition (EFI_GUID *Ptype, VOID **Msg, UINT32 Size);

EFI_STATUS
GetOemHardwareRevision (CHAR8 *nv_hwrevision);
EFI_STATUS
GetOemSerialNum (CHAR8 *nv_serialnum);

#endif
3 changes: 3 additions & 0 deletions QcomModulePkg/Include/Library/UpdateCmdLine.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@

#define MAX_PATH_SIZE 72
#define SERIAL_NUM_SIZE 64
#define HW_REVISION_SIZE 64

typedef struct BootInfo BootInfo;

Expand All @@ -57,11 +58,13 @@ typedef struct UpdateCmdLineParamList {
UINT32 CmdLineLen;
UINT32 HaveCmdLine;
UINT32 PauseAtBootUp;
CHAR8 *StrHardwareRev;
CHAR8 *StrSerialNum;
CHAR8 *SlotSuffixAscii;
CHAR8 *ChipBaseBand;
CHAR8 *DisplayCmdLine;
CONST CHAR8 *CmdLine;
CONST CHAR8 *HardwareRevisionCmdLine;
CONST CHAR8 *AlarmBootCmdLine;
CONST CHAR8 *MdtpActiveFlag;
CONST CHAR8 *BatteryChgPause;
Expand Down
25 changes: 25 additions & 0 deletions QcomModulePkg/Library/BootLib/Board.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "AutoGen.h"
#include <Board.h>
#include <Library/BootImage.h>
#include <Library/Recovery.h>
#include <Library/UpdateDeviceTree.h>
#include <Protocol/EFICardInfo.h>
#include <Protocol/EFIPlatformInfoTypes.h>
Expand Down Expand Up @@ -569,6 +570,24 @@ UfsGetSetBootLun (UINT32 *UfsBootlun, BOOLEAN IsGet)
return Status;
}

EFI_STATUS
BoardHardwareRevision (CHAR8 *StrHwRevision, UINT32 Len)
{

EFI_STATUS Status;

Status = GetOemHardwareRevision(StrHwRevision);
if (Status != EFI_SUCCESS) {
/* use fallback hardware revision and mark as success
* to proceed bootup */
AsciiSPrint (StrHwRevision, Len, "%d", 10000);
Status = EFI_SUCCESS;
}
DEBUG ((EFI_D_ERROR, "Got hardware revusuib from oem partition: %s\n", StrHwRevision));

return Status;
}

EFI_STATUS
BoardSerialNum (CHAR8 *StrSerialNum, UINT32 Len)
{
Expand Down Expand Up @@ -597,6 +616,12 @@ BoardSerialNum (CHAR8 *StrSerialNum, UINT32 Len)
return Status;
}

Status = GetOemSerialNum (StrSerialNum);
if (Status == EFI_SUCCESS) {
DEBUG ((EFI_D_ERROR, "Got serial number from oem partition: %s\n", StrSerialNum));
return Status;
}

if (CardInfo->GetCardInfo (CardInfo, &CardInfoData) == EFI_SUCCESS) {
if (Type == UFS) {
Status = gBS->CalculateCrc32 (CardInfoData.product_serial_num,
Expand Down
1 change: 1 addition & 0 deletions QcomModulePkg/Library/BootLib/BootLib.inf
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
gEfiLogFSPartitionGuid
gEfiNandUserPartitionGuid
gEfiMiscPartitionGuid
gEfiOemPartitionGuid
gEfiRNGAlgRawGuid
gEfiUfsLU0Guid
gEfiUfsLU1Guid
Expand Down
14 changes: 6 additions & 8 deletions QcomModulePkg/Library/BootLib/DeviceInfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,14 +240,7 @@ UpdateDevInfo (CHAR16 *Pname, CHAR8 *ImgVersion)
{
EFI_STATUS Status = EFI_SUCCESS;

if (!StrCmp ((CONST CHAR16 *)Pname, (CONST CHAR16 *)L"bootloader")) {
AsciiStrnCpyS (DevInfo.bootloader_version, MAX_VERSION_LEN, PRODUCT_NAME,
AsciiStrLen (PRODUCT_NAME));
AsciiStrnCatS (DevInfo.bootloader_version, MAX_VERSION_LEN, "-",
AsciiStrLen ("-"));
AsciiStrnCatS (DevInfo.bootloader_version, MAX_VERSION_LEN, ImgVersion,
AsciiStrLen (ImgVersion));
} else {
if (StrCmp ((CONST CHAR16 *)Pname, (CONST CHAR16 *)L"bootloader")) {
AsciiStrnCpyS (DevInfo.radio_version, MAX_VERSION_LEN, PRODUCT_NAME,
AsciiStrLen (PRODUCT_NAME));
AsciiStrnCatS (DevInfo.radio_version, MAX_VERSION_LEN, "-",
Expand Down Expand Up @@ -279,6 +272,11 @@ EFI_STATUS DeviceInfoInit (VOID)
FirstReadDevInfo = FALSE;
}

AsciiStrnCpyS (DevInfo.bootloader_version, MAX_VERSION_LEN, PRODUCT_BOOTLOADER_VERSION,
AsciiStrLen (PRODUCT_BOOTLOADER_VERSION));

EnableChargingScreen (TRUE);

if (CompareMem (DevInfo.magic, DEVICE_MAGIC, DEVICE_MAGIC_SIZE)) {
DEBUG ((EFI_D_ERROR, "Device Magic does not match\n"));
gBS->SetMem (&DevInfo, sizeof (DevInfo), 0);
Expand Down
64 changes: 51 additions & 13 deletions QcomModulePkg/Library/BootLib/FastbootMenu.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ STATIC MENU_MSG_INFO mFastbootCommonMsgInfo[] = {
COMMON,
0,
NOACTION},
{{"FastBoot Mode"},
{{"Fastboot mode\n\n"},
COMMON_FACTOR,
BGR_RED,
BGR_YELLOW,
BGR_BLACK,
COMMON,
0,
Expand All @@ -110,6 +110,13 @@ STATIC MENU_MSG_INFO mFastbootCommonMsgInfo[] = {
COMMON,
0,
NOACTION},
{{"PRODUCT_MODEL - "},
COMMON_FACTOR,
BGR_WHITE,
BGR_BLACK,
COMMON,
0,
NOACTION},
{{"VARIANT - "},
COMMON_FACTOR,
BGR_WHITE,
Expand Down Expand Up @@ -138,20 +145,34 @@ STATIC MENU_MSG_INFO mFastbootCommonMsgInfo[] = {
COMMON,
0,
NOACTION},
{{"HARDWARE REVISION - "},
COMMON_FACTOR,
BGR_WHITE,
BGR_BLACK,
COMMON,
0,
NOACTION},
{{"SECURE BOOT - "},
COMMON_FACTOR,
BGR_WHITE,
BGR_BLACK,
COMMON,
0,
NOACTION},
{{"DEVICE STATE - "},
{{"\nDEVICE STATE - unlocked"},
COMMON_FACTOR,
BGR_RED,
BGR_BLACK,
COMMON,
0,
NOACTION},
{{"\nDEVICE STATE - locked"},
COMMON_FACTOR,
BGR_GREEN,
BGR_BLACK,
COMMON,
0,
NOACTION},
};

/**
Expand Down Expand Up @@ -250,6 +271,12 @@ FastbootMenuShowScreen (OPTION_MENU_INFO *OptionMenuInfo)
AsciiStrLen (PRODUCT_NAME));
break;
case 3:
/* Get product model */
AsciiStrnCatS (mFastbootCommonMsgInfo[i].Msg,
sizeof (mFastbootCommonMsgInfo[i].Msg), PRODUCT_MODEL,
AsciiStrLen (PRODUCT_MODEL));
break;
case 4:
/* Get variant value */
BoardHwPlatformName (StrTemp, sizeof (StrTemp));
GetRootDeviceType (StrTemp1, sizeof (StrTemp1));
Expand All @@ -264,42 +291,53 @@ FastbootMenuShowScreen (OPTION_MENU_INFO *OptionMenuInfo)
sizeof (mFastbootCommonMsgInfo[i].Msg), StrTemp1,
sizeof (StrTemp1));
break;
case 4:
case 5:
/* Get bootloader version */
GetBootloaderVersion (VersionTemp, sizeof (VersionTemp));
AsciiStrnCatS (mFastbootCommonMsgInfo[i].Msg,
sizeof (mFastbootCommonMsgInfo[i].Msg), VersionTemp,
sizeof (VersionTemp));
break;
case 5:
case 6:
/* Get baseband version */
ZeroMem (VersionTemp, sizeof (VersionTemp));
GetRadioVersion (VersionTemp, sizeof (VersionTemp));
AsciiStrnCatS (mFastbootCommonMsgInfo[i].Msg,
sizeof (mFastbootCommonMsgInfo[i].Msg), VersionTemp,
sizeof (VersionTemp));
break;
case 6:
case 7:
/* Get serial number */
ZeroMem (StrTemp, sizeof (StrTemp));
BoardSerialNum (StrTemp, MAX_RSP_SIZE);
AsciiStrnCatS (mFastbootCommonMsgInfo[i].Msg,
sizeof (mFastbootCommonMsgInfo[i].Msg), StrTemp,
sizeof (StrTemp));
break;
case 7:
case 8:
/* Get hardware revision */
ZeroMem (StrTemp, sizeof (StrTemp));
BoardHardwareRevision (StrTemp, MAX_RSP_SIZE);
AsciiStrnCatS (mFastbootCommonMsgInfo[i].Msg,
sizeof (mFastbootCommonMsgInfo[i].Msg), StrTemp,
sizeof (StrTemp));
break;
case 9:
/* Get secure boot value */
AsciiStrnCatS (
mFastbootCommonMsgInfo[i].Msg, sizeof (mFastbootCommonMsgInfo[i].Msg),
IsSecureBootEnabled () ? "yes" : "no",
IsSecureBootEnabled () ? AsciiStrLen ("yes") : AsciiStrLen ("no"));
break;
case 8:
/* Get device status */
AsciiStrnCatS (
mFastbootCommonMsgInfo[i].Msg, sizeof (mFastbootCommonMsgInfo[i].Msg),
IsUnlocked () ? "unlocked" : "locked",
IsUnlocked () ? AsciiStrLen ("unlocked") : AsciiStrLen ("locked"));
case 10:
/* Get device status, only show when unlocked */
if (!IsUnlocked ())
continue;
break;
case 11:
/* Get device status, only show when locked */
if (IsUnlocked ())
continue;
break;
}

Expand Down
Loading