Linux Kerner training (1) Lauterbach and trace32 debug u-boot

 

LinuxKernel Training


Refrences:

$ git cloneGit://igloocommunity.org/git/kernerl/igloo-kerner.git

http://igloocommunity.org/support/Technical_documentation

https://wiki.linaro.org/Platform/Android

https://www.islief.com/mediawiki/index.php/Snowball

Kernel Source mainline

http://kernel.org

U-boot

git clone git://igloocommunity.org/git/boot/u-boot-ux500.git


Getting the first Open Source GSMstack in Linux;  this is an example from Marcin which develop an gsm proting on linux

This is my summary after training,  detail can see the video.

Lauterbach(H) ----- trace32(S)

 

Lauterbach UserGuide


preconditions,

1. u8500 snowboard

2. lauterbach emulator

install the software

sudo dpkg -i semc-trace32-sw_33438.1202091+git20120215.ad792810_amd64.deb

will be installed in /opt/t32 directory


Edit a shell to start trace32

start.sh
#!/bin/sh
xset +fp /opt/t32/fonts
xset fp rehash
/opt/t32/bin/pc_linux/t32marm -c /opt/t32/bin/pc_linux/config.t32 -s /opt/t32/demo/practice/t32.cmm


the content of config.t32,

;Generic config file for T32

OS=
ID=T32
TMP=/tmp
SYS=/opt/t32/

PBI=
USB
CORE=1

SCREEN=
FONT=SMALL
HEADER=Generic Trace32

LICENSE=/opt/t32/license.t32

t32.cmm will add some tool bar.


B::                         ; This presents that command in trace32

B:: cd ~snow                 ;entry your work path

B::do   start_core0.cmm              ;start-core0 do some context init

 start_core0.cmm,

; Start-Up Script for Cortex-A9 of A9500 on Snowball Board from ST Ericsson
; PEG, June 2011

  RESet
  SYStem.CPU A9500
  CORE.ASSIGN 1
  SYStem.Mode Attach
  if run()
      Break


download and compile u-boot

 

git clone git://igloocommunity.org/git/boot/u-boot-ux500.git


change u-boot delay time,

$ vim common/main.c

        s = getenv ("bootdelay");
        bootdelay = s ? (int)simple_strtol(s, NULL, 10) : CONFIG_BOOTDELAY;
        bootdelay = 10;

$make CROSS_COMPILE=arm-linux-gnueabi- distclean

$make  u8500_snowball_config

$make CROSS_COMPILE=arm-linux-gnueabi-       ;apt-cache arm-linux          if there is not, apt-get install arm-linux-gnueabi-



B::data.load u-boot-ux500/u-boot              ;load the symbol file

Here, we can reorder it like this,

1. power supply snowborad

2. B::do   start_core0.cmm                    ; here will stop, becauseif run() Break

3. B::data.load u-boot-ux500/u-boot

Next, start snowboard, minicom to connect the snowboard console.

  • minicom -D /dev/ttyUSB0 ( ls /dev/ttyUSB* to know what usbserial port is )
  • Type minicom -s to start it in setup mode.Select “serial port setup”and press 'a' to change the Serial Device to /dev/ttyUSB0.Press 'e' and select speed 115200 no parity 8 data bits ,one stop bit (1152008N1)and press enter. Select No hardware flow control and no software flow control.

in minicom console, will print out

CPU:    ST-Ericsson db8500 v2 (Dual ARM Cortex A9) 998.400 Mhz
I2C:   ready
DRAM:   1 GB
MMC:
MCDE:  startup failed
sec_bridge: ISSWAPI_FLUSH_BOOT_CODE: 2
EMMC: 0, MMC: 1
In:    serial
Out:   serial
Err:   serial
Net:   smc911x-0
Hit any key to stop autoboot:  7 


Hit any key, will go into snow emmc console,

Snowball $ version

U-Boot 2009.11-dirty (Apr 26 2012 - 15:02:02)
Snowball $ mmcinfo
Device: EMMC
Manufacturer ID: 13
OEM: 100
Name: Tran Speed: 25000000
Rd Block Len: 512
MMC version 4.0
High Capacity: Yes
Capacity: 3791650816
Bus Width: 8-bit


In B::data.list window, change the mode and find this line,

ldr     pc,_start_armboot      @jump to c code

Right click this line, select go till, will go to void start_armboot(void) entry point, this is the uboot start point. Or from menu, run->go till->   select start_armboot(void).


