微處理器 - Allwinner F1C100S (荔枝派Nano) - 如何使用J-Link GDB Server和IDA Pro除錯程式



參考資訊:
https://whycan.com/t_1003.html
https://whycan.com/t_2025.html
https://whycan.com/files/members/3/TF_SDNAND_JTAG_V002.pdf
https://github.com/nminaylov/F1C100s_info/blob/master/JTAG/allwinner_f1c100s.cfg

F1C100S JTAG腳位(和MicroSD共用腳位)

TMSPF0, SDC0_D1
TDIPF1, SDC0_D0
TDOPF3, SDC0_CMD
TCKPF5, SDC0_D2

連接J-Link


main.s

    .global _start
  
    .equ GPIO_BASE, 0x01c20800 
    .equ PE_CFG0,   (GPIO_BASE + (4 * 0x24) + 0x00)
    .equ PE_DATA,   (GPIO_BASE + (4 * 0x24) + 0x10)
   
    .arm
    .text
_start:    b reset
_undef:    b .
_swi:      b .
_pabort:   b .
_dabort:   b .
_reserved: b .
_irq:      b .
_fiq:      b .

reset:
    ldr r0, =PE_CFG0
    ldr r1, =0x00010000
    str r1, [r0]
 
    ldr r0, =PE_DATA
0:
    eor r1, #0x10
    str r1, [r0]
    b 0b
    .end

main.ld

MEMORY {
    RAM : ORIGIN = 0, LENGTH = 32K
}

SECTIONS {
    text : {
        *(.text*)
    } > RAM
}

編譯

$ arm-none-eabi-as -mcpu=arm9 -o main.o main.s
$ arm-none-eabi-ld -T main.ld -o main.elf main.o
$ arm-none-eabi-objcopy -O binary main.elf main.bin

下載程式到RAM(loadbin c:\main.bin 0)


開啟J-Link GDB Server(Init registers記得勾選)


選擇ARM 9


Listening on TCP/IP port 2331


IDA Pro載入main.bin


按下F9,選擇Remote GDB debugger


按下F9,輸入localhost 2331


接著就可以開始除錯程式