STM32F769 Linux Unhandled exception
I’m working with my stm32f769-DISCOvery board.
I’m trying to work through a few things that are unfinished/missing with the various buildroot configs on github and the stock one in buildroot.
On boot, it crashes like this:
[ 1.705669] Unhandled exception: IPSR = 00000006 LR = fffffffd
I’m apparently hitting an error with binutils newer than 2.28.1.
It’s looking like this report, except I have also managed to get fffffff1 instead of fffffffd
https://github.com/fdu/STM32F769I-disco_Buildroot/issues/1#issue-340504566
This emcraft patch seems to be intended to mitigate the crash:
https://github.com/EmcraftSystems/linux-upstream/commit/2882de1d86bd536c855feee582d44722434c2ac9
In theory, the fix should be upstream as as well, and the 5.15 kernel i’m playing with should be new enough. (I’ll need to validate that I guess)
https://github.com/torvalds/linux/commit/afc9f65e01cd114cb2cedf544d22239116ce0cc6
Looking at this:
https://github.com/fdu/STM32F769I-disco_Buildroot/issues/1
It seems it is caused by binutils 2.28.1. I’m sure I knew that, I can even find some post of mine that I have no recollection of ;-)
Anyway, this leads among other things to this LKML thread https://lkml.org/lkml/2018/6/19/917 and https://lkml.org/lkml/2018/6/19/927
What I’m not understanding is how this is not seen more commonly and what the common strategy is to deal with it. would it not affect most Cortex-M7/Thumb2 processors?
I see a few people have gone back to 2.28.1 binutils or patched 2.29 or patched parts of the kernel but I’m not sure why, or what, hasn’t been upstreamed.
debug info:
So, that’s what I put in buildroot. Flash the SD card, boot, and the kernel crashes with this instruction issue, see here:
Starting kernel ...
[ 0.000000] Booting Linux on physical CPU 0x0
[ 0.000000] Linux version 5.15.202 (demo@localhost.localdomain) (arm-buildroo
t-uclinux-uclibcgnueabihf-gcc.br_real (Buildroot 2024.05) 13.3.0, GNU ld (GNU Bi
nutils) 2.41) #1 PREEMPT Sun Jul 12 13:40:47 UTC 2026
[ 0.000000] CPU: ARMv7-M [411fc270] revision 0 (ARMv7M), cr=00000000
[ 0.000000] CPU: PIPT / VIPT nonaliasing data cache, PIPT instruction cache
[ 0.000000] OF: fdt: Machine model: STMicroelectronics STM32F769-DISCO board
[snipsnap]
[ 1.705669]
[ 1.705669] Unhandled exception: IPSR = 00000006 LR = fffffffd
[ 1.712892] CPU: 0 PID: 40 Comm: rcS Not tainted 5.15.202 #1
[ 1.718525] Hardware name: STM32 (Device Tree Support)
[ 1.723648] PC is at 0xc061940a
[ 1.726771] LR is at 0xc060ebd5
[ 1.729895] pc : [<c061940a>] lr : [<c060ebd5>] psr: 81000000
[ 1.736145] sp : c0668830 ip : 00000000 fp : 00000004
[ 1.741353] r10: c066ac28 r9 : ffffffff r8 : ffffffff
[ 1.746561] r7 : c066b030 r6 : c066b0d0 r5 : c066b030 r4 : c066ac28
[ 1.753070] r3 : c066ac48 r2 : 00000020 r1 : 00000020 r0 : c066b028
[ 1.759581] xPSR: 81000000
[ 1.762275] CPU: 0 PID: 40 Comm: rcS Not tainted 5.15.202 #1
[ 1.767914] Hardware name: STM32 (Device Tree Support)
[ 1.773055] [<c000afa5>] (unwind_backtrace) from [<c000a283>] (show_stack+0xb/0xc)
[ 1.780597] [<c000a283>] (show_stack) from [<c000a8b3>] (__invalid_entry+0x4b/0x4c)
I have the following settings in buildroot
BR2_NORMALIZED_ARCH="arm"
BR2_ENDIAN="LITTLE"
BR2_GCC_TARGET_ABI="aapcs-linux"
BR2_GCC_TARGET_CPU="cortex-m7"
BR2_GCC_TARGET_FPU="fpv5-sp-d16"
BR2_GCC_TARGET_FLOAT_ABI="hard"
BR2_GCC_TARGET_MODE="thumb"
BR2_READELF_ARCH_NAME="ARM"
BR2_ARM_CPU_MAYBE_HAS_FPU=y
BR2_ARM_CPU_HAS_FPU=y
BR2_ARM_CPU_MAYBE_HAS_FPV4=y
BR2_ARM_CPU_HAS_FPV4=y
BR2_ARM_CPU_MAYBE_HAS_FPV5=y
BR2_ARM_CPU_HAS_FPV5=y
BR2_ARM_CPU_HAS_THUMB2=y
BR2_ARM_CPU_ARMV7M=y
i last worked on this a month ago, so I don’t recall all details but I went through the configure once more and looked it and all of it seems good. Meaning, from a lot of reading they should be correct. I tried a few attempts as well.
btw. it seems to only show if i enable the FPU (but: One thing that I really care about in terms of performance would be to have the FPU enabled in the kernel). I don’t know the assembler backgrounds for it (and can’t learn them currently)
I’ve just tried again, with no VFP and soft float the kernel is booting. But this macro they patch back (__badr) seems to not be a FPU instruction? (I’m not sure)
I understand the Cortex-M7 has an optional FPU. For all I know, the stm32f769 does have this FPU. I’ve seen example code for it. Further, as far as I understood, other from some M4 models, it has not a single but double-float-able FPU, so it should work for most random stuff thrown at it. As far as I understand it _also_ has the FPV5 extensions which make some extra operations avaliable (I forgot the details as to what, if it’s vector or simd or whatever. It’s something, and for the later M7 versions like this one is, it should be FPV5)
rationale for messing around with this:
I’d rather take the time to sort this out now and be able to work with a fairly recent buildroot. I wanna be able to contribute QSPI root support and try out XiP, break out the modules so they can be on disk instead of having a too large for the ram kernel image.
et cetera. many tiny steps, it’s possible to do and so i think it should be done. At the very least I need to make enough space to load the TFT framebuffer drivers and all that. I know basically this is an MCU and I should maybe not be using Linux when there’s more direct ways to the same goal. But it HAS 16MB ram. That’s more than enough to run Unix with GUI. Especially since today we have XiP so the RAM usage will be quite limited. plus, my ressources are limited as well, and sticking with buildroot/linux will pay forward on multiple other projects. When I can afford it again I’ll look at the emcraft package for this board, but right now it ‘s not possible. Also, emcraft didn’t enable the FPU in-kernel, just for userspace.

