1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-04-26 22:52:34 +02:00

116 Commits

Author SHA1 Message Date
Anastasia Klimchuk
75dc0655b9 Complete and fix progress feature implementation for all operations
Original progress reporting implemented in CB:49643 and it has some
issues, for example:

    size_t start_address = start;
    size_t end_address = len - start;

End address is anything but length minus start address.

    update_progress(flash,
                    FLASHROM_PROGRESS_READ,
                    /*current*/ start - start_address + to_read,
                    /*total*/ end_address);

Total should just be length if that's how current value is computed.

---

libflashrom needs to know total size ahead of time.
That's init_progress() and changed update_progress().

It also needs to store the last current value to be able to update it.
That's stage_progress in flashrom_flashctx.

Measuring accurately amount of data which will be read/erased/written
isn't easy because things can be skipped as optimizations. The next
patch in the chain aims to address this, there are TODO/FIXME
comments there.

---

CLI shares terminal with the rest of the code and has to maintain more
state to handle that reasonably well.

Similar to CB:64668, an effort is made to keep the progress on a
single line. Non-progress output is kept track of to know when
moving to a new line cannot be avoided.

---

A script to test the CLI:

\#!/bin/bash
t=${1:-rewW}
shift

if [[ $t =~ r ]]; then
    echo ">>> READ"
    ./flashrom -p dummy:emulate=W25Q128FV,freq=64mhz -r dump.rom --progress "$@"
    echo
fi

if [[ $t =~ e ]]; then
    echo ">>> ERASE"
    ./flashrom -p dummy:emulate=W25Q128FV,freq=64mhz -E --progress "$@"
    echo
fi

if [[ $t =~ w ]]; then
    echo ">>> WRITE (without erase)"
    dd if=/dev/zero of=zero.rom bs=1M count=16 2> /dev/null
    ./flashrom -p dummy:emulate=W25Q128FV,freq=64mhz -w zero.rom --progress "$@"
    echo
fi

if [[ $t =~ W ]]; then
    echo ">>> WRITE (with erase)"
    dd if=/dev/zero of=zero.rom bs=1M count=16 2> /dev/null
    dd if=/dev/random of=random.rom bs=1M count=16 2> /dev/null
    ./flashrom -p dummy:emulate=W25Q128FV,freq=64mhz,image=random.rom -w zero.rom --progress "$@"
    echo
fi

Co-developed-by: Anastasia Klimchuk <aklm@flashrom.org>
Co-developed-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
Change-Id: If1e40fc97f443c4f0c0501cef11cff1f3f84c051
Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
Signed-off-by: Anastasia Klimchuk <aklm@flashrom.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/84102
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
2024-10-27 06:13:11 +00:00
Thomas Heijligen
90286fe643 printf: Use inttype.h macros for format strings
DJGPP for compiling DOS has other sizes for the normal int types and
therefore throwing errors when using %i %d or %x with uint32_t.

Fix these warnings by using the macros created for it and provided in
inttypes.h.

Change-Id: Ia75b6df981ce60c891161fe553c7ceab8570178d
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/73040
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2023-04-27 09:36:46 +00:00
Edward O'Callaghan
648dc4a653 jedec.c: Provide better lexical scope to itermediates
Change-Id: I8e01d471bb33a933b80760df2c69a4bf3589ba76
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/73285
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Reviewed-by: Thomas Heijligen <src@posteo.de>
2023-02-27 10:25:24 +00:00
Edward O'Callaghan
439f096049 jedec.c: Tidy up whitespace and line wraps
Change-Id: I3f18609709e59cdfc5a853c6e1ae5f53aecacc1a
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/73284
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Reviewed-by: Thomas Heijligen <src@posteo.de>
2023-02-27 10:24:18 +00:00
Edward O'Callaghan
15d348feff jedec.c: Add a little more const correctness
Change-Id: Ic9a76ce3734bd83399c95478a7c0bfc081211124
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/73283
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Reviewed-by: Thomas Heijligen <src@posteo.de>
2023-02-27 10:23:33 +00:00
Edward O'Callaghan
2c03317a4b jedec.c: Rename func to jedec_write_page()
Change-Id: I1be83d5974e305bddceaa34b64e982b774ade0d2
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/73282
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Reviewed-by: Thomas Heijligen <src@posteo.de>
2023-02-27 10:21:12 +00:00
Edward O'Callaghan
4ea3f6cbf8 jedec.c: Drop branching non-zero programmer_delay() operands
The programmer_delay() function is already tolerant upon zero
delay values and will simply just return with a NOP. Therefore
there is no need to branch.

