diff options
Diffstat (limited to 'scripts/rkimage.c')
-rw-r--r-- | scripts/rkimage.c | 71 |
1 files changed, 4 insertions, 67 deletions
diff --git a/scripts/rkimage.c b/scripts/rkimage.c index dde9724886..6e68d508ac 100644 --- a/scripts/rkimage.c +++ b/scripts/rkimage.c @@ -13,6 +13,10 @@ #include <errno.h> #include <stdbool.h> +#include "common.h" +#include "common.c" +#include "rockchip.h" + #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0])) #define ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1)) @@ -34,37 +38,6 @@ static void sha512(const void *buf, int len, void *out) SHA512_Final(out, &sha512); } -#define NEWIDB_MAGIC 0x534e4b52 /* 'RKNS' */ - -struct newidb_entry { - uint32_t sector; - uint32_t unknown_ffffffff; - uint32_t unknown1; - uint32_t image_number; - unsigned char unknown2[8]; - unsigned char hash[64]; -}; - -struct newidb { - uint32_t magic; - unsigned char unknown1[4]; - uint32_t n_files; - uint32_t hashtype; - unsigned char unknown2[8]; - unsigned char unknown3[8]; - unsigned char unknown4[88]; - struct newidb_entry entries[4]; - unsigned char unknown5[40]; - unsigned char unknown6[512]; - unsigned char unknown7[16]; - unsigned char unknown8[32]; - unsigned char unknown9[464]; - unsigned char hash[512]; -}; - -#define SECTOR_SIZE 512 -#define PAGE_SIZE 2048 - typedef enum { HASH_TYPE_SHA256 = 1, HASH_TYPE_SHA512 = 2, @@ -149,42 +122,6 @@ static void usage(const char *prgname) prgname); } -static int read_full(int fd, void *buf, size_t size) -{ - size_t insize = size; - int now; - int total = 0; - - while (size) { - now = read(fd, buf, size); - if (now == 0) - return total; - if (now < 0) - return now; - total += now; - size -= now; - buf += now; - } - - return insize; -} - -static int write_full(int fd, void *buf, size_t size) -{ - size_t insize = size; - int now; - - while (size) { - now = write(fd, buf, size); - if (now <= 0) - return now; - size -= now; - buf += now; - } - - return insize; -} - int main(int argc, char *argv[]) { int opt, i, fd; |