When "Loading kernek image...." appears in minicom console,  in Trace32, Break

B::do linux-attach.cmm,                  ;will start debug kernel after uboot

  WinCLEAR
  RESet
  SYStem.CPU A9500
 
  SYStem.Option DACR ON          ; give Debugger global write permissions
  TrOnchip.Set DABORT OFF        ; used by Linux for page miss!
  TrOnchip.Set PABORT OFF        ; used by Linux for page miss!
  TrOnchip.Set UNDEF OFF         ; my be used by Linux for FPU detection
  SYStem.Option MMUSPACES ON        ; enable space ids to virtual addresses
 
  TERM.METHOD COM COM4 115200. 8 NONE 1STOP NONE
  TERM.MODE VT100
  TERM.SCROLL ON
  TERM.SIZE 80 1000
  WINPOS 76.0 25.0 80. 24. 0. 0. TermWin
  SCREEN.ALWAYS
  TERM
      
 
  SYStem.Mode Attach  
 
  if run()
    Break
    
 
 
  ; Load the Linux kernel symbols into the debugger
  print "loading Linux kernel symbols..."
  Data.LOAD.Elf vmlinux /gnu /nocode
 
  ; Open a Code Window -- we like to see something
 
  WINPOS 0. 0. 75. 20.
  Data.List
  screen
 
 
  print "initializing debugger MMU..."
  MMU.FORMAT LINUX swapper_pg_dir 0xc0000000--0xdfffffff 0x00000000
  TRANSLATION.COMMON 0bf000000--0ffffffff            ; common area for kernel and processes
  TRANSLATION.TableWalk ON   ; debugger uses a table walk to decode virtual addresses
  TRANSlation.ON

 
  print "initializing multitask support..."
  TASK.CONFIG ~~/demo/arm/kernel/linux/linux       ; loads Linux awareness (linux.t32)
  MENU.ReProgram ~~/demo/arm/kernel/linux/linux    ; loads Linux menu (linux.men)
  HELP.FILTER.Add rtoslinux  ; add linux awareness manual to help filter
   
  sYmbol.Autoload.CHECKLINUX "do autoload.cmm "
 
  Go  


seems the upper B::do linux-attach.cmm  step is not needed.

Download and compile kernel

$ git clone git://igloocommunity.org/git/kernel/igloo-kernel.git

$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- u8500_android_defconfig 

$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- menuconfig       ;;裁剪kernel

$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- uImage -j3     ;; 生成image

$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- modules     ;; compile modules

B::data.load vmlinux  /nocode          ;load kernel ELF file

in B::sYmbol.Browse window, can see start_kernel function

at the below picture, we can see the break impl isSOFT,  right click it, must change it to Onchip, otherwise, can not go till start_kerner(void).



 

Below is come records I did, can read it as  a reference.


加載自己的uboot

u-boot.bin

in Trace32 tools,

d.dump 0x56000

d.l 0x56000

加載ubootram

B:: data.load u-boot/u-boot.bin 0x5600000

;load it into start point address 0x5600000


File->set PC here “0x56000”

$ cd u-boot

$ readelf –h u-boot

ELF Header:
  Magic:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
  Class:                             ELF32
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              DYN (Shared object file)
  Machine:                           ARM
  Version:                           0x1
  Entry point address:               0x0
  Start of program headers:          52 (bytes into file)
  Start of section headers:          563080 (bytes into file)
  Flags:                             0x5000000, Version5 EABI
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         2
  Size of section headers:           40 (bytes)
  Number of section headers:         23
  Section header string table index: 20

B::data.load u-boot/u-boot

B::y.b

#listsymbole


readelf -h vmlinux

ELF Header:
  Magic:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
  Class:                             ELF32
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           ARM
  Version:                           0x1
  Entry point address:               0xc0008000
  Start of program headers:          52 (bytes into file)
  Start of section headers:          91517696 (bytes into file)
  Flags:                             0x5000002, has entry point, Version5 EABI
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         3
  Size of section headers:           40 (bytes)
  Number of section headers:         39
  Section header string table index: 36



編譯uboot可以選擇不優化notoptimizeOPTFLAGS -o0,這樣跟蹤時可以line by line to go


啓動trace32的模擬器模式

./t32marm -c config_sim.t32

cp config.732 to config_sim.t32, change PBI=USB to PBI=SIM

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章