Skip to content

hal-qspi test #7325

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 8 commits into from
Jul 18, 2018
Merged

hal-qspi test #7325

merged 8 commits into from
Jul 18, 2018

Conversation

maciejbocianski
Copy link
Contributor

@maciejbocianski maciejbocianski commented Jun 26, 2018

Description

This PR adds:

  • QSPI hal test
  • temporary fix for qspi_free return value for STM QSPI implementation
  • qspi pin names for DISCO_L475VG_IOT01A target
  • fix for QSPI custom command sending for NRF target
  • fix for qspi R/W opcodes mapping for NRF target

Supported targets: DISCO_L475VG_IOT01A, NRF52840_DK

Known issues:

  • STM: lack of qspi_free implementation
  • STM: bug with to early write finish indication on DISCO_L475VG_IOT01A target (for more details see STM_DISCO_L475VG_IOT01A_WRITE_4IO_BUG_WORKAROUND)
  • STM: HAL_QSPI_Init is failing on ARM compiler with HAL_BUSY error
  • STM: malloc is failing on DISCO_L475VG_IOT01A target on GCC (every dynamic memory allocation returns NULL)

Pull request type

[ ] Fix
[ ] Refactor
[ ] New target
[X] Feature
[ ] Breaking change

@0xc0170 0xc0170 requested a review from SenRamakri June 26, 2018 08:53
@cmonr cmonr requested a review from kegilbert June 27, 2018 02:08
@bulislaw bulislaw requested review from jamesbeyond and offirko June 27, 2018 08:34
@@ -192,7 +192,8 @@ qspi_status_t qspi_init(qspi_t *obj, PinName io0, PinName io1, PinName io2, PinN
qspi_status_t qspi_free(qspi_t *obj)
{
// TODO
return QSPI_STATUS_ERROR;
//return QSPI_STATUS_ERROR;
return QSPI_STATUS_OK;
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the reason, this function can't be fully implemented but required a temperate fix?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's temporary fix. It should be implemented

@adustm Please review

{
uint8_t reg_data[QSPI_STATUS_REGISTER_SIZE];

reg_data[0] = STATUS_BIT_QE;
Copy link
Contributor

Choose a reason for hiding this comment

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

SFDP standard defines Quad Enable procedure depending on QER bits value.
This procedure of matches QER setup 010b where QE is bit 6 of status register.
Do we require a more general approach that handles Quad Enable for all QER value scenarios?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, could be done in next step.
But not sure if we really need such flexibility as SFDP provides in test layer.
The idea of QSPI tests was to check basic features, common for all targets/memory chips,
just to be sure that HAL API implementations works
@0xc0170 @SenRamakri

Copy link
Contributor

Choose a reason for hiding this comment

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

@offirko This is utils functions for the driver test that has no SFDP knowledge. SFDP will be part of the device block driver (tested there). What would you suggest here?

Copy link
Contributor

Choose a reason for hiding this comment

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

AFAIU (regardless of SFDP), QE bit is frequently bit number 6 of Status Register - but not for all devices. 'quad_enable' will pass successfully because it verifies that bit 6 value has changed, but if further tests expect that quad_enable will enable QPI or FAST Quad mode they might fail for certain devices. We can perhaps start with this hard coded value and later on move to it to per-target configuration if required.

return ((reg[0] & STATUS_BIT_WEL) == 0 ? QSPI_STATUS_OK : QSPI_STATUS_ERROR);
}

WEAK void log_security_register(Qspi &qspi)
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the purpose of these log_xx_register functions? Why are they weak? Usually we don't have to print lot of data from tests, may be you need to confine them to debug builds only.

Copy link
Contributor Author

@maciejbocianski maciejbocianski Jun 28, 2018

Choose a reason for hiding this comment

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

Yes, it was for debugging purpose, I'll remove it.
All weak function can be overridden if specific target require different handling

@maciejbocianski maciejbocianski force-pushed the qspi_tests branch 2 times, most recently from c11c8f8 to c9b3b45 Compare June 29, 2018 15:51
@maciejbocianski
Copy link
Contributor Author

maciejbocianski commented Jun 29, 2018

PR has been rebased and updated:

  • log_xx_register functions removed

@cmonr
Copy link
Contributor

cmonr commented Jun 30, 2018

If all of the reviewers could re-review:
@0xc0170 @SenRamakri @jamesbeyond @offirko @kegilbert

@maciejbocianski
Copy link
Contributor Author

Test code was updated. Changes was introduced as background for new memory chips support.
Please review again @0xc0170 @SenRamakri @jamesbeyond @offirko @kegilbert

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.

Is there a 4_4_4 QPI read mode test?
Thanks

{
uint8_t reg_data[QSPI_STATUS_REGISTER_SIZE];

reg_data[0] = STATUS_BIT_QE;
Copy link
Contributor

Choose a reason for hiding this comment

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

AFAIU (regardless of SFDP), QE bit is frequently bit number 6 of Status Register - but not for all devices. 'quad_enable' will pass successfully because it verifies that bit 6 value has changed, but if further tests expect that quad_enable will enable QPI or FAST Quad mode they might fail for certain devices. We can perhaps start with this hard coded value and later on move to it to per-target configuration if required.

@maciejbocianski
Copy link
Contributor Author

maciejbocianski commented Jul 5, 2018

@offirko
Currently 4_4_4 is not supported, but the test will evolve as new targets/flash chips support will be added, so there is no problem to add it in future when we will have stable version of test.

BTW adding new configs is very easy since everything is parameterized

@maciejbocianski
Copy link
Contributor Author

@offirko
It has been already done (see a3f76bc) all per-target configuration like: quad_enable, quad_disable, dual_enable, dual_disable, fast_mode_enable was moved to memory config files

@jamesbeyond
Copy link
Contributor

Can we have CI on this one, please ? @cmonr

@cmonr
Copy link
Contributor

cmonr commented Jul 5, 2018

/morph build

@mbed-ci
Copy link

mbed-ci commented Jul 5, 2018

Build : ABORTED

Build number : 2535
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/7325/

@cmonr
Copy link
Contributor

cmonr commented Jul 5, 2018

Trying that again.
/morph build

@mbed-ci
Copy link

mbed-ci commented Jul 5, 2018

Build : FAILURE

Build number : 2541
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/7325/

@maciejbocianski
Copy link
Contributor Author

maciejbocianski commented Jul 6, 2018

Test failed on some QSPI targets since only selected QSPI enabled targets support QSPI test.
Additional preprocessor guard has been added

@maciejbocianski
Copy link
Contributor Author

@cmonr @0xc0170 @adbridge
morph can be re-triggered

@maciejbocianski
Copy link
Contributor Author

feature-qspi branch ant this PR have been rebased

@0xc0170
Copy link
Contributor

0xc0170 commented Jul 17, 2018

/morph build

@adustm
Copy link
Member

adustm commented Jul 17, 2018

Hello @maciejbocianski
Could you give me more details about the failure in case you remove the STM_WRITE_4IO_BUG_WORKAROUND ?
I don't see the difference with and without it.
Kind regards

@cmonr
Copy link
Contributor

cmonr commented Jul 17, 2018

/morph build

@mbed-ci
Copy link

mbed-ci commented Jul 17, 2018

Build : ABORTED

Build number : 2624
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/7325/

@cmonr
Copy link
Contributor

cmonr commented Jul 17, 2018

Not sure why this ended up timing out, but please take a look at the build errors.

QSPI feature was mistakenly moved form target nrf52840 to nrf52832
while rebasing. This change fixes it
@maciejbocianski
Copy link
Contributor Author

There was mistake while rebasing. QSPI flag was mistakenly moved from nrf52840 to 'nrf52832` config.
Thus all nrf52832 based targets builds failed.
Fix was added: af90f2c

@cmonr
Copy link
Contributor

cmonr commented Jul 18, 2018

@maciejbocianski Been there. It happens.

/morpg build

@cmonr
Copy link
Contributor

cmonr commented Jul 18, 2018

/morph build

@mbed-ci
Copy link

mbed-ci commented Jul 18, 2018

Build : SUCCESS

Build number : 2627
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/7325/

Triggering tests

/morph test
/morph uvisor-test
/morph export-build
/morph mbed2-build

@mbed-ci
Copy link

mbed-ci commented Jul 18, 2018

@mbed-ci
Copy link

mbed-ci commented Jul 18, 2018

@cmonr cmonr merged commit 0715a46 into ARMmbed:feature-qspi Jul 18, 2018
@maciejbocianski
Copy link
Contributor Author

@adustm
after rebasing feature_qspi branch to master, problems with malloc and with write delay seems to be not present anymore

@adustm
Copy link
Member

adustm commented Jul 24, 2018

great news. The only remaining problem I can see is the ARM toolchain

---------------------+---------------------+-------------------------------------------------------+--------+--------+---------+--------------------+
 platform_name       | test suite          | test case                                             | passed | failed | result  | elapsed_time (sec) |
---------------------+---------------------+-------------------------------------------------------+--------+--------+---------+--------------------+
 DISCO_L475VG_IOT01A | tests-mbed_hal-qspi | qspi frequency setting test                           | 0      | 0      | SKIPPED | 0.0                |
 DISCO_L475VG_IOT01A | tests-mbed_hal-qspi | qspi init/free test                                   | 0      | 1      | FAIL    | 0.08               |
 DISCO_L475VG_IOT01A | tests-mbed_hal-qspi | qspi memory id test                                   | 1      | 0      | OK      | 0.1                |
 DISCO_L475VG_IOT01A | tests-mbed_hal-qspi | qspi write(1-1-1)/x1  read(1-1-1)/x1  repeat/x1  test | 0      | 0      | SKIPPED | 0.0                |

I can't find the fix for that at the moment (the issue disappears when opened with a debugger)

@maciejbocianski
Copy link
Contributor Author

On my side problem with ARM compiler also disappeared (after update to master)

@adustm
Copy link
Member

adustm commented Jul 24, 2018

On my side problem with ARM compiler also disappeared (after update to master)
@maciejbocianski did you rebase again or are you using feature-qspi branch that was rebased a few days ago ?

@maciejbocianski
Copy link
Contributor Author

@adustm there was only one rebase a few days ago, and I'm using it (pure https://github.com/ARMmbed/mbed-os/tree/feature-qspi plus yours PR #7581)

@adustm
Copy link
Member

adustm commented Jul 24, 2018

Hello,
I'm using the same version as you. It's a matter of chance that yours is working.
I've found the bug.
qspi object is a local variable in qspi_init_free_test function (then located in the stack that contains whatever values).
2 variables in qspi struct shall be initalized before the call to HAL_QSPI_Init function, inside qspi_init function. Otherwise you can be blocked at HAL_LOCK(hqspi) in stm32l4xx_hal_qspi.c, line 276
which was my case

 qspi_status_t qspi_init(qspi_t *obj, PinName io0, PinName io1, PinName io2, PinName io3, PinName sclk, PinName ssel, uint32_t hz, uint8_t mode)
 {
     // Enable interface clock for QSPI
      __HAL_RCC_QSPI_CLK_ENABLE();
 
     // Reset QSPI
     __HAL_RCC_QSPI_FORCE_RESET();
     __HAL_RCC_QSPI_RELEASE_RESET();
 
+    // Reset handle internal state
+    obj->handle.State = HAL_QSPI_STATE_RESET;
+    obj->handle.Lock = HAL_UNLOCKED;
+

PR#7586 has just arrived ;)

Kind regards
Armelle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants