[gnome-build-meta/tpollard/raspi64: 3/3] WIP Add initial Raspi 3B+ target



commit 6bb18c7b898ea22299e1cfafee84c2d23333a428
Author: Tom Pollard <tom pollard codethink co uk>
Date:   Thu Apr 2 13:54:52 2020 +0100

    WIP Add initial Raspi 3B+ target
    
    This is using the directory approach, adapted from vm/
    Initially ostree, initrd & flathub will not be integrated.

 .gitlab-ci.yml                                   | 27 ++++++--
 elements/raspi/bsp.bst                           | 10 +++
 elements/raspi/bsp/boot.bst                      | 83 ++++++++++++++++++++++++
 elements/raspi/bsp/firmware.bst                  | 29 +++++++++
 elements/raspi/bsp/kernel-modules.bst            | 15 +++++
 elements/raspi/bsp/linux.bst                     | 59 +++++++++++++++++
 elements/raspi/bsp/userland-firmware.bst         | 24 +++++++
 elements/raspi/configure.bst                     | 29 +++++++++
 elements/raspi/deps.bst                          | 22 +++++++
 elements/raspi/filesystem.bst                    | 14 ++++
 elements/raspi/image.bst                         | 75 +++++++++++++++++++++
 elements/raspi/initial-scripts.bst               |  7 ++
 elements/raspi/initramfs.bst.temp                | 66 +++++++++++++++++++
 elements/raspi/initramfstemp/deps.bst            | 14 ++++
 elements/raspi/initramfstemp/initial-scripts.bst |  7 ++
 15 files changed, 476 insertions(+), 5 deletions(-)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 1cd8f9b9..9bf7485a 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -100,11 +100,19 @@ default:
     - logs
     expire_in: '1 week'
 
-.vm-image-template:
+.image-template:
   stage: image
   script:
-    - ${BST_NO_PUSH} --max-jobs $(( $(nproc) / 4 )) -o arch "${ARCH}" build vm/image.bst
-    - ${BST_NO_PUSH} -o arch "${ARCH}" checkout --hardlinks vm/image.bst image
+  - |
+    # Build vm for x86
+    if [ "${ARCH}" == "x86_64" ]; then
+        ${BST_NO_PUSH} --max-jobs $(( $(nproc) / 4 )) -o arch "${ARCH}" build vm/image.bst
+        ${BST_NO_PUSH} -o arch "${ARCH}" checkout --hardlinks vm/image.bst image
+    # Only run the raspi build on arm64
+    elif [ "${ARCH}" == "aarch64" ]; then
+        ${BST_NO_PUSH} --max-jobs $(( $(nproc) / 4 )) -o arch "${ARCH}" build raspi/image.bst
+        ${BST_NO_PUSH} -o arch "${ARCH}" checkout --hardlinks raspi/image.bst raspi-image
+    fi
   rules:
   - if: $CI_COMMIT_REF_NAME == "master" || $CI_COMMIT_REF_NAME =~ /^gnome-\d-\d\d$/
     when: on_success
@@ -117,6 +125,7 @@ default:
     paths:
     - logs
     - image
+    - raspi-image
     expire_in: '2 days'
 
 .flatpak-template:
@@ -200,7 +209,7 @@ track:
   interruptible: true
   script:
   - 'sed -i "s/track-tags: False/track-tags: ${BST_TRACK_TAGS}/" project.conf'
-  - ${BST} track --deps all core.bst flatpak-runtimes.bst vm/image.bst
+  - ${BST} track --deps all core.bst flatpak-runtimes.bst vm/image.bst raspi/image.bst
   retry: 2
   # only run on branches targeting master
   rules:
@@ -229,7 +238,7 @@ build-gnome-core-arm:
 
 
 vm-image-x86_64:
-  extends: .vm-image-template
+  extends: .image-template
   # run as soon as the x86_64 build job is done, don't wait for other arches
   needs:
   - track
@@ -237,6 +246,14 @@ vm-image-x86_64:
     artifacts: false
   <<: *x86_64
 
+raspi-image-aarch64:
+  extends: .image-template
+  # run as soon as the aarch64 build job is done, don't wait for other arches
+  needs:
+  - track
+  - job: build-gnome-core-aarch64
+    artifacts: false
+  <<: *aarch64
 
 flatpak-prepare:
   stage: prepare_flatpak