Change-Id: Ic547669bb16e6ace4fe283e07345fc2d7075d63e
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/72692
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Reviewed-by: Thomas Heijligen <src@posteo.de>
2023-02-27 10:19:52 +00:00
Edward O'Callaghan
dddf948685 jedec.c: Move probe_timings decode into sep func
The chip data structure packed from the flashchips db
should have the probe_timing field decoded by its own
function.

Change-Id: I638518cd537954172eb774f6d15af0db7e06d1ba
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/72609
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2023-02-22 10:33:08 +00:00
Edward O'Callaghan
f4ddd32343 jedec.c: Fold up mask param into func
Change-Id: Iee4b1d5bc850cbeec0de9a1603fe04a3a1855330
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/72631
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2023-02-21 13:15:49 +00:00
Edward O'Callaghan
707cd6bc73 jedec.c: Rewrite control flow procedurally
Drop goto usage in fav of loop constructs.

Change-Id: I0927ed40e54cc7e114a57dc40e3614f4825a0ca9
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/72608
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2023-02-21 13:15:29 +00:00
Edward O'Callaghan
86babd0627 jedec.c: Move printlock stuff into printlock.c
Change-Id: Iacaa16c81e141aac30feb6871700c4fdc9eec8e9
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/72607
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Reviewed-by: Thomas Heijligen <src@posteo.de>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2023-02-21 12:56:22 +00:00
Edward O'Callaghan
61cf7e53b2 jedec.c: Fold up dst into toggle_ready_jedec()
Change-Id: Ib7a3fdbc6e0a888093dc8da6f5567a7301ec5040
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/72691
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
2023-02-21 06:13:30 +00:00
Edward O'Callaghan
1ac468e663 jedec.c: Consolidate op,operand sequencing into func
Change-Id: I9a1b211b49777f6d7f62a052975c1759e036c8df
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/72502
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2023-02-16 22:44:38 +00:00
Edward O'Callaghan
ec6eaff2f8 jedec.c: Trivial code style fix
Change-Id: I42ebdda07512d0a84a6bd6d0630f96c40f039259
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/72606
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2023-02-02 02:08:13 +00:00
Edward O'Callaghan
7378557e54 jedec.c: Collapse probe_jedec() indirection
Change-Id: I57c27bcf25c5d9ce10fb9c74d9be6ab3544ac7ba
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/72504
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2023-02-02 02:08:00 +00:00
Edward O'Callaghan
d0fbe5344a jedec.c: Collapse erase_chip_block_jedec() indirection
Change-Id: I6e4a63e4935d4b69b66cbd1888f62b6af066a2ac
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/72503
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2023-02-02 02:07:32 +00:00
Edward O'Callaghan
3edef2f3a6 jedec.c: Collapse erase_block_jedec() indirection
Change-Id: Ia9b539d7fb4a54ba6cc56730e96d35044e291844
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/72501
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2023-02-02 02:06:52 +00:00
Edward O'Callaghan
8fd4aeb8ec jedec.c: Collapse erase_sector_jedec() indirection
Change-Id: I9cc9e8c88c0442dc2602bbb2de2073113e9c484b
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/72500
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2023-02-02 02:06:27 +00:00
Edward O'Callaghan
d01e694a22 jedec.c: Make getaddrmask() ret const correct
Change-Id: If9701a6d56159d0dfc047aa91b2a80c80fb33e5f
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/72499
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2023-02-02 02:05:13 +00:00
Alexander Goncharov
5c69cde561 tree: provide flashrom context into programmer_delay()
Modify the `programmer_delay` function signature to allow passing
the flashrom context. Programmers that depend on internal delay
should provide NULL as a context. The use of this function parameter
will be introduced in CB:67393.

TOPIC=programmer_handle_global
TEST=builds

Change-Id: Ibb0bce26ce2052853ee52158d7ba742967a9e229
Signed-off-by: Alexander Goncharov <chat@joursoir.net>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/66373
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Reviewed-by: Felix Singer <felixsinger@posteo.net>
2022-10-17 01:00:35 +00:00
Richard Hughes
40892b0c08 libflashrom: Return progress state to the library user
Projects using libflashrom like fwupd expect the user to wait for the
operation to complete. To avoid the user thinking the process has
"hung" or "got stuck" report back the progress complete of the erase,
write and read operations.

Add a new --progress flag to the CLI to report progress of operations.

Include a test for the dummy spi25 device.

TEST=./test_build.sh; ./flashrom -p lspcon_i2c_spi:bus=7 -r /dev/null --progress

