新聞中心

        EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > Powerpc構(gòu)架系統(tǒng)內(nèi)核和內(nèi)核模塊調(diào)試

        Powerpc構(gòu)架系統(tǒng)內(nèi)核和內(nèi)核模塊調(diào)試

        作者: 時(shí)間:2012-07-25 來源:網(wǎng)絡(luò) 收藏

        說明:

        本文引用地址:http://www.104case.com/article/148724.htm

        此文檔的目標(biāo)為freescale MPC8349E-mITX,對(duì)其他采用powerPC,MIPS,ARM的芯片的亦具有參考意義。 此文檔中為了簡(jiǎn)化,采用目標(biāo)中的UBOOT初始化目標(biāo)板,并通過UBOOT或者BDI2000加載到目標(biāo)板的RAM中。

        1. BDI2000配置:

        下面是MPC8349E-mITX的BDI2000配置文件,

        ; BDI-2000 CONfiguraTIon file for the MPC8349E-mITX

        ; Tip: If after a reset, the BDI-2000 fails to halt at 0x100,

        ; you may need to power-down the bOArd for a few seconds.

        [INIT]

        ; we use UBOOT to initialize the board

        [TARGET]

        CPUTYPE 8349

        JTAGCLOCK 1

        ;STARTUP RESET

        STARTUP RUN

        BREAKMODE HARD

        STEPMODE HWBP

        BOOTADDR 0x00000100

        ;If you're getting Writing to workspace failed errors during flash operations,

        ;then try uncommenting this line instead. This moves the FLASH window to

        ;high memory, leaving low memory available for DDR.

        RCW 0xb060a000 0x04040000 ;Set the HRCW to boot the image at 0xFE000000

        MMU XLAT ;0xc0000000

        PTBASE 0xf0 ;

        [HOST]

        IP 192.168.7.90

        FILE $u-boot.bin

        LOAD MANUAL

        PROMPT 8349E-mITX-GP>

        DUMP itx-dump.bin

        [Flash]

        CHIPTYPE AM29BX16

        CHIPSIZE 0x800000

        BUSWIDTH 16

        ;WORKSPACE 0x1000

        FORMAT BIN 0xfe000000

        ;flash_image.bin is an image file of an entire 8MB flash region.

        ;Flash this file at 0xfe0000000 to restore all of flash.

        ;ERASE 0xFE000000 0x10000 127 ; 127 sectors @ 64KB each

        ;ERASE 0xFE7F0000 0x2000 8 ; 8 sectors @ 8KB each

        ;FILE $flash_image.bin

        ;Use these lines if you just want to flash U-Boot

        ERASE 0xfe000000 0x10000? 4; Erase 384KB, each sector is 64KB

        FILE? mpc8349e/u-boot131-mitx-gp.bin

        [REGS]

        FILE $reg8349e.def

        以上配置文件的【HOST】段的IP要改為主機(jī)IP,關(guān)鍵的字段MMU XLAT 和PTBASE 是POWERPC和MIPS經(jīng)常需要設(shè)置的,關(guān)于PTBASE的具體設(shè)置,超出本文范圍,詳細(xì)情況請(qǐng)參考BDI2000的手冊(cè)

        2.修改和配置

        為了能夠內(nèi)核,需要在內(nèi)核中的Makefile中增加如下選項(xiàng):

        CFLAGS 增加C代碼調(diào)試選項(xiàng)-g –ggdb

        AFLAGS 增加匯編代碼調(diào)試選項(xiàng):-Wa,-L -gdwarf-2

        去掉CFLAGS編譯選項(xiàng)中-fomit-frAME-pointer

        GCC的-fomit-frame-pointer選項(xiàng)是優(yōu)化函數(shù)棧回溯(stack backtrace)的,我們調(diào)試的時(shí)候需要提供函數(shù)回溯能力,所以我們要去掉這個(gè)選項(xiàng),當(dāng)然,有的系統(tǒng)系統(tǒng)不受它的影響,或者說它不起作用,為了統(tǒng)一,我們統(tǒng)一去掉它。

        相對(duì)個(gè)案來說,我是做如下改動(dòng)的:

        --- Makefile 2008-07-08 03:07:38.000000000 +0800

        +++ Makefile.debug 2008-07-08 03:06:04.000000000 +0800

        -CPPFLAGS := -D__KERNEL__ $(LINUXINCLUDE)

        +ifdef CONFIG_DEBUG_INFO

        +

        + CPPFLAGS := -D__KERNEL__ $(LINUXINCLUDE) -g -ggdb

        -CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs

        + CFLAGS := $(CPPFLAGS) -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs

        -fno-strict-aliasing -fno-common

        -AFLAGS := -D__ASSEMBLY__

        + AFLAGS := -D__ASSEMBLY__ -Wa,-L -gdwarf-2

        +else

        + CPPFLAGS := -D__KERNEL__ $(LINUXINCLUDE)

        + CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs

        + -fno-strict-aliasing -fno-common

        + AFLAGS := -D__ASSEMBLY__

        +

        +endif

        @@ -491,27 +500,33 @@

        # Defaults vmlinux but it is usually overridden in the arch makefile

        all: vmlinux

        -ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE

        -CFLAGS += -Os

        -else

        -CFLAGS += -O2

        -endif

        include $(srctree)/arch/$(ARCH)/Makefile

        -ifdef CONFIG_FRAME_POINTER

        -CFLAGS += -fno-omit-frame-pointer $(call cc-option,-fno-optimize-sibling-calls,)

        -else

        -CFLAGS += -fomit-frame-pointer

        -endif

        ifdef CONFIG_UNWIND_INFO

        CFLAGS += -fasynchronous-unwind-tables

        endif

        -ifdef CONFIG_DEBUG_INFO

        -CFLAGS += -g

        -endif

        +#ifdef CONFIG_DEBUG_INFO

        +CFLAGS += -fno-omit-frame-pointer $(call cc-option,-fno-optimize-sibling-calls,)

        +CFLAGS += -g -ggdb

        +CFLAGS += -O

        +#else

        +

        +# ifdef CONFIG_FRAME_POINTER

        + CFLAGS += -fno-omit-frame-pointer $(call cc-option,-fno-optimize-sibling-calls,)

        +# else

        + CFLAGS += -fomit-frame-pointer

        +# endif

        +

        +# ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE

        + CFLAGS += -Os

        +# else

        + CFLAGS += -O2

        +# endif

        +

        +#endif

        通過以上修改后,系統(tǒng)的的調(diào)試信息簡(jiǎn)單的通過CONFIG_DEBUG_INFO宏來控制了,那么CONFIG_DEBUG_INFO宏又是從哪里來的呢?它其實(shí)是從內(nèi)核的配置文件.config里面來的。

        一般內(nèi)核通過make menuconfig做配置的時(shí)候,都有

        Kernel hacking --->

        [*] Kernel debugging

        [*] Compile the kernel with debug info

        [*] Force gcc to inline functions marked 'inline' (2.6比較新的內(nèi)核有這一項(xiàng))


        上一頁 1 2 3 下一頁

        評(píng)論


        相關(guān)推薦

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

        關(guān)閉
        主站蜘蛛池模板: 肥城市| 洪洞县| 红河县| 延边| 镇远县| 龙江县| 布拖县| 汤原县| 唐河县| 定日县| 孟村| 天津市| 涿鹿县| 奈曼旗| 乡宁县| 高碑店市| 阿尔山市| 大城县| 扎鲁特旗| 阿拉善右旗| 衢州市| 宝丰县| 盐山县| 彭州市| 永嘉县| 崇信县| 安阳市| 开鲁县| 泸溪县| 南陵县| 宽甸| 晋江市| 托里县| 句容市| 内江市| 延安市| 阿荣旗| 额尔古纳市| 阿拉善右旗| 榆社县| 靖宇县|