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

targets:MIMXRT1050: Add QSPI flash support #12711

Merged
merged 5 commits into from
Apr 15, 2020
Merged

Conversation

liugang-gavin
Copy link
Contributor

Summary of changes

targets:MIMXRT1050:
    1. QSPI Flash boot support
    2. QSPI Flash FLASHIAP support
    3. Update link file for application and bootloader

Impact of changes

Migration actions required

Documentation

None


Pull request type

[] Patch update (Bug fix / Target update / Docs update / Test update / Refactor)
[X] Feature update (New feature / Functionality change / New API)
[] Major update (Breaking change E.g. Return code change / API behaviour change)

Test results

[] No Tests required for this change (E.g docs only update)
[X] Covered by existing mbed-os tests (Greentea or Unittest)
[] Tests / results supplied as part of this PR

Reviewers

[email protected]


@ciarmcom
Copy link
Member

@liugang-gavin, thank you for your changes.
@maclobdell @ARMmbed/mbed-os-maintainers please review.

@ciarmcom ciarmcom requested review from maclobdell and a team March 29, 2020 15:00
@adbridge
Copy link
Contributor

@liugang-gavin I think as a target update only this comes under patch not feature type? Could you please update.

@@ -271,11 +272,245 @@ status_t flexspi_nor_flash_page_program_ram(uint32_t address, const uint32_t *sr
return status;
}

#else
AT_QUICKACCESS_SECTION_CODE(status_t flexspi_nor_enable_quad_mode_ram(void));
status_t flexspi_nor_enable_quad_mode_ram(void)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this an internal only api or are you adding something exposed to the user ?

flashXfer.dataSize = 1;

status = FLEXSPI_TransferBlocking(FLEXSPI, &flashXfer);
if (status != kStatus_Success)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be :

if () {
}

/* Write enable */
status = flexspi_nor_write_enable_ram(0);

if (status != kStatus_Success)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be

if () {
}

return status;
}

void flexspi_update_lut_ram(void)
Copy link
Contributor

Choose a reason for hiding this comment

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

Again , internal only api or externally exposed ?

flashXfer.data = &readValue;
flashXfer.dataSize = 1;

do
Copy link
Contributor

Choose a reason for hiding this comment

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

This whole block is incorrectly formatted. Please check coding guidelines and / or run through astyle


status = FLEXSPI_TransferBlocking(FLEXSPI, &flashXfer);

if (status != kStatus_Success)
Copy link
Contributor

Choose a reason for hiding this comment

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

Incorrect formatting

flashXfer.seqIndex = NOR_CMD_LUT_SEQ_IDX_ERASESECTOR;
status = FLEXSPI_TransferBlocking(FLEXSPI, &flashXfer);

if (status != kStatus_Success)
Copy link
Contributor

Choose a reason for hiding this comment

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

Incorrect formatting

flashXfer.deviceAddress = address + offset;
flashXfer.port = kFLEXSPI_PortA1;
flashXfer.cmdType = kFLEXSPI_Write;
flashXfer.SeqNumber = 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

Indentation seems to have gone wrong here

#else
const flexspi_nor_config_t qspiflash_config = {
.memConfig =
{
Copy link
Contributor

Choose a reason for hiding this comment

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

.memConfig = {

.serialClkFreq = kFlexSpiSerialClk_133MHz,
.lutCustomSeqEnable = 0u,
.sflashA1Size = 0x00800000u, /* 8MB/64Mbit */
.lookupTable =
Copy link
Contributor

Choose a reason for hiding this comment

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

.lookupTable = {

@liugang-gavin
Copy link
Contributor Author

thanks for your review, I'm working for the second version based on your comments.

NXP MIMXRT1050 EVK can support Hyper Flash or QSPI Flash with
small hardware reworks. Modify the XIP file to support boot
from the two kinds of Flash device. The Hyper Flash should be
the default device and defined in tartgets.json with the macro
"HYPERFLASH_BOOT". To select the QSPI Flash, just remove the
macro with the below line in any overriding json file.
	"target.macros_remove" : ["HYPERFLASH_BOOT"]

Signed-off-by: Gavin Liu <[email protected]>
The flash access may fail when implementing flash
initialization. So there is risk for interrupt handler
which linked in flash space.

Add the critical section to avoid the risk.

Signed-off-by: Gavin Liu <[email protected]>
The memset function from c library will be linked in flash
space, it's risk for FLASHIAP. So I wrote flexspi_memset
to replace the memset for IMX FLASHIAP, and put the function
into targets/.../TARGET_IMX/flash_api.c file. All IMX Soc
platforms can declare it as extern and use in their Soc
flexspi driver files.

Signed-off-by: Gavin Liu <[email protected]>
Update the flash driver to support both Hyper Flash
and QSPI Flash.

In addition, the static function cannot be linked to
SRAM even defined by AT_QUICKACCESS_SECTION_CODE macro.
So remove all "static" modifier for the FLASHIAP
functions.

Signed-off-by: Gavin Liu <[email protected]>
For the application(firmware) booted by bootloader(OTA),
the image doesn't need the "flash_config" and "ivt" header.
So update the link file to support both kinds of application
(firmware) booted by bootROM and bootloader.

In default, the compilation will get the image with
"flash_config" and "ivt" header, for example the bootloader
compiling.

When compiling the OTA application image, please add the
line as below in the mbed_app.json file.

	"target.macros_add" : ["MBED_APP_COMPILE"]

This will remove the "flash_config" and "ivt" header in the
final image.

Signed-off-by: Gavin Liu <[email protected]>
@liugang-gavin
Copy link
Contributor Author

hi, adbridge and reviewer,

I updated the PR with the second version patches, it includes new patches to fix some potential issues. And also I checked the code with astyle.
@adbridge

  1. I want to change the PR summary to remove the [X] Feature update, but sorry I don't know why the page always cannot be put to the edit mode.
  2. For some FLASHIAP internal functions but defined with AT_QUICKACCESS_SECTION_CODE, it cannot be defined with "static", otherwise the compiler cannot put them in the SRAM space.
  3. please also help to reveiw the PR: nxp:mimxrt1050: Add support for MIMXRT1050_EVK mbed-os-example-pelion#123 for PDMC.

Thanks!
Gavin

@mergify mergify bot added needs: CI and removed needs: work labels Apr 3, 2020
@adbridge
Copy link
Contributor

adbridge commented Apr 6, 2020

HI @liugang-gavin we don't have anything to do with the Pelion example I'm afraid.

@liugang-gavin liugang-gavin mentioned this pull request Apr 8, 2020
@0xc0170
Copy link
Contributor

0xc0170 commented Apr 14, 2020

CI restarted

@mbed-ci
Copy link

mbed-ci commented Apr 14, 2020

Test run: SUCCESS

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

@0xc0170 0xc0170 merged commit 92f5809 into ARMmbed:master Apr 15, 2020
@mergify mergify bot removed the ready for merge label Apr 15, 2020
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.

5 participants