Change-Id: I7197572bb7f19e3bdb2bde855d70a0f50fd3854c
Signed-off-by: Richard Hughes <richard@hughsie.com>
Signed-off-by: Daniel Campello <campello@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/49643
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-by: Thomas Heijligen <src@posteo.de>
2022-05-25 08:08:13 +00:00
Nico Huber
519be66fc5 Fix -Wsign-compare trouble
Mostly by changing to `unsigned` types where applicable, sometimes
`signed` types, and casting as a last resort.

Change-Id: I08895543ffb7a48058bcf91ef6500ca113f2d305
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/30409
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Jacob Garber <jgarber1@ualberta.ca>
2019-07-31 08:26:59 +00:00
Jacob Garber
cf3976e658 tree: Remove unused functions with no prototypes
These functions are no longer used, or were never used in the first place.

generate_testpattern() - Introduced in commit eaac68bf8b, never used
list_programmers() - Introduced in commit 552420b0d6, never used
pci_dev_find_filter() - Prototype removed in commit 5c316f9549
erase_chip_jedec() - Usage and prototype removed in commit f52f784bb3
printlock_regspace2_blocks() - Introduced in commit ef3ac8ac17, never used
spi_write_status_enable() - Usage dropped in commit fcbdbbc0d4

Change-Id: I742164670521fea65ffa3808446594848ce63cec
Signed-off-by: Jacob Garber <jgarber1@ualberta.ca>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/33669
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
2019-06-23 21:40:09 +00:00
Elyes HAOUAS
5bd11dc847 Remove empty line at EOF
Change-Id: Id6063cb5d406d7139abf7fcdf2ae265363640f9f
Signed-off-by: Elyes HAOUAS <ehaouas@noos.fr>
Reviewed-on: https://review.coreboot.org/28207
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
2018-08-19 10:41:55 +00:00
Elyes HAOUAS
e083880279 Remove address from GPLv2 headers
Change-Id: I7bfc339673cbf5ee2d2ff7564c4db04ca088d0a4
Signed-off-by: Elyes HAOUAS <ehaouas@noos.fr>
Reviewed-on: https://review.coreboot.org/25381
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
2018-04-24 20:21:41 +00:00
Elyes HAOUAS
124ef38f7a Fix whitespace errors
Change-Id: Ic2d3bb9d8581a0471a8568a130f893b34dddf113
Signed-off-by: Elyes HAOUAS <ehaouas@noos.fr>
Reviewed-on: https://review.coreboot.org/25380
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
2018-04-24 20:18:58 +00:00
Stefan Tauner
23e10b8780 Add a bunch of new/tested stuff and various small changes 24
Tested mainboards:
OK:
 - ASRock G31M-GS
   Reported by Александр Трубицын
 - ASRock G41M-VS3
   Reported by Александр Трубицын
 - ASRock N68C-S UCC
   Reported by Alexey Belyaev
 - ASRock AMCP7AION-HT (ION 330HT(-BD))
   Reported by Stefan Tauner
 - ASUS P5K SE
   Reported by Александр Трубицын
 - ASUS P5KPL-VM
   Reported by Marin Vlah
 - ASUS RAMPAGE III GENE
   Reported by stevessss on IRC
 - GIGABYTE GA-945GM-S2
   Reported by Александр Трубицын
 - GIGABYTE GA-945GCM-S2 (rev. 3.0)
   Reported by Александр Трубицын
 - GIGABYTE GA-965P-S3
   Reported by Александр Трубицын
 - GIGABYTE GA-EG43M-S2H
   Reported by Александр Трубицын
 - GIGABYTE GA-EP31-DS3L (rev. 1.0)
   Reported by Александр Трубицын
 - GIGABYTE GA-G33M-S2
   Reported by Александр Трубицын
 - GIGABYTE GA-G33M-S2L
   Reported by Александр Трубицын
 - GIGABYTE GA-H55M-S2
   Reported by Александр Трубицын
 - GIGABYTE GA-J1900N-D3V
   Reported by Marcos Truchado and Guillermo von Hünefeld
 - GIGABYTE GA-K8NS
   Reported  by nicolae788
 - GIGABYTE GA-M56S-S3
   Reported by Estevo Paz Freire
 - GIGABYTE GA-P31-DS3L
   Reported by Александр Трубицын
 - GIGABYTE GA-P31-S3G
   Reported by Александр Трубицын
 - MSI MS-7336
   Reported by Benjamin Bellec
 - MSI X79A-GD45 (8D) (MS-7760)"
   Reported by mortehu on IRC
 - Supermicro A1SAi-2550F
   Reported by Bernard Grymonpon
 - Supermicro X7DWT
   Reported by Steven Stremciuc

