init.rc not executing in our A20 custom board

383 views
Skip to first unread message

Puneet B

unread,
Jun 9, 2014, 9:34:08 AM6/9/14
to android...@googlegroups.com
Hi all,

We are using Allwinner A20 custom board. we did booting android4.2 from sdcard which is working fine and tested all interface.

but once we tried booting android from NAND flash, init.rc script not executing it is going to init.recovery.sun7i.rc.

so i am not able to home screen(but some time device booted fine and able to get home screen also but this will happen once in 20 times reboot).

there is no issue with nand  memory . Once init.rc starts execution we will get home screen.

In which scenario init.recovery.sun7i.rc will execute instead of init.rc?.

Kindly tell me what will be issue. your help will be greatly appreciable.

Regards
Punith

Puneet B

unread,
Jun 9, 2014, 11:20:50 AM6/9/14
to android...@googlegroups.com
 Since in my case instead init.rc , init.recovery.sun7i.rc is executing so i coped init.rc to init.recovery.sun7i.rc.

but once i booted i get fallowing error.

[   14.161745] init: could not import file '/init.trace.rc' from '/init.recovery.sun7i.rc'
[   14.170709] init: could not import file '/init.usb.rc' from '/init.recovery.sun7i.rc'
[   14.179467] init: could not import file '/init.sun7i.rc' from '/init.recovery.sun7i.rc'
[   14.189081] init (1): /proc/1/oom_adj is deprecated, please use /proc/1/oom_score_adj instead.
[   14.379378] init: command 'loglevel' r=0

i mounted rootfs under root also but not used.

Regards
Punith

shridutt kothari

unread,
Jun 10, 2014, 6:42:45 AM6/10/14
to android...@googlegroups.com

Puneet B

unread,
Jun 12, 2014, 10:01:45 AM6/12/14
to android...@googlegroups.com
 Hi all,

I found the problem it is because from u-boot it is reading misc partition from NAND and going to boot recovery mode.

int android_misc_flash_check(void) {

    u32   misc_offset = 0;
    char  buffer[2048];

    misc_offset = (u32)sunxi_partition_get_offset_byname("misc");
    if(misc_offset == (u32)(-1))
    {
        puts("no misc partition is found\n");
        return 0;
    }   
    memset(buffer, 0, 2048);
#ifdef DEBUG
    printf("misc_offset  : %d\n", (int )misc_offset);
#endif
    sunxi_flash_read(misc_offset, 2048/512, buffer);
    memcpy(&misc_message, buffer, sizeof(misc_message));
#ifdef DEBUG
//    printf("misc.command  : %s\n", misc_message.command);
//    printf("misc.status   : %s\n", misc_message.status);
//    printf("misc.recovery : %s\n", misc_message.recovery);
#endif
    if(storage_type)
    {
        if(!strcmp(misc_message.command, "boot-recovery")) {
            /* there is a recovery command */
            puts("find boot recovery\n");
            setenv("bootcmd", "run setargs_mmc boot_recovery");
            puts("Recovery detected, will boot recovery\n");
            /* android recovery will clean the misc */
        }
        else{
            printf("bootcmd set setargs_mmc\n");
            setenv("bootcmd", "run setargs_mmc boot_normal");
        }
        if(!strcmp(misc_message.command, "boot-fastboot")) {
            /* there is a fastboot command */
            setenv("bootcmd", "run setargs_mmc boot_fastboot");
            puts("Fastboot detected, will enter fastboot\n");
            /* clean the misc partition ourself */
            memset(buffer, 0, 2048);
            sunxi_flash_write(misc_offset, 2048/512, buffer);
        }
    }
    else
    {
        if(!strcmp(misc_message.command, "boot-recovery")) {
            /* there is a recovery command */
            puts("find boot recovery\n");
            setenv("bootcmd", "run setargs_nand boot_recovery");
            puts("Recovery detected, will boot recovery\n");
            /* android recovery will clean the misc */
       
}
        else{
            printf("bootcmd set setargs_nand\n");
            setenv("bootcmd", "run setargs_nand boot_normal");
        }

        if(!strcmp(misc_message.command, "boot-fastboot")) {
            /* there is a fastboot command */
            setenv("bootcmd", "run setargs_nand boot_fastboot");
            puts("Fastboot detected, will enter fastboot\n");
            /* clean the misc partition ourself */
            memset(buffer, 0, 2048);
            sunxi_flash_write(misc_offset, 2048/512, buffer);
        }
    }

    return 0;
}

misc_message.command is matching to boot.recovery so android boot went to recovery mode.

but once i hard coded environment variable , the device is booting fine.

Can you say why it was so, your help will be greatly appreciable.

Regards
Punith

shridutt kothari

unread,
Jun 13, 2014, 3:35:25 AM6/13/14
to android...@googlegroups.com
HI,

misc_message.command is ment for telling uboot or bootloader, that device needs to be booted into recovery mode i.e. the kernel from recovery image should be loaded instead of kernel of boot image.

and until recovery image overrides/resets the misc_message.command block device always boots in recovery mode just for the safety if devices power goes down recovery can perform its tasks again, and misc_message.command is only reset at the end of the intended tasks done by recovery.

--------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Some key things about /misc and the BCB:
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
1. /misc and the BCB:

   •Tiny partition used for communication between RC (Recovery console) and bootloader, and for RC to save state information
   •Contains Bootloader Control Block (BCB)
         –command[32]: Commands for the bootloader
   •“boot-recovery” boot into RC instead of Android
   •Other platform-specific commands may be implemented for update tasks that must be done by the bootloader
   •If empty, garbage, or no known commands matched, normal Android boot
         –status[32]: Return status field written by bootloader after performing platform-specific commands
   •No specification, platform-dependent
         –recovery[1024]: Command line for Recovery Console
   •Arguments tokenized by ‘\n’
   •Invalid if first argument not ‘recovery’

2. Bootloader selects boot image (or other task) based on BCB.command
         –BCB.command is persistent; keep booting into RC until RC clears it
         –Garbage or zeroed out contents should simply boot into Android

3. Recovery Console
   • Upon startup, looks for command line arguments in decreasing precedence:
       –Actual command line to ‘recovery’, debug-only scenario
       –BCB.recovery
       –Command file in /cache/recovery/command (written by RecoverySystem APIs)
   • RecoverySystem doesn’t write to BCB due to permissions on doing raw block device I/O
   • Always copies arguments into BCB.recovery and sets BCB.command to “boot-recovery”
       –Makes sure we keep booting into RC with the same arguments in event of unexpected power loss
   • finish_recovery()
       –Called when requested operations (SW update, factory data reset, etc) are complete, whether successful or failed
       –BCB is cleared so that subsequent reboot goes back into Android
   • A divergent update process is very very bad, should always at some point complete so that finish_recovery() can be called
       –Else the device will get stuck, user resets it, gets stuck again, can never boot back into Android

--------------------------------------------------------------------------------------------------------------------------------------------------------------------

Thanks,
Shridutt Kothari,
Impetus Infotech India Ltd.
Reply all
Reply to author
Forward
0 new messages