summaryrefslogtreecommitdiffstats
path: root/scripts/imx/imx-usb-loader.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2016-01-25 15:17:23 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2016-02-02 15:41:04 +0100
commitba8898e63f2cb39afb03f2eb1dc2d8c6872f72b9 (patch)
tree2c1dc14510afdc5fd9675da66140fe064c7d7b88 /scripts/imx/imx-usb-loader.c
parent9ee83d3f8d2e64e9344a1d7264f0cd2a06eb593a (diff)
downloadbarebox-ba8898e63f2cb39afb03f2eb1dc2d8c6872f72b9.tar.gz
barebox-ba8898e63f2cb39afb03f2eb1dc2d8c6872f72b9.tar.xz
scripts: imx-usb-loader: Add -s and -i options
Normally imx-usb-loader interprets and executes the DCD table from an uploaded image and invalidates the DCD before uploading the image itself to prevent the i.MX ROM code from executing it again. With HAB signed images this is not possible since invalidating the DCD table modifies the image which also makes the signature invalid. To support this usecase add two new options to imx-usb-loader: The -i option allows to pass in an external config file which can be used to setup SDRAM. The DCD table in the image can then be made empty so that the ROM does not see a second SDRAM setup. The -s option allows to skip interpreting the DCD table in the image. This may when some setup stuff is still in the images DCD table but shall be executed by the ROM and not by imx-usb-loader. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'scripts/imx/imx-usb-loader.c')
-rw-r--r--scripts/imx/imx-usb-loader.c37
1 files changed, 36 insertions, 1 deletions
diff --git a/scripts/imx/imx-usb-loader.c b/scripts/imx/imx-usb-loader.c
index 40a7200c96..2f1db28f8c 100644
--- a/scripts/imx/imx-usb-loader.c
+++ b/scripts/imx/imx-usb-loader.c
@@ -44,6 +44,7 @@
#define FT_LOAD_ONLY 0x00
int verbose;
+static int skip_image_dcd;
static struct libusb_device_handle *usb_dev_handle;
static struct usb_id *usb_id;
@@ -864,6 +865,9 @@ static int perform_dcd(unsigned char *p, unsigned char *file_start, unsigned cnt
struct imx_flash_header_v2 *hdr = (struct imx_flash_header_v2 *)p;
int ret = 0;
+ if (skip_image_dcd)
+ return 0;
+
switch (usb_id->mach_id->header_type) {
case HDR_MX51:
ret = write_dcd_table_old(ohdr, file_start, cnt);
@@ -1201,10 +1205,28 @@ cleanup:
return ret;
}
+static int write_mem(struct config_data *data, uint32_t addr, uint32_t val, int width)
+{
+ printf("wr 0x%08x 0x%08x\n", addr, val);
+
+ return write_memory(addr, val, width);
+}
+
+static int parse_initfile(const char *filename)
+{
+ struct config_data data = {
+ .write_mem = write_mem,
+ };
+
+ return parse_config(&data, filename);
+}
+
static void usage(const char *prgname)
{
fprintf(stderr, "usage: %s [OPTIONS] [FILENAME]\n\n"
"-c check correctness of flashed image\n"
+ "-i <cfgfile> Specify custom SoC initialization file\n"
+ "-s skip DCD included in image\n"
"-v verbose (give multiple times to increase)\n"
"-h this help\n", prgname);
exit(1);
@@ -1223,8 +1245,9 @@ int main(int argc, char *argv[])
int verify = 0;
struct usb_work w = {};
int opt;
+ char *initfile = NULL;
- while ((opt = getopt(argc, argv, "cvh")) != -1) {
+ while ((opt = getopt(argc, argv, "cvhi:s")) != -1) {
switch (opt) {
case 'c':
verify = 1;
@@ -1234,6 +1257,12 @@ int main(int argc, char *argv[])
break;
case 'h':
usage(argv[0]);
+ case 'i':
+ initfile = optarg;
+ break;
+ case 's':
+ skip_image_dcd = 1;
+ break;
default:
exit(1);
}
@@ -1300,6 +1329,12 @@ int main(int argc, char *argv[])
goto out;
}
+ if (initfile) {
+ err = parse_initfile(initfile);
+ if (err)
+ goto out;
+ }
+
err = do_irom_download(&w, verify);
if (err) {
err = do_status();