Make flash-size limiting of atapromise a general --force feature
To allow accessing at least part of flash chips behind this size-limited
controller, the `atapromise' driver used a local function that adjusted
a chip description. As flashprog would have bailed out earlier already,
this was only ever usable with the `--force' flag.
The same adjustment can be used with other programmers. Making it a glo-
bal feature also gets rid of a driver peculiarity and removes the depen-
dency on `flashctx` in the `atapromise' driver.
The logic enforces a complete chip erase if any erase is necessary. So,
while this should make part of the chip fully read/writable, content of
the inaccessible area will be lost on write.
Change-Id: I6bce8ff7781f683b001f76154621f22bd03687bc
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.sourcearcade.org/c/flashprog/+/431
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
diff --git a/include/flash.h b/include/flash.h
index eec09b4..8aff7a1 100644
--- a/include/flash.h
+++ b/include/flash.h
@@ -524,6 +524,7 @@
/* helpers.c */
bool flashprog_no_data(const void *raw_data, size_t);
int flashprog_read_chunked(struct flashctx *, uint8_t *dst, unsigned int start, unsigned int len, unsigned int chunksize, readfunc_t *);
+int flashprog_limit_chip(struct flashctx *);
uint32_t address_to_bits(uint32_t addr);
unsigned int bitcount(unsigned long a);
#undef MIN