Laptop:
 - ASUS U38N
   Reported by Ultra on IRC
 - Dell Latitude D630
   Reported by Márton Miklós
 - Fujitsu Amilo Xi 3650
   Reported by Elmar Stellnberger
 - Lenovo T400 (whitelisting only)

Chipsets:
 - Mark 8086:1f38 (Intel Avoton/Rangeley) as tested
   Reported by Jeremy Porter and Bernard Grymonpon
 - Add Intel Sunrise Point IDs but no support yet.

Flash chips:
 - Atmel AT45DB321D to PREW (+PREW)
   Reported by The Raven
 - Eon EN25QH32 to PREW (+PREW)
   Reported by Josua Mayer
 - Eon EN25QH64 to PREW (+EW)
   Reported by David s. Alessio
 - GigaDevice GD25LQ64(B) to PREW (+PREW)
   Reported by Greg Tippit
 - Intel 28F001BN/BX-T to PREW (+EW)
   Reported by Lu Xie
 - Micron M25P10-A to PREW (+W)
   Reported by the Raven
 - Micron M25PE40
   Reported by David Wood
 - Micron N25Q128..3E to PREW (+PREW)
   Reported by Miklós Márton
 - Macronix MX25L3273E to PREW (+PREW)
   Reported by Roklobsta on IRC
 - Macronix MX23L6454 to PR (+PR)
   Reported by Steven Honeyman
 - Macronix MX25U6435E/F to PREW (+PREW)
   Reported by Marcos Truchado and Guillermo von Hünefeld
 - PMC Pm25LQ032C to PREW (+EW)
   Reported by Dirk Knop
 - Spansion S25FL016A to PREW (+EW)
   Reported by Márton Miklós
 - Spansion S25FL128S......0 to PREW (+PREW)
   Reported by Jim Houston
 - Spansion S25FL204K to PR (+PR)
   Reported by Thomas Debrunner
 - SST SST49LF016C to PREW (+EW)
   Reported by Steven Stremciuc
 - SST SST39VF040 to PREW (+PREW)
   Reported by Xavier Bourgeois
 - SST SST49LF040B to PREW (+EW)
   Reported by Rikard Åhlund
 - ST M25P10-A to PREW (+W)
   Reported by Martijn Schiedon
 - Winbond W39V040FA to PREW (+EW)
   Reported by Евгений Черкашин
 - Winbond W39V080FA to PREW (+EW)
   Reported by protagonist0 on IRC
 - Winbond W25Q80.W to PREW (+PREW)
   Reported by Miklós Márton
 - Winbond W25X64 to PREW (+REW)
   Reported by Johannes Krampf and Manuel Dejonghe
 - Fix ID of AMIC A25LQ64
   Reported by Roman Titov
 - Fix page size of Spansion S25FL129P......1
   Copy and paste error from the 128S uniform 256kB variant, probably.
 - Add Micron/Numonyx phase-change memory IDs

Miscellaneous:
 - Detect Android target OS.
   No changes are required to build flashrom (excluding programmers
   with NEED_PCI) on Android.
 - Update rayerspi (spipgm) URL
 - Fix max_data_write handling of at45db.
 - Minor refinement of the README
 - Mark board enable for the GA-K8NS variants as tested.
   Tested by "nicolae788" on a board with socket 754.
 - Mark "Multi-system" chassis as non-laptop case.
 - Remove W836xx log requests.
   We got enough (and no one is looking at them for the time being anyway).
 - serprog: improve invalid reply error message, contributed by Urja Rannikko.
 - Remove default include paths for MinGW.
 - Disable implicit rules in the Makefile because we don't need them and they
   just make the build (imperceptibly) slower.
 - Enable our own strnlen() implementation not only on DJGPP but also if
   HAVE_STRNLEN is not defined. This is needed to get older BSDs
   (e.g. NetBSD 6.0, FreeBSD < 8.0) to work.
 - Tiny other stuff.

Corresponding to flashrom svn r1917.

Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
2016-01-23 16:16:49 +00:00
Stefan Tauner
5859ced80f Fix handling of write protection at register space address +2
Since r1833 we added the offset of the virtual register in several
functions, which produced segfaults. This patch renames a few
parameters and reorganizes/fixes various parts of the
changelock_regspace2_block() function - hence the rather big diff.

Thanks to Roman Lebedev for reporting this issue and testing numerous
revisions of this patch.

