Hard fault calling function in RAM

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Hard fault calling function in RAM

ソリューションへジャンプ
2,197件の閲覧回数
marlonsmith
Contributor IV

Hi everyone,

I'm working on a flash driver for a K20 chip, and since it only has one page of memory I believe I have to move my sector erase function to RAM so I'm not accessing the bank while erasing part of it.  I'm using GCC and a custom linker script for my project.

So far I've done this:

- Use the attribute label to tell the linker to put the function in RAM:

bool erase_sector(uint32_t address) __attribute__((long_call, section(".ramfunctions")));

- and in the linker script:

. = 0x1FFFE000;

  .data ()   :

  {

    __data_start = . ;

    __data_start__ = .;

    *(.data .data.* .gnu.linkonce.d.*)

    . = ALIGN(32 / 8);

    SORT(CONSTRUCTORS)

    . = ALIGN(32 / 8);

    *(.ramfunctions) /* Place specified functions in RAM */

  }


- Add -mlong-calls to my compiler arguments

However when I run my code, I get a hard fault as soon as I call my erase_sector function.  Is there another step here that I'm missing?

Thanks!

Marlon

ラベル(1)
タグ(2)
0 件の賞賛
返信
1 解決策
1,484件の閲覧回数
JimDon
Senior Contributor III

All flash code that I have seen or written copies the routine from flash to ram explicitly.

It is considered unsafe to jump to code in ram that is put there by the C runtime initialization code, and it is not very portable.

So, you will be a pioneer.

You can use PE to generate flashing code - for Kinetis it copies it to a ram buffer. For coldfire it uses the stack.

元の投稿で解決策を見る

0 件の賞賛
返信
2 返答(返信)
1,485件の閲覧回数
JimDon
Senior Contributor III

All flash code that I have seen or written copies the routine from flash to ram explicitly.

It is considered unsafe to jump to code in ram that is put there by the C runtime initialization code, and it is not very portable.

So, you will be a pioneer.

You can use PE to generate flashing code - for Kinetis it copies it to a ram buffer. For coldfire it uses the stack.

0 件の賞賛
返信
1,484件の閲覧回数
marlonsmith
Contributor IV

Thanks for reply Jim.  I created a separate section in the linker script for this purpose and then modified my startup code to copy the functions to RAM, and it seems to be working for me now.

Thanks for the help.

Marlon

0 件の賞賛
返信