[U-Boot] [PATCH resend] Added UBL_MAGIC_PLL number for ublimage + added automatic page size calculation
Stijn Souffriau
stijn.souffriau at essensium.com
Sat Jun 2 22:38:35 CEST 2012
---
tools/mkimage.h | 6 ++++++
tools/ublimage.c | 29 +++++++++++++++++++++++++++--
tools/ublimage.h | 2 ++
3 files changed, 35 insertions(+), 2 deletions(-)
diff --git a/tools/mkimage.h b/tools/mkimage.h
index 5fe1a48..cd835f0 100644
--- a/tools/mkimage.h
+++ b/tools/mkimage.h
@@ -140,6 +140,12 @@ struct image_type_params {
void mkimage_register (struct image_type_params *tparams);
/*
+ * This struct contains the global parameters and is initialized
+ * by the main core before any image type specific functions are called.
+ */
+extern struct mkimage_params params;
+
+/*
* There is a c file associated with supported image type low level code
* for ex. default_image.c, fit_image.c
* init is the only function referred by mkimage core.
diff --git a/tools/ublimage.c b/tools/ublimage.c
index d6b4017..adbfc83 100644
--- a/tools/ublimage.c
+++ b/tools/ublimage.c
@@ -36,6 +36,10 @@
#include <image.h>
#include "ublimage.h"
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
/*
* Supported commands for configuration file
*/
@@ -58,8 +62,9 @@ static table_entry_t ublimage_cmds[] = {
* this is needed to set the correct flash offset
*/
static table_entry_t ublimage_bootops[] = {
- {UBL_MAGIC_SAFE, "safe", "Safe boot mode", },
- {-1, "", "Invalid", },
+ {UBL_MAGIC_SAFE,"safe", "Safe boot mode", },
+ {UBL_MAGIC_PLL, "pll", "With PLL enabled to have higher ARM/DMA clocks", },
+ {-1, "", "Invalid", },
};
static struct ubl_header ublimage_header;
@@ -89,6 +94,20 @@ static void print_hdr(struct ubl_header *ubl_hdr)
printf("start page : %08x\n", ubl_hdr->page);
}
+//This function calculates the size of the datafile in NAND pages
+static uint32_t get_data_pages_size(void)
+{
+ uint32_t size = 0;
+ struct stat buf;
+ int rv = stat(params.datafile, &buf);
+ if (rv == 0) {
+ size = (buf.st_size/UBL_BLOCK_SIZE) + (buf.st_size % UBL_BLOCK_SIZE == 0 ? 0 : 1);
+ } else {
+ fprintf(stderr, "Error: could not stat datafile %s\n", params.datafile);
+ }
+ return size;
+}
+
static void parse_cfg_cmd(struct ubl_header *ublhdr, int32_t cmd, char *token,
char *name, int lineno, int fld, int dcd_len)
{
@@ -171,6 +190,12 @@ static uint32_t parse_cfg_file(struct ubl_header *ublhdr, char *name)
*ptr = 0xff;
ptr++;
}
+
+ /* By default, the size of the data in NAND pages
+ * will be automatically calculated but it can be overwritten
+ * in the configuration file.
+ */
+ ublhdr->pages = get_data_pages_size();
/*
* Very simple parsing, line starting with # are comments
diff --git a/tools/ublimage.h b/tools/ublimage.h
index e440625..cbff8b7 100644
--- a/tools/ublimage.h
+++ b/tools/ublimage.h
@@ -61,6 +61,8 @@ enum ublimage_fld_types {
#define UBL_MAGIC_DMA_IC (0x44)
/* DMA + ICache + Fast EMIF boot mode */
#define UBL_MAGIC_DMA_IC_FAST (0x55)
+/* With PLL enabled to have higher ARM/DMA clocks */
+#define UBL_MAGIC_PLL (0x66)
/* Define max UBL image size */
#define UBL_IMAGE_SIZE (0x00003800u)
--
1.7.9.5
More information about the U-Boot
mailing list