[LPC55xx] Why FLASH Program cannot Success?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

[LPC55xx] Why FLASH Program cannot Success?

[LPC55xx] Why FLASH Program cannot Success?

MCUXpresso SDK for LPC55xx uses FLASH API to implement FLASH drivers. Some user may meet issue when executes FLASH program code, for instance:

status = FLASH_Program(&flashInstance, destAdrss, (uint8_t *)s_bufferFF, 8);


After execution this code, nothing changed in the destination address, but error code 101 returns:

pastedImage_1.png

This error code looks new, as it doesn’t commonly exist in other older LPCs. If we check FLASH driver status code from UM, code 101 means FLASH_Alignment Error:

pastedImage_2.png

Alignment error Ah ha? ! Go back to the definition of FLASH_Program,

status_t FLASH_Program(flash_config_t *config, uint32_t start, uint32_t *src, uint32_t lengthInBytes);

New user often overlooks the UM description of this API “the required start and the lengthInBytes must be page size aligned”. That’s to say, to execute FLASH_Program function, both start address and the length must be 512 bytes-aligned. So if we modify

status = FLASH_Program(&flashInstance, destAdrss, (uint8_t *)s_bufferFF, 8);

To

status = FLASH_Program(&flashInstance, destAdrss, (uint8_t *)s_bufferFF, 512);

FLASH_Program can be successful.

 

!!NOTE: In old version of SDK2.6.x, the description of FLASH_Program says the start address and length are word-aligned which is not correct. The new SDK2.7.0 has fixed the typo. 

Keep in mind: Even you want to program 1 word, the lengInBytes is still 512 aligned, as same as destAdrss!

PS.

I always recommend my customer to check FLASH driver status code when meet problem with FLASH API. We can find it in UM11126, Chapter 9, FLASH API.

I extract here for your quickly browse:

pastedImage_3.png

 

Happy Programming

