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
ti
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
免责声明:文章内容来自互联网,本站不对其真实性负责,也不承担任何法律责任,如有侵权等情况,请与本站联系删除。
转载请注明出处:RK3588 Android+Linux双系统方案的实现-rk3566 linux https://www.yhzz.com.cn/a/6969.html