| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
| |
NAND mtd devices carry information how the OOB area is used. So far
there is no way to visualize it, so print it along with other NAND
informations.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This updates the barebox NAND layer and parts of the mtd layer to
Linux-5.9.
This patch is huge, but the barebox NAND layer is so far away from the
Linux NAND layer that a step by step update would have taken ages.
Unlike Linux barebox has functions to mark a block as good. This feature
has been preserved. Also barebox used to make NAND write support
optional, this feature is lost during the update for the sake of better
compatibility to the Linux NAND layer.
This patch has been tested:
- GPMI aka nand_mxs on i.MX6
- nand_imx on i.MX25
- nand_omap_gpmc on AM335x
- atmel_nand on Atmel sama5d3
- nand_denali on SoCFPGA
Currently untested:
- nand_orion
- nand_mrvl_nfc
- nand_s3c24xx
The nand_denali driver is tested with the update of that driver to
Linux-5.9 following in the next patch.
I could only test the drivers with the NAND chips found on my boards, so
there's still enough room for regressions, especially given that the
NAND drivers themselves are mostly not updated. With the NAND layer
being up-to-date with Linux it should hopefully be easy to update
drivers to their Linux counterpart as well if necessary.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
| |
In Linux mtd->parent is what in barebox is mtd->master. Rename this
to get closer to the Linux mtd layer.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
| |
The mtds own device is named 'dev' in the Kernel whereas it's named
'class_dev' in barebox. Rename it to 'dev' for better compatilibility
to the Kernel.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
| |
Instead of mtd->parent we can use mtd->classdev.parent which points to
the same device. With this we can remove the 'parent' member of struct
mtd_info. This member exists in the Linux kernel as well, but is of type
struct mtd_info, so this is done as preparation to re-add mtd->parent
with the same type as in Linux.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
| |
In the Kernel the mtd function hooks begin with an underscore. Do the
same in barebox to be better comparable to the Kernel.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
| |
asynchronous erase support is unused and also dropped from the Kernel,
so remove it from barebox.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
| |
The CREDITS file was removed from barebox in 2015 by commit 6570288f2d97
("Remove the CREDITS file"). Remove references to it from several files.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Only the following cdevs do not declare an .lseek() operation:
- Console devices in common/console.c
- Firmware framework in common/firmware.c
- JTAG driver in drivers/misc/jtag.c
- UBI in drivers/mtd/ubi/barebox.c
Of those four, first two are marked DEVFS_IS_CHARACTER_DEV and
implement only .write() operation and the last two don't implement
anything but .ioctl(). While there's probably no meaningful way to use
lseek() against any of those devices, there doesn't seem to be any
harm in allowing it either.
Change devfs_lseek() to ignore absense of .lseek() callback and drop
dev_lseek_default() and all references to it in the codebase.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
On Thu, Jan 10, 2019 at 09:32:07AM +0100, Sascha Hauer wrote:
> On Wed, Jan 09, 2019 at 12:28:14PM +0100, Ladislav Michl wrote:
> > Devices as AT45DB161 DataFlash uses non power of two page size (528)
> > while present alignment algorithm relies on erasesize being power
> > of 2.
> > Fix that by introducing helper functions rounding to any multiply.
> > Note that logic is sligthly changed to be consistent as ending
> > address is moved forward to include also last byte meant to be
> > erased while previous implementation moved it backward.
> >
> > Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
> > ---
> > drivers/mtd/core.c | 28 ++++++++++++++++++++++------
> > include/linux/kernel.h | 5 +++++
> > 2 files changed, 27 insertions(+), 6 deletions(-)
>
> Applied, thanks
Hi Sascha,
I was searching for paper bag, but was unable to find anything thick
enouh to cover behind :-/ This version is buggy and I noticed right
now when testing on another board. Corrected version follows, which
is also 192 bytes shorter for my ARM target. It seems next branch
at https://git.pengutronix.de/ is not yet updated, so perhaps my fault
won't affect anyone.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
At least some MTD_NO_ERASE devices like MRAM do not specify a sensible
erase block size; instead, erasesize is equal to the whole flash size. This
leads to an EINVAL return from mtd_erase_align() whenever a partial erase
is attempted.
At least on the MRAM I tested, a full flash erase did not return an error,
but it did not have any effect on the flash either. As erase seems to be
entirely unsupported on this class of devices, and it is not necessary
anyways, it's better to return early with EOPNOTSUPP.
This fixes envfs_save() on a partitioned MRAM.
Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
| |
Introduce dev_set_name() in order to hide implementation details of
setting device's name so it'd be easier to change it.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
| |
in mtd_detect we do not check if the mtd is already attached to UBI. If
it is we get the error:
ERROR: ubi: mtd0 is already attached to ubi0
Check before trying to attach it to avoid this message.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
| |
When printing the partition size with "0x" prefix the value has to
be displayed in hex.
Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
| |
Linux also has struct file_operations which are something different.
Rename our file_operations to cdev_operations which better matches
what we have.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This patch creates a consitent set of device parameter functions.
With this we have: dev_add_param_<type><access>
"type" is one of: int32, uint32, int64, uint64, string, mac, ipv4, enum, bitmask
The improvement here is that we now can exactly specify the width of the
int type parameters and also correctly distinguish between signed and
unsigned variables which means that a variable no longer ends up with
INT_MAX when it's assigned -1.
"access" can be empty for regular read/write parameter, "_ro" for readonly
parameters which get their value from a variable pointer in the
background or "_fixed" for parameters which are set to a fixed value
(without a pointer in the background).
Some more exotic types are not (yet) implemented, like
dev_add_param_ip_ro.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
| |
dev_add_param_string allows to pass a priv * so that the device_d *
argument is not needed and can be removed later.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
| |
Move the fixup code where the parser code is already.
Since the code will not only be used for mtd in the future
drivers/of/ is a better place than drivers/mtd/.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
| |
mtd_read´() returns -EUCLEAN to indicate that a page needs cleanup.
This value shouldn't be returned from the mtd read file operation
since this should return the number of bytes read.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When we want to detect if a mtd device contains an UBI image then
testing the first block is not enough since it can always happen that
UBI has just erased the block before the power failed during last boot.
Since UBI only ever erases one block at a time and directly writes the
ec header to it afterwards, it shouldn't be necessary to scan the whole
device for UBI data. Scan the first 64 blocks. The first non-empty block
then must contain UBI data, if instead we find foreign data we assume
that no UBI is on that mtd device.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
| |
Our asprintf and vasprintf have different prototypes than the glibc
functions. This causes trouble when we want to share barebox code
with userspace code. Change the prototypes for (v)asprintf to match
the glibc prototypes. Since the current (v)asprintf are convenient
to use change the existing functions to b(v)asprintf.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
| |
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
| |
To make clear this function checks a given buffer and not data on a mtd
device.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
| |
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
| |
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
| |
mtd_[read|write|erase] are input functions to the mtd subsystem, so
check for valid input data here rather than relying on the drivers doing
this. The checks are copied from the Kernel as of 4.5-rc5
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
| |
Check if the given offset is valid for the mtd device. Print an error
message if not to inform the user in the command 'nand'.
Signed-off-by: Stefan Christ <s.christ@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
| |
When a device >4GiB is erased, not only the offset can be bigger
than 4GiB, but also the size. This happens with the simplest command
to erase a device: erase /dev/nand0. Make the size argument a 64bit
type to make this work.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
| |
The mtd erase file operation has a unnecessary conversion to unsigned
long in the offset. Remove it to make it work with chips >4GiB.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
| |
The mtd read file operation has a unnecessary conversion to unsigned
long in the read offset. Remove it to make it work with chips >4GiB
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
| |
Make the userspace structs 64bit where necessary. Since we do not have
separated kernel/userspace in barebox we can just modifiy the original
structs instead of adding separate 64bit structs.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
| |
Some mtd drivers like the spi-nor driver do not assign a value
to the retlen pointer but instead only add the bytes written
to *retlen. Users of mtd_write expect the variable to be initialized
by the mtd core though, so we have to do it in mtd_write(). The
same is done in mtd_read already.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
| |
Partition names should be partition@<offset> with <offset> being the
offset in the master mtd, and not a counting number.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
| |
Make setting partitions a litte bit more robust.
Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|\
| |
| |
| |
| | |
Conflicts:
drivers/mtd/core.c
|
| |
| |
| |
| |
| |
| |
| | |
Hook UBI attachment into the mtd class devices detect function. This
makes it possible to attach ubi devices with 'detect nand0.root'.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|/
|
|
|
|
|
| |
add_mtd_device duplicates the string where necessary, so make it
const.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
| |
mtd_op_protect must return int instead of size_t.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|\ |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
We have to start searching for the mtd node starting in the given root node not
the defaukt (= barebox internal) one. This means the internal DT is always
fixed up. This leads to booting not fixed up DT when using external DTs.
This patch fixes the problem.
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
To get the number of address cells and size cells we have to use
the newly created partition node, not the parent device node. The
parent device node returns the address/size cells of the controller
node, not the partition node.
On an am335x machine this fixes the device tree passed to Linux.
The situation there is:
...
gpmc@50000000 {
...
#address-cells = <0x2>;
#size-cells = <0x1>;
ranges = <0x0 0x0 0x8000000 0x10000000>;
...
nand@0,0 {
reg = <0x0 0x0 0x0>;
#address-cells = <0x1>;
#size-cells = <0x1>;
...
partition@7 {
label = "system";
reg = <0x220000 0x7de0000>;
};
};
};
and without this patch barebox passes three bytes for
partition@7's reg property instead of only two which naturally
confuses Linux and yields to the system partition to start at 0
with a size of 0x220000.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Reported-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Tested-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
|
|
|
|
| |
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
| |
The partitions parameter allows to partition a mtd device
using a standard cmdline partition description string. This
way the partitions of a mtd device can be changed at once.
The output of the string can be used to be passed to the kernel
as cmdline partition string. The partitions can also still be
changed with addpart/delpart, the partitions parameter will
be updated accordingly.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
| |
mtd partitions should not conflict with each other, so forbid this.
Also add the partitions to the partitions list sorted, so that they
can be easier translated into a cmdline partition string.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
| |
the bb devices which are created in add_mtd_device() must be removed
in del_mtd_device(). Also remove deletion of the bb devices in the
mtdparts-add environment file.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
| |
So that we can iterate over the existing partitions from the master
mtd device.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
| |
register_device and devfs_create can fail. Add error checks for these.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
| |
Partitions are mtd devices themselves, but the 'erasebad'
parameter is only set to the master mtd device. To allow to
erase bad blocks on partitions test the master device instead
of the partition devices.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
| |
Signed-off-by: Herve Codina <Herve.CODINA@celad.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
| |
Signed-off-by: Herve Codina <Herve.CODINA@celad.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|