Skip to content

nRF52840_DK: "qspi_api.c" check read/write WORD alignment, set clock frequency divider #8832

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 20, 2018

Conversation

j3hill
Copy link
Contributor

@j3hill j3hill commented Nov 21, 2018

Description

In "targets\TARGET_NORDIC\TARGET_NRF5x\qspi_hal.c", add logic to make sure that Read/Write commands are WORD (4 bytes) aligned. If they are not aligned, return QSPI_STATUS_INVALID_PARAMETER. Remove incorrect MBED_HAL_QSPI_HZ_TO_CONFIG macro, and replace with a new private helper function that sets the closest available nRF clock frequency divider for the requested QSPI clock frequency (up to 32 MHz).

Pull request type

[X ] Fix
[ ] Refactor
[ ] Target update
[ ] Functionality change
[ ] Docs update
[ ] Test update
[ ] Breaking change

@j3hill
Copy link
Contributor Author

j3hill commented Nov 21, 2018

Results from mbed greentea "tests-mbed_hal-qspi":

mbedgt: greentea test automation tool ver. 1.4.0
mbedgt: using multiple test specifications from current directory!
using 'BUILD\tests\NRF52840_DK\ARM\test_spec.json'
mbedgt: detecting connected mbed-enabled devices...
mbedgt: detected 1 device
mbedgt: processing target 'NRF52840_DK' toolchain 'ARM' compatible platforms... (note: switch set to --parallel 1)
mbedgt: running 1 test for platform 'NRF52840_DK' and toolchain 'ARM'
mbedgt: mbed-host-test-runner: started
mbedgt: checking for GCOV data...
mbedgt: test on hardware with target id: 1102000044203120484d3943323038313430303297969903
mbedgt: test suite 'tests-mbed_hal-qspi' ............................................................. OK in 52.50 sec
test case: 'qspi frequency setting test' ..................................................... OK in 0.38 sec
test case: 'qspi init/free test' ............................................................. OK in 0.13 sec
test case: 'qspi memory id test' ............................................................. OK in 0.09 sec
test case: 'qspi write(1-1-1)/x1 read(1-1-1)/x1 repeat/x1 test' ........................... OK in 0.14 sec
test case: 'qspi write(1-1-1)/x1 read(1-1-1)/x1 repeat/x4 test' ........................... OK in 0.27 sec
test case: 'qspi write(1-1-1)/x1 read(1-1-1)/x4 repeat/x1 test' ........................... OK in 0.13 sec
test case: 'qspi write(1-1-1)/x1 read(1-1-2)/x1 repeat/x1 test' ........................... OK in 0.15 sec
test case: 'qspi write(1-1-1)/x1 read(1-1-2)/x1 repeat/x4 test' ........................... OK in 0.31 sec
test case: 'qspi write(1-1-1)/x1 read(1-1-2)/x4 repeat/x1 test' ........................... OK in 0.13 sec
test case: 'qspi write(1-1-1)/x1 read(1-1-4)/x1 repeat/x1 test' ........................... OK in 0.13 sec
test case: 'qspi write(1-1-1)/x1 read(1-1-4)/x1 repeat/x4 test' ........................... OK in 0.30 sec
test case: 'qspi write(1-1-1)/x1 read(1-1-4)/x4 repeat/x1 test' ........................... OK in 0.13 sec
test case: 'qspi write(1-1-1)/x1 read(1-2-2)/x1 repeat/x1 test' ........................... OK in 0.14 sec
test case: 'qspi write(1-1-1)/x1 read(1-2-2)/x1 repeat/x4 test' ........................... OK in 0.29 sec
test case: 'qspi write(1-1-1)/x1 read(1-2-2)/x4 repeat/x1 test' ........................... OK in 0.14 sec
test case: 'qspi write(1-1-1)/x1 read(1-4-4)/x1 repeat/x1 test' ........................... OK in 0.14 sec
test case: 'qspi write(1-1-1)/x1 read(1-4-4)/x1 repeat/x4 test' ........................... OK in 0.30 sec
test case: 'qspi write(1-1-1)/x1 read(1-4-4)/x4 repeat/x1 test' ........................... OK in 0.14 sec
test case: 'qspi write(1-1-1)/x4 read(1-1-1)/x1 repeat/x1 test' ........................... OK in 0.14 sec
test case: 'qspi write(1-1-1)/x4 read(1-1-2)/x1 repeat/x1 test' ........................... OK in 0.14 sec
test case: 'qspi write(1-1-1)/x4 read(1-1-4)/x1 repeat/x1 test' ........................... OK in 0.14 sec
test case: 'qspi write(1-1-1)/x4 read(1-2-2)/x1 repeat/x1 test' ........................... OK in 0.13 sec
test case: 'qspi write(1-1-1)/x4 read(1-4-4)/x1 repeat/x1 test' ........................... OK in 0.14 sec
test case: 'qspi write(1-4-4)/x1 read(1-1-1)/x1 repeat/x1 test' ........................... OK in 0.12 sec
test case: 'qspi write(1-4-4)/x1 read(1-1-1)/x1 repeat/x4 test' ........................... OK in 0.30 sec
test case: 'qspi write(1-4-4)/x1 read(1-1-1)/x4 repeat/x1 test' ........................... OK in 0.14 sec
test case: 'qspi write(1-4-4)/x1 read(1-1-2)/x1 repeat/x1 test' ........................... OK in 0.14 sec
test case: 'qspi write(1-4-4)/x1 read(1-1-2)/x1 repeat/x4 test' ........................... OK in 0.34 sec
test case: 'qspi write(1-4-4)/x1 read(1-1-2)/x4 repeat/x1 test' ........................... OK in 0.15 sec
test case: 'qspi write(1-4-4)/x1 read(1-1-4)/x1 repeat/x1 test' ........................... OK in 0.15 sec
test case: 'qspi write(1-4-4)/x1 read(1-1-4)/x1 repeat/x4 test' ........................... OK in 0.33 sec
test case: 'qspi write(1-4-4)/x1 read(1-1-4)/x4 repeat/x1 test' ........................... OK in 0.14 sec
test case: 'qspi write(1-4-4)/x1 read(1-2-2)/x1 repeat/x1 test' ........................... OK in 0.14 sec
test case: 'qspi write(1-4-4)/x1 read(1-2-2)/x1 repeat/x4 test' ........................... OK in 0.33 sec
test case: 'qspi write(1-4-4)/x1 read(1-2-2)/x4 repeat/x1 test' ........................... OK in 0.15 sec
test case: 'qspi write(1-4-4)/x1 read(1-4-4)/x1 repeat/x1 test' ........................... OK in 0.14 sec
test case: 'qspi write(1-4-4)/x1 read(1-4-4)/x1 repeat/x4 test' ........................... OK in 0.32 sec
test case: 'qspi write(1-4-4)/x1 read(1-4-4)/x4 repeat/x1 test' ........................... OK in 0.15 sec
test case: 'qspi write(1-4-4)/x4 read(1-1-1)/x1 repeat/x1 test' ........................... OK in 0.13 sec
test case: 'qspi write(1-4-4)/x4 read(1-1-2)/x1 repeat/x1 test' ........................... OK in 0.14 sec
test case: 'qspi write(1-4-4)/x4 read(1-1-4)/x1 repeat/x1 test' ........................... OK in 0.15 sec
test case: 'qspi write(1-4-4)/x4 read(1-2-2)/x1 repeat/x1 test' ........................... OK in 0.15 sec
test case: 'qspi write(1-4-4)/x4 read(1-4-4)/x1 repeat/x1 test' ........................... OK in 0.15 sec
mbedgt: test case summary: 43 passes, 0 failures
mbedgt: all tests finished!
mbedgt: shuffle seed: 0.5911968729
mbedgt: test suite report:
+-----------------+---------------+---------------------+--------+--------------------+-------------+
| target | platform_name | test suite | result | elapsed_time (sec) | copy_method |
+-----------------+---------------+---------------------+--------+--------------------+-------------+
| NRF52840_DK-ARM | NRF52840_DK | tests-mbed_hal-qspi | OK | 52.5 | default |
+-----------------+---------------+---------------------+--------+--------------------+-------------+
mbedgt: test suite results: 1 OK
mbedgt: test case report:
+-----------------+---------------+---------------------+-------------------------------------------------------+--------+--------+--------+--------------------+
| target | platform_name | test suite | test case | passed | failed | result | elapsed_time (sec) |
+-----------------+---------------+---------------------+-------------------------------------------------------+--------+--------+--------+--------------------+
| NRF52840_DK-ARM | NRF52840_DK | tests-mbed_hal-qspi | qspi frequency setting test | 1 | 0 | OK | 0.38 |
| NRF52840_DK-ARM | NRF52840_DK | tests-mbed_hal-qspi | qspi init/free test | 1 | 0 | OK | 0.13 |
| NRF52840_DK-ARM | NRF52840_DK | tests-mbed_hal-qspi | qspi memory id test | 1 | 0 | OK | 0.09 |
| NRF52840_DK-ARM | NRF52840_DK | tests-mbed_hal-qspi | qspi write(1-1-1)/x1 read(1-1-1)/x1 repeat/x1 test | 1 | 0 | OK | 0.14 |
| NRF52840_DK-ARM | NRF52840_DK | tests-mbed_hal-qspi | qspi write(1-1-1)/x1 read(1-1-1)/x1 repeat/x4 test | 1 | 0 | OK | 0.27 |
| NRF52840_DK-ARM | NRF52840_DK | tests-mbed_hal-qspi | qspi write(1-1-1)/x1 read(1-1-1)/x4 repeat/x1 test | 1 | 0 | OK | 0.13 |
| NRF52840_DK-ARM | NRF52840_DK | tests-mbed_hal-qspi | qspi write(1-1-1)/x1 read(1-1-2)/x1 repeat/x1 test | 1 | 0 | OK | 0.15 |
| NRF52840_DK-ARM | NRF52840_DK | tests-mbed_hal-qspi | qspi write(1-1-1)/x1 read(1-1-2)/x1 repeat/x4 test | 1 | 0 | OK | 0.31 |
| NRF52840_DK-ARM | NRF52840_DK | tests-mbed_hal-qspi | qspi write(1-1-1)/x1 read(1-1-2)/x4 repeat/x1 test | 1 | 0 | OK | 0.13 |
| NRF52840_DK-ARM | NRF52840_DK | tests-mbed_hal-qspi | qspi write(1-1-1)/x1 read(1-1-4)/x1 repeat/x1 test | 1 | 0 | OK | 0.13 |
| NRF52840_DK-ARM | NRF52840_DK | tests-mbed_hal-qspi | qspi write(1-1-1)/x1 read(1-1-4)/x1 repeat/x4 test | 1 | 0 | OK | 0.3 |
| NRF52840_DK-ARM | NRF52840_DK | tests-mbed_hal-qspi | qspi write(1-1-1)/x1 read(1-1-4)/x4 repeat/x1 test | 1 | 0 | OK | 0.13 |
| NRF52840_DK-ARM | NRF52840_DK | tests-mbed_hal-qspi | qspi write(1-1-1)/x1 read(1-2-2)/x1 repeat/x1 test | 1 | 0 | OK | 0.14 |
| NRF52840_DK-ARM | NRF52840_DK | tests-mbed_hal-qspi | qspi write(1-1-1)/x1 read(1-2-2)/x1 repeat/x4 test | 1 | 0 | OK | 0.29 |
| NRF52840_DK-ARM | NRF52840_DK | tests-mbed_hal-qspi | qspi write(1-1-1)/x1 read(1-2-2)/x4 repeat/x1 test | 1 | 0 | OK | 0.14 |
| NRF52840_DK-ARM | NRF52840_DK | tests-mbed_hal-qspi | qspi write(1-1-1)/x1 read(1-4-4)/x1 repeat/x1 test | 1 | 0 | OK | 0.14 |
| NRF52840_DK-ARM | NRF52840_DK | tests-mbed_hal-qspi | qspi write(1-1-1)/x1 read(1-4-4)/x1 repeat/x4 test | 1 | 0 | OK | 0.3 |
| NRF52840_DK-ARM | NRF52840_DK | tests-mbed_hal-qspi | qspi write(1-1-1)/x1 read(1-4-4)/x4 repeat/x1 test | 1 | 0 | OK | 0.14 |
| NRF52840_DK-ARM | NRF52840_DK | tests-mbed_hal-qspi | qspi write(1-1-1)/x4 read(1-1-1)/x1 repeat/x1 test | 1 | 0 | OK | 0.14 |
| NRF52840_DK-ARM | NRF52840_DK | tests-mbed_hal-qspi | qspi write(1-1-1)/x4 read(1-1-2)/x1 repeat/x1 test | 1 | 0 | OK | 0.14 |
| NRF52840_DK-ARM | NRF52840_DK | tests-mbed_hal-qspi | qspi write(1-1-1)/x4 read(1-1-4)/x1 repeat/x1 test | 1 | 0 | OK | 0.14 |
| NRF52840_DK-ARM | NRF52840_DK | tests-mbed_hal-qspi | qspi write(1-1-1)/x4 read(1-2-2)/x1 repeat/x1 test | 1 | 0 | OK | 0.13 |
| NRF52840_DK-ARM | NRF52840_DK | tests-mbed_hal-qspi | qspi write(1-1-1)/x4 read(1-4-4)/x1 repeat/x1 test | 1 | 0 | OK | 0.14 |
| NRF52840_DK-ARM | NRF52840_DK | tests-mbed_hal-qspi | qspi write(1-4-4)/x1 read(1-1-1)/x1 repeat/x1 test | 1 | 0 | OK | 0.12 |
| NRF52840_DK-ARM | NRF52840_DK | tests-mbed_hal-qspi | qspi write(1-4-4)/x1 read(1-1-1)/x1 repeat/x4 test | 1 | 0 | OK | 0.3 |
| NRF52840_DK-ARM | NRF52840_DK | tests-mbed_hal-qspi | qspi write(1-4-4)/x1 read(1-1-1)/x4 repeat/x1 test | 1 | 0 | OK | 0.14 |
| NRF52840_DK-ARM | NRF52840_DK | tests-mbed_hal-qspi | qspi write(1-4-4)/x1 read(1-1-2)/x1 repeat/x1 test | 1 | 0 | OK | 0.14 |
| NRF52840_DK-ARM | NRF52840_DK | tests-mbed_hal-qspi | qspi write(1-4-4)/x1 read(1-1-2)/x1 repeat/x4 test | 1 | 0 | OK | 0.34 |
| NRF52840_DK-ARM | NRF52840_DK | tests-mbed_hal-qspi | qspi write(1-4-4)/x1 read(1-1-2)/x4 repeat/x1 test | 1 | 0 | OK | 0.15 |
| NRF52840_DK-ARM | NRF52840_DK | tests-mbed_hal-qspi | qspi write(1-4-4)/x1 read(1-1-4)/x1 repeat/x1 test | 1 | 0 | OK | 0.15 |
| NRF52840_DK-ARM | NRF52840_DK | tests-mbed_hal-qspi | qspi write(1-4-4)/x1 read(1-1-4)/x1 repeat/x4 test | 1 | 0 | OK | 0.33 |
| NRF52840_DK-ARM | NRF52840_DK | tests-mbed_hal-qspi | qspi write(1-4-4)/x1 read(1-1-4)/x4 repeat/x1 test | 1 | 0 | OK | 0.14 |
| NRF52840_DK-ARM | NRF52840_DK | tests-mbed_hal-qspi | qspi write(1-4-4)/x1 read(1-2-2)/x1 repeat/x1 test | 1 | 0 | OK | 0.14 |
| NRF52840_DK-ARM | NRF52840_DK | tests-mbed_hal-qspi | qspi write(1-4-4)/x1 read(1-2-2)/x1 repeat/x4 test | 1 | 0 | OK | 0.33 |
| NRF52840_DK-ARM | NRF52840_DK | tests-mbed_hal-qspi | qspi write(1-4-4)/x1 read(1-2-2)/x4 repeat/x1 test | 1 | 0 | OK | 0.15 |
| NRF52840_DK-ARM | NRF52840_DK | tests-mbed_hal-qspi | qspi write(1-4-4)/x1 read(1-4-4)/x1 repeat/x1 test | 1 | 0 | OK | 0.14 |
| NRF52840_DK-ARM | NRF52840_DK | tests-mbed_hal-qspi | qspi write(1-4-4)/x1 read(1-4-4)/x1 repeat/x4 test | 1 | 0 | OK | 0.32 |
| NRF52840_DK-ARM | NRF52840_DK | tests-mbed_hal-qspi | qspi write(1-4-4)/x1 read(1-4-4)/x4 repeat/x1 test | 1 | 0 | OK | 0.15 |
| NRF52840_DK-ARM | NRF52840_DK | tests-mbed_hal-qspi | qspi write(1-4-4)/x4 read(1-1-1)/x1 repeat/x1 test | 1 | 0 | OK | 0.13 |
| NRF52840_DK-ARM | NRF52840_DK | tests-mbed_hal-qspi | qspi write(1-4-4)/x4 read(1-1-2)/x1 repeat/x1 test | 1 | 0 | OK | 0.14 |
| NRF52840_DK-ARM | NRF52840_DK | tests-mbed_hal-qspi | qspi write(1-4-4)/x4 read(1-1-4)/x1 repeat/x1 test | 1 | 0 | OK | 0.15 |
| NRF52840_DK-ARM | NRF52840_DK | tests-mbed_hal-qspi | qspi write(1-4-4)/x4 read(1-2-2)/x1 repeat/x1 test | 1 | 0 | OK | 0.15 |
| NRF52840_DK-ARM | NRF52840_DK | tests-mbed_hal-qspi | qspi write(1-4-4)/x4 read(1-4-4)/x1 repeat/x1 test | 1 | 0 | OK | 0.15 |
+-----------------+---------------+---------------------+-------------------------------------------------------+--------+--------+--------+--------------------+
mbedgt: test case results: 43 OK
mbedgt: completed in 53.33 sec

