2011年5月25日 星期三

Build WLAN driver and Android Filesystem

1) Patch

Because there are too many warnings when building WLAN drivers. So I turn off the -Werror command line option in the EXTRA_CFLAGS, like

EXTRA_CFLAGS += -fsigned-char
#EXTRA_CFLAGS += -fsigned-char -Werror

Modified files:
1. /opt/L27.12.1-P2/mydroid/hardware/ti/wlan/wl1283/stad/build/linux/common.inc
2. /opt/L27.12.1-P2/mydroid/hardware/ti/wlan/

2) Script used to build WLAN drivers and Android Filesystem

#!/bin/bash
MYDROID=/opt/L27.12.1-P2/mydroid

mkdir -p logs
export KERNEL_DIR=/opt/L27.12.1-P2/kernel/android-2.6.35

# Build 127x station driver
cd $MYDROID/hardware/ti/wlan/wl1283/platforms/os/linux
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- TNETW=1273

# Build 127x softAp driver
cd $MYDROID/hardware/ti/wlan/wl1283_softAP/platforms/os/linux
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- TNETW=1273

cd $MYDROID
cp -Rfp device/ti/pandaboard/buildspec.mk.default buildspec.mk
#(required for rebuild only)
make clean
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- -j4 2>&1 |tee $MYDROID/logs/android_make.out

3) Finally, build errors

host StaticLib: libunz (out/host/linux-x86/obj/STATIC_LIBRARIES/libunz_intermediates/libunz.a)
echo out/host/linux-x86/obj/STATIC_LIBRARIES/libunz_intermediates/adler32.o out/host/linux-x86/obj/STATIC_LIBRARIES/libunz_intermediates/crc32.o out/host/linux-x86/obj/STATIC_LIBRARIES/libunz_intermediates/zutil.o out/host/linux-x86/obj/STATIC_LIBRARIES/libunz_intermediates/inflate.o out/host/linux-x86/obj/STATIC_LIBRARIES/libunz_intermediates/inftrees.o out/host/linux-x86/obj/STATIC_LIBRARIES/libunz_intermediates/inffast.o | xargs ar crsP  out/host/linux-x86/obj/STATIC_LIBRARIES/libunz_intermediates/libunz.a
host SharedLib: libfst (out/host/linux-x86/obj/lib/libfst.so)
host StaticLib: libtinyxml (out/host/linux-x86/obj/STATIC_LIBRARIES/libtinyxml_intermediates/libtinyxml.a)
echo out/host/linux-x86/obj/STATIC_LIBRARIES/libtinyxml_intermediates/tinyxml.o out/host/linux-x86/obj/STATIC_LIBRARIES/libtinyxml_intermediates/tinyxmlparser.o out/host/linux-x86/obj/STATIC_LIBRARIES/libtinyxml_intermediates/tinyxmlerror.o out/host/linux-x86/obj/STATIC_LIBRARIES/libtinyxml_intermediates/tinystr.o | xargs ar crsP  out/host/linux-x86/obj/STATIC_LIBRARIES/libtinyxml_intermediates/libtinyxml.a
host Executable: adb (out/host/linux-x86/obj/EXECUTABLES/adb_intermediates/adb)
/usr/bin/ld: skipping incompatible /usr/lib/libncurses.so when searching for -lncurses
/usr/bin/ld: skipping incompatible /usr/lib/libncurses.a when searching for -lncurses
/usr/bin/ld: cannot find -lncurses
collect2: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/EXECUTABLES/adb_intermediates/adb] Error 1
make: *** Waiting for unfinished jobs....
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/libstdc++.so when searching for -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/libstdc++.a when searching for -lstdc++
/usr/bin/ld: cannot find -lstdc++
collect2: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl] Error 1
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/libstdc++.so when searching for -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/libstdc++.a when searching for -lstdc++
/usr/bin/ld: cannot find -lstdc++
collect2: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/lib/libESR_Portable.so] Error 1
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/libstdc++.so when searching for -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/libstdc++.a when searching for -lstdc++
/usr/bin/ld: cannot find -lstdc++
collect2: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/lib/libfst.so] Error 1
mingfeng@mingfeng-desktop:/opt/L27.12.1-P2/mydroid$

Build linux kernel (android-2.6.35)

1) Script used to build android-2.6.35

#!/bin/bash
# build kernel image
mkdir -p ./logs

#"mkimage" is located in your u-boot/tools/ directory.
export PATH=/opt/L27.12.1-P2/u-boot/tools:$PATH

#(required for rebuild only)
make ARCH=arm distclean
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- CFLAGS="-march=armv7-a+sec" panda_defconfig
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- uImage 2>&1 |tee ./logs/kernel_make.out

# build kernel modules
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- modules 2>&1 |tee ./logs/kernel_modules.out


2) Error

  CC      security/smc/omap4/scxlnx_device_mshield.o
In file included from security/smc/omap4/scxlnx_util.h:29:0,
                 from security/smc/omap4/scxlnx_device_mshield.c:38:
include/linux/pagemap.h: In function 'fault_in_pages_readable':
include/linux/pagemap.h:415:16: warning: variable 'c' set but not used [-Wunused-but-set-variable]
  AS      security/smc/omap4/bridge_pub2sec.o
