Age | Commit message (Collapse) | Author | Files | Lines |
|
Otherwise we could end up trying to build files before the links
are created.
Let's use a heavy handed approach and not build *anything* until
we have the links.
Reported-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
For the need of Debian/Ubuntu packaging, I infered some initial man
pages from their help output.
Signed-off-by: Frédéric Bonnard <frediz@linux.vnet.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
The write(2) system call returns the number of bytes written, this is
important since it is entitled to write less than what we requested.
Currently we ignore the return value and assume it wrote everything we
requested. While in practice this is likely to always be the case, it
isn't actually correct.
This patch addresses this.
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
Add the misc flag clear_on_ecc_error to libflash/pflash. This was
the only missing flag. The generator of the virtual pnor image
relies on libflash/pflash to provide the partition information,
so all flags are needed to build an accurate virtual pnor partition
table.
Signed-off-by: Adriana Kobylak <anoo@linux.vnet.ibm.com>
Reviewed-by: Cyril Bur <cyril.bur@au1.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
When performing a read the return value from pflash is non-zero, even for
a successful read, when the size being read is not a multiple of 256.
This is because do_read_file returns the value from the write system
call which is then returned by pflash. When the size is a multiple of
256 we get lucky in that this wraps around back to zero. However for any
other value the return code is size % 256. This means even when the
operation is successful the return code will seem to reflect an error.
Fix this by returning zero if the entire size was read correctly,
otherwise return the corresponding error code.
Fixes: e1cf130d ("external/pflash: Remove use of exit() and fix memory leaks")
Reported-by: Pridhiviraj Paidipeddi <ppaidipe@linux.vnet.ibm.com>
Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
Reviewed-by: Cyril Bur <cyrilbur@gmail.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
It is possible to erase within a single erase block. Currently the
pflash code assumes that if the erase starts part way into an erase
block it is because it needs to be aligned up to the boundary with the
next erase block.
Doing an erase smaller than a single erase block will cause underflows
and looping forever on erase.
Fixes: ae6cb86c2 ("external/pflash: Reinstate the progress bars")
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
Fixes: b786e7ba1d34c5a4d8baa6304f4d930539cefac8
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
The volatile flag was added to the pnor image to
indicate partitions that are cleared during a host
power off. Display this flag from the pflash command.
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
The erase_range() function handles erasing the flash for a given start
address and length, and can handle an unaligned start address and
length. However in the unaligned start address case we are incorrectly
calculating the remaining size which can lead to incomplete erases.
If we're going to update the remaining size based on what the start
address was then we probably want to do that before we overide the
origin start address. So rearrange the code so that this is indeed the
case.
Reported-by: Pridhiviraj Paidipeddi <ppaidipe@in.ibm.com>
Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
Reviewed-by: Cyril Bur <cyril.bur@au1.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
When writing ECC bytes to ECC regions we don't check that
blocklevel_write() succeeds nor we check that the region was correctly
erased prior to setting the ECC bytes.
Fixes: CID 163737
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
Thanks Coverity.
Fixes: CID 163745
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
Thanks Coverity.
Fixes: CID 163742
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
Several of the cases in the getopt loop take the optarg pointer and pass
it to functions which will dereference it. There is currently no bug as
all of these are marked to getopt as having a requirement argument so
optarg will never be null.
The rationale for this patch is firstly to silence coverity as it is
fairly simple to do. More importantly having a brand new version of this
Coverity error appear in the event of a future mistake with optional
arguments to getopt will be useful.
Fixes: CID 163739
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
New code that is very much pflash functionality was added in commit
f2c87a3d2f6 "pflash option to retrieve PNOR partition flags".
Unfortunately at the time there wasn't an easy way to test pflash.
The previous patch adds pflash infrastructure and plumbs it into
`make check` nicely. This commit converts the tests originally added to
libflash tests.
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
Reviewed-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
Reviewed-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
Recent work did some optimising which unfortunately removed some of the
progress bars in pflash.
It turns out that there's only one thing people prefer to correctly
programmed flash chips, it is the ability to watch little equals
characters go across their screens for potentially minutes.
Personally I don't understand the appeal but I have received strongly
worded requests for the reinstatement of the progress bars in pflash and
I fear for the stability of our society if pflash doesn't promptly regain
its most unimportant feature.
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
Reviewed-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
Reviewed-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
Using exit() all over the place has lead to a huge mess of leaving all
sorts of dangling references to malloc()ed memory, to blocklevel_devices
and even sometimes file descriptors.
Stop using exit() and simply report everything back to the main where
everything can be freed on the way back out.
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
Reviewed-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
Very simple rework, makes sense to calculate those at the same time.
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
Reviewed-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
It doesn't make sense for --tune to do anything unless --direct was
passed.
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
Reviewed-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
Currently all the flash details including the pointer to the
blocklevel_device to access the flash is global. This is annoying since
it makes it hard to know when it was allocated, some of the code just
changes it which makes tracking difficult.
Rather than have it globally accessible, pass it around as a structure
so better control who modifies it and where and when.
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
Reviewed-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
pflash should check the alignment of addresses and sizes when asked to
erase. There are two possibilities:
1. The user has specified sizes manually in which case pflash should
be as flexible as possible, blocklevel_smart_erase() permits this. To
prevent possible mistakes pflash will require --force to perform a
manual erase of unaligned sizes.
2. The user used -P to specify a partition, partitions aren't
necessarily erase granule aligned anymore, blocklevel_smart_erase() can
handle. In this it doesn't make sense to warn/error about misalignment
since the misalignment is inherent to the FFS partition and not really
user input.
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
Reviewed-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
Reviewed-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
Also add 0x in front of --info output to avoid a copy and paste mistake.
Reported-by: Michael Neuling <mikey@neuling.org>
Suggested-by: Michael Neuling <mikey@neuling.org>
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
Reviewed-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
Recent reworks of pflash expose more partition flags, the --info command
only prints them in their one character short names.
It isn't obvious what they all are, add a little description
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
Reviewed-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
Also add usage text to pflash.
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
Reviewed-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
This enables some extra linked list checking
Reviewed-by: Cyril Bur <cyril.bur@au1.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
mostly missing prototypes and unused parameters.
Reviewed-by: Cyril Bur <cyril.bur@au1.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
This commit extends pflash with an option to retrieve and print
information for a particular partition, including the content from
"pflash -i" and a verbose list of set miscellaneous flags. -i option
is also updated to print a short list of flags in addition to the
ECC flag, with one character per flag. A test of the new option is
included in libflash/test.
Signed-off-by: Michael Tritz <mtritz@us.ibm.com>
Reviewed-by: Cyril Bur <cyril.bur@au1.ibm.com>
[stewart@linux.vnet.ibm.com: various test fixes, enable gcov]
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
Remove 'Support pnor "update" mode which only update selected partitions'
from TODO list as pflash supports --partition=part_name already
Signed-off-by: Werner Fischer <wfischer@thomas-krenn.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
If the -F flag is used then pflash uses a regular file as the flash.
On cleanup pflash fails to tell arch_flash_close() if it had passed a
filename to arch_flash_init() as such arch_flash_close() assumes that
it needs to close the actual flash structure and not simply a file
descriptor leading to a NULL dereference.
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
Fixes: 86640b032d79ff0 (pflash: Fix printf format warning)
Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
Currently we warn the user and truncate the file by default. Instead
abort as this is rarely the desired behaviour.
You can still shoot yourself in the foot by passing --force.
Signed-off-by: Joel Stanley <joel@jms.id.au>
Reviewed-by: Cyril Bur <cyril.bur@au1.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
Now that BMC and host kernel mtd drivers exist and have matured we
should use them by default.
This is especially important since we seem to be telling everyone to use
pflash.
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
Honestly the first name was terrible. Initially this was intended only
to serve for BMC/ARM flash access, however, it should be more generic as
it is in the external/common arch code it should play nice on all
architectures.
This change also paves the way to change the default flash access
methods in pflash.
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
Acked-by: Joel Stanley <joel@jms.id.au>
[stewart@linux.vnet.ibm.com: preserve Joel's ack]
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
Warnings in progress.c are not critical but warn about %d being used in printf
format string when the parameter passed is unsigned.
Trivial fixup which should silence the warnings.
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
Let use LDFLAGS from the environment for gard and pflash
Debian/Ubuntu use this mechanism to do hardened builds.
Signed-off-by: Frederic Bonnard <frediz@linux.vnet.ibm.com>
[stewart@linux.vnet.ibm.com: also use LDFLAGS for pflash]
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
When we're using a file on the filesystem as the flash device,
we don't need to write protect it when we flash.
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
pflash.c: In function ‘print_flash_info’:
pflash.c:138:27: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘uint64_t {aka long unsigned int}’ [-Wformat=]
printf("Total size = %dMB \n", fl_total_size >> 20);
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
Currently pflash and opal-prd do not return to its original tree
after a 'make distclean'. I understand that distclean should return the tree to
its original state, so, the make can restart from scratch.
On Debian[1], we need to clear these remaining file 'manually' to make the
build 'reproducible' (two builds in sequence).
[1] https://packages.debian.org/source/sid/skiboot
Signed-off-by: Breno Leitao <breno.leitao@gmail.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
This ends up being harmless bug due to memory layout.
$ ./pflash -F ~/op-build/output/images/firestone.pnor -i
==31829==ERROR: AddressSanitizer: global-buffer-overflow on address 0x00000062f0
80 at pc 0x410226 bp 0x7ffedba9c950 sp 0x7ffedba9c948
WRITE of size 8 at 0x00000062f080 thread T0
#0 0x410225 in file_get_info (/home/stewart/skiboot/external/pflash/pflash+0
x410225)
#1 0x40d832 in blocklevel_get_info (/home/stewart/skiboot/external/pflash/pf
lash+0x40d832)
#2 0x401f0c in main (/home/stewart/skiboot/external/pflash/pflash+0x401f0c)
#3 0x7fc77439ab44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21
b44)
#4 0x403884 (/home/stewart/skiboot/external/pflash/pflash+0x403884)
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
Someone was a bit too keen with the cleanups last time. Restore the
ability for pflash to build in non-shared mode.
Fixes: c327eddd9b29 (pflash: Clean up makefiles and resolve build race)
Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
I accidentally built myself a cross-toolchain with the musl libc. It does
not support on_exit which we use to clean up in pflash.
Instead use atexit with is supported by both uclibc, musl and glibc.
Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
The pflash build process has regressed from when the were last fixed in
6c21c4ffaf82.
This patch resolves that issue and performs some cleanups:
- Remove duplicated rules. Patches had moved rules into common files,
but forgotten to remove them from the pflash makefiles.
- Make assignements simply expanded variables where possible. Form the
make manual:
Functions referenced in the definition will be executed every time
the variable is expanded. This makes make run slower; worse, it
causes the wildcard and shell functions to give unpredictable
results because you cannot easily control when they are called, or
even how many times.
To avoid all the problems and inconveniences of recursively
expanded variables, there is another flavor: simply expanded
variables.
- set the 'shared' target as a dependency of the libflash objects. This
was the final piece to resolve the race condition.
The failed build could be reproduced by doing a `git clean -f -x` and
then running the following:
$ make -j 32 CROSS_COMPILE=arm-linux-gnueabi- SKIBOOT_VERSION=5.2.4
PFLASH_VERSION=5.2.4 V=1 -C external/pflash all LINKAGE=dynamic
make: Entering directory '/home/joel/dev/skiboot/external/pflash'
ln -sf ../../libflash ./libflash
ln -sf ../../ccan ./ccan
ln -sf ../common ./common
cc -O2 -Wall -I. -c pflash.c -o pflash.o
cc -O2 -Wall -I. -c progress.c -o progress.o
make -C ../shared
make[1]: Entering directory '/home/joel/dev/skiboot/external/shared'
ln -sf ../../hw/ast-bmc/ast-sf-ctrl.c common/ast-sf-ctrl.c
ln -sf ../../include/ast.h common/ast.h
ln -sf arch_flash_arm_io.h common/io.h
cc -O2 -Wall -I. -c common/arch_flash_common.c -o
common-arch_flash_common.o
cc -O2 -Wall -I. -c common/arch_flash_arm.c -o common-arch_flash_arm.o
cc -O2 -Wall -I. -c common/ast-sf-ctrl.c -o common-ast-sf-ctrl.o
cc -O2 -Wall -I. -c version.c -o version.o
ld -r common-arch_flash_common.o common-arch_flash_arm.o
common-ast-sf-ctrl.o -o common-arch_flash.o
ln -sf ../../libflash ./libflash
ln -sf ../../ccan ./ccan
ln -sf ../common ./common
make[1]: *** No rule to make target 'libflash/file.c', needed by
'libflash-file.o'. Stop.
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory '/home/joel/dev/skiboot/external/shared'
rules.mk:25: recipe for target
'../shared/libflash.so.skiboot-5.2.4-1-g9f13f64c322f-joel-dirty-d5873ce'
failed
make: ***
[../shared/libflash.so.skiboot-5.2.4-1-g9f13f64c322f-joel-dirty-d5873ce]
Error 2
Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
While reviewing the Debian packaging, codespell found those.
Most proposed fixes are based on codespell's default dictionnary.
Signed-off-by: Frederic Bonnard <frediz@linux.vnet.ibm.com>
Reviewed-by: Mukesh Ojha <mukesh02@linux.vnet.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
Modify the $(EXE) and install target dependencies if LINKAGE=dynamic.
The default remains a statically linked pflash binary.
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|