标签 (1)
附件
%3CLINGO-SUB%20id%3D%22lingo-sub-1106670%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%5BLPC55xx%5D%E4%B8%BA%E4%BB%80%E4%B9%88FLASH%E7%BC%96%E7%A8%8B%E6%97%A0%E6%B3%95%E6%88%90%E5%8A%9F%EF%BC%9F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1106670%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%26lt%3Bmeta%20http-equiv%3D%22Content-Type%22%20content%3D%22text%2Fhtml%3B%20charset%3Dutf-8%22%20%2F%26gt%3B%0A%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2015px%3B%22%3ELPC55xx%20%E7%9A%84%20MCUXpresso%20SDK%20%E4%BD%BF%E7%94%A8%20FLASH%20API%20%E6%9D%A5%E5%AE%9E%E7%8E%B0%20FLASH%20%E9%A9%B1%E5%8A%A8%E7%A8%8B%E5%BA%8F%E3%80%82%E6%9F%90%E4%BA%9B%E7%94%A8%E6%88%B7%E5%9C%A8%E6%89%A7%E8%A1%8CFLASH%E7%A8%8B%E5%BA%8F%E4%BB%A3%E7%A0%81%E6%97%B6%E5%8F%AF%E8%83%BD%E4%BC%9A%E9%81%87%E5%88%B0%E9%97%AE%E9%A2%98%EF%BC%8C%E4%BE%8B%E5%A6%82%EF%BC%9A%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2015px%3B%22%3E%3CEM%3E%E7%8A%B6%E6%80%81%20%3D%20FLASH_Program(%26amp%3BflashInstance%2C%20destAdrss%2C%20(uint8_t%20*)s_bufferFF%2C%208)%3B%3C%2FEM%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CBR%20%2F%3E%3CSPAN%20style%3D%22font-size%3A%2015px%3B%22%3E%E6%89%A7%E8%A1%8C%E6%AD%A4%E4%BB%A3%E7%A0%81%E5%90%8E%EF%BC%8C%E7%9B%AE%E6%A0%87%E5%9C%B0%E5%9D%80%E6%B2%A1%E6%9C%89%E4%BB%BB%E4%BD%95%E5%8F%98%E5%8C%96%EF%BC%8C%E4%BD%86%E8%BF%94%E5%9B%9E%E9%94%99%E8%AF%AF%E4%BB%A3%E7%A0%81%3CSTRONG%3E101%3C%2FSTRONG%3E%20%EF%BC%9A%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2015px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22pastedImage_1.png%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22pastedImage_1.png%22%20style%3D%22width%3A%20496px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F97129i5F9E31F36FD18C15%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22pastedImage_1.png%22%20alt%3D%22pastedImage_1.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2015px%3B%22%3E%E8%BF%99%E4%B8%AA%E9%94%99%E8%AF%AF%E4%BB%A3%E7%A0%81%E7%9C%8B%E8%B5%B7%E6%9D%A5%E5%BE%88%E6%96%B0%EF%BC%8C%E5%9B%A0%E4%B8%BA%E5%AE%83%E5%9C%A8%E5%85%B6%E4%BB%96%E8%BE%83%E6%97%A7%E7%9A%84%20LPC%20%E4%B8%AD%E5%B9%B6%E4%B8%8D%E5%B8%B8%E8%A7%81%E3%80%82%E5%A6%82%E6%9E%9C%E6%88%91%E4%BB%AC%E4%BB%8E%20UM%20%E6%A3%80%E6%9F%A5%20FLASH%20%E9%A9%B1%E5%8A%A8%E7%A8%8B%E5%BA%8F%E7%8A%B6%E6%80%81%E4%BB%A3%E7%A0%81%EF%BC%8C%E4%BB%A3%E7%A0%81%20101%20%E8%A1%A8%E7%A4%BA%20FLASH_Alignment%20%E9%94%99%E8%AF%AF%EF%BC%9A%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2015px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22pastedImage_2.png%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22pastedImage_2.png%22%20style%3D%22width%3A%20554px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F97174iD6DEFB488D0FC278%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22pastedImage_2.png%22%20alt%3D%22pastedImage_2.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2015px%3B%22%3E%E5%AF%B9%E5%87%86%E9%94%99%E8%AF%AF%E5%95%8A%E5%93%88%EF%BC%9F%EF%BC%81%E5%9B%9E%E5%88%B0FLASH_Program%E7%9A%84%E5%AE%9A%E4%B9%89%EF%BC%8C%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2015px%3B%22%3E%3CEM%3Estatus_t%20FLASH_Program%EF%BC%88flash_config_t%20*config%EF%BC%8Cuint32_t%20start%EF%BC%8Cuint32_t%20*src%EF%BC%8Cuint32_t%20lengthInBytes%EF%BC%89%EF%BC%9B%3C%2FEM%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2015px%3B%22%3E%E6%96%B0%E7%94%A8%E6%88%B7%E7%BB%8F%E5%B8%B8%E5%BF%BD%E7%95%A5%E6%AD%A4%20API%20%E7%9A%84%20UM%20%E6%8F%8F%E8%BF%B0%E2%80%9C%E6%89%80%E9%9C%80%E7%9A%84%3CEM%3E%E8%B5%B7%E5%A7%8B%3C%2FEM%3E%E5%92%8C%3CEM%3E%E9%95%BF%E5%BA%A6%EF%BC%88%E5%AD%97%E8%8A%82%EF%BC%89%3C%2FEM%3E%E5%BF%85%E9%A1%BB%E4%B8%8E%E9%A1%B5%E9%9D%A2%E5%A4%A7%E5%B0%8F%E5%AF%B9%E9%BD%90%E2%80%9D%E3%80%82%E4%B9%9F%E5%B0%B1%E6%98%AF%E8%AF%B4%EF%BC%8C%E8%A6%81%E6%89%A7%E8%A1%8CFLASH_Program%E5%87%BD%E6%95%B0%EF%BC%8C%E8%B5%B7%E5%A7%8B%E5%9C%B0%E5%9D%80%E5%92%8C%E9%95%BF%E5%BA%A6%E9%83%BD%E5%BF%85%E9%A1%BB%E6%98%AF512%E5%AD%97%E8%8A%82%E5%AF%B9%E9%BD%90%E7%9A%84%E3%80%82%E6%89%80%E4%BB%A5%E5%A6%82%E6%9E%9C%E6%88%91%E4%BB%AC%E4%BF%AE%E6%94%B9%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2015px%3B%22%3E%3CEM%3E%E7%8A%B6%E6%80%81%20%3D%20FLASH_Program(%26amp%3BflashInstance%2C%20destAdrss%2C%20(uint8_t%20*)s_bufferFF%2C%20%3CSTRONG%20style%3D%22color%3A%20red%3B%20%22%3E8%3C%2FSTRONG%3E%20)%3B%3C%2FEM%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2015px%3B%22%3E%E8%87%B4%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2015px%3B%22%3E%3CEM%3E%E7%8A%B6%E6%80%81%20%3D%20FLASH_Program(%26amp%3BflashInstance%2C%20destAdrss%2C%20(uint8_t%20*)s_bufferFF%2C%20%3CSTRONG%20style%3D%22color%3A%20red%3B%20%22%3E512%3C%2FSTRONG%3E%20)%3B%3C%2FEM%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2015px%3B%22%3EFLASH_Program%20%E5%8F%AF%E4%BB%A5%E6%88%90%E5%8A%9F%E3%80%82%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2015px%3B%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2015px%3B%22%3E%3CSTRONG%3E%E6%B3%A8%E6%84%8F%3C%2FSTRONG%3E%EF%BC%9A%E5%9C%A8%E6%97%A7%E7%89%88%E6%9C%AC%E7%9A%84SDK2.6.x%E4%B8%AD%EF%BC%8CFLASH_Program%E7%9A%84%E6%8F%8F%E8%BF%B0%E8%AF%B4%E8%B5%B7%E5%A7%8B%E5%9C%B0%E5%9D%80%E5%92%8C%E9%95%BF%E5%BA%A6%E6%98%AF%E5%AD%97%E5%AF%B9%E9%BD%90%E7%9A%84%EF%BC%8C%E8%BF%99%E6%98%AF%E4%B8%8D%E6%AD%A3%E7%A1%AE%E7%9A%84%E3%80%82%E6%96%B0%E7%9A%84SDK2.7.0%E5%B7%B2%E7%BB%8F%E4%BF%AE%E5%A4%8D%E4%BA%86%E8%BF%99%E4%B8%AA%E9%94%99%E5%AD%97%E3%80%82%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2015px%3B%22%3E%3CSTRONG%3E%E8%AF%B7%E8%AE%B0%E4%BD%8F%EF%BC%9A%3C%2FSTRONG%3E%E5%8D%B3%E4%BD%BF%E6%82%A8%E6%83%B3%E7%BC%96%E7%A8%8B%201%20%E4%B8%AA%E5%AD%97%EF%BC%8ClengInBytes%20%E4%BB%8D%E7%84%B6%E6%98%AF%20512%20%E5%AF%B9%E9%BD%90%E7%9A%84%EF%BC%8C%E4%B8%8E%20destAdrss%20%E7%9B%B8%E5%90%8C%EF%BC%81%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2015px%3B%22%3EPS.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2015px%3B%22%3E%E5%BD%93%E9%81%87%E5%88%B0%20FLASH%20API%20%E9%97%AE%E9%A2%98%E6%97%B6%EF%BC%8C%E6%88%91%E6%80%BB%E6%98%AF%E5%BB%BA%E8%AE%AE%E6%88%91%E7%9A%84%E5%AE%A2%E6%88%B7%E6%A3%80%E6%9F%A5%20FLASH%20%E9%A9%B1%E5%8A%A8%E7%A8%8B%E5%BA%8F%E7%8A%B6%E6%80%81%E4%BB%A3%E7%A0%81%E3%80%82%E6%88%91%E4%BB%AC%E5%8F%AF%E4%BB%A5%E5%9C%A8UM11126%E7%AC%AC9%E7%AB%A0FLASH%20API%E4%B8%AD%E6%89%BE%E5%88%B0%E5%AE%83%E3%80%82%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2015px%3B%22%3E%E6%88%91%E5%9C%A8%E8%BF%99%E9%87%8C%E6%91%98%E5%BD%95%E4%BB%A5%E4%BE%9B%E6%82%A8%E5%BF%AB%E9%80%9F%E6%B5%8F%E8%A7%88%EF%BC%9A%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2015px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22pastedImage_3.png%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22pastedImage_3.png%22%20style%3D%22width%3A%20543px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F97220i88BED0265319B6B6%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22pastedImage_3.png%22%20alt%3D%22pastedImage_3.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2015px%3B%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2015px%3B%22%3E%E5%BF%AB%E4%B9%90%E7%BC%96%E7%A8%8B%3CIMG%20class%3D%22jive_emoji%22%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Fimages%2Femojis%2F1f60a.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CP%3E%3C%2FP%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1106670%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CLINGO-LABEL%3ELPC55xx%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
100% 有帮助 (1/1)
版本历史
最后更新:
‎01-20-2020 02:00 AM
更新人: