RK3588雙系統啟動流程如下圖
uboot根據按鍵來識別要啟動的系統,這里可以使用撥碼開關來代替。
uboot在加載分區的時根據分區名字來區分加載android或者linux的分區,所以在linux和android分區表中需要用"_android"字段來區分。
硬件環境
基于RK3588 EVB1
開發板
實現,系統切換按鍵是ESC 返回鍵
軟件環境
RK3588 Android12 SDK + RK3588 linux Debian系統
要求
Android和linux的固件的代碼uboot和rkbin部分需要一致,因為uboot和loader是共用一份
uboot需要額外補丁,可以通過RK的redmine獲取
代碼修改
uboot引導不同的系統
在uboot打上支持雙系統的補丁0003-disk-part-Support-get-par
tion-name-suffix-from-env.patch,該補丁可以通過RK的redmine系統獲取。
設置切換按鍵及分區名稱下標
u-boot$
//配置BACK按鍵做為切換按鍵,這里使用adc采樣,設置按鍵對應的adc值
diff --git a/arch/arm/dts/rk3588-evb.dts b/arch/arm/dts/rk3588-evb.dts
index ad750d5b74..b6218fd742 100644
--- a/arch/arm/dts/rk3588-evb.dts
+++ b/arch/arm/dts/rk3588-evb.dts
@@
-27,5 +27,12 @@
label = "volume up";
press-threshold-microvolt = <1750>;
};
+
+ back-key {
+ u-boot,dm-pre-reloc;
+ linux,code =
;
+ label = "back";
+ press-threshold-microvolt = <1235000>;
+ };
};
};
//配置按鍵切換,在開機是檢測到按鍵按下就從boot_android分區引導boot啟動,即啟動android系統,否則引導linux的boot,啟動linux系統
diff --git a/arch/arm/mach-rockchip/rk3588/rk3588.c b/arch/arm/mach-rockchip/rk3588/rk3588.c
index a8efc4f9b4..e7b94001c1 100644
--- a/arch/arm/mach-rockchip/rk3588/rk3588.c
+++ b/arch/arm/mach-rockchip/rk3588/rk3588.c
@@ -4,6 +4,7 @@
* SPDX-License-Identifier: GPL-2.0+
*/
#include
+#include
#include
#include
#include
@@ -940,3 +941,18 @@ int rk_board_fdt_fixup(const void *blob)
return 0;
}
+
+int board_early_init_r(void)
+{
+
+ printf("board_early_init_r
");
+ if (key_is_pressed(key_read(KEY_BACK))) {
+ env_set("part_suffix", "_android");
+ printf("Part suffix: _android
");
+ } else {
+ env_set("part_suffix", NULL);
+ }
+
+ return 0;
+}
+
diff --git a/configs/rk3588_defconfig b/configs/rk3588_defconfig
index fd6c9114f0..da7ca13626 100644
--- a/configs/rk3588_defconfig
+++ b/configs/rk3588_defconfig
@@ -223,3 +223,4 @@ CONFIG_RK_AVB_LIBAVB_USER=y
CONFIG_OPTEE_CLIENT=y
CONFIG_OPTEE_V2=y
CONFIG_OPTEE_ALWAYS_USE_SECURITY_PARTITION=y
+CONFIG_BOARD_EARLY_INIT_R=y
diff --git a/drivers/input/key-uclass.c b/drivers/input/key-uclass.c
index 1fe9f2c267..0db67fb251 100644
--- a/drivers/input/key-uclass.c
+++ b/drivers/input/key-uclass.c
@@ -39,6 +39,7 @@ uint64_t key_timer(uint64_t base)
static int key_adc_event(struct dm_key_uclass_platdata *uc_key, int adcval)
{
+ KEY_ERR("adcval=%d,max=%d,min=%d
",adcval, uc_key->max, uc_key->min);
return (adcval <= uc_key->max && adcval >= uc_key->min) ?
KEY_PRESS_DOWN : KEY_PRESS_NONE;
}
修改parameter分區表
雙系統的分區表使用同一個,需要把linux和android的分區都加上去,如果兩個系統分區名稱有重復的,需要把android的分區名后面加_android來區分。具體如下:
FIRMWARE_VER: 12.0
MACHINE_MODEL: rk3588_s
MACHINE_ID: 007
MANUFACTURER: rockchip
MAGIC: 0x5041524B
ATAG: 0x00200800
MACHINE: rk3588_s
CHECK_MASK: 0x80
PWR_HLD: 0,0,A,0,1
TYPE: GPT
CMDLINE:mtdparts=rk29xxnand:0x00002000@0x00002000(security),0x00002000@0x00004000(uboot),0x00002000@0x00006000(trust),0x00002000@0x00008000(misc_android),0x00002000@0x0000a000(dtbo),0x00000800@0x0000c000(vbmeta),0x00014000@0x0000c800(boot_android),0x00030000@0x00020800(recovery_android),0x000c0000@0x00050800(backup_android),0x000c0000@0x00110800(cache),0x00008000@0x001d0800(metadata),0x00000800@0x001d8800(baseparameter),0x00614000@0x001d9000(super),0x800000@0x007ed000(userdata_android),0x00002000@0x00fed000(misc),0x00020000@0x00fef000(boot),0x00040000@0x0100f000(recovery),0x00010000@0x0104f000(backup),0x01c00000@0x0105f000(rootfs),0x00040000@0x02c5f000(oem),-@0x02c9f000(userdata:grow)
uuid:rootfs=614e0000-0000-4b53-8000-1d28000054a9
** 其中:
uboot分區是linux和android共用的,其他分區都是獨立的;
Android的misc、boot、 recovery、 backup、 userdata分區因為跟linux重復了所以需要改為misc_android boot_android recovery_android backup_android userdata_android
修改Android系統的fstab
由于Android的分區名改了,所以需要fstab里面對應修改掛在的路徑,如下:
fstab的修改
device/rockchip/common:
diff --git a/scripts/fstab_tools/fstab.in b/scripts/fstab_tools/fstab.in
index 2ec6c265..c5098a0c 100755
--- a/scripts/fstab_tools/fstab.in
+++ b/scripts/fstab_tools/fstab.in
@@ -6,10 +6,10 @@ ${_block_prefix}system/system ext4 ro,barrier=1 ${_flags_vbmeta},first_stage
${_block_prefix}vendor/vendor ext4 ro,barrier=1 ${_flags},first_stage_mount
${_block_prefix}odm /odm ext4 ro,barrier=1 ${_flags},first_stage_mount
-/dev/block/by-name/boot /boot emmc defaults ${_flags_chained}first_stage_mount
+/dev/block/by-name/boot_android /boot emmc defaults ${_flags_chained}first_stage_mount
/dev/block/by-name/cache /cache ext4 noatime,nodiratime,nosuid,nodev,noauto_da_alloc,discard wait,check
/dev/block/by-name/metadata /metadata ext4 nodev,noatime,nosuid,discard,sync wait,formattable,first_stage_mount,check
-/dev/block/by-name/misc /misc emmc defaults defaults
+/dev/block/by-name/misc_android /misc emmc defaults defaults
/devices/platform/*usb* auto vfat defaults voldmanaged=usb:auto
@@ -23,6 +23,6 @@ ${_block_prefix}odm /odm ext4 ro,barrier=1 ${_flags},first_stage_mount
# For sdmmc
/devices/platform/${_sdmmc_device}/mmc_host* autoauto defaults voldmanaged=sdcard1:auto
#Full disk encryption has less effect on rk3326, so default to enable this.
-/dev/block/by-name/userdata /data f2fs noatime,nosuid,nodev,discard,reserve_root=32768,resgid=1065 latemount,wait,check,fileencryption=aes-256-xts:aes-256-cts:v2+inlinecrypt_optimized,keydirectory=/metadata/vold/metadata_encryption,quota,formattable,reservedsize=128M,checkpoint=fs
+/dev/block/by-name/userdata_android /data f2fs noatime,nosuid,nodev,discard,reserve_root=32768,resgid=1065,fsync_mode=nobarrier latemount,wait,check,fileencryption=aes-256-xts:aes-256-cts:v2+inlinecrypt_optimized,keydirectory=/metadata/vold/metadata_encryption,quota,formattable,reservedsize=128M,checkpoint=fs
# for ext4
#/dev/block/by-name/userdata /data ext4 discard,noatime,nosuid,nodev,noauto_da_alloc,data=ordered,user_xattr,barrier=1 latemount,wait,formattable,check,fileencryption=software,quota,reservedsize=128M,checkpoint=block
recovery.fstab的修改
對應的recovery的fstab也要修改,修改產品目錄下的recovery.fstab
device/rockchip/rk3588$
diff --git a/rk3588_s/recovery.fstab b/rk3588_s/recovery.fstab
index f7843a1..6a82ccc 100644
--- a/rk3588_s/recovery.fstab
+++ b/rk3588_s/recovery.fstab
@@ -9,20 +9,20 @@
/dev/block/by-name/system_ext /system_ext ext4 defaults defaults
/dev/block/by-name/vendor_dlkm /vendor_dlkm ext4 defaults defaults
/dev/block/by-name/odm_dlkm /odm_dlkm ext4 defaults defaults
/dev/block/by-name/cache /cache ext4 defaults defaults
/dev/block/by-name/metadata /metadata ext4 defaults defaults
-/dev/block/by-name/userdata /data f2fs defaults defaults
+/dev/block/by-name/userdata_android /data f2fs defaults defaults
/dev/block/by-name/cust /cust ext4 defaults defaults
/dev/block/by-name/custom /custom ext4 defaults defaults
/dev/block/by-name/radical_update /radical_update ext4 defaults defaults
-/dev/block/by-name/misc /misc emmc defaults defaults
+/dev/block/by-name/misc_android /misc emmc defaults defaults
/dev/block/by-name/uboot /uboot emmc defaults defaults
/dev/block/by-name/charge /charge emmc defaults defaults
/dev/block/by-name/resource /resource emmc defaults defaults
/dev/block/by-name/parameter /parameter emmc defaults defaults
-/dev/block/by-name/boot /boot emmc defaults defaults
-/dev/block/by-name/recovery /recovery emmc defaults defaults
-/dev/block/by-name/backup /backup emmc defaults defaults
+/dev/block/by-name/boot_android /boot emmc defaults defaults
+/dev/block/by-name/recovery_android /recovery emmc defaults defaults
+/dev/block/by-name/backup_android /backup emmc defaults defaults
/dev/block/by-name/frp /frp emmc defaults defaults
/dev/block/by-name/trust /trust emmc defaults defaults
/dev/block/by-name/baseparamer /baseparamer emmc defaults defaults
Linux系統固件
linux系統的固件軟件不需要修改,可以直接用編譯好的固件
固件燒寫
固件需要燒寫linux和android的固件,如下圖,可以直接右鍵導入上面修改好的parameter.txt文件,然后刪除不需要的燒寫固件分區即可。
注意:uboot、loader、parameter這三個是共用的,只需要燒一份即可。
驗證
固件燒寫完成后第一次默認開機會從linux系統啟動,linux正常啟動后可以按住ESC按鍵,然后重啟系統,ESC要一直按住到android系統啟動完成。
原作者:loitawu
-
Android
+關注
關注
12文章
3923瀏覽量
127128 -
Linux
+關注
關注
87文章
11225瀏覽量
208910 -
開發板
+關注
關注
25文章
4943瀏覽量
97188 -
Uboot
+關注
關注
4文章
125瀏覽量
28165 -
RK3588
+關注
關注
6文章
312瀏覽量
4221
發布評論請先 登錄
相關推薦
評論