Skip to content
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

QSPI : Define default pins at drivers level #11444

Merged
merged 5 commits into from
Oct 21, 2019

Conversation

jeromecoutant
Copy link
Collaborator

@jeromecoutant jeromecoutant commented Sep 9, 2019

Description

I had to make some tests with an existing MBED target and an external QSPI,
and it was not so easy, many patches were needed in several part.

This proposition is then to be able to make it easier.

QSPI and QSPIF tests are now possible only with mbed_app.json update:

Example:

        "NUCLEO_L4R5ZI": {
            "target.device_has_add": ["QSPI"],
            "target.components": ["QSPIF"],
            "drivers.qspi_io0": "PE_12",
            "drivers.qspi_io1": "PB_0",
            "drivers.qspi_io2": "PE_14",
            "drivers.qspi_io3": "PE_15",
            "drivers.qspi_sck": "PB_10",
            "drivers.qspi_csn": "PA_2",
            "target.extra_labels_add": ["MX25R6435F"]
        }, 

Addition of new board with some already defined QSPI memory is now very easy!

There is no change for existing targets with embedded QSPI.

Pull request type

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

Reviewers

Release Notes

@ciarmcom ciarmcom requested review from a team September 9, 2019 17:00
@ciarmcom
Copy link
Member

ciarmcom commented Sep 9, 2019

@jeromecoutant, thank you for your changes.
@ARMmbed/mbed-os-hal @ARMmbed/mbed-os-core @ARMmbed/mbed-os-test @ARMmbed/mbed-os-storage @ARMmbed/mbed-os-maintainers please review.

@@ -17,6 +17,16 @@
#ifndef MBED_FLASH_CONFIGS_H
#define MBED_FLASH_CONFIGS_H

#define MX25R6435F 1
Copy link
Contributor

Choose a reason for hiding this comment

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

Why this would need to be always enabled?

