summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/hash.c13
-rw-r--r--common/spl/Kconfig13
-rw-r--r--lib/Kconfig5
-rw-r--r--lib/Makefile4
-rw-r--r--tools/Kconfig5
5 files changed, 31 insertions, 9 deletions
diff --git a/common/hash.c b/common/hash.c
index 3b591ba09e..79202e18a2 100644
--- a/common/hash.c
+++ b/common/hash.c
@@ -178,7 +178,7 @@ static int hash_finish_crc16_ccitt(struct hash_algo *algo, void *ctx,
return 0;
}
-static int hash_init_crc32(struct hash_algo *algo, void **ctxp)
+static int __maybe_unused hash_init_crc32(struct hash_algo *algo, void **ctxp)
{
uint32_t *ctx = malloc(sizeof(uint32_t));
*ctx = 0;
@@ -186,15 +186,16 @@ static int hash_init_crc32(struct hash_algo *algo, void **ctxp)
return 0;
}
-static int hash_update_crc32(struct hash_algo *algo, void *ctx,
- const void *buf, unsigned int size, int is_last)
+static int __maybe_unused hash_update_crc32(struct hash_algo *algo, void *ctx,
+ const void *buf, unsigned int size,
+ int is_last)
{
*((uint32_t *)ctx) = crc32(*((uint32_t *)ctx), buf, size);
return 0;
}
-static int hash_finish_crc32(struct hash_algo *algo, void *ctx, void *dest_buf,
- int size)
+static int __maybe_unused hash_finish_crc32(struct hash_algo *algo, void *ctx,
+ void *dest_buf, int size)
{
if (size < algo->digest_size)
return -1;
@@ -311,6 +312,7 @@ static struct hash_algo hash_algo[] = {
.hash_update = hash_update_crc16_ccitt,
.hash_finish = hash_finish_crc16_ccitt,
},
+#if CONFIG_IS_ENABLED(CRC32)
{
.name = "crc32",
.digest_size = 4,
@@ -320,6 +322,7 @@ static struct hash_algo hash_algo[] = {
.hash_update = hash_update_crc32,
.hash_finish = hash_finish_crc32,
},
+#endif
};
/* Try to minimize code size for boards that don't want much hashing */
diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index 8a8a971a91..17ce2f6b61 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -419,7 +419,8 @@ config SYS_MMCSD_RAW_MODE_EMMC_BOOT_PARTITION
config SPL_CRC32
bool "Support CRC32"
- default y if SPL_LEGACY_IMAGE_SUPPORT
+ default y if SPL_LEGACY_IMAGE_SUPPORT || SPL_EFI_PARTITION
+ default y if SPL_ENV_SUPPORT || TPL_BLOBLIST
help
Enable this to support CRC32 in uImages or FIT images within SPL.
This is a 32-bit checksum value that can be used to verify images.
@@ -1419,6 +1420,16 @@ config TPL_BOOTROM_SUPPORT
BOOT_DEVICE_BOOTROM (or fall-through to the next boot device in the
boot device list, if not implemented for a given board)
+config TPL_CRC32
+ bool "Support CRC32 in TPL"
+ default y if TPL_ENV_SUPPORT || TPL_BLOBLIST
+ help
+ Enable this to support CRC32 in uImages or FIT images within SPL.
+ This is a 32-bit checksum value that can be used to verify images.
+ For FIT images, this is the least secure type of checksum, suitable
+ for detected accidental image corruption. For secure applications you
+ should consider SHA1 or SHA256.
+
config TPL_DRIVERS_MISC
bool "Support misc drivers in TPL"
help
diff --git a/lib/Kconfig b/lib/Kconfig
index 64765acfa6..70bf8e7a46 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -496,6 +496,11 @@ config SPL_MD5
security applications, but it can be useful for providing a quick
checksum of a block of data.
+config CRC32
+ def_bool y
+ help
+ Enables CRC32 support in U-Boot. This is normally required.
+
config CRC32C
bool
diff --git a/lib/Makefile b/lib/Makefile
index 454396f101..5ddbc77ed6 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -96,9 +96,7 @@ obj-y += display_options.o
CFLAGS_display_options.o := $(if $(BUILD_TAG),-DBUILD_TAG='"$(BUILD_TAG)"')
obj-$(CONFIG_BCH) += bch.o
obj-$(CONFIG_MMC_SPI) += crc7.o
-#ifndef CONFIG_TPL_BUILD
-obj-y += crc32.o
-#endif
+obj-$(CONFIG_$(SPL_TPL_)CRC32) += crc32.o
obj-$(CONFIG_CRC32C) += crc32c.o
obj-y += ctype.o
obj-y += div64.o
diff --git a/tools/Kconfig b/tools/Kconfig
index 8685c800f9..91ce8ae3e5 100644
--- a/tools/Kconfig
+++ b/tools/Kconfig
@@ -9,6 +9,11 @@ config MKIMAGE_DTC_PATH
some cases the system dtc may not support all required features
and the path to a different version should be given here.
+config TOOLS_CRC32
+ def_bool y
+ help
+ Enable CRC32 support in the tools builds
+
config TOOLS_LIBCRYPTO
bool "Use OpenSSL's libcrypto library for host tools"
default y