From 1c16acaf902f3b2ec777c49f13787371800f87a8 Mon Sep 17 00:00:00 2001 From: Opvolger Date: Sun, 1 Dec 2024 21:28:16 +0100 Subject: [PATCH] start playbook --- .gitignore | 1 + .../localhost/milkv_jupiter_kernel.yaml | 77 ++++++++++ .../localhost/milkv_jupiter_opensbi.yaml | 13 ++ .../localhost/milkv_jupiter_u_boot.yaml | 21 +++ ansible/host_vars/localhost/opensuse.yaml | 4 + .../localhost/spacemit-toolchain.yaml | 4 + .../starfive_visionfive2_kernel.yaml | 49 ++++++ .../starfive_visionfive2_opensbi.yaml | 10 ++ .../starfive_visionfive2_u_boot.yaml | 18 +++ ansible/milkv-jupiter-opensuse.yaml | 25 +++ ansible/readme.md | 30 ++++ ansible/starfive-visionfive2-compile.yaml | 15 ++ ansible/starfive-visionfive2-create-boot.yaml | 20 +++ ansible/starfive-visionfive2-opensuse.yaml | 16 ++ ansible/starfive-visionfive2-update-boot.yaml | 16 ++ .../starfive-visionfive2-update-kernel.yaml | 14 ++ ansible/tasks/build-kernel.yaml | 142 ++++++++++++++++++ ansible/tasks/build-opensbi.yaml | 27 ++++ ansible/tasks/build-u-boot.yaml | 38 +++++ .../clear-and-create-boot-partitions.yaml | 10 ++ ansible/tasks/copy-kernel-to-drive.yaml | 79 ++++++++++ ansible/tasks/create-bootfs-partition.yaml | 47 ++++++ ansible/tasks/create-opensuse-partition.yaml | 101 +++++++++++++ .../tasks/download-spacemit-toolchain.yaml | 35 +++++ ...clear-and-create-boot-partitions-test.yaml | 48 ++++++ .../k1-clear-and-create-boot-partitions.yaml | 14 ++ .../tasks/k1-write-to-boot-partitions.yaml | 34 +++++ ansible/tasks/write-to-boot-partitions.yaml | 13 ++ ansible/templates/boot.cmd.j2 | 19 +++ 29 files changed, 940 insertions(+) create mode 100644 ansible/host_vars/localhost/milkv_jupiter_kernel.yaml create mode 100644 ansible/host_vars/localhost/milkv_jupiter_opensbi.yaml create mode 100644 ansible/host_vars/localhost/milkv_jupiter_u_boot.yaml create mode 100644 ansible/host_vars/localhost/opensuse.yaml create mode 100644 ansible/host_vars/localhost/spacemit-toolchain.yaml create mode 100644 ansible/host_vars/localhost/starfive_visionfive2_kernel.yaml create mode 100644 ansible/host_vars/localhost/starfive_visionfive2_opensbi.yaml create mode 100644 ansible/host_vars/localhost/starfive_visionfive2_u_boot.yaml create mode 100644 ansible/milkv-jupiter-opensuse.yaml create mode 100644 ansible/readme.md create mode 100644 ansible/starfive-visionfive2-compile.yaml create mode 100644 ansible/starfive-visionfive2-create-boot.yaml create mode 100644 ansible/starfive-visionfive2-opensuse.yaml create mode 100644 ansible/starfive-visionfive2-update-boot.yaml create mode 100644 ansible/starfive-visionfive2-update-kernel.yaml create mode 100644 ansible/tasks/build-kernel.yaml create mode 100644 ansible/tasks/build-opensbi.yaml create mode 100644 ansible/tasks/build-u-boot.yaml create mode 100644 ansible/tasks/clear-and-create-boot-partitions.yaml create mode 100644 ansible/tasks/copy-kernel-to-drive.yaml create mode 100644 ansible/tasks/create-bootfs-partition.yaml create mode 100644 ansible/tasks/create-opensuse-partition.yaml create mode 100644 ansible/tasks/download-spacemit-toolchain.yaml create mode 100644 ansible/tasks/k1-clear-and-create-boot-partitions-test.yaml create mode 100644 ansible/tasks/k1-clear-and-create-boot-partitions.yaml create mode 100644 ansible/tasks/k1-write-to-boot-partitions.yaml create mode 100644 ansible/tasks/write-to-boot-partitions.yaml create mode 100644 ansible/templates/boot.cmd.j2 diff --git a/.gitignore b/.gitignore index 5d4f9fb..ac0d89c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ starfiveVisionFive2/*.html *.html **/boot.scr +report.txt diff --git a/ansible/host_vars/localhost/milkv_jupiter_kernel.yaml b/ansible/host_vars/localhost/milkv_jupiter_kernel.yaml new file mode 100644 index 0000000..0415f46 --- /dev/null +++ b/ansible/host_vars/localhost/milkv_jupiter_kernel.yaml @@ -0,0 +1,77 @@ +milkv_jupiter_kernel: + git: + # use own copy, the real repo is VERY slow! + repo: "https://github.com/Opvolger/spacemit-k1-linux-6.6.git" + version: "bl-v2.0.y" + checkout_dir: "/home/opvolger/bianbu-kernel/source/spacemit-k1-linux-6.6" + extra_firmware_download: + - https://gitee.com/bianbu-linux/buildroot-ext/blob/bl-v2.0.y/board/spacemit/k1/target_overlay/lib/firmware/esos.elf + target: "/home/opvolger/bianbu-kernel" + dtb_file_location: /arch/riscv/boot/dts/spacemit/k1-x_milkv-jupiter.dtb + defconfig: k1_defconfig + # do not use modules + replace_m_for_y: true + extra_environment_vars: + PATH: "{{ spacemit_toolchain.toolchain_path }}:{{ ansible_env.PATH }}" + build_params: + CROSS_COMPILE: riscv64-unknown-linux-gnu- + ARCH: riscv + add_to_config: + # disable signing check + CONFIG_MODULE_SIG_KEY: "" + # disable onboard DRM, camara, sound + CHARGER_SGM415XX + CONFIG_INPUT_TOUCHSCREEN: n + CONFIG_DRM_SPACEMIT: n + CONFIG_SPACEMIT_HDMI: n + CONFIG_SPACEMIT_HDMIAUDIO: n + CONFIG_SPACEMIT_DUMMYCODEC: n + CONFIG_SND_SOC_ES7210: n + CONFIG_SPACEMIT_K1X_CAMERA_V2: n + CONFIG_SPACEMIT_K1X_CCIC_V2: n + CONFIG_SPACEMIT_K1X_VI_V2: n + CONFIG_SPACEMIT_K1X_VI_IOMMU: n + CONFIG_SPACEMIT_K1X_ISP_V2: n + CONFIG_SPACEMIT_K1X_CPP_V2: n + CONFIG_SPACEMIT_K1X_SENSOR_V2: n + CONFIG_CHARGER_SGM415XX: n + # disable wifi network (gives errors) + CONFIG_WLAN_VENDOR_REALTEK: n + CONFIG_AIC8800_WLAN_SUPPORT: n + # firmware in kernel + CONFIG_EXTRA_FIRMWARE: "esos.elf radeon/CYPRESS_pfp.bin radeon/CYPRESS_me.bin radeon/CYPRESS_rlc.bin radeon/CYPRESS_smc.bin radeon/CYPRESS_uvd.bin radeon/CEDAR_smc.bin radeon/CEDAR_me.bin radeon/CEDAR_pfp.bin radeon/CEDAR_rlc.bin" + CONFIG_EXTRA_FIRMWARE_DIR: "../linux-firmware" + # needed for fedora: (zram) + CONFIG_BLK_DEV_RAM: y + CONFIG_BLK_DEV_RAM_COUNT: 16 + CONFIG_BLK_DEV_RAM_SIZE: 4096 + + CONFIG_INPUT_EVDEV: y + + # AMDGPU + HDMI sound + CONFIG_DRM_AMDGPU: y + CONFIG_DRM_AMD_DC: y + CONFIG_DRM_AMD_DC_FP: y + CONFIG_SND_DYNAMIC_MINORS: y + CONFIG_SND_MAX_CARDS: 32 + CONFIG_SND_VMASTER: y + CONFIG_SND_HDA: y + CONFIG_SND_HDA_INTEL: y + CONFIG_SND_HDA_CODEC_HDMI: y + CONFIG_SND_HDA_POWER_SAVE_DEFAULT: 0 + CONFIG_SND_HDA_CORE: y + CONFIG_SND_HDA_COMPONENT: y + CONFIG_SND_INTEL_NHLT: y + CONFIG_SND_INTEL_DSP_CONFIG: y + CONFIG_SND_INTEL_SOUNDWIRE_ACPI: y + + # needed for ubuntu (snap): + CONFIG_SQUASHFS: y + CONFIG_SQUASHFS_FILE_CACHE: y + CONFIG_SQUASHFS_DECOMP_SINGLE: y + CONFIG_SQUASHFS_COMPILE_DECOMP_SINGLE: y + CONFIG_SQUASHFS_ZLIB: y + CONFIG_SQUASHFS_LZ4: y + CONFIG_SQUASHFS_LZO: y + CONFIG_SQUASHFS_XZ: y + CONFIG_SQUASHFS_ZSTD: y + CONFIG_SQUASHFS_FRAGMENT_CACHE_SIZE: 3 \ No newline at end of file diff --git a/ansible/host_vars/localhost/milkv_jupiter_opensbi.yaml b/ansible/host_vars/localhost/milkv_jupiter_opensbi.yaml new file mode 100644 index 0000000..e642918 --- /dev/null +++ b/ansible/host_vars/localhost/milkv_jupiter_opensbi.yaml @@ -0,0 +1,13 @@ +# https://gitlab.alpinelinux.org/alpine/aports/-/blob/master/testing/opensbi-spacemit/APKBUILD +milkv_jupiter_opensbi: + git: + repo: "https://gitee.com/bianbu-linux/opensbi.git" + version: "v2.0.2" + checkout_dir: "/tmp/bianbu-opensbi" + build_params: + PLATFORM: generic + ARCH: riscv + CROSS_COMPILE: riscv64-unknown-linux-gnu- + PLATFORM_DEFCONFIG: k1_defconfig + extra_environment_vars: + PATH: "{{ spacemit_toolchain.toolchain_path }}:{{ ansible_env.PATH }}" diff --git a/ansible/host_vars/localhost/milkv_jupiter_u_boot.yaml b/ansible/host_vars/localhost/milkv_jupiter_u_boot.yaml new file mode 100644 index 0000000..4239e8c --- /dev/null +++ b/ansible/host_vars/localhost/milkv_jupiter_u_boot.yaml @@ -0,0 +1,21 @@ +# https://gitlab.alpinelinux.org/alpine/aports/-/blob/master/testing/u-boot-spacemit/APKBUILD +milkv_jupiter_u_boot: + git: + repo: "https://gitee.com/bianbu-linux/uboot-2022.10.git" + version: "v2.0.2" + checkout_dir: "/tmp/bianbu-u-boot" + defconfig: k1_defconfig + add_to_config: + DUMMY: n + DUMMY2: n + # disable nvme in u-boot (some GPU don't like that) + # CONFIG_BOOTCOMMAND: "load {{ on_boot.boot_device }}:3 ${scriptaddr} boot.scr; source ${scriptaddr}" + # disable nvme in u-boot (some GPU don't like that) + # escape bash + yaml, so for ' you need '\'' and $ will be '\\$' + # CONFIG_PREBOOT: "usb start; setenv bootcmd '\\''load {{ on_boot.boot_device }}:3 '\\$'{scriptaddr} boot.scr; source '\\$'{scriptaddr}'\\''" + build_params: + # OPENSBI: ../bianbu-opensbi/fw_dynamic.itb + CROSS_COMPILE: riscv64-unknown-linux-gnu- + ARCH: riscv + extra_environment_vars: + PATH: "{{ spacemit_toolchain.toolchain_path }}:{{ ansible_env.PATH }}" diff --git a/ansible/host_vars/localhost/opensuse.yaml b/ansible/host_vars/localhost/opensuse.yaml new file mode 100644 index 0000000..8c99594 --- /dev/null +++ b/ansible/host_vars/localhost/opensuse.yaml @@ -0,0 +1,4 @@ +opensuse: + target: "/tmp/opensuse" + #download: https://download.opensuse.org/ports/riscv/tumbleweed/images/openSUSE-Tumbleweed-RISC-V-KDE.riscv64-rootfs.riscv64.tar.xz + download: https://download.opensuse.org/ports/riscv/tumbleweed/images/openSUSE-Tumbleweed-RISC-V-JeOS-devel.riscv64-rootfs.riscv64.tar.xz \ No newline at end of file diff --git a/ansible/host_vars/localhost/spacemit-toolchain.yaml b/ansible/host_vars/localhost/spacemit-toolchain.yaml new file mode 100644 index 0000000..93a16f1 --- /dev/null +++ b/ansible/host_vars/localhost/spacemit-toolchain.yaml @@ -0,0 +1,4 @@ +spacemit_toolchain: + target: "/tmp/spacemit" + download: https://archive.spacemit.com/toolchain/spacemit-toolchain-linux-glibc-x86_64-v1.0.1.tar.xz + toolchain_path: "/tmp/spacemit/unpack/spacemit-toolchain-linux-glibc-x86_64-v1.0.1/bin" \ No newline at end of file diff --git a/ansible/host_vars/localhost/starfive_visionfive2_kernel.yaml b/ansible/host_vars/localhost/starfive_visionfive2_kernel.yaml new file mode 100644 index 0000000..deb47f1 --- /dev/null +++ b/ansible/host_vars/localhost/starfive_visionfive2_kernel.yaml @@ -0,0 +1,49 @@ +starfive_visionfive2_kernel: + target: "/tmp/kernel" + download: https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-[version].tar.xz + version: "6.12.1" + dtb_file_location: /arch/riscv/boot/dts/starfive/jh7110-starfive-visionfive-2-v1.3b.dtb + # do not use modules + replace_m_for_y: true + build_params: + CROSS_COMPILE: riscv64-linux-gnu- + ARCH: riscv + add_to_config: + # firmware in kernel + CONFIG_EXTRA_FIRMWARE: "amdgpu/polaris10_ce.bin amdgpu/polaris10_ce_2.bin amdgpu/polaris10_k_smc.bin amdgpu/polaris10_k2_smc.bin amdgpu/polaris10_k_mc.bin amdgpu/polaris10_mc.bin amdgpu/polaris10_me.bin amdgpu/polaris10_me_2.bin amdgpu/polaris10_mec2.bin amdgpu/polaris10_mec2_2.bin amdgpu/polaris10_mec.bin amdgpu/polaris10_mec_2.bin amdgpu/polaris10_pfp.bin amdgpu/polaris10_pfp_2.bin amdgpu/polaris10_rlc.bin amdgpu/polaris10_sdma1.bin amdgpu/polaris10_sdma.bin amdgpu/polaris10_smc.bin amdgpu/polaris10_smc_sk.bin amdgpu/polaris10_uvd.bin amdgpu/polaris10_vce.bin amdgpu/dimgrey_cavefish_vcn.bin amdgpu/dimgrey_cavefish_ce.bin amdgpu/dimgrey_cavefish_pfp.bin amdgpu/dimgrey_cavefish_me.bin amdgpu/dimgrey_cavefish_mec.bin amdgpu/dimgrey_cavefish_mec2.bin amdgpu/dimgrey_cavefish_rlc.bin amdgpu/dimgrey_cavefish_sos.bin amdgpu/dimgrey_cavefish_ta.bin amdgpu/dimgrey_cavefish_sdma.bin amdgpu/dimgrey_cavefish_dmcub.bin amdgpu/dimgrey_cavefish_smc.bin radeon/CYPRESS_uvd.bin radeon/CEDAR_smc.bin radeon/CEDAR_me.bin radeon/CEDAR_pfp.bin radeon/CEDAR_rlc.bin amdgpu/hawaii_k_smc.bin amdgpu/hawaii_smc.bin amdgpu/hawaii_uvd.bin amdgpu/hawaii_vce.bin amdgpu/hawaii_sdma.bin amdgpu/hawaii_sdma1.bin amdgpu/hawaii_pfp.bin amdgpu/hawaii_me.bin amdgpu/hawaii_ce.bin amdgpu/hawaii_rlc.bin amdgpu/hawaii_mec.bin amdgpu/hawaii_mc.bin radeon/hawaii_pfp.bin radeon/hawaii_me.bin radeon/hawaii_ce.bin radeon/hawaii_mec.bin radeon/hawaii_mc.bin radeon/hawaii_rlc.bin radeon/hawaii_sdma.bin radeon/hawaii_smc.bin radeon/hawaii_k_smc.bin radeon/HAWAII_pfp.bin radeon/HAWAII_me.bin radeon/HAWAII_ce.bin radeon/HAWAII_mec.bin radeon/HAWAII_mc.bin radeon/HAWAII_mc2.bin radeon/HAWAII_rlc.bin radeon/HAWAII_sdma.bin radeon/HAWAII_smc.bin" + CONFIG_EXTRA_FIRMWARE_DIR: "../linux-firmware" + # needed for fedora: (zram) + CONFIG_BLK_DEV_RAM: y + CONFIG_BLK_DEV_RAM_COUNT: 16 + CONFIG_BLK_DEV_RAM_SIZE: 4096 + + CONFIG_INPUT_EVDEV: y + + # AMDGPU + HDMI sound + CONFIG_DRM_AMDGPU: y + CONFIG_DRM_AMD_DC: y + CONFIG_DRM_AMD_DC_FP: y + CONFIG_SND_DYNAMIC_MINORS: y + CONFIG_SND_MAX_CARDS: 32 + CONFIG_SND_VMASTER: y + CONFIG_SND_HDA: y + CONFIG_SND_HDA_INTEL: y + CONFIG_SND_HDA_CODEC_HDMI: y + CONFIG_SND_HDA_POWER_SAVE_DEFAULT: 0 + CONFIG_SND_HDA_CORE: y + CONFIG_SND_HDA_COMPONENT: y + CONFIG_SND_INTEL_NHLT: y + CONFIG_SND_INTEL_DSP_CONFIG: y + CONFIG_SND_INTEL_SOUNDWIRE_ACPI: y + + # needed for ubuntu (snap): + CONFIG_SQUASHFS: y + CONFIG_SQUASHFS_FILE_CACHE: y + CONFIG_SQUASHFS_DECOMP_SINGLE: y + CONFIG_SQUASHFS_COMPILE_DECOMP_SINGLE: y + CONFIG_SQUASHFS_ZLIB: y + CONFIG_SQUASHFS_LZ4: y + CONFIG_SQUASHFS_LZO: y + CONFIG_SQUASHFS_XZ: y + CONFIG_SQUASHFS_ZSTD: y + CONFIG_SQUASHFS_FRAGMENT_CACHE_SIZE: 3 \ No newline at end of file diff --git a/ansible/host_vars/localhost/starfive_visionfive2_opensbi.yaml b/ansible/host_vars/localhost/starfive_visionfive2_opensbi.yaml new file mode 100644 index 0000000..ab64de9 --- /dev/null +++ b/ansible/host_vars/localhost/starfive_visionfive2_opensbi.yaml @@ -0,0 +1,10 @@ +starfive_visionfive2_opensbi: + git: + repo: "https://github.com/riscv-software-src/opensbi.git" + version: "v1.5.1" + checkout_dir: "/tmp/opensbi" + build_params: + PLATFORM: generic + FW_OPTIONS: "0" + FW_TEXT_START: "0x40000000" + CROSS_COMPILE: riscv64-linux-gnu- \ No newline at end of file diff --git a/ansible/host_vars/localhost/starfive_visionfive2_u_boot.yaml b/ansible/host_vars/localhost/starfive_visionfive2_u_boot.yaml new file mode 100644 index 0000000..5c9051c --- /dev/null +++ b/ansible/host_vars/localhost/starfive_visionfive2_u_boot.yaml @@ -0,0 +1,18 @@ +starfive_visionfive2_u_boot: + git: + repo: "https://github.com/u-boot/u-boot.git" + version: "v2024.10" + checkout_dir: "/tmp/u-boot" + defconfig: starfive_visionfive2_defconfig + add_to_config: + # disable nvme in u-boot (some GPU don't like that) + CONFIG_BOOTCOMMAND: "load {{ on_boot.boot_device }}:3 ${scriptaddr} boot.scr; source ${scriptaddr}" + # disable nvme in u-boot (some GPU don't like that) + # escape bash + yaml, so for ' you need '\'' and $ will be '\\$' + CONFIG_PREBOOT: "usb start; setenv fdt_addr '\\$'{fdtcontroladdr}; fdt addr '\\$'{fdtcontroladdr}; setenv bootcmd '\\''load {{ on_boot.boot_device }}:3 '\\$'{scriptaddr} boot.scr; source '\\$'{scriptaddr}'\\''" + CONFIG_PCI_INIT_R: n + CONFIG_CMD_PCI: n + build_params: + OPENSBI: ../opensbi/build/platform/generic/firmware/fw_payload.bin + CONFIG_DEFAULT_FDT_FILE: starfive/jh7110-starfive-visionfive-2-v1.3b.dtb + CROSS_COMPILE: riscv64-linux-gnu- diff --git a/ansible/milkv-jupiter-opensuse.yaml b/ansible/milkv-jupiter-opensuse.yaml new file mode 100644 index 0000000..25bdf6a --- /dev/null +++ b/ansible/milkv-jupiter-opensuse.yaml @@ -0,0 +1,25 @@ +--- +- hosts: localhost + vars: + build_jobs: 16 + target: /dev/sdb + on_boot: + boot_device: "mmc 0" + rootfs_location: "/dev/mmcblk1p6" + bootfs_partition: 5 + ramdisk_addr_r: "0x21000000" + fdt_addr_r: "0x31000000" + opensbi: "{{ milkv_jupiter_opensbi }}" + u_boot: "{{ milkv_jupiter_u_boot }}" + kernel: "{{ milkv_jupiter_kernel }}" + tasks: + # - include_tasks: tasks/download-spacemit-toolchain.yaml + # - include_tasks: tasks/build-opensbi.yaml + # - include_tasks: tasks/build-u-boot.yaml + - include_tasks: tasks/build-kernel.yaml + + # - include_tasks: tasks/k1-clear-and-create-boot-partitions.yaml + # - include_tasks: tasks/k1-write-to-boot-partitions.yaml + # - include_tasks: tasks/create-bootfs-partition.yaml + # - include_tasks: tasks/create-opensuse-partition.yaml + # - include_tasks: tasks/copy-kernel-to-drive.yaml \ No newline at end of file diff --git a/ansible/readme.md b/ansible/readme.md new file mode 100644 index 0000000..0fc4da1 --- /dev/null +++ b/ansible/readme.md @@ -0,0 +1,30 @@ +# Create bootable partitions from RISCV + +## StarFive VisionFive 2 + +U-boot and opensbi build can be find [here](https://github.com/u-boot/u-boot/blob/master/doc/board/starfive/visionfive2.rst) + +### Reset u-boot environment variables + +Maybe reset the u-boot environment variables with: + +```bash +env default -a +saveenv +``` + +This has to be done in U-boot! + +### Create / Update SD-card + +```bash +ansible-playbook [board]-[action].yaml --ask-become-pass -v +``` + +Examples for Starfive Visionfive2: + +- starfive-visionfive2-compile.yaml: Compiles U-boot, OpenSBI and the kernel +- starfive-visionfive2-create-boot.yaml: starfive-visionfive2-compile.yaml + creates boot partitions + bootfs (with kernel) +- starfive-visionfive2-opensuse.yaml: starfive-visionfive2-create-boot.yaml + creates rootfs partition +- starfive-visionfive2-update-boot.yaml: updates U-boot, OpenSBI and the kernel on the boot partitions +- starfive-visionfive2-update-kernel.yaml: updates the kernel and copied to the bootfs diff --git a/ansible/starfive-visionfive2-compile.yaml b/ansible/starfive-visionfive2-compile.yaml new file mode 100644 index 0000000..4c02a2e --- /dev/null +++ b/ansible/starfive-visionfive2-compile.yaml @@ -0,0 +1,15 @@ +--- +- hosts: localhost + vars: + build_jobs: 16 + target: /dev/sdb + on_boot: + boot_device: "mmc 1" + rootfs_location: "/dev/mmcblk1p3" + opensbi: "{{ starfive_visionfive2_opensbi }}" + u_boot: "{{ starfive_visionfive2_u_boot }}" + kernel: "{{ starfive_visionfive2_kernel }}" + tasks: + - include_tasks: tasks/build-opensbi.yaml + - include_tasks: tasks/build-u-boot.yaml + - include_tasks: tasks/build-kernel.yaml diff --git a/ansible/starfive-visionfive2-create-boot.yaml b/ansible/starfive-visionfive2-create-boot.yaml new file mode 100644 index 0000000..e09a284 --- /dev/null +++ b/ansible/starfive-visionfive2-create-boot.yaml @@ -0,0 +1,20 @@ +--- +- hosts: localhost + vars: + build_jobs: 16 + target: /dev/sdb + on_boot: + boot_device: "mmc 1" + rootfs_location: "/dev/mmcblk1p3" + opensbi: "{{ starfive_visionfive2_opensbi }}" + u_boot: "{{ starfive_visionfive2_u_boot }}" + kernel: "{{ starfive_visionfive2_kernel }}" + tasks: + + - name: First compile code + ansible.builtin.import_playbook: starfive-visionfive2-compile.yaml + + - include_tasks: tasks/clear-and-create-boot-partitions.yaml + - include_tasks: tasks/write-to-boot-partitions.yaml + - include_tasks: tasks/create-bootfs-partition.yaml + - include_tasks: tasks/copy-kernel-to-drive.yaml diff --git a/ansible/starfive-visionfive2-opensuse.yaml b/ansible/starfive-visionfive2-opensuse.yaml new file mode 100644 index 0000000..b8e9fb7 --- /dev/null +++ b/ansible/starfive-visionfive2-opensuse.yaml @@ -0,0 +1,16 @@ +--- +- hosts: localhost + vars: + build_jobs: 16 + target: /dev/sdb + on_boot: + boot_device: "mmc 1" + rootfs_location: "/dev/mmcblk1p3" + opensbi: "{{ starfive_visionfive2_opensbi }}" + u_boot: "{{ starfive_visionfive2_u_boot }}" + kernel: "{{ starfive_visionfive2_kernel }}" + tasks: + + - name: First compile code + ansible.builtin.import_playbook: starfive-visionfive2-create-boot.yaml + - include_tasks: tasks/create-opensuse-partition.yaml diff --git a/ansible/starfive-visionfive2-update-boot.yaml b/ansible/starfive-visionfive2-update-boot.yaml new file mode 100644 index 0000000..531be90 --- /dev/null +++ b/ansible/starfive-visionfive2-update-boot.yaml @@ -0,0 +1,16 @@ +--- +- hosts: localhost + vars: + build_jobs: 16 + target: /dev/sdb + on_boot: + boot_device: "mmc 1" + rootfs_location: "/dev/mmcblk1p3" + opensbi: "{{ starfive_visionfive2_opensbi }}" + u_boot: "{{ starfive_visionfive2_u_boot }}" + kernel: "{{ starfive_visionfive2_kernel }}" + tasks: + - name: First compile code + ansible.builtin.import_playbook: starfive-visionfive2-compile.yaml + - include_tasks: tasks/write-to-boot-partitions.yaml + - include_tasks: tasks/copy-kernel-to-drive.yaml diff --git a/ansible/starfive-visionfive2-update-kernel.yaml b/ansible/starfive-visionfive2-update-kernel.yaml new file mode 100644 index 0000000..6a49734 --- /dev/null +++ b/ansible/starfive-visionfive2-update-kernel.yaml @@ -0,0 +1,14 @@ +--- +- hosts: localhost + vars: + build_jobs: 16 + target: /dev/sdb + on_boot: + boot_device: "mmc 1" + rootfs_location: "/dev/mmcblk1p3" + opensbi: "{{ starfive_visionfive2_opensbi }}" + u_boot: "{{ starfive_visionfive2_u_boot }}" + kernel: "{{ starfive_visionfive2_kernel }}" + tasks: + - include_tasks: tasks/build-kernel.yaml + - include_tasks: tasks/copy-kernel-to-drive.yaml diff --git a/ansible/tasks/build-kernel.yaml b/ansible/tasks/build-kernel.yaml new file mode 100644 index 0000000..d7c91fa --- /dev/null +++ b/ansible/tasks/build-kernel.yaml @@ -0,0 +1,142 @@ +- name: Git checkout linux-firmware + ansible.builtin.git: + repo: 'git://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git' + depth: 1 + dest: "{{ kernel.target }}/source/linux-firmware" + +- name: Download extra firmwares + block: + - name: Download firmware + ansible.builtin.get_url: + url: "{{ item }}" + dest: "{{ kernel.target }}/source/linux-firmware/{{ item | basename }}" + loop: "{{ kernel.extra_firmware_download }}" + when: kernel.extra_firmware_download is defined + +- name: When download zip + block: + - set_fact: + download_url: "{{ kernel.download | replace('[version]',kernel.version) }}" + + - name: Get Kernel source tar.gz + block: + - name: Creates directory + ansible.builtin.file: + path: "{{ kernel.target }}" + state: directory + + - name: Get stats of kernel tar.gz + stat: + path: "{{ kernel.target }}/{{ download_url | basename }}" + register: kernelfile + + - name: download kernel source + get_url: + url: "{{ download_url }}" + dest: "{{ kernel.target }}/{{ download_url | basename }}" + when: not kernelfile.stat.exists + + - name: Creates source directory + ansible.builtin.file: + path: "{{ kernel.target }}/source" + state: directory + + - name: Get set kernel directory + stat: + path: "{{ kernel.target }}/source/linux-{{ kernel.version }}" + register: kernel_dir_stat + + - name: Get set kernel directory + set_fact: + kernel_dir: "{{ kernel.target }}/source/linux-{{ kernel.version }}" + + - name: Unarchive the kernel + ansible.builtin.unarchive: + src: "{{ kernel.target }}/{{ download_url| basename }}" + dest: "{{ kernel.target }}/source" + remote_src: yes + when: not kernel_dir_stat.stat.exists + when: kernel.download is defined + +- name: When git location + block: + - name: Git checkout kernel + ansible.builtin.git: + repo: '{{ kernel.git.repo }}' + dest: '{{ kernel.git.checkout_dir }}' + force: true + version: '{{ kernel.git.version }}' + + - name: Get set kernel directory + set_fact: + kernel_dir: "{{ kernel.git.checkout_dir }}" + + when: kernel.git is defined + +- name: Get stats of defconfig_backup + stat: + path: "{{ kernel_dir }}/arch/riscv/configs/defconfig_backup" + register: defconfig_backup + +- name: Create backup of defconfig + ansible.builtin.copy: + src: "{{ kernel_dir }}/arch/riscv/configs/defconfig" + dest: "{{ kernel_dir }}/arch/riscv/configs/defconfig_backup" + remote_src: yes + when: not defconfig_backup.stat.exists + +- name: Copy back defconfig_backup to defconfig + ansible.builtin.copy: + src: "{{ kernel_dir }}/arch/riscv/configs/defconfig_backup" + dest: "{{ kernel_dir }}/arch/riscv/configs/defconfig" + remote_src: yes + when: kernel.defconfig is not defined + +- name: Copy {{ kernel.defconfig }} to defconfig + ansible.builtin.copy: + src: "{{ kernel_dir }}/arch/riscv/configs/{{ kernel.defconfig }}" + dest: "{{ kernel_dir }}/arch/riscv/configs/defconfig" + remote_src: yes + when: kernel.defconfig is defined + +- name: Replace text + replace: + path: "{{ kernel_dir }}/arch/riscv/configs/defconfig" + regexp: '=m' + replace: '=y' + when: kernel.replace_m_for_y + +- name: Add to configfile + ansible.builtin.shell: echo "{{ item.key }}={{ item.value }}" >> {{ kernel_dir }}/arch/riscv/configs/defconfig + when: not (item.value is string and item.value != 'n' and item.value != 'y') + loop: "{{ lookup('ansible.builtin.dict', kernel.add_to_config) }}" + +- name: Add to configfile string + ansible.builtin.shell: echo '{{ item.key }}="{{ item.value }}"' >> {{ kernel_dir }}/arch/riscv/configs/defconfig + when: item.value is string and item.value != 'n' and item.value != 'y' + loop: "{{ lookup('ansible.builtin.dict', kernel.add_to_config) }}" + +- name: Create default RISC-V config + community.general.make: + make: make + chdir: "{{ kernel_dir }}" + jobs: '{{ build_jobs }}' + params: + CROSS_COMPILE: riscv64-linux-gnu- + ARCH: riscv + defconfig: + +- name: Replace text + replace: + path: "{{ kernel_dir }}/.config" + regexp: '=m' + replace: '=y' + when: kernel.replace_m_for_y + +- name: Build kernel + community.general.make: + make: make + chdir: "{{ kernel_dir }}" + jobs: '{{ build_jobs }}' + params: '{{ kernel.build_params }}' + environment: "{{ kernel.extra_environment_vars }}" \ No newline at end of file diff --git a/ansible/tasks/build-opensbi.yaml b/ansible/tasks/build-opensbi.yaml new file mode 100644 index 0000000..cb5c549 --- /dev/null +++ b/ansible/tasks/build-opensbi.yaml @@ -0,0 +1,27 @@ +- name: Git checkout opensbi + ansible.builtin.git: + repo: '{{ opensbi.git.repo }}' + dest: '{{ opensbi.git.checkout_dir }}' + force: true + version: '{{ opensbi.git.version }}' + +- name: Build clean + community.general.make: + make: make + chdir: '{{ opensbi.git.checkout_dir }}' + target: clean + +- name: Build .config + community.general.make: + make: make + chdir: '{{ opensbi.git.checkout_dir }}' + target: '{{ opensbi.defconfig }}' + when: opensbi.defconfig is defined + +- name: Build opensbi + community.general.make: + make: make + chdir: '{{ opensbi.git.checkout_dir }}' + jobs: '{{ build_jobs }}' + params: '{{ opensbi.build_params }}' + environment: "{{ opensbi.extra_environment_vars }}" diff --git a/ansible/tasks/build-u-boot.yaml b/ansible/tasks/build-u-boot.yaml new file mode 100644 index 0000000..58609ed --- /dev/null +++ b/ansible/tasks/build-u-boot.yaml @@ -0,0 +1,38 @@ +- name: Git checkout u-boot + ansible.builtin.git: + repo: '{{ u_boot.git.repo }}' + dest: '{{ u_boot.git.checkout_dir }}' + force: true + version: '{{ u_boot.git.version }}' + +- name: Build distclean + community.general.make: + make: make + chdir: '{{ u_boot.git.checkout_dir }}' + target: distclean + +- name: Add to configfile {{ u_boot.git.checkout_dir }}/configs/{{ u_boot.defconfig }} + ansible.builtin.shell: echo "{{ item.key }}={{ item.value }}" >> {{ u_boot.git.checkout_dir }}/configs/{{ u_boot.defconfig }} + when: + - item.value |string | length < 5 + loop: "{{ lookup('ansible.builtin.dict', u_boot.add_to_config) }}" + +- name: Add to configfile string {{ u_boot.git.checkout_dir }}/configs/{{ u_boot.defconfig }} + ansible.builtin.shell: echo '{{ item.key }}="{{ item.value }}"' >> {{ u_boot.git.checkout_dir }}/configs/{{ u_boot.defconfig }} + when: + - item.value |string | length > 5 + loop: "{{ lookup('ansible.builtin.dict', u_boot.add_to_config) }}" + +- name: Build .config + community.general.make: + make: make + chdir: '{{ u_boot.git.checkout_dir }}' + target: '{{ u_boot.defconfig }}' + +- name: Build u-boot + community.general.make: + make: make + chdir: '{{ u_boot.git.checkout_dir }}' + jobs: '{{ build_jobs }}' + params: '{{ u_boot.build_params }}' + environment: "{{ u_boot.extra_environment_vars }}" \ No newline at end of file diff --git a/ansible/tasks/clear-and-create-boot-partitions.yaml b/ansible/tasks/clear-and-create-boot-partitions.yaml new file mode 100644 index 0000000..d722b9a --- /dev/null +++ b/ansible/tasks/clear-and-create-boot-partitions.yaml @@ -0,0 +1,10 @@ +- name: Clear partitions and create 2 new partitions spl and uboot + become: true + become_user: root + ansible.builtin.shell: "sudo sgdisk --clear \ + --set-alignment=2 \ + --new=1:4096:8191 --change-name=1:spl --typecode=1:2E54B353-1271-4842-806F-E436D6AF6985 \ + --new=2:8192:16383 --change-name=2:uboot --typecode=2:BC13C2FF-59E6-4262-A352-B275FD6F7172 \ + {{ target }}" + args: + executable: /bin/bash diff --git a/ansible/tasks/copy-kernel-to-drive.yaml b/ansible/tasks/copy-kernel-to-drive.yaml new file mode 100644 index 0000000..dd89649 --- /dev/null +++ b/ansible/tasks/copy-kernel-to-drive.yaml @@ -0,0 +1,79 @@ +- name: Creates mount directory + ansible.builtin.file: + path: "{{ opensuse.target }}/mnt" + state: directory + +- name: Read device information "{{ target }}" + become: true + become_user: root + community.general.parted: + device: "{{ target }}" + unit: MiB + register: disk_info + +- set_fact: + bootfs_partition: "{{ (disk_info.partitions | selectattr('name', 'search', 'bootfs') | list | first).num }}" + +- name: Mount "{{ target }}{{ bootfs_partition }}" + become: true + become_user: root + ansible.posix.mount: + path: "{{ opensuse.target }}/mnt" + src: "{{ target }}{{ bootfs_partition }}" + fstype: ext4 + state: ephemeral + +- name: Get set kernel directory + set_fact: + kernel_dir: "{{ kernel.target }}/source/linux-{{ kernel.version }}" + when: kernel.download is defined + +- name: Get set kernel directory + set_fact: + kernel_dir: "{{ kernel.git.checkout_dir }}" + when: kernel.git is defined + +- name: Copy kernel + become: true + become_user: root + ansible.builtin.copy: + src: "{{ kernel_dir }}/arch/riscv/boot/Image.gz" + dest: "{{ opensuse.target }}/mnt/Image.gz" + remote_src: yes + +- name: Copy kernel + become: true + become_user: root + ansible.builtin.copy: + src: "{{ kernel_dir }}/arch/riscv/boot/Image.itb" + dest: "{{ opensuse.target }}/mnt/Image.itb" + remote_src: yes + +- name: Copy device tree + become: true + become_user: root + ansible.builtin.copy: + src: "{{ kernel_dir }}{{ kernel.dtb_file_location }}" + dest: "{{ opensuse.target }}/mnt/{{ kernel.dtb_file_location | basename }}" + remote_src: yes + +- name: write hostname using jinja2 + become: true + become_user: root + ansible.builtin.template: + src: templates/boot.cmd.j2 + dest: "{{ opensuse.target }}/mnt/boot.cmd" + +- name: Create boot.scr from boot.cmd + become: true + become_user: root + ansible.builtin.shell: "sudo mkimage -C none -A riscv -T script -d {{ opensuse.target }}/mnt/boot.cmd {{ opensuse.target }}/mnt/boot.scr" + args: + executable: /bin/bash + +- name: Unmount "{{ opensuse.target }}/mnt" + become: true + become_user: root + ansible.posix.mount: + path: "{{ opensuse.target }}/mnt" + state: unmounted diff --git a/ansible/tasks/create-bootfs-partition.yaml b/ansible/tasks/create-bootfs-partition.yaml new file mode 100644 index 0000000..653357c --- /dev/null +++ b/ansible/tasks/create-bootfs-partition.yaml @@ -0,0 +1,47 @@ +- name: Read device information of {{ target }} + become: true + become_user: root + community.general.parted: + device: "{{ target }}" + unit: MiB + register: disk_info + +- name: Print disk_info + ansible.builtin.debug: + var: disk_info + +- name: Create new partition for bootfs + block: + - name: Create new partition for bootfs + become: true + become_user: root + community.general.parted: + device: "{{ target }}" + name: bootfs + label: gpt + number: "{{ disk_info.partitions | length + 1 }}" + part_start: "{{ disk_info.partitions[-1].end }}MiB" + part_end: "{{ disk_info.partitions[-1].end + 256 }}MiB" + state: present + - name: Create a ext4 filesystem on {{ target }}{{ disk_info.partitions | length + 1 }} + become: true + become_user: root + community.general.filesystem: + fstype: ext4 + force: true + dev: "{{ target }}{{ disk_info.partitions | length + 1 }}" + # uuid: B572F8B1-E6E4-437F-9BD5-7F949FE0B507 + when: disk_info.partitions | selectattr('name', 'search', 'bootfs') | list | length == 0 + +- name: Creates mount directory + ansible.builtin.file: + path: "{{ opensuse.target }}/mnt" + state: directory + +- name: Read device information "{{ target }}" + become: true + become_user: root + community.general.parted: + device: "{{ target }}" + unit: MiB + register: disk_info diff --git a/ansible/tasks/create-opensuse-partition.yaml b/ansible/tasks/create-opensuse-partition.yaml new file mode 100644 index 0000000..97e0c77 --- /dev/null +++ b/ansible/tasks/create-opensuse-partition.yaml @@ -0,0 +1,101 @@ +- name: Get OpenSUSE rootfs tar.xz + block: + + - name: Creates directory + ansible.builtin.file: + path: "{{ opensuse.target }}" + state: directory + + - name: Get stats of OpenSUSE rootfs file + stat: + path: "{{ opensuse.target }}/{{ opensuse.download | basename }}" + register: opensusefile + + - name: download rootfs + get_url: + url: "{{ opensuse.download }}" + dest: "{{ opensuse.target }}/{{ opensuse.download | basename }}" + when: not opensusefile.stat.exists + +- name: Read device information of {{ target }} + become: true + become_user: root + community.general.parted: + device: "{{ target }}" + unit: MiB + register: disk_info + +- name: Print disk_info + ansible.builtin.debug: + var: disk_info + +- name: Create new partition for rootfs + block: + - name: Create new partition for rootfs + become: true + become_user: root + community.general.parted: + device: "{{ target }}" + name: rootfs + label: gpt + number: "{{ disk_info.partitions | length + 1 }}" + part_start: "{{ disk_info.partitions[-1].end }}MiB" + part_end: "100%" + state: present + - name: Create a ext4 filesystem on {{ target }}{{ disk_info.partitions | length + 1 }} + become: true + become_user: root + community.general.filesystem: + fstype: ext4 + force: true + dev: "{{ target }}{{ disk_info.partitions | length + 1 }}" + uuid: EBD0A0A2-B9E5-4433-87C0-68B6B72699C7 + when: not disk_info.partitions[-1].name == 'rootfs' + +- name: Creates mount directory + ansible.builtin.file: + path: "{{ opensuse.target }}/mnt" + state: directory + +- name: Read device information "{{ target }}" + become: true + become_user: root + community.general.parted: + device: "{{ target }}" + unit: MiB + register: disk_info + +- name: Mount "{{ target }}{{ disk_info.partitions[-1].num }}" + become: true + become_user: root + ansible.posix.mount: + path: "{{ opensuse.target }}/mnt" + src: "{{ target }}{{ disk_info.partitions[-1].num }}" + fstype: ext4 + state: ephemeral + +- name: Get stats of OpenSUSE rootfs file + stat: + path: "{{ opensuse.target }}/mnt/tmp" + register: tmp_in_mount + +# - name: Unarchive rootfs to "{{ target }}{{ disk_info.partitions[-1].num }}" (very slow!) +# become: true +# become_user: root +# ansible.builtin.shell: tar -xJvf "{{ opensuse.target }}/{{ opensuse.download | basename }}" --directory "{{ opensuse.target }}/mnt" +# https://github.com/ansible/ansible/issues/38267 +- name: Unarchive rootfs to "{{ target }}{{ disk_info.partitions[-1].num }}" (very slow!) + become: true + become_user: root + ansible.builtin.unarchive: + src: "{{ opensuse.target }}/{{ opensuse.download | basename }}" + dest: "{{ opensuse.target }}/mnt" + remote_src: yes + when: not tmp_in_mount.stat.exists + +- name: Unmount "{{ opensuse.target }}/mnt" (very slow!) + become: true + become_user: root + ansible.posix.mount: + path: "{{ opensuse.target }}/mnt" + state: unmounted diff --git a/ansible/tasks/download-spacemit-toolchain.yaml b/ansible/tasks/download-spacemit-toolchain.yaml new file mode 100644 index 0000000..4d34b57 --- /dev/null +++ b/ansible/tasks/download-spacemit-toolchain.yaml @@ -0,0 +1,35 @@ +- name: Get toolchain tar.xz (if not downloaded) + block: + + - name: Creates directory + ansible.builtin.file: + path: "{{ spacemit_toolchain.target }}" + state: directory + + - name: Get stats of toolchain file + stat: + path: "{{ spacemit_toolchain.target }}/{{ spacemit_toolchain.download | basename }}" + register: spacemit_toolchainfile + + - name: download toolchain + get_url: + url: "{{ spacemit_toolchain.download }}" + dest: "{{ spacemit_toolchain.target }}/{{ spacemit_toolchain.download | basename }}" + when: not spacemit_toolchainfile.stat.exists + +- name: Creates unpack directory + ansible.builtin.file: + path: "{{ spacemit_toolchain.target }}/unpack" + state: directory + +- name: Get stats of spacemit_toolchain path + stat: + path: "{{ spacemit_toolchain.toolchain_path }}" + register: spacemit_toolchain_path + +- name: Unarchive toolchain + ansible.builtin.unarchive: + src: "{{ spacemit_toolchain.target }}/{{ spacemit_toolchain.download | basename }}" + dest: "{{ spacemit_toolchain.target }}/unpack" + remote_src: yes + when: not spacemit_toolchain_path.stat.exists diff --git a/ansible/tasks/k1-clear-and-create-boot-partitions-test.yaml b/ansible/tasks/k1-clear-and-create-boot-partitions-test.yaml new file mode 100644 index 0000000..3334693 --- /dev/null +++ b/ansible/tasks/k1-clear-and-create-boot-partitions-test.yaml @@ -0,0 +1,48 @@ +# https://gitee.com/bianbu-linux/buildroot-ext/blob/bl-v1.0.y/board/spacemit/k1/partition_flash.json +- name: Clear partitions and create 4 new partitions fsbl,env,opensbi and uboot + become: true + become_user: root + ansible.builtin.shell: "sudo sgdisk --clear \ + --set-alignment=2 \ + --new=1:256:767 --change-name=1:fsbl --typecode=1:76CE056B-7C39-40E6-972D-85800638DD5E \ + --new=2:768:895 --change-name=2:env --typecode=2:9B670021-BE65-49F5-B10F-6C02EB9A8327 \ + --new=3:2048:4095 --change-name=3:opensbi --typecode=2:EECBDE06-0362-414F-ABAB-4841EE8FA6D2 \ + --new=4:4096:16383 --change-name=4:uboot --typecode=2:172C5C47-EFE7-49CE-BD1C-58A40A039428 \ + {{ target }}" + args: + executable: /bin/bash + +- name: "Write bootinfo_sd.bin to {{ target }}" + become: true + become_user: root + ansible.builtin.shell: "sudo dd if=/home/opvolger/Downloads/bianbu-linux-k1-v2.0.2-20241111201323/factory/bootinfo_sd.bin of={{ target }}" + args: + executable: /bin/bash + +- name: "Write FSBL.bin to {{ target }}1" + become: true + become_user: root + ansible.builtin.shell: "sudo dd if=/home/opvolger/Downloads/bianbu-linux-k1-v2.0.2-20241111201323/factory/FSBL.bin of={{ target }}1" + args: + executable: /bin/bash + +- name: "Write u-boot-env-default.bin to {{ target }}2" + become: true + become_user: root + ansible.builtin.shell: "sudo dd if=/home/opvolger/Downloads/bianbu-linux-k1-v2.0.2-20241111201323/env.bin of={{ target }}2" + args: + executable: /bin/bash + +- name: "Write fw_dynamic.itb to {{ target }}3" + become: true + become_user: root + ansible.builtin.shell: "sudo dd if=/home/opvolger/Downloads/bianbu-linux-k1-v2.0.2-20241111201323/fw_dynamic.itb of={{ target }}3" + args: + executable: /bin/bash + +- name: "Write u-boot.itb to {{ target }}4" + become: true + become_user: root + ansible.builtin.shell: "sudo dd if=/home/opvolger/Downloads/bianbu-linux-k1-v2.0.2-20241111201323/u-boot.itb of={{ target }}4" + args: + executable: /bin/bash diff --git a/ansible/tasks/k1-clear-and-create-boot-partitions.yaml b/ansible/tasks/k1-clear-and-create-boot-partitions.yaml new file mode 100644 index 0000000..2906e7e --- /dev/null +++ b/ansible/tasks/k1-clear-and-create-boot-partitions.yaml @@ -0,0 +1,14 @@ +# https://gitee.com/bianbu-linux/buildroot-ext/blob/bl-v1.0.y/board/spacemit/k1/partition_flash.json +- name: Clear partitions and create 4 new partitions fsbl,env,opensbi and uboot + become: true + become_user: root + ansible.builtin.shell: "sudo sgdisk --clear \ + --set-alignment=2 \ + --new=1:256:767 --change-name=1:fsbl --typecode=1:76CE056B-7C39-40E6-972D-85800638DD5E \ + --new=2:768:895 --change-name=2:env --typecode=2:9B670021-BE65-49F5-B10F-6C02EB9A8327 \ + --new=3:2048:4095 --change-name=3:opensbi --typecode=2:EECBDE06-0362-414F-ABAB-4841EE8FA6D2 \ + --new=4:4096:16383 --change-name=4:uboot --typecode=2:172C5C47-EFE7-49CE-BD1C-58A40A039428 \ + {{ target }}" + args: + executable: /bin/bash + diff --git a/ansible/tasks/k1-write-to-boot-partitions.yaml b/ansible/tasks/k1-write-to-boot-partitions.yaml new file mode 100644 index 0000000..7c28550 --- /dev/null +++ b/ansible/tasks/k1-write-to-boot-partitions.yaml @@ -0,0 +1,34 @@ +- name: "Write bootinfo_sd.bin to {{ target }}" + become: true + become_user: root + ansible.builtin.shell: "sudo dd if={{ u_boot.git.checkout_dir }}/bootinfo_sd.bin of={{ target }}" + args: + executable: /bin/bash + +- name: "Write FSBL.bin to {{ target }}1" + become: true + become_user: root + ansible.builtin.shell: "sudo dd if={{ u_boot.git.checkout_dir }}/FSBL.bin of={{ target }}1" + args: + executable: /bin/bash + +- name: "Write u-boot-env-default.bin to {{ target }}2" + become: true + become_user: root + ansible.builtin.shell: "sudo dd if={{ u_boot.git.checkout_dir }}/u-boot-env-default.bin of={{ target }}2" + args: + executable: /bin/bash + +- name: "Write fw_dynamic.itb to {{ target }}3" + become: true + become_user: root + ansible.builtin.shell: "sudo dd if={{ opensbi.git.checkout_dir }}/build/platform/generic/firmware/fw_dynamic.itb of={{ target }}3" + args: + executable: /bin/bash + +- name: "Write u-boot.itb to {{ target }}4" + become: true + become_user: root + ansible.builtin.shell: "sudo dd if={{ u_boot.git.checkout_dir }}/u-boot.itb of={{ target }}4" + args: + executable: /bin/bash diff --git a/ansible/tasks/write-to-boot-partitions.yaml b/ansible/tasks/write-to-boot-partitions.yaml new file mode 100644 index 0000000..5c63dc0 --- /dev/null +++ b/ansible/tasks/write-to-boot-partitions.yaml @@ -0,0 +1,13 @@ +- name: "Write u-boot-spl.bin.normal.out to {{ target }}1" + become: true + become_user: root + ansible.builtin.shell: "sudo dd if={{ u_boot.git.checkout_dir }}/spl/u-boot-spl.bin.normal.out of={{ target }}1" + args: + executable: /bin/bash + +- name: "Write u-boot-spl.bin.normal.out to {{ target }}2" + become: true + become_user: root + ansible.builtin.shell: "sudo dd if={{ u_boot.git.checkout_dir }}/u-boot.itb of={{ target }}2" + args: + executable: /bin/bash diff --git a/ansible/templates/boot.cmd.j2 b/ansible/templates/boot.cmd.j2 new file mode 100644 index 0000000..77ebc78 --- /dev/null +++ b/ansible/templates/boot.cmd.j2 @@ -0,0 +1,19 @@ +{% if on_boot.ramdisk_addr_r is defined %} +ramdisk_addr_r={{ on_boot.ramdisk_addr_r }} +{% endif %} +{% if on_boot.fdt_addr_r is defined %} +fdt_addr_r={{ on_boot.fdt_addr_r }} +{% endif %} +{% if on_boot.bootargs is defined %} +setenv bootargs '{{ on_boot.bootargs }}' +{% else %} +setenv bootargs 'root={{ on_boot.rootfs_location }} rw console=tty0 console=ttyS0,115200 earlycon rootwait stmmaceth=chain_mode:1 selinux=0' +{% endif %} +load {{ on_boot.boot_device }}:{{ on_boot.bootfs_partition }} ${kernel_addr_r} /Image.gz +load {{ on_boot.boot_device }}:{{ on_boot.bootfs_partition }} ${fdt_addr_r} /{{ kernel.dtb_file_location | basename }} +{% if on_boot.load_ramdisk_location is defined %} +load {{ on_boot.boot_device }}:{{ on_boot.bootfs_partition }} ${ramdisk_addr_r} {{ on_boot.load_ramdisk_location }} +booti $kernel_addr_r $ramdisk_addr_r:$filesize $fdt_addr_r +{% else %} +booti ${kernel_addr_r} - ${fdt_addr_r} +{% endif %} \ No newline at end of file