中文字幕 另类精品,亚洲欧美一区二区蜜桃,日本在线精品视频免费,孩交精品乱子片免费

<sup id="3hn2b"></sup>

    1. <sub id="3hn2b"><ol id="3hn2b"></ol></sub><legend id="3hn2b"></legend>

      1. <xmp id="3hn2b"></xmp>

      2. 新聞中心

        EEPW首頁 > 模擬技術(shù) > 設(shè)計應用 > 如何在晶心平臺實作ROM patch

        如何在晶心平臺實作ROM patch

        作者: 時間:2012-07-27 來源:電子產(chǎn)品世界 收藏

          (2) patch在編譯之前,先匯入主程序的symbol table。(將export.txt檔案放在一起編譯)。Patch的linker script要匯入主程序的symbol,寫法如下面紅色字體。

        本文引用地址:http://www.antipu.com.cn/article/135126.htm

          ENTRY(_start)
          /* Do we need any of these for elf?
          __DYNAMIC = 0; */
          INCLUDE "..export.txt"
          SECTIONS
          {

          (3) patch的程序代碼里如下,沒有main function,也不要加入startup files。改寫func2。func2放在flash的FUNC_PATCH section。并且將jump_table里的func2,改成指向新的func2。

          #include
          #include
          extern int func1(int);
          extern int func3(int);
          int func2(int) __attribute__ ((section ("FUNC_PATCH")));
          extern int num2;

          typedef struct strfunptr {
          int (*func_a)(int);
          int (*func_b)(int);
          int (*func_c)(int);
          }sfptr;

          sfptr jump_table __attribute__ ((section ("FUNC_TABLE")))= {func1, func2, func3};

          int func2(int x){
          return x*num2*100;
          }

          (4) patch的linker script,加入FUNC_PATH在jump_table之后。

          FUNC_PATCH 0x510020 :
          {
          *(.FUNC_PATCH)
          }

          3. 如何除錯

          首先,將程序代碼存放在IC的及flash里。(本文為了示范,我們的做法是在AndeShape™ ADP-XC5的FPGA板上,用RAM模擬及flash,分別將主程序和patch的bin文件restore到板子上。)

          當gdb debug時,載入patch 的symbol。以下節(jié)錄gdb指令。

          core0(gdb) file mainprog.adx
          core0(gdb) add-symbol-file patch.adx 0x500000 -s FUNC_TABLE 0x510000 -s FUNC_PATCH 0x510020
          core0(gdb) set $pc=0x500000
          core0(gdb) b main
          Breakpoint 1 at 0x50010c: file ../main.c, line 20.
          core0(gdb) c
          Breakpoint 1, main () at ../main.c:20
          20 printf("func1(30)=%dn",jump_table.func_a(30));
          core0(gdb) s
          func1 (x=30) at ../main.c:28
          28 return x*num1;
          core0(gdb) n
          29 }
          core0(gdb) s
          main () at ../main.c:21
          21 printf("func2(30)=%dn",jump_table.func_b(30));
          core0(gdb) s
          func2 (x=30) at ../patchprog.c:24
          24 return x*num2*100;
          core0(gdb)

          上面過程中,先加載main的symbol,再加載patch的symbol及debug information。"add-symbol-file patch.adx 0x500000 -s FUNC_TABLE 0x510000 -s FUNC_PATCH 0x510020"是將patch section的symbol及debug information也載入gdb以debug。讀者可以在gdb里,打"help add-symbol-file"查閱add-symbol-file的用法。

          3.1 主程序patch后的執(zhí)行結(jié)果

          func1(30)=30
          func2(30)=6000
          func3(30)=90

          4. 結(jié)語

          目前科技使用GNU的toolchain,其功能非常強大。讀者可多動手試試不同的linker script寫法,使得開發(fā)firmware更有彈性及效率。


        上一頁 1 2 3 下一頁

        關(guān)鍵詞: 晶心 ROM

        評論


        相關(guān)推薦

        技術(shù)專區(qū)

        關(guān)閉