security/smc/omap4/bridge_pub2sec.S: Assembler messages:
security/smc/omap4/bridge_pub2sec.S:95: Error: selected processor does not support ARM mode `smc #0'
make[3]: *** [security/smc/omap4/bridge_pub2sec.o] Error 1
make[2]: *** [security/smc/omap4] Error 2
make[1]: *** [security/smc] Error 2
make: *** [security] Error 2
mingfeng@mingfeng-desktop:/opt/L27.12.1-P2/kernel/android-2.6.35$


3) Patch

--- security/smc/omap4/bridge_pub2sec.S.orig    2011-05-25 20:24:21.649675315 +0800
+++ security/smc/omap4/bridge_pub2sec.S 2011-05-25 20:26:39.429877396 +0800
@@ -74,6 +74,7 @@
        b       label_smc

 label_smc:
+       .arch_extension sec
        INVALIDATE_BTB
        dsb
        dmb



4) Audio fixes for kernel
cd ${YOUR_PATH}/L27.12.1-P2/kernel/android-2.6.35
git fetch http://review.omapzoom.org/p/kernel/omap refs/changes/01/13001/2 && git cherry-pick FETCH_HEAD
git fetch http://review.omapzoom.org/p/kernel/omap refs/changes/02/13002/2 && git cherry-pick FETCH_HEAD


5) EHCI fixes for kernel
cd ${YOUR_PATH}/L27.12.1-P2/kernel/android-2.6.35
git fetch http://review.omapzoom.org/p/kernel/omap refs/changes/17/13617/1 && git cherry-pick FETCH_HEAD


6) WLAN patches
Apply the following patches to enable wlan
cd ${YOUR_PATH}/L27.12.1-P2/kernel/android-2.6.35
git fetch http://review.omapzoom.org/p/kernel/omap refs/changes/02/12002/2 && git cherry-pick FETCH_HEAD
git fetch http://review.omapzoom.org/p/kernel/omap refs/changes/03/12003/1 && git cherry-pick FETCH_HEAD



7) patch for panda_defconfig

diff --git a/arch/arm/configs/panda_defconfig b/arch/arm/configs/panda_defconfig
index 2adf851..9d574e1 100644
--- a/arch/arm/configs/panda_defconfig
+++ b/arch/arm/configs/panda_defconfig
@@ -290,7 +290,6 @@ CONFIG_OMAP_DM_TIMER=y
 # CONFIG_OMAP_PM_NONE is not set
 # CONFIG_OMAP_PM_NOOP is not set
 CONFIG_OMAP_PM=y
-CONFIG_OMAP_HDMI_AUDIO_WA=y

 #
 # OMAP Board Type
@@ -808,6 +807,7 @@ CONFIG_KERNEL_DEBUGGER_CORE=y
 # CONFIG_SENSORS_TSL2550 is not set
 # CONFIG_SENSORS_BH1780 is not set
 # CONFIG_SENSORS_AK8975 is not set
+# CONFIG_TWL6040_VIB is not set
 # CONFIG_CDC_TCXO is not set
 # CONFIG_DS1682 is not set
 # CONFIG_TI_DAC7512 is not set
@@ -830,7 +830,7 @@ CONFIG_UID_STAT=y
 #
 # Texas Instruments shared transport line discipline
 #
-CONFIG_TI_ST=m
+CONFIG_TI_ST=y
 CONFIG_HAVE_IDE=y
 # CONFIG_IDE is not set

@@ -888,7 +888,8 @@ CONFIG_KS8851=y
 # CONFIG_USB_KAWETH is not set
 # CONFIG_USB_PEGASUS is not set
 # CONFIG_USB_RTL8150 is not set
-# CONFIG_USB_USBNET is not set
+CONFIG_USB_USBNET=y
+CONFIG_USB_NET_SMSC95XX=y
 # CONFIG_USB_HSO is not set
 # CONFIG_USB_IPHETH is not set
 # CONFIG_WAN is not set
@@ -1275,7 +1276,7 @@ CONFIG_SSB_POSSIBLE=y
 #
 # CONFIG_SSB is not set
 CONFIG_MFD_SUPPORT=y
-# CONFIG_MFD_CORE is not set
+CONFIG_MFD_CORE=y
 # CONFIG_MFD_88PM860X is not set
 # CONFIG_MFD_SM501 is not set
 # CONFIG_MFD_ASIC3 is not set
@@ -1291,7 +1292,7 @@ CONFIG_TWL4030_CORE=y
 CONFIG_TWL6030_PWM=y
 CONFIG_TWL6030_POWEROFF=y
 CONFIG_TWL6030_GPADC=y
-# CONFIG_TWL6040_CODEC is not set
+CONFIG_TWL6040_CODEC=y
 # CONFIG_MFD_TMIO is not set
 # CONFIG_MFD_T7L66XB is not set
 # CONFIG_MFD_TC6387XB is not set
@@ -1368,7 +1369,6 @@ CONFIG_VIDEO_HELPER_CHIPS_AUTO=y
 CONFIG_VIDEO_IR_I2C=y
 # CONFIG_VIDEO_VIVI is not set
 CONFIG_VIDEO_OMAP2_VOUT=y
-CONFIG_VIDEO_OMAP_GFX=m
 # CONFIG_VIDEO_SAA5246A is not set
 # CONFIG_VIDEO_SAA5249 is not set
 # CONFIG_SOC_CAMERA is not set
@@ -1553,7 +1553,49 @@ CONFIG_LOGO=y
 CONFIG_LOGO_LINUX_MONO=y
 CONFIG_LOGO_LINUX_VGA16=y
 CONFIG_LOGO_LINUX_CLUT224=y
-# CONFIG_SOUND is not set
+CONFIG_SOUND=y
+# CONFIG_SOUND_OSS_CORE is not set
+CONFIG_SND=y
+CONFIG_SND_TIMER=y
+CONFIG_SND_PCM=y
+CONFIG_SND_JACK=y
+# CONFIG_SND_SEQUENCER is not set
+# CONFIG_SND_MIXER_OSS is not set
+# CONFIG_SND_PCM_OSS is not set
+# CONFIG_SND_HRTIMER is not set
+CONFIG_SND_DYNAMIC_MINORS=y
+CONFIG_SND_SUPPORT_OLD_API=y
+CONFIG_SND_VERBOSE_PROCFS=y
+# CONFIG_SND_VERBOSE_PRINTK is not set
+# CONFIG_SND_DEBUG is not set
+# CONFIG_SND_RAWMIDI_SEQ is not set
+# CONFIG_SND_OPL3_LIB_SEQ is not set
+# CONFIG_SND_OPL4_LIB_SEQ is not set
+# CONFIG_SND_SBAWE_SEQ is not set
+# CONFIG_SND_EMU10K1_SEQ is not set
+CONFIG_SND_DRIVERS=y
+# CONFIG_SND_DUMMY is not set
+# CONFIG_SND_MTPAV is not set
+# CONFIG_SND_SERIAL_U16550 is not set
+# CONFIG_SND_MPU401 is not set
+CONFIG_SND_ARM=y
+CONFIG_SND_SPI=y
+CONFIG_SND_USB=y
+# CONFIG_SND_USB_AUDIO is not set
+# CONFIG_SND_USB_UA101 is not set
+# CONFIG_SND_USB_CAIAQ is not set
+CONFIG_SND_SOC=y
+CONFIG_SND_OMAP_SOC=y
+CONFIG_SND_OMAP_SOC_ABE_DSP=y
+CONFIG_SND_OMAP_SOC_MCBSP=y
+CONFIG_SND_OMAP_SOC_MCPDM=y
+CONFIG_SND_OMAP_SOC_ABE=y
+CONFIG_SND_OMAP_SOC_VXREC=y
+CONFIG_SND_OMAP_SOC_OMAP4_PANDA=y
+CONFIG_SND_SOC_I2C_AND_SPI=y
+# CONFIG_SND_SOC_ALL_CODECS is not set
+CONFIG_SND_SOC_TWL6040=y
+# CONFIG_SOUND_PRIME is not set
 CONFIG_HID_SUPPORT=y
 CONFIG_HID=y
 # CONFIG_HIDRAW is not set
@@ -1633,7 +1675,8 @@ CONFIG_USB_OTG=y
 # USB Host Controller Drivers
 #
 # CONFIG_USB_C67X00_HCD is not set
-# CONFIG_USB_EHCI_HCD is not set
+CONFIG_USB_EHCI_HCD=y
+CONFIG_USB_EHCI_ROOT_HUB_TT=y
 # CONFIG_USB_OXU210HP_HCD is not set
 # CONFIG_USB_ISP116X_HCD is not set
 # CONFIG_USB_ISP1760_HCD is not set

Build x-loader

1) Script used to build x-loader

#!/bin/bash
mkdir -p ./logs
make distclean  
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- CFLAGS="-Wa,-march=armv7-a+sec" omap4430panda_config
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- ift 2>&1 | tee ./logs/x-loader_make.out


2) Error

arm-none-linux-gnueabi-gcc -Wa,-gstabs -D__ASSEMBLY__ -g  -Os   -fno-strict-aliasing  -fno-common -ffixed-r8 -msoft-float  -D__KERNEL__ -DTEXT_BASE=0x40304350 -I/opt/L27.12.1-P2/x-loader/include -fno-builtin -ffreestanding -nostdinc -isystem /opt/build/arm-none-linux-gnueabi-4.6.0/lib/gcc/arm-none-linux-gnueabi/4.6.0/include -pipe  -DCONFIG_ARM -D__ARM__ -march=armv7-a -mabi=apcs-gnu -c -o smc.o /opt/L27.12.1-P2/x-loader/cpu/omap4/smc.S
/opt/L27.12.1-P2/x-loader/cpu/omap4/smc.S: Assembler messages:
/opt/L27.12.1-P2/x-loader/cpu/omap4/smc.S:40: Error: selected processor does not support ARM mode `smc #0'
make[1]: *** [smc.o] Error 1
make[1]: Leaving directory `/opt/L27.12.1-P2/x-loader/cpu/omap4'
make: *** [cpu/omap4/libomap4.a] Error 2
mingfeng@mingfeng-desktop:/opt/L27.12.1-P2/x-loader$

3) Patches

--- x-loader/cpu/omap4/smc.S.orig       2011-05-25 20:06:00.188059813 +0800
+++ x-loader/cpu/omap4/smc.S    2011-05-25 20:04:02.757887581 +0800
@@ -29,6 +29,7 @@
  * @arg: Argument passed to ROM api (input in r1 will move to r0) 
  */  
 .globl omap_smc_rom
+.arch_extension sec
 omap_smc_rom:
        push {r4-r11,lr}
        mov     r12,    r0

4) Build successfully

mingfeng@mingfeng-desktop:/opt/L27.12.1-P2/x-loader$ ls -la
總計 288
drwxr-xr-x 13 mingfeng mingfeng  4096 2011-05-25 20:09 .
drwxr-xr-x  6 mingfeng mingfeng  4096 2011-05-25 20:12 ..
-rw-r--r--  1 mingfeng mingfeng   908 2011-05-17 23:43 arm_config.mk
drwxr-xr-x 10 mingfeng mingfeng  4096 2011-05-17 23:43 board
-rwxr-xr-x  1 mingfeng mingfeng   242 2011-05-25 20:09 build.sh
drwxr-xr-x  2 mingfeng mingfeng  4096 2011-05-25 20:08 common
-rw-r--r--  1 mingfeng mingfeng  5260 2011-05-17 23:43 config.mk
drwxr-xr-x  6 mingfeng mingfeng  4096 2011-05-17 23:43 cpu
drwxr-xr-x  2 mingfeng mingfeng  4096 2011-05-25 20:08 disk
drwxr-xr-x  2 mingfeng mingfeng  4096 2011-05-25 20:08 drivers
drwxr-xr-x  3 mingfeng mingfeng  4096 2011-05-17 23:43 fs
drwxr-xr-x  8 mingfeng mingfeng  4096 2011-05-17 23:43 .git
-rw-r--r--  1 mingfeng mingfeng   520 2011-05-17 23:43 .gitignore
drwxr-xr-x  5 mingfeng mingfeng  4096 2011-05-25 20:08 include
drwxr-xr-x  2 mingfeng mingfeng  4096 2011-05-25 20:08 lib
drwxr-xr-x  2 mingfeng mingfeng  4096 2011-05-18 22:17 logs
-rw-r--r--  1 mingfeng mingfeng  7529 2011-05-17 23:43 Makefile
-rwxr-xr-x  1 mingfeng mingfeng  1122 2011-05-17 23:43 mkconfig
-rw-r--r--  1 mingfeng mingfeng 21920 2011-05-25 20:08 MLO
-rw-r--r--  1 mingfeng mingfeng  3935 2011-05-17 23:43 README
drwxr-xr-x  2 mingfeng mingfeng  4096 2011-05-17 23:43 scripts
-rwxr-xr-x  1 mingfeng mingfeng  9642 2011-05-25 20:08 signGP
-rw-r--r--  1 mingfeng mingfeng  3279 2011-05-25 20:08 System.map
-rwxr-xr-x  1 mingfeng mingfeng 93779 2011-05-25 20:08 x-load
-rwxr-xr-x  1 mingfeng mingfeng 21400 2011-05-25 20:08 x-load.bin
-rw-r--r--  1 mingfeng mingfeng 21920 2011-05-25 20:08 x-load.bin.ift
-rw-r--r--  1 mingfeng mingfeng 29031 2011-05-25 20:08 x-load.map
mingfeng@mingfeng-desktop:/opt/L27.12.1-P2/x-loader$

2011年5月18日 星期三

Building u-boot and x-loader

Pre-requisite packages for build Android Filesystem (Note this is with reference to uBuntu 8.04)
If you are behind firewall, you will have to set-up firewall using the instructions in Support Tools
For higher versions of U-buntu please refer to Host PC COnfiguration
The following commands will install the correct packages to your server:
sudo apt-get install git-core flex bison gperf libesd0-dev libwxgtk2.6-dev zlib1g-dev build-essential libstdc++5 tofrodos
sudo apt-get install x-dev (*** no files existing ***)
sudo apt-get install libx11-dev
sudo apt-get install libncurses5-dev
sudo apt-get install sun-java5-jdk (*** no files existing ***)

If you do not have sudo rights to your machine, contact your System Administrator for assistance. Google has issued that “sun-java6-jdk” has become unsupported: “because of incompatibilities with @Override” To uninstall “sun-java6-jdk” please type:
sudo apt-get remove sun-java6-jdk
“Intrepid (8.10) users may need a newer version of libreadline:
sudo apt-get install lib32readline5-dev” 
1) script used to build u-boot:
#!/bin/bash
make distclean
mkdir -p ./logs
make ARCH=arm omap4430panda_config
make 2>&1 |tee ./logs/u-boot_make.out
2) script used to build x-loader:
#!/bin/bash
mkdir -p ./logs
make distclean  
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- omap4430panda_config
make CROSS_COMPILE=arm-none-linux-gnueabi- ift 2>&1 |tee ./logs/x-loader_make.out
Finally, I built u-boot successfully, but there is an error when I
built the x-loader.
find . -type f \
                \( -name 'core' -o -name '*.bak' -o -name '*~' \
                -o -name '*.o'  -o -name '*.a'  \) -print \
                | xargs rm -f
find . -type f \
                \( -name .depend -o -name '*.srec' -o -name '*.bin' \) \
                -print \
                | xargs rm -f
rm -f cpu/omap4/start.o *.bak tags TAGS
rm -fr *.*~
rm -f x-load x-load.map x-load.bin System.map x-load.bin.ift signGP MLO
rm -f include/asm/proc include/asm/arch
rm -f include/config.h include/config.mk
rm -f include/config.h include/config.mk
Configuring for omap4430panda board...
echo "/* Generarated file. Do not edit */" >./include/config.h
echo "#include <configs/omap4430panda.h>" >>./include/config.h
MPU at 1GHz revision..
arm-none-linux-gnueabi-gcc -Wa,-gstabs -D__ASSEMBLY__ -g  -Os   -fno-strict-aliasing  -fno-common -ffixed-r8 -msoft-float  -D__KERNEL__ -DTEXT_BASE=0x40304350 -I/opt/L27.12.1-P2/x-loader/include -fno-builtin -ffreestanding -nostdinc -isystem /opt/build/arm-none-linux-gnueabi-4.6.0/lib/gcc/arm-none-linux-gnueabi/4.6.0/include -pipe  -DCONFIG_ARM -D__ARM__ -march=armv7-a -mabi=apcs-gnu -c -o cpu/omap4/start.o /opt/L27.12.1-P2/x-loader/cpu/omap4/start.S
make -C `dirname board/omap4430panda/libomap4430panda.a`
make[1]: Entering directory `/opt/L27.12.1-P2/x-loader/board/omap4430panda'
arm-none-linux-gnueabi-gcc -M -g  -Os   -fno-strict-aliasing  -fno-common -ffixed-r8 -msoft-float  -D__KERNEL__ -DTEXT_BASE=0x40304350 -I/opt/L27.12.1-P2/x-loader/include -fno-builtin -ffreestanding -nostdinc -isystem /opt/build/arm-none-linux-gnueabi-4.6.0/lib/gcc/arm-none-linux-gnueabi/4.6.0/include -pipe  -DCONFIG_ARM -D__ARM__ -march=armv7-a -mabi=apcs-gnu  omap4430panda.c | \
                        sed -e "s/\:/\\\:/g"|sed -e "s/\\\: /\: /g"> .depend