diff --git a/elements/raspi/bsp.bst b/elements/raspi/bsp.bst
new file mode 100644
index 00000000..030de129
--- /dev/null
+++ b/elements/raspi/bsp.bst
@@ -0,0 +1,10 @@
+kind: stack
+description:  |
+  Linux kernel and platform specific components required to boot an Raspberry Pi 3B+
+
+depends:
+  - filename: raspi/bsp/linux.bst
+  - filename: raspi/bsp/firmware.bst
+  - filename: raspi/bsp/userland-firmware.bst
+  - filename: raspi/bsp/boot.bst
+  - filename: raspi/bsp/kernel-modules.bst
diff --git a/elements/raspi/bsp/boot.bst b/elements/raspi/bsp/boot.bst
new file mode 100644
index 00000000..c04eca30
--- /dev/null
+++ b/elements/raspi/bsp/boot.bst
@@ -0,0 +1,83 @@
+kind: manual
+
+
+depends:
+- filename: raspi/bsp/linux.bst
+  type: build
+- filename: raspi/bsp/firmware.bst
+  type: build
+
+- junction: freedesktop-sdk.bst
+  filename: components/automake.bst
+  type: build
+
+config:
+  install-commands:
+  - cp  -r /boot/* %{install-root}
+  - echo "dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 
elevator=deadline rootwait kernel=kernel8.img init=/bin/sh" > %{install-root}/cmdline.txt
+  - |
+    cat > %{install-root}/config.txt << EOF
+    # For more options and information see
+    # http://rpf.io/configtxt
+    # Some settings may impact device functionality. See link above for details
+
+    enable_uart=1
+    arm_64bit=1
+    start_x=1
+    gpu_mem=128
+
+    # uncomment if you get no picture on HDMI for a default "safe" mode
+    #hdmi_safe=1
+
+    # uncomment this if your display has a black border of unused pixels visible
+    # and your display can output without overscan
+    #disable_overscan=1
+
+    # uncomment the following to adjust overscan. Use positive numbers if console
+    # goes off screen, and negative if there is too much border
+    #overscan_left=16
+    #overscan_right=16
+    #overscan_top=16
+    #overscan_bottom=16
+
+    # uncomment to force a console size. By default it will be display's size minus
+    # overscan.
+    #framebuffer_width=1280
+    #framebuffer_height=720
+
+    # uncomment if hdmi display is not detected and composite is being output
+    #hdmi_force_hotplug=1
+
+    # uncomment to force a specific HDMI mode (this will force VGA)
+    #hdmi_group=1
+    #hdmi_mode=1
+
+    # uncomment to force a HDMI mode rather than DVI. This can make audio work in
+    # DMT (computer monitor) modes
+    #hdmi_drive=2
+
+    # uncomment to increase signal to HDMI, if you have interference, blanking, or
+    # no display
+    #config_hdmi_boost=4
+
+    # uncomment for composite PAL
+    #sdtv_mode=2
+
+    #uncomment to overclock the arm. 700 MHz is the default.
+    #arm_freq=800
+
+    # Uncomment some or all of these to enable the optional hardware interfaces
+    #dtparam=i2c_arm=on
+    #dtparam=i2s=on
+    #dtparam=spi=on
+
+    # Uncomment this to enable the lirc-rpi module
+    #dtoverlay=lirc-rpi
+
+    # Additional overlays and parameters are documented /boot/overlays/README
+
+    # Enable audio (loads snd_bcm2835)
+    dtparam=audio=on
+    EOF
+
+
diff --git a/elements/raspi/bsp/firmware.bst b/elements/raspi/bsp/firmware.bst
new file mode 100644
index 00000000..cf1b2d0d
--- /dev/null
+++ b/elements/raspi/bsp/firmware.bst
@@ -0,0 +1,29 @@
+# Pre-compiled binaries, userspace libs & GPU/bootloader firmware
+
+kind: manual
+
+depends:
+- junction: freedesktop-sdk.bst
+  filename: components/autoconf.bst
+  type: build
+- junction: freedesktop-sdk.bst
+  filename: components/automake.bst
+  type: build
+
+
+
+sources:
+- kind: git
+  url: https://github.com/raspberrypi/firmware
+  track: master
+
+
+  ref: 69a759d39aa802f65d0cc578361ff73e9dcbedc4
+config:
+  install-commands:
+  - mkdir -p  %{install-root}/boot/
+  - cp -a boot/*.bin %{install-root}/boot/
+  - cp -a boot/*.dat %{install-root}/boot/
+  - cp -a boot/*.elf %{install-root}/boot/
+  - cp -a boot/LICENCE.broadcom %{install-root}/boot/
+
diff --git a/elements/raspi/bsp/kernel-modules.bst b/elements/raspi/bsp/kernel-modules.bst
new file mode 100644
index 00000000..fd3c7522
--- /dev/null
+++ b/elements/raspi/bsp/kernel-modules.bst
@@ -0,0 +1,15 @@
+kind: filter
+depends:
+- filename: raspi/bsp/linux.bst
+  type: build
+
+config:
+  exclude:
+  - boot
+  include-orphans: True
+
+public:
+  bst:
+    overlap-whitelist:
+    # FIX
+    - '**'
diff --git a/elements/raspi/bsp/linux.bst b/elements/raspi/bsp/linux.bst
new file mode 100644
index 00000000..b0181e31
--- /dev/null
+++ b/elements/raspi/bsp/linux.bst
@@ -0,0 +1,59 @@
+kind: autotools
+
+depends:
+- filename: bootstrap-import.bst
+  junction: freedesktop-sdk.bst
+  type: build
+
+- junction: freedesktop-sdk.bst
+  filename: components/kmod.bst
+  type: build
+
+- junction: freedesktop-sdk.bst
+  filename: components/flex.bst
+  type: build
+- junction: freedesktop-sdk.bst
+  filename: components/bison.bst
+  type: build
+- junction: freedesktop-sdk.bst
+  filename: components/bc.bst
+  type: build
+- junction: freedesktop-sdk.bst
+  filename: components/gzip.bst
+  type: build
+
+
+
+sources:
+- kind: git
+  url: https://github.com/raspberrypi/linux
+  track: rpi-4.19.y
+  ref: c54bc9cff310e006ede2a4ffa745860fad87f79e
+variables:
+  make: make Image modules dtbs
+
+config:
+  configure-commands:
+  - |
+    KERNEL=kernel8
+    make ARCH=arm64 bcmrpi3_defconfig
+
+  install-commands:
+  - |
+    make INSTALL_MOD_PATH="%{install-root}/usr/" modules_install
+    mkdir -p %{install-root}/boot/
+    mkdir -p %{install-root}/boot/overlays
+
+    cp arch/arm64/boot/Image %{install-root}/boot/kernel8.img
+    cp arch/arm64/boot/dts/broadcom/*.dtb* %{install-root}/boot/
+    cp arch/arm64/boot/dts/overlays/*.dtb* %{install-root}/boot/overlays/
+    cp arch/arm64/boot/dts/overlays/README %{install-root}/boot/overlays/
+
+public:
+  bst:
+    split-rules:
+      boot:
+        - '/boot/*'
+      mods:
+        - '/lib/*'
+
diff --git a/elements/raspi/bsp/userland-firmware.bst b/elements/raspi/bsp/userland-firmware.bst
new file mode 100644
index 00000000..e3cd4215
--- /dev/null
+++ b/elements/raspi/bsp/userland-firmware.bst
@@ -0,0 +1,24 @@
+kind: cmake
+
+sources:
+- kind: git
+  url: https://github.com/raspberrypi/userland/
+  track: master
+  ref: 6e6a2c859a17a195fbb6a97c9da584dd2b9b0178
+depends:
+- junction: freedesktop-sdk.bst
+  filename: public-stacks/buildsystem-cmake.bst
+  type: build
+
+- filename: bootstrap-import.bst
+  junction: freedesktop-sdk.bst
+
+
+- filename: raspi/bsp/kernel-modules.bst
+
+
+variables:
+  cmake-local: |
+    -DCMAKE_BUILD_TYPE=Release \
+    -DARM64=ON \
+    -DBUILD_WAYLAND=TRUE
diff --git a/elements/raspi/configure.bst b/elements/raspi/configure.bst
new file mode 100644
index 00000000..5323f381
--- /dev/null
+++ b/elements/raspi/configure.bst
@@ -0,0 +1,29 @@
+kind: script
+
+build-depends:
+- raspi/filesystem.bst
+- raspi/initial-scripts.bst
+- freedesktop-sdk.bst:vm/prepare-image.bst
+
+variables:
+  uuidnamespace: 060b57a8-62bd-4d48-a471-0d28466d1fbb
+
+config:
+  layout:
+  - element: ''
+    destination: /tmp
+  - element: raspi/filesystem.bst
+    destination: /sysroot
+  - element: raspi/initial-scripts.bst
+    destination: /
+  - element: vm/prepare-image.bst
+    destination: /
+
+  commands:
+  - |
+    prepare-image.sh \
+       --sysroot /sysroot \
+       --seed "%{uuidnamespace}" \
+       --rootsource /dev/gpt-auto-root \
+       --rootpasswd "root" >/dev/null \
+       --noboot
diff --git a/elements/raspi/deps.bst b/elements/raspi/deps.bst
new file mode 100644
index 00000000..2ed0ab1a
--- /dev/null
+++ b/elements/raspi/deps.bst
@@ -0,0 +1,22 @@
+kind: stack
+
+runtime-depends:
+- freedesktop-sdk.bst:components/util-linux.bst
+- freedesktop-sdk.bst:components/tzdata.bst
+- freedesktop-sdk.bst:components/systemd.bst
+- freedesktop-sdk.bst:components/xorg-server.bst
+- freedesktop-sdk.bst:components/shadow.bst
+- freedesktop-sdk.bst:vm/mesa-default.bst
+
+# - raspi/bsp.bst
+
+- vm/plymouth-gnome-theme.bst
+- vm/kbd.bst
+
+- freedesktop-sdk.bst:vm/config/pulseaudio.bst
+- freedesktop-sdk.bst:vm/config/sudo.bst
+- freedesktop-sdk.bst:vm/config/journald.bst
+
+- sdk-platform.bst
+- core.bst
+- core/systemd-presets.bst
diff --git a/elements/raspi/filesystem.bst b/elements/raspi/filesystem.bst
new file mode 100644
index 00000000..b05fccb5
--- /dev/null
+++ b/elements/raspi/filesystem.bst
@@ -0,0 +1,14 @@
+kind: compose
+
+build-depends:
+- raspi/bsp.bst
+- raspi/deps.bst
+
+# Currently we just take everything and remove the
+# devel stuff (headers and static libraries), and debugging
+# symbols which take a huge amount of space, we could
+# refine this and make it much more selective, though.
+config:
+  exclude:
+  - devel
+  - debug
diff --git a/elements/raspi/image.bst b/elements/raspi/image.bst
new file mode 100644
index 00000000..a88c9638
--- /dev/null
+++ b/elements/raspi/image.bst
@@ -0,0 +1,75 @@
+kind: script
+
+build-depends:
+- raspi/filesystem.bst
+- freedesktop-sdk.bst:integration/mtab.bst
+- freedesktop-sdk.bst:components/genimage.bst
+- raspi/initial-scripts.bst
+- freedesktop-sdk.bst:vm/prepare-image.bst
+
+variables:
+  uuidnamespace: 060b57a8-62bd-4d48-a471-0d28466d1fbb
+
+config:
+  layout:
+  - element: ''
+    destination: '/sysroot'
+  - element: ''
+    destination: '/genimage'
+  - element: integration/mtab.bst
+    destination: '/'
+  - element: components/genimage.bst
+    destination: '/'
+  - element: ''
+    destination: /tmp
+  - element: raspi/filesystem.bst
+    destination: /sysroot
+  - element: raspi/initial-scripts.bst
+    destination: /
+  - element: vm/prepare-image.bst
+    destination: /
+
+  commands:
+  - |
+    prepare-image.sh \
+       --sysroot /sysroot \
+       --seed "%{uuidnamespace}" \
+       --rootsource /dev/gpt-auto-root \
+       --rootpasswd "root" \
+       --noboot
+
+  - |
+    cat >/genimage/genimage.cfg <<EOF
+     image boot.vfat {   
+       vfat {
+        }
+        mountpoint = "/boot"
+        size = 32M
+    }
+    image rootfs.ext4 {
+        ext4  {
+            label = "root"
+        }
+        size = 16G
+    }
+    image sdcard.img {
+        hdimage {
+            align = 1M
+            gpt = true
+        }
+        partition boot {
+            partition-type = 0xC
+            bootable = 'true'
+            image = "boot.vfat"
+
+        }
+        partition rootfs {
+            partition-type = 0x83
+            image = "rootfs.ext4"
+        }
+    }
+    EOF
+
+  - |
+    cd /genimage
+    genimage --rootpath /sysroot
diff --git a/elements/raspi/initial-scripts.bst b/elements/raspi/initial-scripts.bst
new file mode 100644
index 00000000..3938fca7
--- /dev/null
+++ b/elements/raspi/initial-scripts.bst
@@ -0,0 +1,7 @@
+kind: collect_initial_scripts
+
+build-depends:
+- raspi/deps.bst
+
+config:
+  path: /etc/fdsdk/initial_scripts
diff --git a/elements/raspi/initramfs.bst.temp b/elements/raspi/initramfs.bst.temp
new file mode 100644
index 00000000..73083a62
--- /dev/null
+++ b/elements/raspi/initramfs.bst.temp
@@ -0,0 +1,66 @@
+kind: script
+
+build-depends:
+- raspi/initramfs/deps.bst
+- raspi/initramfs/initial-scripts.bst
+- freedesktop-sdk.bst:vm/prepare-image.bst
+
+variables:
+  uuidnamespace: aea54278-2587-4075-ae67-8688ace4ce3d
+
+config:
+  layout:
+  - element: ''
+    destination: '/tmp'
+  - element: ''
+    destination: '/efi'
+  - element: ''
+    destination: '/var/tmp'
+  - element: raspi/initramfs/deps.bst
+    destination: '/'
+  - element: raspi/initramfs/initial-scripts.bst
+    destination: '/'
+  - element: vm/prepare-image.bst
+    destination: '/'
+
+  commands:
+  - |
+    prepare-image.sh \
+       --seed "%{uuidnamespace}" \
+       --rootsource /dev/gpt-auto-root \
+       --efisource LABEL=EFI \
+       --efipath /boot \
+       --rootpasswd "root" >/dev/null
+
+  - |
+    mkdir -p "%{install-root}/usr/lib/"
+    cp -r /usr/lib/modules "%{install-root}/usr/lib/"
+
+  - |
+    version="$(ls -1 /lib/modules | head -n1)"
+    mkdir -p "%{install-root}/usr/lib/modules/${version}"
+    dracut -v --fstab \
+           --no-machineid \
+           --kver "${version}" \
+           --add plymouth \
+           --install 'fsck.ext4' \
+           "%{install-root}/usr/lib/modules/${version}/initramfs"
+
+  - |
+    version="$(ls -1 /lib/modules | head -n1)"
+    cp /boot/kernel8.img "%{install-root}/usr/lib/modules/${version}/kernel8.img"
+
+  - dbus-uuidgen >/etc/machine-id
+  - SYSTEMD_RELAX_ESP_CHECKS=1 bootctl --path='/efi' --no-variables install
+  - rm /etc/machine-id
+
+  - |
+    cp -r /efi "%{install-root}/boot"
+
+  - |
+    cat <<EOF >%{install-root}/boot/loader/loader.conf
+    timeout 3
+    editor yes
+    console-mode keep
+    default *
+    EOF
diff --git a/elements/raspi/initramfstemp/deps.bst b/elements/raspi/initramfstemp/deps.bst
new file mode 100644
index 00000000..1d85533c
--- /dev/null
+++ b/elements/raspi/initramfstemp/deps.bst
@@ -0,0 +1,14 @@
+kind: stack
+
+runtime-depends:
+- freedesktop-sdk.bst:bootstrap-import.bst
+- freedesktop-sdk.bst:components/util-linux.bst
+- raspi/bsp.bst
+- freedesktop-sdk.bst:components/systemd.bst
+- freedesktop-sdk.bst:components/dbus.bst
+- freedesktop-sdk.bst:components/dracut.bst
+- freedesktop-sdk.bst:components/os-release.bst
+- freedesktop-sdk.bst:components/shadow.bst
+- freedesktop-sdk.bst:components/tzdata.bst
+- freedesktop-sdk.bst:components/pkg-config.bst
+- vm/plymouth-gnome-theme.bst
diff --git a/elements/raspi/initramfstemp/initial-scripts.bst 
b/elements/raspi/initramfstemp/initial-scripts.bst
new file mode 100644
index 00000000..13a47914
--- /dev/null
+++ b/elements/raspi/initramfstemp/initial-scripts.bst
@@ -0,0 +1,7 @@
+kind: collect_initial_scripts
+
+build-depends:
+- raspi/initramfs/deps.bst
+
+config:
+  path: /etc/fdsdk/initial_scripts


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]