-
-
Save AAGaming00/c617934df7a4cad516f760ab053b82b0 to your computer and use it in GitHub Desktop.
LK LE.UM.1.3.r4.4 - Anki vector
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Only in .: .git | |
diff -ru ./app/aboot/aboot.c ../opensource-1.6/bootable/bootloader/lk/app/aboot/aboot.c | |
--- ./app/aboot/aboot.c 2019-12-24 12:48:59.000000000 -0800 | |
+++ ../opensource-1.6/bootable/bootloader/lk/app/aboot/aboot.c 2019-12-19 10:42:02.000000000 -0800 | |
@@ -102,7 +102,6 @@ | |
char **buf); | |
void *info_buf; | |
-void write_device_info(device_info *dev); | |
void write_device_info_mmc(device_info *dev); | |
void write_device_info_flash(device_info *dev); | |
static int aboot_save_boot_hash_mmc(uint32_t image_addr, uint32_t image_size); | |
@@ -111,7 +110,6 @@ | |
bool pwr_key_is_pressed = false; | |
static bool is_systemd_present=false; | |
static void publish_getvar_multislot_vars(); | |
-static bool critical_flash_allowed(const char * entry); | |
/* fastboot command function pointer */ | |
typedef void (*fastboot_cmd_fn) (const char *, void *, unsigned); | |
@@ -157,18 +155,11 @@ | |
//a uncompressed kernel + appended dtb | |
#define PATCHED_KERNEL_MAGIC "UNCOMPRESSED_IMG" | |
-/* commands that required to check allowed or not */ | |
-#define CMD_FLASH 1 | |
-#define CMD_ERASE 2 | |
-#define CMD_BOOT 3 | |
-#define CMD_META 4 | |
- | |
#if USE_BOOTDEV_CMDLINE | |
static const char *emmc_cmdline = " androidboot.bootdevice="; | |
#else | |
static const char *emmc_cmdline = " androidboot.emmc=true"; | |
#endif | |
-static const char *usb_sn_cmdline = " androidboot.serialno="; | |
static const char *androidboot_mode = " androidboot.mode="; | |
static const char *systemd_ffbm_mode = " systemd.unit=ffbm.target"; | |
@@ -192,9 +183,10 @@ | |
static const char *warmboot_cmdline = " qpnp-power-on.warm_boot=1"; | |
static const char *baseband_apq_nowgr = " androidboot.baseband=baseband_apq_nowgr"; | |
static const char *androidboot_slot_suffix = " androidboot.slot_suffix="; | |
-static const char *skip_ramfs = " skip_initramfs"; | |
-static const char *sys_path_cmdline = " rootwait ro init=/init"; | |
-static const char *sys_path = " root=/dev/mmcblk0p"; | |
+static const char *sys_path_cmdline = " rootwait ro"; | |
+ | |
+static const char *unbrick_cmdline = " anki.unbrick"; | |
+static const char *anki_dev_cmdline = " anki.dev"; | |
#if VERIFIED_BOOT | |
static const char *verity_mode = " androidboot.veritymode="; | |
@@ -238,6 +230,8 @@ | |
static device_info device = {DEVICE_MAGIC, 0, 0, 0, 0, {0}, {0},{0}, 1}; | |
static bool is_allow_unlock = 0; | |
+static bool is_anki_dev = 0; | |
+ | |
static char frp_ptns[2][8] = {"config","frp"}; | |
static const char *critical_flash_allowed_ptn[] = { | |
@@ -304,71 +298,6 @@ | |
extern int fastboot_trigger(void); | |
#endif | |
-#if VERIFIED_BOOT | |
-static bool is_cmd_fastboot_allowed(const char *arg, int cmd) | |
-{ | |
- if (target_build_variant_user()) { | |
- switch (cmd) { | |
- case CMD_FLASH: | |
- /* if device is locked: | |
- * common partition will not allow to be flashed | |
- * critical partition will allow to flash image. | |
- */ | |
- if (!device.is_unlocked && | |
- !critical_flash_allowed(arg)) { | |
- fastboot_fail("Partition flashing is not allowed"); | |
- return false; | |
- } | |
- | |
- /* if device critical is locked: | |
- * common partition will allow to be flashed | |
- * critical partition will not allow to flash image. | |
- */ | |
- if (VB_V2 == target_get_vb_version() && | |
- !device.is_unlock_critical && | |
- critical_flash_allowed(arg)) { | |
- fastboot_fail("Critical partition flashing is not allowed"); | |
- return false; | |
- } | |
- break; | |
- case CMD_META: | |
- if (!device.is_unlocked) { | |
- fastboot_fail("Device is locked, meta image flashing is not allowed"); | |
- return false; | |
- } | |
- | |
- if (VB_V2 == target_get_vb_version() && | |
- !device.is_unlock_critical) | |
- { | |
- fastboot_fail("Device is critical locked, Meta image flashing is not allowed"); | |
- return false; | |
- } | |
- break; | |
- case CMD_ERASE: | |
- case CMD_BOOT: | |
- if (!device.is_unlocked) | |
- return false; | |
- default: | |
- break; | |
- } | |
- } | |
- | |
- return true; | |
-} | |
-#else | |
-static bool is_cmd_fastboot_allowed(const char *arg, int cmd) | |
-{ | |
- if (is_vb_le_enabled()) { | |
- if (!device.is_unlocked) { | |
- fastboot_fail("device is in locked state, this command is not allowed"); | |
- return false; | |
- } | |
- } | |
- | |
- return true; | |
-} | |
-#endif | |
- | |
static void update_ker_tags_rdisk_addr(struct boot_img_hdr *hdr, bool is_arm64) | |
{ | |
/* overwrite the destination of specified for the project */ | |
@@ -407,6 +336,7 @@ | |
{ | |
int cmdline_len = 0; | |
int have_cmdline = 0; | |
+ int target_boot_params_status = 0; | |
unsigned char *cmdline_final = NULL; | |
int pause_at_bootup = 0; | |
bool warm_boot = false; | |
@@ -415,11 +345,8 @@ | |
char *boot_dev_buf = NULL; | |
bool is_mdtp_activated = 0; | |
int current_active_slot = INVALID; | |
- int system_ptn_index = -1; | |
unsigned int lun = 0; | |
char lun_char_base = 'a'; | |
- int syspath_buflen = strlen(sys_path) + sizeof(int) + 1; /*allocate buflen for largest possible string*/ | |
- char syspath_buf[syspath_buflen]; | |
#if VERIFIED_BOOT | |
uint32_t boot_state = RED; | |
#endif | |
@@ -453,9 +380,6 @@ | |
#endif | |
} | |
- cmdline_len += strlen(usb_sn_cmdline); | |
- cmdline_len += strlen(sn_buf); | |
- | |
#if VERIFIED_BOOT | |
if (VB_V2 == target_get_vb_version()) | |
{ | |
@@ -497,12 +421,16 @@ | |
cmdline_len += strlen(auth_kernel); | |
} | |
- if (get_target_boot_params(cmdline, boot_into_recovery ? "recoveryfs" : | |
- "system", | |
- &target_boot_params) == 0) { | |
+ target_boot_params_status = get_target_boot_params(cmdline, boot_into_recovery ? "recoveryfs" : "system", &target_boot_params); | |
+ if (target_boot_params_status == 0) { | |
have_target_boot_params = 1; | |
cmdline_len += strlen(target_boot_params); | |
} | |
+ else if (target_boot_params_status == 1) { | |
+ have_target_boot_params = 1; | |
+ have_cmdline = 0; | |
+ cmdline_len += strlen(target_boot_params) - strlen(cmdline); | |
+ } | |
/* Determine correct androidboot.baseband to use */ | |
switch(target_baseband()) | |
@@ -551,6 +479,13 @@ | |
break; | |
} | |
+ if (boot_unbrick) { | |
+ cmdline_len += strlen(unbrick_cmdline); | |
+ } | |
+ if (is_anki_dev) { | |
+ cmdline_len += strlen(anki_dev_cmdline); | |
+ } | |
+ | |
#if ENABLE_DISPLAY | |
if (cmdline) { | |
if ((strstr(cmdline, DISPLAY_DEFAULT_PREFIX) == NULL) && | |
@@ -573,24 +508,7 @@ | |
cmdline_len += (strlen(androidboot_slot_suffix)+ | |
strlen(SUFFIX_SLOT(current_active_slot))); | |
- system_ptn_index = partition_get_index("system"); | |
- if (platform_boot_dev_isemmc()) | |
- { | |
- snprintf(syspath_buf, syspath_buflen, " root=/dev/mmcblk0p%d", | |
- system_ptn_index + 1); | |
- } | |
- else | |
- { | |
- lun = partition_get_lun(system_ptn_index); | |
- snprintf(syspath_buf, syspath_buflen, " root=/dev/sd%c%d", | |
- lun_char_base + lun, | |
- partition_get_index_in_lun("system", lun)); | |
- } | |
- | |
cmdline_len += strlen(sys_path_cmdline); | |
- cmdline_len += strlen(syspath_buf); | |
- if (!boot_into_recovery) | |
- cmdline_len += strlen(skip_ramfs); | |
} | |
#if TARGET_CMDLINE_SUPPORT | |
@@ -654,20 +572,24 @@ | |
while ((*dst++ = *src++)); | |
} | |
#endif | |
- src = usb_sn_cmdline; | |
- if (have_cmdline) --dst; | |
- have_cmdline = 1; | |
- while ((*dst++ = *src++)); | |
- src = sn_buf; | |
- if (have_cmdline) --dst; | |
- have_cmdline = 1; | |
- while ((*dst++ = *src++)); | |
if (warm_boot) { | |
if (have_cmdline) --dst; | |
src = warmboot_cmdline; | |
while ((*dst++ = *src++)); | |
} | |
+ if (boot_unbrick) { | |
+ if(have_cmdline) --dst; | |
+ src = unbrick_cmdline; | |
+ while ((*dst++ = *src++)); | |
+ } | |
+ | |
+ if (is_anki_dev) { | |
+ if(have_cmdline) --dst; | |
+ src = anki_dev_cmdline; | |
+ while ((*dst++ = *src++)); | |
+ } | |
+ | |
if (boot_into_recovery && gpt_exists) { | |
src = secondary_gpt_enable; | |
if (have_cmdline) --dst; | |
@@ -800,23 +722,13 @@ | |
--dst; | |
while ((*dst++ = *src++)); | |
--dst; | |
- src = SUFFIX_SLOT(current_active_slot); | |
+ if (boot_into_recovery) src = "_f"; | |
+ else src = SUFFIX_SLOT(current_active_slot); | |
while ((*dst++ = *src++)); | |
- if (!boot_into_recovery) | |
- { | |
- src = skip_ramfs; | |
- --dst; | |
- while ((*dst++ = *src++)); | |
- } | |
- | |
src = sys_path_cmdline; | |
--dst; | |
while ((*dst++ = *src++)); | |
- | |
- src = syspath_buf; | |
- --dst; | |
- while ((*dst++ = *src++)); | |
} | |
#if TARGET_CMDLINE_SUPPORT | |
@@ -1160,11 +1072,7 @@ | |
#if !VERIFIED_BOOT | |
if(device.is_tampered) | |
{ | |
- if (is_vb_le_enabled() && is_secure_boot_enable()) { | |
- dprintf(CRITICAL, "Device is tampered. Asserting..\n"); | |
- ASSERT(0); | |
- } | |
- write_device_info(&device); | |
+ write_device_info_mmc(&device); | |
#ifdef TZ_TAMPER_FUSE | |
set_tamper_fuse_cmd(); | |
#endif | |
@@ -1280,9 +1188,6 @@ | |
struct kernel64_hdr *kptr = NULL; | |
int current_active_slot = INVALID; | |
- if (check_format_bit()) | |
- boot_into_recovery = 1; | |
- | |
if (!boot_into_recovery) { | |
memset(ffbm_mode_string, '\0', sizeof(ffbm_mode_string)); | |
rcode = get_ffbm(ffbm_mode_string, sizeof(ffbm_mode_string)); | |
@@ -1386,7 +1291,7 @@ | |
* platform accordingly. | |
* 4. Sanity Check on kernel_addr and ramdisk_addr and copy data. | |
*/ | |
- if (partition_multislot_is_supported()) | |
+ if (partition_multislot_is_supported() && !boot_into_recovery) | |
{ | |
current_active_slot = partition_find_active_slot(); | |
dprintf(INFO, "Loading boot image (%d) active_slot(%s): start\n", | |
@@ -1412,7 +1317,7 @@ | |
return -1; | |
} | |
- if (partition_multislot_is_supported()) | |
+ if (partition_multislot_is_supported() && !boot_into_recovery) | |
{ | |
dprintf(INFO, "Loading boot image (%d) active_slot(%s): done\n", | |
imagesize_actual, SUFFIX_SLOT(current_active_slot)); | |
@@ -2279,10 +2184,6 @@ | |
void write_device_info(device_info *dev) | |
{ | |
- /* do not write devinfo in LE based VB case with secure boot enabled. */ | |
- if (is_vb_le_enabled() && is_secure_boot_enable()) | |
- return; | |
- | |
if(target_is_emmc_boot()) | |
{ | |
struct device_info *info = memalign(PAGE_SIZE, ROUNDUP(BOOT_IMG_MAX_PAGE_SIZE, PAGE_SIZE)); | |
@@ -2315,10 +2216,6 @@ | |
void read_device_info(device_info *dev) | |
{ | |
- /* do not read devinfo in LE based VB case with secure boot enabled. */ | |
- if (is_vb_le_enabled() && is_secure_boot_enable()) | |
- return; | |
- | |
if(target_is_emmc_boot()) | |
{ | |
struct device_info *info = memalign(PAGE_SIZE, ROUNDUP(BOOT_IMG_MAX_PAGE_SIZE, PAGE_SIZE)); | |
@@ -2451,18 +2348,14 @@ | |
set_device_unlock_value(type, status); | |
- /* Don't wipe data for LE targets when LE based VB enabled. */ | |
- if (is_vb_le_enabled()) { | |
- fastboot_okay(""); | |
- } else { | |
- struct recovery_message msg; | |
- memset(&msg, 0, sizeof(msg)); | |
- snprintf(msg.recovery, sizeof(msg.recovery), "recovery\n--wipe_data"); | |
- write_misc(0, &msg, sizeof(msg)); | |
+ /* wipe data */ | |
+ struct recovery_message msg; | |
+ memset(&msg, 0, sizeof(msg)); | |
+ snprintf(msg.recovery, sizeof(msg.recovery), "recovery\n--wipe_data"); | |
+ write_misc(0, &msg, sizeof(msg)); | |
- fastboot_okay(""); | |
- reboot_device(RECOVERY_MODE); | |
- } | |
+ fastboot_okay(""); | |
+ reboot_device(RECOVERY_MODE); | |
} | |
static bool critical_flash_allowed(const char * entry) | |
@@ -2603,11 +2496,13 @@ | |
exit_menu_keys_detection(); | |
#endif | |
- if(!is_cmd_fastboot_allowed(arg, CMD_BOOT)) | |
+#if VERIFIED_BOOT | |
+ if(target_build_variant_user() && !device.is_unlocked) | |
{ | |
fastboot_fail("unlock device to use this command"); | |
goto boot_failed; | |
} | |
+#endif | |
if (sz < sizeof(hdr)) { | |
fastboot_fail("invalid bootimage header"); | |
@@ -2925,10 +2820,16 @@ | |
void cmd_erase(const char *arg, void *data, unsigned sz) | |
{ | |
- if (!is_cmd_fastboot_allowed(arg, CMD_ERASE)) { | |
- fastboot_fail("device is locked. Cannot erase"); | |
- return; | |
+#if VERIFIED_BOOT | |
+ if (target_build_variant_user()) | |
+ { | |
+ if(!device.is_unlocked) | |
+ { | |
+ fastboot_fail("device is locked. Cannot erase"); | |
+ return; | |
+ } | |
} | |
+#endif | |
if(target_is_emmc_boot()) | |
cmd_erase_mmc(arg, data, sz); | |
@@ -3077,8 +2978,21 @@ | |
* which with "any" name other than bootloader. Because it maybe | |
* a meta package of all partitions. | |
*/ | |
- if (!is_cmd_fastboot_allowed(arg, CMD_META)) | |
- return; | |
+#if VERIFIED_BOOT | |
+ if (target_build_variant_user()) { | |
+ if (!device.is_unlocked) { | |
+ fastboot_fail("Device is locked, meta image flashing is not allowed"); | |
+ return; | |
+ } | |
+ | |
+ if (VB_V2 == target_get_vb_version() && | |
+ !device.is_unlock_critical) | |
+ { | |
+ fastboot_fail("Device is critical locked, Meta image flashing is not allowed"); | |
+ return; | |
+ } | |
+ } | |
+#endif | |
meta_header = (meta_header_t*) data; | |
if( data_end < ((uintptr_t)data + meta_header->img_hdr_sz)) | |
@@ -3467,8 +3381,30 @@ | |
} | |
#endif /* SSD_ENABLE */ | |
- if (!is_cmd_fastboot_allowed(arg, CMD_FLASH)) | |
- return; | |
+#if VERIFIED_BOOT | |
+ if (target_build_variant_user()) | |
+ { | |
+ /* if device is locked: | |
+ * common partition will not allow to be flashed | |
+ * critical partition will allow to flash image. | |
+ */ | |
+ if(!device.is_unlocked && !critical_flash_allowed(arg)) { | |
+ fastboot_fail("Partition flashing is not allowed"); | |
+ return; | |
+ } | |
+ | |
+ /* if device critical is locked: | |
+ * common partition will allow to be flashed | |
+ * critical partition will not allow to flash image. | |
+ */ | |
+ if (VB_V2 == target_get_vb_version() && | |
+ !device.is_unlock_critical && | |
+ critical_flash_allowed(arg)) { | |
+ fastboot_fail("Critical partition flashing is not allowed"); | |
+ return; | |
+ } | |
+ } | |
+#endif | |
sparse_header = (sparse_header_t *) data; | |
meta_header = (meta_header_t *) data; | |
@@ -3709,86 +3645,6 @@ | |
reboot_device(FASTBOOT_MODE); | |
} | |
-void cmd_oem_enable_charger_screen(const char *arg, void *data, unsigned size) | |
-{ | |
- dprintf(INFO, "Enabling charger screen check\n"); | |
- device.charger_screen_enabled = 1; | |
- write_device_info(&device); | |
- fastboot_okay(""); | |
-} | |
- | |
-void cmd_oem_disable_charger_screen(const char *arg, void *data, unsigned size) | |
-{ | |
- dprintf(INFO, "Disabling charger screen check\n"); | |
- device.charger_screen_enabled = 0; | |
- write_device_info(&device); | |
- fastboot_okay(""); | |
-} | |
- | |
-void cmd_oem_off_mode_charger(const char *arg, void *data, unsigned size) | |
-{ | |
- char *p = NULL; | |
- const char *delim = " \t\n\r"; | |
- char *sp; | |
- | |
- if (arg) { | |
- p = strtok_r((char *)arg, delim, &sp); | |
- if (p) { | |
- if (!strncmp(p, "0", 1)) { | |
- device.charger_screen_enabled = 0; | |
- } else if (!strncmp(p, "1", 1)) { | |
- device.charger_screen_enabled = 1; | |
- } | |
- } | |
- } | |
- | |
- /* update charger_screen_enabled value for getvar | |
- * command | |
- */ | |
- snprintf(charger_screen_enabled, MAX_RSP_SIZE, "%d", | |
- device.charger_screen_enabled); | |
- | |
- write_device_info(&device); | |
- fastboot_okay(""); | |
-} | |
- | |
-void cmd_oem_select_display_panel(const char *arg, void *data, unsigned size) | |
-{ | |
- dprintf(INFO, "Selecting display panel %s\n", arg); | |
- if (arg) | |
- strlcpy(device.display_panel, arg, | |
- sizeof(device.display_panel)); | |
- write_device_info(&device); | |
- fastboot_okay(""); | |
-} | |
- | |
-void cmd_oem_unlock(const char *arg, void *data, unsigned sz) | |
-{ | |
- set_device_unlock(UNLOCK, TRUE); | |
-} | |
- | |
-void cmd_oem_unlock_go(const char *arg, void *data, unsigned sz) | |
-{ | |
- if(!device.is_unlocked) { | |
- if(!is_allow_unlock) { | |
- fastboot_fail("oem unlock is not allowed"); | |
- return; | |
- } | |
- | |
- set_device_unlock_value(UNLOCK, TRUE); | |
- | |
- /* wipe data */ | |
- struct recovery_message msg; | |
- memset(&msg, 0, sizeof(msg)); | |
- snprintf(msg.recovery, sizeof(msg.recovery), "recovery\n--wipe_data"); | |
- write_misc(0, &msg, sizeof(msg)); | |
- | |
- fastboot_okay(""); | |
- reboot_device(RECOVERY_MODE); | |
- } | |
- fastboot_okay(""); | |
-} | |
- | |
static int aboot_frp_unlock(char *pname, void *data, unsigned sz) | |
{ | |
int ret=1; | |
@@ -3813,269 +3669,6 @@ | |
return ret; | |
} | |
-void cmd_oem_lock(const char *arg, void *data, unsigned sz) | |
-{ | |
- set_device_unlock(UNLOCK, FALSE); | |
-} | |
- | |
-void cmd_oem_devinfo(const char *arg, void *data, unsigned sz) | |
-{ | |
- char response[MAX_RSP_SIZE]; | |
- snprintf(response, sizeof(response), "\tDevice tampered: %s", (device.is_tampered ? "true" : "false")); | |
- fastboot_info(response); | |
- snprintf(response, sizeof(response), "\tDevice unlocked: %s", (device.is_unlocked ? "true" : "false")); | |
- fastboot_info(response); | |
-#if VERIFIED_BOOT | |
- if (VB_V2 == target_get_vb_version()) | |
- { | |
- snprintf(response, sizeof(response), "\tDevice critical unlocked: %s", | |
- (device.is_unlock_critical ? "true" : "false")); | |
- fastboot_info(response); | |
- } | |
-#endif | |
- snprintf(response, sizeof(response), "\tCharger screen enabled: %s", (device.charger_screen_enabled ? "true" : "false")); | |
- fastboot_info(response); | |
- snprintf(response, sizeof(response), "\tDisplay panel: %s", (device.display_panel)); | |
- fastboot_info(response); | |
- fastboot_okay(""); | |
-} | |
- | |
-void cmd_flashing_get_unlock_ability(const char *arg, void *data, unsigned sz) | |
-{ | |
- char response[MAX_RSP_SIZE]; | |
- snprintf(response, sizeof(response), "\tget_unlock_ability: %d", is_allow_unlock); | |
- fastboot_info(response); | |
- fastboot_okay(""); | |
-} | |
- | |
-void cmd_flashing_lock_critical(const char *arg, void *data, unsigned sz) | |
-{ | |
- if (is_vb_le_enabled()) { | |
- fastboot_fail("\tlock critical is not supported"); | |
- return; | |
- } else { | |
- set_device_unlock(UNLOCK_CRITICAL, FALSE); | |
- } | |
-} | |
- | |
-void cmd_flashing_unlock_critical(const char *arg, void *data, unsigned sz) | |
-{ | |
- if (is_vb_le_enabled()) { | |
- fastboot_fail("unlock critical is not supported"); | |
- return; | |
- } else { | |
- set_device_unlock(UNLOCK_CRITICAL, TRUE); | |
- } | |
-} | |
- | |
-void cmd_preflash(const char *arg, void *data, unsigned sz) | |
-{ | |
- fastboot_okay(""); | |
-} | |
- | |
-static uint8_t logo_header[LOGO_IMG_HEADER_SIZE]; | |
- | |
-int splash_screen_check_header(logo_img_header *header) | |
-{ | |
- if (memcmp(header->magic, LOGO_IMG_MAGIC, 8)) | |
- return -1; | |
- if (header->width == 0 || header->height == 0) | |
- return -1; | |
- return 0; | |
-} | |
- | |
-int splash_screen_flash() | |
-{ | |
- struct ptentry *ptn; | |
- struct ptable *ptable; | |
- struct logo_img_header *header; | |
- struct fbcon_config *fb_display = NULL; | |
- | |
- ptable = flash_get_ptable(); | |
- if (ptable == NULL) { | |
- dprintf(CRITICAL, "ERROR: Partition table not found\n"); | |
- return -1; | |
- } | |
- | |
- ptn = ptable_find(ptable, "splash"); | |
- if (ptn == NULL) { | |
- dprintf(CRITICAL, "ERROR: splash Partition not found\n"); | |
- return -1; | |
- } | |
- if (flash_read(ptn, 0, (void *)logo_header, LOGO_IMG_HEADER_SIZE)) { | |
- dprintf(CRITICAL, "ERROR: Cannot read boot image header\n"); | |
- return -1; | |
- } | |
- | |
- header = (struct logo_img_header *)logo_header; | |
- if (splash_screen_check_header(header)) { | |
- dprintf(CRITICAL, "ERROR: Boot image header invalid\n"); | |
- return -1; | |
- } | |
- | |
- fb_display = fbcon_display(); | |
- if (fb_display) { | |
- if (header->type && (header->blocks != 0)) { // RLE24 compressed data | |
- uint8_t *base = (uint8_t *) fb_display->base + LOGO_IMG_OFFSET; | |
- | |
- /* if the logo is full-screen size, remove "fbcon_clear()" */ | |
- if ((header->width != fb_display->width) | |
- || (header->height != fb_display->height)) | |
- fbcon_clear(); | |
- | |
- if (flash_read(ptn + LOGO_IMG_HEADER_SIZE, 0, | |
- (uint32_t *)base, | |
- (header->blocks * 512))) { | |
- dprintf(CRITICAL, "ERROR: Cannot read splash image from partition\n"); | |
- return -1; | |
- } | |
- fbcon_extract_to_screen(header, base); | |
- return 0; | |
- } | |
- | |
- if ((header->width > fb_display->width) || (header->height > fb_display->height)) { | |
- dprintf(CRITICAL, "Logo config greater than fb config. Fall back default logo\n"); | |
- return -1; | |
- } | |
- | |
- uint8_t *base = (uint8_t *) fb_display->base; | |
- uint32_t fb_size = ROUNDUP(fb_display->width * | |
- fb_display->height * | |
- (fb_display->bpp / 8), 4096); | |
- uint32_t splash_size = ((((header->width * header->height * | |
- fb_display->bpp/8) + 511) >> 9) << 9); | |
- | |
- if (splash_size > fb_size) { | |
- dprintf(CRITICAL, "ERROR: Splash image size invalid\n"); | |
- return -1; | |
- } | |
- | |
- if (flash_read(ptn + LOGO_IMG_HEADER_SIZE, 0, | |
- (uint32_t *)base, | |
- ((((header->width * header->height * fb_display->bpp/8) + 511) >> 9) << 9))) { | |
- fbcon_clear(); | |
- dprintf(CRITICAL, "ERROR: Cannot read splash image from partition\n"); | |
- return -1; | |
- } | |
- } | |
- | |
- return 0; | |
-} | |
- | |
-int splash_screen_mmc() | |
-{ | |
- int index = INVALID_PTN; | |
- unsigned long long ptn = 0; | |
- struct fbcon_config *fb_display = NULL; | |
- struct logo_img_header *header; | |
- uint32_t blocksize, realsize, readsize; | |
- uint8_t *base; | |
- | |
- index = partition_get_index("splash"); | |
- if (index == 0) { | |
- dprintf(CRITICAL, "ERROR: splash Partition table not found\n"); | |
- return -1; | |
- } | |
- | |
- ptn = partition_get_offset(index); | |
- if (ptn == 0) { | |
- dprintf(CRITICAL, "ERROR: splash Partition invalid\n"); | |
- return -1; | |
- } | |
- | |
- mmc_set_lun(partition_get_lun(index)); | |
- | |
- blocksize = mmc_get_device_blocksize(); | |
- if (blocksize == 0) { | |
- dprintf(CRITICAL, "ERROR:splash Partition invalid blocksize\n"); | |
- return -1; | |
- } | |
- | |
- fb_display = fbcon_display(); | |
- if (!fb_display) | |
- { | |
- dprintf(CRITICAL, "ERROR: fb config is not allocated\n"); | |
- return -1; | |
- } | |
- | |
- base = (uint8_t *) fb_display->base; | |
- | |
- if (mmc_read(ptn, (uint32_t *)(base + LOGO_IMG_OFFSET), blocksize)) { | |
- dprintf(CRITICAL, "ERROR: Cannot read splash image header\n"); | |
- return -1; | |
- } | |
- | |
- header = (struct logo_img_header *)(base + LOGO_IMG_OFFSET); | |
- if (splash_screen_check_header(header)) { | |
- dprintf(CRITICAL, "ERROR: Splash image header invalid\n"); | |
- return -1; | |
- } | |
- | |
- if (fb_display) { | |
- if (header->type && (header->blocks != 0)) { /* 1 RLE24 compressed data */ | |
- base += LOGO_IMG_OFFSET; | |
- | |
- realsize = header->blocks * 512; | |
- readsize = ROUNDUP((realsize + LOGO_IMG_HEADER_SIZE), blocksize) - blocksize; | |
- | |
- /* if the logo is not full-screen size, clean screen */ | |
- if ((header->width != fb_display->width) | |
- || (header->height != fb_display->height)) | |
- fbcon_clear(); | |
- | |
- uint32_t fb_size = ROUNDUP(fb_display->width * | |
- fb_display->height * | |
- (fb_display->bpp / 8), 4096); | |
- | |
- if (readsize > fb_size) { | |
- dprintf(CRITICAL, "ERROR: Splash image size invalid\n"); | |
- return -1; | |
- } | |
- | |
- if (mmc_read(ptn + blocksize, (uint32_t *)(base + blocksize), readsize)) { | |
- dprintf(CRITICAL, "ERROR: Cannot read splash image from partition\n"); | |
- return -1; | |
- } | |
- | |
- fbcon_extract_to_screen(header, (base + LOGO_IMG_HEADER_SIZE)); | |
- } else { /* 2 Raw BGR data */ | |
- | |
- if ((header->width > fb_display->width) || (header->height > fb_display->height)) { | |
- dprintf(CRITICAL, "Logo config greater than fb config. Fall back default logo\n"); | |
- return -1; | |
- } | |
- | |
- realsize = header->width * header->height * fb_display->bpp / 8; | |
- readsize = ROUNDUP((realsize + LOGO_IMG_HEADER_SIZE), blocksize) - blocksize; | |
- | |
- if (blocksize == LOGO_IMG_HEADER_SIZE) { /* read the content directly */ | |
- if (mmc_read((ptn + LOGO_IMG_HEADER_SIZE), (uint32_t *)base, readsize)) { | |
- fbcon_clear(); | |
- dprintf(CRITICAL, "ERROR: Cannot read splash image from partition\n"); | |
- return -1; | |
- } | |
- } else { | |
- if (mmc_read(ptn + blocksize , | |
- (uint32_t *)(base + LOGO_IMG_OFFSET + blocksize), readsize)) { | |
- dprintf(CRITICAL, "ERROR: Cannot read splash image from partition\n"); | |
- return -1; | |
- } | |
- memmove(base, (base + LOGO_IMG_OFFSET + LOGO_IMG_HEADER_SIZE), realsize); | |
- } | |
- } | |
- } | |
- | |
- return 0; | |
-} | |
- | |
-int fetch_image_from_partition() | |
-{ | |
- if (target_is_emmc_boot()) { | |
- return splash_screen_mmc(); | |
- } else { | |
- return splash_screen_flash(); | |
- } | |
-} | |
/* Get the size from partiton name */ | |
static void get_partition_size(const char *arg, char *response) | |
@@ -4244,20 +3837,6 @@ | |
{"continue", cmd_continue}, | |
{"reboot", cmd_reboot}, | |
{"reboot-bootloader", cmd_reboot_bootloader}, | |
- {"oem unlock", cmd_oem_unlock}, | |
- {"oem unlock-go", cmd_oem_unlock_go}, | |
- {"oem lock", cmd_oem_lock}, | |
- {"flashing unlock", cmd_oem_unlock}, | |
- {"flashing lock", cmd_oem_lock}, | |
- {"flashing lock_critical", cmd_flashing_lock_critical}, | |
- {"flashing unlock_critical", cmd_flashing_unlock_critical}, | |
- {"flashing get_unlock_ability", cmd_flashing_get_unlock_ability}, | |
- {"oem device-info", cmd_oem_devinfo}, | |
- {"preflash", cmd_preflash}, | |
- {"oem enable-charger-screen", cmd_oem_enable_charger_screen}, | |
- {"oem disable-charger-screen", cmd_oem_disable_charger_screen}, | |
- {"oem off-mode-charge", cmd_oem_off_mode_charger}, | |
- {"oem select-display-panel", cmd_oem_select_display_panel}, | |
{"set_active",cmd_set_active}, | |
#if UNITTEST_FW_SUPPORT | |
{"oem run-tests", cmd_oem_runtests}, | |
@@ -4340,8 +3919,11 @@ | |
} | |
ASSERT((MEMBASE + MEMSIZE) > MEMBASE); | |
- read_device_info(&device); | |
- read_allow_oem_unlock(&device); | |
+ device.is_unlocked = false; | |
+ device.is_tampered = false; | |
+ device.is_unlock_critical = false; | |
+ device.charger_screen_enabled = false; | |
+ device.verity_mode = true; | |
/* Detect multi-slot support */ | |
if (partition_multislot_is_supported()) | |
@@ -4349,7 +3931,7 @@ | |
boot_slot = partition_find_active_slot(); | |
if (boot_slot == INVALID) | |
{ | |
- boot_into_fastboot = true; | |
+ boot_into_recovery = true; | |
dprintf(INFO, "Active Slot: (INVALID)\n"); | |
} | |
else | |
@@ -4388,7 +3970,13 @@ | |
#endif | |
target_serialno((unsigned char *) sn_buf); | |
- dprintf(SPEW,"serial number: %s\n",sn_buf); | |
+ dprintf(INFO,"serial number: %s\n",sn_buf); | |
+ dprintf(INFO, "chip_serial: %d\n", board_chip_serial()); | |
+ | |
+#ifdef QSN_LOCK | |
+ ASSERT(board_chip_serial() == QSN_LOCK); | |
+ is_anki_dev = true; | |
+#endif | |
memset(display_panel_buf, '\0', MAX_PANEL_BUF_SIZE); | |
@@ -4399,27 +3987,11 @@ | |
if (is_user_force_reset()) | |
goto normal_boot; | |
- /* Check if we should do something other than booting up */ | |
- if (keys_get_state(KEY_VOLUMEUP) && keys_get_state(KEY_VOLUMEDOWN)) | |
+ if (keys_get_state(KEY_ESC)) | |
{ | |
- dprintf(ALWAYS,"dload mode key sequence detected\n"); | |
- reboot_device(EMERGENCY_DLOAD); | |
- dprintf(CRITICAL,"Failed to reboot into dload mode\n"); | |
- | |
- boot_into_fastboot = true; | |
+ boot_into_recovery = true; | |
+ boot_unbrick = true; | |
} | |
- if (!boot_into_fastboot) | |
- { | |
- if (keys_get_state(KEY_HOME) || keys_get_state(KEY_VOLUMEUP)) | |
- boot_into_recovery = 1; | |
- if (!boot_into_recovery && | |
- (keys_get_state(KEY_BACK) || keys_get_state(KEY_VOLUMEDOWN))) | |
- boot_into_fastboot = true; | |
- } | |
- #if NO_KEYPAD_DRIVER | |
- if (fastboot_trigger()) | |
- boot_into_fastboot = true; | |
- #endif | |
#if USE_PON_REBOOT_REG | |
reboot_mode = check_hard_reboot_mode(); | |
@@ -4485,12 +4057,12 @@ | |
retry_boot: | |
/* Trying to boot active partition */ | |
- if (partition_multislot_is_supported()) | |
+ if (partition_multislot_is_supported() && !boot_into_recovery) | |
{ | |
boot_slot = partition_find_boot_slot(); | |
partition_mark_active_slot(boot_slot); | |
if (boot_slot == INVALID) | |
- goto fastboot; | |
+ boot_into_recovery = true; | |
} | |
boot_err_type = boot_linux_from_mmc(); | |
@@ -4518,8 +4090,9 @@ | |
#endif | |
boot_linux_from_flash(); | |
} | |
- dprintf(CRITICAL, "ERROR: Could not do normal boot. Reverting " | |
- "to fastboot mode.\n"); | |
+ dprintf(CRITICAL, "ERROR: Could not do normal boot. Booting recovery\n"); | |
+ boot_into_recovery = true; | |
+ goto retry_boot; | |
} | |
fastboot: | |
diff -ru ./app/aboot/recovery.c ../opensource-1.6/bootable/bootloader/lk/app/aboot/recovery.c | |
--- ./app/aboot/recovery.c 2019-12-24 12:48:42.000000000 -0800 | |
+++ ../opensource-1.6/bootable/bootloader/lk/app/aboot/recovery.c 2019-04-12 15:12:01.000000000 -0700 | |
@@ -57,6 +57,7 @@ | |
static char buf[4096]; | |
unsigned boot_into_recovery = 0; | |
+unsigned boot_unbrick = 0; | |
extern uint32_t get_page_size(); | |
extern void reset_device_info(); | |
@@ -626,5 +627,3 @@ | |
free(ffbm_page_buffer); | |
return retval; | |
} | |
- | |
- | |
diff -ru ./app/aboot/recovery.h ../opensource-1.6/bootable/bootloader/lk/app/aboot/recovery.h | |
--- ./app/aboot/recovery.h 2019-12-24 12:48:24.000000000 -0800 | |
+++ ../opensource-1.6/bootable/bootloader/lk/app/aboot/recovery.h 2019-04-12 15:12:01.000000000 -0700 | |
@@ -90,5 +90,6 @@ | |
int get_ffbm(char *ffbm, unsigned size); | |
extern unsigned boot_into_recovery; | |
+extern unsigned boot_unbrick; | |
#endif | |
Only in ../opensource-1.6/bootable/bootloader/lk/lib/openssl/crypto/bn/asm: armv4-mont.S | |
Only in ./lib/openssl/crypto/bn/asm: armv4-mont.s | |
diff -ru ./makefile ../opensource-1.6/bootable/bootloader/lk/makefile | |
--- ./makefile 2019-12-24 12:48:54.000000000 -0800 | |
+++ ../opensource-1.6/bootable/bootloader/lk/makefile 2019-04-12 15:12:01.000000000 -0700 | |
@@ -62,6 +62,7 @@ | |
ifeq ($(TARGET_BUILD_VARIANT),user) | |
CFLAGS += -DDISABLE_FASTBOOT_CMDS=1 | |
+ CFLAGS += -DPROD_BOOT_KEY=1 | |
endif | |
ifeq ($(APPEND_CMDLINE),1) | |
@@ -75,6 +76,7 @@ | |
CFLAGS += -DENABLE_EARLY_ETHERNET=1 | |
endif | |
+ | |
# setup toolchain prefix | |
TOOLCHAIN_PREFIX ?= arm-eabi- | |
CFLAGS += -fstack-protector-all | |
@@ -82,7 +84,7 @@ | |
CPPFLAGS := -fno-exceptions -fno-rtti -fno-threadsafe-statics | |
#CPPFLAGS += -Weffc++ | |
ASMFLAGS := -DASSEMBLY | |
-LDFLAGS := | |
+LDFLAGS := | |
CFLAGS += -ffunction-sections -fdata-sections | |
LDFLAGS += -gc-sections | |
@@ -92,17 +94,17 @@ | |
# the following three object lists are identical except for the ordering | |
# which is bootobjs, kobjs, objs | |
-BOOTOBJS := | |
+BOOTOBJS := | |
OBJS := | |
# a linker script needs to be declared in one of the project/target/platform files | |
-LINKER_SCRIPT := | |
+LINKER_SCRIPT := | |
# anything you add here will be deleted in make clean | |
GENERATED := $(CONFIGHEADER) | |
# anything added to DEFINES will be put into $(BUILDDIR)/config.h | |
-DEFINES := LK=1 | |
+DEFINES := LK=1 | |
# Anything added to SRCDEPS will become a dependency of every source file in the system. | |
# Useful for header files that may be included by one or more source files. | |
@@ -123,6 +125,10 @@ | |
endif | |
endif | |
+ifdef QSN_LOCK | |
+ DEFINES += QSN_LOCK=$(QSN_LOCK) | |
+endif | |
+ | |
ifeq ($(OSVERSION_IN_BOOTIMAGE),1) | |
DEFINES += OSVERSION_IN_BOOTIMAGE=1 | |
endif | |
@@ -149,10 +155,10 @@ | |
MODULES := | |
# any rules you put here will also be built by the system before considered being complete | |
-EXTRA_BUILDDEPS := | |
+EXTRA_BUILDDEPS := | |
# any rules you put here will be depended on in clean builds | |
-EXTRA_CLEANDEPS := | |
+EXTRA_CLEANDEPS := | |
include project/$(PROJECT).mk | |
include target/$(TARGET)/rules.mk | |
@@ -196,7 +202,7 @@ | |
DEPS := $(ALLOBJS:%o=%d) | |
# default to no ccache | |
-CCACHE ?= | |
+CCACHE ?= | |
CC := $(CCACHE) $(TOOLCHAIN_PREFIX)gcc | |
ifeq ($(LD),ld) | |
LD := $(TOOLCHAIN_PREFIX)ld | |
Only in ../opensource-1.6/bootable/bootloader/lk/platform/msm_shared: LEOEMCertificate_prod.h | |
diff -ru ./platform/msm_shared/ab_partition_parser.c ../opensource-1.6/bootable/bootloader/lk/platform/msm_shared/ab_partition_parser.c | |
--- ./platform/msm_shared/ab_partition_parser.c 2019-12-24 12:48:59.000000000 -0800 | |
+++ ../opensource-1.6/bootable/bootloader/lk/platform/msm_shared/ab_partition_parser.c 2019-04-12 15:12:01.000000000 -0700 | |
@@ -281,22 +281,6 @@ | |
} | |
} | |
} | |
- | |
- /* All slots are zeroed, this is first bootup */ | |
- /* Marking and trying SLOT 0 as default */ | |
- if (count == AB_SUPPORTED_SLOTS) | |
- { | |
- /* Update the priority of the boot slot */ | |
- partition_entries[boot_slot_index[SLOT_A]].attribute_flag |= | |
- ((PART_ATT_PRIORITY_VAL | | |
- PART_ATT_ACTIVE_VAL | | |
- PART_ATT_MAX_RETRY_COUNT_VAL) & | |
- (~PART_ATT_SUCCESSFUL_VAL & | |
- ~PART_ATT_UNBOOTABLE_VAL)); | |
- if (!attributes_updated) | |
- attributes_updated = true; | |
- return SLOT_A; | |
- } | |
} | |
/* If no valid slot */ | |
return INVALID; | |
@@ -314,13 +298,13 @@ | |
} | |
/* NO Bootable slot */ | |
- panic("ERROR: Unable to find any bootable slot"); | |
- return 0; | |
+ return INVALID; | |
} | |
int partition_find_boot_slot() | |
{ | |
int boot_slot; | |
+ int next_slot; | |
int slt_index; | |
uint64_t boot_retry_count; | |
struct partition_entry *partition_entries = partition_get_partition_entries(); | |
@@ -351,7 +335,12 @@ | |
~PART_ATT_ACTIVE_VAL & | |
~PART_ATT_PRIORITY_VAL); | |
- partition_switch_slots(boot_slot, next_active_bootable_slot(partition_entries)); | |
+ next_slot = next_active_bootable_slot(partition_entries); | |
+ if (next_slot == INVALID) { | |
+ boot_slot = INVALID; | |
+ goto out; | |
+ } | |
+ partition_switch_slots(boot_slot, next_slot); | |
reboot_device(0); | |
} | |
diff -ru ./platform/msm_shared/debug.c ../opensource-1.6/bootable/bootloader/lk/platform/msm_shared/debug.c | |
--- ./platform/msm_shared/debug.c 2019-12-24 12:47:58.000000000 -0800 | |
+++ ../opensource-1.6/bootable/bootloader/lk/platform/msm_shared/debug.c 2019-04-12 15:12:01.000000000 -0700 | |
@@ -151,9 +151,11 @@ | |
#if PON_VIB_SUPPORT | |
vib_turn_off(); | |
#endif | |
+#if 0 | |
dprintf(CRITICAL, "HALT: reboot into dload mode...\n"); | |
- reboot_device(NORMAL_DLOAD); | |
- | |
+ reboot_device(FASTBOOT_MODE); /// ANKI DC make debugging kernel signing easier | |
+#else | |
dprintf(CRITICAL, "HALT: spinning forever...\n"); | |
for (;;) ; | |
+#endif | |
} | |
diff -ru ./platform/msm_shared/dev_tree.c ../opensource-1.6/bootable/bootloader/lk/platform/msm_shared/dev_tree.c | |
--- ./platform/msm_shared/dev_tree.c 2019-12-24 12:48:31.000000000 -0800 | |
+++ ../opensource-1.6/bootable/bootloader/lk/platform/msm_shared/dev_tree.c 2019-04-12 15:12:01.000000000 -0700 | |
@@ -622,7 +622,7 @@ | |
if((cur_dt_msm_id == (board_platform_id() & 0x0000ffff)) && | |
(cur_dt_hw_platform == board_hardware_id()) && | |
(cur_dt_hw_subtype == board_hardware_subtype()) && | |
- (cur_dt_hlos_ddr == (target_get_hlos_subtype() & 0x700)) && | |
+ +// XXX-NDM - to support 4Gb/8Gb w/same image (cur_dt_hlos_ddr == (target_get_hlos_subtype() & 0x700)) && | |
(cur_dt_entry->soc_rev <= board_soc_version()) && | |
((cur_dt_entry->variant_id & 0x00ffff00) <= (board_target_id() & 0x00ffff00)) && | |
((cur_dt_entry->pmic_rev[0] & 0x00ffff00) <= (board_pmic_target(0) & 0x00ffff00)) && | |
diff -ru ./platform/msm_shared/display_menu.c ../opensource-1.6/bootable/bootloader/lk/platform/msm_shared/display_menu.c | |
--- ./platform/msm_shared/display_menu.c 2019-12-24 12:48:59.000000000 -0800 | |
+++ ../opensource-1.6/bootable/bootloader/lk/platform/msm_shared/display_menu.c 2019-04-12 15:12:01.000000000 -0700 | |
@@ -56,21 +56,19 @@ | |
"or No. Then press the Power button to continue.\n"; | |
#define YELLOW_WARNING_MSG "Your device has loaded a different operating system\n\n "\ | |
- "Visit this link on another device:\n" | |
+ "Visit this link on another device:\n g.co/ABH" | |
#define ORANGE_WARNING_MSG "Your device software can't be\n checked for corruption. Please lock the bootloader\n\n"\ | |
- "Visit this link on another device:\n" | |
+ "Visit this link on another device:\n g.co/ABH" | |
#define RED_WARNING_MSG "Your device is corrupt. It can't be\ntrusted and will not boot\n\n" \ | |
- "Visit this link on another device:\n" | |
+ "Visit this link on another device:\n g.co/ABH" | |
#define LOGGING_WARNING_MSG "The dm-verity is not started in enforcing mode and may "\ | |
"not work properly\n\nTo learn more, visit:\n" | |
#define EIO_WARNING_MSG "Your device is corrupt. It can't be\n trusted and may not work properly.\n\n"\ | |
- "Visit this link on another device:\n" | |
- | |
-#define URL_MSG "g.co/ABH\n" | |
+ "Visit this link on another device:\n g.co/ABH" | |
#define DELAY_5SEC 5000 | |
#define DELAY_30SEC 30000 | |
@@ -82,15 +80,14 @@ | |
struct boot_verify_info { | |
int msg_type; | |
const char *warning_msg; | |
- const char *url_msg; | |
}; | |
struct boot_verify_info boot_verify_info[] = { | |
- [DISPLAY_MENU_RED] = {FBCON_RED_MSG, RED_WARNING_MSG, URL_MSG}, | |
- [DISPLAY_MENU_YELLOW] = {FBCON_YELLOW_MSG, YELLOW_WARNING_MSG, URL_MSG}, | |
- [DISPLAY_MENU_ORANGE] = {FBCON_ORANGE_MSG, ORANGE_WARNING_MSG, URL_MSG}, | |
- [DISPLAY_MENU_LOGGING] = {FBCON_RED_MSG, LOGGING_WARNING_MSG, NULL}, | |
- [DISPLAY_MENU_EIO] = {FBCON_RED_MSG, EIO_WARNING_MSG, URL_MSG}}; | |
+ [DISPLAY_MENU_RED] = {FBCON_RED_MSG, RED_WARNING_MSG}, | |
+ [DISPLAY_MENU_YELLOW] = {FBCON_YELLOW_MSG, YELLOW_WARNING_MSG}, | |
+ [DISPLAY_MENU_ORANGE] = {FBCON_ORANGE_MSG, ORANGE_WARNING_MSG}, | |
+ [DISPLAY_MENU_LOGGING] = {FBCON_RED_MSG, LOGGING_WARNING_MSG}, | |
+ [DISPLAY_MENU_EIO] = {FBCON_RED_MSG, EIO_WARNING_MSG}}; | |
#endif | |
static char *verify_option_menu[] = { | |
@@ -289,9 +286,8 @@ | |
display_fbcon_menu_message((char*)boot_verify_info[type].warning_msg, | |
FBCON_COMMON_MSG, common_factor); | |
- if(boot_verify_info[type].url_msg != NULL) | |
- display_fbcon_menu_message((char*)boot_verify_info[type].url_msg, | |
- boot_verify_info[type].msg_type, common_factor); | |
+ display_fbcon_menu_message("g.co/placeholder\n", | |
+ boot_verify_info[type].msg_type, common_factor); | |
if (type == DISPLAY_MENU_YELLOW) { | |
fp_buf = get_boot_fingerprint(&fp_size); | |
diff -ru ./platform/msm_shared/image_verify.c ../opensource-1.6/bootable/bootloader/lk/platform/msm_shared/image_verify.c | |
--- ./platform/msm_shared/image_verify.c 2019-12-24 12:48:54.000000000 -0800 | |
+++ ../opensource-1.6/bootable/bootloader/lk/platform/msm_shared/image_verify.c 2019-04-12 15:12:01.000000000 -0700 | |
@@ -34,7 +34,11 @@ | |
#include "image_verify.h" | |
#include "scm.h" | |
+#ifdef PROD_BOOT_KEY | |
+#include <LEOEMCertificate_prod.h> | |
+#else | |
#include <LEOEMCertificate.h> | |
+#endif | |
const char hash_identifier[] = { | |
0x30, 0x31, 0x30, 0x0D, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, | |
diff -ru ./project/msm8909.mk ../opensource-1.6/bootable/bootloader/lk/project/msm8909.mk | |
--- ./project/msm8909.mk 2019-12-24 12:48:59.000000000 -0800 | |
+++ ../opensource-1.6/bootable/bootloader/lk/project/msm8909.mk 2019-04-12 15:12:01.000000000 -0700 | |
@@ -48,7 +48,7 @@ | |
#DEFINES += ENABLE_FBCON_LOGGING=1 | |
#Enable the feature of long press power on | |
-DEFINES += LONG_PRESS_POWER_ON=1 | |
+DEFINES += LONG_PRESS_POWER_ON=0 | |
ifeq ($(ENABLE_RPMB_SUPPORT),1) | |
DEFINES += USE_RPMB_FOR_DEVINFO=1 | |
diff -ru ./target/apq8084/init.c ../opensource-1.6/bootable/bootloader/lk/target/apq8084/init.c | |
--- ./target/apq8084/init.c 2019-12-24 12:48:59.000000000 -0800 | |
+++ ../opensource-1.6/bootable/bootloader/lk/target/apq8084/init.c 2019-04-12 15:12:01.000000000 -0700 | |
@@ -1,4 +1,4 @@ | |
-/* Copyright (c) 2013-2015, 2017, The Linux Foundation. All rights reserved. | |
+/* Copyright (c) 2013-2015, The Linux Foundation. All rights reserved. | |
* | |
* Redistribution and use in source and binary forms, with or without | |
* modification, are permitted provided that the following conditions are | |
@@ -330,8 +330,8 @@ | |
} | |
size = partition_get_size(index); | |
- if ((size == 0) || ((ULLONG_MAX - CACHE_LINE + 1) < size)) { | |
- dprintf(CRITICAL, "Error: invalid ssd partition size %d\n",size); | |
+ if (size == 0) { | |
+ dprintf(CRITICAL, "Error: invalid ssd partition size\n"); | |
return; | |
} | |
diff -ru ./target/init.c ../opensource-1.6/bootable/bootloader/lk/target/init.c | |
--- ./target/init.c 2019-12-24 12:48:59.000000000 -0800 | |
+++ ../opensource-1.6/bootable/bootloader/lk/target/init.c 2019-04-12 15:12:01.000000000 -0700 | |
@@ -307,24 +307,13 @@ | |
} | |
#endif | |
-#if VERIFIED_BOOT_LE | |
-int verified_boot_le = 1; | |
-#else | |
-int verified_boot_le = 0; | |
-#endif | |
- | |
int is_vb_le_enabled(void) | |
{ | |
- uint32_t platform = board_platform_id(); | |
- | |
- switch(platform) | |
- { | |
- case APQ8053: | |
- return verified_boot_le; | |
- default: | |
- break; | |
- } | |
- return 0; | |
+ #if VERIFIED_BOOT_LE | |
+ return 1; | |
+ #else | |
+ return 0; | |
+ #endif | |
} | |
#if PON_VIB_SUPPORT | |
diff -ru ./target/msm8909/init.c ../opensource-1.6/bootable/bootloader/lk/target/msm8909/init.c | |
--- ./target/msm8909/init.c 2019-12-24 12:48:59.000000000 -0800 | |
+++ ../opensource-1.6/bootable/bootloader/lk/target/msm8909/init.c 2019-04-12 15:12:01.000000000 -0700 | |
@@ -66,6 +66,8 @@ | |
#define TLMM_VOL_UP_BTN_GPIO 90 | |
#define TLMM_VOL_DOWN_BTN_GPIO 91 | |
+#define ANKI_SPINE_RX_GPIO 21 | |
+ | |
#if PON_VIB_SUPPORT | |
#define VIBRATE_TIME 250 | |
#endif | |
@@ -231,6 +233,18 @@ | |
return !status; | |
} | |
+uint32_t target_esc_down() | |
+{ | |
+ uint32_t status = 0; | |
+ gpio_tlmm_config(ANKI_SPINE_RX_GPIO, 0, GPIO_INPUT, GPIO_PULL_UP, GPIO_2MA, GPIO_ENABLE); | |
+ thread_sleep(10); // Wait for the gpio config to take effect | |
+ for (unsigned i=0; i<1000; ++i) | |
+ { | |
+ if (gpio_status(ANKI_SPINE_RX_GPIO)) return 0; | |
+ } | |
+ return 1; | |
+} | |
+ | |
/* Return 1 if vol_down pressed */ | |
uint32_t target_volume_down() | |
{ | |
@@ -258,12 +272,15 @@ | |
{ | |
keys_init(); | |
- if(target_volume_down()) | |
- keys_post_event(KEY_VOLUMEDOWN, 1); | |
- | |
- if(target_volume_up()) | |
- keys_post_event(KEY_VOLUMEUP, 1); | |
- | |
+ if (target_esc_down()) | |
+ { | |
+ dprintf(INFO, "INFO: target_esc_down=1\n"); | |
+ keys_post_event(KEY_ESC, 1); | |
+ } | |
+ else | |
+ { | |
+ dprintf(INFO, "INFO: target_esc_down=0\n"); | |
+ } | |
} | |
static void set_sdc_power_ctrl() | |
@@ -530,89 +547,102 @@ | |
{ | |
struct ptable *ptable; | |
int system_ptn_index = -1; | |
- int le_based = -1; | |
uint32_t buflen = 0; | |
if (!cmdline || !part ) { | |
dprintf(CRITICAL, "WARN: Invalid input param\n"); | |
return -1; | |
} | |
+ | |
+ system_ptn_index = partition_get_index(part); | |
+ if (system_ptn_index < 0) { | |
+ dprintf(CRITICAL, | |
+ "WARN: Cannot get partition index for %s\n", part); | |
+ return -1; | |
+ } | |
- /*LE partition.xml will have recoveryfs partition*/ | |
- if (target_is_emmc_boot()) | |
- le_based = partition_get_index("recoveryfs"); | |
- else | |
- /*Nand targets by default have this*/ | |
- le_based = 1; | |
- | |
- if (le_based != -1) | |
+ if (strstr(cmdline, "dm=") == NULL) // Not a DM verity enabled kernel | |
{ | |
- if (!target_is_emmc_boot()) | |
+ if (strstr(cmdline, "root=") != NULL) // But has a root= argument! | |
{ | |
- ptable = flash_get_ptable(); | |
- if (!ptable) | |
- { | |
- dprintf(CRITICAL, | |
- "WARN: Cannot get flash partition table\n"); | |
- return -1; | |
- } | |
- system_ptn_index = ptable_get_index(ptable, part); | |
- } | |
- else | |
- system_ptn_index = partition_get_index(part); | |
- if (system_ptn_index < 0) { | |
- dprintf(CRITICAL, | |
- "WARN: Cannot get partition index for %s\n", part); | |
- return -1; | |
- } | |
- /* | |
- * check if cmdline contains "root=" at the beginning of buffer or | |
- * " root=" in the middle of buffer. | |
- */ | |
- if (((!strncmp(cmdline, "root=", strlen("root="))) || | |
- (strstr(cmdline, " root=")))) { | |
dprintf(DEBUG, "DEBUG: cmdline has root=\n"); | |
return -1; | |
} | |
else | |
- /*in success case buf will be freed in the calling function of this*/ | |
{ | |
- if (!target_is_emmc_boot()) | |
- { | |
- buflen = strlen(UBI_CMDLINE) + strlen(" root=ubi0:rootfs ubi.mtd=") + sizeof(int) + 1; /* 1 byte for null character*/ | |
+ static const char* root_part_fmt = " root=/dev/mmcblk0p%d"; | |
+ buflen = strlen(root_part_fmt) + 3; // 2 characters of number + null termination | |
- /* In success case, this memory is freed in calling function */ | |
- *buf = (char *)malloc(buflen); | |
- if(!(*buf)) { | |
- dprintf(CRITICAL,"Unable to allocate memory for boot params \n"); | |
- return -1; | |
- } | |
- | |
- /* Adding command line parameters according to target boot type */ | |
- snprintf(*buf, buflen, UBI_CMDLINE); | |
- snprintf(*buf+strlen(*buf), buflen, " root=ubi0:rootfs ubi.mtd=%d", system_ptn_index); | |
+ // In success case, this memory is freed in calling function | |
+ *buf = (char *)malloc(buflen); | |
+ if(!(*buf)) { | |
+ dprintf(CRITICAL,"Unable to allocate memory for boot params \n"); | |
+ return -1; | |
} | |
- else | |
- { | |
- /* Extra character is for Null termination */ | |
- buflen = strlen(" root=/dev/mmcblk0p") + sizeof(int) + 1; | |
- /* In success case, this memory is freed in calling function */ | |
- *buf = (char *)malloc(buflen); | |
- if(!(*buf)) { | |
- dprintf(CRITICAL,"Unable to allocate memory for boot params \n"); | |
- return -1; | |
- } | |
+ // For Emmc case increase the ptn_index by 1 | |
+ snprintf(*buf, buflen, root_part_fmt, system_ptn_index + 1); | |
+ return 0; | |
+ } | |
+ } | |
+ | |
+ else // DM Verity enabled kernel | |
+ { | |
+ static const char* search = "##SYSTEM_BOOT_PART##"; | |
- /*For Emmc case increase the ptn_index by 1*/ | |
- snprintf(*buf, buflen, " root=/dev/mmcblk0p%d",system_ptn_index + 1); | |
- } | |
+ char *p; | |
+ char *q; | |
+ size_t count; | |
+ size_t search_len; | |
+ size_t replace_len; | |
+ size_t cmdline_len; | |
+ | |
+ #define DM_MAX_REPLACE 1024 | |
+ static char replace[DM_MAX_REPLACE]; | |
+ | |
+ // Find number of occurences of the search pattern in cmdline | |
+ count = 0; | |
+ p = cmdline; | |
+ search_len = strlen(search); | |
+ while ((p = strstr(p,search))) { | |
+ ++count; | |
+ p += search_len; | |
+ } | |
+ | |
+ if (count == 0) { | |
+ *buf = NULL; | |
+ dprintf(CRITICAL, "Unable to locate system boot part token\n"); | |
+ return -1; | |
} | |
- /*Return for LE based Targets.*/ | |
- return 0; | |
+ replace_len = snprintf(replace,DM_MAX_REPLACE,"%d",system_ptn_index + 1); | |
+ cmdline_len = strlen(cmdline); | |
+ buflen = cmdline_len + ((replace_len - search_len) * count) + 1; | |
+ | |
+ // In success case, this memory is freed in calling function | |
+ *buf = (char *)malloc(buflen); | |
+ if(!(*buf)) { | |
+ dprintf(CRITICAL,"Unable to allocate memory for boot params \n"); | |
+ return -1; | |
+ } | |
+ memset(*buf,'\0',buflen); | |
+ | |
+ p = cmdline; | |
+ while ((q = strstr(p,search))) { | |
+ int l = q-p; | |
+ strncat(*buf, p, l); | |
+ strncat(*buf, replace, replace_len); | |
+ p = q + search_len; | |
+ } | |
+ | |
+ //copy last chunk | |
+ if(p < cmdline+cmdline_len) { | |
+ strncat(*buf, p, cmdline+cmdline_len-p); | |
+ } | |
+ | |
+ return 1; // target command line replaces input cmdline | |
+ | |
} | |
- return -1; | |
} | |
unsigned target_baseband() | |
@@ -622,7 +652,7 @@ | |
int emmc_recovery_init(void) | |
{ | |
- return _emmc_recovery_init(); | |
+ return 0; // Recovery is just another boot mode for victor, no need to support all this fancyness | |
} | |
void target_usb_init(void) | |
diff -ru ./target/msm8953/init.c ../opensource-1.6/bootable/bootloader/lk/target/msm8953/init.c | |
--- ./target/msm8953/init.c 2019-12-24 12:48:59.000000000 -0800 | |
+++ ../opensource-1.6/bootable/bootloader/lk/target/msm8953/init.c 2019-04-12 15:12:01.000000000 -0700 | |
@@ -263,23 +263,6 @@ | |
dprintf(INFO, "target_init()\n"); | |
spmi_init(PMIC_ARB_CHANNEL_NUM, PMIC_ARB_OWNER_ID); | |
- if(target_is_pmi_enabled()) | |
- { | |
- if(platform_is_msm8953()) | |
- { | |
- uint8_t pmi_rev = 0; | |
- uint32_t pmi_type = 0; | |
- | |
- pmi_type = board_pmic_target(1) & 0xffff; | |
- if(pmi_type == PMIC_IS_PMI8950) | |
- { | |
- /* read pmic spare register for rev */ | |
- pmi_rev = pmi8950_get_pmi_subtype(); | |
- if(pmi_rev) | |
- board_pmi_target_set(1,pmi_rev); | |
- } | |
- } | |
- } | |
target_keystatus(); | |
Only in ../opensource-1.6/bootable/bootloader/lk/target/msm8974: pc-x86 | |
Only in ./target: pc-x86 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment