Browse code

RPi3 image builder improvements

Build everyting from sources:
- dtb files
- u-boot for RPi3 with uEFI support
- grub2-efi
only exception is the 1st stage propraitery bootloader that loads u-boot.

Binaries date/commit hash is:
https://github.com/raspberrypi/firmware/commit/23047785b7414111cb7cb80aa9d0042c99fae437

linux: added linux-dtb-rpi3 subpackage which contains dtb files for
Raspberry Pi 3

known issues/features:
1. u-boot tries network boot first even after grub is loaded
2. grub does not always shows a photon logo
3. timeout in a grub after loadinf the kernel image and before kernel
start. Sometime it shows "Out of Memory" message

I started to observe these 3 issues after compiling u-boot from sources.
Initialy, old binary version from Suse didn't have such problems.

One more new issues which started to observe after flashing new rpi3
image:
- linux kenrel can not initialize 256M cma memory.

Change-Id: I16c6dc0cf1eedb94ab8381dcba72424057793173
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/4718
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Srivatsa S. Bhat <srivatsab@vmware.com>
Reviewed-by: Bo Gan <ganb@vmware.com>

Alexey Makhalov authored on 2018/01/31 08:25:09
Showing 18 changed files
... ...
@@ -82,8 +82,13 @@ endif
82 82
 
83 83
 TOOLS_BIN := $(SRCROOT)/tools/bin
84 84
 CONTAIN := $(TOOLS_BIN)/contain
85
+ifeq ($(ARCH),x86_64)
85 86
 VIXDISKUTIL := $(TOOLS_BIN)/vixdiskutil
86 87
 IMGCONVERTER := $(TOOLS_BIN)/imgconverter
88
+else
89
+VIXDISKUTIL :=
90
+IMGCONVERTER :=
91
+endif
87 92
 
88 93
 .PHONY : all iso clean photon-build-machine photon-vagrant-build photon-vagrant-local cloud-image \
89 94
 check-tools check-docker check-bison check-g++ check-gawk check-repo-tool check-kpartx check-vagrant check-packer check-packer-ovf-plugin check-sanity \
90 95
new file mode 100644
... ...
@@ -0,0 +1,18 @@
0
+diff --git a/arch/arm/boot/dts/bcm2835-rpi.dtsi b/arch/arm/boot/dts/bcm2835-rpi.dtsi
1
+index e36c392a2b8f..409ee0460b22 100644
2
+--- a/arch/arm/boot/dts/bcm2835-rpi.dtsi
3
+@@ -27,6 +27,13 @@
4
+ 			firmware = <&firmware>;
5
+ 			#power-domain-cells = <1>;
6
+ 		};
7
++		vchiq: vchiq {
8
++			compatible = "brcm,bcm2835-vchiq";
9
++			reg = <0x7e00b840 0xf>;
10
++			interrupts = <0 2>;
11
++			cache-line-size = <32>;
12
++			firmware = <&firmware>;
13
++		};
14
+ 	};
15
+ };
16
+ 
... ...
@@ -2,7 +2,7 @@
2 2
 Summary:        Kernel
3 3
 Name:           linux
4 4
 Version:        4.14.8
5
-Release:        1%{?kat_build:.%kat_build}%{?dist}
5
+Release:        2%{?kat_build:.%kat_build}%{?dist}
6 6
 License:    	GPLv2
7 7
 URL:        	http://www.kernel.org/
8 8
 Group:        	System Environment/Kernel
... ...
@@ -25,6 +25,8 @@ Patch3:         SUNRPC-Do-not-reuse-srcport-for-TIME_WAIT-socket.patch
25 25
 Patch4:         SUNRPC-xs_bind-uses-ip_local_reserved_ports.patch
26 26
 Patch5:         vsock-transport-for-9p.patch
27 27
 Patch6:         x86-vmware-STA-support.patch
28
+# rpi3 dts
29
+Patch10:	arm-dts-add-vchiq-entry.patch
28 30
 #HyperV patches
29 31
 Patch13:        0004-vmbus-Don-t-spam-the-logs-with-unknown-GUIDs.patch
30 32
 # TODO: Is CONFIG_HYPERV_VSOCKETS the same?
... ...
@@ -105,6 +107,15 @@ Requires:       audit
105 105
 %description tools
106 106
 This package contains the 'perf' performance analysis tools for Linux kernel.