@@ -12,6 +12,24 @@
"spi_count_max": {
"help": "The maximum number of SPI peripherals used at the same time. Determines RAM allocated for SPI peripheral management. If null, limit determined by hardware.",
"value": null
},
"qspi_io0": {
Copy link
Contributor

Choose a reason for hiding this comment

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

We have QSPI_FLASH1_IO0 and now introducing QSPI_FLASH1_IO0 ?

Why are not these in PinNames and defined for all boards having QSPI? There are QSPI pins or not? They should provide default pins, that could be overriden in tests/apps via config. Is this what is it adding?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Goal is to use an external QSPI,
and add pins value in mbed_app.json file

Copy link
Contributor

Choose a reason for hiding this comment

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

I understand now. This is a new approach here in this drivers config. This brings QSPI definitions even for a board that does not have it. Shouldn' t this be by default null, not even created if not used , and a target would override it and set?

@maciejbocianski what do you think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Goal of this approach is to be full compatible with current implementation.
There is no impact with current targets with and without QSPI pins

Copy link
Contributor

Choose a reason for hiding this comment

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

The only impact having QSPI defined always even if QSPI is not available?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

4 new define added and not used in the mbed_config.h file

#define QPIN_2 static_cast<PinName>(MBED_CONF_DRIVERS_QSPI_IO2)
#define QPIN_3 static_cast<PinName>(MBED_CONF_DRIVERS_QSPI_IO3)
#define QSCK static_cast<PinName>(MBED_CONF_DRIVERS_QSPI_SCK)
#define QCSN static_cast<PinName>(MBED_CONF_DRIVERS_QSPI_CSN)
Copy link
Contributor

Choose a reason for hiding this comment

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

It was designed that tests-mbed_hal-qspi uses default qspi interface available on dev boards.
This should look rather like below to maintain hal test working:

#ifdef MBED_CONF_DRIVERS_QSPI_IO0
#define QPIN_0 static_cast<PinName>(MBED_CONF_DRIVERS_QSPI_IO0)
#else 
#define QPIN_0 static_cast<PinName>(QSPI_FLASH1_IO0)
#endif

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't see the difference as MBED_CONF_DRIVERS_QSPI_IO0 is QSPI_FLASH1_IO0...

@jeromecoutant
Copy link
Collaborator Author

I split the proposition in few commits with more comments in order to be more explicit.

@0xc0170 0xc0170 requested a review from a team September 10, 2019 11:52
@0xc0170
Copy link
Contributor

0xc0170 commented Sep 10, 2019

@ARMmbed/mbed-os-hal Please review if drivers config should be extended to provide QSPI pins.

@maciejbocianski What is the current way to provide these pins, besides defining them in PinNames.h (using on board flash) but what about external flash with our tests?

@adbridge
Copy link
Contributor

@bulislaw @evedon could you please review on behalf of the hal team? (@donatieng fyi)

@adbridge adbridge requested a review from bulislaw September 27, 2019 15:18
@jeromecoutant
Copy link
Collaborator Author

Hi
Some QSPI development are still ongoing. Please merge this PR in order to make mbed easy to use.
Thx
@MarceloSalazar

Copy link
Contributor

@VeijoPesonen VeijoPesonen left a comment

Choose a reason for hiding this comment

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

Looks good to me.

Copy link
Member

@bulislaw bulislaw left a comment

Choose a reason for hiding this comment

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

Hi Jerome, I think I'm missing something. The tests has been updated to use the new config MBED_CONF_DRIVERS_QSPI_XXX, but it's not set by default to anything and the code wasn't change to link the existing (built in QSPI chips) accessible via QSPI_FLASH1_XXX to the new config.

The way users would use the code (not test) doesn't change and it's described here: https://github.com/ARMmbed/mbed-os/blob/master/components/storage/blockdevice/COMPONENT_QSPIF/QSPIFBlockDevice.h#L50 no matter if they use builtin or external chip.

For tests things should still work by default with built in QSPI, but it should be possible to reconfigure to use external, I agree here. What i'm missing is how this change works with default built in memories. So where MBED_CONF_DRIVERS_QSPI_IO0 defaults to QSPI_FLASH1_IO0.

@@ -12,6 +12,24 @@
"spi_count_max": {
"help": "The maximum number of SPI peripherals used at the same time. Determines RAM allocated for SPI peripheral management. If null, limit determined by hardware.",
"value": null
},
"qspi_io0": {
Copy link
Member

Choose a reason for hiding this comment

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

Help text is missing.

@jeromecoutant
Copy link
Collaborator Author

@bulislaw
QSPIF test was updated, QSPI test is still difficult to execute.

@jeromecoutant
Copy link
Collaborator Author

Help added in the json file

Rebase also done

"QSPI_IO3": "QSPI_FLASH1_IO3",
"QSPI_SCK": "QSPI_FLASH1_SCK",
"QSPI_CSN": "QSPI_FLASH1_CSN",
"QSPI_IO0": "MBED_CONF_DRIVERS_QSPI_IO0",
Copy link
Member

Choose a reason for hiding this comment

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

@jeromecoutant what I'm saying is these new configs like MBED_CONF_DRIVERS_QSPI_IO0 are not defined by default as far as i can tell, while the old ones like QSPI_FLASH1_IO0 were defined as part of pinmap. Am I missing something?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

MBED_CONF_DRIVERS_QSPI_IO0 is set by default to QSPI_FLASH1_IO0,
so no impact for QSPIF

Difference, now, is that when user adds some external QSPI memory, he only has to update his mbed_app.json file. Then he could execute QSPIF AND QSPI tests.

Thx

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks it work
mbed_config.h:

// Automatically generated configuration file.
// DO NOT EDIT, content will be overwritten.

#ifndef __MBED_CONFIG_DATA__
#define __MBED_CONFIG_DATA__

// Configuration parameters
...
#define MBED_CONF_DRIVERS_QSPI_CSN QSPI_FLASH1_CSN // set by library:drivers
#define MBED_CONF_DRIVERS_QSPI_IO0 QSPI_FLASH1_IO0 // set by library:drivers
#define MBED_CONF_DRIVERS_QSPI_IO1 QSPI_FLASH1_IO1 // set by library:drivers
#define MBED_CONF_DRIVERS_QSPI_IO2 QSPI_FLASH1_IO2 // set by library:drivers
#define MBED_CONF_DRIVERS_QSPI_IO3 QSPI_FLASH1_IO3 // set by library:drivers
#define MBED_CONF_DRIVERS_QSPI_SCK QSPI_FLASH1_SCK // set by library:drivers
...

@adbridge
Copy link
Contributor

adbridge commented Oct 7, 2019

CI started

@mbed-ci
Copy link

mbed-ci commented Oct 7, 2019

Test run: SUCCESS

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

@0xc0170
Copy link
Contributor

0xc0170 commented Oct 14, 2019

astyle error - please fix,

Now, these pins can be used everywhere (MBED_CONF_DRIVERS_QSPI_xxx)
and be redefined in local mbed_app.json
(no more need to patch PinNames.h file)
This makes new board with the same QSPI memory addition.
@0xc0170 0xc0170 requested review from maciejbocianski and removed request for a team October 18, 2019 12:52
@0xc0170
Copy link
Contributor

0xc0170 commented Oct 18, 2019

CI started

Please @maciejbocianski review

@mbed-ci
Copy link

mbed-ci commented Oct 18, 2019

Test run: SUCCESS

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

@0xc0170
Copy link
Contributor

0xc0170 commented Oct 21, 2019

As soon as @maciejbocianski approves, this can go in.

@0xc0170 0xc0170 added the release-version: 6.0.0-alpha-1 First pre-release version of 6.0.0 label Oct 21, 2019
@maciejbocianski
Copy link
Contributor

maciejbocianski commented Oct 21, 2019

@0xc0170
The idea for qspi pins was QSPI_FLASHn_IO0 for on board flashes
and QSPIn_IO0 for qspi pins routed out.
So there is always need of manual configuration when testing external qspi flash

Copy link
Contributor

@maciejbocianski maciejbocianski left a comment

Choose a reason for hiding this comment

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

LGTM

@0xc0170 0xc0170 merged commit fe12608 into ARMmbed:master Oct 21, 2019
@0xc0170
Copy link
Contributor

0xc0170 commented Oct 21, 2019

The idea for qspi pins was QSPI_FLASHn_IO0 for on board flashes
and QSPIn_IO0 for qspi pins routed out.
So there is always need of manual configuration when testing external qspi flash

IS this captured in our docs, for instance in QSPI driver docs? If not , it should !

@isaev-d
Copy link
Contributor

isaev-d commented Nov 3, 2020

@jeromecoutant you save my evening.

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.

9 participants