Andes Workshop

It is currently Wed Apr 08, 2020 2:53 pm

All times are UTC + 8 hours [ DST ]




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: N1033的local memory 程式示範
PostPosted: Sat Mar 12, 2011 1:16 pm 
Offline
User avatar

Joined: Fri Mar 04, 2011 9:36 pm
Posts: 500
這個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-lm1.zip [51.85 KiB]
Downloaded 872 times




程式startup-lm說明
這個程式要注意看的file有2個:main.c及nds32.ld
nds32.ld設定程式的執行位址及local memory的位址。

AndeStar AndeStar™ System Priiviillege Archiitecture的文件在AndeSight或bsp的安裝目錄下有。我也放一份在這裡:
Attachment:
AndeStar_SPA_UM026_V1.4.pdf [4.86 MiB]
Downloaded 832 times


從文件的9.4.7節可以知道設定instruction local memory,
必須把mr6這個register設為enabled,並且設定它的數值。
Attachment:
local.gif
local.gif [ 83.49 KiB | Viewed 8615 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上執行。


Top
 Profile Send private message E-mail  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group