107 107
 
108
+%ifarch aarch64
109
+%package dtb-rpi3
110
+Summary:        Kernel Device Tree Blob files for Raspberry Pi3
111
+Group:          System Environment/Kernel
112
+Requires:       %{name} = %{version}-%{release}
113
+%description dtb-rpi3
114
+Kernel Device Tree Blob files for Raspberry Pi3
115
+%endif
116
+
108 117
 
109 118
 %prep
110 119
 %setup -q -n linux-%{version}
... ...
@@ -117,6 +128,7 @@ This package contains the 'perf' performance analysis tools for Linux kernel.
117 117
 %patch4 -p1
118 118
 %patch5 -p1
119 119
 %patch6 -p1
120
+%patch10 -p1
120 121
 %patch13 -p1
121 122
 %patch24 -p1
122 123
 %patch26 -p1
... ...
@@ -176,6 +188,7 @@ install -vdm 755 %{buildroot}%{_defaultdocdir}/%{name}-%{uname_r}
176 176
 install -vdm 755 %{buildroot}/usr/src/%{name}-headers-%{uname_r}
177 177
 install -vdm 755 %{buildroot}/usr/lib/debug/lib/modules/%{uname_r}
178 178
 make INSTALL_MOD_PATH=%{buildroot} modules_install
179
+
179 180
 %ifarch x86_64
180 181
 # install ENA module
181 182
 bldroot=`pwd`
... ...
@@ -197,9 +210,14 @@ if [ "$ID1" != "$ID2" ] ; then
197 197
 fi
198 198
 install -vm 644 arch/x86/boot/bzImage %{buildroot}/boot/vmlinuz-%{uname_r}
199 199
 %endif
200
+
200 201
 %ifarch aarch64
201 202
 install -vm 644 arch/arm64/boot/Image %{buildroot}/boot/vmlinuz-%{uname_r}
203
+# Install DTB files
204
+install -vdm 755 %{buildroot}/boot/dtb
205
+install -vm 640 arch/arm64/boot/dts/broadcom/bcm2837-rpi-3-b.dtb %{buildroot}/boot/dtb/
202 206
 %endif
207
+
203 208
 # Restrict the permission on System.map-X file
204 209
 install -vm 400 System.map %{buildroot}/boot/System.map-%{uname_r}
205 210
 install -vm 644 .config %{buildroot}/boot/config-%{uname_r}
... ...
@@ -316,7 +334,16 @@ ln -sf %{name}-%{uname_r}.cfg /boot/photon.cfg
316 316
 /usr/share/perf-core/strace/groups/file
