From dc518807a50c9732e1fb8cd5daeacab5c78c23c3 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 12 Jan 2016 20:14:54 +0100 Subject: [PATCH 01/14] Initial commit. Added README file. --- README | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 README diff --git a/README b/README new file mode 100644 index 0000000..e69de29 -- 2.26.2 From 1400643f0bd2bf3d3824cc8a6f4a9e65ab66f22d Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 12 Jan 2016 20:34:40 +0100 Subject: [PATCH 02/14] kernel/raspberrypi2: Created repository --- README | 1 + 1 file changed, 1 insertion(+) diff --git a/README b/README index e69de29..8d1c8b6 100644 --- a/README +++ b/README @@ -0,0 +1 @@ + -- 2.26.2 From f885aa39aeee4d7acbd569a991f381c17f5f7fc6 Mon Sep 17 00:00:00 2001 From: John Vogel Date: Fri, 13 May 2016 11:48:43 -0400 Subject: [PATCH 03/14] Add upstream source info to README --- README | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README b/README index 8d1c8b6..61f749e 100644 --- a/README +++ b/README @@ -1 +1,2 @@ - +upstream sources: + https://github.com/raspberrypi/linux -- 2.26.2 From 496c5154c4712d4759b15a633556f6bf6beaf59b Mon Sep 17 00:00:00 2001 From: John Vogel Date: Fri, 13 May 2016 20:51:43 -0400 Subject: [PATCH 04/14] work/README: add place holder for work dir --- work/README | 1 + 1 file changed, 1 insertion(+) create mode 100644 work/README diff --git a/work/README b/work/README new file mode 100644 index 0000000..3b8a04d --- /dev/null +++ b/work/README @@ -0,0 +1 @@ +place holder for version control -- 2.26.2 From aa408bf17c1cb790274e99818177a8f30d5ea7df Mon Sep 17 00:00:00 2001 From: John Vogel Date: Fri, 13 May 2016 22:44:24 -0400 Subject: [PATCH 05/14] Add Makefile Originally based on Makefile for raspberrypi. --- Makefile | 148 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..84a3ced --- /dev/null +++ b/Makefile @@ -0,0 +1,148 @@ +# +# src/kernel/Makefile +# + +TARGET = arm-crux-linux-gnueabihf + +PWD = $(shell pwd) +WORK = $(PWD)/work +CROSSTOOLS = /devel/crux-arm/toolchain/crosstools + +KERNEL_BRANCH = 4.5.y +KERNEL_VERSION = 4.5.4 +PATCH_VERSION = 20160513 + +CONFIG_FILE = config-$(KERNEL_VERSION)-raspberrypi2_$(PATCH_VERSION) +PATCH_FILE = linux-$(KERNEL_BRANCH)-rpi-$(PATCH_VERSION).patch +KERNEL_TARBALL = linux-$(KERNEL_VERSION).tar.xz + + +.PHONY: all clean config files image map menuconfig modules + +all: image modules map dtb + +clean: image-clean modules-clean map-clean dtb-clean + +distclean: clean image-distclean modules-distclean dtb-distclean map-distclean + +$(PWD)/$(KERNEL_TARBALL): + wget -P $(PWD) https://www.kernel.org/pub/linux/kernel/v4.x/$(KERNEL_TARBALL) + touch $@ + +$(PWD)/$(PATCH_FILE): + wget -P $(PWD) http://stygian.me/crux-arm/distfiles/$(PATCH_FILE) + touch $@ + +$(PWD)/$(CONFIG_FILE): + wget -P $(PWD) http://stygian.me/crux-arm/distfiles/$(CONFIG_FILE) + touch $@ + +files: $(PWD)/$(KERNEL_TARBALL) $(PWD)/$(PATCH_FILE) $(PWD)/$(CONFIG_FILE) + +$(WORK)/linux-$(KERNEL_VERSION): + bsdtar -C $(WORK) -xf $(PWD)/$(KERNEL_TARBALL) + patch -d $(WORK)/linux-$(KERNEL_VERSION) -p1 -i $(PWD)/$(PATCH_FILE) + sed -e 's|LINUX_COMPILE_BY=.*|LINUX_COMPILE_BY=devel|' \ + -e 's|LINUX_COMPILE_HOST=.*|LINUX_COMPILE_HOST=crux-arm.nu|' \ + -i $(WORK)/linux-$(KERNEL_VERSION)/scripts/mkcompile_h + touch $@ + +$(WORK)/linux-$(KERNEL_VERSION)/.config: $(WORK)/linux-$(KERNEL_VERSION) + cp -v $(PWD)/$(CONFIG_FILE) $@ + touch $@ + +config: files $(WORK)/linux-$(KERNEL_VERSION)/.config + +$(WORK)/zImage-$(KERNEL_VERSION): config + cd $(WORK)/linux-$(KERNEL_VERSION) && \ + export PATH=$(CROSSTOOLS)/bin:$$PATH && \ + export LD_LIBRARY_PATH=$(CROSSTOOLS)/lib:$$LD_LIBRARY_PATH && \ + make ARCH=arm CROSS_COMPILE=$(TARGET)- zImage + cp -v $(WORK)/linux-$(KERNEL_VERSION)/arch/arm/boot/zImage $@ + touch $@ + +$(WORK)/kernel7-$(KERNEL_VERSION).img: $(WORK)/zImage-$(KERNEL_VERSION) + chmod +x $(WORK)/linux-$(KERNEL_VERSION)/scripts/mkknlimg + cd $(WORK)/linux-$(KERNEL_VERSION) && \ + ./scripts/mkknlimg $(WORK)/zImage-$(KERNEL_VERSION) $@ + touch $@ + +image: $(WORK)/kernel7-$(KERNEL_VERSION).img + +image-clean: + rm -vf $(WORK)/zImage-$(KERNEL_VERSION) + rm -vf $(WORK)/kernel7-$(KERNEL_VERSION).img + if [ -d $(WORK)/linux-$(KERNEL_VERSION)/.config ]; then \ + cd $(WORK)/linux-$(KERNEL_VERSION) && \ + export PATH=$(CROSSTOOLS)/bin:$$PATH && \ + export LD_LIBRARY_PATH=$(CROSSTOOLS)/lib:$$LD_LIBRARY_PATH && \ + make ARCH=arm CROSS_COMPILE=$(TARGET)- clean ; \ + fi + +image-distclean: image-clean + rm -vrf $(WORK)/linux-$(KERNEL_VERSION) + +$(WORK)/dtb-$(KERNEL_VERSION): $(WORK)/linux-$(KERNEL_VERSION) + cd $(WORK)/linux-$(KERNEL_VERSION) && \ + export PATH=$(CROSSTOOLS)/bin:$$PATH && \ + export LD_LIBRARY_PATH=$(CROSSTOOLS):$$LD_LIBRARY_PATH && \ + make ARCH=arm CROSS_COMPILE=$(TARGET)- dtbs + rm -rf $(WORK)/dtb + mkdir -p $(WORK)/dtb/overlays + cp $(WORK)/linux-$(KERNEL_VERSION)/arch/arm/boot/dts/*.dtb $(WORK)/dtb + cp $(WORK)/linux-$(KERNEL_VERSION)/arch/arm/boot/dts/overlays/*.dtb* $(WORK)/dtb/overlays + mv $(WORK)/dtb $(WORK)/dtb-$(KERNEL_VERSION) + +$(WORK)/dtb-$(KERNEL_VERSION).tar.xz: $(WORK)/dtb-$(KERNEL_VERSION) + cd $(WORK)/dtb-$(KERNEL_VERSION) && \ + bsdtar --uid 0 --gid 0 -cvJf $(WORK)/dtb-$(KERNEL_VERSION).tar.xz * + +dtb: $(WORK)/dtb-$(KERNEL_VERSION).tar.xz + +dtb-clean: + rm -vf $(WORK)/dtb-$(KERNEL_VERSION).tar.xz + rm -vrf $(WORK)/dtb-$(KERNEL_VERSION) + +dtb-distclean: dtb-clean + +$(WORK)/modules-$(KERNEL_VERSION): $(WORK)/linux-$(KERNEL_VERSION) + cd $(WORK)/linux-$(KERNEL_VERSION) && \ + export PATH=$(CROSSTOOLS)/bin:$$PATH && \ + export LD_LIBRARY_PATH=$(LD_LIBRARY_PATH)/lib:$$LD_LIBRARY_PATH && \ + make ARCH=arm CROSS_COMPILE=$(TARGET)- modules && \ + make ARCH=arm CROSS_COMPILE=$(TARGET)- INSTALL_MOD_PATH=$(WORK)/modules-$(KERNEL_VERSION) modules_install + rm -f $(WORK)/modules-$(KERNEL_VERSION)/lib/modules/$(KERNEL_VERSION)/{source,build} + touch $(WORK)/modules-$(KERNEL_VERSION) + +$(WORK)/modules-$(KERNEL_VERSION).tar.xz: $(WORK)/modules-$(KERNEL_VERSION) + cd $(WORK)/modules-$(KERNEL_VERSION) && \ + bsdtar --uid 0 --gid 0 -cvJf $(WORK)/modules-$(KERNEL_VERSION).tar.xz * + touch $(WORK)/modules-$(KERNEL_VERSION).tar.xz + +modules: $(WORK)/modules-$(KERNEL_VERSION).tar.xz + +modules-clean: + rm -vf $(WORK)/modules-$(KERNEL_VERSION).tar.xz + rm -vrf $(WORK)/modules-$(KERNEL_VERSION) + +modules-distclean: modules-clean + +$(WORK)/System.map-$(KERNEL_VERSION): $(WORK)/zImage-$(KERNEL_VERSION) + cp $(WORK)/linux-$(KERNEL_VERSION)/System.map $(WORK)/System.map-$(KERNEL_VERSION) + touch $(WORK)/System.map-$(KERNEL_VERSION) + +map: $(WORK)/System.map-$(KERNEL_VERSION) + +map-clean: + rm -vf $(WORK)/System.map-$(KERNEL_VERSION) + +map-distclean: map-clean + +menuconfig: $(WORK)/linux-$(KERNEL_VERSION) + cd $(WORK)/linux-$(KERNEL_VERSION) && \ + export PATH=$(CROSSTOOLS)/bin:$$PATH && \ + export LD_LIBRARY_PATH=$(CROSSTOOLS)/lib:$$LD_LIBRARY_PATH && \ + make ARCH=arm CROSS_COMPILE=$(TARGET)- menuconfig + touch $(WORK)/linux-$(KERNEL_VERSION) + +# End of file -- 2.26.2 From e0384e72f6af04f53d28fd2fe9e9788c88805486 Mon Sep 17 00:00:00 2001 From: John Vogel Date: Fri, 13 May 2016 22:57:31 -0400 Subject: [PATCH 06/14] Add more upstream source and howto for patch --- README | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README b/README index 61f749e..68ded37 100644 --- a/README +++ b/README @@ -1,2 +1,20 @@ +Crux-arm RaspberryPi2 Linux Kernel + upstream sources: + https://www.kernel.org/pub/linux/kernel/v4.x + git://git.kernel.org/pub/scm/linux/kernel/git/statble/linux-stable.git https://github.com/raspberrypi/linux + + +Generating the kernel patch: + +This is a stripped down description of how I generated the kernel patch. +It is based on how I thought it might have been done by Alpine Linux for +there raspberrypi kernel. + +git clone -b rpi-4.5.y https://github.com/raspberrypi/linux.git linux-rpi +cd linux-rpi +git remote add -b linux-4.5.y stable-4.5 \ + git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git +git pull stable-4.5 +git diff stable-4.5..rpi-4.5.y > ../linux-4.5.y-rpi-$(date +%Y%m%d).patch -- 2.26.2 From 64e7c26f46a86e956246911f173cc8cb26dcfdf2 Mon Sep 17 00:00:00 2001 From: John Vogel Date: Fri, 13 May 2016 23:09:28 -0400 Subject: [PATCH 07/14] Makefile: remove verbosity from rm commands --- Makefile | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 84a3ced..2ee081b 100644 --- a/Makefile +++ b/Makefile @@ -70,8 +70,8 @@ $(WORK)/kernel7-$(KERNEL_VERSION).img: $(WORK)/zImage-$(KERNEL_VERSION) image: $(WORK)/kernel7-$(KERNEL_VERSION).img image-clean: - rm -vf $(WORK)/zImage-$(KERNEL_VERSION) - rm -vf $(WORK)/kernel7-$(KERNEL_VERSION).img + rm -f $(WORK)/zImage-$(KERNEL_VERSION) + rm -f $(WORK)/kernel7-$(KERNEL_VERSION).img if [ -d $(WORK)/linux-$(KERNEL_VERSION)/.config ]; then \ cd $(WORK)/linux-$(KERNEL_VERSION) && \ export PATH=$(CROSSTOOLS)/bin:$$PATH && \ @@ -80,7 +80,7 @@ image-clean: fi image-distclean: image-clean - rm -vrf $(WORK)/linux-$(KERNEL_VERSION) + rm -rf $(WORK)/linux-$(KERNEL_VERSION) $(WORK)/dtb-$(KERNEL_VERSION): $(WORK)/linux-$(KERNEL_VERSION) cd $(WORK)/linux-$(KERNEL_VERSION) && \ @@ -100,8 +100,8 @@ $(WORK)/dtb-$(KERNEL_VERSION).tar.xz: $(WORK)/dtb-$(KERNEL_VERSION) dtb: $(WORK)/dtb-$(KERNEL_VERSION).tar.xz dtb-clean: - rm -vf $(WORK)/dtb-$(KERNEL_VERSION).tar.xz - rm -vrf $(WORK)/dtb-$(KERNEL_VERSION) + rm -f $(WORK)/dtb-$(KERNEL_VERSION).tar.xz + rm -rf $(WORK)/dtb-$(KERNEL_VERSION) dtb-distclean: dtb-clean @@ -122,8 +122,8 @@ $(WORK)/modules-$(KERNEL_VERSION).tar.xz: $(WORK)/modules-$(KERNEL_VERSION) modules: $(WORK)/modules-$(KERNEL_VERSION).tar.xz modules-clean: - rm -vf $(WORK)/modules-$(KERNEL_VERSION).tar.xz - rm -vrf $(WORK)/modules-$(KERNEL_VERSION) + rm -f $(WORK)/modules-$(KERNEL_VERSION).tar.xz + rm -rf $(WORK)/modules-$(KERNEL_VERSION) modules-distclean: modules-clean @@ -134,7 +134,7 @@ $(WORK)/System.map-$(KERNEL_VERSION): $(WORK)/zImage-$(KERNEL_VERSION) map: $(WORK)/System.map-$(KERNEL_VERSION) map-clean: - rm -vf $(WORK)/System.map-$(KERNEL_VERSION) + rm -f $(WORK)/System.map-$(KERNEL_VERSION) map-distclean: map-clean -- 2.26.2 From ccd03144532de8aad4bc3638499e25a70481c91a Mon Sep 17 00:00:00 2001 From: John Vogel Date: Fri, 13 May 2016 23:18:57 -0400 Subject: [PATCH 08/14] Add .gitignore --- .gitignore | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1d7b18b --- /dev/null +++ b/.gitignore @@ -0,0 +1,24 @@ +# based on .gitignore from linux kernel +# +# NOTE! Please use 'git ls-files -i --exclude-standard' +# command after changing this file, to see if there are +# any tracked files which get ignored after the change. +# +# Normal rules +# +*.tar +*.gz +*.bz2 +*.lzma +*.xz +*.lz4 +*.lzo +*.patch +work/System.map-* +work/dtb-*.tar.* +work/dtb-* +work/kernel7-*.img +work/linux-* +work/modules-*.tar.* +work/modules-* +work/zImage-* -- 2.26.2 From 8f6d6b885da69fb88469755d958f38b7448f1a33 Mon Sep 17 00:00:00 2001 From: John Vogel Date: Fri, 13 May 2016 23:20:14 -0400 Subject: [PATCH 09/14] .gitignore: add kernel config file --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 1d7b18b..5598345 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ *.lz4 *.lzo *.patch +config-*-raspberrypi2_* work/System.map-* work/dtb-*.tar.* work/dtb-* -- 2.26.2 From 70f63995f26726ac7a6fa2c4e444b43ff269e49a Mon Sep 17 00:00:00 2001 From: John Vogel Date: Sat, 14 May 2016 00:17:30 -0400 Subject: [PATCH 10/14] README: start adding instructions --- README | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/README b/README index 68ded37..7aa87a7 100644 --- a/README +++ b/README @@ -1,10 +1,41 @@ Crux-arm RaspberryPi2 Linux Kernel +NOTE: This README is wip. Some instructions are either vague or missing. + upstream sources: https://www.kernel.org/pub/linux/kernel/v4.x git://git.kernel.org/pub/scm/linux/kernel/git/statble/linux-stable.git https://github.com/raspberrypi/linux +Type make or make all to build kernel image, the device tree files/overlays, +modules and related files. You may also find some of the other targets useful; +either for rebuilding only a certain target or possibly downloading files for +later offline build. These currently include: + +all: build all targets +clean: clean out built files/directories +distclean: clean, plus remove even downloaded files also +files: download all remote files +config: unpatch the kernel and copy the default config into the kernel tree +image: build zImage and rpi2 prep'd kernel image files +dtb: build device tree database/overlay files, tarball +modules: build kernel modules, tarball +menuconfig: run menuconfig for kernel, starting with default kernel config + +For booting the kernel, you will also need to download these addition files: +bootcode.bin: https://github.com/raspberrypi/firmware/raw/master/boot/bootcode.bin +start.elf: https://github.com/raspberrypi/firmware/raw/master/boot/start.elf + +Sd card layout: + +first partition, boot (fat32): +kernel-$version.img, System.map-$version, bootcode.bin, start.elf, config.txt, cmdline.txt +Untar the dtb tarball (dtb-$version.tar.*) to the boot partition. + +second partition, root (ext{2,3,4}, xfs, btrfs, etc): +Untar the modules tarball (modules-$version.tar.*) to the root partition. +Untar all the package files created by crossrootfs and raspberrypi2-arm to +the root partition. Generating the kernel patch: -- 2.26.2 From 3365836dd9f7a778e30b027225480cca84fb93f5 Mon Sep 17 00:00:00 2001 From: John Vogel Date: Sat, 14 May 2016 00:22:36 -0400 Subject: [PATCH 11/14] README: fix git diff command The actual patch generation was erroneus; had used the name of the remote in place of the starting branch for the diff. --- README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README b/README index 7aa87a7..476986b 100644 --- a/README +++ b/README @@ -48,4 +48,4 @@ cd linux-rpi git remote add -b linux-4.5.y stable-4.5 \ git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git git pull stable-4.5 -git diff stable-4.5..rpi-4.5.y > ../linux-4.5.y-rpi-$(date +%Y%m%d).patch +git diff linux-4.5.y..rpi-4.5.y > ../linux-4.5.y-rpi-$(date +%Y%m%d).patch -- 2.26.2 From 23c365d9e81cbf137644580c0562ad23fb087933 Mon Sep 17 00:00:00 2001 From: John Vogel Date: Sat, 14 May 2016 12:31:26 -0400 Subject: [PATCH 12/14] README: add some more details for bootup files --- README | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README b/README index 476986b..fbb04a6 100644 --- a/README +++ b/README @@ -25,6 +25,11 @@ menuconfig: run menuconfig for kernel, starting with default kernel config For booting the kernel, you will also need to download these addition files: bootcode.bin: https://github.com/raspberrypi/firmware/raw/master/boot/bootcode.bin start.elf: https://github.com/raspberrypi/firmware/raw/master/boot/start.elf +fixup.dat: https://github.com/raspberrypi/firmware/raw/master/boot/start.elf + +(Two other files are needed in the boot partition: config.txt and cmdline.txt. + I will add more about these files next edit, as well as provide links to + existing official/semi-official documentation for this files) Sd card layout: -- 2.26.2 From 241545a6ee97906811d237a1bd9dbf1363519a47 Mon Sep 17 00:00:00 2001 From: John Vogel Date: Sat, 14 May 2016 16:13:01 -0400 Subject: [PATCH 13/14] README: add my config.txt and cmdline.txt Should help others get the kernel that's been setup to work more readily, since vc4 seems to be touchy to get working. --- README | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/README b/README index fbb04a6..de0f6ad 100644 --- a/README +++ b/README @@ -31,7 +31,22 @@ fixup.dat: https://github.com/raspberrypi/firmware/raw/master/boot/start.elf I will add more about these files next edit, as well as provide links to existing official/semi-official documentation for this files) -Sd card layout: +my current config.txt: +disable_splash=1 +gpu_mem=256 +kernel=kernel7-4.5.4.img +avoid_warnings=2 +dtoverlay=vc4-kms-v3d + +my current cmdline.txt: +dwg_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty root=/dev/mmcblk0p3 rootfstype=ext4 rootwait + +For the above two files, bare in mind that my sd card partition layout is as follows: +mmcblk0p1: fat32, boot files (mounted to /boot in fstab) +mmcblk0p2: swap +mmcblk0p3: ext4, root filesystem + +Sd card layout (as found on most howtos in the wild): first partition, boot (fat32): kernel-$version.img, System.map-$version, bootcode.bin, start.elf, config.txt, cmdline.txt -- 2.26.2 From 6c30d911a95675eddc2542536c460c243d503ffb Mon Sep 17 00:00:00 2001 From: John Vogel Date: Sat, 14 May 2016 16:16:29 -0400 Subject: [PATCH 14/14] README: add fixup.dat to part1 file list --- README | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README b/README index de0f6ad..dc3dcdc 100644 --- a/README +++ b/README @@ -49,13 +49,14 @@ mmcblk0p3: ext4, root filesystem Sd card layout (as found on most howtos in the wild): first partition, boot (fat32): -kernel-$version.img, System.map-$version, bootcode.bin, start.elf, config.txt, cmdline.txt +kernel-$version.img, System.map-$version, bootcode.bin, start.elf, fixup.dat, + config.txt, and cmdline.txt Untar the dtb tarball (dtb-$version.tar.*) to the boot partition. second partition, root (ext{2,3,4}, xfs, btrfs, etc): Untar the modules tarball (modules-$version.tar.*) to the root partition. Untar all the package files created by crossrootfs and raspberrypi2-arm to -the root partition. + the root partition. Generating the kernel patch: -- 2.26.2