Browse Source

repository refactoring

Émile Morel 10 years ago
parent
commit
9dc0bf386d

+ 29 - 85
README.md

@@ -2,141 +2,85 @@ Debian-Sunxi
 ==========
 
 Bootstrap a minimal debian rootfs with sunxi kernel and boot files. For now
-only 3 olinuxino boards are available. All scripts in this repository are
+only 4 olinuxino boards are available. All scripts in this repository are
 generic so it's easy to add a new boad. Please make a pull request if you
-create and test a new board. I need reviewer for olinuxino lime2 and micro
+create and test a new board. I need reviewers for olinuxino lime2 and micro
 olinuxino boards.
 
 Thanks to [lukas2511](https://github.com/lukas2511/olinuxino-a20-micro) for
-quick bootstrap.
+quick bootstrap, and [igorpecovnik](https://github.com/igorpecovnik/lib) for
+some useful scripts.
 
 # Build docker image
 
 ```shell
-sudo docker pull debian:stable
 git clone https://github.com/bleuchtang/sunxi-debian
 cd sunxi-debian && sudo docker build -t debian:olinux .
 ```
 
-# Build minimal arm debootstrap
-
-We cannot perform a debootstrap in dockerfile because dockerfile doesn't accept
-privileged mode. For more details see [docker
-issue](https://github.com/docker/docker/issues/1916)
-
-To build the minimal debian rootfs run:
-
-```shell
-sudo docker run --privileged -i -t -v $(pwd)/olinux/:/olinux/ debian:olinux sh ./olinux/create_arm_debootstrap.sh
-```
-
-Optional arguments:
-+ -n <name> hostnane
-+ -a <packages> add additional packages
-+ -d <release> debian release (wheezy, jessie...)
-
 # Build sunxi kernel and boot files
 
 To build sunxi kernel and boot files run:
 
 ```shell
-sudo docker run --privileged -i -t -v $(pwd)/olinux/:/olinux/ debian:olinux sh ./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
 ```
 
 Optional arguments:
 + -o offline mode; doesn't pull repositories so you should have run the script once without this option
-+ -t <type> board type (lime,lime2,micro) default is A20 lime
++ -b <type> board type (lime,lime2,micro) default is A20 lime
++ -t <number> number of thread for compilation
++ -l change linux logo on u-boot and kernel 
 
-# Install on a SD card
-
-## Setup SD card device
+# Build minimal arm debootstrap
 
-Find your device card (with dmesg for instance) and put it in a variable.
+We cannot perform a debootstrap in dockerfile because dockerfile doesn't accept
+privileged mode. For more details see [docker issue](https://github.com/docker/docker/issues/1916)
 
+To build the minimal debian rootfs with the kernel previously build:
 
 ```shell
-mmc=/dev/sdc
+sudo docker run --privileged -i -t -v $(pwd)/olinux/:/olinux/ debian:olinux bash ./olinux/create_arm_debootstrap.sh -i
 ```
 
-## Partitioning
-
-Make 2 partitions; one for boot files (kernel, file with custom boot args...),
-and another for root fs.
-
-```shell
-parted -s ${mmc} mklabel msdos
-parted -a optimal ${mmc} mkpart primary fat32 1 16MiB
-parted -a optimal ${mmc} mkpart primary fat32 16MiB 100%
-mkfs.fat -F 32 ${mmc}1
-mkfs.ext4 ${mmc}2
-```
+Optional arguments:
++ -n <name> hostnane
++ -a <packages> add additional packages
++ -d <release> debian release (wheezy, jessie...)
++ -i install kernel previously build
++ -y install yunohost with chroot (testing)
 
-## Installation
+# Install on a SD card
 
-### Boot partition
+## Setup SD card device
 
-Make SD card bootable, add kernel your previously builded and file with
-motherboard paramaters.
+Find your device card (with dmesg for instance). Call create_device script with
+this device in parameter. This script install debootstrap previously build. 
 
 ```shell
-mkdir -p /media/usb
-dd if=olinux/sunxi/u-boot-sunxi/u-boot-sunxi-with-spl.bin of=${mmc} bs=1024 seek=8
-mount ${mmc}1 /media/usb/
-cp olinux/sunxi/linux-sunxi/arch/arm/boot/uImage /media/usb/
-cp olinux/sunxi/script.bin /media/usb/
+sudo bash olinux/create_device.sh -d /dev/sdc
 ```
 
-If you want to do a server without graphical session, you can disable allocated
-ram for the graphical card. To do that copy uEnv.txt file; This file add custom
-kernel parameters to save 32MB of ram. If you want to use the graphical card;
-don't copy uEnv.txt file.
+You can directly create a image file that you can copy after on your sd card or share with others. 
 
 ```shell
-cp olinux/uEnv.txt /media/usb/
-umount /media/usb
+sudo bash olinux/create_device.sh -d img -s 500
 ```
 
-### Root partition
-
-Copy the rootfs you previously builded with debootstrap, and add firmware and
-modules build with sunxi kernel.
-
-```shell
-mount ${mmc}2 /media/usb/
-cp -r olinux/debootstrap/* /media/usb/
-sync
-chmod 1777 /media/usb/tmp/
-rm -rf /media/usb/lib/firmware/
-cp -rf olinux/sunxi/linux-sunxi/out/lib/firmware/ /media/usb/lib/
-sync
-rm -rf /media/usb/lib/modules/
-cp -rf olinux/sunxi/linux-sunxi/out/lib/modules/ /media/usb/lib/
-sync
-umount /media/usb
-```
+# Login to your Olimex
 
-You can now connect to your box via ssh. Default root password is _olinux_.
-After your first connection on your box you should run depmod to build moddep
-file.
+Find IP and ssh on it! (password: olinux)
 
 ```shell
 ssh root@mybox
-depmod -a
 ```
 
-That's it ! Now you probably doesn't want do more system administration for
-your home server so get an eye on [yunohost](https://yunohost.org/#/) ;)
-
-# TODO
-
-- change _Install on a SD card_ to a script ?
-
 # Some links:
 
 ## You probably want to Build your own docker image
 
 - Because it's quick and easy; tutorial [here](http://www.aossama.com/build-debian-docker-image-from-scratch/)
-- Because you shoudn't trust regitry images; demonstration [here](https://joeyh.name/blog/entry/docker_run_debian/)
+- Because you shouldn't trust registry images; demonstration [here](https://joeyh.name/blog/entry/docker_run_debian/)
 
 ## External links
 

+ 4 - 0
olinux/config/boot.cmd

@@ -0,0 +1,4 @@
+ext2load mmc 0 0x46000000 /boot/zImage
+ext2load mmc 0 0x49000000 /boot/board.dtb
+setenv bootargs console=tty0 hdmi.audio=EDID:0 disp.screen0_output_mode=EDID:1280x720p60 root=/dev/mmcblk0p1 rootwait sunxi_ve_mem_reserve=0 sunxi_g2d_mem_reserve=0 sunxi_no_mali_mem_reserve sunxi_fb_mem_reserve=0 panic=10 loglevel=8 consoleblank=0
+bootz 0x46000000 - 0x49000000

File diff suppressed because it is too large
+ 2610 - 0
olinux/config/linux-sunxi.config


+ 22 - 0
olinux/config_board.sh

@@ -0,0 +1,22 @@
+#!/bin/bash
+
+case $BOARD in
+
+  a20lime2)
+    U_BOOT_CONFIG="A20-OLinuXino-Lime2_defconfig"
+    DTB="sun7i-a20-olinuxino-lime2.dtb"
+    ;;
+  a20micro)
+    U_BOOT_CONFIG="A20-OLinuXino_MICRO_defconfig"
+    DTB="sun7i-a20-olinuxino-micro.dtb"
+    ;;
+  a10lime)
+    U_BOOT_CONFIG="A10-OLinuXino-Lime_defconfig"
+    DTB="sun7i-a20-olinuxino-lime.dtb"
+    ;;
+  *)
+    U_BOOT_CONFIG="A20-OLinuXino-Lime_defconfig"
+    DTB="sun7i-a20-olinuxino-lime.dtb"
+    ;;
+
+esac

BIN
olinux/logo/LDN_logo.bmp


File diff suppressed because it is too large
+ 3505 - 0
olinux/logo/LDN_logo.ppm


+ 109 - 0
olinux/patch/packaging-next.patch

@@ -0,0 +1,109 @@
+diff --git a/scripts/Makefile.dtbinst b/scripts/Makefile.dtbinst
+old mode 100644
+new mode 100755
+index 909ed7a..f69e726
+--- a/scripts/Makefile.dtbinst
++++ b/scripts/Makefile.dtbinst
+@@ -23,8 +23,8 @@ include $(srctree)/$(obj)/Makefile
+ PHONY += __dtbs_install_prep
+ __dtbs_install_prep:
+ ifeq ("$(dtbinst-root)", "$(obj)")
+-	$(Q)if [ -d $(INSTALL_DTBS_PATH).old ]; then rm -rf $(INSTALL_DTBS_PATH).old; fi
+-	$(Q)if [ -d $(INSTALL_DTBS_PATH) ]; then mv $(INSTALL_DTBS_PATH) $(INSTALL_DTBS_PATH).old; fi
++	#$(Q)if [ -d $(INSTALL_DTBS_PATH).old ]; then rm -rf $(INSTALL_DTBS_PATH).old; fi
++	#$(Q)if [ -d $(INSTALL_DTBS_PATH) ]; then mv $(INSTALL_DTBS_PATH) $(INSTALL_DTBS_PATH).old; fi
+ 	$(Q)mkdir -p $(INSTALL_DTBS_PATH)
+ endif
+ 
+diff --git a/scripts/package/builddeb b/scripts/package/builddeb
+index 5972624..272d558 100755
+--- a/scripts/package/builddeb
++++ b/scripts/package/builddeb
+@@ -80,10 +80,12 @@ tmpdir="$objtree/debian/tmp"
+ fwdir="$objtree/debian/fwtmp"
+ kernel_headers_dir="$objtree/debian/hdrtmp"
+ libc_headers_dir="$objtree/debian/headertmp"
++dtb_dir="$objtree/debian/dtbtmp"
+ dbg_dir="$objtree/debian/dbgtmp"
+ packagename=linux-image-$version
+ fwpackagename=linux-firmware-image-$version
+ kernel_headers_packagename=linux-headers-$version
++dtb_packagename=linux-dtb-$version
+ libc_headers_packagename=linux-libc-dev
+ dbg_packagename=$packagename-dbg
+ 
+@@ -108,13 +110,17 @@ esac
+ BUILD_DEBUG="$(grep -s '^CONFIG_DEBUG_INFO=y' $KCONFIG_CONFIG || true)"
+ 
+ # Setup the directory structure
+-rm -rf "$tmpdir" "$fwdir" "$kernel_headers_dir" "$libc_headers_dir" "$dbg_dir"
++rm -rf "$tmpdir" "$fwdir" "$kernel_headers_dir" "$libc_headers_dir" "$dbg_dir" "$dtb_dir"
+ mkdir -m 755 -p "$tmpdir/DEBIAN"
+ mkdir -p  "$tmpdir/lib" "$tmpdir/boot" "$tmpdir/usr/share/doc/$packagename"
+ mkdir -m 755 -p "$fwdir/DEBIAN"
+ mkdir -p "$fwdir/lib/firmware/$version/" "$fwdir/usr/share/doc/$fwpackagename"
+ mkdir -m 755 -p "$libc_headers_dir/DEBIAN"
+ mkdir -p "$libc_headers_dir/usr/share/doc/$libc_headers_packagename"
++
++mkdir -m 755 -p "$dtb_dir/DEBIAN"
++mkdir -p "$dtb_dir/boot/dtb" "$dtb_dir/usr/share/doc/$dtb_packagename"
++
+ mkdir -m 755 -p "$kernel_headers_dir/DEBIAN"
+ mkdir -p "$kernel_headers_dir/usr/share/doc/$kernel_headers_packagename"
+ mkdir -p "$kernel_headers_dir/lib/modules/$version/"
+@@ -165,6 +171,11 @@ if grep -q '^CONFIG_MODULES=y' $KCONFIG_CONFIG ; then
+ 	fi
+ fi
+ 
++if grep -q '^CONFIG_OF=y' $KCONFIG_CONFIG ; then
++	#mkdir -p "$tmpdir/boot/dtb"
++	INSTALL_DTBS_PATH="$dtb_dir/boot/dtb" $MAKE KBUILD_SRC= dtbs_install
++fi
++
+ if [ "$ARCH" != "um" ]; then
+ 	$MAKE headers_check KBUILD_SRC=
+ 	$MAKE headers_install KBUILD_SRC= INSTALL_HDR_PATH="$libc_headers_dir/usr"
+@@ -189,9 +200,11 @@ for script in postinst postrm preinst prerm ; do
+ set -e
+ 
+ # Pass maintainer script parameters to hook scripts
++
+ export DEB_MAINT_PARAMS="\$*"
+ 
+ # Tell initramfs builder whether it's wanted
++
+ export INITRD=$want_initrd
+ 
+ test -d $debhookdir/$script.d && run-parts --arg="$version" --arg="/$installed_image_path" $debhookdir/$script.d
+@@ -200,6 +213,14 @@ EOF
+ 	chmod 755 "$tmpdir/DEBIAN/$script"
+ done
+ 
++##
++## Create sym link to kernel image
++##
++kernel_tmp_version="${installed_image_path////\\/}"
++sed -e "s/exit 0/ln -sf \/$kernel_tmp_version \/boot\/zImage/g" -i $tmpdir/DEBIAN/postinst
++echo "exit 0" >> $tmpdir/DEBIAN/postinst
++
++
+ # Try to determine maintainer and email values
+ if [ -n "$DEBEMAIL" ]; then
+        email=$DEBEMAIL
+@@ -330,6 +351,16 @@ fi
+ 
+ cat <<EOF >> debian/control
+ 
++Package: $dtb_packagename
++Architecture: any
++Description: Linux DTB, version $version
++ This package contains device blobs from the Linux kernel, version $version.
++EOF
++
++create_package "$dtb_packagename" "$dtb_dir"
++
++cat <<EOF >> debian/control
++
+ Package: $libc_headers_packagename
+ Section: devel
+ Provides: linux-kernel-headers

olinux/binfmt-misc-arm.sh → olinux/script/binfmt-misc-arm.sh


+ 53 - 0
olinux/script/firstrun

@@ -0,0 +1,53 @@
+#!/bin/bash
+
+### BEGIN INIT INFO
+# Provides:          firstrun
+# Required-Start:    $all
+# Required-Stop:
+# Should-Start:
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: Script to run when first starting
+# Description:       Something needs to be done when  is
+#                    starting at first time.
+#                    regenerate ssh host key
+#                    run depmod 
+### END INIT INFO
+
+# script from https://github.com/igorpecovnik/lib
+# modified by https://github.com/bleuchtang/sunxi-debian
+
+N=/etc/init.d/firstrun
+
+set -e
+
+case "$1" in
+  start)
+            reboot=false
+                echo ""
+                rm -f /etc/ssh/ssh_host*
+                dpkg-reconfigure openssh-server 
+                set +e
+                echo "Expanding rootfs..."
+		device="/dev/mmcblk0"
+		((echo d; echo n; echo p; echo 1; echo ; echo; echo w;) | fdisk $device)>/dev/null
+                if [ $? -eq 0 ] ;then
+                        echo "Expanding rootfs success, rebooting automatically." 
+			/sbin/resize2fs /dev/mmcblk0p1 2>/dev/null
+                        reboot=true
+                else
+                        echo "Expanding rootfs has failed, see log files." 
+                fi
+		depmod -a
+                /sbin/insserv -r firstrun
+		if $reboot;then
+			/sbin/reboot
+		fi
+        ;;
+  *)
+        echo "Usage: $N {start}" >&2
+        exit 1
+        ;;
+esac
+
+exit 0