diff mbox series

[v2,1/2] package/amlogic-boot-fip: new host package to sign bootloader for amlogic SoCs

Message ID 20230516155310.1341998-1-sebastian.weyer@smile.fr
State Accepted
Headers show
Series [v2,1/2] package/amlogic-boot-fip: new host package to sign bootloader for amlogic SoCs | expand

Commit Message

Sebastian Weyer May 16, 2023, 3:53 p.m. UTC
This tool is needed by some SoCs to sign the bootloader. The supported
SoCs are the following:
bananapi-cm4io
bananapi-m2-pro
bananapi-m2s
bananapi-m5
beelink-gt1
beelink-s922x
jethub-j100
jethub-j80
khadas-vim
khadas-vim2
khadas-vim3
khadas-vim3l
lafrite
lepotato
nanopi-k2
odroid-c2
odroid-c4
odroid-go-ultra
odroid-hc4
odroid-n2
odroid-n2l
odroid-n2-plus
p200
p201
p212
radxa-zero
radxa-zero2
s400
sei510
sei610
tartiflette-s905d
tartiflette-s912
u200
wetek-core2
wetek-hub
wetek-play2

The variable BR2_PACKAGE_HOST_AMLOGIC_BOOT_FIP_DEVICE is used to specify
for which device this package needs to be used.

This tool uses pre-compiled binaries in order to sign the bootloader.
These binaries are provided under a proprietary license that prohibits
any redistribution of the resulting images.

A similar tool was tried to be added in the past:
http://patchwork.ozlabs.org/project/buildroot/patch/1533545408-11248-2-git-send-email-narmstrong@baylibre.com/
This time however a license file is present which can be used by
make legal-info. Additionally, acs_tool.pyc was replaced by acs_tool.py
and is therefore not compiled anymore.

Signed-off-by: Sebastian Weyer <sebastian.weyer@smile.fr>
---
To my knowledge there is no open-source alternative for A311D SoCs like
the Khadas VIM3. For devices using a S805, S905, S912 or A113D SoC like the
lafrite, the lepotato or the tartiflette, an open-source alternative
might be supported: https://github.com/repk/gxlimg
---
 DEVELOPERS                                    |  3 ++
 package/Config.in.host                        |  1 +
 package/amlogic-boot-fip/Config.in.host       | 52 +++++++++++++++++++
 .../amlogic-boot-fip/amlogic-boot-fip.hash    |  3 ++
 package/amlogic-boot-fip/amlogic-boot-fip.mk  | 31 +++++++++++
 5 files changed, 90 insertions(+)
 create mode 100644 package/amlogic-boot-fip/Config.in.host
 create mode 100644 package/amlogic-boot-fip/amlogic-boot-fip.hash
 create mode 100644 package/amlogic-boot-fip/amlogic-boot-fip.mk

Comments

Romain Naour Sept. 30, 2023, 7:41 p.m. UTC | #1
Hello Sebastian,

Le 16/05/2023 à 17:53, Sebastian Weyer a écrit :
> This tool is needed by some SoCs to sign the bootloader. The supported
> SoCs are the following:
> bananapi-cm4io
> bananapi-m2-pro
> bananapi-m2s
> bananapi-m5
> beelink-gt1
> beelink-s922x
> jethub-j100
> jethub-j80
> khadas-vim
> khadas-vim2
> khadas-vim3
> khadas-vim3l
> lafrite
> lepotato
> nanopi-k2
> odroid-c2
> odroid-c4
> odroid-go-ultra
> odroid-hc4
> odroid-n2
> odroid-n2l
> odroid-n2-plus
> p200
> p201
> p212
> radxa-zero
> radxa-zero2
> s400
> sei510
> sei610
> tartiflette-s905d
> tartiflette-s912
> u200
> wetek-core2
> wetek-hub
> wetek-play2
> 
> The variable BR2_PACKAGE_HOST_AMLOGIC_BOOT_FIP_DEVICE is used to specify
> for which device this package needs to be used.
> 
> This tool uses pre-compiled binaries in order to sign the bootloader.
> These binaries are provided under a proprietary license that prohibits
> any redistribution of the resulting images.
> 
> A similar tool was tried to be added in the past:
> http://patchwork.ozlabs.org/project/buildroot/patch/1533545408-11248-2-git-send-email-narmstrong@baylibre.com/
> This time however a license file is present which can be used by
> make legal-info. Additionally, acs_tool.pyc was replaced by acs_tool.py
> and is therefore not compiled anymore.
> 
> Signed-off-by: Sebastian Weyer <sebastian.weyer@smile.fr>

