| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
| |
The install target used $(sbindir) which isn't set anywhere.
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
|
|
|
|
|
|
|
|
| |
Add command line parameters for passing into libflash to have
pflash manipulate a file rather than flash.
This is useful for testing.
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Reviewed-by: Cyril Bur <cyril.bur@au1.ibm.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The current pflash cmd-line option parsing has two flaws.
Firstly, the error reporting leaves quite a bit to be desired. That is, when
invalid options or argument are found, not much reporting is done. This patch
addresses this.
Secondly, pflash doesn't detect when there are leftovers in argv. This often
signals a typo in what the user meant to do and could lead to the wrong
outcome. For example: `pflash -e -p zImage.next - P BOOTKERNEL` will do quite
the wrong thing.
This patch addresses both issues.
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The makefiles under external/* utilize the $(CROSS_COMPILE) variable
to determine the cross-compiler prefix. In a few places,
$(CROSS_COMPILE)gcc is called instead of $(CC). The issue with this is
that yocto build passes some compile flags as part of $(CC) instead of
$(CFLAGS), the most important of these is '--sysroot=...'. Without the
proper --sysroot flag, pflash compile fails to find critical libc
headers like stdio.h.
This change delegates setting of $(CC) and $(LD) to
external/common/rules.mk, which is widely used in the external tree, and
ensures that:
1) $(CC) is used instead of $(CROSS_COMPILE)gcc.
2) CC is only set when not passed from the environment.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Reviewed-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
|
|
|
|
|
|
|
| |
Move symlinking target to external/common/rules.mk, so the rule
could be reused by gard and opal-prd.
Signed-off-by: Dinar Valeev <dvaleev@suse.com>
Reviewed-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The current behaviour of --bmc is to take over the flash controller. This
flag was written for very early bring-up when the BMC stack would run
entirely out of RAM. This is no longer the case and using --bmc on a BMC
running out of the very flash --bmc will read is extremely likely to brick
the system.
It has come to light that there is some requirement to read BMC flash and
some thinking that pflash is the appropriate tool. As AMI BMC firmware
exposes the flash through /dev/mtd and pflash can be easily taught to read
from MTD pflash can be upgraded to be the tool for the job.
In order to preserve the current behavior of the --bmc a new flag --mtd
has been introduced to have pflash access BMC flash the 'safe' way.
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Currently the file backend will keep a file descriptor open until the
structure is destroyed. This is undesirable for daemons and long running
processes that only have a very occasional need to access the file. Keeping
the file open requires users of blocklevel to close and reinit their
structures every time, doing is isn't disastrous but can easily be
managed at the interface level.
This has been done at the blocklevel_device interface so as to provide
minimal changes to arch_flash_init().
At the moment there isn't a need for the actually flash driver to be able
to do this, this remains unimplmented there.
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When building under buildroot, libflash was being built before the
links:
make[2]: *** No rule to make target 'libflash/libflash.c', needed by
'libflash-libflash.o'. Stop.
make[2]: *** Waiting for unfinished jobs....
LN ccan
LN common
LN libflash
To reproduce this outside of buildroot, set PFLASH_VERSION to anything.
This is another race that is only exposed in certain conditions. By
describing the dependencies on the source files the build works again.
I think it's almost time to stop using symlinks.
Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
|
|
|
| |
Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
|
|
| |
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
|
|
|
|
|
|
|
|
|
|
| |
We need to test all the backends when eg. making changes to libflash, to
ensure that something hasn't gone wrong. To encourage developers to do
this, add a script to simplify it.
Patches welcome to detect the specific cross compilers binaries shipped
on your favourite distro.
Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Adding quiet rules to make our output a bit cleaner. Building now looks
like this:
$ make
LN libflash
LN common
LN ccan
CC pflash.o
CC version.o
LD common-arch_flash.o
CC pflash
You can see the full build ouput by doing a "make V=1".
By doing this, we build fractionally faster, exposing arace condition
between running the make_version.sh script and the link existing for it.
As we run it when creating the variable, there is no way to ensure it
exists first.
Solved this by not creating the symlink and simply running
make_version.sh from the root.
Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
pflash contained a copy of the include/ast.h header. It had grown stale,
so remove in and link in the common header.
Note that it's hard to test that we haven't broken tools in the
external/ directory these days; when making changes we need to test with
amd64, ppc64, ppc64le and arm to ensure that everything can build!
Signed-off-by: Joel Stanley <joel@jms.id.au>
Reviewed-by: Cédric Le Goater <clg@fr.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|
|
|
|
| |
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
|