@@ -20,16 +20,16 @@ function add_host_dependencies__mvebu64_add_32_bit_c_compiler() {
2020 declare -g EXTRA_BUILD_DEPS="${EXTRA_BUILD_DEPS} gcc-arm-linux-gnueabi" # @TODO: convert to array later
2121}
2222
23- ARCH=arm64
24- BOOTBRANCH='tag:v2025.10'
25- BOOTPATCHDIR='v2025.10'
26- BOOTENV_FILE='mvebu64.txt'
27- BOOTSCRIPT_OUTPUT='boot.scr'
28- OVERLAY_DIR="/boot/dtb/marvell/overlay"
29- ATFSOURCE='https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git'
30- ATFDIR='arm-trusted-firmware-espressobin'
31- ATFBRANCH='tag:lts-v2.12.8'
32- ATF_USE_GCC='> 7.2'
23+ declare -g ARCH=arm64
24+ declare -g BOOTBRANCH='tag:v2025.10'
25+ declare -g BOOTPATCHDIR='v2025.10'
26+ declare -g BOOTENV_FILE='mvebu64.txt'
27+ declare -g BOOTSCRIPT_OUTPUT='boot.scr'
28+ declare -g OVERLAY_DIR="/boot/dtb/marvell/overlay"
29+ declare -g ATFSOURCE='https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git'
30+ declare -g ATFDIR='arm-trusted-firmware-espressobin'
31+ declare -g ATFBRANCH='tag:lts-v2.12.8'
32+ declare -g ATF_USE_GCC='> 7.2'
3333
3434if [[ "${SKIP_EXTERNAL_TOOLCHAINS}" == "yes" ]]; then
3535 ATF_COMPILER='aarch64-linux-gnu-'
4040if [[ $BOARD = macchiatobin-doubleshot ]]; then
4141 export SCP_BL2=$SRC/cache/sources/marvell-binaries/mrvl_scp_bl2.img # ATTENTION! This is actually a required 'export', since it's picked up by ATF's make.
4242
43- ATF_TARGET_MAP="USE_COHERENT_MEM=0 LOG_LEVEL=20 MV_DDR_PATH=$SRC/cache/sources/marvell-ddr SECURE=0 PLAT=a80x0_mcbin;;build/a80x0_mcbin/release/bl31.bin"
44- UBOOT_TARGET_MAP="DEVICE_TREE=armada-8040-mcbin ;;flash-image.bin"
43+ declare -g ATF_TARGET_MAP="USE_COHERENT_MEM=0 LOG_LEVEL=20 MV_DDR_PATH=$SRC/cache/sources/marvell-ddr SECURE=0 PLAT=a80x0_mcbin;;build/a80x0_mcbin/release/bl31.bin"
44+ declare -g UBOOT_TARGET_MAP="DEVICE_TREE=armada-8040-mcbin ;;flash-image.bin"
4545
46- BOOTSCRIPT="boot-macchiatobin-doubleshot.cmd:boot.cmd"
47- SERIALCON='ttyS0'
46+ declare -g BOOTSCRIPT="boot-macchiatobin-doubleshot.cmd:boot.cmd"
47+ declare -g SERIALCON='ttyS0'
4848else
49- ATF_TARGET_MAP="USE_COHERENT_MEM=0 LOG_LEVEL=20 SECURE=0 CLOCKSPRESET=CPU_800_DDR_800 DDR_TOPOLOGY=2 BOOTDEV=SPINOR PARTNUM=0 PLAT=a3700;;build/a3700/release/bl31.bin"
50- UBOOT_TARGET_MAP="DEVICE_TREE=armada-3720-espressobin ;;flash-image-*.bin"
49+ declare -g ATF_TARGET_MAP="USE_COHERENT_MEM=0 LOG_LEVEL=20 SECURE=0 CLOCKSPRESET=CPU_800_DDR_800 DDR_TOPOLOGY=2 BOOTDEV=SPINOR PARTNUM=0 PLAT=a3700;;build/a3700/release/bl31.bin"
50+ declare -g UBOOT_TARGET_MAP="DEVICE_TREE=armada-3720-espressobin ;;flash-image-*.bin"
5151
52- BOOTSCRIPT="boot-espressobin.cmd:boot.cmd"
53- SERIALCON='ttyMV0'
52+ declare -g BOOTSCRIPT="boot-espressobin.cmd:boot.cmd"
53+ declare -g SERIALCON='ttyMV0'
5454fi
5555
5656case $BRANCH in
@@ -70,11 +70,11 @@ case $BRANCH in
7070
7171esac
7272
73- CPUMIN=200000
74- CPUMAX=1300000
75- GOVERNOR=ondemand
73+ declare -g CPUMIN=200000
74+ declare -g CPUMAX=1300000
75+ declare -g GOVERNOR=ondemand
7676
77- write_uboot_platform() {
77+ function write_uboot_platform() {
7878 if [[ $BOARD = macchiatobin-doubleshot ]]; then
7979 dd if=$1/flash-image.bin of=$2 bs=512 seek=1 status=noxfer > /dev/null 2>&1
8080 else
@@ -83,83 +83,89 @@ write_uboot_platform() {
8383 fi
8484}
8585
86- family_tweaks() {
86+ function family_tweaks() {
8787 if [[ $BOARD = "espressobin" ]]; then
88- echo "#Marvell Espressobin Console" >> $ SDCARD/etc/securetty
89- echo "ttyMV0" >> $ SDCARD/etc/securetty
88+ echo "#Marvell Espressobin Console" >> "${ SDCARD} /etc/securetty"
89+ echo "ttyMV0" >> "${ SDCARD} /etc/securetty"
9090 fi
9191}
9292
93- family_tweaks_bsp() {
93+ function family_tweaks_bsp() {
94+ : "${destination:?destination is not set}"
9495 if [[ $BOARD = "espressobin" ]]; then
9596 cp "$SRC/packages/bsp/mvebu64/initramfs/99-uboot-fit" "$destination/etc/initramfs/post-update.d/"
9697 fi
9798}
9899
99- atf_custom_postprocess() {
100+ function atf_custom_postprocess() {
100101 # prepare compilers for postprocess
101102 ubootdir="$SRC/cache/sources/u-boot-worktree/$BOOTDIR/${BOOTBRANCH##*:}"
102- declare -g ATF1=$toolchain/$ATF_COMPILER
103- if [[ "${SKIP_EXTERNAL_TOOLCHAINS}" == "yes" ]]; then
104- declare -g TOOLCHAIN_NAME="arm-linux-gnueabi-"
105- else
106- declare -g TOOLCHAIN_NAME="arm-none-linux-gnueabihf-"
107- fi
108- declare -g ATF2=$(find_toolchain "$TOOLCHAIN_NAME" "> 10.0")/$TOOLCHAIN_NAME
109- declare -g BL33=$ubootdir"/u-boot.bin"
103+ declare -g ATF1="${ATF_COMPILER}"
104+ declare -g ATF2="arm-linux-gnueabi-"
105+ declare -g BL33="${ubootdir}/u-boot.bin"
110106}
111107
112- uboot_custom_postprocess() {
108+ function uboot_custom_postprocess() {
113109 # clean previous
114110 run_host_command_logged rm -f "$ubootdir"/flash-image*
115- local atfdir="$SRC/cache/sources/$ATFDIR/${ATFBRANCH##*:}"
116- local ubootdir="$SRC/cache/sources/u-boot-worktree/$BOOTDIR/${BOOTBRANCH##*:}"
117- local moxbootdir="$SRC/cache/sources/mox-boot"
118- cd $atfdir
111+
112+ declare atfdir="$SRC/cache/sources/$ATFDIR/${ATFBRANCH##*:}"
113+ declare ubootdir="$SRC/cache/sources/u-boot-worktree/$BOOTDIR/${BOOTBRANCH##*:}"
114+ declare moxbootdir="$SRC/cache/sources/mox-boot"
115+
116+ cd "${atfdir}" || exit_with_error "Cannot enter ATF directory ${atfdir}"
119117
120118 if [[ $BOARD = macchiatobin-doubleshot ]]; then
121119 run_host_command_logged make distclean
122120
123121 FILENAME="flash-image.bin"
124- display_alert "Building $FILENAME " "" "info"
122+ display_alert "Building mvebu64 ${BOARD} " "$FILENAME " "info"
125123 # http://wiki.macchiatobin.net/tiki-index.php?page=Build+from+source+-+Bootloader#Building_ATF
126124 run_host_command_logged make distclean
127125 run_host_command_logged "CFLAGS=-fdiagnostics-color=always" pipetty make USE_COHERENT_MEM=0 LOG_LEVEL=20 MV_DDR_PATH=$SRC/cache/sources/marvell-ddr PLAT=a80x0_mcbin CROSS_COMPILE=$ATF1 BL33=$BL33 mrvl_flash $CTHREADS
128126 run_host_command_logged cp -pv build/a80x0_mcbin/release/flash-image.bin $ubootdir/$FILENAME
129127 else
130- cd $moxbootdir
128+
129+ cd "${moxbootdir}" || exit_with_error "Cannot enter mox-boot directory ${moxbootdir}"
130+
131+ display_alert "Patching mox-boot for mvebu64 ${BOARD}" "crazy toolchain thing" "info"
131132 [[ -f Makefile ]] && sed -i "s/aarch64-unknown-linux-gnu-/aarch64-linux-gnu-/" Makefile
132133 [[ -f wtmi/a53_helper/Makefile ]] && sed -i "s/aarch64-unknown-linux-gnu-/aarch64-linux-gnu-/" wtmi/a53_helper/Makefile
133- make clean # @TODO: rpardini: why?
134- run_host_command_logged "CFLAGS=-fdiagnostics-color=always" pipetty make CROSS_CM3=$ATF2 wtmi_app.bin
135- cd $atfdir
134+ run_host_command_logged pipetty regular_git diff -u || true
135+
136+ display_alert "Building" "mox-boot for mvebu64 ${BOARD}" "info"
137+ run_host_command_logged make clean
138+ run_host_command_logged "CFLAGS=-fdiagnostics-color=always" pipetty make "CROSS_CM3=$ATF2" wtmi_app.bin
136139
137- clocks=(600_600 800_800 1000_800 1200_750)
138- topology=(512m_1cs_0 1g_2cs_2 1g_1cs_4 2g_2cs_7 1g_1cs_5 2g_2cs_6)
140+ cd "${atfdir}" || exit_with_error "Cannot enter ATF directory ${atfdir}"
141+ display_alert "Building atf for mvebu64 ${BOARD}" "" "info"
142+ declare -a clocks=("600_600" "800_800" "1000_800" "1200_750")
143+ declare -a topology=("512m_1cs_0" "1g_2cs_2" "1g_1cs_4" "2g_2cs_7" "1g_1cs_5" "2g_2cs_6")
139144 for i in "${clocks[@]}"; do
140145 for j in "${topology[@]}"; do
141- if [[ $j = *cs_5 || $j = *cs_6 ]]; then local ddrname="DDR4"; else ddrname="DDR3"; fi
146+ declare ddrname="undetermined"
147+ if [[ $j = *cs_5 || $j = *cs_6 ]]; then ddrname="DDR4"; else ddrname="DDR3"; fi
142148 FILENAME="flash-image-$ddrname-$j-$i.bin"
143149 DDR_TOPOLOGY="${j##*_}"
144150 CLOCKSPRESET="CPU_${i%_*}_DDR_${i##*_}"
145- display_alert "Building $FILENAME " "mvebu64 " "info"
151+ display_alert "Building mvebu64 not-macchiatobin-doubleshot: ${BOARD} " "$FILENAME " "info"
146152 run_host_command_logged make distclean
147- run_host_command_logged "CFLAGS=-fdiagnostics-color=always" pipetty make CROSS_COMPILE=$ATF1 \
148- CROSS_CM3=$ATF2 \
153+ run_host_command_logged "CFLAGS=-fdiagnostics-color=always" pipetty make " CROSS_COMPILE=$ATF1" \
154+ " CROSS_CM3=$ATF2" \
149155 USE_COHERENT_MEM=0 \
150156 PLAT=a3700 \
151- CLOCKSPRESET=$CLOCKSPRESET DDR_TOPOLOGY=$DDR_TOPOLOGY \
152- MV_DDR_PATH=$SRC/cache/sources/marvell-ddr \
153- WTP=$SRC/cache/sources/marvell-tools \
154- CRYPTOPP_PATH=$SRC/cache/sources/cryptopp \
155- BL33=$BL33 \
156- WTMI_IMG=$moxbootdir/wtmi_app.bin \
157+ " CLOCKSPRESET=$CLOCKSPRESET" " DDR_TOPOLOGY=$DDR_TOPOLOGY" \
158+ " MV_DDR_PATH=$SRC/cache/sources/marvell-ddr" \
159+ " WTP=$SRC/cache/sources/marvell-tools" \
160+ " CRYPTOPP_PATH=$SRC/cache/sources/cryptopp" \
161+ " BL33=$BL33" \
162+ " WTMI_IMG=$moxbootdir/wtmi_app.bin" \
157163 BOOTDEV=SPINOR PARTNUM=0 \
158164 LOG_LEVEL=20 all fip mrvl_flash $CTHREADS
159- run_host_command_logged cp -pv build/a3700/release/flash-image.bin $ ubootdir/$ FILENAME
165+ run_host_command_logged cp -pv build/a3700/release/flash-image.bin "${ ubootdir}/${ FILENAME}"
160166 done
161167 done
162168 fi
163169
164- cd $ ubootdir
170+ cd "${ ubootdir}" || exit_with_error "Cannot enter ATF directory ${ubootdir}"
165171}
0 commit comments