Summary of problems with IAP programming page0 returning failure

Publisher:创新之星Latest update time:2023-03-21 Source: elecfans Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Recently, I encountered such a problem when supporting a customer: the customer was making his own secondary boot loader and using the LPC54608 IAP function. When programming page0 in sector0, it always failed (returning 0x21 error code), but programming any other page There is no problem (the customer's code is in the last sector, no programming).


The problem seems strange at first glance, because only page0 will have problems, and there will be no problems with operations on other pages, and there will be no problems with erasing page/sector. Only programming operations will go wrong.


After a short discussion, the problem was finally locked on the check sum verification mechanism of the LPC interrupt vector table: LPC (except for the relatively new LPC5500 series) basically needs to fill in the 8th position of the interrupt vector table. Checksums of the first seven interrupt vectors. For details about the checksums, please refer to the article mentioned at the beginning.


In the .bin file compiled by Keil, this checksum is not automatically added by default, so whenever IAP is called to change to page0, the IAP program will check this checksum internally. Once the checksum is wrong (such as all 0 ) will return failure.


The solution is also very simple, just calculate the checksum every time you program page0. The code for calculating the checksum is given directly here:

213df384-30e7-11ec-82a8-dac502259ad0.png

adr is the programming address. When adr is 0, the page0 area is programmed. The code in the red box calculates the checksum and fills the checksum into the 8th position of the interrupt vector table.


After adding this code to calculate the checksum, the problem is solved. This problem is common in almost all old LPC models except the LPC5500 series. I hope this article will be helpful to everyone in developing LPC MCUs!


Reference address:Summary of problems with IAP programming page0 returning failure

Previous article:RS-485 bus realizes smart home network system
Next article:Methods to Investigate HardFault Using SAU and Secure AHB Controllers

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号