Corresponding to flashrom svn r1859.

Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
2014-12-20 16:45:31 +00:00
Stefan Tauner
4e32ec19b1 Refine physical address mapping of flash chips
- Create distinct functions for mapping and unmapping for flash chips.
 - Map only when needed: map before probing and unmap immediately
   after it. Map again when a single chip was probed successfully before
   taking any actual actions and clean up afterwards.
 - Map special function chip registers centrally together with flash space
   instead of within (some) probing methods after successful probes.
 - Save the used base addresses of the mappings in struct flashctx as well.
 - Do not try to (un)map the zero-sized chip definitions that are merely hacks.
   This also fixes the printing of wrong warnings for these chip definitions
   introduced in r1765.

Corresponding to flashrom svn r1847.

Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
2014-08-30 23:39:51 +00:00
Carl-Daniel Hailfinger
a8cf3620a4 Unify non-shifted and shifted JEDEC access
Some Parallel bus chips have a 16-bit mode and an 8-bit mode. They use
normal JEDEC addresses for 16-bit mode and shifted addresses (by 1 bit)
for 8-bit mode. Some programmers can access them in 16-bit mode, but on
all flashrom-supported programmers so far, we access them in 8-bit mode.
This means we have to shift the addresses but apart from the addresses
we can share the code.

This patch makes this possible by checking the chip's FEATURE_ADDR_SHIFTED
flag in common JEDEC functions and applying the right addresses respectively.

Corresponding to flashrom svn r1840.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
2014-08-08 08:33:01 +00:00
Stefan Tauner
03a9c3c1bb Add support for a bunch of 29GL parallel flash chips
29GL chips use a new 3-Byte device ID probing function at addresses
0x01, 0x0E, 0x0F.

Flash chip families supported by this method include...
 - EON EN29GL
 - Gigadevice GD29GL (if they really exist)
 - ISSI (PMC) IS29GL
 - Macronix MX29GL (+MX68GL1G0F)
 - Spansion S29GL (+S70GL02G)
 - Winbond W29GL

This patch adds respective flash chip definitions for chips up to 16 MB from
Eon, ISSI, Macronix and Winbond. Bigger chips as well as those from
Gigadevice and Spansion are left out.

Corresponding to flashrom svn r1835.

Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
2014-08-03 14:15:14 +00:00
Carl-Daniel Hailfinger
ef3ac8ac17 Refactor unlocking of many chips with locking at register space address +2
This includes PMC Pm49*, SST 49LF00*, ST M50* and Winbond W39* families.
The erase and write test status bits of all affected chips have been reset.

Corresponding to flashrom svn r1833.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
2014-08-03 13:05:34 +00:00
Stefan Tauner
0ab1e5d5e3 jedec.c: constify a bit more
Also, include chipdrivers.h to find conflicting types between exported
declarations and actual implementations.

Corresponding to flashrom svn r1805.

Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
2014-05-29 11:51:24 +00:00
Stefan Tauner
f80419c75a Make delay values unsigned
There is no reason for negative delays in our use cases:
 - We don't need it (to work around any quirks).
 - sleep() (POSIX) uses an unsigned argument.
 - usleep() (POSIX) uses an unsigned argument.
 - Sleep() (Windows) uses an unsigned argument.

Change all callees as well (without any complications).

Corresponding to flashrom svn r1782.

Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
2014-05-02 15:41:42 +00:00
Stefan Tauner
0554ca5cd3 Add a bunch of new/tested stuff and various small changes 18
Tested mainboards:
OK:
 - ASUS C60M1-I
   http://www.flashrom.org/pipermail/flashrom/2013-February/010578.html
 - ASUS P8H77-I
   http://www.flashrom.org/pipermail/flashrom/2013-March/010607.html
 - ASUS P8H77-M
   http://www.flashrom.org/pipermail/flashrom/2013-May/010994.html
 - ASUS P8P67 LE (B2)
   http://www.flashrom.org/pipermail/flashrom/2013-May/010972.html
 - Elitegroup GeForce6100PM-M2 (V3.0)
   http://www.flashrom.org/pipermail/flashrom/2013-July/011177.html
 - GIGABYTE GA-P55A-UD7
   http://www.flashrom.org/pipermail/flashrom/2013-July/011302.html
 - MSI B75MA-E33 (MS-7808)
   http://www.flashrom.org/pipermail/flashrom/2013-March/010659.html
 - MSI H77MA-G43 (MS-7756)
   http://www.flashrom.org/pipermail/flashrom/2013-April/010853.html
 - MSI KA780G (MS-7551)
   http://paste.flashrom.org/view.php?id=1617
 - SAPPHIRE IPC-E350M1
   Reported by xvilka on IRC
 - Supermicro X8DTG-D
   http://www.flashrom.org/pipermail/flashrom/2013-July/011305.html
