Skip to content

Commit d942220

Browse files
committed
Add smart compiler detection for Pi Zero: auto-switch between hard/soft float ABI - Add fallback soft-float compiler installation - Implement runtime compiler testing with automatic ABI selection - Support both hard-float (gnueabihf) and soft-float (gnueabi) toolchains - Enhanced error handling and logging for compilation issues
1 parent 82e59c5 commit d942220

File tree

1 file changed

+37
-8
lines changed

1 file changed

+37
-8
lines changed

.github/workflows/pi-zero.yml

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ jobs:
2020
- buildtype: Debug
2121
system: armv6l
2222
crosscompiler: arm-linux-gnueabihf
23-
cmake_flags: "-march=armv6 -mfloat-abi=soft"
23+
cmake_flags: "-march=armv6 -mfpu=vfp -mfloat-abi=hard"
2424
description: "Raspberry Pi Zero (Debug)"
2525

2626
- buildtype: Release
2727
system: armv6l
2828
crosscompiler: arm-linux-gnueabihf
29-
cmake_flags: "-march=armv6 -mfloat-abi=soft"
29+
cmake_flags: "-march=armv6 -mfpu=vfp -mfloat-abi=hard"
3030
description: "Raspberry Pi Zero (Release)"
3131

3232
name: Build for ${{ matrix.description }}
@@ -63,6 +63,11 @@ jobs:
6363
git \
6464
g++-${{ matrix.crosscompiler }} \
6565
gcc-${{ matrix.crosscompiler }}
66+
67+
# Try to install soft-float compiler as fallback
68+
sudo apt-get install -y --no-install-recommends \
69+
g++-arm-linux-gnueabi \
70+
gcc-arm-linux-gnueabi || echo "Soft-float compiler not available"
6671
6772
- name: Configure CMake for Pi Zero
6873
run: |
@@ -72,14 +77,38 @@ jobs:
7277
echo "🔧 Configuring CMake for Raspberry Pi Zero ARMv6..."
7378
echo "Compiler flags: ${{ matrix.cmake_flags }}"
7479
80+
# Check if soft-float compiler is available and use it if hard-float fails
81+
COMPILER="${{ matrix.crosscompiler }}-gcc"
82+
CXX_COMPILER="${{ matrix.crosscompiler }}-g++"
83+
FLAGS="${{ matrix.cmake_flags }}"
84+
85+
# Test compiler with simple program
86+
echo 'int main(){return 0;}' > test_compile.c
87+
if ! $COMPILER $FLAGS test_compile.c -o test_compile 2>/dev/null; then
88+
echo "❌ Hard-float compiler failed, trying soft-float alternative..."
89+
if command -v arm-linux-gnueabi-gcc > /dev/null; then
90+
COMPILER="arm-linux-gnueabi-gcc"
91+
CXX_COMPILER="arm-linux-gnueabi-g++"
92+
FLAGS="-march=armv6 -mfloat-abi=soft"
93+
echo "✅ Using soft-float compiler: $COMPILER"
94+
echo "✅ Using soft-float flags: $FLAGS"
95+
else
96+
echo "❌ No compatible compiler found!"
97+
exit 1
98+
fi
99+
else
100+
echo "✅ Hard-float compiler working: $COMPILER"
101+
fi
102+
rm -f test_compile.c test_compile
103+
75104
cmake \
76105
-DCMAKE_BUILD_TYPE=${{ matrix.buildtype }} \
77106
-DCMAKE_SYSTEM_NAME=Linux \
78107
-DCMAKE_SYSTEM_PROCESSOR=${{ matrix.system }} \
79-
-DCMAKE_C_COMPILER=${{ matrix.crosscompiler }}-gcc \
80-
-DCMAKE_CXX_COMPILER=${{ matrix.crosscompiler }}-g++ \
81-
-DCMAKE_C_FLAGS="${{ matrix.cmake_flags }}" \
82-
-DCMAKE_CXX_FLAGS="${{ matrix.cmake_flags }}" \
108+
-DCMAKE_C_COMPILER=$COMPILER \
109+
-DCMAKE_CXX_COMPILER=$CXX_COMPILER \
110+
-DCMAKE_C_FLAGS="$FLAGS" \
111+
-DCMAKE_CXX_FLAGS="$FLAGS" \
83112
-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \
84113
-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \
85114
-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
@@ -181,7 +210,7 @@ jobs:
181210
echo " - Low resolution: -W 320 -H 240 -F 10"
182211
echo " - MJPEG format: -f MJPG"
183212
echo " - With web interface: -w 8080"
184-
echo " - Compatible with ARMv6 soft-float"
213+
echo " - Auto-detected ABI: hard-float or soft-float"
185214
186215
# Create a simple upload script for manual use
187216
cat << 'EOF' > upload_instructions.txt
@@ -199,7 +228,7 @@ jobs:
199228
echo "./v4l2rtspserver -W 640 -H 480 -F 15 -f MJPG /dev/video0 # Better quality" >> upload_instructions.txt
200229
echo "./v4l2rtspserver -w 8080 -W 320 -H 240 -F 10 /dev/video0 # With web UI" >> upload_instructions.txt
201230
echo "" >> upload_instructions.txt
202-
echo "🔧 Compatibility: Built for ARMv6 with soft-float (Pi Zero compatible)" >> upload_instructions.txt
231+
echo "🔧 Compatibility: Built for ARMv6 with auto-detected ABI (Pi Zero compatible)" >> upload_instructions.txt
203232
204233
cat upload_instructions.txt
205234

0 commit comments

Comments
 (0)