All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v5 14/41] rockchip: Add support for the SD image
Date: Sun, 30 Aug 2015 16:55:25 -0600	[thread overview]
Message-ID: <1440975352-28528-15-git-send-email-sjg@chromium.org> (raw)
In-Reply-To: <1440975352-28528-1-git-send-email-sjg@chromium.org>

The Rockchip boot ROM requires a particular file format. It consists of
64KB of zeroes, a 512-byte header encoded with RC4, and then some executable
code.

Add support to mkimage so that an SPL image (u-boot-spl-dtb.bin) can be
converted to this format.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 common/image.c  |   1 +
 include/image.h |   3 +-
 tools/Makefile  |   2 +-
 tools/rksd.c    | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 106 insertions(+), 2 deletions(-)
 create mode 100644 tools/rksd.c

diff --git a/common/image.c b/common/image.c
index cf2806f..2cdc728 100644
--- a/common/image.c
+++ b/common/image.c
@@ -156,6 +156,7 @@ static const table_entry_t uimage_type[] = {
 	{	IH_TYPE_X86_SETUP,  "x86_setup",  "x86 setup.bin",    },
 	{	IH_TYPE_LPC32XXIMAGE, "lpc32xximage",  "LPC32XX Boot Image", },
 	{	IH_TYPE_RKIMAGE,    "rkimage",    "Rockchip Boot Image" },
+	{	IH_TYPE_RKSD,       "rksd",       "Rockchip SD Boot Image" },
 	{	-1,		    "",		  "",			},
 };
 
diff --git a/include/image.h b/include/image.h
index 2daa74a..ea16205 100644
--- a/include/image.h
+++ b/include/image.h
@@ -246,8 +246,9 @@ struct lmb;
 #define IH_TYPE_LPC32XXIMAGE	21	/* x86 setup.bin Image		*/
 #define IH_TYPE_LOADABLE	22	/* A list of typeless images	*/
 #define IH_TYPE_RKIMAGE		23	/* Rockchip Boot Image		*/
+#define IH_TYPE_RKSD		24	/* Rockchip SD card		*/
 
-#define IH_TYPE_COUNT		24	/* Number of image types */
+#define IH_TYPE_COUNT		25	/* Number of image types */
 
 /*
  * Compression Types
diff --git a/tools/Makefile b/tools/Makefile
index 267f55c..9082bda 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -64,7 +64,7 @@ RSA_OBJS-$(CONFIG_FIT_SIGNATURE) := $(addprefix lib/rsa/, \
 					rsa-sign.o rsa-verify.o rsa-checksum.o \
 					rsa-mod-exp.o)
 
-ROCKCHIP_OBS = lib/rc4.o rkcommon.o rkimage.o
+ROCKCHIP_OBS = lib/rc4.o rkcommon.o rkimage.o rksd.o
 
 # common objs for dumpimage and mkimage
 dumpimage-mkimage-objs := aisimage.o \
diff --git a/tools/rksd.c b/tools/rksd.c
new file mode 100644
index 0000000..2efcd68
--- /dev/null
+++ b/tools/rksd.c
@@ -0,0 +1,102 @@
+/*
+ * (C) Copyright 2015 Google,  Inc
+ * Written by Simon Glass <sjg@chromium.org>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ *
+ * See README.rockchip for details of the rksd format
+ */
+
+#include "imagetool.h"
+#include <image.h>
+#include <rc4.h>
+#include "mkimage.h"
+#include "rkcommon.h"
+
+enum {
+	RKSD_HEADER0_START	= 64 * RK_BLK_SIZE,
+	RKSD_SPL_HDR_START	= RKSD_HEADER0_START +
+					RK_CODE1_OFFSET * RK_BLK_SIZE,
+	RKSD_SPL_START		= RKSD_SPL_HDR_START + 4,
+	RKSD_HEADER_LEN		= RKSD_SPL_START,
+};
+
+static char dummy_hdr[RKSD_HEADER_LEN];
+
+static int rksd_check_params(struct image_tool_params *params)
+{
+	return 0;
+}
+
+static int rksd_verify_header(unsigned char *buf,  int size,
+				 struct image_tool_params *params)
+{
+	return 0;
+}
+
+static void rksd_print_header(const void *buf)
+{
+}
+
+static void rksd_set_header(void *buf,  struct stat *sbuf,  int ifd,
+			       struct image_tool_params *params)
+{
+	unsigned int size;
+	int ret;
+
+	/* Zero the whole header. The first 32KB is empty */
+	memset(buf,  '\0',  RKSD_HEADER0_START);
+
+	size = params->file_size - RKSD_SPL_HDR_START;
+	ret = rkcommon_set_header(buf + RKSD_HEADER0_START, size);
+	if (ret) {
+		/* TODO(sjg at chromium.org): This method should return an error */
+		printf("Warning: SPL image is too large (size %#x) and will not boot\n",
+		       size);
+	}
+
+	memcpy(buf + RKSD_SPL_HDR_START, "RK32", 4);
+}
+
+static int rksd_extract_subimage(void *buf,  struct image_tool_params *params)
+{
+	return 0;
+}
+
+static int rksd_check_image_type(uint8_t type)
+{
+	if (type == IH_TYPE_RKSD)
+		return EXIT_SUCCESS;
+	else
+		return EXIT_FAILURE;
+}
+
+/* We pad the file out to a fixed size - this method returns that size */
+static int rksd_vrec_header(struct image_tool_params *params,
+			    struct image_type_params *tparams)
+{
+	int pad_size;
+
+	pad_size = RKSD_SPL_HDR_START + RK_MAX_CODE1_SIZE;
+	debug("pad_size %x\n", pad_size);
+
+	return pad_size - params->file_size;
+}
+
+/*
+ * rk_sd parameters
+ */
+U_BOOT_IMAGE_TYPE(
+	rksd,
+	"Rockchip SD Boot Image support",
+	RKSD_HEADER_LEN,
+	dummy_hdr,
+	rksd_check_params,
+	rksd_verify_header,
+	rksd_print_header,
+	rksd_set_header,
+	rksd_extract_subimage,
+	rksd_check_image_type,
+	NULL,
+	rksd_vrec_header
+);
-- 
2.5.0.457.gab17608

  parent reply	other threads:[~2015-08-30 22:55 UTC|newest]