NOT OK:
 - ASRock Fatal1ty Z77 Performance
   http://www.flashrom.org/pipermail/flashrom/2013-January/010467.html
 - ASRock Z68 Extreme4
   http://www.flashrom.org/pipermail/flashrom/2013-May/010984.html
 - ASUS P8B75-M LE
   http://www.flashrom.org/pipermail/flashrom/2013-April/010867.html
 - ASUS P8P67-M PRO
   http://www.flashrom.org/pipermail/flashrom/2013-February/010541.html
 - ASUS P8Z68-V LE
   http://www.flashrom.org/pipermail/flashrom/2013-February/010582.html
 - Intel DQ77MK
   http://paste.flashrom.org/view.php?id=1603
 - Supermicro X9DRD-7LN4F
   http://paste.flashrom.org/view.php?id=1582
 - Supermicro X9SCE-F
   http://www.flashrom.org/pipermail/flashrom/2013-February/010588.html
 - Supermicro X9SCM-F
   http://www.flashrom.org/pipermail/flashrom/2013-February/010527.html
 - Tyan S7066
   http://www.flashrom.org/pipermail/flashrom/2013-March/010630.html

Chipsets:
 - Marked Intel B75 as tested
   http://www.flashrom.org/pipermail/flashrom/2013-March/010659.html
 - Marked Intel H77 as tested
   http://www.flashrom.org/pipermail/flashrom/2013-March/010607.html
 - Removed 10de:03e2 because it is apparently the MCP61 host bridge.
   It was reclassified to Host Bridge in the PCI device ID database and there
   is at least one report suggesting this configuration too:
   http://www.flashrom.org/pipermail/flashrom/2012-August/009716.html
 - Added MCP89 which hopefully works with the code for previous versions.
   Thanks to James Laird for submitting this change.

Tested flash chips:
 - Atmel AT25DF641(A) to PREW (+PREW)
   http://www.flashrom.org/pipermail/flashrom/2013-June/011113.html
 - Atmel AT25F512 to PREW (+PREW)
   http://www.flashrom.org/pipermail/flashrom/2013-April/010904.html
   Also, change its ID according to Modification of PCN SC040401A:
   "There has been a change in the returned value of the Product Identification
   (RDID) command, the AT25F512A RDID code is 65h compared to 60h from
   the AT25F512 product."
   It seems to be quite likely that all AT25F512 are fully functional relabeled
   AT25F1024 chips. There are even some hints in the datasheet:
   in table 6 they stress that address pin 16 needs to be low under all circum-
   stances; while continuous reads can wrap around on the AT25F1024 the DS
   notes "For the AT25F512, the read command must be terminated when the
   highest address (00FFFF) is reached." OTOH the lock bit semantics are
   different, but this has not been tested thoroughly
 - Atmel AT25F512A to PREW (+PREW)
   http://paste.flashrom.org/view.php?id=1569
 - Eon EN25F05 to PREW (+PREW)
   http://paste.flashrom.org/view.php?id=1571
 - Macronix MX25L12805(D) to PREW (+REW)
   http://www.flashrom.org/pipermail/flashrom/2013-April/010913.html
 - Spansion S25FL256S......0 and S25FL512S to P/!R!E!W (+P)
   Tested by Stefan Tauner
 - Micron/Numonyx/ST M25PX80 to PREW (+PREW)
   Tested by Stefan Tauner
 - Micron/Numonyx/ST N25Q032..3E and N25Q128..3E to PREW (+PREW)
   Tested by Stefan Tauner
 - Micron/Numonyx/ST N25Q256..3E and N25Q512..3G to P/!R!E!W (+P)
   Tested by Stefan Tauner
 - SST SST25VF040B to PREW (+PREW)
   http://paste.flashrom.org/view.php?id=1574
 - SST SST25VF040B.REMS to PREW (+EW)
   http://paste.flashrom.org/view.php?id=1575
 - ST M25P05-A to PREW (+PREW)
   http://paste.flashrom.org/view.php?id=1576
 - ST M29W512B to PREW (+W)
   http://www.flashrom.org/pipermail/flashrom/2013-March/010635.html
 - Winbond W25Q64.W to PREW (+PREW)
   Tested by the chromiumos guys.
 - Winbond W25Q128.V to PREW (+REW)
   http://www.flashrom.org/pipermail/flashrom/2013-June/011108.html
 - Winbond W25X20 to PREW (+PREW)
   http://www.flashrom.org/pipermail/flashrom/2013-May/010990.html