@SenRamakri SenRamakri requested review from a team and 0xc0170 November 21, 2018 20:39

// Convert hz to closest NRF frequency divider
if (hz > 16000000)
freq = NRF_QSPI_FREQ_32MDIV1; // 32 MHz
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be safer to round down instead of up.


config.pins.sck_pin = (uint32_t)sclk;
config.pins.sck_pin = (uint32_t)sclk;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not introduce new spaces (if possible set your editor to do this for you on lines you edit)


// use sync version, no handler
(void)(obj);
if (hz > MBED_HAL_QSPI_MAX_FREQ)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use alignment that is already in the code

@@ -247,6 +251,11 @@ qspi_status_t qspi_frequency(qspi_t *obj, int hz)

qspi_status_t qspi_write(qspi_t *obj, const qspi_command_t *command, const void *data, size_t *length)
{
// length needs to be rounded up to the next WORD (4 bytes)
if ((*length & WORD_MASK) > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does the transfer size need to be 4 byte aligned? I don't see this as a requirement in the documentation qspi_api.h.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns out this is a limitation of the NRF52. Thanks for updating the documentation @j3hill

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. This is a Nordic requirement. In the nRF52840 product specification document (https://infocenter.nordicsemi.com/pdf/nRF52840_OPS_v0.5.pdf ) it states that for qspi read and write operations: "The length must be a multiple of 4 bytes." To help make this clear going forward, I've updated the length comments in "qspi_api.h" to note that support for non 4-byte (WORD) aligned reads/writes is implementation defined.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@j3hill - I do not understand the comment: "support for non 4-byte (WORD) aligned reads/writes is implementation defined". 4-bytes alignment is Nordic limitation. Other targets might have other limitations.
Currently qspi_hal has no limitation on read/write granularity - so minimal size is 1byte.
The way I understand it the remark should be something like: "support for any specific target alignment requirement is - target implementation defined"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont not understand neither rereading this thread. Similar limitations we have in flashing. How do we cover it there? via get_program_page_size() ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@donatieng , @0xc0170 - if you're referring to FalshIAP, it is covered by a hal API flash_get_page_size() which is implemented in each target, and surface its requirement to the driver FlashIAP. The FlashIAP driver then handles the program address alignment and granularity requirements with its own internal buffer.

Driver:


_uint32_t FlashIAP::get_page_size() const
{
return flash_get_page_size(&flash);
}

HAL:


_/** Get page size
*

  • The page size defines the writable page size
  • @param obj The flash object
  • @return The size of a page
    */
    uint32_t flash_get_page_size(const flash_t *obj);_

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@offirko you are referring to the internal flash. The external QSPI flash blockdevice is defined here: https://github.com/ARMmbed/mbed-os/blob/master/components/storage/blockdevice/COMPONENT_QSPIF/QSPIFBlockDevice.cpp#L468-L472

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marcuschangarm - I know.

I was simply showing @0xc0170 and @donatieng that in FlashIAP the driver handles alignment and write-granularity using its own internal buffer, and based on page_size upstreamed from hal .
My original suggestion was to do the same for QSPI

@j3hill j3hill force-pushed the nRF52840_QSPI branch 2 times, most recently from d378141 to c7df6c7 Compare November 27, 2018 16:02
0xc0170
0xc0170 previously approved these changes Nov 28, 2018
Copy link
Contributor

@0xc0170 0xc0170 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maciejbocianski Can you review additions to the qspi_api.h ?

@maciejbocianski
Copy link
Contributor

Generally looks OK, but found this in QSPIBlockDevice

bd_size_t QSPIFBlockDevice::get_read_size() const
{
// Assuming all devices support 1byte read granularity
return QSPIF_DEFAULT_READ_SIZE;
}
bd_size_t QSPIFBlockDevice::get_program_size() const
{
// Assuming all devices support 1byte program granularity
return QSPIF_DEFAULT_PROG_SIZE;

@offirko can you check whether this 4B read/program size alignment should be taken into account in QSPIFBlockDevice layer

Copy link
Contributor

@offirko offirko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maciejbocianski - FileSystem is relying on 'QSPIFBlockDevice::get_program_size()' to align or buffer its data if required - so indeed it should be taken into account in QSPIFBlockDevice.
The problem is that QSPIFBlockDevice is an SFDP standard BlockDevice and SFDP standard defines write granularity 1byte. In order for specific targets to expose their special non-standard requirement, the information should surface from HAL to QSPI Driver and to QSPIF BD. We need to add such an API both to qspi_hal and to qspi driver.

@@ -247,6 +251,11 @@ qspi_status_t qspi_frequency(qspi_t *obj, int hz)

qspi_status_t qspi_write(qspi_t *obj, const qspi_command_t *command, const void *data, size_t *length)
{
// length needs to be rounded up to the next WORD (4 bytes)
if ((*length & WORD_MASK) > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@j3hill - I do not understand the comment: "support for non 4-byte (WORD) aligned reads/writes is implementation defined". 4-bytes alignment is Nordic limitation. Other targets might have other limitations.
Currently qspi_hal has no limitation on read/write granularity - so minimal size is 1byte.
The way I understand it the remark should be something like: "support for any specific target alignment requirement is - target implementation defined"

@donatieng
Copy link
Contributor

donatieng commented Nov 29, 2018

Maybe my understanding is extremely naïve, but instead of defining a new HAL API or limitations to address the quirks of one platform can we just pad any unaligned accesses on this platform with 0xFF (which would result in a no-op as we're dealing with NOR flash)?

@maciejbocianski
Copy link
Contributor

But this approach will require data replication to internal aligned buffer what is not good idea.

@offirko
Copy link
Contributor

offirko commented Nov 29, 2018

@donatieng - This solution can be a valid one, considering the extra replication that @maciejbocianski mentioned.
But, you wrote: "..can we just pad any unaligned accesses on this platform.."
Are you referring to a solution for the specific platform hal implementation?
If so, my assumption was that the specific platform can not resolve its own quirk..otherwise it wouldn't have raised it as a restriction.

If you're referring to a solution in higher level (driver/blockdevice) then we still need the hal API to know if the quirk of the platform is 4-bytes alignment or more..

@0xc0170 0xc0170 dismissed their stale review November 30, 2018 14:00

Not convinced about the note in the docs (non 4 byte alignment )

@donatieng
Copy link
Contributor

donatieng commented Nov 30, 2018

We'll always find platforms with some specific quirks. Question is: how many other platforms have this specific requirement?

I've just checked the datasheet + driver and memory for reads and writes must be aligned in the QSPI Flash and RAM. So in addition to padding we also need to potentially move the memory in RAM to make it aligned. I'm uncomfortable with "upstreaming" that as a requirement for the HAL.

Copy link
Contributor

@donatieng donatieng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This implementation won't work as it is now

@elm3
Copy link

elm3 commented Dec 6, 2018

I want to jump in here and try to get this back on track. This PR is just about getting the QSPI working on the Nordic platform. This Nordic platform does not support transfers that are not 32-bit aligned and sized. So in this case, the new functionality returns the appropriate error.

I don't want to dismiss the effort to understand what the implications around the block driver and what this does to that subsystem, but that is not the intent of the PR. I think the architectural discussions around the QSPI block device work SHOULD happen, but I don't think we should hold these fixed up.

@j3hill
Copy link
Contributor Author

j3hill commented Dec 11, 2018

I have updated the "hal/qspi_api.h" comments as requested. This PR is now ready for approval.

Copy link
Contributor

@offirko offirko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@donatieng
Copy link
Contributor

Hey @j3hill I don't see the workarounds for alignment in targets\TARGET_NORDIC\TARGET_NRF5x\qspi_hal.c`?

@j3hill j3hill dismissed donatieng’s stale review December 14, 2018 15:24

We are not implementing alignment fixes in this PR, we are just returning an error if reads/writes are less than 4 bytes.

clock frequency divider

These changes are to enable QSPI functioanlity
for the NRF52840DK.
@j3hill
Copy link
Contributor Author

j3hill commented Dec 18, 2018

@donatieng The changes to the comments in "hal\qspi_api.h" have been removed, as requested.

@0xc0170
Copy link
Contributor

0xc0170 commented Dec 19, 2018

@donatieng Happy with the current state here?

@cmonr
Copy link
Contributor

cmonr commented Dec 19, 2018

CI started

@mbed-ci
Copy link

mbed-ci commented Dec 19, 2018

Test run: SUCCESS

Summary: 11 of 11 test jobs passed
Build number : 1
Build artifacts

@0xc0170 0xc0170 merged commit 3a2f6e9 into ARMmbed:master Dec 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants