Andes Workshop http://forum.andestech.com/ |
|
N1033的local memory 程式示範 http://forum.andestech.com/viewtopic.php?f=6&t=23 |
Page 1 of 1 |
Author: | cindy [ Sat Mar 12, 2011 1:16 pm ] |
Post subject: | N1033的local memory 程式示範 |
這個local memory的示範是BSP v3.0.0裡的範例程式startup-lm,我們要編譯前,必須修改makefile及nds32.ld。makefile只要改toolchain的路徑,nds32.ld必須要依照板子的local memory大小做修改。我的板子是32KB的ILM(instruction local memory)及32KB DLM(data local memory),所以我改成 0x08000。 Attachment: 程式startup-lm說明 這個程式要注意看的file有2個:main.c及nds32.ld nds32.ld設定程式的執行位址及local memory的位址。 AndeStar AndeStar™ System Priiviillege Archiitecture的文件在AndeSight或bsp的安裝目錄下有。我也放一份在這裡: Attachment: 從文件的9.4.7節可以知道設定instruction local memory, 必須把mr6這個register設為enabled,並且設定它的數值。 Attachment: local.gif [ 83.49 KiB | Viewed 13907 times ] 如果我們用gdb連進ICE下command,指令如下: set $mr6=0x01000001 表示ILM enabled,並且設定base=0x01000000 set $mr6=0x01000001 就是程式main.c裡下面這一段做的事情 Code: ilm_base = ilm_base + 1; /*mtsr $r1, $ilmb*/ __nds32__mtsr(ilm_base, NDS32_SR_ILMB); __nds32__dsb(); ilm_base = ilm_base - 1; 上面這一段程式將*.text區的資料copy到ILM裡面。 copy完成之後,將ILM的位址改為從0x0開始, 如此一來,從改位址以後的程式,實際上是跑在ILM裡面。 程式是下面這一段: Code: size = size + 1; __nds32__mtsr(size, NDS32_SR_ILMB); __nds32__dsb(); 上面這一段中,一開始size=0, 等同於gdb command的 set $mr6=0x1 設定ILM的起始位址為0,並且enabled它。 從此刻開始,程式是在ILM上執行。 |
Page 1 of 1 | All times are UTC + 8 hours [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |