summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--arch/arm/cpu/armv7/mx6/soc.c48
-rw-r--r--arch/arm/cpu/armv7/mx7/soc.c51
-rw-r--r--board/freescale/common/recovery.c5
-rw-r--r--board/freescale/mx6qsabreauto/mx6qsabreauto.c7
-rw-r--r--board/freescale/mx6sabresd/mx6sabresd.c7
-rw-r--r--board/freescale/mx6slevk/mx6slevk.c8
-rw-r--r--board/freescale/mx6sxsabreauto/mx6sxsabreauto.c8
-rw-r--r--board/freescale/mx6sxsabresd/mx6sxsabresd.c7
-rw-r--r--board/freescale/mx7dsabresd/mx7dsabresd.c7
-rw-r--r--drivers/usb/gadget/command.c87
-rw-r--r--drivers/usb/gadget/f_fastboot.c12
-rw-r--r--include/configs/mx6sabreandroid_common.h2
-rw-r--r--include/configs/mx6sxsabreautoandroid.h2
-rw-r--r--include/fsl_fastboot.h6
-rw-r--r--include/recovery.h3
15 files changed, 108 insertions, 152 deletions
diff --git a/arch/arm/cpu/armv7/mx6/soc.c b/arch/arm/cpu/armv7/mx6/soc.c
index ba768e3..9a4228c 100644
--- a/arch/arm/cpu/armv7/mx6/soc.c
+++ b/arch/arm/cpu/armv7/mx6/soc.c
@@ -1074,52 +1074,4 @@ void clear_boot_reason()
writel(reg, SNVS_BASE_ADDR + SNVS_LPGPR);
}
#endif
-#ifdef CONFIG_ANDROID_RECOVERY
-#define ANDROID_RECOVERY_BOOT (1 << 7)
-/* check if the recovery bit is set by kernel, it can be set by kernel
- * issue a command '# reboot recovery' */
-int recovery_check_and_clean_flag(void)
-{
- int flag_set = 0;
- u32 reg;
- reg = readl(SNVS_BASE_ADDR + SNVS_LPGPR);
-
- flag_set = !!(reg & ANDROID_RECOVERY_BOOT);
- printf("check_and_clean: reg %x, flag_set %d\n", reg, flag_set);
- /* clean it in case looping infinite here.... */
- if (flag_set) {
- reg &= ~ANDROID_RECOVERY_BOOT;
- writel(reg, SNVS_BASE_ADDR + SNVS_LPGPR);
- }
-
- return flag_set;
-}
-#endif /*CONFIG_ANDROID_RECOVERY*/
-
-#define ANDROID_FASTBOOT_BOOT (1 << 8)
-/* check if the recovery bit is set by kernel, it can be set by kernel
- * issue a command '# reboot fastboot' */
-int fastboot_check_and_clean_flag(void)
-{
- int flag_set = 0;
- u32 reg;
-
- reg = readl(SNVS_BASE_ADDR + SNVS_LPGPR);
-
- flag_set = !!(reg & ANDROID_FASTBOOT_BOOT);
-
- /* clean it in case looping infinite here.... */
- if (flag_set) {
- reg &= ~ANDROID_FASTBOOT_BOOT;
- writel(reg, SNVS_BASE_ADDR + SNVS_LPGPR);
- }
-
- return flag_set;
-}
-
-void fastboot_enable_flag(void)
-{
- setbits_le32(SNVS_BASE_ADDR + SNVS_LPGPR,
- ANDROID_FASTBOOT_BOOT);
-}
#endif /*CONFIG_FSL_FASTBOOT*/
diff --git a/arch/arm/cpu/armv7/mx7/soc.c b/arch/arm/cpu/armv7/mx7/soc.c
index f807a55..bda4828 100644
--- a/arch/arm/cpu/armv7/mx7/soc.c
+++ b/arch/arm/cpu/armv7/mx7/soc.c
@@ -485,56 +485,5 @@ void clear_boot_reason()
writel(reg, SNVS_BASE_ADDR + SNVS_LPGPR);
}
#endif
-#ifdef CONFIG_ANDROID_RECOVERY
-#define ANDROID_RECOVERY_BOOT (1 << 7)
-/*
- * check if the recovery bit is set by kernel, it can be set by kernel
- * issue a command '# reboot recovery'
- */
-int recovery_check_and_clean_flag(void)
-{
- int flag_set = 0;
- u32 reg;
- reg = readl(SNVS_BASE_ADDR + SNVS_LPGPR);
-
- flag_set = !!(reg & ANDROID_RECOVERY_BOOT);
- printf("check_and_clean: reg %x, flag_set %d\n", reg, flag_set);
- /* clean it in case looping infinite here.... */
- if (flag_set) {
- reg &= ~ANDROID_RECOVERY_BOOT;
- writel(reg, SNVS_BASE_ADDR + SNVS_LPGPR);
- }
-
- return flag_set;
-}
-#endif /*CONFIG_ANDROID_RECOVERY*/
-
-#define ANDROID_FASTBOOT_BOOT (1 << 8)
-/*
- * check if the recovery bit is set by kernel, it can be set by kernel
- * issue a command '# reboot fastboot'
- */
-int fastboot_check_and_clean_flag(void)
-{
- int flag_set = 0;
- u32 reg;
-
- reg = readl(SNVS_BASE_ADDR + SNVS_LPGPR);
-
- flag_set = !!(reg & ANDROID_FASTBOOT_BOOT);
- /* clean it in case looping infinite here.... */
- if (flag_set) {
- reg &= ~ANDROID_FASTBOOT_BOOT;
- writel(reg, SNVS_BASE_ADDR + SNVS_LPGPR);
- }
-
- return flag_set;
-}
-
-void fastboot_enable_flag(void)
-{
- setbits_le32(SNVS_BASE_ADDR + SNVS_LPGPR,
- ANDROID_FASTBOOT_BOOT);
-}
#endif /*CONFIG_FSL_FASTBOOT*/
diff --git a/board/freescale/common/recovery.c b/board/freescale/common/recovery.c
index 9fa31c4..396bc73 100644
--- a/board/freescale/common/recovery.c
+++ b/board/freescale/common/recovery.c
@@ -72,11 +72,6 @@ void check_recovery_mode(void)
} else if (check_recovery_cmd_file()) {
puts("Fastboot: Recovery command file found!\n");
setup_recovery_env();
-#ifdef CONFIG_BCB_SUPPORT
- } else if (recovery_check_and_clean_command()) {
- puts("Fastboot: BCB command found\n");
- setup_recovery_env();
-#endif
} else {
puts("Fastboot: Normal\n");
}
diff --git a/board/freescale/mx6qsabreauto/mx6qsabreauto.c b/board/freescale/mx6qsabreauto/mx6qsabreauto.c
index 21362a4..3588f19 100644
--- a/board/freescale/mx6qsabreauto/mx6qsabreauto.c
+++ b/board/freescale/mx6qsabreauto/mx6qsabreauto.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012-2015 Freescale Semiconductor, Inc.
+ * Copyright (C) 2012-2016 Freescale Semiconductor, Inc.
*
* Author: Fabio Estevam <fabio.estevam@freescale.com>
*
@@ -1032,8 +1032,9 @@ int check_recovery_cmd_file(void)
int button_pressed = 0;
int recovery_mode = 0;
- recovery_mode = recovery_check_and_clean_flag();
-
+#ifdef CONFIG_BCB_SUPPORT
+ recovery_mode = recovery_check_and_clean_command();
+#endif
/* Check Recovery Combo Button press or not. */
imx_iomux_v3_setup_multiple_pads(recovery_key_pads,
ARRAY_SIZE(recovery_key_pads));
diff --git a/board/freescale/mx6sabresd/mx6sabresd.c b/board/freescale/mx6sabresd/mx6sabresd.c
index 88f5d96..cd9dd83 100644
--- a/board/freescale/mx6sabresd/mx6sabresd.c
+++ b/board/freescale/mx6sabresd/mx6sabresd.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012-2015 Freescale Semiconductor, Inc.
+ * Copyright (C) 2012-2016 Freescale Semiconductor, Inc.
*
* Author: Fabio Estevam <fabio.estevam@freescale.com>
*
@@ -1256,8 +1256,9 @@ int check_recovery_cmd_file(void)
int button_pressed = 0;
int recovery_mode = 0;
- recovery_mode = recovery_check_and_clean_flag();
-
+#ifdef CONFIG_BCB_SUPPORT
+ recovery_mode = recovery_check_and_clean_command();
+#endif
/* Check Recovery Combo Button press or not. */
imx_iomux_v3_setup_multiple_pads(recovery_key_pads,
ARRAY_SIZE(recovery_key_pads));
diff --git a/board/freescale/mx6slevk/mx6slevk.c b/board/freescale/mx6slevk/mx6slevk.c
index b94fdf0..3a71295 100644
--- a/board/freescale/mx6slevk/mx6slevk.c
+++ b/board/freescale/mx6slevk/mx6slevk.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013-2015 Freescale Semiconductor, Inc.
+ * Copyright (C) 2013-2016 Freescale Semiconductor, Inc.
*
* Author: Fabio Estevam <fabio.estevam@freescale.com>
*
@@ -876,7 +876,11 @@ void board_fastboot_setup(void)
#ifdef CONFIG_ANDROID_RECOVERY
int check_recovery_cmd_file(void)
{
- return recovery_check_and_clean_flag();
+#ifdef CONFIG_BCB_SUPPORT
+ return recovery_check_and_clean_command();
+#else
+ return 0;
+#endif
}
void board_recovery_setup(void)
diff --git a/board/freescale/mx6sxsabreauto/mx6sxsabreauto.c b/board/freescale/mx6sxsabreauto/mx6sxsabreauto.c
index 43a2e3f..e84f1a6 100644
--- a/board/freescale/mx6sxsabreauto/mx6sxsabreauto.c
+++ b/board/freescale/mx6sxsabreauto/mx6sxsabreauto.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014-2015 Freescale Semiconductor, Inc.
+ * Copyright (C) 2014-2016 Freescale Semiconductor, Inc.
*
* SPDX-License-Identifier: GPL-2.0+
*/
@@ -886,9 +886,9 @@ void board_fastboot_setup(void)
int check_recovery_cmd_file(void)
{
int recovery_mode = 0;
-
- recovery_mode = recovery_check_and_clean_flag();
-
+#ifdef CONFIG_BCB_SUPPORT
+ recovery_mode = recovery_check_and_clean_command();
+#endif
return recovery_mode;
}
diff --git a/board/freescale/mx6sxsabresd/mx6sxsabresd.c b/board/freescale/mx6sxsabresd/mx6sxsabresd.c
index 3b238e7..d475752 100644
--- a/board/freescale/mx6sxsabresd/mx6sxsabresd.c
+++ b/board/freescale/mx6sxsabresd/mx6sxsabresd.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014-2015 Freescale Semiconductor, Inc.
+ * Copyright (C) 2014-2016 Freescale Semiconductor, Inc.
*
* Author: Fabio Estevam <fabio.estevam@freescale.com>
*
@@ -970,8 +970,9 @@ int check_recovery_cmd_file(void)
int button_pressed = 0;
int recovery_mode = 0;
- recovery_mode = recovery_check_and_clean_flag();
-
+#ifdef CONFIG_BCB_SUPPORT
+ recovery_mode = recovery_check_and_clean_command();
+#endif
/* Check Recovery Combo Button press or not. */
imx_iomux_v3_setup_multiple_pads(recovery_key_pads,
ARRAY_SIZE(recovery_key_pads));
diff --git a/board/freescale/mx7dsabresd/mx7dsabresd.c b/board/freescale/mx7dsabresd/mx7dsabresd.c
index 870db58..f9e8e17 100644
--- a/board/freescale/mx7dsabresd/mx7dsabresd.c
+++ b/board/freescale/mx7dsabresd/mx7dsabresd.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015 Freescale Semiconductor, Inc.
+ * Copyright (C) 2015-2016 Freescale Semiconductor, Inc.
*
* SPDX-License-Identifier: GPL-2.0+
*/
@@ -1187,8 +1187,9 @@ int check_recovery_cmd_file(void)
int button_pressed = 0;
int recovery_mode = 0;
- recovery_mode = recovery_check_and_clean_flag();
-
+#ifdef CONFIG_BCB_SUPPORT
+ recovery_mode = recovery_check_and_clean_command();
+#endif
/* Check Recovery Combo Button press or not. */
imx_iomux_v3_setup_multiple_pads(recovery_key_pads,
ARRAY_SIZE(recovery_key_pads));
diff --git a/drivers/usb/gadget/command.c b/drivers/usb/gadget/command.c
index 3af3fcf..9693022 100644
--- a/drivers/usb/gadget/command.c
+++ b/drivers/usb/gadget/command.c
@@ -6,10 +6,13 @@
#include <common.h>
#include <g_dnl.h>
+#ifdef CONFIG_FASTBOOT_STORAGE_NAND
+#include <nand.h>
+#endif
#include "bcb.h"
-#ifndef CONFIG_FASTBOOT_STORAGE_NAND
static char command[32];
+#ifndef CONFIG_FASTBOOT_STORAGE_NAND
static int read_command(char *command)
{
int ret = 0;
@@ -62,44 +65,94 @@ static int write_command(char *bcb_command)
return 0;
}
-int recovery_check_and_clean_command(void)
+#else
+#define ALIGN_BYTES 64
+#define MISC_PAGES 3
+static int read_command(char *command)
+{
+ char read_cmd[128];
+ char *addr_str;
+ char *nand_str;
+ ulong misc_info_size;
+ nand_info_t *nand = &nand_info[0];
+ if (command == NULL)
+ return -1;
+ memset(read_cmd, 0, 128);
+ misc_info_size = MISC_PAGES * nand->writesize;
+ nand_str = (char *)memalign(ALIGN_BYTES, misc_info_size);
+ sprintf(read_cmd, "nand read 0x%x ${misc_nand_offset} \
+ 0x%x", nand_str, misc_info_size);
+ run_command(read_cmd, 0);
+ /* The offset of bootloader_message is 1 PAGE.
+ The offset of bootloader_message and the size of misc info
+ need align with user space and recovery.
+ */
+ addr_str = nand_str + nand->writesize;
+ memcpy(command, (char *)addr_str, 32);
+ free(nand_str);
+ return 0;
+}
+static int write_command(char *command)
+{
+ char cmd[128];
+ char *addr_str;
+ char *nand_str;
+ ulong misc_info_size;
+ nand_info_t *nand = &nand_info[0];
+ if (command == NULL)
+ return -1;
+ memset(cmd, 0, 128);
+ misc_info_size = MISC_PAGES * nand->writesize;
+ nand_str = (char *)memalign(ALIGN_BYTES, misc_info_size);
+ sprintf(cmd, "nand read 0x%x ${misc_nand_offset} \
+ 0x%x", nand_str, misc_info_size);
+ run_command(cmd, 0);
+ /* the offset of bootloader_message is 1 PAGE*/
+ addr_str = nand_str + nand->writesize;
+ memcpy((char *)addr_str, command, 32);
+ /* erase 3 pages which hold BCB struct.*/
+ sprintf(cmd, "nand erase ${misc_nand_offset} 0x%x",nand->erasesize);
+ run_command(cmd, 0);
+ sprintf(cmd, "nand write 0x%x ${misc_nand_offset} 0x%x",nand_str, misc_info_size);
+ run_command(cmd, 0);
+ free(nand_str);
+ return 0;
+}
+#endif
+bool recovery_check_and_clean_command(void)
{
int ret;
ret = read_command(command);
if (ret < 0) {
printf("read command failed\n");
- return 0;
+ return false;
}
if (!strcmp(command, "boot-recovery")) {
memset(command, 0, 32);
write_command(command);
- return 1;
+ return true;
}
- return 0;
+ return false;
}
-int fastboot_check_and_clean_command(void)
+bool fastboot_check_and_clean_command(void)
{
int ret;
ret = read_command(command);
if (ret < 0) {
printf("read command failed\n");
- return 0;
+ return false;
}
if (!strcmp(command, "boot-bootloader")) {
memset(command, 0, 32);
write_command(command);
- return 1;
+ return true;
}
- return 0;
+ return false;
}
-#else
-int recovery_check_and_clean_command(void)
-{
- return 0;
-}
-int fastboot_check_and_clean_command(void)
+void fastboot_enable_command(void)
{
- return 0;
+ char fastboot_command[32];
+ memcpy(fastboot_command,"boot-bootloader",32);
+ write_command(fastboot_command);
}
-#endif
diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index 89b5f24..42fd5ac 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -1565,21 +1565,21 @@ void fastboot_setup(void)
/*get the fastboot dev*/
_fastboot_setup_dev();
+ /*load partitions information for the fastboot dev*/
+ _fastboot_load_partitions();
+
/*check if we need to setup recovery*/
#ifdef CONFIG_ANDROID_RECOVERY
- check_recovery_mode();
+ check_recovery_mode();
#endif
- /*load partitions information for the fastboot dev*/
- _fastboot_load_partitions();
-
parameters_setup();
}
/* export to lib_arm/board.c */
void check_fastboot(void)
{
- if (fastboot_check_and_clean_flag())
+ if (fastboot_check_and_clean_command())
run_command("fastboot", 0);
}
@@ -2640,7 +2640,7 @@ static void cb_reboot_bootloader(struct usb_ep *ep, struct usb_request *req)
fastboot_tx_write_str("OKAY");
udelay(1000000);
- fastboot_enable_flag();
+ fastboot_enable_command();
do_reset(NULL, 0, 0, NULL);
}
#endif
diff --git a/include/configs/mx6sabreandroid_common.h b/include/configs/mx6sabreandroid_common.h
index 2429b20..57e9fc3 100644
--- a/include/configs/mx6sabreandroid_common.h
+++ b/include/configs/mx6sabreandroid_common.h
@@ -62,7 +62,7 @@
#define CONFIG_ANDROID_MISC_PARTITION_MMC 8
#if defined(CONFIG_FASTBOOT_STORAGE_NAND)
-#define ANDROID_FASTBOOT_NAND_PARTS "16m@64m(boot) 16m@80m(recovery) 810m@96m(android_root)ubifs"
+#define ANDROID_FASTBOOT_NAND_PARTS "16m@64m(boot) 16m@80m(recovery) 1m@96m(misc) 810m@97m(android_root)ubifs"
#endif
#define CONFIG_CMD_BOOTA
diff --git a/include/configs/mx6sxsabreautoandroid.h b/include/configs/mx6sxsabreautoandroid.h
index 049d240..00aea92 100644
--- a/include/configs/mx6sxsabreautoandroid.h
+++ b/include/configs/mx6sxsabreautoandroid.h
@@ -53,7 +53,7 @@
#endif
#if defined(CONFIG_FASTBOOT_STORAGE_NAND)
-#define ANDROID_FASTBOOT_NAND_PARTS "16m@64m(boot) 16m@80m(recovery) 810m@96m(android_root)ubifs"
+#define ANDROID_FASTBOOT_NAND_PARTS "16m@64m(boot) 16m@80m(recovery) 1m@96m(misc) 810m@97m(android_root)ubifs"
#endif
#define CONFIG_ANDROID_MAIN_MMC_BUS 2
diff --git a/include/fsl_fastboot.h b/include/fsl_fastboot.h
index 60c4057..75b166b 100644
--- a/include/fsl_fastboot.h
+++ b/include/fsl_fastboot.h
@@ -7,6 +7,7 @@
#ifndef FSL_FASTBOOT_H
#define FSL_FASTBOOT_H
+#include <common.h>
#define FASTBOOT_PTENTRY_FLAGS_REPEAT(n) (n & 0x0f)
#define FASTBOOT_PTENTRY_FLAGS_REPEAT_MASK 0x0000000F
@@ -175,11 +176,10 @@ void fastboot_flash_dump_ptn(void);
/* Check the board special boot mode reboot to fastboot mode. */
-int fastboot_check_and_clean_flag(void);
-int fastboot_check_and_clean_command(void);
+bool fastboot_check_and_clean_command(void);
/* Set the flag which reboot to fastboot mode*/
-void fastboot_enable_flag(void);
+void fastboot_enable_command(void);
/*check if fastboot mode is requested by user*/
void check_fastboot(void);
diff --git a/include/recovery.h b/include/recovery.h
index 3adaeb1..e1636bf 100644
--- a/include/recovery.h
+++ b/include/recovery.h
@@ -13,8 +13,7 @@ struct reco_envs {
};
void check_recovery_mode(void);
-int recovery_check_and_clean_flag(void);
-int recovery_check_and_clean_command(void);
+bool recovery_check_and_clean_command(void);
int check_recovery_cmd_file(void);
void board_recovery_setup(void);
int read_boot_reason(void);