Commit Graph

51 Commits

Author SHA1 Message Date
Kever Yang fd810b8003 android: return fail if not found misc partition
Return directly and do not continue read from misc partition
if there is no partition.

Change-Id: I549d123632aecc5bd29ebdc2c4c7917c76750247
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
2019-02-15 10:15:32 +08:00
Joseph Chen 10e1f9ebb7 android: fix avb enable state set error
Fixes: 8e66ecd25d
(android: fix get wrong ramdisk address when avb verify)

Change-Id: I6b28ee32824e97e7eaed4aa8a530903d8486004b
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-31 20:00:49 +08:00
Joseph Chen 8e66ecd25d android: fix get wrong ramdisk address when avb verify
- add interface to get android avb enable state;
- get ramdisk from "ramdisk_addr_r" only when android avb disabled
  and CONFIG_ANDROID_BOOT_IMAGE_SEPARATE is enabled;

(fixes: 644e344 android: support loading android image separate)

Change-Id: I7280f911a0c5db851d119acb458b3f335dc28bce
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-30 16:51:22 +08:00
Joseph Chen 644e344181 android: support loading android image separate
This patch support loading android image separate for the
kernel/ramdisk/second images. It is disabled when android
AVB is enabled, because AVB need verify the full android image.

It brings some benefits, mainly for saving a lot of boot time:
  - allow skip load second content when kernel dtb is enabled;
  - allow skip fdt and ramdisk relocation during bootm boot flow;
  - allow loading fdt/ramdisk to "fdt_addr_r"/"ramdisk_addr_r";
  - avoid android image too large when load to ram;

Change-Id: Ia040b3031307a8a7c98b011ce038ec61fee6804a
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-24 15:33:12 +08:00
Jason Zhu e92f47e469 android: test the vbmeta to enable avb
Change-Id: I36d6473a247ab7fc012ceb9a7c9a43e14e701611
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2019-01-22 16:59:11 +08:00
Jian Qiu c2ba77d93f lib: optee_client: Extract keymaster CA module
Extract keymaster CA module from OpteeClientInterface
refactoring code for keymaster reads and writes form caller module

Change-Id: I1069fce0d29d9d9815f71e7f3b4d231754382acd
Signed-off-by: Jian Qiu <qiujian@rock-chips.com>
2019-01-18 09:09:34 +08:00
Jason Zhu d549e1d1e1 android: add androidboot.verifiedbootstate
Since the androidboot.verifiedbootstate is required in android Pie, so add
it to bootargs when secure boot flag is not set.

Change-Id: I4a883ca87bbba321a894ee66ebcf0ff9d5cb6ca8
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2019-01-14 11:52:51 +08:00
Joseph Chen 1153acfe76 android: print android avb enable state
Change-Id: I0be76d29eef3614d4885e2d69048cf521352ffc0
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-10 18:24:21 +08:00
Jason Zhu 424bfdcf40 android: enable secure boot by vboot_flag
We read the vboot_flag which is the flag of secure boot to enable
verified boot in uboot.

Change-Id: I592473ad14f9e19c6529602d029b7ec2fb335da8
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-08 15:44:38 +08:00
Joseph Chen 67c90ac350 android: include fdt_support.h file
fix compile error when enable fdt overlay

Change-Id: I283ef3cd44aeb6c64f3362907fcc399919401345
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-03 10:32:24 +08:00
Jason Zhu 270ed4a992 android: fix compare slot_suffix error
If slot_suffix is equal to "_a", slot_index_to_boot is equal to '0'
but not '1' when use function strncmp.

Change-Id: I53ffc920824e03c923f1d9ab8fd326a733c59654
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2018-12-29 14:38:16 +08:00
Joseph Chen b4913f9584 android: make android boot message more accurate and clear
1. Actually, the "kernel_address" is android header address but not
   real kernel address, let's use "kernel_addr_r/c" to verbose.

