]> git.sur5r.net Git - u-boot/blobdiff - tools/rkcommon.c
Merge branch 'master' of git://git.denx.de/u-boot-rockchip
[u-boot] / tools / rkcommon.c
index 92c2ff48cec096eb21c6cce80c3625869e08a486..04e8272fd5b63b870186bd73a31e4256ee38352f 100644 (file)
@@ -74,9 +74,12 @@ struct spl_info {
 static struct spl_info spl_infos[] = {
        { "rk3036", "RK30", 0x1000, false, false },
        { "rk3188", "RK31", 0x8000 - 0x800, true, false },
+       { "rk322x", "RK32", 0x8000 - 0x1000, false, false },
        { "rk3288", "RK32", 0x8000, false, false },
        { "rk3328", "RK32", 0x8000 - 0x1000, false, false },
-       { "rk3399", "RK33", 0x20000, false, true },
+       { "rk3368", "RK33", 0x8000 - 0x1000, false, true },
+       { "rk3399", "RK33", 0x30000 - 0x2000, false, true },
+       { "rv1108", "RK11", 0x1800, false, false},
 };
 
 static unsigned char rc4_key[16] = {
@@ -184,11 +187,14 @@ static void rkcommon_set_header0(void *buf, uint file_size,
         */
        hdr->init_size = ROUND(hdr->init_size, 4);
        /*
-        * The images we create do not contain the stage following the SPL as
-        * part of the SPL image, so the init_boot_size (which might have been
-        * read by Rockchip's miniloder) should be the same as the init_size.
+        * init_boot_size needs to be set, as it is read by the BootROM
+        * to determine the size of the next-stage bootloader (e.g. U-Boot
+        * proper), when used with the back-to-bootrom functionality.
+        *
+        * see https://lists.denx.de/pipermail/u-boot/2017-May/293267.html
+        * for a more detailed explanation by Andy Yan
         */
-       hdr->init_boot_size = hdr->init_size;
+       hdr->init_boot_size = hdr->init_size + RK_MAX_BOOT_SIZE / RK_BLK_SIZE;
 
        rc4_encode(buf, RK_BLK_SIZE, rc4_key);
 }
@@ -222,11 +228,6 @@ static inline unsigned rkcommon_offset_to_spi(unsigned offset)
        return ((offset & ~0x7ff) << 1) + (offset & 0x7ff);
 }
 
-static inline unsigned rkcommon_spi_to_offset(unsigned offset)
-{
-       return ((offset & ~0x7ff) >> 1) + (offset & 0x7ff);
-}
-
 static int rkcommon_parse_header(const void *buf, struct header0_info *header0,
                                 struct spl_info **spl_info)
 {
@@ -376,8 +377,9 @@ int rkcommon_vrec_header(struct image_tool_params *params,
 
        /* Allocate, clear and install the header */
        tparams->hdr = malloc(tparams->header_size);
+       if (!tparams->hdr)
+               return -ENOMEM;
        memset(tparams->hdr, 0, tparams->header_size);
-       tparams->header_size = tparams->header_size;
 
        /*
         * If someone passed in 0 for the alignment, we'd better handle