Hello NXP Community members,
I am trying to write data block to flash sector(s) e.g. starting address of the sector: 0xC000.
It is working if I have my user application starting 0x0000 as start address of PROGRAM_FLASH. However it is failed (hardfault) if I have the user application relocated the start address to other than 0x0000 e.g. 0x1000 or 0x2000 of the PROGRAM_FLASH.
Can you please help me to get this problem resolved ?
Any technical tip will be highly appreciated.
My SW development environment is as follows;
1. IDE: MCUXpresso
2. MCU: LPC850
3. Target board: customized
4. memory section and assignment info attached.
Thank you in advance.
已解决! 转到解答。
Hi Alice,
The problem has been solved and everything works as expected since merging simple jump2app project and mainApp project thanks to your help.
Again, thank you so much for your support.
Hello @uzza9
1) Do you mean using Flash programmer download project into memory 0x2000? If yes, you can use GUI Flash Tool on MCUXpresso IDE:
2) Why are you splitting the flash in two parts? And discontinuous as your attachment?
3)I guess you place secondary bootloader into 0x0000, right?
4) BTW, your chip is LPC850 or LPC860?
BR
Alice
Hi Alice,
Thank you for your reply and the questions.
Please see my answer as follows;
1) Do you mean using Flash programmer download project into memory 0x2000? If yes, you can use GUI Flash Tool on MCUXpresso IDE:
Answer) I have my own flash tool with Python. And the flash tool works to download/flash s19 file to target boards.
The starting address for flash operation depends on the address in s19 file e.g. 0x2000, 0x3000, 0xC000, and etc.
2) Why are you splitting the flash in two parts? And discontinuous as your attachment?
Answer) 1st part is for program code, and 2nd part is for calibration data that can be flashed while program code working.
The discontinuous was because I captured the attachment while trying to run test case.
In actual code, for the user application (PROGRAM_FLASH), I have 0x3000 as starting address and the size is 0x9000.
For the calibration data (CAL_FLASH), I have 0xC000 as starting address and the size is 0x4000.
For your better understanding my MCU settings, please refer to screen capture attached.
3) I guess you place secondary bootloader into 0x0000, right?
Answer) Yes, I have the secondary bootloader from 0x0000 with size of 0x3000.
4) BTW, your chip is LPC850 or LPC860?
Answer) The MCU is LPC865M201.
Additional info again, my user application is working as expected to flash calibration data in s19 file to the part (CAL_FLASH) when I have the start address of the PROGRAM_FLASH at 0x0000.
However, I got hard fault while flashing the same calibration data when I have the starting address of the FLASH_PROGRAM other than 0x0000 e.g. the start address at 0x1000, 0x2000, 0x3000.
Please let me know if you need my further follow up.
Thank you,
uzza9.
Hello @uzza9
" I got hard fault while flashing the same calibration data when I have the starting address of the FLASH_PROGRAM other than 0x0000 e.g. the start address at 0x1000, 0x2000, 0x3000."
->> Is there hard fault when write flash ? or run your project?
If when write flash, you should check your flash tool.
If got hard fault when run your project, have you program your second bootloader first? The start address of LPC865 is 0x00.
BR
Alice
Hi Alice,
Thank you for your follow up.
I think I made narrow down cause of the problem, however still don't know why it occurs and how to get the problem solved.
First, please see the answer to your question below.
1. Is there hard fault when write flash ? or run your project?
Answer) It happens while running my project. The problem doesn't seem to be related to the flash process.
2. have you program your second bootloader first?
Answer) No I did not flash my second bootloader at 0x0000, but just flash my application from other than 0x0000 e.g. 0x1000.
An weird that is observed while testing with the second bootloader only is that the same problem occurs when I have my second bootloader sitting from other than 0x0000. Therefore, I can say any program if I do not have starting from 0x0000 seems cause the problem.
Second, here please take a look into my progress to narrow down to get the cause;
1. Let's say, I have a test code to see PC as follows;
void rx_pkt_msg()
{
if (testCnt < 1028)
{
}
else
{
blRxMsg.message[testCnt] = testCnt;
testCnt++;
if (testCnt >= 173)
{
__asm volatile("nop");
}
}
} <=== observe SP and PC at this point
2. The test result is that seems working until testCnt reaches up to about 170, however that runs into hard fault when testCnt is reaching between more than 170 and less than 200+.
3. Observation; SP and PC at the return point (arrow marked at the test code)
a. attached screen capture of disassembly at return point: file name "pc_at_return.jpg"
b. attached screen capture of disassembly for normal return: file name "pc_for_normal_return.jpg"
c. attached screen capture of disassembly for abnormal return: file name "pc_for_abnormal_return.jpg"
4. The hard fault occurs when PC has value 0x5700 that points in side a function, not ENTRY POINT OF THE FUNCTION.
It will be highly appreciated if you let me get any clue to try to fix this problem.
Thank you,
uzza9
Hi Alice,
Can you please let me know how to set VTOR without bootloader?
Usually, I put the following in bootloader to jump to user application;
Hello @uzza9
Yes, you need jump code, you can jut copy the jump function code from bootloader to a simple project, place it into 0x00.
And there is a method to debug from No-zero address without jump function, using MCUXpresso ide:
BR
Alice
Hi Alice,
Thank you for your reply.
As I understood, I need to merge two projects together.
Therefore, I am struggling to merge a simple jump2App project (starting at 0x0000 with size of 0x3000) and a mainApp project (starting at 0x3000 with size of 0x9000).
However, I don't think I have clue to move forward to merge the projects. (Still I don't get appropriate links while searching on NXP forum)
My approach to merge the 2 projects is to add include files of mainApp project into jump2App project that is very similar way to integrate a library (*.a) to main project.
Meantime I am struggling, can you please let me get a technical tip and/or guide links?
Do I need to have mainApp.elf at someplace in MCUXpresso as I needed to have libExample.a on Settings >> Tool Settings >> Standard S32DS C Linker >> Libraries ?
For your information, I am familiar with
1. How to handle a secondary bootloader and user application.
2. How to integrate library project to main project.
Thank you,
uzza9
Hello @uzza9
1)You can program bootloader first, then program application image, pay attention do not erase bootloader when program application.
2)If there is no bootloader , just want to debug application project, can refer to the linker I mentioned last time.
BR
Alice
Hi Alice,
The problem has been solved and everything works as expected since merging simple jump2app project and mainApp project thanks to your help.
Again, thank you so much for your support.