Browse Source

create_device - Path in parameter, cross_compilation, and git in https

Émile Morel 10 years ago
parent
commit
0cd3f6b940
2 changed files with 56 additions and 30 deletions
  1. 2 2
      README.md
  2. 54 28
      olinux/create_sunxi_boot_files.sh

+ 2 - 2
README.md

@@ -23,7 +23,7 @@ cd sunxi-debian && sudo docker build -t debian:olinux .
 To build sunxi kernel and boot files run:
 
 ```shell
-sudo docker run --privileged -i -t -v $(pwd)/olinux/:/olinux/ debian:olinux bash ./olinux/create_sunxi_boot_files.sh
+sudo docker run --privileged -i -t -v $(pwd)/olinux/:/olinux/ debian:olinux bash ./olinux/create_sunxi_boot_files.sh -c
 ```
 
 Optional arguments:
@@ -40,7 +40,7 @@ privileged mode. For more details see [docker issue](https://github.com/docker/d
 To build the minimal debian rootfs with the kernel previously build:
 
 ```shell
-sudo docker run --privileged -i -t -v $(pwd)/olinux/:/olinux/ debian:olinux bash ./olinux/create_arm_debootstrap.sh -i
+sudo docker run --privileged -i -t -v $(pwd)/olinux/:/olinux/ debian:olinux bash ./olinux/create_arm_debootstrap.sh -i -c
 ```
 
 Optional arguments:

+ 54 - 28
olinux/create_sunxi_boot_files.sh

@@ -17,8 +17,10 @@ cat <<EOF
 
   -o		offline mode						(mandatory)
   -b		olinux board (a10lime, a20lime, a20lime2, a20micro) 	(default: a20lime)
-  -t		number of thread 					(default: 2)
+  -t		target directory for compilation			(default: /olinux/sunxi)
+  -j		number of thread 					(default: 2)
   -l		change linux boot logo
+  -c		cross compilation 
 
 EOF
 exit 1
@@ -28,8 +30,10 @@ exit 1
 THREADS=2
 MAINTAINER="Emile"
 MAINTAINERMAIL="emile@bleuchtang.fr"
+REP=$(dirname $0)
+TARGET=/olinux/sunxi
 
-while getopts ":ob:t:l:" opt; do
+while getopts ":ob:t:l:c" opt; do
   case $opt in
     o)
       OFFLINE=yes
@@ -37,70 +41,92 @@ while getopts ":ob:t:l:" opt; do
     b)
       BOARD=$OPTARG
       ;;
-    t)
+    j)
       THREADS=$OPTARG
       ;;
+    t)
+      TARGET=$OPTARG
+      ;;
     l)
       LOGO=$OPTARG
       ;;
+    c)
+      CROSS=yes
+      ;;
     \?)
       show_usage
       ;;
   esac
 done
 
-source /olinux/config_board.sh
+source ${REP}/config_board.sh
 
 clone_or_pull (){
   project=$1
   repo=$2
   name=$(echo $project |  sed 's/.git$//')
   if [ "$OFFLINE" ] ; then
-    if [ -f /olinux/sunxi/$name/Makefile ] ; then
-      cd /olinux/sunxi/$name/ && make clean && git checkout .
+    if [ -f ${TARGET}/$name/Makefile ] ; then
+      cd ${TARGET}/$name/ && make clean && git checkout .
       return 0
     else
       return 0
     fi
   fi
-  if [ -d /olinux/sunxi/$name/ ] ; then
-    if [ -f /olinux/sunxi/$name/Makefile ] ; then
-      cd /olinux/sunxi/$name/ && make clean && git checkout . && git pull
+  if [ -d ${TARGET}/$name/ ] ; then
+    if [ -f ${TARGET}/$name/Makefile ] ; then
+      cd ${TARGET}/$name/ && make clean && git checkout . && git pull
     else
-      cd /olinux/sunxi/$name/ && git checkout . && git pull
+      cd ${TARGET}/$name/ && git checkout . && git pull
     fi
   else
-    git clone $repo/$project /olinux/sunxi/$name/
+    git clone $repo/$project ${TARGET}/$name/
   fi
 }
 
