slitaz-arm rev 35

Improve Raspberry Pi support
author Christophe Lincoln <pankso@slitaz.org>
date Fri Mar 07 01:31:58 2014 +0100 (2014-03-07)
parents eeb23d633529
children 5445fd3856ad
files .hgignore README flavors/base/packages.list flavors/rpi/packages.list rpi/README rpi/rootfs/boot/cmdline.txt spi
line diff
     1.1 --- a/.hgignore	Thu Mar 06 22:58:40 2014 +0100
     1.2 +++ b/.hgignore	Fri Mar 07 01:31:58 2014 +0100
     1.3 @@ -2,4 +2,5 @@
     1.4  mirror/
     1.5  packages/
     1.6  spk/
     1.7 -rpi/
     1.8 +rpi/git
     1.9 +rpi/distro
     2.1 --- a/README	Thu Mar 06 22:58:40 2014 +0100
     2.2 +++ b/README	Fri Mar 07 01:31:58 2014 +0100
     2.3 @@ -5,8 +5,22 @@
     2.4  SliTaz ARM tools and files
     2.5  
     2.6  
     2.7 -Sat howto
     2.8 ----------
     2.9 +Installation
    2.10 +--------------------------------------------------------------------------------
    2.11 +To install 'sat' and 'spi' you must have make installed:
    2.12 +
    2.13 +# make install
    2.14 +
    2.15 +
    2.16 +rootfs/ directory
    2.17 +--------------------------------------------------------------------------------
    2.18 +Custom SliTaz ARM scripts and files used to generate a distro. These files
    2.19 +and any other system file can be erased or added via the flavors support. The
    2.20 +rootfs files can also be directly modified before generating a new distro. 
    2.21 +
    2.22 +
    2.23 +Sat quickstart
    2.24 +--------------
    2.25  Sat is a tool in the spirit of all SliTaz tools, all commands and options are
    2.26  accessible via: sat usage or help. To create a distro you first need to have
    2.27  some ARM packages. You can use custom cook or the one from the SliTaz mirror.
    2.28 @@ -25,7 +39,7 @@
    2.29  
    2.30  
    2.31  Mirror
    2.32 -------
    2.33 +--------------------------------------------------------------------------------
    2.34  Sat lets you clone the ARM cooking mirror to let you debug and try official ARM
    2.35  packages. Sat will create a mirror directory in the working path and download 
    2.36  all lists and packages. After a first clone it will only check the repo ID 
    2.37 @@ -33,12 +47,12 @@
    2.38  
    2.39  
    2.40  Bugs
    2.41 -----
    2.42 +--------------------------------------------------------------------------------
    2.43  Please report bugs on the Slitaz Bug Tracker: http://bugs.slitaz.org/
    2.44  
    2.45  
    2.46  History
    2.47 --------
    2.48 +--------------------------------------------------------------------------------
    2.49  While I was porting SliTaz to ARM I ended up by creating a lot of initramfs' 
    2.50  to test the SliTaz boot, packages and so on. So I first wrote a small script,
    2.51  then improved it by just having to put include packages in a single directory
     3.1 --- a/flavors/base/packages.list	Thu Mar 06 22:58:40 2014 +0100
     3.2 +++ b/flavors/base/packages.list	Fri Mar 07 01:31:58 2014 +0100
     3.3 @@ -7,6 +7,7 @@
     3.4  slitaz-base-files
     3.5  slitaz-boot-scripts
     3.6  slitaz-tools
     3.7 +spk
     3.8  tazirc
     3.9  util-linux-blkid
    3.10  util-linux-uuid
     4.1 --- a/flavors/rpi/packages.list	Thu Mar 06 22:58:40 2014 +0100
     4.2 +++ b/flavors/rpi/packages.list	Fri Mar 07 01:31:58 2014 +0100
     4.3 @@ -6,6 +6,7 @@
     4.4  slitaz-base-files
     4.5  slitaz-boot-scripts
     4.6  slitaz-tools
     4.7 +spk
     4.8  tazirc
     4.9  util-linux-blkid
    4.10  util-linux-uuid
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/rpi/README	Fri Mar 07 01:31:58 2014 +0100
     5.3 @@ -0,0 +1,25 @@
     5.4 +SliTaz RPi
     5.5 +================================================================================
     5.6 +
     5.7 +
     5.8 +SliTaz Raspberry Pi distro tools and files
     5.9 +
    5.10 +
    5.11 +Spi quickstart
    5.12 +--------------------------------------------------------------------------------
    5.13 +The Raspberry Pi have a lot of specification SliTaz ARM provide 'spi' to build
    5.14 +custom SliTaz Rpi distro's images ready to boot. To get the list of avalaible 
    5.15 +commands and options:
    5.16 +
    5.17 +# spi help
    5.18 +
    5.19 +Slitaz RPi mirror host the prebuilt Linux kernel package. To get the
    5.20 +latest version and unpack it:
    5.21 +
    5.22 +# spi get-linux
    5.23 +
    5.24 +The 'gen' command will generate a new SliTaz Raspberry Pi distro using 'sat'.
    5.25 +I will also install needed firmware and boot configuration files.
    5.26 +
    5.27 +# spi gen
    5.28 +
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/rpi/rootfs/boot/cmdline.txt	Fri Mar 07 01:31:58 2014 +0100
     6.3 @@ -0,0 +1,1 @@
     6.4 +root=/dev/mmcblk0p3 rootwait quiet
     7.1 --- a/spi	Thu Mar 06 22:58:40 2014 +0100
     7.2 +++ b/spi	Fri Mar 07 01:31:58 2014 +0100
     7.3 @@ -10,23 +10,25 @@
     7.4  # Paths
     7.5  [ "$work" ] || work="$(pwd)"
     7.6  distro="$work/distro"
     7.7 -data="$work/rpi/data"
     7.8 -boot="$work/rpi/boot"
     7.9 -rootfs="$work/rpi/rootfs"
    7.10 -kernel="$data/linux"
    7.11 -firmware="$data/firmware"
    7.12 -tools="$data/tools"
    7.13 +rpi="$work/rpi"
    7.14 +data="$rpi/distro/data"
    7.15 +boot="$rpi/distro/boot"
    7.16 +rootfs="$rpi/distro/rootfs"
    7.17 +rpi_git="$rpi/git"
    7.18 +kernel="$rpi_git/linux"
    7.19 +firmware="$rpi_git/firmware"
    7.20 +tools="$rpi_git/tools"
    7.21  
    7.22  # URLs
    7.23 -rpi_url="http://mirror.slitaz.org/arm/rpi/"
    7.24 +rpi_mirror="http://mirror.slitaz.org/arm/rpi/"
    7.25  fw_url="https://github.com/raspberrypi/firmware/raw/master/boot/"
    7.26  tools_url="https://raw.github.com/raspberrypi/tools/master/mkimage/"
    7.27 -lkgit_url="git://github.com/raspberrypi/linux.git"
    7.28 +rpi_git_url="git://github.com/raspberrypi/"
    7.29  
    7.30  # Lists
    7.31  fwlist="bootcode.bin fixup.dat start.elf"
    7.32  toolslist="imagetool-uncompressed.py args-uncompressed.txt \
    7.33 -boot-uncompressed.txt" #first32k.bin
    7.34 +boot-uncompressed.txt"
    7.35  
    7.36  #
    7.37  # Functions
    7.38 @@ -41,8 +43,10 @@
    7.39    info          Display paths and distro info
    7.40    install       Install SliTaz RPi to sdcard
    7.41    gen           Generate a new SliTaz RPi distro
    7.42 -  cooklinux     Build the Raspberry Pi Linux kernel
    7.43 +  cook-linux    Build the Raspberry Pi Linux kernel
    7.44 +  get-linux     Get a the SliTaz RPi linux package
    7.45    get-fw        Download or update RPi Firmware
    7.46 +  clone-fw      Clone the RPi Firmware repository
    7.47    get-tools     Download or update RPi Tools (mkimage)
    7.48    get-prebuilt  Get a prebuilt SliTaz ARM toolchain
    7.49    oclock        Display overclocking information
    7.50 @@ -66,30 +70,37 @@
    7.51  	separator
    7.52  }
    7.53  
    7.54 -# Get RPi firmware
    7.55 +# Get minimal RPi firmware
    7.56  get_fw() {
    7.57 -	mkdir -p $firmware
    7.58 +	mkdir -p $firmware/boot
    7.59  	for fw in $fwlist
    7.60  	do
    7.61 -		[ "$up" ] && rm -f $firmware/$fw
    7.62 -		if [ ! -f "$firmware/$fw" ]; then
    7.63 +		[ "$up" ] && rm -f $firmware/boot/$fw
    7.64 +		if [ ! -f "$firmware/boot/$fw" ]; then
    7.65  			echo -n "Fetching: $fw"
    7.66  			wget -q --no-check-certificate ${fw_url}${fw} \
    7.67 -				-O $firmware/${fw}; status
    7.68 +				-O $firmware/boot/${fw}; status
    7.69  		fi
    7.70  	done
    7.71  }
    7.72  
    7.73 +# Get all RPi firmware
    7.74 +clone_fw() {
    7.75 +	[ -d "${rpi_git}/firmware" ] && return 0
    7.76 +	mkdir -p ${rpi_git} && cd ${rpi_git}
    7.77 +	git clone --depth 1 ${rpi_git_url}firmware.git
    7.78 +}
    7.79 +
    7.80  # Get RPi tools
    7.81  get_tools() {
    7.82 -	mkdir -p $data
    7.83 +	mkdir -p $tools
    7.84  	for t in $toolslist
    7.85  	do
    7.86 -		[ "$up" ] && rm -f $data/$t
    7.87 +		[ "$up" ] && rm -f ${tools}/${t}
    7.88  		if [ ! -f "$data/$t" ]; then
    7.89  			echo -n "Fetching: $t"
    7.90  			wget -q --no-check-certificate ${tools_url}${t} \
    7.91 -				-O $data/${t}; status
    7.92 +				-O ${tools}/${t}; status
    7.93  		fi
    7.94  	done
    7.95  }
    7.96 @@ -139,7 +150,7 @@
    7.97  	info)
    7.98  		header "SliTaz Raspberry Pi info"
    7.99  		echo "Firmware : $fwlist" 
   7.100 -		echo "RPi path : $work/rpi"
   7.101 +		echo "RPi path : $rpi"
   7.102  		colorize 36 "/boot/cmdline.txt:"
   7.103  		cat ${boot}/cmdline.txt
   7.104  		colorize 36 "/boot/config.txt:"
   7.105 @@ -220,18 +231,30 @@
   7.106  		fi
   7.107  		header "SliTaz Raspberry Pi distro"
   7.108  		dsize="$(du -sh ${distro}/rootfs | awk '{print $1}')"
   7.109 -		echo -n "Copying the rootfs: $dsize"
   7.110 +		echo -n "Copying: rootfs ($dsize)"
   7.111  		cp -a ${distro}/rootfs ${rootfs}; status
   7.112  		
   7.113  		# Boot firmware
   7.114 -		echo -n "Installing: firmware files"
   7.115 +		echo -n "Copying: firmware files..."
   7.116  		get_fw
   7.117 -		cp $firmware/* ${boot}; status
   7.118 +		for fw in $fwlist
   7.119 +		do
   7.120 +			cp $firmware/boot/${fw} ${boot}
   7.121 +		done
   7.122 +		status
   7.123  		
   7.124 -		# /boot/cmdline.txt
   7.125 -		echo -n "Creating: /boot/cmdline.txt"
   7.126 -		echo 'root=/dev/mmcblk0p3 rootwait quiet' >> \
   7.127 -			${boot}/cmdline.txt; status
   7.128 +		# SliTaz Raspberry Pi custom rootfs files. Make sure all files 
   7.129 +		# belong to root
   7.130 +		if [ -d "$work/rootfs" ]; then
   7.131 +			size=$(du -sh $work/rootfs | awk '{print $1}')
   7.132 +			echo -n "Copying: SliTaz RPi rootfs ($size)"
   7.133 +			tmp=$distro/tmp-$$
   7.134 +			mkdir -p $tmp
   7.135 +			cp -r $work/rootfs/* $tmp
   7.136 +			chown -R root.root $tmp
   7.137 +			cp -a $tmp/* ${rootfs} && rm -rf $tmp
   7.138 +			status
   7.139 +		fi
   7.140  		
   7.141  		# /boot/config.txt
   7.142  		echo -n "Creating: /boot/config.txt"
   7.143 @@ -258,7 +281,7 @@
   7.144  		kvers=$(ls $data/linux-*/fs/lib/modules)
   7.145  		kpkg="$rootfs/var/lib/tazpkg/installed/linux"
   7.146  		if [ -d "$data/linux-$kvers/fs" ]; then
   7.147 -			echo -n "Installing: Linux Kernel $kvers"
   7.148 +			echo -n "Copying: Linux Kernel $kvers"
   7.149  			rm -rf ${rootfs}/lib/modules
   7.150  			cp -rf ${data}/linux-${kvers}/fs/lib/* ${rootfs}/lib
   7.151  			cp -f  ${data}/linux-${kvers}/fs/boot/* ${boot}
   7.152 @@ -282,7 +305,7 @@
   7.153  		echo "- Rootfs: $(du -sh $rootfs | awk '{print $1}')" 
   7.154  		newline ;;
   7.155  	
   7.156 -	linux)
   7.157 +	cook-linux)
   7.158  		# Native SliTaz Toolchain and cross toolchain must be installed
   7.159  		check_root
   7.160  		#: ${arch=armv6hf}
   7.161 @@ -293,7 +316,7 @@
   7.162  			exit 1
   7.163  		fi
   7.164  		# Kernel source
   7.165 -		[ -d "$kernel" ] || git clone --depth 1 ${lkgit_url}
   7.166 +		[ -d "$kernel" ] || git clone --depth 1 ${rpi_git_url}linux.git
   7.167  		
   7.168  		if [ ! -d "$install" ]; then
   7.169  			cd ${kernel}
   7.170 @@ -308,6 +331,10 @@
   7.171  			cp -a arch/arm/boot/zImage ${install}/boot
   7.172  		fi
   7.173  		
   7.174 +		# Compress all modules
   7.175 +		#echo -n "Searching all modules to compress them... "
   7.176 +		#find . -name "*.ko" -exec xz '{}' \; 2> /dev/null
   7.177 +		
   7.178  		# Pack
   7.179  		fs="$data/linux-$kvers/fs"
   7.180  		kvers=$(ls ${install}/lib/modules)
   7.181 @@ -321,8 +348,9 @@
   7.182  		fi
   7.183  		get_tools
   7.184  		echo "Compressing: zImage to kernel.img"
   7.185 +		cd ${tools}
   7.186 +		python imagetool-uncompressed.py ${fs}/boot/zImage
   7.187  		cd ${data}
   7.188 -		python imagetool-uncompressed.py ${fs}/boot/zImage
   7.189  		mv kernel.img ${fs}/boot && rm ${fs}/boot/zImage
   7.190  		echo "Creating package: receipt"
   7.191  		cat > linux-$kvers/receipt << EOT
   7.192 @@ -344,10 +372,11 @@
   7.193  		
   7.194  	get-linux)
   7.195  		# Precook RPi kernel
   7.196 +		mkdir -p ${data}
   7.197  		rm -f ${data}/linux-version.txt
   7.198 -		if busybox wget -q -s ${rpi_url}/last-linux.txt; then
   7.199 +		if busybox wget -q -s ${rpi_mirror}/last-linux.txt; then
   7.200  			echo -n "Fetching latest Kernel string..."
   7.201 -			wget -q ${rpi_url}/last-linux.txt \
   7.202 +			wget -q ${rpi_mirror}/last-linux.txt \
   7.203  				-O ${data}/linux-version.txt || exit 1
   7.204  			status
   7.205  		else
   7.206 @@ -359,7 +388,7 @@
   7.207  		# Download
   7.208  		if [ ! -f "$data/linux-$kvers.tazpkg" ]; then
   7.209  			echo -n "Fetching latest Linux package..."
   7.210 -			wget -q ${rpi_url}/linux-${kvers}.tazpkg \
   7.211 +			wget -q ${rpi_mirror}/linux-${kvers}.tazpkg \
   7.212  				-O ${data}/linux-${kvers}.tazpkg; status
   7.213  		fi
   7.214  		# Extract
   7.215 @@ -392,6 +421,9 @@
   7.216  		cp -a ${name}-${vers}/${arch}/* ${arch} 
   7.217  		echo "Tools path: /cross/${arch}/tools/bin" ;;
   7.218  	
   7.219 +	clone-fw)
   7.220 +		clone_fw ;;
   7.221 +	
   7.222  	oclock)
   7.223  		cat << EOT
   7.224