rpi4_64: make the I2C/Sense HAT path work on 64-bit - #302
Merged
Conversation
The i2c_bsc and rpisense drivers date from the 32-bit rpi4 platform and had
never actually run on rpi4_64. Enabling them there boots to complete silence.
Three leftovers from the 32->64-bit move, each invisible until a 64-bit build
exercised this code:
1. Kconfig depended on RPI4, a symbol that no longer exists (arm32 only carries
VIRT32 now), so I2C_BSC and RPI_SENSE were not selectable on rpi4_64.
devices/serial/Kconfig was already updated to "RPI4 || RPI4_64" when rpi4_64
landed; i2c and rpisense were missed. Use the same form rather than RPI4_64
alone, so a returning 32-bit platform keeps working.
2. Both drivers stored the io_map() return value in a uint32_t. io_map()
returns addr_t, and on arm64 the virtual address sits at
CONFIG_IO_MAPPING_BASE (0xffff9000_00000000), so the top half was cut off
and the driver dereferenced the truncated address. Both are
REGISTER_DRIVER_CORE, i.e. they probe *before* the POSTCORE serial console:
the resulting abort killed the kernel with no output at all. On arm32
IO_MAPPING_BASE is 0xe0000000, which is why the bug slept there.
3. bsp/rpi4/config.txt never got the 64-bit boot settings. The deploy installs
the aarch64 U-Boot as kernel8.img, but the firmware defaults arm_64bit to 0
and looks for kernel7l.img, so nothing is loaded and there is no output at
all.
config.txt is shared by every rpi4 BSP, and a 32- and a 64-bit chain need
opposite values there. Rather than hardcode the 64-bit ones, keep the file as
the common part and let each BSP append a config_rpi4_arm{32,64}.txt fragment
after copying the directory. Only bsp_rpi4_64.inc consumes one today; the arm32
fragment is in place for the 32-bit platform.
Also disable the HAT EEPROM read. With a Sense HAT fitted, the firmware merges
the HAT's overlay into the DT it passes to U-Boot; that DT has no
/chosen/stdout-path, so U-Boot picks its console by node order, and the merge
made it drive the wrong UART and boot silently. Isolated to a single variable:
same board, same card, HAT removed -> U-Boot starts. SO3 drives the HAT through
rpisense and does not need the overlay.
Validated on real hardware (RPi 4 Model B, 1 GB, Sense HAT fitted): U-Boot
starts, boots the FIT image, SO3 6.2.3 reaches userspace, and the HAT's LEDs
and joystick respond.
daniel-rossier
force-pushed
the
fix/rpi4-64-i2c-rpisense
branch
from
July 17, 2026 10:07
9c85fa0 to
74f0d54
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
i2c_bscandrpisensedrivers come from the 32-bit rpi4 platform and had never actually run on rpi4_64. Enabling them there (CONFIG_I2C_BSC/CONFIG_RPI_SENSE+status = "ok"on thei2c1/rpisenseDT nodes) boots to complete silence — no kernel output at all.Three independent leftovers from the 32→64-bit move, each invisible until a 64-bit build exercised this code:
1. Kconfig hangs off a dead symbol
RPI4no longer exists —arch/arm32/Kconfigonly carriesVIRT32; the 64-bit board isRPI4_64. SoI2C_BSCandRPI_SENSEare simply not selectable on rpi4_64.devices/serial/Kconfig:12already readsdepends on RPI4 || RPI4_64— it was updated when rpi4_64 landed and i2c/rpisense were missed. This PR uses the same form rather thanRPI4_64alone, so a returning 32-bit platform keeps working.2.
io_map()return value truncated to 32 bitsOn arm64 the mapped virtual address sits at
CONFIG_IO_MAPPING_BASE(0xffff9000_00000000), so auint32_tdrops the top half and the driver dereferences the truncated address. On ARM32addr_twas 32-bit and the code was correct.Why the total silence: both are
REGISTER_DRIVER_CORE, so they probe before thePOSTCOREserial console — the abort kills the kernel before there is anything to print with.3.
config.txtnever got the 64-bit boot settingsThe deploy installs the aarch64 U-Boot as
kernel8.img, but this firmware (bcm2711, Aug 2021) defaultsarm_64bitto 0 and looks forkernel7l.img— nothing is loaded, no output. Now setsarm_64bit=1and names the kernel explicitly.Bonus: the Sense HAT blocked U-Boot entirely
With a HAT fitted the firmware merges the HAT's EEPROM overlay into the DT it hands to U-Boot (
Loaded HAT overlayin the firmware log). That DT has no/chosen/stdout-path, so U-Boot picks its console by DT node order — the merge perturbs it and U-Boot drives the wrong UART, booting in silence. Isolated to one variable: same board, same card, HAT removed → U-Boot starts.force_eeprom_read=0avoids it. SO3 talks to the HAT through its ownrpisensedriver and never needs the overlay.Test
Real hardware, RPi 4 Model B (0xc03111, 1 GB), Sense HAT fitted:
SO3 reaches userspace with
i2c_bscandrpisenseprobing at CORE, and the HAT's LED matrix and joystick respond.Notes
config.txtis shared by every rpi4 BSP, so the 32/64-bit settings live in the appendedconfig_rpi4_arm{32,64}.txtfragments rather than in the file itself. Onlybsp_rpi4_64.incconsumes one today.i2c1/rpisenseinrpi4_64.dtsis deliberately not part of this PR: they are CORE drivers, so turning them on by default would make every rpi4_64 probe a Sense HAT that may not be there.build/meta-bsp/recipes-bsp/bsp/rpi4/ships no.dtb, so the deploy relies on whatever DTB already sits on the card.