/* ************************************************************************************************************ * * function * * name : * * parmeters : * * return : * * note : * * ************************************************************************************************************ */ void sunxi_update_subsequent_processing(int next_work) { printf("next work %d\n", next_work); switch(next_work) { case SUNXI_UPDATE_NEXT_ACTION_REBOOT: //重启 case SUNXI_UPDATA_NEXT_ACTION_SPRITE_TEST: printf("SUNXI_UPDATE_NEXT_ACTION_REBOOT\n"); //do_reset(NULL, 0, 0, NULL); sunxi_board_restart(0); break; case SUNXI_UPDATE_NEXT_ACTION_SHUTDOWN: //关机 printf("SUNXI_UPDATE_NEXT_ACTION_SHUTDOWN\n"); //do_shutdown(NULL, 0, 0, NULL); sunxi_board_shutdown(); break; case SUNXI_UPDATE_NEXT_ACTION_REUPDATE: printf("SUNXI_UPDATE_NEXT_ACTION_REUPDATE\n"); sunxi_board_run_fel(); //进行量产 break; case SUNXI_UPDATE_NEXT_ACTION_BOOT: case SUNXI_UPDATE_NEXT_ACTION_NORMAL: default: printf("SUNXI_UPDATE_NEXT_ACTION_NULL\n"); break; } return ; }
int do_efex (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { printf ("## jump to efex ...\n"); sunxi_board_run_fel(); return 0; }
/* ************************************************************************************************************ * * function * * name : * * parmeters : * * return : * * note : * * ************************************************************************************************************ */ static void __oem_operation(char *operation) { char response[68]; char lock_info[64]; int lockflag; int ret; memset(lock_info, 0, 64); memset(response, 0, 68); if(!strncmp(operation, "lock", 4)) { lockflag = SUNXI_RELOCKING; } else if(!strncmp(operation, "unlock", 6)) { lockflag = SUNXI_UNLOCK; } else { if(!strncmp(operation, "efex", 4)) { strcpy(response, "OKAY"); __sunxi_fastboot_send_status(response, strlen(response)); sunxi_board_run_fel(); } else { const char *info = "fastboot oem operation fail: unknown cmd"; printf("%s\n", info); strcpy(response, "FAIL"); strcat(response, info); __sunxi_fastboot_send_status(response, strlen(response)); } return ; } ret = sunxi_oem_op_lock(lockflag, lock_info, 0); if(!ret) { strcpy(response, "OKAY"); } else { strcpy(response, "FAIL"); } strcat(response, lock_info); printf("%s\n", response); __sunxi_fastboot_send_status(response, strlen(response)); return ; }
/* ************************************************************************************************************ * * function * * name : * * parmeters : * * return : * * note : * * ************************************************************************************************************ */ int check_android_misc(void) { int mode; int pmu_value; u32 misc_offset = 0; char misc_args[2048]; char misc_fill[2048]; char boot_commond[128]; static struct bootloader_message *misc_message; if(uboot_spare_head.boot_data.work_mode != WORK_MODE_BOOT) { return 0; } if(gd->force_shell) { char delaytime[8]; sprintf(delaytime, "%d", 3); setenv("bootdelay", delaytime); } //if enter debug mode,set loglevel = 8 check_debug_mode(); memset(boot_commond, 0x0, 128); strcpy(boot_commond, getenv("bootcmd")); printf("base bootcmd=%s\n", boot_commond); //判断存储介质 if((uboot_spare_head.boot_data.storage_type == 1) || (uboot_spare_head.boot_data.storage_type == 2)) { sunxi_str_replace(boot_commond, "setargs_nand", "setargs_mmc"); printf("bootcmd set setargs_mmc\n"); } else { printf("bootcmd set setargs_nand\n"); } misc_message = (struct bootloader_message *)misc_args; memset(misc_args, 0x0, 2048); memset(misc_fill, 0xff, 2048); mode = detect_other_boot_mode(); if(mode == ANDROID_NULL_MODE) { pmu_value = axp_probe_pre_sys_mode(); if(pmu_value == PMU_PRE_FASTBOOT_MODE) { puts("PMU : ready to enter fastboot mode\n"); strcpy(misc_message->command, "bootloader"); } else if(pmu_value == PMU_PRE_RECOVERY_MODE) { puts("PMU : ready to enter recovery mode\n"); strcpy(misc_message->command, "boot-recovery"); } else { misc_offset = sunxi_partition_get_offset_byname("misc"); debug("misc_offset = %x\n",misc_offset); if(!misc_offset) { printf("no misc partition is found\n"); } else { printf("misc partition found\n"); sunxi_flash_read(misc_offset, 2048/512, misc_args); //read misc partition data } } } else if(mode == ANDROID_RECOVERY_MODE) { strcpy(misc_message->command, "boot-recovery"); } else if( mode == ANDROID_FASTBOOT_MODE) { strcpy(misc_message->command, "bootloader"); } //最终统一判断命令 if(!loglel_change_flag) //add by young,if you want to enter debug_mode ,so do enter boot_normal { if(!strcmp(misc_message->command, "efex")) { /* there is a recovery command */ puts("find efex cmd\n"); sunxi_flash_write(misc_offset, 2048/512, misc_fill); sunxi_board_run_fel(); return 0; } if(!strcmp(misc_message->command, "boot-resignature")) { puts("find boot-resignature cmd\n"); sunxi_flash_write(misc_offset, 2048/512, misc_fill); sunxi_oem_op_lock(SUNXI_LOCKING, NULL, 1); } else if(!strcmp(misc_message->command, "boot-recovery")) { if(!strcmp(misc_message->recovery, "sysrecovery")) { puts("recovery detected, will sprite recovery\n"); strncpy(boot_commond, "sprite_recovery", sizeof("sprite_recovery")); sunxi_flash_write(misc_offset, 2048/512, misc_fill); } else { puts("Recovery detected, will boot recovery\n"); sunxi_str_replace(boot_commond, "boot_normal", "boot_recovery"); } /* android recovery will clean the misc */ } else if(!strcmp(misc_message->command, "bootloader")) { puts("Fastboot detected, will boot fastboot\n"); sunxi_str_replace(boot_commond, "boot_normal", "boot_fastboot"); if(misc_offset) sunxi_flash_write(misc_offset, 2048/512, misc_fill); } else if(!strcmp(misc_message->command, "usb-recovery")) { puts("Recovery detected, will usb recovery\n"); sunxi_str_replace(boot_commond, "boot_normal", "boot_recovery"); } } if(!strcmp(misc_message->command ,"debug_mode")) { puts("debug_mode detected ,will enter debug_mode"); if(!change_to_debug_mode()) { check_debug_mode(); } sunxi_flash_write(misc_offset,2048/512,misc_fill); } setenv("bootcmd", boot_commond); printf("to be run cmd=%s\n", boot_commond); return 0; }
/* ************************************************************************************************************ * * function * * name : * * parmeters : * * return : * * note : * * ************************************************************************************************************ */ int check_android_misc(void) { int mode; u32 misc_offset = 0; char misc_args[2048]; char misc_fill[2048]; char boot_commond[128]; static struct bootloader_message *misc_message; if(uboot_spare_head.boot_data.work_mode != WORK_MODE_BOOT) { return 0; } if(gd->force_shell) { char delaytime[8]; sprintf(delaytime, "%d", 3); setenv("bootdelay", delaytime); } memset(boot_commond, 0x0, 128); set_boot_type_cmd(boot_commond); printf("base bootcmd=%s\n", boot_commond); //判断存储介质 if((uboot_spare_head.boot_data.storage_type == 1) || (uboot_spare_head.boot_data.storage_type == 2)) { sunxi_str_replace(boot_commond, "setargs_nand", "setargs_mmc"); printf("bootcmd set setargs_mmc\n"); } else { printf("bootcmd set setargs_nand\n"); } //判断是否存在按键进入其它模式 memset(misc_args, 0x0, 2048); mode = detect_other_boot_mode(); misc_message = (struct bootloader_message *)misc_args; if(mode == ANDROID_NULL_MODE) { misc_offset = sunxi_partition_get_offset_byname("misc"); if(!misc_offset) { int pmu_value; puts("no misc partition is found\n"); pmu_value = axp_probe_pre_sys_mode(); if(pmu_value == PMU_PRE_FASTBOOT_MODE) { puts("ready to enter fastboot mode\n"); setenv("bootcmd", "run boot_fastboot"); return 0; } else { printf("to be run cmd=%s\n", boot_commond); setenv("bootcmd", boot_commond); return 0; } } memset(misc_fill, 0xff, 2048); #ifdef DEBUG tick_printf("misc_offset : %d\n", (int )misc_offset); #endif sunxi_flash_read(misc_offset, 2048/512, misc_args); } else if(mode == ANDROID_RECOVERY_MODE) { strcpy(misc_message->command, "boot-recovery"); } else if(mode == ANDROID_FASTBOOT_MODE) { strcpy(misc_message->command, "bootloader"); } #ifdef DEBUG { uint *dump_value; dump_value = *(uint *)misc_message->command; if(dump_value != 0xffffffff) printf("misc.command : %s\n", misc_message->command); else printf("misc.command : NULL\n"); dump_value = *(uint *)misc_message->status; if(dump_value != 0xffffffff) printf("misc.status : %s\n", misc_message->status); else printf("misc.status : NULL\n"); dump_value = *(uint *)misc_message->recovery; if(dump_value != 0xffffffff) printf("misc.recovery : %s\n", misc_message->recovery); else printf("misc.recovery : NULL\n"); } #endif //判断命令 if(!strcmp(misc_message->command, "efex")) { /* there is a recovery command */ puts("find efex cmd\n"); sunxi_flash_write(misc_offset, 2048/512, misc_fill); sunxi_board_run_fel(); return 0; } if(!strcmp(misc_message->command, "boot-resignature")) { puts("find boot-resignature cmd\n"); sunxi_flash_write(misc_offset, 2048/512, misc_fill); sunxi_oem_op_lock(SUNXI_LOCKING, NULL, 1); } else if(!strcmp(misc_message->command, "boot-recovery")) { puts("Recovery detected, will boot recovery\n"); sunxi_str_replace(boot_commond, "boot_normal", "boot_recovery"); /* android recovery will clean the misc */ } else if(!strcmp(misc_message->command, "bootloader")) { puts("Fastboot detected, will boot fastboot\n"); sunxi_str_replace(boot_commond, "boot_normal", "boot_fastboot"); if(misc_offset) sunxi_flash_write(misc_offset, 2048/512, misc_fill); } setenv("bootcmd", boot_commond); printf("to be run cmd=%s\n", boot_commond); return 0; }
int check_android_misc(void) { int mode; int pmu_value; u32 misc_offset = 0; char misc_args[2048]; char misc_fill[2048]; char boot_commond[128]; static struct bootloader_message *misc_message; if(uboot_spare_head.boot_data.work_mode != WORK_MODE_BOOT) { return 0; } if(gd->force_shell) { char delaytime[8]; sprintf(delaytime, "%d", 3); setenv("bootdelay", delaytime); } //if enter debug mode,set loglevel = 8 check_debug_mode(); memset(boot_commond, 0x0, 128); strcpy(boot_commond, getenv("bootcmd")); printf("base bootcmd=%s\n", boot_commond); //判断存储介质 if((uboot_spare_head.boot_data.storage_type == 1) || (uboot_spare_head.boot_data.storage_type == 2)) { sunxi_str_replace(boot_commond, "setargs_nand", "setargs_mmc"); printf("bootcmd set setargs_mmc\n"); } else { printf("bootcmd set setargs_nand\n"); } //判断是否存在按键进入其它模式 misc_message = (struct bootloader_message *)misc_args; memset(misc_args, 0x0, 2048); memset(misc_fill, 0xff, 2048); mode = detect_other_boot_mode(); misc_offset = sunxi_partition_get_offset_byname("misc"); //先判断上一次系统是否有写入数据到pmu寄存器 pmu_value = axp_probe_pre_sys_mode(); if(pmu_value == PMU_PRE_FASTBOOT_MODE) { puts("PMU : ready to enter fastboot mode\n"); strcpy(misc_message->command, "bootloader"); } else if(pmu_value == PMU_PRE_RECOVERY_MODE) { puts("PMU : ready to enter recovery mode\n"); strcpy(misc_message->command, "boot-recovery"); } //get the part --"misc" else { debug("misc_offset = %x\n",misc_offset); if(!misc_offset) { printf("no misc partition is found\n"); } else { printf("misc partition found\n"); sunxi_flash_read(misc_offset, 2048/512, misc_args); //read misc partition data } } if((misc_message->command[0] == 0x00) ||(misc_message->command[0] == 0xff)) { printf("misc_message->command = %x \n",misc_message->command[0]); if(mode == USER_SELECT_MODE) //说明探测阶段有按键按下 { printf("enter user_select_mode\n"); #if 0 //如果misc分区没有上次系统写入数据,并且检测到有按键按下,那么进入图片显示菜单 user_select_current_status = FASTBOOT_MODE; show_user_select_menu_ui(); //显示当前模式的ui while(status != POWERON_KEY_PRESSED)//图片显示菜单 { status = sunxi_probe_key_pressed(); if(( status == KEY_PRESSED)) { debug("key_ststus = 0x%x\n ",status); user_mode_status_update(status); //更新菜单的选项 show_user_select_menu_ui(); //显示当前模式的ui } } if(user_select_current_status == RECOVERY_MODE ) { printf("misc_message->command = boot-recovery\n"); strcpy(misc_message->command, "boot-recovery"); } else if(user_select_current_status == FASTBOOT_MODE) { printf("misc_message->command = bootloader\n"); strcpy(misc_message->command, "bootloader"); } #endif } else if(mode == ANDROID_RECOVERY_MODE) { strcpy(misc_message->command, "boot-recovery"); } else if( mode == ANDROID_FASTBOOT_MODE) { strcpy(misc_message->command, "bootloader"); } } //最终统一判断命令 if(!loglel_change_flag) //add by young,if you want to enter debug_mode ,so do enter boot_normal { if(!strcmp(misc_message->command, "efex")) { /* there is a recovery command */ puts("find efex cmd\n"); sunxi_flash_write(misc_offset, 2048/512, misc_fill); sunxi_board_run_fel(); return 0; } if(!strcmp(misc_message->command, "boot-resignature")) { puts("find boot-resignature cmd\n"); sunxi_flash_write(misc_offset, 2048/512, misc_fill); sunxi_oem_op_lock(SUNXI_LOCKING, NULL, 1); } else if(!strcmp(misc_message->command, "boot-recovery")) { puts("Recovery detected, will boot recovery\n"); sunxi_str_replace(boot_commond, "boot_normal", "boot_recovery"); /* android recovery will clean the misc */ } else if(!strcmp(misc_message->command, "bootloader")) { puts("Fastboot detected, will boot fastboot\n"); sunxi_str_replace(boot_commond, "boot_normal", "boot_fastboot"); if(misc_offset) sunxi_flash_write(misc_offset, 2048/512, misc_fill); } else if(!strcmp(misc_message->command, "usb-recovery")) { puts("Recovery detected, will usb recovery\n"); sunxi_str_replace(boot_commond, "boot_normal", "boot_recovery"); } } if(!strcmp(misc_message->command ,"debug_mode")) { puts("debug_mode detected ,will enter debug_mode"); if(!change_to_debug_mode()) { check_debug_mode(); } sunxi_flash_write(misc_offset,2048/512,misc_fill); } setenv("bootcmd", boot_commond); printf("to be run cmd=%s\n", boot_commond); #if 0 misc_message = (struct bootloader_message *)misc_args; if(mode == ANDROID_NULL_MODE) { misc_offset = sunxi_partition_get_offset_byname("misc"); if(!misc_offset) { int pmu_value; puts("no misc partition is found\n"); pmu_value = axp_probe_pre_sys_mode(); if(pmu_value == PMU_PRE_FASTBOOT_MODE) { puts("ready to enter fastboot mode\n"); setenv("bootcmd", "run boot_fastboot"); return 0; } else { printf("to be run cmd=%s\n", boot_commond); setenv("bootcmd", boot_commond); return 0; } } memset(misc_fill, 0xff, 2048); #ifdef DEBUG tick_printf("misc_offset : %d\n", (int )misc_offset); #endif sunxi_flash_read(misc_offset, 2048/512, misc_args); } else if(mode == ANDROID_RECOVERY_MODE) { strcpy(misc_message->command, "boot-recovery"); } else if(mode == ANDROID_FASTBOOT_MODE) { strcpy(misc_message->command, "bootloader"); } #ifdef DEBUG { uint *dump_value; dump_value = *(uint *)misc_message->command; if(dump_value != 0xffffffff) printf("misc.command : %s\n", misc_message->command); else printf("misc.command : NULL\n"); dump_value = *(uint *)misc_message->status; if(dump_value != 0xffffffff) printf("misc.status : %s\n", misc_message->status); else printf("misc.status : NULL\n"); dump_value = *(uint *)misc_message->recovery; if(dump_value != 0xffffffff) printf("misc.recovery : %s\n", misc_message->recovery); else printf("misc.recovery : NULL\n"); } #endif //判断命令 if(!strcmp(misc_message->command, "efex")) { /* there is a recovery command */ puts("find efex cmd\n"); sunxi_flash_write(misc_offset, 2048/512, misc_fill); sunxi_board_run_fel(); return 0; } if(!strcmp(misc_message->command, "boot-resignature")) { puts("find boot-resignature cmd\n"); sunxi_flash_write(misc_offset, 2048/512, misc_fill); sunxi_oem_op_lock(SUNXI_LOCKING, NULL, 1); } else if(!strcmp(misc_message->command, "boot-recovery")) { puts("Recovery detected, will boot recovery\n"); sunxi_str_replace(boot_commond, "boot_normal", "boot_recovery"); /* android recovery will clean the misc */ } else if(!strcmp(misc_message->command, "bootloader")) { puts("Fastboot detected, will boot fastboot\n"); sunxi_str_replace(boot_commond, "boot_normal", "boot_fastboot"); if(misc_offset) sunxi_flash_write(misc_offset, 2048/512, misc_fill); } setenv("bootcmd", boot_commond); printf("to be run cmd=%s\n", boot_commond); #endif return 0; }