commit 00eb4081445a18468219a1c7f625609f9654ceed
Author: MikoĊaj Lenczewski <mblenczewski@gmail.com>
Date: Thu, 22 Jan 2026 22:26:24 +0000
Initial commit
Diffstat:
11 files changed, 237 insertions(+), 0 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -0,0 +1,8 @@
+linux/
+mv-bin/
+mv-ddr/
+tfa/
+u-boot/
+
+flash-image.bin
+boot.scr
diff --git a/README b/README
@@ -0,0 +1,13 @@
+mcbin
+-------------------------------------------------------------------------------
+A set of scripts to build upstream firmware for the MacchiatoBIN Double Shot
+board. Builds u-boot + tf-a. Expects a cross-compiler to have been set up
+beforehand (expected target is aarch64-linux-gnu).
+
+To build, run `./setup.sh` followed by `./build.sh`. This will pull the required
+repositories, and build a final `flash-image.bin` and its corresponding
+`boot.scr`. An example of how to partition and flash the SD card is given in
+`./format.sh`. I have then further used ArchLinuxARM-aarch64 as the test image,
+so `boot.scr` assumes dtbs are under `/boot/dtbs`.
+
+TODO: build a kernel and dtbs for reference
diff --git a/boot.txt b/boot.txt
@@ -0,0 +1,15 @@
+# After modifying, run ./mkscr
+
+test -n "${distro_bootpart}" || setenv distro_bootpart 1
+part uuid ${devtype} ${devnum}:${distro_bootpart} uuid
+setenv bootargs "console=ttyS0,115200 root=PARTUUID=${uuid} rw rootwait earlycon"
+
+if load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_r} /boot/Image; then
+ if load ${devtype} ${devnum}:${distro_bootpart} ${fdt_addr_r} /boot/dtbs/${fdtfile}; then
+ if load ${devtype} ${devnum}:${distro_bootpart} ${ramdisk_addr_r} /boot/initramfs-linux.img; then
+ booti ${kernel_addr_r} ${ramdisk_addr_r}:${filesize} ${fdt_addr_r};
+ else
+ booti ${kernel_addr_r} - ${fdt_addr_r};
+ fi;
+ fi;
+fi
diff --git a/build.sh b/build.sh
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+export CROSS_COMPILE=aarch64-linux-gnu-
+
+USE_EDK2=false
+
+set -ex
+
+if $USE_EDK2; then
+
+# build edk2
+export WORKSPACE="$PWD"
+export PACKAGES_PATH="$PWD/edk2:$PWD/edk2-platforms:$PWD/edk2-non-osi"
+
+. edk2/edksetup.sh
+
+make -C edk2/BaseTools
+
+export GCC5_AARCH64_PREFIX=$CROSS_COMPILE
+build -a AARCH64 -t GCC5 -b RELEASE -D X64EMU_ENABLE -D INCLUDE_TFTP_COMMAND -p Platform/SolidRun/Armada80x0McBin/Armada80x0McBin.dsc
+export BL33=$PWD/Build/Armada80x0McBin-AARCH64/RELEASE_GCC5/FV/ARMADA_EFI.fd
+
+else
+
+# build u-boot
+make -C u-boot mvebu_mcbin-88f8040_defconfig
+make -C u-boot
+
+export BL33=$PWD/u-boot/u-boot.bin
+
+fi
+
+# build arm-trusted-firmware
+export SCP_BL2=$PWD/mv-bin/mrvl_scp_bl2.img
+export MV_DDR_PATH=$PWD/mv-ddr
+
+make -C tfa USE_COHERENT_MEM=0 LOG_LEVEL=20 PLAT=a80x0_mcbin all fip mrvl_flash
+
+cp tfa/build/a80x0_mcbin/release/flash-image.bin flash-image.bin
+
+# build boot.scr
+u-boot/tools/mkimage -A arm -O linux -T script -C none -n "U-Boot boot script" -d boot.txt boot.scr
diff --git a/clean.sh b/clean.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+export CROSS_COMPILE=aarch64-linux-gnu-
+
+set -ex
+
+rm -rf Build/
+make -C u-boot clean
+make -C tfa CROSS_COMPILE=$CROSS_COMPILE realclean
diff --git a/format.sh b/format.sh
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+dd if=/dev/zero of=/dev/sdX bs=1M count=8
+
+sfdisk /dev/sdX <<EOF
+label: dos
+unit: sectors
+/dev/sdX1: start=8192,type=83,bootable # our linux partition
+EOF
+
+dd if=flash-image.bin of=/dev/sdX seek=4096 conv=fdatasync,notrunc
diff --git a/patches/edk2-platforms-mcbin.patch b/patches/edk2-platforms-mcbin.patch
@@ -0,0 +1,43 @@
+diff --git a/Silicon/Marvell/Armada7k8k/AcpiTables/Armada80x0McBin.inf b/Silicon/Marvell/Armada7k8k/AcpiTables/Armada80x0McBin.inf
+index c8cdea2b7d..430fe5d950 100644
+--- a/Silicon/Marvell/Armada7k8k/AcpiTables/Armada80x0McBin.inf
++++ b/Silicon/Marvell/Armada7k8k/AcpiTables/Armada80x0McBin.inf
+@@ -54,4 +54,4 @@
+ gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate
+
+ [BuildOptions]
+- *_*_*_ASLCC_FLAGS = -DARMADA8K
++ *_*_*_ASLCC_FLAGS = -DARMADA8K -target aarch64-linux-gnu
+diff --git a/Silicon/Marvell/Armada7k8k/Feature/Capsule/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf b/Silicon/Marvell/Armada7k8k/Feature/Capsule/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf
+index 7bf1f2f41a..7017929dfd 100644
+--- a/Silicon/Marvell/Armada7k8k/Feature/Capsule/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf
++++ b/Silicon/Marvell/Armada7k8k/Feature/Capsule/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf
+@@ -42,3 +42,6 @@
+
+ [Depex]
+ TRUE
++
++[BuildOptions]
++ *_*_*_ASLCC_FLAGS = -target aarch64-linux-gnu
+diff --git a/Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.inf b/Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.inf
+index bd8b557c1a..e2ea3261d2 100644
+--- a/Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.inf
++++ b/Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.inf
+@@ -57,3 +57,6 @@
+
+ [Depex]
+ TRUE
++
++[BuildOptions]
++ *_*_*_CC_FLAGS = -Wno-tautological-constant-out-of-range-compare
+diff --git a/Silicon/Marvell/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.inf b/Silicon/Marvell/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.inf
+index 682de9aeec..2d18fe300b 100644
+--- a/Silicon/Marvell/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.inf
++++ b/Silicon/Marvell/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.inf
+@@ -48,3 +48,6 @@
+
+ [Depex]
+ gEfiSmbiosProtocolGuid
++
++[BuildOptions]
++ *_*_*_CC_FLAGS = -Wno-bitfield-constant-conversion -Wno-missing-braces
diff --git a/patches/mv-ddr-clang-got.patch b/patches/mv-ddr-clang-got.patch
@@ -0,0 +1,30 @@
+diff --git a/Makefile b/Makefile
+index 045284c..4733ba4 100644
+--- a/Makefile
++++ b/Makefile
+@@ -313,8 +313,8 @@ else
+ CROSS = $(CROSS_COMPILE)
+
+ LD = $(CROSS)ld
+-CC = $(CROSS)gcc
+-AS = $(CROSS)gcc
++CC = $(CROSS)cc
++AS = $(CROSS)cc
+ AR = $(CROSS)ar
+ OBJCOPY = $(CROSS)objcopy
+ OBJDUMP = $(CROSS)objdump
+@@ -337,6 +337,14 @@ CFLAGS += -Wall -Werror -Os -ffreestanding -mlittle-endian -g -gdwarf-2 -nostdin
+ CFLAGS += -march=armv8-a -fpie
+ CFLAGS += $(call cc_option, --param=min-pagesize=0)
+
++# clang fixes to compile cleanly on clang-20
++CFLAGS += -target aarch64-arm-none-elf
++CFLAGS += -Wno-unused-command-line-argument -Wno-unused-but-set-variable \
++ -Wno-enum-conversion -Wno-self-assign -Wno-shift-negative-value
++
++# clang fixes to stop .got blowing up
++CFLAGS += -fno-pic -fno-pie -fvisibility=hidden
++
+ # PLATFORM is set in ble/ble.mk
+ ifneq ($(findstring a80x0,$(PLATFORM)),)
+ ifneq ($(findstring ocp,$(PLATFORM)),)
diff --git a/patches/tfa-clang.patch b/patches/tfa-clang.patch
@@ -0,0 +1,40 @@
+diff --git a/include/plat/marvell/armada/common/aarch64/marvell_macros.S b/include/plat/marvell/armada/common/aarch64/marvell_macros.S
+index bfe2d4127..e18290b1b 100644
+--- a/include/plat/marvell/armada/common/aarch64/marvell_macros.S
++++ b/include/plat/marvell/armada/common/aarch64/marvell_macros.S
+@@ -30,8 +30,7 @@ icc_regs:
+ #endif
+ /* Registers common to both GICv2 and GICv3 */
+ gicd_pend_reg:
+- .asciz "gicd_ispendr regs (Offsets 0x200 - 0x278)\n" \
+- " Offset:\t\t\tvalue\n"
++ .asciz "gicd_ispendr regs (Offsets 0x200 - 0x278)\nOffset:\t\t\tvalue\n"
+ newline:
+ .asciz "\n"
+ spacer:
+diff --git a/plat/marvell/armada/a8k/common/a8k_common.mk b/plat/marvell/armada/a8k/common/a8k_common.mk
+index 81b355191..64b2d43b4 100644
+--- a/plat/marvell/armada/a8k/common/a8k_common.mk
++++ b/plat/marvell/armada/a8k/common/a8k_common.mk
+@@ -10,6 +10,8 @@ PLAT_COMMON_BASE := plat/marvell/armada/a8k/common
+ MARVELL_DRV_BASE := drivers/marvell
+ MARVELL_COMMON_BASE := plat/marvell/armada/common
+
++CFLAGS += -Wno-asm-operand-widths
++
+ MARVELL_SVC_TEST := 0
+ $(eval $(call add_define,MARVELL_SVC_TEST))
+
+diff --git a/tools/fiptool/Makefile b/tools/fiptool/Makefile
+index 6deac9d0f..e10f54fb7 100644
+--- a/tools/fiptool/Makefile
++++ b/tools/fiptool/Makefile
+@@ -22,6 +22,8 @@ else
+ FIPTOOL_CFLAGS += -O2
+ endif
+
++FIPTOOL_CFLAGS += -Wno-overflow
++
+ FIPTOOL_INCLUDE_DIRS := ../../include/tools_share
+
+ FIPTOOL_DEFINES += STATIC=$(STATIC)
diff --git a/setup.sh b/setup.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
+( cd linux; git checkout linux-6.12.y )
+
+# TODO: implement EDKII build
+# git clone https://github.com/tianocore/edk2.git
+# (cd edk2; git submodule update --init)
+# git clone https://github.com/tianocore/edk2-platforms.git
+# (cd edk2-platforms; git submodule update --init; git apply ../patches/edk2-platform-mcbin.patch)
+# git clone https://github.com/tianocore/edk2-non-osi.git
+# (cd edk2-non-osi; git submodule update --init)
+
+git clone https://github.com/u-boot/u-boot.git
+( cd u-boot; git checkout v2026.01 )
+
+git clone https://github.com/ARM-software/arm-trusted-firmware.git tfa
+( cd tfa; git checkout lts-v2.12.9 )
+
+git clone https://github.com/MarvellEmbeddedProcessors/mv-ddr-marvell.git mv-ddr
+
+git clone https://github.com/MarvellEmbeddedProcessors/binaries-marvell.git mv-bin
+( cd mv-bin; git checkout binaries-marvell-armada-SDK10.0.1.0 )
diff --git a/terminal.sh b/terminal.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+exec picocom /dev/ttyUSB0 -b 115200 -f n -y n -d 8 -p 1