Miscellaneous:
 - Add Lenovo X201 to the laptop whitelist.
 - Add chip IDs for the ESMT F25L..QA family.
 - Add chip IDs for a few Macronix MX25 models.
 - The list of flashchips is not sorted strictly alphabetically and should not be
   either. Refine the comment explaining the scheme on top of the list.
 - Support -L output of chip sizes with up to 6 decimal places (up to 4 Gb).
 - Use z length modifier in (more) prints for size_t types.
 - Remove chips >16MB again because our current implementation of memory mapping
   the flash chip violates common rules by mapping a window as large as the chip.
   This leads to failing mmaps as can be seen here:
   http://paste.flashrom.org/view.php?id=1695
 - Document spispeed parameter of linux_spi (and fix some leaks).
 - Rephrase the "multiple chips detected" message because it was confusing.
 - Skip verification step if the image is equal to the flash contents.
 - Tiny other stuff.

Corresponding to flashrom svn r1702.

Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
2013-07-25 22:54:25 +00:00
Stefan Tauner
c2333751c4 Use uintptr_t for chipaddr instead of unsigned long
Corresponding to flashrom svn r1698.

Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
2013-07-13 23:31:37 +00:00
Stefan Tauner
78ffbeaa02 Do not read the flash chip twice in verification mode
Kyösti Mälkki noticed that we unnecessarily read the flash chip twice when
called with --verify. The first one is the mandatory read before everything
(to be able to detect the seriousness of errors), but the second one is not
necessary because we can just use the former for the comparison.

This introduces a small output change: previously we printed ERASE or
VERIFY depending on the callee. This special case has been dropped
because it is unnecessary to print it (and wrong for the verification
function to need to know why it is verifying exactly).
If an erase fails we mention that fact explicitly already, similar for verify.

Corresponding to flashrom svn r1619.

Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
2012-10-27 15:36:56 +00:00
Carl-Daniel Hailfinger
5a7cb847f0 Make struct flashchip a field in struct flashctx instead of a complete copy
All the driver conversion work and cleanup has been done by Stefan.
flashrom.c and cli_classic.c are a joint work of Stefan and Carl-Daniel.

Corresponding to flashrom svn r1579.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
2012-08-25 01:17:58 +00:00
Carl-Daniel Hailfinger
8a3c60cdd0 Add struct flashctx * parameter to all functions accessing flash chips
All programmer access function prototypes except init have been made
static and moved to the respective file.

A few internal functions in flash chip drivers had chipaddr parameters
which are no longer needed.

The lines touched by flashctx changes have been adjusted to 80 columns
except in header files.

Corresponding to flashrom svn r1474.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Michael Karcher <flashrom@mkarcher.dialup.fu-berlin.de>
2011-12-18 15:01:24 +00:00
Carl-Daniel Hailfinger
63fd9026f1 Use struct flashctx instead of struct flashchip for flash chip access
Struct flashchip is used only for the flashchips array and for
operations which do not access hardware, e.g. printing a list of
supported flash chips.

struct flashctx (flash context) contains all data available in
struct flashchip, but it also contains runtime information like
mapping addresses. struct flashctx is expected to grow additional
members over time, a prime candidate being programmer info.
struct flashctx contains all of struct flashchip with identical
member layout, but struct flashctx has additional members at the end.

The separation between struct flashchip/flashctx shrinks the memory
requirement of the big flashchips array and allows future extension
of flashctx without having to worry about bloat.

Corresponding to flashrom svn r1473.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Michael Karcher <flashrom@mkarcher.dialup.fu-berlin.de>
2011-12-14 22:25:15 +00:00
Stefan Tauner
c69c9c84e0 Unsignify lengths and addresses in chip functions and structs
Push those changes forward where needed to prevent new sign
conversion warnings where possible.

Corresponding to flashrom svn r1470.

Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
2011-11-23 09:13:48 +00:00
Stefan Tauner
8c35745fcf Revert "Unsignify lengths and addresses in chip functions and structs"
- probe_timing was changed to unsigned although we use negative values
  for special cases
- some code was not changed along hence did no longer compile:
  * dediprog's read and write functions
  * linux_spi's read and write functions
