summaryrefslogtreecommitdiffstatshomepage
path: root/src/tools
diff options
context:
space:
mode:
authorGravatarGravatar Sergey Svishchev <shattered@users.noreply.github.com>2019-05-08 23:26:34 +0300
committerGravatarGravatar Sergey Svishchev <shattered@users.noreply.github.com>2019-06-02 15:01:26 +0300
commit63c0ee96ec9dd6fe8ed244e9ffa54f322b34fc3f (patch)
treec0ad49cf934c0b34abdf4de4716bf91ba397cb57 /src/tools
parent6deb0d35e38ff52dacc0e916e10022eb86b680d7 (diff)
imgtool: MT 6693 wip, solves mess_hd issue (nw)
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/imgtool/imghd.cpp19
-rw-r--r--src/tools/imgtool/modules/pc_hard.cpp2
2 files changed, 6 insertions, 15 deletions
diff --git a/src/tools/imgtool/imghd.cpp b/src/tools/imgtool/imghd.cpp
index 17e47a7bf87..b868b692c63 100644
--- a/src/tools/imgtool/imghd.cpp
+++ b/src/tools/imgtool/imghd.cpp
@@ -53,14 +53,14 @@ imgtoolerr_t imghd_create(imgtool::stream &stream, uint32_t hunksize, uint32_t c
chd_error rc;
chd_codec_type compression[4] = { CHD_CODEC_NONE };
- /* sanity check args */
- if (hunksize >= 2048)
+ /* sanity check args -- see parse_hunk_size() in src/lib/util/chd.cpp */
+ if (hunksize > (1024 * 1024))
{
err = IMGTOOLERR_PARAMCORRUPT;
return err;
}
if (hunksize <= 0)
- hunksize = 1024; /* default value */
+ hunksize = 4096; /* default value */
/* bail if we are read only */
if (stream.is_read_only())
@@ -80,15 +80,6 @@ imgtoolerr_t imghd_create(imgtool::stream &stream, uint32_t hunksize, uint32_t c
return err;
}
- /* open the new hard drive */
- rc = chd.open(*stream.core_file());
-
- if (rc != CHDERR_NONE)
- {
- err = map_chd_error(rc);
- return err;
- }
-
/* write the metadata */
const std::string metadata = string_format(HARD_DISK_METADATA_FORMAT, cylinders, heads, sectors, seclen);
err = (imgtoolerr_t)chd.write_metadata(HARD_DISK_METADATA_TAG, 0, metadata);
@@ -236,7 +227,7 @@ OPTION_GUIDE_START( mess_hd_create_optionguide )
OPTION_INT(mess_hd_createopts_seclen, "seclen", "Sector Bytes" )
OPTION_GUIDE_END
-#define mess_hd_create_optionspecs "B[1]-2048;C1-[32]-65536;D1-[8]-64;E1-[128]-4096;F128/256/[512]/1024/2048/4096/8192/16384/32768/65536"
+#define mess_hd_create_optionspecs "B1-[4]-2048;C1-[32]-65536;D1-[8]-64;E1-[128]-4096;F128/256/[512]/1024/2048/4096/8192/16384/32768/65536"
void hd_get_info(const imgtool_class *imgclass, uint32_t state, union imgtoolinfo *info)
@@ -267,5 +258,5 @@ static imgtoolerr_t mess_hd_image_create(imgtool::image &image, imgtool::stream:
sectors = createoptions->lookup_int(mess_hd_createopts_sectors);
seclen = createoptions->lookup_int(mess_hd_createopts_seclen);
- return imghd_create(*stream.get(), blocksize, cylinders, heads, sectors, seclen);
+ return imghd_create(*stream.get(), blocksize * seclen, cylinders, heads, sectors, seclen);
}
diff --git a/src/tools/imgtool/modules/pc_hard.cpp b/src/tools/imgtool/modules/pc_hard.cpp
index 9973f84e762..c04ad33cce6 100644
--- a/src/tools/imgtool/modules/pc_hard.cpp
+++ b/src/tools/imgtool/modules/pc_hard.cpp
@@ -61,7 +61,7 @@ OPTION_GUIDE_START( pc_chd_create_optionguide )
OPTION_INT('S', "sectors", "Sectors" )
OPTION_GUIDE_END
-static const char pc_chd_create_optionspec[] = "H1-[16]S1-[32]-63T10/20/30/40/50/60/70/80/90/[100]/110/120/130/140/150/160/170/180/190/200";
+static const char pc_chd_create_optionspec[] = "H1-[16];S1-[32]-63;T10/20/30/40/50/60/70/80/90/[100]/110/120/130/140/150/160/170/180/190/200";
static const char fat8_string[8] = { 'F', 'A', 'T', ' ', ' ', ' ', ' ', ' ' };
static const char fat12_string[8] = { 'F', 'A', 'T', '1', '2', ' ', ' ', ' ' };