Lpc54102 iap ram to flash

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

Lpc54102 iap ram to flash

跳至解决方案
1,217 次查看
svensavic
Contributor III

I am trying to make a secondary bootloader and I have issues copying data from RAM to flash.

I prepared the sector (command 50), erased the page I want to write into. No errors up to this point.  Then when I call (command 51) write RAM to Flash, I get return value = 2. “Ram address not a word (or something like that).” Buffer address is at location 0x02000082 (read from debugger). Page I want to write into is 0x00008000 and data buffer is 256 bytes long.

What could be the cause of this error?

i read in user manual that I need to disable ISR. Is that just a case of having all NVIC ISR=0 or there is something else that needs to be disabled?

标签 (1)
0 项奖励
回复
1 解答
1,018 次查看
converse
Senior Contributor V

You can never rely on hope for alignment!

instead use the compiler directive when declaring the variable

__attribute__ ((aligned (4)))

Place the directive before your declaration. 

See here for more information 

Using the GNU Compiler Collection (GCC) 

在原帖中查看解决方案

4 回复数
1,018 次查看
converse
Senior Contributor V

Your ram needs to be 4-byte (word) aligned. So, the address needs to end with a 0,4,8, or C. Your address is only 2-byte aligned.

0 项奖励
回复
1,018 次查看
svensavic
Contributor III

I see. Is that the start address requirement or end address? I dont have idea how to force static allocation of buffer at certain location.. I suppose by shuffling variable position in the code? Will that address be guaranteed when optimizer kicks in? Or is there a way to guard part of memory that I need for my buffer?

I am writting the code in C. 

0 项奖励
回复
1,019 次查看
converse
Senior Contributor V

You can never rely on hope for alignment!

instead use the compiler directive when declaring the variable

__attribute__ ((aligned (4)))

Place the directive before your declaration. 

See here for more information 

Using the GNU Compiler Collection (GCC) 

1,018 次查看
svensavic
Contributor III

That is handy to have cheatsheet. Thanks for that.

0 项奖励
回复