We have the hardcoded value 0x8000 for the space needed for FCB and DBBT in several places. Use a variable instead and initialize it correctly with 12 * meminfo.writesize (which is in fact 0x6000 for 2k pagesize). Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx> --- arch/arm/mach-imx/imx-bbu-internal.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/arch/arm/mach-imx/imx-bbu-internal.c b/arch/arm/mach-imx/imx-bbu-internal.c index 125415e..ae981e8 100644 --- a/arch/arm/mach-imx/imx-bbu-internal.c +++ b/arch/arm/mach-imx/imx-bbu-internal.c @@ -178,6 +178,7 @@ static int imx_bbu_internal_v2_write_nand_dbbt(struct imx_internal_bbu_handler * uint32_t *ptr, *num_bb, *bb; uint64_t offset; int block = 0, len, now, blocksize; + int pre_image_size; ret = stat(data->devicefile, &s); if (ret) @@ -193,6 +194,8 @@ static int imx_bbu_internal_v2_write_nand_dbbt(struct imx_internal_bbu_handler * if (ret) goto out; + pre_image_size = 12 * meminfo.writesize; + blocksize = meminfo.erasesize; ptr = image + 0x4; @@ -218,7 +221,7 @@ static int imx_bbu_internal_v2_write_nand_dbbt(struct imx_internal_bbu_handler * bb = ptr + 1; offset = 0; - size_need = data->len + 0x8000; + size_need = data->len + pre_image_size; /* * Collect bad blocks and construct DBBT @@ -261,18 +264,18 @@ static int imx_bbu_internal_v2_write_nand_dbbt(struct imx_internal_bbu_handler * } debug("total image size: 0x%08zx. Space needed including bad blocks: 0x%08zx\n", - data->len + 0x8000, - data->len + 0x8000 + *num_bb * blocksize); + data->len + pre_image_size, + data->len + pre_image_size + *num_bb * blocksize); - if (data->len + 0x8000 + *num_bb * blocksize > imx_handler->device_size) { + if (data->len + pre_image_size + *num_bb * blocksize > imx_handler->device_size) { printf("needed space (0x%08zx) exceeds partition space (0x%08zx)\n", - data->len + 0x8000 + *num_bb * blocksize, + data->len + pre_image_size + *num_bb * blocksize, imx_handler->device_size); ret = -ENOSPC; goto out; } - len = data->len + 0x8000; + len = data->len + pre_image_size; offset = 0; /* -- 2.0.1 _______________________________________________ barebox mailing list barebox@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/barebox