Patch to Cradlepoint Current
Change-Id: Ibd430f8938a41cc0fcb4066500cd7332612f1e45
diff --git a/common/autoboot.c b/common/autoboot.c
index 48b0606..517171c 100644
--- a/common/autoboot.c
+++ b/common/autoboot.c
@@ -31,6 +31,16 @@
/* Stored value of bootdelay, used by autoboot_command() */
static int stored_bootdelay;
+extern void check_serial_console(void);
+extern void check_for_enable_usb_passthrough(void);
+extern void print_menu_selections(void);
+extern void process_menu_selection(int);
+#if defined(CONFIG_DEBUG_ENABLE)
+extern int process_debug_package(void);
+#endif
+extern void check_factory_reset(void);
+extern void usb_passthrough(void);
+
#if defined(CONFIG_AUTOBOOT_KEYED)
#if defined(CONFIG_AUTOBOOT_STOP_STR_SHA256)
@@ -217,22 +227,53 @@
# else /* !defined(CONFIG_AUTOBOOT_KEYED) */
-#ifdef CONFIG_MENUKEY
-static int menukey;
-#endif
+static int menukey = 0;
+
+/* Check if we've got CPConfig in the environment. If not, add it and save the environment */
+void fixup_environment(void)
+{
+ char * s = getenv("CPConfig");
+ if (s == NULL) {
+ printf("Found unsaved environment...\n");
+ setenv("CPConfig", "yes");
+ saveenv();
+ }
+}
+int validateUserSelection(unsigned char c){
+ char valid_min = '1';
+ char valid_max = '9' ;
+ if (c >= valid_min && c <= valid_max){
+ return 0;
+ }
+ return 1;
+}
+
static int abortboot_normal(int bootdelay)
{
int abort = 0;
unsigned long ts;
+ fixup_environment();
+
+#if defined(CONFIG_DEBUG_ENABLE)
+ if (process_debug_package() == 0) {
+ printf("Successfully validated the debug enable package.\n");
+ } else {
+ printf("Debug package not found or otherwise invalid\n");
+ }
+#endif
+
#ifdef CONFIG_MENUPROMPT
printf(CONFIG_MENUPROMPT);
#else
+ /* check_serial_console(); */
+ print_menu_selections();
if (bootdelay >= 0)
printf("Hit any key to stop autoboot: %2d ", bootdelay);
#endif
+
#if defined CONFIG_ZERO_BOOTDELAY_CHECK
/*
* Check if key already pressed
@@ -240,29 +281,32 @@
*/
if (bootdelay >= 0) {
if (tstc()) { /* we got a key press */
- (void) getc(); /* consume input */
- puts("\b\b\b 0");
- abort = 1; /* don't auto boot */
+ menukey = getc(); /* consume input */
+ if (!validateUserSelection(menukey)){
+ puts ("\b\b\b 0");
+ abort = 1; /* don't auto boot */
+ }
}
}
#endif
+ check_factory_reset();
while ((bootdelay > 0) && (!abort)) {
--bootdelay;
/* delay 1000 ms */
ts = get_timer(0);
do {
if (tstc()) { /* we got a key press */
- abort = 1; /* don't auto boot */
- bootdelay = 0; /* no more delay */
-# ifdef CONFIG_MENUKEY
menukey = getc();
-# else
- (void) getc(); /* consume input */
-# endif
- break;
+ printf("You pressed %c\n", (char) menukey);
+ if (!validateUserSelection((char)menukey)){
+ abort = 1; /* don't auto boot */
+ bootdelay = 0; /* no more delay */
+ break;
+ }
}
udelay(10000);
+ check_factory_reset();
} while (!abort && get_timer(ts) < 1000);
printf("\b\b\b%2d ", bootdelay);
@@ -274,6 +318,11 @@
if (abort)
gd->flags &= ~GD_FLG_SILENT;
#endif
+ if (abort)
+ process_menu_selection(menukey);
+ else
+ process_menu_selection('3');
+
return abort;
}
# endif /* CONFIG_AUTOBOOT_KEYED */
@@ -366,10 +415,22 @@
return 0;
}
+__weak void check_reset_button(void)
+{
+ printf("This is where the reset button check would be running, if it were complete\n");
+ return;
+}
void autoboot_command(const char *s)
{
debug("### main_loop: bootcmd=\"%s\"\n", s ? s : "<UNDEFINED>");
+ char * skip = NULL;
+ skip = getenv("skip_usb_passthrough");
+ if (!(skip != NULL && strcmp(skip, "yes") == 0)) {
+ printf("Doing usbpassthrough, since skip_usb_passthrough isn't set to yes\n");
+ usb_passthrough();
+ }
+
#ifdef CONFIG_QCA_APPSBL_DLOAD
/*
* If kernel has crashed in previous boot,