Skip to content

Add QSPI #7783

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 78 commits into from
Aug 24, 2018
Merged

Add QSPI #7783

merged 78 commits into from
Aug 24, 2018

Conversation

maciejbocianski
Copy link
Contributor

@maciejbocianski maciejbocianski commented Aug 14, 2018

Description

Bring new QSPI HAL API to master.

Pull request type

[ ] Fix
[ ] Refactor
[ ] Target update
[X] Feature
[ ] Breaking change

@bulislaw @donatieng @jamesbeyond @0xc0170 @offirko

@@ -0,0 +1,192 @@
/* mbed Microcontroller Library
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it common practice to use specific commercial manufacturers setups in mbed Tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think it's common, actually it's first time. But how to figure out what frequency or what dummy cycle count is supported?

Copy link
Contributor

Choose a reason for hiding this comment

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

@OPpuolitaival Please review

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know how the configuration works but this sounds wrong place to put board specific configuration. We should have some mechanism existing for these configs

Copy link
Contributor Author

@maciejbocianski maciejbocianski Aug 21, 2018

Choose a reason for hiding this comment

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

Actually it's memory chip specific configuration.The configuration covers: max supported frequency, dummy_cycles_count for different write/read modes, mechanisms for enabling/disabling dual/quad/fast modes (which flag in which register to be set).

Here is example of adding QSPI support to new target by vendor, also contain new memory chip description file (link)

Alternatives:

  • put config elsewhere (but where?)
  • use SFDP as is in QSPI SFDP Flash - Block Device link, but it's high level mechanism, not sure if it's adequate here
  • reduce test to subset of common features supported by all memory chips (not a good idea, HAL tests should cover max of features available in specific API)

Copy link
Contributor

Choose a reason for hiding this comment

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

@maciejbocianski - I have no advise on this subject, sorry.
Other than that looks great to me - thanks.

return QSPI_STATUS_OK


#define QUAD_ENABLE() \
Copy link
Contributor

Choose a reason for hiding this comment

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

I see currently those are TODOs, is there a plan to test QUAD?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure dual/quad will be tested, currently we have problems to enable dual/quad mode on targets with N25Q128A memory chip

sUnknown
};

struct QspiCommand {
Copy link
Contributor

Choose a reason for hiding this comment

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

I know struct and class are both legit, but I would prefer to see here a Class

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated, now QspiCommand is a class with privat _cmd


qspi_command_t * get();

qspi_command_t cmd;
Copy link
Contributor

Choose a reason for hiding this comment

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

Another reason to make it a class - If a class would have been used, then mbed-os coding style would have required this member to be '_cmd' - later on in the cpp code its hard to tell whether cmd is a member/global/member

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated, now QspiCommand is a class with privat _cmd

drivers/QSPI.h Outdated
@@ -0,0 +1,222 @@
/* mbed Microcontroller Library
* Copyright (c) 2006-2015 ARM Limited
Copy link
Contributor

Choose a reason for hiding this comment

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

typo I think license date should be updated

drivers/QSPI.h Outdated
*
* @param inst_width Bus width used by instruction phase(Valid values are 1,2,4)
* @param address_width Bus width used by address phase(Valid values are 1,2,4)
* @param address_size Size in bits used by address phase(Valid values are 8,16,24,32)
Copy link
Contributor

Choose a reason for hiding this comment

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

same here, better specifies valid ENUM values and not the integer representation which are different

Copy link
Contributor

Choose a reason for hiding this comment

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

@maciejbocianski Can you remove those integers. It's obvious what type these parameters are

drivers/QSPI.h Outdated

/** Acquire exclusive access to this SPI bus
*/
virtual void lock(void);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we want driver lock/unlock to be public? It could potentially be misused to block other SPI users.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure what was the design @0xc0170 @SenRamakri , but public lock/unlock could be utilized to synchronize between two QSPI driver instances controlling two parallel flash chips connected to the same data lines

Copy link
Contributor

