From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Matthias Zoechmann <matthias.zoechmann@ife-doors.com>
Subject: [PATCH v2025.09.y 03/58] scripts: imx-image: support DCD_WRITE on closed dev
Date: Fri, 13 Mar 2026 14:24:47 +0100 [thread overview]
Message-ID: <20260313132631.2257573-4-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20260313132631.2257573-1-a.fatoum@pengutronix.de>
From: Matthias Zoechmann <matthias.zoechmann@ife-doors.com>
If an image is loaded by serial download protocol with DCD_WRITE ROM
command on closed i.mx6 devices, the DCD table block loaded into the
OCRAM must be signed.
This patch adds the option '-a' to apply the additional authentication
block for the OCRAM section into the CSF.
The load address for the block is fixed to '0x00910000' which is the
default address configured in mfg-tools of NXP.
(cherry picked from commit c722f8cf43690effcfe0031b1d9507a0957f5bf3)
Signed-off-by: Matthias Zoechmann <matthias.zoechmann@ife-doors.com>
Link: https://lore.barebox.org/20250901-imx6-usb-uuu-v1-2-1194bb6135ae@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
| 2 ++
scripts/imx/imx-image.c | 19 ++++++++++++++++++-
scripts/imx/imx.c | 22 ++++++++++++++++++++++
3 files changed, 42 insertions(+), 1 deletion(-)
--git a/include/mach/imx/imx-header.h b/include/mach/imx/imx-header.h
index 08329e3d0561..e8ead33a9ead 100644
--- a/include/mach/imx/imx-header.h
+++ b/include/mach/imx/imx-header.h
@@ -115,6 +115,7 @@ struct config_data {
int (*write_mem)(const struct config_data *data, uint32_t addr,
uint32_t val, int width, int set_bits, int clear_bits);
int (*nop)(const struct config_data *data);
+ int (*get_dcd_length)(void);
char *csf;
char *flexspi_csf;
int sign_image;
@@ -122,6 +123,7 @@ struct config_data {
int encrypt_image;
size_t dek_size;
bool hab_qspi_support;
+ bool dcd_usb_image;
};
#define MAX_RECORDS_DCD_V2 1024
diff --git a/scripts/imx/imx-image.c b/scripts/imx/imx-image.c
index a8ac34091fc0..c08857a6157e 100644
--- a/scripts/imx/imx-image.c
+++ b/scripts/imx/imx-image.c
@@ -495,6 +495,9 @@ static void usage(const char *prgname)
" variable 'CST'\n"
"-u create USB image suitable for imx-usb-loader\n"
" necessary for signed images (-s) only\n"
+ "-a authenticate additionaly the DCD block loaded via\n"
+ " 'SDP: DCD_WRITE' to the internal RAM on i.mx6 devices\n"
+ " necessary for usb images (-u) only\n"
"-h this help\n", prgname);
exit(1);
}
@@ -662,6 +665,11 @@ static int nop(const struct config_data *data)
}
}
+static int get_dcd_length(void)
+{
+ return sizeof(uint32_t) + (curdcd * sizeof(uint32_t));
+}
+
/*
* This uses the Freescale Code Signing Tool (CST) to sign the image.
* The cst is expected to be executable as 'cst' or if exists, the content
@@ -875,6 +883,7 @@ int main(int argc, char *argv[])
.write_mem = write_mem,
.check = check,
.nop = nop,
+ .get_dcd_length = get_dcd_length
};
uint32_t *bb_header;
size_t sizeof_bb_header;
@@ -883,7 +892,7 @@ int main(int argc, char *argv[])
prgname = argv[0];
- while ((opt = getopt(argc, argv, "c:hf:o:p:bduse")) != -1) {
+ while ((opt = getopt(argc, argv, "c:hf:o:p:bduase")) != -1) {
switch (opt) {
case 'c':
configfile = optarg;
@@ -909,6 +918,9 @@ int main(int argc, char *argv[])
case 'u':
create_usb_image = true;
break;
+ case 'a':
+ data.dcd_usb_image = true;
+ break;
case 'e':
data.encrypt_image = 1;
break;
@@ -969,6 +981,11 @@ int main(int argc, char *argv[])
create_usb_image = 0;
}
+ if (data.dcd_usb_image && !create_usb_image) {
+ fprintf(stderr, "Warning: the -a option only has effect with usb images\n");
+ data.dcd_usb_image = false;
+ }
+
if (data.image_ivt_offset == 0xffffffff) {
if (create_usb_image)
data.image_ivt_offset = 0x0;
diff --git a/scripts/imx/imx.c b/scripts/imx/imx.c
index 6dabaf59c159..26efe6d813dc 100644
--- a/scripts/imx/imx.c
+++ b/scripts/imx/imx.c
@@ -430,6 +430,28 @@ static int do_hab_blocks(struct config_data *data, int argc, char *argv[])
ret = asprintf(&str, "Blocks = 0x%08x 0x%08x 0x%08x \"%s\"",
data->image_load_addr + data->image_ivt_offset, offset,
signed_size - data->image_ivt_offset, data->outfile);
+
+ if (data->dcd_usb_image && (data->cpu_type == IMX_CPU_IMX6)) {
+ char *str_dcd_blk;
+ uint32_t dcd_offset = offset + offsetof(struct imx_flash_header_v2, dcd_header);
+ uint32_t dcd_length = data->get_dcd_length();
+
+ if(!dcd_length) {
+ fprintf(stderr, "failed to get dcd length\n");
+ return -EINVAL;
+ }
+
+ ret |= asprintf(&str_dcd_blk, ", \\\n 0x00910000 0x%08x 0x%08x \"%s\"",
+ dcd_offset, dcd_length, data->outfile);
+
+ str = strcata(str, str_dcd_blk);
+ free(str_dcd_blk);
+
+ if(!str) {
+ return -ENOMEM;
+ }
+ }
+
if (data->flexspi_csf)
ret |= asprintf(&flexspi_str,
"Blocks = 0x%08x 0x%08x 0x%08x \"%s\"",
--
2.47.3
next prev parent reply other threads:[~2026-03-13 13:27 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-13 13:24 [PATCH v2025.09.y 00/58] Backports for v2025.09.1 Ahmad Fatoum
2026-03-13 13:24 ` [PATCH v2025.09.y 01/58] clk: clkdev: fix format security Ahmad Fatoum
2026-03-13 13:24 ` [PATCH v2025.09.y 02/58] scripts: imx: fix string in further auth block Ahmad Fatoum
2026-03-13 13:24 ` Ahmad Fatoum [this message]
2026-03-13 13:24 ` [PATCH v2025.09.y 04/58] mci: am654-sdhci: Wait for transfer complete interrupt with MMC_RSP_BUSY cmd Ahmad Fatoum
2026-03-13 13:24 ` [PATCH v2025.09.y 05/58] video: simplefb-client: switch to dev_get_resource Ahmad Fatoum
2026-03-13 13:24 ` [PATCH v2025.09.y 06/58] MIPS: qemu-malta_defconfig: Use largest possible relocation table Ahmad Fatoum
2026-03-13 13:24 ` [PATCH v2025.09.y 07/58] firmware: handle firmware files being links correctly Ahmad Fatoum
2026-03-13 13:24 ` [PATCH v2025.09.y 08/58] drivers: don't propagate of_alias_get_id's -ENODEV out of probe Ahmad Fatoum
2026-03-13 13:24 ` [PATCH v2025.09.y 09/58] ARM: socfpga: arria10-reset-manager: release UART0 Ahmad Fatoum
2026-03-13 13:24 ` [PATCH v2025.09.y 10/58] bug: add support for CONFIG_DEBUG_BUGVERBOSE Ahmad Fatoum
2026-03-13 13:24 ` [PATCH v2025.09.y 11/58] driver: implement get_free_deviceid_from() Ahmad Fatoum
2026-03-13 13:24 ` [PATCH v2025.09.y 12/58] sandbox: fix make dependency for sandbox Ahmad Fatoum
2026-03-13 13:24 ` [PATCH v2025.09.y 13/58] gpio: Fix GPIOD_ASIS flag Ahmad Fatoum
2026-03-13 13:24 ` [PATCH v2025.09.y 14/58] i.MX: HAB: fix field return unlock fuse uid Ahmad Fatoum
2026-03-13 13:24 ` [PATCH v2025.09.y 15/58] ARM: cpu: common: skip R_ARM_NONE relocations Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 16/58] mmc: resolve conflict between MMC_CAP_NONREMOVABLE and MMC_CAP_1_8V_DDR Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 17/58] virtio: ring: fix stale data in queue after reset Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 18/58] scripts: Makefile.lib: suppress graph_port warnings for overlays Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 19/58] ARM: Rockchip: rk3576-prtpuk: suppress video graph warning Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 20/58] kbuild: fold rmdirs into rmfiles Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 21/58] mtd: nand: mxc_nand: use clk_get_optional for clock handling Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 22/58] FIT: fix double free issue with >1 reference count Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 23/58] net: phy: mdio_bus: fix freeing of cdev name before devfs_remove Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 24/58] bootm: fix bootm override saving/restoring Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 25/58] common: tlv: Correct eth address list fixup Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 26/58] common: tlv: fix link error when CONFIG_NET is disabled Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 27/58] include: array_size.h: make header self-contained Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 28/58] RISC-V: dts: fix generation of dtbs-list Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 29/58] of: overlay: propagate error unflattening DTBO Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 30/58] efi: fix potential NULL dereference Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 31/58] FIT: fix potential underflow of stack array Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 32/58] of: fdt: fix double free in fdt_ensure_space Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 33/58] of: overlay: initialize ret to fix garbage return value Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 34/58] firmware: xilinx-fpga: fix double free in probe error path Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 35/58] driver: fix missing va_end in dev_add_alias " Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 36/58] net: eth: avoid overlapping memcpy in eth_set_ethaddr Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 37/58] pmdomain: fix dereference before NULL check in genpd_get_from_provider Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 38/58] net: phy: add NULL check for phy driver in page accessors Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 39/58] open: add missing mode argument to O_CREAT calls Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 40/58] hush: add NULL check for gl_pathv after do_glob_in_argv Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 41/58] i2c: rk3x: fix NULL pointer dereference on repeated NACK Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 42/58] mci: imx-esdhc: remove misleading NULL check for cmd pointer Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 43/58] mci: spi: initialize r1 to fix garbage return value Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 44/58] virtio: fix variable shadowing in virtqueue_add_sgs input scatter loop Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 45/58] video: mode-helpers: preserve sync polarity in fb_videomode conversion Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 46/58] ARM: rockchip: dmc: use define instead of hardcoded value Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 47/58] ARM: rockchip: atf: Fix memend Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 48/58] regulator: fix handling of off_on_delay Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 49/58] regulator: fixed: handle startup-delay-us property Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 50/58] scripts: include: break dependency of list.h on kernel.h Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 51/58] Makefile: include scripts/ in compile_commands.json Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 52/58] jwt: fix buffer overflow and double-free in jwt_part_parse Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 53/58] of: fdt: fix heap-buffer-overflow in fdt_machine_is_compatible Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 54/58] powerpc: fix initjmp storing function pointer at wrong offset Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 55/58] net: r8169: drain RX descriptor ring Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 56/58] of: fdt: refuse / in property and node names Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 57/58] FIT: reconstruct hashed-nodes property during verification Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 58/58] scripts: fix build failure with glibc 2.43 Ahmad Fatoum
2026-03-13 14:56 ` [PATCH v2025.09.y 00/58] Backports for v2025.09.1 Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260313132631.2257573-4-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=matthias.zoechmann@ife-doors.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox