Hi all.
I have trouble to writing p-flash area for coding bootload.
Basically my code is depending on AN2295 SW.
I want to write some word like 0x2143. But it is not writing at the address 0x0410. It is written at 0x1FFF8000. Here is SRAM area.
My modified code is blow:
__attribute__((section(".programbuff"))) Byte buffer[200];
FCC0B_STR CommandObj;
#define FLASH_FlashCommandSequence ((LWord (*)(Byte))&buffer[1])
FLASH_ProgramLongWord(destination, *pSource++)
{
CommandObj.regsLong.fccob3210 = destination;
CommandObj.regs.fccob0 = FLASH_PROGRAM_LONGWORD;
CommandObj.regsLong.fccob7654 = data32b;
return FLASH_FlashCommandSequence(PROGRAM_LONGWORD_INDEX);
}
I set the destination 0x410
*pSource is data array pointer.
But it write at 0x1FFF8000 not 0x0410.
Error message is this: No source available for "0x1FFF8000 (0x1FFF8000)() "
What is meaning of #define FLASH_FlashCommandSequence((LWord (*)(Byte))&buffer[1]) ?
Why i need this? and What is FCC0B STR CommandObj? I can't understand this meaning.
And my syntax is right?
Do you have idea?
Thank you.
Eunseok.
Solved! Go to Solution.
Hi Eunseok Jung,
FLASH_FlashCommandSequenceStart function is used for the flash command operation sequence.
As you know, every flash operation is using the according command to realize the flash operation function by write the FCCOBx register.
The index is means how many FCCOB register to control, the base address is defined as FLASH_BASE_PTR->FCCOB3:Just FCCOB3,
From our flash register table, you will know FCCOB3 is the base address of FCCOBn, just like the following:
#define ERASE_BLOCK_INDEX 4
#define PROGRAM_LONGWORD_INDEX 8
#define PROGRAM_PHRASE_INDEX 12
The index number should be the number of FCCOB registers which need to control.
(1)ERASE_BLOCK_INDEX 4 means Erase block is just control 4 FCCOB registers:
(2) PROGRAM_LONGWORD_INDEX 8 means this command should control 8 FCCOB registers:
(3) PORGRAM_PHASE_INDEX 12
I think it should be the Progarm check command, this command should control 12 FCCOB registers:
Please find more detals from our K10 reference manual, chapter 29 .
Wish it helps you!
Have a great day,
Jingjing
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Eunseok Jung,
Alice Yang is correct.
In your code, you do the following definition:
for(i = 0;i<10; i++) | |
{ | |
write_buffer[i] = 0x2143; | |
//#if BOOTLOADER_CRC_ENABLE == 1 | |
// CRC_AddByte(write_buffer[i]); | |
//#endif | |
} |
That's why you see your 0x2143 in the RAM address, because you define it in the RAM.
Before you do flash writing , you should erase it at first, otherwise , your flash operation won't be successed.
Actually, in AN2295, from address 0x00000410, it is the bootloader code.
I don't know, why you write the word 0x2143 in the bootloader code area.
If you want to realize the function of uart bootloader, you need to modify your application code address, not the bootloader code address.
Please read our AN2295.pdf at first, this application write how to realize the uart bootloader in details, please read Chapter 7 carefully.
If you stll have quesiton, please let us know.
Wish it helps you!
Have a great day,
Jingjing
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Thank you Jingjing.
The reason why i want to write at 0x0000410 is just practice for bootload.
Can i ask one?
Could you explain this function? It is from AN2295SW file.
LWord FLASH_FlashCommandSequenceStart(Byte index)
{
Byte* ptrFccobReg = (Byte*)&FLASH_BASE_PTR->FCCOB3;
Byte* ptrCommandObj = (Byte*)&CommandObj;
/* wait till CCIF bit is set */
while(!(FLASH_FSTAT & FLASH_FSTAT_CCIF_MASK)){};
/* clear RDCOLERR & ACCERR & FPVIOL flag in flash status register */
FLASH_FSTAT = FLASH_FSTAT_ACCERR_MASK | FLASH_FSTAT_FPVIOL_MASK | FLASH_FSTAT_RDCOLERR_MASK;
/* load FCCOB registers */
while(index--)
*ptrFccobReg++ = *ptrCommandObj++;
// launch a command
FLASH_FSTAT |= FLASH_FSTAT_CCIF_MASK;
// waiting for the finishing of the command
while(!(FLASH_FSTAT & FLASH_FSTAT_CCIF_MASK)){};
/* Check error bits */
/* Get flash status register value */
return (FLASH_FSTAT & (FLASH_FSTAT_ACCERR_MASK | FLASH_FSTAT_FPVIOL_MASK | FLASH_FSTAT_MGSTAT0_MASK));
}
One more question.
In AN2295SW file, they defined some indexes.
#define ERASE_BLOCK_INDEX 4
#define PROGRAM_LONGWORD_INDEX 8
#define PROGRAM_PHRASE_INDEX 12
Why ERASE BLOCK INDEX is 4 and why LONGWORD is 8 and phrase is 12?
Could you help me?
BR
Eunseok.
Hi Eunseok Jung,
FLASH_FlashCommandSequenceStart function is used for the flash command operation sequence.
As you know, every flash operation is using the according command to realize the flash operation function by write the FCCOBx register.
The index is means how many FCCOB register to control, the base address is defined as FLASH_BASE_PTR->FCCOB3:Just FCCOB3,
From our flash register table, you will know FCCOB3 is the base address of FCCOBn, just like the following:
#define ERASE_BLOCK_INDEX 4
#define PROGRAM_LONGWORD_INDEX 8
#define PROGRAM_PHRASE_INDEX 12
The index number should be the number of FCCOB registers which need to control.
(1)ERASE_BLOCK_INDEX 4 means Erase block is just control 4 FCCOB registers:
(2) PROGRAM_LONGWORD_INDEX 8 means this command should control 8 FCCOB registers:
(3) PORGRAM_PHASE_INDEX 12
I think it should be the Progarm check command, this command should control 12 FCCOB registers:
Please find more detals from our K10 reference manual, chapter 29 .
Wish it helps you!
Have a great day,
Jingjing
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Jung,
Please check the linker file ,the section".programbuff" is in which segment .
BR
Alice
Programbuff is in
m_programbuff (RW) : ORIGIN = 0x1FFF8000, LENGTH = 0x00001000
Is this the reason for writing in 0x1FFF8000?
I changed the region
m_programbuff (RW) : ORIGIN = 0x020000, LENGTH = 0x00001000.
But it is not working properly.
The debug always error when it run #define FLASH_FlashCommandSequence ((LWord (*)(Byte))&buffer[1]) command.
And what is m_text segment(or session?) What is written in here?
HIi,
Which IDE do you use ?
Mainly fcous on the "SECTION " part of Linker file .
Best Regards,
Alice
------------------------------------------------------------------------------------------
If this post answers your question, please click the Correct Answer button.
-----------------------------------------------------------------------------------
If this post help your question, please click the helpful Answer button.
I'm using CW10.3 with Multilink Universal.
I haven't SECTION part in the Linker file.
MEMORY {
m_interrupts (RX) : ORIGIN = 0x00000000, LENGTH = 0x000001BC
m_text (RX) : ORIGIN = 0x00000410, LENGTH = 0x0001FBF0
m_data (RW) : ORIGIN = 0x1FFF9000, LENGTH = 0x00007000
m_data_20000000 (RW) : ORIGIN = 0x20000000, LENGTH = 0x00008000
m_programbuff (RW) : ORIGIN = 0x00020000, LENGTH = 0x00001000
m_cfmprotrom (RX) : ORIGIN = 0x00000400, LENGTH = 0x00000010
}
My code has problem when it runs "The debug always error when it run #define FLASH_FlashCommandSequence ((LWord (*)(Byte))&buffer[1])" command.
Could you send your project to me ?
I uploaded my project file
Hi,
This is this the SECTION :
from this part , you can find the place of your ".programbuff" :
m_programbuff (RW) : ORIGIN = 0x00020000, LENGTH = 0x00001000
.........
.m_programbuff : AT(___m_programbuff_ROMStart)
{
. = ALIGN(4);
___m_programbuff_RAMStart = .;
*(.m_programbuff) /* This is an User defined section */
___m_programbuff_RAMEnd = .;
. = ALIGN(4);
} > m_programbuff
I paste your code
.m_programbuff : AT(___m_programbuff_ROMStart)
{
. = ALIGN(4);
___m_programbuff_RAMStart = .;
*(.m_programbuff) /* This is an User defined section */
___m_programbuff_RAMEnd = .;
. = ALIGN(4);
} > m_programbuff
in the section.
But the result is same. Error is same. It is not working....
Sorry you misunderstand me .
I just tell you how to check the Linker file, to find the setion ".programbuff" in it.
Now , i just find there is a error :
change this
__attribute__((section(".programbuff"))) Byte buffer[200];
to
__attribute__((section(".m_programbuff"))) Byte buffer[200];
.
And if still have question , please tell me what'e the problem , and what's your aim.
BR
Alice
My problem is occurred when i run "#define FLASH_FlashCommandSequence ((LWord (*)(Byte))&buffer[0])" . It makes error.
I want write some value at 0x00020000.
But this code can't write at 0x00020000.This code write value at 0x1FFF9040 instead of 0x00020000.
How can i write value at 0x00020000.
Thank you~
Hi,
I think the 0x1fff9040 is the address of your write_buffer[i] , please check.
And it seems that you have not erase the flash you want to write.
And if your aim is simple write data to flash , you can not use the bootlaoder , can simple configurate the linker file.
BR
Alice