[6/8] am57xx_hs: avb2.0: add support of AVB 2.0

Message ID 1524662285-19617-7-git-send-email-igor.opaniuk@linaro.org
State New
Headers show
Series
  • Initial integration of AVB2.0
Related show

Commit Message

Igor Opaniuk April 25, 2018, 1:18 p.m.
1. Add vbmeta partition info to android partition layout for am57xx SoC
2. Add support of AVB 2.0 (including avb subset of commands) for am57xx HS

Signed-off-by: Igor Opaniuk <igor.opaniuk@linaro.org>
---
 configs/am57xx_hs_evm_defconfig |  3 +++
 include/configs/am57xx_evm.h    | 11 +++++++++++
 include/environment/ti/boot.h   | 15 +++++++++++++++
 3 files changed, 29 insertions(+)

Comments

Sam Protsenko May 2, 2018, 7:06 p.m. | #1
On 25 April 2018 at 16:18, Igor Opaniuk <igor.opaniuk@linaro.org> wrote:
> 1. Add vbmeta partition info to android partition layout for am57xx SoC
> 2. Add support of AVB 2.0 (including avb subset of commands) for am57xx HS
>
> Signed-off-by: Igor Opaniuk <igor.opaniuk@linaro.org>
> ---
>  configs/am57xx_hs_evm_defconfig |  3 +++
>  include/configs/am57xx_evm.h    | 11 +++++++++++
>  include/environment/ti/boot.h   | 15 +++++++++++++++
>  3 files changed, 29 insertions(+)
>
> diff --git a/configs/am57xx_hs_evm_defconfig b/configs/am57xx_hs_evm_defconfig
> index ca9742f..226537a 100644
> --- a/configs/am57xx_hs_evm_defconfig
> +++ b/configs/am57xx_hs_evm_defconfig
> @@ -81,3 +81,6 @@ CONFIG_USB_GADGET=y
>  CONFIG_USB_GADGET_MANUFACTURER="Texas Instruments"
>  CONFIG_USB_GADGET_VENDOR_NUM=0x0451
>  CONFIG_USB_GADGET_PRODUCT_NUM=0xd022
> +# CONFIG_LIBAVB is not set
> +# CONFIG_LIBAVB_AB is not set
> +# CONFIG_CMD_AVB is not set

Maybe it would be better to put "default n" to corresponding options
in Kconfig? So that we only need to enable those when needed, instead
of disabling in all not related configs. Because otherwise we risk to
have not needed feature enabled in all boards. But "buildman" should
show you that, if you run it for all "arm" boards.

> diff --git a/include/configs/am57xx_evm.h b/include/configs/am57xx_evm.h
> index d1f73f7..020eec1 100644
> --- a/include/configs/am57xx_evm.h
> +++ b/include/configs/am57xx_evm.h
> @@ -38,6 +38,16 @@
>
>  #define CONFIG_SYS_OMAP_ABE_SYSCK
>
> +#define str(a)                         #a

Consider using __stringify_1() or just __stringify() for this.

> +#define VBMETA_PART_SIZE               (64 * 1024)
> +
> +#if defined(CONFIG_LIBAVB)
> +#define VBMETA_PART \
> +       "name=vbmeta,size=" str(VBMETA_PART_SIZE) ",uuid=${uuid_gpt_vbmeta};"
> +#else
> +#define VBMETA_PART                    ""
> +#endif
> +
>  /* Define the default GPT table for eMMC */
>  #define PARTS_DEFAULT \
>         /* Linux partitions */ \
> @@ -61,6 +71,7 @@
>         "name=cache,size=256M,uuid=${uuid_gpt_cache};" \
>         "name=ipu1,size=1M,uuid=${uuid_gpt_ipu1};" \
>         "name=ipu2,size=1M,uuid=${uuid_gpt_ipu2};" \
> +       VBMETA_PART \
>         "name=userdata,size=-,uuid=${uuid_gpt_userdata}"
>
>  #define DFUARGS \
> diff --git a/include/environment/ti/boot.h b/include/environment/ti/boot.h
> index 24b7783..a8336ae 100644
> --- a/include/environment/ti/boot.h
> +++ b/include/environment/ti/boot.h
> @@ -18,6 +18,19 @@
>  #define PARTS_DEFAULT
>  #endif
>
> +#if defined(CONFIG_CMD_AVB)
> +#define AVB_VERIFY_CHECK "if run avb_verify; then " \
> +                               "echo AVB verification OK.;" \
> +                               "set bootargs $bootargs $avb_bootargs;" \
> +                       "else " \
> +                               "echo AVB verification failed.;" \
> +                       "exit; fi;"
> +#define AVB_VERIFY_CMD "avb_verify=avb init 1; avb verify;\0"
> +#else
> +#define AVB_VERIFY_CHECK ""
> +#define AVB_VERIFY_CMD ""
> +#endif
> +
>  #define DEFAULT_COMMON_BOOT_TI_ARGS \
>         "console=" CONSOLEDEV ",115200n8\0" \
>         "fdtfile=undefined\0" \
> @@ -26,6 +39,7 @@
>         "bootfile=zImage\0" \
>         "usbtty=cdc_acm\0" \
>         "vram=16M\0" \
> +       AVB_VERIFY_CMD \
>         "partitions=" PARTS_DEFAULT "\0" \
>         "optargs=\0" \
>         "dofastboot=0\0" \
> @@ -43,6 +57,7 @@
>                 "setenv machid fe6; " \
>                 "mmc dev $mmcdev; " \
>                 "mmc rescan; " \
> +               AVB_VERIFY_CHECK \
>                 "part start mmc ${mmcdev} environment fdt_start; " \
>                 "part size mmc ${mmcdev} environment fdt_size; " \
>                 "part start mmc ${mmcdev} boot boot_start; " \
> --
> 2.7.4
>

