|
New Boot Partition for Dual-Boot
Posted at 3/5/2016 11:17:30
View:4533
|
Replies:3
Print
Only Author
[Copy Link]
1#
Android support the following boot modes:
1. reboot loader
2. reboot recovery
It means that we can also switch the system when dual booting in a diffent way.
Ubuntu booting can be installed in a new independent partition named ramfs instead of the Recovery partition.
So here I describe how to add ramfs boot mode for Ubuntu.
Please add all the patches manually as the locations will differ in every SDK.
Adding the boot mode
Linux kernel patch
- diff --git a/arch/arm/mach-rockchip/common.c b/arch/arm/mach-rockchip/common.c
- index 510e4da..e91fa64 100755
- --- a/arch/arm/mach-rockchip/common.c
- +++ b/arch/arm/mach-rockchip/common.c
- @@ -264,6 +264,9 @@ void rockchip_restart_get_boot_mode(const char *cmd, u32 *flag, u32 *mode)
- else if (!strcmp(cmd, "charge")) {
- *flag = SYS_LOADER_REBOOT_FLAG + BOOT_CHARGING;
- *mode = BOOT_MODE_CHARGE;
- + }else if(!strcmp(cmd, "ramfs")){
- + *flag = SYS_LOADER_REBOOT_FLAG + BOOT_RAMFS;
- + *mode = BOOT_MODE_RAMFS;
- }
- } else {
- if (is_panic)
- diff --git a/arch/arm/mach-rockchip/loader.h b/arch/arm/mach-rockchip/loader.h
- index bf2cd47..819e277 100644
- --- a/arch/arm/mach-rockchip/loader.h
- +++ b/arch/arm/mach-rockchip/loader.h
- @@ -17,6 +17,7 @@ enum {
- BOOT_FASTBOOT, /* enter fast boot mode */
- BOOT_SECUREBOOT_DISABLE,
- BOOT_CHARGING, /* enter charge mode */
- + BOOT_RAMFS,
- BOOT_MAX /* MAX VALID BOOT TYPE.*/
- };
-
- diff --git a/include/linux/rockchip/common.h b/include/linux/rockchip/common.h
- index 006d52d..0a10625 100644
- --- a/include/linux/rockchip/common.h
- +++ b/include/linux/rockchip/common.h
- @@ -52,6 +52,7 @@ int rockchip_cpu_disable(unsigned int cpu);
- #define BOOT_MODE_PANIC 7
- #define BOOT_MODE_WATCHDOG 8
- #define BOOT_MODE_TSADC 9
- +#define BOOT_MODE_RAMFS 10
-
- int rockchip_boot_mode(void);
- void __init rockchip_boot_mode_init(u32 flag, u32 mode);
- diff --git a/include/uapi/linux/reboot.h b/include/uapi/linux/reboot.h
- index 09d056d..28e4c51 100644
- --- a/include/uapi/linux/reboot.h
- +++ b/include/uapi/linux/reboot.h
- @@ -33,6 +33,7 @@
- #define LINUX_REBOOT_CMD_RESTART2 0xA1B2C3D4
- #define LINUX_REBOOT_CMD_SW_SUSPEND 0xD000FCE2
- #define LINUX_REBOOT_CMD_KEXEC 0x45584543
- +#define LINUX_REBOOT_CMD_RESTART_RAMFS 0xEEEEEEEE
-
- diff --git a/kernel/sys.c b/kernel/sys.c
- index b1a203d..3147ab5 100644
- --- a/kernel/sys.c
- +++ b/kernel/sys.c
- @@ -505,6 +505,8 @@ SYSCALL_DEFINE4(reboot, int, magic1, int, magic2, unsigned int, cmd,
-
- mutex_lock(&reboot_mutex);
- switch (cmd) {
- + case LINUX_REBOOT_CMD_RESTART_RAMFS:
- + kernel_restart("ramfs");
- case LINUX_REBOOT_CMD_RESTART:
- kernel_restart(NULL);
- break;
Copy the code U-Boot patch
- diff --git a/board/rockchip/common/config.h b/board/rockchip/common/config.h
- index 37d287a..9347fe0 100755
- --- a/board/rockchip/common/config.h
- +++ b/board/rockchip/common/config.h
- @@ -188,6 +188,7 @@ enum {
- BOOT_FASTBOOT,
- BOOT_SECUREBOOT_DISABLE,
- BOOT_CHARGING,
- + BOOT_RAMFS,
- BOOT_MAX /* MAX VALID BOOT TYPE.*/
- };
-
- diff --git a/board/rockchip/common/rkboot/fastboot.c b/board/rockchip/common/rkboot/fastboot.c
- index 4bb8c28..c3f47f0 100755
- --- a/board/rockchip/common/rkboot/fastboot.c
- +++ b/board/rockchip/common/rkboot/fastboot.c
- @@ -120,6 +120,10 @@ enum fbt_reboot_type board_fbt_get_reboot_type(void)
- case BOOT_CHARGING:
- frt = FASTBOOT_REBOOT_CHARGE;
- break;
- + case BOOT_RAMFS:
- + frt = FASTBOOT_REBOOT_RAMFS;
- + break;
- +
- default:
- printf("unsupport rk boot type %d\n", reboot_mode);
- break;
- @@ -479,6 +483,12 @@ void board_fbt_preboot(void)
- board_fbt_request_start_fastboot();
- }
- #endif
- + else if (frt == FASTBOOT_REBOOT_RAMFS) {
- + #ifdef CONFIG_CMD_BOOTRK
- + char *const boot_cmd[] = {"bootrk", "ramfs"};
- + do_bootrk(NULL, 0, ARRAY_SIZE(boot_cmd), boot_cmd);
- + #endif
- + }
- else {
- FBTDBG("\n%s: check misc command.\n", __func__);
- /* unknown reboot cause (typically because of a cold boot).
- diff --git a/include/fastboot.h b/include/fastboot.h
- index 7b8508b..d6b8f1f 100755
- --- a/include/fastboot.h
- +++ b/include/fastboot.h
- @@ -238,6 +238,7 @@ enum fbt_reboot_type {
- FASTBOOT_REBOOT_RECOVERY_WIPE_DATA, /* recovery and wipe data */
- FASTBOOT_REBOOT_FASTBOOT, /* android fastboot */
- FASTBOOT_REBOOT_CHARGE, /* charge */
- + FASTBOOT_REBOOT_RAMFS,
- };
Copy the code Adding the new boot partition
- diff --git a/board/rockchip/common/rkboot/fastboot.c b/board/rockchip/common/rkboot/
- index f77fa2c..39e4b69 100755
- --- a/board/rockchip/common/rkboot/fastboot.c
- +++ b/board/rockchip/common/rkboot/fastboot.c
- @@ -218,6 +218,10 @@ void board_fbt_boot_failed(const char* boot)
- printf("try to start backup\n");
- char *const boot_cmd[] = {"bootrk", BACKUP_NAME};
- do_bootrk(NULL, 0, ARRAY_SIZE(boot_cmd), boot_cmd);
- + } else if (!memcmp(BACKUP_NAME, boot, sizeof(BACKUP_NAME))) {
- + printf("try to start ramfs\n");
- + char *const boot_cmd[] = {"bootrk", RAMFS_NAME};
- + do_bootrk(NULL, 0, ARRAY_SIZE(boot_cmd), boot_cmd);
- }
- #endif
- printf("try to start rockusb\n");
- diff --git a/board/rockchip/common/rkloader/rkimage.h b/board/rockchip/common/rkload
- index 812055f..a2d2855 100755
- --- a/board/rockchip/common/rkloader/rkimage.h
- +++ b/board/rockchip/common/rkloader/rkimage.h
- @@ -144,6 +144,7 @@ typedef struct tag_second_loader_hdr
- #define RESOURCE_NAME "resource"
- #define LOGO_NAME "logo"
- #define FACTORY_NAME "factory"
- +#define RAMFS_NAME "ramfs"
-
-
- int rkimage_load_image(rk_boot_img_hdr *hdr, const disk_partition_t *boot_ptn, \
Copy the code Then also add the ramfs partition to your partition file
Please use your own partition file, this is just an example
- CMDLINE: console=ttyS2 root=LABEL=linuxroot rw rootfstype=ext4 init=/sbin/init mtdparts=rk29xxnand:0x00002000@0x00002000(uboot),0x00002000@0x00004000(trust),0x00008000@0x00006000(resource),0x00010000@0x0000E000(ramfs),-@0x0001E000(linuxroot)
Copy the code
Now you can flash the linux-boot.img image to ramfs partition instead of Recovery partition and still keep the Android Recovery or flash TWRP Recovery to it while still dual-booting
Will also need to add ramfs partition info to the first screen of AndroidTool v2.35
I hope Firefly Team will implement this into their next dual-boot firmware to have an extra partition for dual-booting.
|
|