summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPali Rohár <pali.rohar@gmail.com>2012-07-14 09:21:34 +0200
committerPali Rohár <pali.rohar@gmail.com>2012-07-14 09:21:34 +0200
commit8301455a5bf9db54a91c9dd4cdecce5366e20ec2 (patch)
tree7f547919affca4ec8b1430409da7f569b85eb950
parent860d71d18a8ac8739d1671f5c7a20c2a93c25d82 (diff)
download0xFFFF-8301455a5bf9db54a91c9dd4cdecce5366e20ec2.tar.bz2
Align also kernel image
-rw-r--r--src/fiasco.c21
-rw-r--r--src/hash.c13
2 files changed, 26 insertions, 8 deletions
diff --git a/src/fiasco.c b/src/fiasco.c
index 0f6f8b2..b0b68cf 100644
--- a/src/fiasco.c
+++ b/src/fiasco.c
@@ -394,6 +394,7 @@ int fiasco_add(int fd, const char *name, const char *file, const char *layout, c
int i;
int gd,ret;
int size;
+ int align;
unsigned int sz;
unsigned char len;
unsigned short hash;
@@ -410,8 +411,12 @@ int fiasco_add(int fd, const char *name, const char *file, const char *layout, c
return -1;
sz = lseek(gd, 0, SEEK_END);
- if (name && strcmp(name, "mmc") == 0) // align mmc
- sz = ((sz >> 8) + 1) << 8;
+ if (name) {
+ if (strcmp(name, "mmc") == 0) // align mmc
+ sz = ((sz >> 8) + 1) << 8;
+ else if (strcmp(name, "kernel") == 0) // align kernel
+ sz = ((sz >> 7) + 1) << 7;
+ }
printf(" size: %d\n", sz);
sz = htonl((unsigned int) sz);
@@ -533,9 +538,15 @@ int fiasco_add(int fd, const char *name, const char *file, const char *layout, c
}
}
- /* align mmc (fill with 0xff) */
- if (name && strcmp(name, "mmc") == 0) {
- int align = ((size >> 8) + 1) << 8;
+ /* align mmc and kernel (fill with 0xff) */
+ align = 0;
+ if (name) {
+ if (strcmp(name, "mmc") == 0)
+ align = ((size >> 8) + 1) << 8;
+ else if (strcmp(name, "kernel") == 0)
+ align = ((size >> 7) + 1) << 7;
+ }
+ if (align) {
while (size < align) {
write(fd, "\xff", 1);
++size;
diff --git a/src/hash.c b/src/hash.c
index 4ee070c..9090bad 100644
--- a/src/hash.c
+++ b/src/hash.c
@@ -33,6 +33,7 @@ usho do_hash_file(const char *filename, const char *type)
unsigned char buf[BSIZE];
FILE *fd = fopen(filename, "r");
usho hash = 0;
+ int align = 0;
int size;
int ret;
@@ -51,9 +52,15 @@ usho do_hash_file(const char *filename, const char *type)
size = ftell(fd);
fclose(fd);
- /* mmc image must be aligned */
- if (type && strcmp(type, "mmc") == 0) {
- int align = ((size >> 8) + 1) << 8;
+ /* mmc and kernel image must be aligned */
+ if (type) {
+ if (strcmp(type, "mmc") == 0)
+ align = ((size >> 8) + 1) << 8;
+ else if (strcmp(type, "kernel") == 0)
+ align = ((size >> 7) + 1) << 7;
+ }
+
+ if (align) {
printf("align from %d to %d\n", size, align);
buf[0] = 0xff;
while (size < align) {