Patch

diff --git a/configs/am57xx_hs_evm_defconfig b/configs/am57xx_hs_evm_defconfig
index ca9742f..226537a 100644
--- a/configs/am57xx_hs_evm_defconfig
+++ b/configs/am57xx_hs_evm_defconfig
@@ -81,3 +81,6 @@  CONFIG_USB_GADGET=y
 CONFIG_USB_GADGET_MANUFACTURER="Texas Instruments"
 CONFIG_USB_GADGET_VENDOR_NUM=0x0451
 CONFIG_USB_GADGET_PRODUCT_NUM=0xd022
+# CONFIG_LIBAVB is not set
+# CONFIG_LIBAVB_AB is not set
+# CONFIG_CMD_AVB is not set
diff --git a/include/configs/am57xx_evm.h b/include/configs/am57xx_evm.h
index d1f73f7..020eec1 100644
--- a/include/configs/am57xx_evm.h
+++ b/include/configs/am57xx_evm.h
@@ -38,6 +38,16 @@ 
 
 #define CONFIG_SYS_OMAP_ABE_SYSCK
 
+#define str(a)				#a
+#define VBMETA_PART_SIZE		(64 * 1024)
+
+#if defined(CONFIG_LIBAVB)
+#define VBMETA_PART \
+	"name=vbmeta,size=" str(VBMETA_PART_SIZE) ",uuid=${uuid_gpt_vbmeta};"
+#else
+#define VBMETA_PART			""
+#endif
+
 /* Define the default GPT table for eMMC */
 #define PARTS_DEFAULT \
 	/* Linux partitions */ \
@@ -61,6 +71,7 @@ 
 	"name=cache,size=256M,uuid=${uuid_gpt_cache};" \
 	"name=ipu1,size=1M,uuid=${uuid_gpt_ipu1};" \
 	"name=ipu2,size=1M,uuid=${uuid_gpt_ipu2};" \
+	VBMETA_PART \
 	"name=userdata,size=-,uuid=${uuid_gpt_userdata}"
 
 #define DFUARGS \
diff --git a/include/environment/ti/boot.h b/include/environment/ti/boot.h
index 24b7783..a8336ae 100644
--- a/include/environment/ti/boot.h
+++ b/include/environment/ti/boot.h
@@ -18,6 +18,19 @@ 
 #define PARTS_DEFAULT
 #endif
 
+#if defined(CONFIG_CMD_AVB)
+#define AVB_VERIFY_CHECK "if run avb_verify; then " \
+				"echo AVB verification OK.;" \
+				"set bootargs $bootargs $avb_bootargs;" \
+			"else " \
+				"echo AVB verification failed.;" \
+			"exit; fi;"
+#define AVB_VERIFY_CMD "avb_verify=avb init 1; avb verify;\0"
+#else
+#define AVB_VERIFY_CHECK ""
+#define AVB_VERIFY_CMD ""
+#endif
+
 #define DEFAULT_COMMON_BOOT_TI_ARGS \
 	"console=" CONSOLEDEV ",115200n8\0" \
 	"fdtfile=undefined\0" \
@@ -26,6 +39,7 @@ 
 	"bootfile=zImage\0" \
 	"usbtty=cdc_acm\0" \
 	"vram=16M\0" \
+	AVB_VERIFY_CMD \
 	"partitions=" PARTS_DEFAULT "\0" \
 	"optargs=\0" \
 	"dofastboot=0\0" \
@@ -43,6 +57,7 @@ 
 		"setenv machid fe6; " \
 		"mmc dev $mmcdev; " \
 		"mmc rescan; " \
+		AVB_VERIFY_CHECK \
 		"part start mmc ${mmcdev} environment fdt_start; " \
 		"part size mmc ${mmcdev} environment fdt_size; " \
 		"part start mmc ${mmcdev} boot boot_start; " \