317 317
 /usr/share/doc/*
318 318
 
319
+%ifarch aarch64
320
+%files dtb-rpi3
321
+%defattr(-,root,root)
322
+/boot/dtb/bcm2837-rpi-3-b.dtb
323
+%endif
324
+
319 325
 %changelog
326
+*   Fri Jan 26 2018 Alexey Makhalov <amakhalov@vmware.com> 4.14.8-2
327
+-   Added vchiq entry to rpi3 dts
328
+-   Added dtb-rpi3 subpackage
320 329
 *   Fri Dec 22 2017 Alexey Makhalov <amakhalov@vmware.com> 4.14.8-1
321 330
 -   Version update
322 331
 *   Wed Dec 13 2017 Alexey Makhalov <amakhalov@vmware.com> 4.9.66-4
... ...
@@ -1,12 +1,14 @@
1 1
 {
2 2
     "packages":["glibc", "zlib", "filesystem",
3
-                "pkg-config", "bash", "bzip2", "shadow", "procps-ng", "coreutils", "bc", "libtool", "net-tools",
4
-                "findutils", "xz", "iproute2", "util-linux", "kmod", "linux", "ca-certificates", "curl", "iptables", "Linux-PAM",
5
-                "systemd", "dbus", "file", "e2fsprogs", "rpm","gawk","gptfdisk",
3
+                "pkg-config", "bash", "bzip2", "shadow", "procps-ng",
4
+		"coreutils", "bc", "libtool", "net-tools", "findutils", "xz",
5
+		"iproute2", "util-linux", "kmod", "linux", "linux-dtb-rpi3",
6
+		"ca-certificates", "curl", "iptables", "Linux-PAM", "systemd",
7
+		"dbus", "file", "e2fsprogs", "rpm","gawk","gptfdisk",
6 8
                 "openssh", "gdbm", "parted",
7 9
                 "photon-release", "photon-repos",
8 10
                 "sed", "grep", "cpio", "gzip", "vim", "libdb", "tdnf",
9
-                "which", "tzdata", "motd", "gdbm"]
11
+                "which", "tzdata", "motd", "gdbm", "u-boot-rpi3" ]
10 12
 }
11 13
 
12 14
 
... ...
@@ -63,13 +63,16 @@ def create_vmdk_and_partition(config, vmdk_path):
63 63
             partitions_data['root'] = line.replace("ROOT_PARTITION=", "").strip()
64 64
             partitions_data['boot'] = partitions_data['root']
65 65
             partitions_data['bootdirectory'] = '/boot/'
66
-            count += 1
67
-
68
-    if count == 2:
69
-        partitions_data['partitions'] = [{'path': partitions_data['root'], 'mountpoint': '/',
66
+            partitions_data['partitions'] = [{'path': partitions_data['root'], 'mountpoint': '/',
70 67
                                           'filesystem': 'ext4'}]
68
+            count += 1
69
+        elif line.startswith("ESP_PARTITION="):
70
+            partitions_data['esp'] = line.replace("ESP_PARTITION=", "").strip()
71
+            partitions_data['partitions'].append({'path': partitions_data['esp'], 'mountpoint': '/boot/esp',
72
+                                          'filesystem': 'vfat'})
73
+            count += 1
71 74
 
72
-    return partitions_data, count == 2
75
+    return partitions_data, count == 2 or count == 3
73 76
 
74 77
 def get_file_name_with_last_folder(filename):
75 78
     basename = os.path.basename(filename)
76 79
deleted file mode 100755
77 80
Binary files a/support/cloud-image-builder/rpi3/esp/EFI/BOOT/bootaa64.efi and /dev/null differ
78 81
Binary files a/support/cloud-image-builder/rpi3/esp/bootcode.bin and b/support/cloud-image-builder/rpi3/esp/bootcode.bin differ
... ...
@@ -2,12 +2,9 @@
2 2
 # or on https://www.raspberrypi.org/documentation/configuration/config-txt.md
3 3
 # Our kernels are located on a Linux partition. Chainload U-Boot to load them.
4 4
 kernel=u-boot.bin
5
-# Use 64 MB for GPU for RPi with 256 MB (Min 16 - Max 192 MB)
6
-gpu_mem_256=64
7
-# Use 64 MB for GPU for RPi with 512 MB (Min 16 - Max 448 MB)
8
-gpu_mem_512=64
9 5
 # Use 128 MB for GPU for RPi with 1024 MB (Min 16 - Max 944 MB)
10
-gpu_mem_1024=128
6
+gpu_mem=256
7
+start_x=1
11 8
 # Turbo mode: 0 = enable dynamic freq/voltage - 1 = always max
12 9
 force_turbo=0
13 10
 # Start in turbo mode for 30 seconds or until cpufreq sets a frequency
... ...
@@ -19,4 +16,7 @@ arm_control=0x200
19 19
 # Fix mini UART input frequency, and setup/enable up the UART.
20 20
 enable_uart=1
21 21
 # Disable warning overlays as they don't work well together with linux's graphical output
22
-avoid_warnings=1
22
+avoid_warnings=2
23
+dtoverlay=vc4-kms-v3d
24
+
25
+hdmi_drive=2
23 26
Binary files a/support/cloud-image-builder/rpi3/esp/fixup.dat and b/support/cloud-image-builder/rpi3/esp/fixup.dat differ
24 27
Binary files a/support/cloud-image-builder/rpi3/esp/start.elf and b/support/cloud-image-builder/rpi3/esp/start.elf differ
25 28
new file mode 100755
26 29
Binary files /dev/null and b/support/cloud-image-builder/rpi3/esp/start_x.elf differ
27 30
deleted file mode 100755
28 31
Binary files a/support/cloud-image-builder/rpi3/esp/u-boot.bin and /dev/null differ
... ...
@@ -15,15 +15,20 @@
15 15
 
16 16
 grub_efi_install()
17 17
 {
18
-    mkdir -p $BUILDROOT/boot/efi
19
-    #
20
-    # if it is a loop device then we should mount the dev mapped boot partition
21
-    #
22 18
     BOOT_PARTITION=/dev/mapper/`basename ${HDD}`p1
23
-    mkfs.fat $BOOT_PARTITION
24
-    mount -t vfat $BOOT_PARTITION $BUILDROOT/boot/efi
25
-    cp -r esp/* $BUILDROOT/boot/efi/
26
-    umount $BUILDROOT/boot/efi
19
+#    mount -t vfat $BOOT_PARTITION $BUILDROOT/boot/esp
20
+    # Raspberry prorpiaetary GPU bootloader (1st stage)
21
+    cp -r esp/* $BUILDROOT/boot/esp/
22
+    # u-boot (2nd stage) was copied earlier by installer.py
23
+    # grub efi bootloader (3rd stage)
24
+    mkdir -p $BUILDROOT/boot/esp/EFI/BOOT/
25
+    cp EFI_aarch64/BOOT/* $BUILDROOT/boot/esp/EFI/BOOT/
26
+    mkdir -p $BUILDROOT/boot/esp/boot/grub2
27
+    cat > $BUILDROOT/boot/esp/boot/grub2/grub.cfg << EOF
28
+search -n -u ${BOOT_UUID} -s
29
+configfile ${BOOT_DIRECTORY}grub2/grub.cfg
30
+EOF
31
+#    umount $BUILDROOT/boot/esp
27 32
 }
28 33
 
29 34
 set -o errexit        # exit if error...insurance ;)
... ...
@@ -50,7 +55,7 @@ fi
50 50
 #
51 51
 #    Install grub2.
52 52
 #
53
-#BOOT_UUID=$(blkid -s UUID -o value $BOOT_PARTITION_PATH)
53
+BOOT_UUID=$(blkid -s UUID -o value $BOOT_PARTITION_PATH)
54 54
 
55 55
 mkdir -p $BUILDROOT/boot/grub2
56 56
 ln -sfv grub2 $BUILDROOT/boot/grub
... ...
@@ -64,7 +69,7 @@ cp boot/splash.png ${BUILDROOT}/boot/grub2/themes/photon/photon.png
64 64
 cp boot/terminal_*.tga ${BUILDROOT}/boot/grub2/themes/photon/
65 65
 cp boot/theme.txt ${BUILDROOT}/boot/grub2/themes/photon/
66 66
 
67
-EXTRA_PARAMS="rootwait rw console=ttyS0,115200n8 console=tty0"
67
+EXTRA_PARAMS="rootwait rw console=ttyS0,115200n8 console=tty0 cma=256M"
68 68
 
69 69
 cat > $BUILDROOT/boot/grub2/grub.cfg << EOF
70 70
 # Begin /boot/grub2/grub.cfg
... ...
@@ -83,10 +83,11 @@ echo "Creating raw disk file " $VMDK_IMAGE_NAME " of size " $TOTAL_SIZE
83 83
 dd if=/dev/zero of=$VMDK_IMAGE_NAME bs=1024 count=$(($TOTAL_SIZE * 1024 * 512))
84 84
 chmod 755 $VMDK_IMAGE_NAME
85 85
 
86
+parted -s $VMDK_IMAGE_NAME mklabel msdos mkpart primary fat32 1M 30M mkpart primary ext4 30M 100%
87
+
86 88
 echo "Associating loopdevice to raw disk"
87
-DISK_DEVICE=`losetup --show -f $VMDK_IMAGE_NAME`
89
+DISK_DEVICE=`losetup --show -f -P $VMDK_IMAGE_NAME`
88 90
 
89
-parted -s $DISK_DEVICE mklabel msdos mkpart primary fat32 1M 30M mkpart primary ext4 30M 100%
90 91
 #echo "Creating partition on raw disk"
91 92
 #if [ $SWAP_PARTITION_SIZE -gt 0 ] 
92 93
 #then
... ...
@@ -103,15 +104,18 @@ parted -s $DISK_DEVICE mklabel msdos mkpart primary fat32 1M 30M mkpart primary
103 103
 #    echo "BIOS boot partition"
104 104
 #    sgdisk -t1:ef02 $DISK_DEVICE >> $LOGFILE
105 105
 #fi
106
+
106 107
 echo "Mapping device partition to loop device"
107 108
 kpartx -avs $DISK_DEVICE >> $LOGFILE
108 109
 
109 110
 DEVICE_NAME=`echo $DISK_DEVICE|cut -c6- `
110 111
 
111
-echo "Adding file system to device partition"
112
-mkfs -t ext4 /dev/mapper/${DEVICE_NAME}p2
112
+echo "Formatting partitions"
113
+mkfs.ext4 /dev/mapper/${DEVICE_NAME}p2
114
+mkfs.fat /dev/mapper/${DEVICE_NAME}p1
113 115
 
114 116
 echo "DISK_DEVICE=$DISK_DEVICE"
115 117
 echo "ROOT_PARTITION=/dev/mapper/${DEVICE_NAME}p2"
118
+echo "ESP_PARTITION=/dev/mapper/${DEVICE_NAME}p1"
116 119
 
117 120
 
118 121
new file mode 100644
119 122
Binary files /dev/null and b/support/cloud-image-builder/rpi3/root/lib/firmware/brcm/brcmfmac43430-sdio.bin differ
120 123
new file mode 100644
... ...
@@ -0,0 +1,66 @@
0
+# NVRAM file for BCM943430WLPTH
1
+# 2.4 GHz, 20 MHz BW mode
2
+
3
+# The following parameter values are just placeholders, need to be updated.
4
+manfid=0x2d0
5
+prodid=0x0727
6
+vendid=0x14e4
7
+devid=0x43e2
8
+boardtype=0x0727
9
+boardrev=0x1101
10
+boardnum=22
11
+macaddr=00:90:4c:c5:12:38
12
+sromrev=11
13
+boardflags=0x00404201
14
+boardflags3=0x08000000
15
+xtalfreq=37400
16
+nocrc=1
17
+ag0=255
18
+aa2g=1
19
+ccode=ALL
20
+
21
+pa0itssit=0x20
22
+extpagain2g=0
23
+#PA parameters for 2.4GHz, measured at CHIP OUTPUT
24
+pa2ga0=-168,7161,-820
25
+AvVmid_c0=0x0,0xc8
26
+cckpwroffset0=5
27
+
28
+# PPR params
29
+maxp2ga0=84
30
+txpwrbckof=6
31
+cckbw202gpo=0
32
+legofdmbw202gpo=0x66111111
33
+mcsbw202gpo=0x77711111
34
+propbw202gpo=0xdd
35
+
36
+# OFDM IIR :
37
+ofdmdigfilttype=18
38
+ofdmdigfilttypebe=18
39
+# PAPD mode:
40
+papdmode=1
41
+papdvalidtest=1
42
+pacalidx2g=42
43
+papdepsoffset=-22
44
+papdendidx=58
45
+
46
+# LTECX flags
47
+ltecxmux=0
48
+ltecxpadnum=0x0102
49
+ltecxfnsel=0x44
50
+ltecxgcigpio=0x01
51
+
52
+il0macaddr=00:90:4c:c5:12:38
53
+wl0id=0x431b
54
+
55
+deadman_to=0xffffffff
56
+# muxenab: 0x1 for UART enable, 0x2 for GPIOs, 0x8 for JTAG
57
+muxenab=0x1
58
+# CLDO PWM voltage settings - 0x4 - 1.1 volt
59
+#cldo_pwm=0x4
60
+
61
+#VCO freq 326.4MHz
62
+spurconfig=0x3 
63
+
64
+edonthd20l=-75
65
+edoffthd20ul=-80
... ...
@@ -13,7 +13,8 @@
13 13
     "additionalfiles": [
14 14
                             {"photon-dev.repo": "/etc/yum.repos.d/photon-dev.repo"},
15 15
                             {"resizefs.sh": "/usr/local/bin/resizefs.sh"},
16
-                            {"resizefs.service": "/lib/systemd/system/resizefs.service"}
16
+                            {"resizefs.service": "/lib/systemd/system/resizefs.service"},
17
+			    {"root/lib/firmware": "/lib/firmware"}
17 18
                        ],
18 19
     "artifacttype": "xz",
19 20
     "keeprawdisk": "true"
... ...
@@ -395,6 +395,8 @@ class constants(object):
395 395
             # https://github.com/draios/sysdig/issues/833
396 396
             "sysdig.spec",
397 397
             "falco.spec",
398
+            # one more fail, not investigated yet
399
+            "log4cpp.spec",
398 400
 
399 401
             # VIVACE packages
400 402
             # need to update to mono-4.5