2. print compressed type info, like:
   "Booting LZ4 kernel at 0x02480000(Uncompress to 00680000) with fdt at 1f00000..." or
   "Booting kernel at 0x00680000 with fdt at 0x1f00000..."

Change-Id: Ifb628ab355670681f78d8f73893baddee21223a0
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2018-12-10 16:27:42 +08:00
Joseph Chen ee465021fe android: support boot images packed with rockchip android hdr
For some legacy reasons, rockchip use mkbootimg tool to pack android
images with special pack parameters(SDK version lower than 8.1) to
assign kernel/ramdisk/seconds address and page size.

Android hdr on RK3399 SDK-7.1:
   kernel size:      1299808
   kernel address:   60408000
   ramdisk size:     1e6b80
   ramdisk addrress: 62000000
   second size:      41c00
   second address:   60f00000
   tags address:     60088000
   page size:        4000
   header_version:   0
   os_version:       e041114 (ver: 1.7.2, level: 2017.4)
   name:
   cmdline:          buildvariant=userdebug

The kernel/ramdisk/seconds address base is not from 0x10000000 and
page size is not 0x800!

This patch makes bootflow to compatible with above legacy packing.

Change-Id: I663a0d1386694658c97586706ff21ed887d6a2e7
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2018-11-01 08:42:27 +08:00
Jason Zhu 4171cf46e3 android: fix error when the vbmeta is NULL or verification error
If the vbmeta has no data or verify errors occur, the system get abort:
"Synchronous Abort" handler, esr 0x96000010
* Relocate offset = 000000003db40000
* ELR(PC)    =   0000000000220d2c
* LR         =   0000000000220d08
* SP         =   0000000031d35040

Change-Id: I452e9b109ef5f61dfc338ff5bfb72a687a2b0003
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2018-10-29 15:53:34 +08:00
Joseph Chen 5af94f7887 android: get fdt by suitable ways
We may have special operations for fdt(optional):
- apply fdt overlay;
- select fdt by adc or gpio;

We can't read default rk-kernel.dtb and pass it to kernel,
call rockchip_read_dtb_file() to get dtb.

Change-Id: I3aba002b0cfe324cc7c3852bf8b9561575590fd4
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2018-10-07 09:19:03 +08:00
Zhangbin Tong affcebcd8f android: verity: Fix environment variable "bootargs" override
Change-Id: Idd079d8773f536928d02f1b32bb562d5540ee85a
Signed-off-by: Zhangbin Tong <zebulun.tong@rock-chips.com>
2018-09-06 16:57:28 +08:00
Jason Zhu fc7985c1ac android: add 'root=PARTUUID=xxx-xxx'
Set 'root=PARTUUID=' to bootargs When use the CONFIG_ANDROID_AB.

Change-Id: I9760f1a9ad67ba1f2cb334a0af50db464d87816b
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2018-08-17 11:31:07 +08:00
Joseph Chen 9e228ce338 android: dtbo: fix "androidboot.dtbo_" => "androidboot.dtbo_idx="
Change-Id: Iefc050e4c503d5e79843c840a8d0b3a002dd9833
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2018-08-16 15:28:43 +08:00
Jason Zhu dc3aa58f81 android: add verify state to cmdline
When we use avb, we will add the verify result to cmdline.
The format is "androidboot.verifiedbootstate=green, yellow
orange, or red".

Change-Id: I0059fbd7e73225f580bb5bf0b5e4b04faeb22f45
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2018-08-13 15:20:44 +08:00
Joseph Chen edac97f481 android: dtbo: enable depends on CONFIG_CMD_DTIMG
Change-Id: I04ba7d39fed1b5c6950a3882f04de5420dfcff2e
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2018-08-09 14:23:17 +08:00
Joseph Chen f8dbe86116 android: support dtb overlay
- read dtbo from recovery or dtbo partition;
- append "androidboot.dtbo_idx" to cmdline;
- apply dtb overlay when first read kernel dtb;
- pass dtb that first time read to kernel;