- it introduced a number of new sign conversion warnings
  (http://paste.flashrom.org/view.php?id=832)

To be safe this patch reverts all changes made in r1448, a corrected
patch will follow later.

Thanks to idwer for pointing out the problem first!

Corresponding to flashrom svn r1450.

Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
2011-09-18 22:42:18 +00:00
Stefan Tauner
d196e7c138 Unsignify lengths and addresses in chip functions and structs
Corresponding to flashrom svn r1448.

Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
2011-09-18 00:41:33 +00:00
Stefan Tauner
a63c7c4496 Remove unneeded inclusions of chipdrivers.h
This is related to the spi split patch as discussed in:
http://www.flashrom.org/pipermail/flashrom/2010-February/thread.html#2364
the old commit (r914) log notes:
"Some of the spi programmer drivers required chipdrivers.h, needs fixing later: it87spi.c
  ichspi.c   sb600spi.c   wbsio_spi.c   buspirate_spi.c   ft2232spi.c   bitbang_spi.c   dediprog.c"

there still remain a few cases where chipdrivers.h is needed:
dediprog.c (spi_read_chunked and spi_write_chunked)
it87spi.c (due to spi_write_enable and spi_read_status_register)
wbsio_spi.c (spi_programmer registration only)

besides that, there are also non-spi files that do not need it.
also, add flash.h to chipdrivers.h because it uses some types of it
and remove flashchips.h from print.c

Corresponding to flashrom svn r1414.

Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
2011-08-16 12:08:22 +00:00
Carl-Daniel Hailfinger
b4061f61cd Move erase verification to generic code
Erase functions are no longer called from chip drivers and thus their
internal erase verification can be moved to generic code. This also
makes it easier to skip the verify step if desired and to differentiate
between failed command submission and failed erase verification.

Corresponding to flashrom svn r1353.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
2011-06-26 17:04:16 +00:00
Michael Karcher
880e867ae8 Remove delays in JEDEC erase sequence
It is extremely unlikely that a chip not requiring delays in probe does
require them in erase. We observed unreliable erasing with a SST49LF004A
with these delays, so remove them if the are not required.

In review, I got the hint that "probe_jedec goes further by making that
call conditional on nonzero delay". I decided to ignore that. For
internal_delay, the small amount of clock cycles wasted for calling
programmer_delay(0) is negligible compared to LPC cycle times. It might
be an issue for 5 wasted bytes on the serial line in serprog. OTOH,
flash erase is still slow compared to 6*5 bytes on a serial port at
reasonable speed.

Corresponding to flashrom svn r1288.

Signed-off-by: Michael Karcher <flashrom@mkarcher.dialup.fu-berlin.de>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
2011-04-15 00:03:37 +00:00
Sean Nelson
f59e2637d1 Add a reset to probe_jedec before we read the chip's IDs
Previous probes might have had too short delays for entering ID mode,
so the chip may still be in the process of entering the ID mode. Due to
that, an additional delay before the reset makes sense.
Add FEATURE_RESET_MASK to deal cleanly with those feature bits.

Maciej Pijanka tested the patch and it fixes probing for him with some
old Atmel chips.

Corresponding to flashrom svn r1216.

Signed-off-by: Sean Nelson <audiohacked@gmail.com>
Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Anders Juel Jensen <andersjjensen@gmail.com>
Tested-by: Maciej Pijanka <maciej.pijanka@gmail.com>
Acked-by: Sean Nelson <audiohacked@gmail.com>
2010-10-20 21:13:19 +00:00
Carl-Daniel Hailfinger
75a58f94cc Switch all flash chips to partial write
The inner write functions which handle partial write are renamed to the
original name of their wrappers. The write wrappers are removed.

Corresponding to flashrom svn r1211.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Tested-by: Maciej Pijanka <maciej.pijanka@gmail.com>
Tested-by: Andrew Morgan <ziltro@ziltro.com>
Tested-by: Idwer Vollering <vidwer@gmail.com>
Acked-by: Idwer Vollering <vidwer@gmail.com>
Tested-by: Sean Nelson <audiohacked@gmail.com> 
Acked-by: Sean Nelson <audiohacked@gmail.com>
2010-10-13 22:26:56 +00:00
Carl-Daniel Hailfinger
79e6757d26 Refactor remaining write wrappers
Kill duplicated code.

Annotate write functions with their chunk size.

Mark Fujitsu MBM29F400BC and ST M29F400BB as untested because their
write code no longer uses a broken layout.

Corresponding to flashrom svn r1210.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
Tested-by: Maciej Pijanka <maciej.pijanka@gmail.com>
Tested-by: Idwer Vollering <vidwer@gmail.com>
Acked-by: Idwer Vollering <vidwer@gmail.com>
Tested-by: Sean Nelson <audiohacked@gmail.com> 
Acked-by: Sean Nelson <audiohacked@gmail.com>
2010-10-13 21:49:30 +00:00
Carl-Daniel Hailfinger
184b95f449 Simplify calls to inner write functions
No behavioural changes, just equivalence transformations.

Corresponding to flashrom svn r1209.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
2010-10-10 16:10:49 +00:00