how to customize UI menu for android recovery mode

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

how to customize UI menu for android recovery mode

5,394 Views
chenguoyin
NXP Employee
NXP Employee

Since JB4.3, we have added a customer library in myandroid/devices/fsl/common/recovery to give a chance for customer to customize their UI menu in recovery.img

By default, we define below menu as below:

const char* ITEMS[] = { "reboot system now",

  "apply update from ADB",

  "wipe data/factory reset",

  "wipe cache partition",

  NULL };

Below is an example to add a new menu as "apply update from SD Card":

diff --git a/common/recovery/recovery_ui.cpp b/common/recovery/recovery_ui.cpp

index ccf8ccd..9cbd91e 100644

--- a/common/recovery/recovery_ui.cpp

+++ b/common/recovery/recovery_ui.cpp

@@ -31,6 +31,7 @@ const char* HEADERS[] = { "Volume up/down to move highlight;",

const char* ITEMS[] = { "reboot system now",

  "apply update from ADB",

+ "apply update from SD Card",

  "wipe data/factory reset",

  "wipe cache partition",

  NULL };

@@ -77,8 +78,9 @@ class ImxDevice : public Device {

switch (menu_position) {

case 0: return REBOOT;

case 1: return APPLY_ADB_SIDELOAD;

- case 2: return WIPE_DATA;

- case 3: return WIPE_CACHE;

+ case 2: return APPLY_EXT;

+ case 3: return WIPE_DATA;

+ case 4: return WIPE_CACHE;

default: return NO_ACTION;

}

}

The handle on the menu is defined in function prompt_and_wait(Device* device, int status) in myandroid/bootable/recovery/recovery.cpp. Below is the buildin menu function in recovery.

    enum BuiltinAction { NO_ACTION, REBOOT, APPLY_EXT, APPLY_CACHE,

  APPLY_ADB_SIDELOAD, WIPE_DATA, WIPE_CACHE };

Tags (3)
0 Kudos
13 Replies

2,529 Views
erickang
Contributor II

Dear Guoyin,

I found some point to solve the problem.

I compared the init.rc for Normal mode and Recovery mode for /mnt/extsd and /extsd.

init.rc in Normal mode : device/fsl/imx6/etc/init.rc

init.rc in Recovery mode : bootable/recovery/etc/init.rc

In the recovery mode, there wasn't /mnt/extsd and /extsd.

So I think we have to add /mnt/extsd and /extsd into the recovery mode init.rc

mkdir /mnt/extsd 0000 system system

symlink /mnt/extsd /extsd

Is that right?

I'll try to this method.

Best Regards,

Eric.

0 Kudos

2,529 Views
chenguoyin
NXP Employee
NXP Employee

You also need to update recovery to make sure the /extsd been mounted. By default the extsd volume is not been mounted.

~/maddev_kk4.4.3_3.10.y/bootable/recovery$ git diff

diff --git a/recovery.cpp b/recovery.cpp

index 43cd9da..2604591 100644

--- a/recovery.cpp

+++ b/recovery.cpp

@@ -942,6 +942,7 @@ main(int argc, char **argv) {

load_volume_table();

ensure_path_mounted(LAST_LOG_FILE);

+ ensure_path_mounted("/extsd");

rotate_last_logs(10);

get_args(&argc, &argv);

0 Kudos

2,529 Views
erickang
Contributor II

We updated the Recovery Image by using fatload command, and others.

0 Kudos

2,529 Views
燕频姜
Contributor II

Hi,erickang

     Have you solved this problem? also my SDcard can not mounted in the recovery mode.If you have done it,could you give me some help?thanks!

0 Kudos

2,528 Views
sriramperiyasam
Contributor II

Hi,

you have to add the file system mount entry for the SD card in the file bootable\recovery\etc\fstab.freescale.recovery. And also create the directories needed to mount the sdcard in the bootable\recovery\etc\init.rc file.

Regards

Sriram.

0 Kudos

2,529 Views
燕频姜
Contributor II

Hi,Sriram

     Thank you for your reply.

     I have done the two things. 1、fstab.freescale 2、init.rc

     But I have the "E:failed to mount /mnt/extsd (No such file or directory)" ,Could you give me some details about it.

 

   Rregards

   yanpin Jiang

0 Kudos

2,529 Views
sriramperiyasam
Contributor II

hi yanpin,

Can you share me your init.rc and fstab.freescale?

Thanks

Sriram.

0 Kudos

2,529 Views
燕频姜
Contributor II

Hi,Sriram

     Thank you for your reply. My android version is JB4.3.1.

     Below is my fstab.freescale file in recovery mode

     1、fstab.freescale

# Android fstab file.

#<src>                                                  <mnt_point>         <type>    <mnt_flags and options>                       <fs_mgr_flags>

# The filesystem that contains the filesystem checker binary (typically /system) cannot

# specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK

/devices/platform/sdhci-esdhc-imx.2/mmc_host/mmc1 /mnt/extsd vfat defaults voldmanaged=sdcard:auto

/devices/platform/fsl-ehci /mnt/udisk vfat defaults voldmanaged=sdcard:auto

/dev/block/mmcblk0p5    /system      ext4    ro                                                                               wait

/dev/block/mmcblk0p4    /data        ext4    nosuid,nodev,nodiratime,noatime,nomblk_io_submit,noauto_da_alloc,errors=panic    wait,encryptable=footer

/dev/block/mmcblk0p6    /cache       ext4    nosuid,nodev,nomblk_io_submit                                                    wait

/dev/block/mmcblk0p7    /device      ext4    ro,nosuid,nodev                                                                  wait

/dev/block/mmcblk0p1    /boot        emmc    defaults                                                                         defaults

/dev/block/mmcblk0p2    /recovery    emmc    defaults                                                                         defaults

/dev/block/mmcblk0p8    /misc        emmc    defaults                                                                         defaults

     2、init.rc in recovery mode

import /init.recovery.${ro.hardware}.rc

on early-init

    start ueventd

on init

    export PATH /sbin

    export ANDROID_ROOT /system

    export ANDROID_DATA /data

    export EXTERNAL_STORAGE /mnt/extsd

    symlink /system/etc /etc

    mkdir /mnt

     mkdir /mnt/extsd

    mkdir /system

    mkdir /data

    mkdir /cache

    mount /tmp /tmp tmpfs

    chown root shell /tmp

    chmod 0775 /tmp

    write /sys/class/android_usb/android0/enable 0

    write /sys/class/android_usb/android0/idVendor 18D1

    write /sys/class/android_usb/android0/idProduct D001

    write /sys/class/android_usb/android0/functions adb

    write /sys/class/android_usb/android0/iManufacturer ${ro.product.manufacturer}

    write /sys/class/android_usb/android0/iProduct ${ro.product.model}

    write /sys/class/android_usb/android0/iSerial ${ro.serialno}

on boot

    ifup lo

    hostname localhost

    domainname localdomain

    class_start default

service ueventd /sbin/ueventd

    critical

service recovery /sbin/recovery

service adbd /sbin/adbd recovery

    disabled

# Always start adbd on userdebug and eng builds

on property:ro.debuggable=1

    write /sys/class/android_usb/android0/enable 1

    start adbd

# Restart adbd so it can run as root

on property:service.adb.root=1

    write /sys/class/android_usb/android0/enable 0

    restart adbd

    write /sys/class/android_usb/android0/enable 1

    There are  the vold and mount in  In JB4.3,but I don't know how to deal with them.

     Thanks

    

     yanpin Jiang

0 Kudos

2,529 Views
sriramperiyasam
Contributor II

Hi,

Please replace following line

/devices/platform/sdhci-esdhc-imx.2/mmc_host/mmc1 /mnt/extsd vfat defaults voldmanaged=sdcard:auto

with

/dev/block/mmcblk1p1 /mnt/extsd vfat defaults voldmanaged=sdcard:auto

And ensure that recovery image changes flashed successfully since if you flash it using fastboot, it will not flash properly. Try to use manufacturing tool for flashing.

Thanks and Regards

Sriram.

2,529 Views
燕频姜
Contributor II

Hi,Sriram

     Thank you very much!

     I have solved this problem. I used the mount("/dev/block/mmcblk1p1....") command .

     I am very grateful to you for giving me so much help。

     

    Regards

    Yanpin

0 Kudos

2,529 Views
sriramperiyasam
Contributor II

Hi,

You have to add the appropriate directory path in recovery init.rc also. Hope this may help others.

0 Kudos

2,529 Views
erickang
Contributor II

Dear Guoyin Chen,

Thanks for your response.

The SD-Card was not mounted when I applied your guide like as below

1st : ensure_path_mounted("/extsd");

2nd : ensure_path_mounted("/mnt/extsd");

I could see the below log when the board was entered the Recovery mode.

Log.#1.jpgLog.#0.jpg

I'm using the JB4.3, and the board have SD-Card(via SD3 port) and eMMC(via SD4).

Could you tell me what's the problem?

Best Regards,

Eric.

0 Kudos

2,529 Views
erickang
Contributor II

Dear Guoyin,

I modified the below file based on your comments, and then confirmed the displayed SD-Card menu in UI menu.

common/recovery/recovery_ui.cpp

But I couldn't update the Android Image because the board couldn't mount sd-card in /mnt/extsd and /sdcard.

and I could confirm the sd-card mounting point in the below files.

1) myandroid/out/target/product/sabresd_6dq/recovery/root/fstab.freescale

    /devices/platform/sdhci-esdhc-imx.2/mmc_host/mmc1 /mnt/extsd vfat defaults voldmanaged=sdcard:auto

2) myandroid/bootable/recovery/recovery.cpp

   static const char *SDCARD_ROOT = "/sdcard";

Could you tell me how to update the Android image on the board with SD-Card for detailed?

I confirmed the below items for Android Recovery mode & Android Norml mode via SD-Card.

- check the sd-card interface operation in Android normal mode (No Recovery mode)

   . SD-Card was mounted as /mnt/extsd when the sd-card was inserted.

   . linked the /mnt/extsd to /sdcard, and then we can control the data in /mnt/extsd and /sdcard (after remounting "/" as rw)

- check SD-Card UI menu in Android Recovery mode

   . displayed sd-card UI menu after applying your upper comments.

Best Regards,

Eric.

0 Kudos