Thread overview: 84+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-30 22:55 [U-Boot] [PATCH v5 00/41] dm: Introduce Rockchip RK3288 support Simon Glass
2015-08-30 22:55 ` [U-Boot] [PATCH v5 01/41] pinctrl: Add help text to Kconfig Simon Glass
2015-09-03 17:57   ` Simon Glass
2015-08-30 22:55 ` [U-Boot] [PATCH v5 02/41] pinctrl: Add the concept of peripheral IDs Simon Glass
2015-09-03 17:57   ` Simon Glass
2015-08-30 22:55 ` [U-Boot] [PATCH v5 03/41] dm: led: Tidy up SPL options for the led and led-gpio Simon Glass
2015-09-03 17:57   ` Simon Glass
2015-08-30 22:55 ` [U-Boot] [PATCH v5 04/41] mmc: Support bypass mode with the get_mmc_clk() method Simon Glass
2015-09-03 17:58   ` Simon Glass
2015-08-30 22:55 ` [U-Boot] [PATCH v5 05/41] dm: Improve handling of a missing uclass Simon Glass
2015-09-03 17:58   ` Simon Glass
2015-08-30 22:55 ` [U-Boot] [PATCH v5 06/41] dm: Provide better debugging when a device fails to bind Simon Glass
2015-09-03 17:58   ` Simon Glass
2015-08-30 22:55 ` [U-Boot] [PATCH v5 07/41] arm: reset: Avoid a build error when the reset uclass is enabled Simon Glass
2015-09-03 17:58   ` Simon Glass
2015-08-30 22:55 ` [U-Boot] [PATCH v5 08/41] rockchip: Add serial support Simon Glass
2015-09-03 17:58   ` Simon Glass
2015-08-30 22:55 ` [U-Boot] [PATCH v5 09/41] rockchip: Bring in RK3288 device tree file includes and bindings Simon Glass
2015-09-03 17:58   ` Simon Glass
2015-08-30 22:55 ` [U-Boot] [PATCH v5 10/41] rockchip: rk3288: dts: Make core devices available early Simon Glass
2015-09-03 17:58   ` Simon Glass
2015-08-30 22:55 ` [U-Boot] [PATCH v5 11/41] mkimage: Allow padding to any length Simon Glass
2015-09-03 17:58   ` Simon Glass
2015-08-30 22:55 ` [U-Boot] [PATCH v5 12/41] mkimage: Allow the original file size to be recorded Simon Glass
2015-09-03 17:58   ` Simon Glass
2015-08-30 22:55 ` [U-Boot] [PATCH v5 13/41] rockchip: Add the rkimage format to mkimage Simon Glass
2015-09-03 17:58   ` Simon Glass
2015-08-30 22:55 ` Simon Glass [this message]
2015-09-03 17:58   ` [U-Boot] [PATCH v5 14/41] rockchip: Add support for the SD image Simon Glass
2015-08-30 22:55 ` [U-Boot] [PATCH v5 15/41] rockchip: Add support for the SPI image Simon Glass
2015-09-03 17:59   ` Simon Glass
2015-08-30 22:55 ` [U-Boot] [PATCH v5 16/41] rockchip: gpio: Add rockchip GPIO driver Simon Glass
2015-09-03 17:59   ` Simon Glass
2015-08-30 22:55 ` [U-Boot] [PATCH v5 17/41] rockchip: Add basic peripheral and clock definitions Simon Glass
2015-09-03 17:59   ` Simon Glass
2015-08-30 22:55 ` [U-Boot] [PATCH v5 18/41] power: Add support for ACT8846 PMIC Simon Glass
2015-09-03 17:59   ` Simon Glass
2015-08-30 22:55 ` [U-Boot] [PATCH v5 19/41] power: regulator: Add a driver for ACT8846 regulators Simon Glass
2015-09-03 17:59   ` Simon Glass
2015-08-30 22:55 ` [U-Boot] [PATCH v5 20/41] rockchip: rk3288: Add clock driver Simon Glass
2015-09-03 17:59   ` Simon Glass
2015-08-30 22:55 ` [U-Boot] [PATCH v5 21/41] rockchip: rk3288: Add header files for PMU and GRF Simon Glass
2015-09-03 17:59   ` Simon Glass
2015-08-30 22:55 ` [U-Boot] [PATCH v5 22/41] rockchip: rk3288: Add SoC reset driver Simon Glass
2015-09-03 17:59   ` Simon Glass
2015-08-30 22:55 ` [U-Boot] [PATCH v5 23/41] rockchip: rk3288: Add a simple syscon driver Simon Glass
2015-09-03 17:59   ` Simon Glass
2015-08-30 22:55 ` [U-Boot] [PATCH v5 24/41] rockchip: rk3288: Add pinctrl driver Simon Glass
2015-09-03 17:59   ` Simon Glass
2015-08-30 22:55 ` [U-Boot] [PATCH v5 25/41] rockchip: rk3288: Add SDRAM init Simon Glass
2015-09-03 17:59   ` Simon Glass
2015-08-30 22:55 ` [U-Boot] [PATCH v5 26/41] rockchip: Add an MMC driver Simon Glass
2015-09-03 17:59   ` Simon Glass
2015-08-30 22:55 ` [U-Boot] [PATCH v5 27/41] rockchip: Add core SoC start-up code Simon Glass
2015-09-03 18:00   ` Simon Glass
2015-08-30 22:55 ` [U-Boot] [PATCH v5 28/41] rockchip: Add I2C driver Simon Glass
2015-09-03 18:00   ` Simon Glass
2015-08-30 22:55 ` [U-Boot] [PATCH v5 29/41] rockchip: Add SPI driver Simon Glass
2015-09-01  5:23   ` Jagan Teki
2015-09-02  1:03     ` Simon Glass
2015-08-30 22:55 ` [U-Boot] [PATCH v5 30/41] rockchip: Add basic support for firefly-rk3288 Simon Glass
2015-09-03 18:00   ` Simon Glass
2015-08-30 22:55 ` [U-Boot] [PATCH v5 31/41] rockchip: Add basic support for jerry Simon Glass
2015-09-03 18:00   ` Simon Glass
2015-08-30 22:55 ` [U-Boot] [PATCH v5 32/41] rockchip: Add a simple README Simon Glass
2015-09-03 18:00   ` Simon Glass
2015-08-30 22:55 ` [U-Boot] [PATCH v5 33/41] doc: Fix reference to Rock pro when Rock 2 is meant Simon Glass
2015-09-03 18:00   ` Simon Glass
2015-08-30 22:55 ` [U-Boot] [PATCH v5 34/41] mmc: Probe DM based mmc devices in u-boot Simon Glass
2015-09-03 18:00   ` Simon Glass
2015-08-30 22:55 ` [U-Boot] [PATCH v5 35/41] rockchip: Disable sdio mmc slot on rk3288-firefly Simon Glass
2015-09-03 18:00   ` Simon Glass
2015-08-30 22:55 ` [U-Boot] [PATCH v5 36/41] rockchip: Turn off CONFIG_SPL_LED for firefly Simon Glass
2015-09-03 18:00   ` Simon Glass
2015-08-30 22:55 ` [U-Boot] [PATCH v5 37/41] rockchip: Add config_distro_bootcmd support Simon Glass
2015-09-03 18:00   ` Simon Glass
2015-08-30 22:55 ` [U-Boot] [PATCH v5 38/41] arm: Turn of d-cache before i-cache Simon Glass
2015-09-03 18:00   ` Simon Glass
2015-08-30 22:55 ` [U-Boot] [PATCH v5 39/41] rockchip: Drop first 32kb of zeros from the rkSD image type Simon Glass
2015-09-03 18:00   ` Simon Glass
2015-08-30 22:55 ` [U-Boot] [PATCH v5 40/41] rockchip: Update todo in README.rockchip Simon Glass
2015-09-03 18:00   ` Simon Glass
2015-08-30 22:55 ` [U-Boot] [PATCH v5 41/41] rockchip: Put README image creation commands on one line Simon Glass
2015-09-03 18:00   ` Simon Glass

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=1440975352-28528-15-git-send-email-sjg@chromium.org \
    --to=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.