Change-Id: Iba5c02c1307d3dad69ef96d3b3b0927fb507be8f
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2018-08-06 11:15:19 +08:00
Jason Zhu d34064effa android: get dev_desc by rockchip_get_bootdev()
Get dev_desc by call rockchip_get_bootdev() but not
default mmc 0.

Change-Id: I78c6760eb6410a14a9f767db2f90902ec97f432f
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2018-07-19 09:57:37 +08:00
Jian Qiu 65413a00f9 fastboot: add FASTBOOT_OEM_UNLOCK option
This enables the following fastboot commands:
  fastboot oem unlock
  fastboot oem unlock_accept
  fastboot oem lock
  fastboot getvar oem-unlock

Android 8.1 need the oem unlock status attach to bootargs on boot.

Change-Id: Icc83451336a4dea2cbcf4927287de23bc8e28cb1
Signed-off-by: Jian Qiu <qiujian@rock-chips.com>
2018-07-19 09:56:14 +08:00
Andy Yan e2ced6c33b android: only take the successed return value as load_address from android_image_load
Function android_image_load will return a negative value in case
of error. We should check the return value first before take it
as an unsigned long load_address.

This fix 008aee876ae5("boot_android: add runtime compatible for
un/compressed kernel image"), which may cause system panic on
a system that boot with none-android format image.

Change-Id: I7f67c322d4ef343328b2276fe83432716148a76d
Signed-off-by: Andy Yan <andy.yan@rock-chips.com>
2018-07-16 09:05:39 +08:00
Andy Yan 008aee876a boot_android: add runtime compatible for un/compressed kernel image
This patch add auto parse the compress format of kernel image.
Then decompress the compressed kernel image for arm64, as for
arm32 zImage, we only need to load it to a higher memory, then
the kernel will handle the decompress itself.

Test on RK3308 AARCH64 mode (Cortex A35 816 MHZ) boot with eMMC:

------------------------------------------------------------------
Format    |  Size(Byte) | Ratio | Decomp time(ms) | Boot time(ms) |
-------------------------------------------------------------------
Image     | 7720968     |       |                 |     488       |
-------------------------------------------------------------------
Image.lz4 | 4119448     | 53%   |       59        |     455       |
-------------------------------------------------------------------
Image.lzo | 3858322     | 49%   |       141       |     536       |
-------------------------------------------------------------------
Image.gz  | 3529108     | 45%   |       222       |     609       |
-------------------------------------------------------------------
Image.bz2 | 3295914     | 42%   |       2940      |               |
-------------------------------------------------------------------
Image.lzma| 2683750     | 34%   |                 |               |
-------------------------------------------------------------------

Note: the boot time is counted from first ddr init log to first Kernel log.

Change-Id: I73b12ec944fbc8238b0e061a37e2f31aa3093231
Signed-off-by: Andy Yan <andy.yan@rock-chips.com>
2018-07-14 11:39:04 +08:00
Jason Zhu 051c625387 android: fix android_bootloader_message_write bug
Acording to rockchip, the bootloader message is storaged
in the misc, and the offset address is BOOTLOADER_MESSAGE_BLK_OFFSET
blocks. But the offset address is zero in the normal state.
So add the CONFIG_RKIMG_BOOTLOADER to seperate it.

Change-Id: Ie4cd473ff9a32f578fe901b48689e60c7a28012a
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2018-06-28 16:26:46 +08:00
Jason Zhu 8e620d08b8 android: add the default fastbootcmd
Run the default fastbootcmd if can not get fastbootcmd
from env.

Change-Id: Iaf4d155a9737dd712673f1a7ab9543dc405343fa
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2018-06-25 09:11:32 +08:00
Jason Zhu 9cc336e89e android: bring up the kernel if device is unlock
If the device is unlock, the device can be brought
up when use avb.

Change-Id: I82dd71d33f47dda0a760740428988dd658a96713
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2018-06-05 08:56:54 +08:00
Joseph Chen 93d59c05c7 android: fix "reboot recovery" command doesn't work
If not find recovery message in misc partition, we try to check
kernel reboot command.

Change-Id: I25847cb5cc06efc39c419426ab6dbe9acde3797d
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2018-05-25 17:48:46 +08:00
qiujian 9e68721b27 bootargs : read oem unlock status
Read oem unlock status from optee_client api
and attach it to bootargs

Change-Id: Ib8b1a9bc115ec9cb7e5ce09dc50845cfd7c1c81b
Signed-off-by: Qiu Jian <qiujian@rock-chips.com>
2018-04-03 10:30:56 +08:00
jason.zhu 5353f2a9a0 android: fix memory overflow
In the function android_assemble_cmdline, the allocated_suffix
size must be strlen(ANDROID_ARG_SLOT_SUFFIX) + strlen(slot_suffix)
+1. If not, the later strcpy and strcat operation will be
out of bounds.

Change-Id: Ib0ed73ebc2f076c8dc8afac168c7aaeccfddfa67
Signed-off-by: jason.zhu <jason.zhu@rock-chips.com>
2018-04-02 16:15:23 +08:00
qiujian 91c73fb4d1 lib: optee_client:Support attestation
Add methods to read attestation key from the misc partition of
 last 64K, store key and certificate chain data in secure storage.

 When CONFIG_OPTEE_CLIENT is defined,
 uboot support load attestation data.

Change-Id: I8f3bd7096a7856de9e58d294822a818d5fe380ba
Signed-off-by: qiujian <qiujian@rock-chips.com>
2018-03-21 16:38:08 +08:00
Jason Zhu 2301a6f51c rockchip: resrouce_img: support a/b
If apply the a/b system, open the macro CONFIG_ANDROID_AB.
Then get the dtb from the boot '_a' or '_b' image.

Change-Id: I21ad9d5a5e6e63e26bc16b1aeeb2e690c669a535
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2018-03-05 14:42:53 +08:00
Kever Yang e4feb814ab rockchip: android: fix compile warning
Change-Id: Ic89e97a852999a9ec929942b1b612f13cc43f57f
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
2018-02-11 19:49:52 +08:00
Jason Zhu b666ac0523 android: support android verified boot(AVB)
Define CONFIG_ANDROID_AVB to open avb.

Change-Id: Iae0306391e403b25aa454205dd5a70a578752aba
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2018-02-10 10:48:34 +08:00
Jason Zhu 8f254cea36 android: change enter recovery and a/b mode
Choose which partition to enter recovery and a/b depend
on CONFIG_ANDROID_AB.

Change-Id: I10d03f1c592702f857e6224566deea3a4d607788
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2018-02-10 10:48:25 +08:00
Jason Zhu 37a7bc39c0 lib: avb: update and modify the avb library
The commit point is updated to google external/avb/
which commit point is cf8c56208d2d9643804a7f123b196c7ebc9af276.

Change-Id: I5a10a8a45d3e9e2c9d20d9b3d44946073c9a49ff
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2018-02-10 10:41:04 +08:00
Jason Zhu f52e474fa5 android: support slot suffix
If the device support the AB system, must add the slot suffix
to partition.

Change-Id: Ibac54109dd937e22a76e6fa68e9fdd1c0be48cc1
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2018-02-05 21:02:00 +08:00
Joseph Chen 1f5bcda2a8 android: replace CONFIG_ROCKCHIP_BOOTLOADER with CONFIG_RKIMG_BOOTLOADER
Change-Id: I24db85313652bd21aada68cd472bdf888b7d022d
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2018-01-24 18:17:48 +08:00
Jason Zhu 2ab11bbe30 android: support the new android format mode
In the new android images, the ramdisk.img is packed in the
system.img. So transmit the "skip_initramfs" to cmdline to
ignore the ramdisk.img (if have) loaded from boot.img.

Change-Id: I1b2051d65078c903411f3ddcc0c7803cbd6892f4
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2018-01-23 09:34:04 +08:00
Jason Zhu b7570de26c android: modify the fdt_addr
The env fdt_addr must be set as hex.

Change-Id: I75ffeb832a4b44dcadafdcfecfc6bb282e495b83
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2018-01-18 10:00:58 +08:00
Kever Yang 891380b57d cmd: boot_android: support legacy aosp image from rockchip
New cmd usage:
boot_android mmc 0

update boot_android:
- do not need provide argv for misc partition and slot
- If CONFIG_ROCKCHIP_RESOURCE_IMAGE is enabled, try to get dtb from resource
partition.

Change-Id: I7242880f9cde916ca10d677ddac07790c66a07a4
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
2017-12-08 18:13:25 +08:00
Weiwen Chen 90e877b59c android: load fdt from the oem partition
The fdt must be named of "kernel.dtb", and it's saved
in the root dir of the oem partition.

Change-Id: I70dc9cbbc295f23b08bf122df3b29bba7dacb82f
Signed-off-by: Weiwen Chen <cww@rock-chips.com>
2017-11-20 10:32:54 +08:00
Weiwen Chen 8ce4d2843d android: add api for loading fdt
If user get the kernel fdt into the independent partition
which is the ext4 filesystem, we can use this api to load
fdt.

Change-Id: I4fa494beffecb41e8c0e4c02f1e782d0291e2d05
Signed-off-by: Weiwen Chen <cww@rock-chips.com>
2017-11-20 10:32:54 +08:00
Jason Zhu b3b934b636 android: boot the system without a/b and avb
Change-Id: I9a6da661c9cf17e2e3190b55f18acd600f9b63f1
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2017-11-20 10:32:54 +08:00
Cody Xie 0e3d235ecd androidboot: Pass "androidboot.serialno" to kernel cmdline.
Change-Id: Ia0b693f2652ab35b2e29b1c23335f962b3943050
Signed-off-by: Cody Xie <cody.xie@rock-chips.com>
2017-11-20 10:26:12 +08:00
Jason Zhu de183ed0f1 android: declare some functions externally
In file boot_android.c, we use some functions
belong to common/android_bootloader.c. BUt these
functions attribute are static. So we modify these
functions used in the boot_android.c.

And android_avb_boot_flow is added to boot a/b
android system.

Change-Id: I3ebc0a6fb24691ab1a0f8475220e16ca633412f1
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2017-11-14 10:55:50 +08:00
Alex Deymo a49a055226 android: Pass the ramdisk to the kernel.
Android kernel image format can include an initramfs image in the same
kernel partition. This patch passes the initramfs to the kernel, which
in the normal boot mode ignores it by passing "skip_initramfs" in the
command line.

Bug: 34346003
Test: `am broadcast -a android.intent.action.MASTER_CLEAR` factory
reseted the device.

Change-Id: I21d89e34a0f54badf3b2e3ad8981cef75f6d5edf
2017-11-14 10:55:47 +08:00
Alex Deymo 170e9eb9d1 android: Fix off-by-one error when joining strings
When concatenating the strings to form a new command line in the
android bootloader flow, the null-terminator was placed one byte after
the end of the allocated string.

Bug: None
Test: booted a rpi3.
Change-Id: I120e09a77bb1c27980e7ce2b5f9b8961424ed0c3
2017-11-14 10:55:47 +08:00
Alex Deymo 8062224026 boot_android: Pass the slot from the command.
In order to support booting from either slot, this patch passes the
slot name from the command line.

Bug: 32707546
Test: Booted rpi3.
Change-Id: I30582bd8b1b95dc0f25b0c6624e7909ee4118bd0
2017-11-14 10:55:46 +08:00