Choose a reason for hiding this comment

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

Good question. I would have assumed this is made protected at least.

@SenRamakri use case for having locks public?

drivers/QSPI.cpp Outdated
bool QSPI::_initialize()
{
if (_mode != 0 && _mode != 1)
return QSPI_STATUS_INVALID_PARAMETER;
Copy link
Contributor

Choose a reason for hiding this comment

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

QSPI_STATUS_INVALID_PARAMETER value (-2) is returned as boolean.
Possibly a problem can occur if "acquire" is called and you return without changing _initialized to false.
also single line 'if' should also be within {..}

Copy link
Contributor

Choose a reason for hiding this comment

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

AStyle to be run on this feature branch additions

drivers/QSPI.h Outdated

/** Configure the data transmission format
*
* @param inst_width Bus width used by instruction phase(Valid values are 1,2,4)
Copy link
Contributor

Choose a reason for hiding this comment

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

Better use the ENUM for Valid values.
The integer representation for the valid values is 0,1,2 :
typedef enum qspi_bus_width {
QSPI_CFG_BUS_SINGLE,
QSPI_CFG_BUS_DUAL,
QSPI_CFG_BUS_QUAD,
} qspi_bus_width_t;

drivers/QSPI.cpp Outdated
_initialized = false;

//Go ahead init the device here with the default config
_initialize();
Copy link
Contributor

Choose a reason for hiding this comment

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

ctor can not return potential failure in 'initialize' - maybe we should at least add an error log print?

@offirko
Copy link
Contributor

offirko commented Aug 15, 2018

@maciejbocianski - Some of my remarks appear twice due to a problem I had in my network during the review - I apologize

for (uint32_t j = 0; j < reg_size; j++) {
utest_printf("register byte %u data: ", j);
for(int i = 0; i < 8; i++) {
utest_printf("%s ", ((reg[j] & (1 << i)) & 0xFF) == 0 ? "0" : "1");
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't it make more sense to print the register contents MSB first? I.e. do a (1 << (7-i)) instead.

@bulislaw
Copy link
Member

Guys we need to accelerate merging this, we have some dependencies. @donatieng @dannybenor

@0xc0170 0xc0170 changed the title Merge feature-qspi to master Add QSPI feature Aug 20, 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.

Waiting for the update (@offirko comments addressed)

@AnotherButler
Copy link
Contributor

Does this docs PR for the driver need updating, or is it still accurate?
ARMmbed/mbed-os-5-docs#354

@maciejbocianski maciejbocianski changed the title Add QSPI feature merge QSPI feature branch Aug 21, 2018
@maciejbocianski
Copy link
Contributor Author

maciejbocianski commented Aug 21, 2018

Update done all comments were addressed. @offirko please review
astyle fixes on QSPI API/driver/tests added

@donatieng @bulislaw @0xc0170 API has changed QSPI::lock/unlock now are protected

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.

Thanks, looks good, let's get this one in!

@jamesbeyond
Copy link
Contributor

Hi @AnotherButler,
The ARMmbed/mbed-os-5-docs#354 is about QSPI drivers API, it looks good, I think @SenRamakri may need to review that again. At least some doxygen links is not valid anymore.

The porting guide is Here, we will update that, and we'll submit a new PR on the handbook.

@AnotherButler
Copy link
Contributor

@jamesbeyond Thanks

@kegilbert Could you please review the linked PR in place of @SenRamakri as he's out?

@maciejbocianski
Copy link
Contributor Author

@bulislaw @AnotherButler @jamesbeyond @donatieng
Also QSPI porting guide has been updated
ARMmbed/mbed-os-5-docs#676

@0xc0170
Copy link
Contributor

0xc0170 commented Aug 22, 2018

/morph build

@cmonr
Copy link
Contributor

cmonr commented Aug 22, 2018

CI related.
/morph build

@cmonr
Copy link
Contributor

cmonr commented Aug 22, 2018

/morph build

@mbed-ci
Copy link

mbed-ci commented Aug 22, 2018

Build : FAILURE

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

@mbed-ci
Copy link

mbed-ci commented Aug 22, 2018

Build : FAILURE

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

1 similar comment
@mbed-ci
Copy link

mbed-ci commented Aug 22, 2018

Build : FAILURE

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

@kegilbert
Copy link
Contributor

Covering for Senthil for the docs portion, left a few comments on the Handbook PRs but overall looks pretty good.

@cmonr
Copy link
Contributor

cmonr commented Aug 23, 2018

/morph build

@cmonr cmonr added the risk: G label Aug 23, 2018
@maciejbocianski
Copy link
Contributor Author

Failed while compiling mbed-os-example-block device K64F IAR

/SPIFBlockDevice.o ./spif-driver/SPIFBlockDevice.cpp
[Warning] SPIFBlockDevice.h@74,56: [Pe611]: overloaded virtual function "BlockDevice::get_erase_size" is only partially overridden in class "SPIFBlockDevice"
[Error] SPIFBlockDevice.cpp@156,52: [Pe020]: identifier "UINT64_MAX" is undefined
[Error] SPIFBlockDevice.cpp@240,17: [Pe020]: identifier "UINT64_MAX" is undefined
[Warning] SPIFBlockDevice.cpp@449,18: [Pe068]: integer conversion resulted in a change of sign
[Error] SPIFBlockDevice.cpp@557,67: [Pe020]: identifier "UINT64_MAX" is undefined
[Error] SPIFBlockDevice.cpp@877,71: [Pe020]: identifier "UINT64_MAX" is undefined
[Error] SPIFBlockDevice.cpp@922,72: [Pe020]: identifier "UINT64_MAX" is undefined
[Error] SPIFBlockDevice.cpp@942,0: [Pe020]: identifier "UINT64_MAX" is undefined

@mbed-ci
Copy link

mbed-ci commented Aug 23, 2018

Build : SUCCESS

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

Triggering tests

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

@0xc0170
Copy link
Contributor

0xc0170 commented Aug 23, 2018

/morph export-build

@mbed-ci
Copy link

mbed-ci commented Aug 23, 2018

@0xc0170
Copy link
Contributor

0xc0170 commented Aug 23, 2018

Restarting . Error initialize storage for one target, eclipse.

/morph export-build

@mbed-ci
Copy link

mbed-ci commented Aug 23, 2018

@cmonr
Copy link
Contributor

cmonr commented Aug 23, 2018

Pausing Test CI until 5.9.6 PR is merged.
Will restart CI shortly after.

@cmonr
Copy link
Contributor

cmonr commented Aug 23, 2018

Network licensing issues.
/morph export-build

Testing gap while release PR is worked on.
/morph test

@mbed-ci
Copy link

mbed-ci commented Aug 23, 2018

@cmonr
Copy link
Contributor

cmonr commented Aug 24, 2018

/morph test

@mbed-ci
Copy link

mbed-ci commented Aug 24, 2018

Test : SUCCESS

Build number : 2635
Test logs :http://mbed-os-logs.s3-website-us-west-1.amazonaws.com/?prefix=logs/7783/2635

@0xc0170
Copy link
Contributor

0xc0170 commented Aug 24, 2018

This PR is ready now for integration.

@AnotherButler Can you review API docs please (there are comments above but not touching the API docs review, so assuming it has not yet been done) ? If there are any edits needed, can you send them as subsequent PR please (this PR is required by few other dependencies so would like to have this in today to continue other work related).

@0xc0170 0xc0170 merged commit 812c6d5 into ARMmbed:master Aug 24, 2018
@0xc0170 0xc0170 changed the title merge QSPI feature branch Add QSPI Aug 24, 2018
@mbed-ci
Copy link

mbed-ci commented Aug 24, 2018

Exporter Build : FAILURE

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

@cmonr cmonr removed the risk: G label Aug 25, 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.