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

STM32L4: clear error programming flags before erase & program operations #8263

Merged
merged 2 commits into from Oct 9, 2018

Conversation

Projects
None yet
6 participants
@juhoeskeli
Contributor

juhoeskeli commented Sep 26, 2018

Description

On STM32L486 when using dual bank operation where the program code was in bank 0 and BlockDevice in bank1 the erase and program operations would fail with Flash_error: 32.

From the reference manual: Bit 7 PGSERR: Programming sequence error Set by hardware when a write access to the Flash memory is performed by the code while PG or FSTPG have not been set previously. Set also by hardware when PROGERR, SIZERR, PGAERR, MISSERR or FASTERR is set due to a previous programming error. Cleared by writing 1.

The suggested write sequence can be found from reference: en.DM00083560.pdf 3.3.7 Flash main memory programming sequences - 2. Check and clear all error programming flags due to a previous programming.

The code change performs just that, clears the flags as per instructions. With the change it is possible to use bank 0 for running the program code while writing data to bank 1. I have tested this change on STM32L486 where OTA FW image was loaded to bank 1 and successfully updated from therein to bank 0.

Further reference: MBEDOSTEST-206

Pull request type

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

@cmonr cmonr requested a review from ARMmbed/team-st-mcd Sep 27, 2018

@cmonr cmonr added the needs: review label Sep 27, 2018

@jeromecoutant

This comment has been minimized.

Contributor

jeromecoutant commented Sep 27, 2018

Flash test results with this patch for STM32L4 NUCLEO boards:

target platform_name test suite result elapsed_time (sec) copy_method
NUCLEO_L432KC-ARM NUCLEO_L432KC tests-mbed_drivers-flashiap OK 21.36 default
NUCLEO_L432KC-ARM NUCLEO_L432KC tests-mbed_hal-flash OK 18.25 default
NUCLEO_L433RC_P-ARM NUCLEO_L433RC_P tests-mbed_drivers-flashiap OK 18.13 default
NUCLEO_L433RC_P-ARM NUCLEO_L433RC_P tests-mbed_hal-flash OK 17.99 default
NUCLEO_L476RG-ARM NUCLEO_L476RG tests-mbed_drivers-flashiap OK 18.09 default
NUCLEO_L476RG-ARM NUCLEO_L476RG tests-mbed_hal-flash OK 17.96 default
NUCLEO_L486RG-ARM NUCLEO_L486RG tests-mbed_drivers-flashiap OK 18.37 default
NUCLEO_L486RG-ARM NUCLEO_L486RG tests-mbed_hal-flash OK 18.1 default
NUCLEO_L496ZG-ARM NUCLEO_L496ZG tests-mbed_drivers-flashiap OK 18.08 default
NUCLEO_L496ZG-ARM NUCLEO_L496ZG tests-mbed_hal-flash OK 18.11 default
@@ -137,6 +137,9 @@ int32_t flash_erase_sector(flash_t *obj, uint32_t address)
return -1;
}
/* Clear error programming flags */
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_ALL_ERRORS);

This comment has been minimized.

@jeromecoutant

jeromecoutant Sep 27, 2018

Contributor

If you clear all flash error, maybe you can remove next __HAL_FLASH_CLEAR_FLAG ?

This comment has been minimized.

@juhoeskeli

juhoeskeli Oct 2, 2018

Contributor

Should be OK now. FLASH_FLAG_ALL_ERRORS includes also FLASH_FLAG_OPTVERR

@jeromecoutant

This comment has been minimized.

Contributor

jeromecoutant commented Oct 2, 2018

Need to check other STM32 families

@0xc0170

This comment has been minimized.

Member

0xc0170 commented Oct 4, 2018

Need to check other STM32 families

Any update?

@jeromecoutant

This comment has been minimized.

Contributor

jeromecoutant commented Oct 4, 2018

Any update?

Sorry, this is "only" a reminder for my todo list
You can start CI for this PR

@0xc0170

0xc0170 approved these changes Oct 4, 2018

@0xc0170 0xc0170 added needs: CI and removed needs: review labels Oct 4, 2018

@jeromecoutant

This comment has been minimized.

Contributor

jeromecoutant commented Oct 5, 2018

Need to check other STM32 families

For information, it seems that L4 FLASH driver is different from other STM32 families.
So this fix has not to be applied everywhere.
Regards,

@juhoeskeli

This comment has been minimized.

Contributor

juhoeskeli commented Oct 8, 2018

To next patch release, please.

@NirSonnenschein

This comment has been minimized.

Contributor

NirSonnenschein commented Oct 9, 2018

/morph build

@mbed-ci

This comment has been minimized.

mbed-ci commented Oct 9, 2018

Build : SUCCESS

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

Triggering tests

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

@mbed-ci

This comment has been minimized.

@NirSonnenschein

This comment has been minimized.

Contributor

NirSonnenschein commented Oct 9, 2018

exporter / mbed2 build seems to have failed because of IAR license shortage - re-=running:
/morph export-build
/morph mbed2-build

@mbed-ci

This comment has been minimized.

@mbed-ci

This comment has been minimized.

@0xc0170 0xc0170 merged commit 17762b4 into ARMmbed:master Oct 9, 2018

16 checks passed

ci-morph-build build completed
Details
ci-morph-exporter build completed
Details
ci-morph-mbed2-build build completed
Details
ci-morph-test test completed
Details
continuous-integration/jenkins/pr-head This commit looks good
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
jenkins-ci/cloud_client_smoke_test Success
Details
jenkins-ci/greentea-test Success
Details
jenkins-ci/unittests Success
Details
travis-ci/astyle Passed, 626 files
Details
travis-ci/docs Local docs testing has passed
Details
travis-ci/events Passed, runtime is 9866 cycles (-405 cycles)
Details
travis-ci/gitattributestest Local gitattributestest testing has passed
Details
travis-ci/licence_check Local licence_check testing has passed
Details
travis-ci/littlefs Passed, code size is 8372B (+0.00%)
Details
travis-ci/tools-py2.7 Local tools-py2.7 testing has passed
Details

@0xc0170 0xc0170 removed the ready for merge label Oct 9, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment