Skip to content

Fix build and boot with modern GCC#51

Open
tuckerwales wants to merge 7 commits intoiDroid-Project:masterfrom
tuckerwales:master
Open

Fix build and boot with modern GCC#51
tuckerwales wants to merge 7 commits intoiDroid-Project:masterfrom
tuckerwales:master

Conversation

@tuckerwales
Copy link
Copy Markdown

@tuckerwales tuckerwales commented Mar 26, 2026

Summary

openiBoot failed to build and boot when compiled with modern arm-none-eabi-gcc (GCC 15) on Apple Silicon. This PR:

  • Replaces SCons with GNU Make - SCons required Python 2 and had bit-rotted. The new GNUmakefile builds all targets with a single make command.
  • Fixes the root cause of boot failures - GCC 15's strict handling of attribute((packed)) generated byte-by-byte LDRB sequences for naturally word-aligned structs, breaking interrupt timing and the cooperative task scheduler. Removed unnecessary packed from
    LinkedList, TaskRegisterState, and TaskDescriptor (layout verified identical via _Static_assert).
  • Fixes ARM/Thumb interwork with GCC 15 - Added .type %function annotations to all ARM-mode assembly functions so the linker generates correct interwork veneers.
  • Fixes driver failures - Rewrote SPI to polled I/O (interrupt handler missed timing windows); removed DMA interrupt registration that raced with polled completion; removed duplicate audiohw_init() call; fixed C11 inline semantics and task init ordering.
  • Adds a default boot menu when /boot/menu.lst is missing, instead of silently failing.
  • Adds CI - GitHub Actions workflow builds all targets and creates releases on tags.
  • Adds documentation - Comprehensive README rewrite and new INSTALLING.md.

Changes by area

Build system

  • Replaced SCons (SConstruct + 18 SConscript files) with a single GNUmakefile
  • Supports all release, debug, and installer targets
  • Removed -fPIC (not meaningful for bare-metal), changed -O2 to -O1
  • Added -no-pie to mk8900image host tool link (fixes build with modern Ubuntu PIE defaults)
  • Added .github/workflows/build.yml - builds all targets on push to tags, uploads artifacts, creates GitHub Release

Core fixes

  • includes/openiboot.h: Removed attribute((packed)) from LinkedList, TaskRegisterState, TaskDescriptor - root cause of boot failure with GCC 15
  • arch-arm/asmhelpers.sx: Added .type %function to all .code 32 functions for correct ARM/Thumb interwork veneers
  • framebuffer.c: Changed inline to static inline (C11 semantics fix)
  • tasks.c: Moved CurrentRunning assignment before task_init() to prevent NULL dereference in EnterCriticalSection

Driver fixes

  • plat-s5l8900/spi.c: Rewrote from interrupt-driven to polled I/O
  • plat-s5l8900/dma.c: Removed DMA interrupt registration that raced with polled dma_finish()
  • plat-s5l8900/s5l8900.c: Removed duplicate audiohw_init() call from platform_init()

Menu

  • menu/menu.c: When /boot/menu.lst is not found, creates a default menu with an "iOS" auto-boot entry instead of dropping to a blank screen. Console is always available as the last menu entry.

Documentation

  • README.md: Comprehensive rewrite - supported devices, build instructions, menu configuration, project structure, architecture notes
  • INSTALLING.md (new): Installation guide for Bootlace, manual recovery mode, DFU mode, and restore

Test plan

  • Built all S5L8900 targets (iPhone2G, iPhone3G, iPodTouch1G) with arm-none-eabi-gcc 15.1 on Apple Silicon Mac
  • Loaded iPhone3G image via recovery mode - boots to menu, USB console connects
  • Verified default menu appears when /boot/menu.lst is absent
  • Verified "Console" entry opens interactive console with working commands
  • CI workflow builds all targets on Ubuntu runner

  - Port SCons scripts from Python 2 to Python 3
  - Switch cross-compiler prefix arm-elf- to arm-none-eabi-
  - Add -std=gnu11 (GCC 15 defaults to C23, breaking old C idioms)
  - Add -fcommon (GCC 10+ default fno-common breaks globals-in-headers)
  - Add per-platform -mcpu flags (assembler needs explicit ARM arch)
  - Remove --nostdlib and -Werror from build flags
  - Fix auto_store inline declaration in util.h
  - Use pre-built mk8900image binary on Darwin arm64 (Rosetta)
@nickpack
Copy link
Copy Markdown
Member

Wow, I can't say I was expecting to ever see this build on a modern system!

It'll take me some time to consume this properly, and I am already pondering how I test it - I don't have any of the appropriate devices anymore - maybe one of the other guys who originally worked on it will have a device stashed somewhere that can build and test properly.

@tuckerwales
Copy link
Copy Markdown
Author

I've only managed to test it on an iPhone 3G as I don't have the other devices either, but all works fine there!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants