Android->recovery:control led
This commit is contained in:
@ -204,11 +204,19 @@ static RKSdBootCfgItem SdBootConfigs[] =
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define YELLOW 1
|
||||||
|
#define BLUE 2
|
||||||
void *thrd_led_func(void *arg);
|
void *thrd_led_func(void *arg);
|
||||||
|
pthread_t tid_yellow_led;
|
||||||
|
pthread_t tid_blue_led;
|
||||||
pthread_t tid;
|
pthread_t tid;
|
||||||
bool isLedFlash = false;
|
bool isLedFlash = false;
|
||||||
bool bSDMounted = false;
|
bool bSDMounted = false;
|
||||||
bool bUsbMounted = false;
|
bool bUsbMounted = false;
|
||||||
|
void startLedBlink(int led);
|
||||||
|
void stopLed(int led);
|
||||||
|
void startLed(int led);
|
||||||
|
void stopLedBlink(int led);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The recovery tool communicates with the main system through /cache files.
|
* The recovery tool communicates with the main system through /cache files.
|
||||||
@ -1773,6 +1781,8 @@ int do_sd_mode_update(char *pFile)
|
|||||||
ui->SetBackground(RecoveryUI::INSTALLING_UPDATE);
|
ui->SetBackground(RecoveryUI::INSTALLING_UPDATE);
|
||||||
ui->SetProgressType(RecoveryUI::DETERMINATE);
|
ui->SetProgressType(RecoveryUI::DETERMINATE);
|
||||||
printf("start sd upgrade...\n");
|
printf("start sd upgrade...\n");
|
||||||
|
startLedBlink(YELLOW);
|
||||||
|
stopLed(BLUE);
|
||||||
|
|
||||||
#ifdef USE_BOARD_ID
|
#ifdef USE_BOARD_ID
|
||||||
ensure_path_mounted("/cust");
|
ensure_path_mounted("/cust");
|
||||||
@ -1783,11 +1793,29 @@ int do_sd_mode_update(char *pFile)
|
|||||||
bRet= do_rk_firmware_upgrade(pFwPath,(void *)handle_upgrade_callback,(void *)handle_upgrade_progress_callback);
|
bRet= do_rk_firmware_upgrade(pFwPath,(void *)handle_upgrade_callback,(void *)handle_upgrade_progress_callback);
|
||||||
else
|
else
|
||||||
bRet = do_rk_partition_upgrade(pFwPath,(void *)handle_upgrade_callback,(void *)handle_upgrade_progress_callback);
|
bRet = do_rk_partition_upgrade(pFwPath,(void *)handle_upgrade_callback,(void *)handle_upgrade_progress_callback);
|
||||||
|
|
||||||
|
// check firefly recovery script
|
||||||
|
const char firefly_recovery_script[256];
|
||||||
|
strcpy(firefly_recovery_script, EX_SDCARD_ROOT);
|
||||||
|
strcat(firefly_recovery_script, "/firefly-recovery.sh");
|
||||||
|
printf("Check %s", firefly_recovery_script);
|
||||||
|
if(bRet && !access(firefly_recovery_script, 0)) { //run firefly scripts
|
||||||
|
ui->Print("Runing firefly-recovery.sh...\n");
|
||||||
|
printf("Running %s", firefly_recovery_script);
|
||||||
|
char *cmd[4];
|
||||||
|
cmd[0] = strdup("/sbin/busybox");
|
||||||
|
cmd[1] = strdup("ash");
|
||||||
|
cmd[2] = strdup(firefly_recovery_script);
|
||||||
|
cmd[3] = NULL;
|
||||||
|
bRet = exec_cmd(cmd[0], cmd) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
ui->SetProgressType(RecoveryUI::EMPTY);
|
ui->SetProgressType(RecoveryUI::EMPTY);
|
||||||
if (!bRet)
|
if (!bRet)
|
||||||
{
|
{
|
||||||
status = INSTALL_ERROR;
|
status = INSTALL_ERROR;
|
||||||
printf("SD upgrade failed!\n");
|
printf("SD upgrade failed!\n");
|
||||||
|
startLedBlink(BLUE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1803,6 +1831,8 @@ int do_sd_mode_update(char *pFile)
|
|||||||
// }
|
// }
|
||||||
bAutoUpdateComplete=true;
|
bAutoUpdateComplete=true;
|
||||||
printf("SD upgrade ok.\n");
|
printf("SD upgrade ok.\n");
|
||||||
|
stopLedBlink(YELLOW);
|
||||||
|
startLed(YELLOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
@ -2037,12 +2067,12 @@ int do_usb_demo_copy(char *demoPath)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void *thrd_led_func(void *arg) {
|
void *thrd_yellow_led_func(void *arg) {
|
||||||
FILE * ledFd = NULL;
|
FILE * ledFd = NULL;
|
||||||
bool onoff = false;
|
bool onoff = false;
|
||||||
|
|
||||||
while(isLedFlash) {
|
while(isLedFlash) {
|
||||||
ledFd = fopen("/sys/class/led_gpio/net_led", "w");
|
ledFd = fopen("/sys/class/leds/firefly:yellow:user/brightness", "w");
|
||||||
if(onoff) {
|
if(onoff) {
|
||||||
fprintf(ledFd, "%d", 0);
|
fprintf(ledFd, "%d", 0);
|
||||||
onoff = false;
|
onoff = false;
|
||||||
@ -2056,32 +2086,98 @@ void *thrd_led_func(void *arg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
printf("stopping led thread, close led and exit\n");
|
printf("stopping led thread, close led and exit\n");
|
||||||
ledFd = fopen("/sys/class/led_gpio/net_led", "w");
|
ledFd = fopen("/sys/class/leds/firefly:yellow:user/brightness", "w");
|
||||||
fprintf(ledFd, "%d", 0);
|
fprintf(ledFd, "%d", 0);
|
||||||
fclose(ledFd);
|
fclose(ledFd);
|
||||||
pthread_exit(NULL);
|
pthread_exit(NULL);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void startLed() {
|
void *thrd_blue_led_func(void *arg) {
|
||||||
|
FILE * ledFd = NULL;
|
||||||
|
bool onoff = false;
|
||||||
|
|
||||||
|
while(isLedFlash) {
|
||||||
|
ledFd = fopen("/sys/class/leds/firefly:blue:power/brightness", "w");
|
||||||
|
if(onoff) {
|
||||||
|
fprintf(ledFd, "%d", 0);
|
||||||
|
onoff = false;
|
||||||
|
}else {
|
||||||
|
fprintf(ledFd, "%d", 1);
|
||||||
|
onoff = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(ledFd);
|
||||||
|
usleep(500 * 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("stopping led thread, close led and exit\n");
|
||||||
|
ledFd = fopen("/sys/class/leds/firefly:blue:power/brightness", "w");
|
||||||
|
fprintf(ledFd, "%d", 0);
|
||||||
|
fclose(ledFd);
|
||||||
|
pthread_exit(NULL);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void startLedBlink(int led) {
|
||||||
isLedFlash = true;
|
isLedFlash = true;
|
||||||
if (pthread_create(&tid,NULL,thrd_led_func,NULL)!=0) {
|
if(led == YELLOW) {
|
||||||
|
if (pthread_create(&tid_yellow_led,NULL,thrd_yellow_led_func,NULL)!=0) {
|
||||||
printf("Create led thread error!\n");
|
printf("Create led thread error!\n");
|
||||||
}
|
}
|
||||||
|
printf("tid in led pthread: %u.\n",tid_yellow_led);
|
||||||
printf("tid in led pthread: %ld.\n",tid);
|
}
|
||||||
|
else if(led == BLUE) {
|
||||||
|
if (pthread_create(&tid_blue_led,NULL,thrd_blue_led_func,NULL)!=0) {
|
||||||
|
printf("Create led thread error!\n");
|
||||||
|
}
|
||||||
|
printf("tid in led pthread: %u.\n",tid_blue_led);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void stopLed() {
|
void startLed(int led) {
|
||||||
|
FILE * ledFd = NULL;
|
||||||
|
if(led == YELLOW) {
|
||||||
|
ledFd = fopen("/sys/class/leds/firefly:yellow:user/brightness", "w");
|
||||||
|
fprintf(ledFd, "%d", 1);
|
||||||
|
fclose(ledFd);
|
||||||
|
}
|
||||||
|
else if (led == BLUE) {
|
||||||
|
ledFd = fopen("/sys/class/leds/firefly:blue:power/brightness", "w");
|
||||||
|
fprintf(ledFd, "%d", 1);
|
||||||
|
fclose(ledFd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void stopLed(int led) {
|
||||||
|
FILE * ledFd = NULL;
|
||||||
|
if(led == YELLOW) {
|
||||||
|
ledFd = fopen("/sys/class/leds/firefly:yellow:user/brightness", "w");
|
||||||
|
fprintf(ledFd, "%d", 0);
|
||||||
|
fclose(ledFd);
|
||||||
|
}
|
||||||
|
else if (led == BLUE) {
|
||||||
|
ledFd = fopen("/sys/class/leds/firefly:blue:power/brightness", "w");
|
||||||
|
fprintf(ledFd, "%d", 0);
|
||||||
|
fclose(ledFd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void stopLedBlink(int led) {
|
||||||
void *tret;
|
void *tret;
|
||||||
isLedFlash = false;
|
isLedFlash = false;
|
||||||
|
|
||||||
if (pthread_join(tid, &tret)!=0){
|
if (led == YELLOW) {
|
||||||
|
if (pthread_join(tid_yellow_led, &tret)!=0){
|
||||||
printf("Join led thread error!\n");
|
printf("Join led thread error!\n");
|
||||||
}else {
|
}else {
|
||||||
printf("join led thread success!\n");
|
printf("join led thread success!\n");
|
||||||
}
|
}
|
||||||
|
} else if (led == BLUE) {
|
||||||
|
if (pthread_join(tid_blue_led, &tret)!=0){
|
||||||
|
printf("Join led thread error!\n");
|
||||||
|
}else {
|
||||||
|
printf("join led thread success!\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int sdtool_main(char *factory_mode, Device* device) {
|
int sdtool_main(char *factory_mode, Device* device) {
|
||||||
|
|||||||
@ -51,6 +51,8 @@ int setup_install_mounts();
|
|||||||
// and 0 if the partition was not wiped.
|
// and 0 if the partition was not wiped.
|
||||||
int erase_persistent_partition();
|
int erase_persistent_partition();
|
||||||
|
|
||||||
|
int exec_cmd(const char* path, char* const argv[]);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user