make[1]: Leaving directory `/opt/L27.12.1-P2/x-loader/board/omap4430panda'
make[1]: Entering directory `/opt/L27.12.1-P2/x-loader/board/omap4430panda'
arm-none-linux-gnueabi-gcc -g  -Os   -fno-strict-aliasing  -fno-common -ffixed-r8 -msoft-float  -D__KERNEL__ -DTEXT_BASE=0x40304350 -I/opt/L27.12.1-P2/x-loader/include -fno-builtin -ffreestanding -nostdinc -isystem /opt/build/arm-none-linux-gnueabi-4.6.0/lib/gcc/arm-none-linux-gnueabi/4.6.0/include -pipe  -DCONFIG_ARM -D__ARM__ -march=armv7-a -mabi=apcs-gnu -Wall -Wstrict-prototypes -c -o omap4430panda.o omap4430panda.c
arm-none-linux-gnueabi-ar crv libomap4430panda.a omap4430panda.o
a - omap4430panda.o
make[1]: Leaving directory `/opt/L27.12.1-P2/x-loader/board/omap4430panda'
make -C `dirname cpu/omap4/libomap4.a`
make[1]: Entering directory `/opt/L27.12.1-P2/x-loader/cpu/omap4'
arm-none-linux-gnueabi-gcc -M -g  -Os   -fno-strict-aliasing  -fno-common -ffixed-r8 -msoft-float  -D__KERNEL__ -DTEXT_BASE=0x40304350 -I/opt/L27.12.1-P2/x-loader/include -fno-builtin -ffreestanding -nostdinc -isystem /opt/build/arm-none-linux-gnueabi-4.6.0/lib/gcc/arm-none-linux-gnueabi/4.6.0/include -pipe  -DCONFIG_ARM -D__ARM__ -march=armv7-a -mabi=apcs-gnu platform.S smc.S cpu.c mmc.c sys_info.c clock.c sdram.c syslib.c sdram_elpida.c | \
                        sed -e "s/\:/\\\:/g"|sed -e "s/\\\: /\: /g"> .depend