-mkdir -p /olinux/sunxi/
+mkdir -p ${TARGET}/
 
 ## Sunxi u-boot
-clone_or_pull u-boot git://git.denx.de
-cd /olinux/sunxi/u-boot/
-make $U_BOOT_CONFIG ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
+clone_or_pull u-boot.git http://git.denx.de
+cd ${TARGET}/u-boot/
+if [ ${CROSS} ] ; then
+  make $U_BOOT_CONFIG ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
+else
+  make $U_BOOT_CONFIG
+fi
 if [ "$LOGO" ] ; then
-  cp /olinux/logo/${LOGO}.bmp /olinux/sunxi/u-boot/tools/logos/denx.bmp
-  sed -i -e 's/#define CONFIG_VIDEO_LOGO/#define CONFIG_VIDEO_LOGO\n#define CONFIG_VIDEO_BMP_LOGO/' /olinux/sunxi/u-boot/include/configs/sunxi-common.h
+  cp ${REP}/logo/${LOGO}.bmp ${TARGET}/u-boot/tools/logos/denx.bmp
+  sed -i -e 's/#define CONFIG_VIDEO_LOGO/#define CONFIG_VIDEO_LOGO\n#define CONFIG_VIDEO_BMP_LOGO/' ${TARGET}/u-boot/include/configs/sunxi-common.h
+fi
+if [ ${CROSS} ] ; then
+  make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
+else
+  make
 fi
-make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
 
 # Linux kernel
-clone_or_pull linux.git git://git.kernel.org/pub/scm/linux/kernel/git/torvalds
-cd /olinux/sunxi/linux/
+clone_or_pull linux.git http://git.kernel.org/pub/scm/linux/kernel/git/torvalds
+cd ${TARGET}/linux/
 # igorpecovnik patch for debian package
-patch -p1 < /olinux/patch/packaging-next.patch
-cp /olinux/config/linux-sunxi.config /olinux/sunxi/linux/.config
+patch -p1 < ${REP}/patch/packaging-next.patch
+cp /${REP}/config/linux-sunxi.config ${TARGET}/linux/.config
 if [ "$LOGO" ] ; then
-  cp /olinux/logo/${LOGO}.ppm /olinux/sunxi/linux/drivers/video/logo/logo_linux_clut224.ppm
+  cp /${REP}/logo/${LOGO}.ppm ${TARGET}/linux/drivers/video/logo/logo_linux_clut224.ppm
 fi
 #make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- sunxi_defconfig
 #make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig
-make -j${THREADS} ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- all zImage
+if [ ${CROSS} ] ; then
+  make -j${THREADS} ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- all zImage
+else
+  make -j${THREADS} all zImage
+fi
 # Install device tree blobs in separate package, link zImage to kernel image script
-rm -f /olinux/sunxi/*.deb
-make -j1 deb-pkg KBUILD_DEBARCH=armhf ARCH=arm DEBFULLNAME="$MAINTAINER" DEBEMAIL="$MAINTAINERMAIL" CROSS_COMPILE=arm-linux-gnueabihf-
+rm -f ${TARGET}/*.deb
+if [ ${CROSS} ] ; then
+  make -j1 deb-pkg KBUILD_DEBARCH=armhf ARCH=arm DEBFULLNAME="$MAINTAINER" DEBEMAIL="$MAINTAINERMAIL" CROSS_COMPILE=arm-linux-gnueabihf-
+else
+  make -j1 deb-pkg KBUILD_DEBARCH=armhf DEBFULLNAME="$MAINTAINER" DEBEMAIL="$MAINTAINERMAIL"
+fi
 
-rm -rf /olinux/sunxi/config/boot.scr
-mkimage -C none -A arm -T script -d /olinux/config/boot.cmd /olinux/sunxi/boot.scr
+rm -rf ${TARGET}/config/boot.scr
+mkimage -C none -A arm -T script -d ${REP}/config/boot.cmd ${TARGET}/boot.scr