Mbed OS does not enable C++ exceptions, so we should call `new` with
`std::nothrow` which returns a C-style NULL pointer when allocation
fails to allow error handling.
For consistency of style within the same file, this commit also
replaces `malloc()` and `free()` to `new (std::nothrow)` and `delete`.
Add const to function declaration. Const objects cannot access const
safe functions, a compiler error is thrown if one tries to do so. This
helps ensure that the object calling the method will not be modified.
This is espescially desirable in functions where all we need to do is
query existing data and not make any alterations.
[Q/O/SPIFBlockDevice::erase() begin with an alignment check,
after which unaligned erases should not happen or be allowed.
If the erase address is not aligned to the value returned by
sfdp_iterate_next_largest_erase_type(), it indicates an
internal error in erase table parsing which should not be
hidden.
From the datasheet of the only OctaSPI flash we currently support
(http://www.mt-system.ru/sites/default/files/docs/Macronix/mx25lm51245g_3v_512mb_v0.01.pdf):
After program/erase command is issued, auto program/erase
algorithms which program/erase and verify the specified page
or sector/block locations will be executed. Program command is
executed on byte basis, or page (256 bytes) basis, or word basis.
Erase command is executed on sector (4K-byte), or block (64K-byte),
or whole chip basis.
So the minimum write size is one byte.
Prior to this PR, the minimum program size (QSPI_MIN_PROG_SIZE) of
QSPIFBlockDevice was 256 by default and 512 for some targets.
Those values were in fact page sizes, not program sizes.
Here's an explanation:
* Most QSPI flashes can be programmed to a granularity of a
single byte or a few bytes - no need to be a whole page.
This should be the value of QSPI_MIN_PROG_SIZE. Applications
need to align buffer sizes to this granularity when
programming QSPI flashes.
* Each sending of the underlying QSPI program signal requires
destination bytes to be located within the same page.
If a QSPIFBlockDevice::program() call crosses page boundaries,
this function breaks down the operation into multiple chunks,
so it's not a concern for the application.
So this PR changes the default program size to 1 (byte), and
for targets with a 4-byte (1-word) read size it overrides the
program size.
Note: No config is needed for the page size, as it comes from
the SFDP table parsed during initialisation.
Aside from the core mbed-os CMake target, a number of targets have been created so they can optionally be included by application executables that require them using `target_link_libraries()`.
Co-authored-by: Martin Kojtal <martin.kojtal@arm.com>
Co-authored-by: Rajkumar Kanagaraj <rajkumar.kanagaraj@arm.com>
Add license identifier to files which Arm owns the copyright to,
and contain either BSD-3 or Apache-2.0 licenses. This is to address
license errors raised by scancode analysis.
To allow overriding of the boot stack size from the Mbed configuration
system, consistently use MBED_CONF_TARGET_BOOT_STACK_SIZE rather than
MBED_BOOT_STACK_SIZE.
Fixes#10319
Previously we get the common erase size of the whole flash, which
may or may not exists if there are multiple regions. In this case
the size returned is zero and the test fails.
Fix this by allocating read and write buffers that are large enough
for all sectors. The test itself already supports non-uniform
erase sizes, and the erase size at any address can be smaller
than our buffers.
The test case only uses one specific sector, but the erase size
is obtained for the whole block device instead. This doesn't work
if different regions of the flash don't have a common erase size.
Fix the issue by getting the erase size at the address we use.
The first revision (1.0) of SFDP (ref: JESD216) does not include
fields for software reset support. It's only been added in the
second revision (1.5) (ref: JESD216A).
Some Mbed OS targets such as DISCO_F746NG include flashes with
legacy SFDP, thus we add an option to preset the reset mode.