I did some minor rework before applying to master!

Best regards,
Romain


> ---
> To my knowledge there is no open-source alternative for A311D SoCs like
> the Khadas VIM3. For devices using a S805, S905, S912 or A113D SoC like the
> lafrite, the lepotato or the tartiflette, an open-source alternative
> might be supported: https://github.com/repk/gxlimg
> ---
>  DEVELOPERS                                    |  3 ++
>  package/Config.in.host                        |  1 +
>  package/amlogic-boot-fip/Config.in.host       | 52 +++++++++++++++++++
>  .../amlogic-boot-fip/amlogic-boot-fip.hash    |  3 ++
>  package/amlogic-boot-fip/amlogic-boot-fip.mk  | 31 +++++++++++
>  5 files changed, 90 insertions(+)
>  create mode 100644 package/amlogic-boot-fip/Config.in.host
>  create mode 100644 package/amlogic-boot-fip/amlogic-boot-fip.hash
>  create mode 100644 package/amlogic-boot-fip/amlogic-boot-fip.mk
> 
> diff --git a/DEVELOPERS b/DEVELOPERS
> index e76717e845..53ce8408db 100644
> --- a/DEVELOPERS
> +++ b/DEVELOPERS
> @@ -2589,6 +2589,9 @@ F:	support/misc/toolchainfile.cmake.in
>  N:	Sam Voss <sam.voss@gmail.com>
>  F:	package/ripgrep/
>  
> +N:	Sebastian Weyer <sebastian.weyer@smile.fr>
> +F:	package/amlogic-boot-fip
> +
>  N:	Sébastien Szymanski <sebastien.szymanski@armadeus.com>
>  F:	package/mmc-utils/
>  F:	package/python-flask-jsonrpc/
> diff --git a/package/Config.in.host b/package/Config.in.host
> index dcadbfdfc1..074adc51f2 100644
> --- a/package/Config.in.host
> +++ b/package/Config.in.host
> @@ -3,6 +3,7 @@ menu "Host utilities"
>  	source "package/abootimg/Config.in.host"
>  	source "package/aespipe/Config.in.host"
>  	source "package/agent-proxy/Config.in.host"
> +	source "package/amlogic-boot-fip/Config.in.host"
>  	source "package/android-tools/Config.in.host"
>  	source "package/asn1c/Config.in.host"
>  	source "package/babeltrace2/Config.in.host"
> diff --git a/package/amlogic-boot-fip/Config.in.host b/package/amlogic-boot-fip/Config.in.host
> new file mode 100644
> index 0000000000..14ecc63bff
> --- /dev/null
> +++ b/package/amlogic-boot-fip/Config.in.host
> @@ -0,0 +1,52 @@
> +config BR2_PACKAGE_HOST_AMLOGIC_BOOT_FIP
> +	bool "host amlogic-boot-fip"
> +	depends on BR2_HOSTARCH = "x86_64"
> +	help
> +	  Firmware Image Pacakge (FIP) sources used to sign Amlogic
> +	  u-boot binaries in LibreELEC images
> +
> +	  https://github.com/LibreELEC/amlogic-boot-fip
> +
> +config BR2_PACKAGE_HOST_AMLOGIC_BOOT_FIP_DEVICE
> +	string "amlogic-boot-fip device"
> +	default "khadas-vim3"
> +	depends on BR2_PACKAGE_HOST_AMLOGIC_BOOT_FIP
> +	help
> +	  Device for which you want to use this package.
> +	  Valid options are:
> +	  bananapi-cm4io
> +	  bananapi-m2-pro
> +	  bananapi-m2s
> +	  bananapi-m5
> +	  beelink-gt1
> +	  beelink-s922x
> +	  jethub-j100
> +	  jethub-j80
> +	  khadas-vim
> +	  khadas-vim2
> +	  khadas-vim3
> +	  khadas-vim3l
> +	  lafrite
> +	  lepotato
> +	  nanopi-k2
> +	  odroid-c2
> +	  odroid-c4
> +	  odroid-go-ultra
> +	  odroid-hc4
> +	  odroid-n2
> +	  odroid-n2l
> +	  odroid-n2-plus
> +	  p200
> +	  p201
> +	  p212
> +	  radxa-zero
> +	  radxa-zero2
> +	  s400
> +	  sei510
> +	  sei610
> +	  tartiflette-s905d
> +	  tartiflette-s912
> +	  u200
> +	  wetek-core2
> +	  wetek-hub
> +	  wetek-play2
> diff --git a/package/amlogic-boot-fip/amlogic-boot-fip.hash b/package/amlogic-boot-fip/amlogic-boot-fip.hash
> new file mode 100644
> index 0000000000..1a08341532
> --- /dev/null
> +++ b/package/amlogic-boot-fip/amlogic-boot-fip.hash
> @@ -0,0 +1,3 @@
> +# Locally calculated
> +sha256  2cc06bc7d5647fd8c0025181fa42c4a8ef0ed16b918a1fa2060ea83c22e47b20  amlogic-boot-fip-e96b6a694380ff07d5a9e4be644ffe254bd18512.tar.gz
> +sha256  4255537f71b1cd0d487de0fa2b8eddf1eb96ed96d119507336dde8b3782b86e6  LICENSE
> diff --git a/package/amlogic-boot-fip/amlogic-boot-fip.mk b/package/amlogic-boot-fip/amlogic-boot-fip.mk
> new file mode 100644
> index 0000000000..0cb7a8d93f
> --- /dev/null
> +++ b/package/amlogic-boot-fip/amlogic-boot-fip.mk
> @@ -0,0 +1,31 @@
> +################################################################################
> +#
> +# amlogic-boot-fip
> +#
> +################################################################################
> +
> +AMLOGIC_BOOT_FIP_VERSION = e96b6a694380ff07d5a9e4be644ffe254bd18512
> +AMLOGIC_BOOT_FIP_SITE = $(call github,LibreELEC,amlogic-boot-fip,$(AMLOGIC_BOOT_FIP_VERSION))
> +AMLOGIC_BOOT_FIP_LICENSE = PROPRIETARY
> +AMLOGIC_BOOT_FIP_LICENSE_FILES = LICENSE
> +
> +AMLOGIC_BOOT_FIP_INSTALL_DIR = $(BINARIES_DIR)/amlogic-boot-fip
> +
> +AMLOGIC_BOOT_FIP_DEVICE = $(BR2_PACKAGE_HOST_AMLOGIC_BOOT_FIP_DEVICE)
> +
> +define HOST_AMLOGIC_BOOT_FIP_INSTALL_CMDS
> +	mkdir -p $(AMLOGIC_BOOT_FIP_INSTALL_DIR)/$(AMLOGIC_BOOT_FIP_DEVICE)
> +	$(INSTALL) -D -m 0755 $(@D)/build-all-fip.sh $(AMLOGIC_BOOT_FIP_INSTALL_DIR)
> +	$(INSTALL) -D -m 0755 $(@D)/build-fip.sh $(AMLOGIC_BOOT_FIP_INSTALL_DIR)
> +	$(INSTALL) -D -m 0755 $(@D)/g12a.inc $(AMLOGIC_BOOT_FIP_INSTALL_DIR)
> +	$(INSTALL) -D -m 0755 $(@D)/$(AMLOGIC_BOOT_FIP_DEVICE)/* $(AMLOGIC_BOOT_FIP_INSTALL_DIR)/$(AMLOGIC_BOOT_FIP_DEVICE)
> +endef
> +
> +# check for empty device string when we're building
> +ifeq ($(BR2_PACKAGE_HOST_AMLOGIC_BOOT_FIP)$(BR_BUILDING),yy)
> +ifeq ($(call qstrip,$(BR2_PACKAGE_HOST_AMLOGIC_BOOT_FIP_DEVICE)),)
> +$(error No device specified for amlogic-boot-fip, please check your BR2_PACKAGE_HOST_AMLOGIC_BOOT_FIP_DEVICE setting)
> +endif
> +endif
> +
> +$(eval $(host-generic-package))
diff mbox series

Patch

diff --git a/DEVELOPERS b/DEVELOPERS
index e76717e845..53ce8408db 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -2589,6 +2589,9 @@  F:	support/misc/toolchainfile.cmake.in
 N:	Sam Voss <sam.voss@gmail.com>
 F:	package/ripgrep/
 
+N:	Sebastian Weyer <sebastian.weyer@smile.fr>
+F:	package/amlogic-boot-fip
+
 N:	Sébastien Szymanski <sebastien.szymanski@armadeus.com>
 F:	package/mmc-utils/
 F:	package/python-flask-jsonrpc/
diff --git a/package/Config.in.host b/package/Config.in.host
index dcadbfdfc1..074adc51f2 100644
--- a/package/Config.in.host
+++ b/package/Config.in.host
@@ -3,6 +3,7 @@  menu "Host utilities"
 	source "package/abootimg/Config.in.host"
 	source "package/aespipe/Config.in.host"
 	source "package/agent-proxy/Config.in.host"
+	source "package/amlogic-boot-fip/Config.in.host"
 	source "package/android-tools/Config.in.host"
 	source "package/asn1c/Config.in.host"
 	source "package/babeltrace2/Config.in.host"
diff --git a/package/amlogic-boot-fip/Config.in.host b/package/amlogic-boot-fip/Config.in.host
new file mode 100644
index 0000000000..14ecc63bff
--- /dev/null
+++ b/package/amlogic-boot-fip/Config.in.host
@@ -0,0 +1,52 @@ 
+config BR2_PACKAGE_HOST_AMLOGIC_BOOT_FIP
+	bool "host amlogic-boot-fip"
+	depends on BR2_HOSTARCH = "x86_64"
+	help
+	  Firmware Image Pacakge (FIP) sources used to sign Amlogic
+	  u-boot binaries in LibreELEC images
+
+	  https://github.com/LibreELEC/amlogic-boot-fip
+
+config BR2_PACKAGE_HOST_AMLOGIC_BOOT_FIP_DEVICE
+	string "amlogic-boot-fip device"
+	default "khadas-vim3"
+	depends on BR2_PACKAGE_HOST_AMLOGIC_BOOT_FIP
+	help
+	  Device for which you want to use this package.
+	  Valid options are:
+	  bananapi-cm4io
+	  bananapi-m2-pro
+	  bananapi-m2s
+	  bananapi-m5
+	  beelink-gt1
+	  beelink-s922x
+	  jethub-j100
+	  jethub-j80
+	  khadas-vim
+	  khadas-vim2
+	  khadas-vim3
+	  khadas-vim3l
+	  lafrite
+	  lepotato
+	  nanopi-k2
+	  odroid-c2
+	  odroid-c4
+	  odroid-go-ultra
+	  odroid-hc4
+	  odroid-n2
+	  odroid-n2l
+	  odroid-n2-plus
+	  p200
+	  p201
+	  p212
+	  radxa-zero
+	  radxa-zero2
+	  s400
+	  sei510
+	  sei610
+	  tartiflette-s905d
+	  tartiflette-s912
+	  u200
+	  wetek-core2
+	  wetek-hub
+	  wetek-play2
diff --git a/package/amlogic-boot-fip/amlogic-boot-fip.hash b/package/amlogic-boot-fip/amlogic-boot-fip.hash
new file mode 100644
index 0000000000..1a08341532
--- /dev/null
+++ b/package/amlogic-boot-fip/amlogic-boot-fip.hash
@@ -0,0 +1,3 @@ 
+# Locally calculated
+sha256  2cc06bc7d5647fd8c0025181fa42c4a8ef0ed16b918a1fa2060ea83c22e47b20  amlogic-boot-fip-e96b6a694380ff07d5a9e4be644ffe254bd18512.tar.gz
+sha256  4255537f71b1cd0d487de0fa2b8eddf1eb96ed96d119507336dde8b3782b86e6  LICENSE
diff --git a/package/amlogic-boot-fip/amlogic-boot-fip.mk b/package/amlogic-boot-fip/amlogic-boot-fip.mk
new file mode 100644
index 0000000000..0cb7a8d93f
--- /dev/null
+++ b/package/amlogic-boot-fip/amlogic-boot-fip.mk
@@ -0,0 +1,31 @@ 
+################################################################################
+#
+# amlogic-boot-fip
+#
+################################################################################
+
+AMLOGIC_BOOT_FIP_VERSION = e96b6a694380ff07d5a9e4be644ffe254bd18512
+AMLOGIC_BOOT_FIP_SITE = $(call github,LibreELEC,amlogic-boot-fip,$(AMLOGIC_BOOT_FIP_VERSION))
+AMLOGIC_BOOT_FIP_LICENSE = PROPRIETARY
+AMLOGIC_BOOT_FIP_LICENSE_FILES = LICENSE
+
+AMLOGIC_BOOT_FIP_INSTALL_DIR = $(BINARIES_DIR)/amlogic-boot-fip
+
+AMLOGIC_BOOT_FIP_DEVICE = $(BR2_PACKAGE_HOST_AMLOGIC_BOOT_FIP_DEVICE)
+
+define HOST_AMLOGIC_BOOT_FIP_INSTALL_CMDS
+	mkdir -p $(AMLOGIC_BOOT_FIP_INSTALL_DIR)/$(AMLOGIC_BOOT_FIP_DEVICE)
+	$(INSTALL) -D -m 0755 $(@D)/build-all-fip.sh $(AMLOGIC_BOOT_FIP_INSTALL_DIR)
+	$(INSTALL) -D -m 0755 $(@D)/build-fip.sh $(AMLOGIC_BOOT_FIP_INSTALL_DIR)
+	$(INSTALL) -D -m 0755 $(@D)/g12a.inc $(AMLOGIC_BOOT_FIP_INSTALL_DIR)
+	$(INSTALL) -D -m 0755 $(@D)/$(AMLOGIC_BOOT_FIP_DEVICE)/* $(AMLOGIC_BOOT_FIP_INSTALL_DIR)/$(AMLOGIC_BOOT_FIP_DEVICE)
+endef
+
+# check for empty device string when we're building
+ifeq ($(BR2_PACKAGE_HOST_AMLOGIC_BOOT_FIP)$(BR_BUILDING),yy)
+ifeq ($(call qstrip,$(BR2_PACKAGE_HOST_AMLOGIC_BOOT_FIP_DEVICE)),)
+$(error No device specified for amlogic-boot-fip, please check your BR2_PACKAGE_HOST_AMLOGIC_BOOT_FIP_DEVICE setting)
+endif
+endif
+
+$(eval $(host-generic-package))