make[1]: Leaving directory `/opt/L27.12.1-P2/x-loader/cpu/omap4'
make[1]: Entering directory `/opt/L27.12.1-P2/x-loader/cpu/omap4'
arm-none-linux-gnueabi-gcc -g  -Os   -fno-strict-aliasing  -fno-common -ffixed-r8 -msoft-float  -D__KERNEL__ -DTEXT_BASE=0x40304350 -I/opt/L27.12.1-P2/x-loader/include -fno-builtin -ffreestanding -nostdinc -isystem /opt/build/arm-none-linux-gnueabi-4.6.0/lib/gcc/arm-none-linux-gnueabi/4.6.0/include -pipe  -DCONFIG_ARM -D__ARM__ -march=armv7-a -mabi=apcs-gnu -Wall -Wstrict-prototypes -c -o cpu.o cpu.c
arm-none-linux-gnueabi-gcc -g  -Os   -fno-strict-aliasing  -fno-common -ffixed-r8 -msoft-float  -D__KERNEL__ -DTEXT_BASE=0x40304350 -I/opt/L27.12.1-P2/x-loader/include -fno-builtin -ffreestanding -nostdinc -isystem /opt/build/arm-none-linux-gnueabi-4.6.0/lib/gcc/arm-none-linux-gnueabi/4.6.0/include -pipe  -DCONFIG_ARM -D__ARM__ -march=armv7-a -mabi=apcs-gnu -Wall -Wstrict-prototypes -c -o mmc.o mmc.c
arm-none-linux-gnueabi-gcc -g  -Os   -fno-strict-aliasing  -fno-common -ffixed-r8 -msoft-float  -D__KERNEL__ -DTEXT_BASE=0x40304350 -I/opt/L27.12.1-P2/x-loader/include -fno-builtin -ffreestanding -nostdinc -isystem /opt/build/arm-none-linux-gnueabi-4.6.0/lib/gcc/arm-none-linux-gnueabi/4.6.0/include -pipe  -DCONFIG_ARM -D__ARM__ -march=armv7-a -mabi=apcs-gnu -Wall -Wstrict-prototypes -c -o sys_info.o sys_info.c
arm-none-linux-gnueabi-gcc -g  -Os   -fno-strict-aliasing  -fno-common -ffixed-r8 -msoft-float  -D__KERNEL__ -DTEXT_BASE=0x40304350 -I/opt/L27.12.1-P2/x-loader/include -fno-builtin -ffreestanding -nostdinc -isystem /opt/build/arm-none-linux-gnueabi-4.6.0/lib/gcc/arm-none-linux-gnueabi/4.6.0/include -pipe  -DCONFIG_ARM -D__ARM__ -march=armv7-a -mabi=apcs-gnu -Wall -Wstrict-prototypes -c -o clock.o clock.c
arm-none-linux-gnueabi-gcc -g  -Os   -fno-strict-aliasing  -fno-common -ffixed-r8 -msoft-float  -D__KERNEL__ -DTEXT_BASE=0x40304350 -I/opt/L27.12.1-P2/x-loader/include -fno-builtin -ffreestanding -nostdinc -isystem /opt/build/arm-none-linux-gnueabi-4.6.0/lib/gcc/arm-none-linux-gnueabi/4.6.0/include -pipe  -DCONFIG_ARM -D__ARM__ -march=armv7-a -mabi=apcs-gnu -Wall -Wstrict-prototypes -c -o sdram.o sdram.c
sdram.c: In function 'emif_config':
sdram.c:116:26: warning: variable 'rev' set but not used [-Wunused-but-set-variable]
arm-none-linux-gnueabi-gcc -g  -Os   -fno-strict-aliasing  -fno-common -ffixed-r8 -msoft-float  -D__KERNEL__ -DTEXT_BASE=0x40304350 -I/opt/L27.12.1-P2/x-loader/include -fno-builtin -ffreestanding -nostdinc -isystem /opt/build/arm-none-linux-gnueabi-4.6.0/lib/gcc/arm-none-linux-gnueabi/4.6.0/include -pipe  -DCONFIG_ARM -D__ARM__ -march=armv7-a -mabi=apcs-gnu -Wall -Wstrict-prototypes -c -o syslib.o syslib.c
arm-none-linux-gnueabi-gcc -g  -Os   -fno-strict-aliasing  -fno-common -ffixed-r8 -msoft-float  -D__KERNEL__ -DTEXT_BASE=0x40304350 -I/opt/L27.12.1-P2/x-loader/include -fno-builtin -ffreestanding -nostdinc -isystem /opt/build/arm-none-linux-gnueabi-4.6.0/lib/gcc/arm-none-linux-gnueabi/4.6.0/include -pipe  -DCONFIG_ARM -D__ARM__ -march=armv7-a -mabi=apcs-gnu -Wall -Wstrict-prototypes -c -o sdram_elpida.o sdram_elpida.c
arm-none-linux-gnueabi-gcc -Wa,-gstabs -D__ASSEMBLY__ -g  -Os   -fno-strict-aliasing  -fno-common -ffixed-r8 -msoft-float  -D__KERNEL__ -DTEXT_BASE=0x40304350 -I/opt/L27.12.1-P2/x-loader/include -fno-builtin -ffreestanding -nostdinc -isystem /opt/build/arm-none-linux-gnueabi-4.6.0/lib/gcc/arm-none-linux-gnueabi/4.6.0/include -pipe  -DCONFIG_ARM -D__ARM__ -march=armv7-a -mabi=apcs-gnu -c -o platform.o /opt/L27.12.1-P2/x-loader/cpu/omap4/platform.S
arm-none-linux-gnueabi-gcc -Wa,-gstabs -D__ASSEMBLY__ -g  -Os   -fno-strict-aliasing  -fno-common -ffixed-r8 -msoft-float  -D__KERNEL__ -DTEXT_BASE=0x40304350 -I/opt/L27.12.1-P2/x-loader/include -fno-builtin -ffreestanding -nostdinc -isystem /opt/build/arm-none-linux-gnueabi-4.6.0/lib/gcc/arm-none-linux-gnueabi/4.6.0/include -pipe  -DCONFIG_ARM -D__ARM__ -march=armv7-a -mabi=apcs-gnu -c -o smc.o /opt/L27.12.1-P2/x-loader/cpu/omap4/smc.S
/opt/L27.12.1-P2/x-loader/cpu/omap4/smc.S: Assembler messages:
/opt/L27.12.1-P2/x-loader/cpu/omap4/smc.S:39: Error: selected processor does not support ARM mode `smc #0'
 

2011年5月17日 星期二

Download Android/Linux kernel/U-Boot/X-loader source

Downloading Release Software

[Reference] http://www.omappedia.org/wiki/PandaBoard_L27.12.1-P2_Release_Notes

Installing repo

For detail information regarding repo visit: Using Repo and Git
Other reference links on Git can be found in Techincal References page
Download repo to environment
$ cd $YOUR_PATH/L27.12.1-P2/mydroid
$ curl http://android.git.kernel.org/repo > ./repo
$ chmod a+x repo

Download Android source

cd $YOUR_PATH/L27.12.1-P2/
cd $MYDROID
repo init -u git://git.omapzoom.org/platform/omapmanifest.git -b 27.x -m RLS27.12.1-P2_Gingerbread.xml
repo sync
Adding Mouse and Keyboard support
cd $MYDROID/frameworks/base
 git remote add rowboat git://gitorious.org/rowboat/frameworks-base.git
 git fetch rowboat
 git cherry-pick 17128d44ab04c5b7cb2911e8b1c9f837aa9b36a5
 git cherry-pick 174cb50436065dc092114d69fb40d5a7712e3ca0
Update PandaBoard device directory Update pandaboard device directory -- TODO: clean up and remove Blaze items
cd $MYDROID/device/ti/pandaboard
git fetch http://review.omapzoom.org/p/device/ti/pandaboard refs/changes/89/13489/1 && git cherry-pick FETCH_HEAD

Kernel & Driver Source

To clone kernel source from scratch do:
cd $YOUR_PATH/L27.12-P2/
git clone git://git.omapzoom.org/kernel/omap.git kernel/android-2.6.35
cd kernel/android-2.6.35
git checkout ec895072ad0b686d2c130e5d80a3076a03042033
If you already have kernel source cloned then just update it (and add a remote if it is the first time):
cd $YOUR_PATH/L27.12-P2/kernel/android-2.6.35
git fetch origin
git checkout ec895072ad0b686d2c130e5d80a3076a03042033

U-Boot Source

cd $YOUR_PATH/L27.12-P2/
git clone git://git.omapzoom.org/repo/u-boot.git u-boot
cd u-boot
git checkout 601ff71c8d46b5e90e13613974a16d10f2006bb3

X-loader Source

cd $YOUR_PATH/L27.12-P2/
git clone git://git.omapzoom.org/repo/x-loader.git x-loader
cd x-loader
git checkout c8855fa6b85bd44073bd1b25dbffa99f02cbeeed

2011年5月15日 星期日

Android Version Control with Repo and Git

Reference:
http://source.android.com/source/version-control.html

1) Download repo:
$ curl http://android.git.kernel.org/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
$ set path to ~/bin/repo
 
2) Basic Workflow
The basic pattern of interacting with the repositories is as follows:
  1. Use repo start to start a new topic branch.
  2. Edit the files.
  3. Use git add to stage changes.
  4. Use git commit to commit changes.
  5. Use repo upload to upload changes to the review server.
 

GCC-4.6.0 build script for arm-none-eabi

#!/bin/bash
GCC_SRC=gcc-4.6.0
#HOST=i686-pc-linux-gnu
HOST=x86_64-linux-gnu
TARGET=arm-none-eabi
PREFIX=/opt/build/arm-none-eabi-${GCC_SRC}
DEFAULT_CPU=cortex-a9

cd /opt
mkdir -p build_binutils
cd build_binutils
../binutils-2.21/configure --build=${HOST} --host=${HOST} --target=${TARGET} --with-sysroot=${PREFIX}/${TARGET} --disable-nls --enable-install-libbfd --enable-interwork --with-v4bx-interworking --enable-lto --enable-multilib --enable-shared --enable-gmp --enable-mpfr --prefix=${PREFIX}
make all install

cd /opt
mkdir -p build_gcc
cd build_gcc

#mkdir -p mpfr
#cp ../${GCC_SRC}/gmp/gmp-impl.h mpfr/
#cp ../${GCC_SRC}/gmp/longlong.h mpfr/

../${GCC_SRC}/configure --build=${HOST} --host=${HOST} --target=${TARGET} --with-pkgversion='M.F. C/C++ Compiler Release 20110423' --disable-libssp --disable-nls --disable-libgomp --disable-threads --disable-tls --enable-lto --enable-multilib --enable-gmp --enable-mpfr --enable-cloog --enable-ppl --with-v4bx-interworking --enable-languages=c,c++ --enable-long-long --enable-c99 --enable-shared --with-float=hard --enable-cxx-flags=-mhard-float --with-cpu=${DEFAULT_CPU} --with-newlib --with-ld=${PREFIX}/bin/${TARGET}-ld --prefix=${PREFIX}
make all install

rm -rf build_binutils
rm -rf build_gcc

2011年5月14日 星期六

GCC-4.6.0 arm-none-linux-gnueabi build script for both little and big endian static toolchain

1) gcc-4.6.0 with arm-none-linux-gnueabi
2) support both -mlittle-endian and -mbig-endian
3) default -mhard-float and multilib for cortex-a9
4) static-build gcc/g++

The patches to gcc-4.6.0:

diff -uNr src/gcc-4.6.0/gcc-4.6.0/gcc/config/arm/linux-eabi.h gcc-4.6.0/gcc/config/arm/linux-eabi.h
--- src/gcc-4.6.0/gcc-4.6.0/gcc/config/arm/linux-eabi.h 2011-01-12 22:29:14.000000000 +0800
+++ gcc-4.6.0/gcc/config/arm/linux-eabi.h       2011-05-11 23:29:29.012044669 +0800
@@ -101,3 +101,6 @@
    is used.  */ 
 #undef  CLEAR_INSN_CACHE
 #define CLEAR_INSN_CACHE(BEG, END) not_used
+
+#undef SYSROOT_SUFFIX_SPEC
+#define SYSROOT_SUFFIX_SPEC "%{mbig-endian:/be}"
diff -uNr src/gcc-4.6.0/gcc-4.6.0/gcc/config/arm/linux-elf.h gcc-4.6.0/gcc/config/arm/linux-elf.h
--- src/gcc-4.6.0/gcc-4.6.0/gcc/config/arm/linux-elf.h  2011-01-15 02:42:32.000000000 +0800
+++ gcc-4.6.0/gcc/config/arm/linux-elf.h        2011-05-14 20:06:44.188276102 +0800
@@ -51,7 +51,7 @@

 #undef  MULTILIB_DEFAULTS
 #define MULTILIB_DEFAULTS \
-       { "marm", "mlittle-endian", "mhard-float", "mno-thumb-interwork" }
+       { "marm", TARGET_ENDIAN_OPTION, "mhard-float", "mno-thumb-interwork" }

 /* Now we define the strings used to build the spec file.  */ 
 #undef  LIB_SPEC
diff -uNr src/gcc-4.6.0/gcc-4.6.0/gcc/config/arm/t-arm-elf gcc-4.6.0/gcc/config/arm/t-arm-elf
--- src/gcc-4.6.0/gcc-4.6.0/gcc/config/arm/t-arm-elf    2011-01-04 04:52:22.000000000 +0800
+++ gcc-4.6.0/gcc/config/arm/t-arm-elf  2011-05-14 21:50:58.517726008 +0800
@@ -36,6 +36,10 @@
 MULTILIB_EXCEPTIONS  =  
 MULTILIB_MATCHES     =  

+MULTILIB_OPTIONS     += mcpu=cortex-a9
+MULTILIB_DIRNAMES    += cortex-a9
+MULTILIB_EXCEPTIONS  +=
+
 #MULTILIB_OPTIONS     += mcpu=fa526/mcpu=fa626/mcpu=fa606te/mcpu=fa626te/mcpu=fmp626/mcpu=fa726te
 #MULTILIB_DIRNAMES    += fa526 fa626 fa606te fa626te fmp626 fa726te
 #MULTILIB_EXCEPTIONS  += *mthumb*/*mcpu=fa526 *mthumb*/*mcpu=fa626
@@ -67,6 +71,10 @@
 # MULTILIB_DIRNAMES    += le be
 # MULTILIB_MATCHES     += mbig-endian=mbe mlittle-endian=mle
 #
+MULTILIB_OPTIONS     += mbig-endian
+MULTILIB_DIRNAMES    += be
+MULTILIB_MATCHES     += mbig-endian=mbe
+#
 # MULTILIB_OPTIONS    += mhard-float/msoft-float
 # MULTILIB_DIRNAMES   += fpu soft
 # MULTILIB_EXCEPTIONS += *mthumb/*mhard-float*
diff -uNr src/gcc-4.6.0/gcc-4.6.0/gcc/config/arm/t-linux gcc-4.6.0/gcc/config/arm/t-linux
--- src/gcc-4.6.0/gcc-4.6.0/gcc/config/arm/t-linux      2009-04-22 03:03:23.000000000 +0800
+++ gcc-4.6.0/gcc/config/arm/t-linux    2011-05-11 23:34:24.503749908 +0800
@@ -28,6 +28,9 @@
 # MULTILIB_OPTIONS = mhard-float/msoft-float
 # MULTILIB_DIRNAMES = hard-float soft-float

+MULTILIB_OPTIONS += mbig-endian
+MULTILIB_DIRNAMES += be
+
 # EXTRA_MULTILIB_PARTS = crtbegin.o crtend.o


 # LIBGCC = stmp-multilib
diff -uNr src/gcc-4.6.0/gcc-4.6.0/gcc/config/arm/t-linux-eabi gcc-4.6.0/gcc/config/arm/t-linux-eabi
--- src/gcc-4.6.0/gcc-4.6.0/gcc/config/arm/t-linux-eabi 2011-01-04 04:52:22.000000000 +0800
+++ gcc-4.6.0/gcc/config/arm/t-linux-eabi       2011-05-14 21:50:19.527668816 +0800
@@ -21,8 +21,22 @@

 # We do not build a Thumb multilib for Linux because the definition of
 # CLEAR_INSN_CACHE in linux-gas.h does not work in Thumb mode.
-MULTILIB_OPTIONS       =
-MULTILIB_DIRNAMES      =
+MULTILIB_OPTIONS     = marm
+MULTILIB_DIRNAMES    = arm
+MULTILIB_EXCEPTIONS  =
+MULTILIB_MATCHES     =
+
+MULTILIB_OPTIONS     += mcpu=cortex-a9
+MULTILIB_DIRNAMES    += cortex-a9
+MULTILIB_EXCEPTIONS  +=
+
+MULTILIB_OPTIONS     += mbig-endian
+MULTILIB_DIRNAMES    += be
+MULTILIB_MATCHES     += mbig-endian=mbe
+
+#MULTILIB_OPTIONS    += mfloat-abi=hard
+#MULTILIB_DIRNAMES   += fpu
+#MULTILIB_EXCEPTIONS += *mthumb/*mfloat-abi=hard*

 #MULTILIB_OPTIONS     += mcpu=fa606te/mcpu=fa626te/mcpu=fmp626/mcpu=fa726te
 #MULTILIB_DIRNAMES    += fa606te fa626te fmp626 fa726te

The build script for arm-none-linux-gnueabi:

[1-build-binutils.sh]
#!/bin/bash
cd ${BUILDPATH}
mkdir -v binutils-build
cd binutils-build
AR=ar AS=as ${BINUTILS_SRC}/configure --build=${HOST} --host=${HOST} --target=${TARGET} --prefix=${PREFIX} --with-lib-path=${PREFIX}/${TARGET}/lib:${PREFIX}/${TARGET}/lib/be --with-sysroot=${PREFIX}/${TARGET} --disable-nls --enable-shared --enable-install-libbfd --enable-interwork --with-v4bx-interworking --enable-multilib
make configure-host
make LDFLAGS="-static"
make install

[3-build-headers.sh]
#!/bin/bash
echo "Prepare Linux kernel headers"

cd ${LINUX_HEADER_SRC}
make ARCH=arm CROSS_COMPILE=${TARGET}- INSTALL_HDR_PATH=${PREFIX}/${TARGET} headers_install

[4-build-gcc.sh]
#!/bin/bash
if test x"${BOOTSTRAP_PREFIX}" != x"${PREFIX}"; then
    mkdir -p ${BOOTSTRAP_PREFIX}/${TARGET}/bin
    for tool in ar as ld strip ranlib; do
        rm -f ${BOOTSTRAP_PREFIX}/${TARGET}/bin/${tool} || true
        ln -s ${PREFIX}/bin/${TARGET}-${tool} ${BOOTSTRAP_PREFIX}/${TARGET}/bin/${tool}
    done
fi

echo "Build bootstrap gcc"

cd ${BUILDPATH}
mkdir -v gcc-build
cd gcc-build

#mkdir -p mpfr
#cp ${GCC_SRC}/gmp/gmp-impl.h ./mpfr
#cp ${GCC_SRC}/gmp/longlong.h ./mpfr

# http://comments.gmane.org/gmane.linux.lfs.devel/10631
# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47836
# need --disable-shared --disable-lto --disable-libquadmath --without-target-libiberty --without-target-zlib
${GCC_SRC}/configure --build=${HOST} --host=${HOST} --target=${TARGET} --prefix=${BOOTSTRAP_PREFIX} --with-local-prefix=${BOOTSTRAP_PREFIX}/${TARGET} --without-target-libiberty --without-target-zlib --disable-libquadmath --disable-lto --disable-libstdcxx-pch --disable-libffi --enable-multilib --disable-nls --disable-libgomp --disable-libmudflap --disable-libssp --enable-gold --enable-ld --enable-symvers=gnu --enable-__cxa_atexit --enable-languages=c --disable-shared --disable-threads --without-headers --disable-decimal-float --enable-mpfr --enable-gmp --without-cloog --without-ppl --with-float=hard --with-v4bx-interworking --with-gnu-as --with-gnu-ld --with-cpu=${DEFAULT_CPU} --with-libelf=${LIBELF_PREFIX} --with-mpc=${MPC_PREFIX}
make
make install

[5-build-glibc.sh]
#!/bin/bash
if test x"${BOOTSTRAP_PREFIX}" != x"${PREFIX}"; then
    ln -s ${PREFIX}/${TARGET}/include ${BOOTSTRAP_PREFIX}/${TARGET}/include
fi

cd ${BUILDPATH}
mkdir -v glibc-build
cd glibc-build
cat > config.cache << EOF
libc_cv_forced_unwind=yes
libc_cv_c_cleanup=yes
libc_cv_arm_tls=yes
libc_cv_gnu89_inline=yes
EOF

# http://newsgroups.derkeiler.com/Archive/Comp/comp.lang.awk/2009-03/msg00088.html
# glibc-2.13 may have [^/], replace it with [^\/] in gen-sorted.awk
# need to install gawk
BUILD_CC="gcc" CC="${TARGET}-gcc" AR="${TARGET}-ar" RANLIB="${TARGET}-ranlib" ${GLIBC_SRC}/configure --prefix=/usr --build=${HOST} --host=${TARGET} --target=${TARGET} --without-cvs --disable-profile --disable-debug --without-gd --with-fp --disable-libunwind-exceptions --cache-file=config.cache --enable-kernel=2.6.38 --with-binutils=${PREFIX}/bin --enable-add-ons=ports,nptl --with-tls --with-__thread --with-arch=${DEFAULT_ARCH} --enable-multilib --enable-sim --enable-shared --enable-multi-arch --with-v4bx-interworking --with-headers=${PREFIX}/${TARGET}/include
make V=1 LD=${TARGET}-ld RANLIB=${TARGET}-ranlib all
make install_root=${PREFIX}/${TARGET} prefix= install

# modify libc.so  libpthread.so
# GROUP ( /lib/libc.so.6 /lib/libc_nonshared.a  AS_NEEDED ( /lib/ld-linux.so.2 ) ) ---> GROUP ( libc.so.6 libc_nonshared.a  AS_NEEDED ( ld-linux.so.2 ) )


cd ${BUILDPATH}
rm -rf glibc-build
mkdir -v glibc-build
cd glibc-build
cat > config.cache << EOF
libc_cv_forced_unwind=yes
libc_cv_c_cleanup=yes
libc_cv_arm_tls=yes
libc_cv_gnu89_inline=yes
libc_cv_slibdir=${PREFIX}/${TARGET}/lib/be
EOF

# http://newsgroups.derkeiler.com/Archive/Comp/comp.lang.awk/2009-03/msg00088.html
# glibc-2.13 may have [^/], replace it with [^\/] in gen-sorted.awk
# need to install gawk
BUILD_CC="gcc" CC="${TARGET}-gcc -mbig-endian -Wl,-EB" AR="${TARGET}-ar" AS="${TARGET}-as -mbig-endian" RANLIB="${TARGET}-ranlib" LD="${TARGET}-ld" ${GLIBC_SRC}/configure --prefix=${PREFIX}/${TARGET} --build=${HOST} --host=${TARGET} --target=${TARGET} --libdir=${PREFIX}/${TARGET}/lib/be --without-cvs --disable-profile --disable-debug --without-gd --with-fp --disable-libunwind-exceptions --cache-file=config.cache --enable-kernel=2.6.38 --with-binutils=${PREFIX}/bin --enable-add-ons=ports,nptl --with-tls --with-__thread --with-arch=${DEFAULT_ARCH} --enable-multilib --enable-sim --enable-shared --enable-multi-arch --with-v4bx-interworking --with-headers=${PREFIX}/${TARGET}/include
make V=1
make install

# modify libc.so  libpthread.so
# GROUP ( /lib/libc.so.6 /lib/libc_nonshared.a  AS_NEEDED ( /lib/ld-linux.so.2 ) ) ---> GROUP ( libc.so.6 libc_nonshared.a  AS_NEEDED ( ld-linux.so.2 ) )

# From crosstool 0.43
# Fix problems in linker scripts.
#
# 1. Remove absolute paths
# Any file in a list of known suspects that isn't a symlink is assumed to be a linker script.
# FIXME: test -h is not portable
# FIXME: probably need to check more files than just these three...
# Need to use sed instead of just assuming we know what's in libc.so because otherwise alpha breaks
#
# 2. Remove lines containing BUG per http://sources.redhat.com/ml/bug-glibc/2003-05/msg00055.html,
# needed to fix gcc-3.2.3/glibc-2.3.2 targeting arm
#
# To make "strip *.so.*" not fail (ptxdist does this), rename to .so_orig rather than .so.orig
for file in libc.so libpthread.so libgcc_s.so; do
    for lib in lib lib/be lib64 usr/lib usr/lib64; do
      if test -f ${PREFIX}/${TARGET}/$lib/$file && test ! -h ${PREFIX}/${TARGET}/$lib/$file; then
        mv ${PREFIX}/${TARGET}/$lib/$file ${PREFIX}/${TARGET}/$lib/${file}_orig
        sed 's,/opt/build/arm-none-linux-gnueabi-4.6.0/arm-none-linux-gnueabi/lib/be/,,g;s,/usr/lib/,,g;s,/usr/lib64/,,g;s,/lib/,,g;s,/lib64/,,g;s,${PREFIX}/${TARGET}/lib/be,,g;/BUG in libc.scripts.output-format.sed/d' < ${PREFIX}/${TARGET}/$lib/${file}_orig > ${PREFIX}/${TARGET}/$lib/$file
        rm -f ${PREFIX}/${TARGET}/$lib/${file}_orig
      fi
    done
done


# link for other multilib options that uses mbig-endian, or they would link to default
# target library that is mlittle-endian

cd ${PREFIX}/${TARGET}/lib; mkdir -p cortex-a9; cd cortex-a9; ln -s ../be be

[6-build-gcc-final.sh]
#!/bin/bash
cd ${BUILDPATH}
mkdir -v gcc-build-final
cd gcc-build-final

#mkdir -p mpfr
#cp ${GCC_SRC}/gmp/gmp-impl.h ./mpfr
#cp ${GCC_SRC}/gmp/longlong.h ./mpfr

AR=ar ${GCC_SRC}/configure --prefix=${PREFIX} --build=${HOST} --host=${HOST} --target=${TARGET} --with-cpu=${DEFAULT_CPU} --with-pkgversion='M.F. C/C++ Compiler Release 20110423' --disable-nls --disable-libssp --disable-libgomp --enable-gold --enable-ld --enable-threads=posix --disable-tls --enable-symvers=gnu --enable-c99 --enable-long-long --enable-multilib --enable-languages=c,c++ --enable-__cxa_atexit --with-float=hard --enable-cxx-flags=-mhard-float --enable-shared --enable-gmp --enable-mpfr --enable-cloog --enable-ppl --with-v4bx-interworking --with-headers=${PREFIX}/${TARGET}/include --with-libelf=${LIBELF_PREFIX} --with-mpc=${MPC_PREFIX}

make AS_FOR_TARGET="${TARGET}-as" LD_FOR_TARGET="${TARGET}-ld" LDFLAGS="-L${PREFIX}/${TARGET}/lib -L${PREFIX}/${TARGET}/lib/be -static" all
make install

rm -f ${PREFIX}/bin/${TARGET}-gccbug
strip ${PREFIX}/bin/*
strip ${PREFIX}/${TARGET}/bin/ar
strip ${PREFIX}/${TARGET}/bin/as
strip ${PREFIX}/${TARGET}/bin/c++
strip ${PREFIX}/${TARGET}/bin/g++
strip ${PREFIX}/${TARGET}/bin/gcc
strip ${PREFIX}/${TARGET}/bin/ld
strip ${PREFIX}/${TARGET}/bin/nm
strip ${PREFIX}/${TARGET}/bin/objcopy
strip ${PREFIX}/${TARGET}/bin/objdump
strip ${PREFIX}/${TARGET}/bin/ranlib
strip ${PREFIX}/${TARGET}/bin/strip
strip ${PREFIX}/libexec/gcc/${TARGET}/${GCC_VER}/cc1
strip ${PREFIX}/libexec/gcc/${TARGET}/${GCC_VER}/cc1plus
strip ${PREFIX}/libexec/gcc/${TARGET}/${GCC_VER}/collect2

[build-all.sh]
#!/bin/bash
set -ex

#HOST=i686-pc-linux-gnu
HOST=x86_64-linux-gnu
TARGET=arm-none-linux-gnueabi
DEFAULT_ARCH=armv7
DEFAULT_CPU=cortex-a9

# Specify the source path of each package
BINUTILS_SRC=/opt/binutils-2.21
GCC_VER=4.6.0
GCC_SRC=/opt/gcc-${GCC_VER}
GLIBC_SRC=/opt/src/glibc-2.13
LINUX_HEADER_SRC=/opt/linux-2.6.38

LOCAL_DIR=${PWD}
BUILDPATH=${LOCAL_DIR}/build
PREFIX=/opt/build/${TARGET}-${GCC_VER}
BOOTSTRAP_PREFIX=${BUILDPATH}/${TARGET}-${GCC_VER}
#MPFR_PREFIX=${PREFIX}/libmpfr
#GMP_PREFIX=${PREFIX}/libgmp
MPFR_PREFIX=/usr
GMP_PREFIX=/usr
MPC_PREFIX=/usr
LIBELF_PREFIX=/usr

unset LD_LIBRARY_PATH
unset LIBRARY_PATH
unset LD_RUN_PATH

if [ -e ${GCC_SRC}/newlib ]; then
  mv ${GCC_SRC}/newlib ${GCC_SRC}/newlib.orig
fi

mkdir -v ${BUILDPATH}
source ${LOCAL_DIR}/1-build-binutils.sh
##source ${LOCAL_DIR}/2-build-gmp-mpfr.sh
source ${LOCAL_DIR}/3-build-headers.sh
if test x"${BOOTSTRAP_PREFIX}" != x"${PREFIX}"; then
    export PATH=${BOOTSTRAP_PREFIX}/bin:${PATH}
fi
export PATH=${PREFIX}/bin:${PATH}
export LD_LIBRARY_PATH=${GMP_PREFIX}/lib:${MPFR_PREFIX}/lib
source ${LOCAL_DIR}/4-build-gcc.sh
source ${LOCAL_DIR}/5-build-glibc.sh
source ${LOCAL_DIR}/6-build-gcc-final.sh

if [ -e ${GCC_SRC}/newlib.orig ]; then
  mv ${GCC_SRC}/newlib.orig ${GCC_SRC}/newlib
fi

2011年5月4日 星期三

GCC-4.6.0 little-endian build script for arm-none-linux-gnueabi

For ARM's cortex-a9, build arm-none-linux-gnueabi little-endian toolchain

Source package:
binutils-2.21
gcc-4.6.0
glibc-2.13

With hardware vfp.

[1-build-binutils.sh]
#!/bin/bash
cd ${BUILDPATH}
mkdir -v binutils-build
cd binutils-build
AR=ar AS=as ${BINUTILS_SRC}/configure --build=${HOST} --host=${HOST} --target=${TARGET} --prefix=${PREFIX} --with-sysroot=${PREFIX}/${TARGET} --disable-nls --enable-shared --enable-install-libbfd --enable-interwork --with-v4bx-interworking --enable-multilib
make configure-host
make LDFLAGS="-static"
make install

[2-build-gmp-mpfr.sh]
#!/bin/bash
mkdir -v ${BUILDPATH}/gmp-build
cd ${BUILDPATH}/gmp-build
${GMP_SRC}/configure --prefix=${GMP_PREFIX} --enable-cxx --enable-mpbsd
make
make install

mkdir -v ${BUILDPATH}/mpfr-build
cd ${BUILDPATH}/mpfr-build
LDFLAGS="-Wl,-rpath,${PREFIX}/lib" ${MPFR_SRC}/configure --prefix=${MPFR_PREFIX} --enable-shared --with-gmp=${GMP_PREFIX}
make
make check
make install

[3-build-headers.sh]
#!/bin/bash
echo "Prepare Linux kernel headers"

cd ${LINUX_HEADER_SRC}
make ARCH=arm CROSS_COMPILE=${TARGET}- INSTALL_HDR_PATH=${PREFIX}/${TARGET} headers_install

[4-build-gcc.sh]
#!/bin/bash
if test x"${BOOTSTRAP_PREFIX}" != x"${PREFIX}"; then
    mkdir -p ${BOOTSTRAP_PREFIX}/${TARGET}/bin
    for tool in ar as ld strip ranlib; do
        rm -f ${BOOTSTRAP_PREFIX}/${TARGET}/bin/${tool} || true
        ln -s ${PREFIX}/bin/${TARGET}-${tool} ${BOOTSTRAP_PREFIX}/${TARGET}/bin/${tool}
    done
fi

echo "Build bootstrap gcc"

cd ${BUILDPATH}
mkdir -v gcc-build
cd gcc-build

#mkdir -p mpfr
#cp ${GCC_SRC}/gmp/gmp-impl.h ./mpfr
#cp ${GCC_SRC}/gmp/longlong.h ./mpfr

# http://comments.gmane.org/gmane.linux.lfs.devel/10631
# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47836
# need --disable-shared --disable-lto --disable-libquadmath --without-target-libiberty --without-target-zlib
${GCC_SRC}/configure --build=${HOST} --host=${HOST} --target=${TARGET} --prefix=${BOOTSTRAP_PREFIX} --with-local-prefix=${BOOTSTRAP_PREFIX}/${TARGET} --without-target-libiberty --without-target-zlib --disable-libquadmath --disable-lto --disable-libstdcxx-pch --disable-libffi --disable-multilib --disable-nls --disable-libgomp --disable-libmudflap --disable-libssp --enable-gold --enable-ld --enable-symvers=gnu --enable-__cxa_atexit --enable-languages=c --disable-shared --disable-threads --without-headers --disable-decimal-float --enable-mpfr --enable-gmp --without-cloog --without-ppl --with-float=hard --with-v4bx-interworking --with-gnu-as --with-gnu-ld --with-cpu=${DEFAULT_CPU} --with-libelf=${LIBELF_PREFIX} --with-mpc=${MPC_PREFIX}
make
make install

[5-build-glibc.sh]
#!/bin/bash
#if test x"${BOOTSTRAP_PREFIX}" != x"${PREFIX}"; then
#    ln -s ${PREFIX}/${TARGET}/include ${BOOTSTRAP_PREFIX}/${TARGET}/include
#fi

cd ${BUILDPATH}
mkdir -v glibc-build
cd glibc-build
cat > config.cache << EOF
libc_cv_forced_unwind=yes
libc_cv_c_cleanup=yes
libc_cv_arm_tls=yes
libc_cv_gnu89_inline=yes
EOF

# http://newsgroups.derkeiler.com/Archive/Comp/comp.lang.awk/2009-03/msg00088.html
# glibc-2.13 may have [^/], replace it with [^\/] in gen-sorted.awk
# need to install gawk
BUILD_CC="gcc" CC="${TARGET}-gcc" AR="${TARGET}-ar" RANLIB="${TARGET}-ranlib" ${GLIBC_SRC}/configure --prefix=/usr --build=${HOST} --host=${TARGET} --target=${TARGET} --without-cvs --disable-profile --disable-debug --without-gd --with-fp --disable-libunwind-exceptions --cache-file=config.cache --enable-kernel=2.6.38 --with-binutils=${PREFIX}/bin --enable-add-ons=ports,nptl --with-tls --with-__thread --with-arch=${DEFAULT_ARCH} --enable-multilib --enable-sim --enable-shared --enable-multi-arch --with-v4bx-interworking --with-headers=${PREFIX}/${TARGET}/include
make V=1 LD=${TARGET}-ld RANLIB=${TARGET}-ranlib all
make install_root=${PREFIX}/${TARGET} prefix= install

# modify libc.so  libpthread.so
# GROUP ( /lib/libc.so.6 /lib/libc_nonshared.a  AS_NEEDED ( /lib/ld-linux.so.2 ) ) ---> GROUP ( libc.so.6 libc_nonshared.a  AS_NEEDED ( ld-linux.so.2 ) )

[6-build-gcc-final.sh]
#!/bin/bash
cd ${BUILDPATH}
mkdir -v gcc-build-final
cd gcc-build-final

#mkdir -p mpfr
#cp ${GCC_SRC}/gmp/gmp-impl.h ./mpfr
#cp ${GCC_SRC}/gmp/longlong.h ./mpfr

#add --with-newlib
AR=ar LDFLAGS="-Wl,-rpath,${PREFIX}/${TARGET}/lib" ${GCC_SRC}/configure --prefix=${PREFIX} --build=${HOST} --host=${HOST} --target=${TARGET} --with-cpu=${DEFAULT_CPU} --with-pkgversion='M.F. C/C++ Compiler Release 20110423' --disable-nls --disable-libssp --disable-libgomp --enable-gold --enable-ld --enable-threads=posix --disable-tls --enable-symvers=gnu --enable-c99 --enable-long-long --enable-multilib --enable-languages=c,c++ --enable-__cxa_atexit --with-float=hard --enable-cxx-flags=-mhard-float --enable-shared --enable-gmp --enable-mpfr --enable-cloog --enable-ppl --with-v4bx-interworking --with-headers=${PREFIX}/${TARGET}/include --with-libelf=${LIBELF_PREFIX} --with-mpc=${MPC_PREFIX}
make AS_FOR_TARGET="${TARGET}-as" LD_FOR_TARGET="${TARGET}-ld" LDFLAGS="-static" all
make install

rm -f ${PREFIX}/bin/${TARGET}-gccbug
strip ${PREFIX}/bin/*
strip ${PREFIX}/${TARGET}/bin/ar
strip ${PREFIX}/${TARGET}/bin/as
strip ${PREFIX}/${TARGET}/bin/c++
strip ${PREFIX}/${TARGET}/bin/g++
strip ${PREFIX}/${TARGET}/bin/gcc
strip ${PREFIX}/${TARGET}/bin/ld
strip ${PREFIX}/${TARGET}/bin/nm
strip ${PREFIX}/${TARGET}/bin/objcopy
strip ${PREFIX}/${TARGET}/bin/objdump
strip ${PREFIX}/${TARGET}/bin/ranlib
strip ${PREFIX}/${TARGET}/bin/strip
strip ${PREFIX}/libexec/gcc/${TARGET}/${GCC_VER}/cc1
strip ${PREFIX}/libexec/gcc/${TARGET}/${GCC_VER}/cc1plus
strip ${PREFIX}/libexec/gcc/${TARGET}/${GCC_VER}/collect2

[build-all.sh]
#!/bin/bash
set -ex

#HOST=i686-pc-linux-gnu
HOST=x86_64-linux-gnu
TARGET=arm-none-linux-gnueabi
DEFAULT_ARCH=armv7
DEFAULT_CPU=cortex-a9

# Specify the source path of each package
BINUTILS_SRC=/opt/binutils-2.21
GCC_VER=4.6.0
GCC_SRC=/opt/gcc-${GCC_VER}
GLIBC_SRC=/opt/src/glibc-2.13
LINUX_HEADER_SRC=/opt/linux-2.6.38

LOCAL_DIR=${PWD}
BUILDPATH=${LOCAL_DIR}/build
PREFIX=/opt/build/${TARGET}-${GCC_VER}
BOOTSTRAP_PREFIX=${BUILDPATH}/${TARGET}-${GCC_VER}
MPFR_PREFIX=/usr
GMP_PREFIX=/usr
MPC_PREFIX=/usr
LIBELF_PREFIX=/usr

unset LD_LIBRARY_PATH
unset LIBRARY_PATH
unset LD_RUN_PATH

if [ -e ${GCC_SRC}/newlib ]; then
  mv ${GCC_SRC}/newlib ${GCC_SRC}/newlib.orig
fi

mkdir -v ${BUILDPATH}
source ${LOCAL_DIR}/1-build-binutils.sh
#source ${LOCAL_DIR}/2-build-gmp-mpfr.sh
source ${LOCAL_DIR}/3-build-headers.sh
if test x"${BOOTSTRAP_PREFIX}" != x"${PREFIX}"; then
    export PATH=${BOOTSTRAP_PREFIX}/bin:${PATH}
fi
export PATH=${PREFIX}/bin:${PATH}
export LD_LIBRARY_PATH=${GMP_PREFIX}/lib:${MPFR_PREFIX}/lib
source ${LOCAL_DIR}/4-build-gcc.sh
source ${LOCAL_DIR}/5-build-glibc.sh
source ${LOCAL_DIR}/6-build-gcc-final.sh

if [ -e ${GCC_SRC}/newlib.orig ]; then
  mv ${GCC_SRC}/newlib.orig ${GCC_SRC}/newlib
fi