From 8e5ce6a87d8e6e95a5b47f6f6eb4c15ba24ba442 Mon Sep 17 00:00:00 2001 From: IanSB Date: Sun, 28 Nov 2021 04:07:08 +0000 Subject: [PATCH] Disable unaligned access (may not work across armv6-v8 on same binary) --- src/armc-start.S | 2 +- src/rgb_to_fb.S | 2 +- src/rgb_to_hdmi.c | 2 +- src/toolchain-arm-none-eabi-rpi.cmake | 1 + src/toolchain-arm-none-eabi-rpi4.cmake | 14 ++++++++++---- src/toolchain-arm-none-eabi-rpiA.cmake | 1 + src/toolchain-arm-none-eabi-rpiA4.cmake | 14 ++++++++++---- 7 files changed, 25 insertions(+), 11 deletions(-) diff --git a/src/armc-start.S b/src/armc-start.S index f558779c..491df226 100644 --- a/src/armc-start.S +++ b/src/armc-start.S @@ -441,7 +441,7 @@ _swi_handler_: _enable_unaligned_access: mrc p15, 0, r0, c1, c0, 0 // read SCTLR bic r0, r0, #2 // A (no unaligned access fault) - orr r0, r0, #1 << 22 // U (v6 unaligned access model) + orr r0, r0, #1 << 22 // U (v6 unaligned access model) not available on arm v8 mcr p15, 0, r0, c1, c0, 0 // write SCTLR mov pc, lr diff --git a/src/rgb_to_fb.S b/src/rgb_to_fb.S index 6c105652..2c1aac42 100644 --- a/src/rgb_to_fb.S +++ b/src/rgb_to_fb.S @@ -2281,7 +2281,7 @@ run_core: mov r0, 0 mov r1, 0 bl enable_MMU_and_IDCaches - bl _enable_unaligned_access + // bl _enable_unaligned_access //do not use for an armv6 to armv8 compatible binary bl _init_cycle_counter run_core_loop: wfe diff --git a/src/rgb_to_hdmi.c b/src/rgb_to_hdmi.c index 2c9b16af..f629426c 100644 --- a/src/rgb_to_hdmi.c +++ b/src/rgb_to_hdmi.c @@ -3584,7 +3584,7 @@ void kernel_main(unsigned int r0, unsigned int r1, unsigned int atags) #else enable_MMU_and_IDCaches(0,0); #endif - _enable_unaligned_access(); + //_enable_unaligned_access(); //do not use for an armv6 to armv8 compatible binary log_info("***********************RESET***********************"); log_info("RGB to HDMI booted"); diff --git a/src/toolchain-arm-none-eabi-rpi.cmake b/src/toolchain-arm-none-eabi-rpi.cmake index 75ca9f8b..8740473a 100644 --- a/src/toolchain-arm-none-eabi-rpi.cmake +++ b/src/toolchain-arm-none-eabi-rpi.cmake @@ -59,6 +59,7 @@ set( CMAKE_OBJCOPY ${TC_PATH}${CROSS_COMPILE}objcopy #use hardware floating point set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfloat-abi=hard" ) +set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mno-unaligned-access" ) #pi1 flags #set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=armv6zk" ) diff --git a/src/toolchain-arm-none-eabi-rpi4.cmake b/src/toolchain-arm-none-eabi-rpi4.cmake index a25dfed8..99b55097 100644 --- a/src/toolchain-arm-none-eabi-rpi4.cmake +++ b/src/toolchain-arm-none-eabi-rpi4.cmake @@ -59,6 +59,7 @@ set( CMAKE_OBJCOPY ${TC_PATH}${CROSS_COMPILE}objcopy #use hardware floating point set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfloat-abi=hard" ) +set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mno-unaligned-access" ) #pi1 flags #set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=armv6zk" ) @@ -75,10 +76,15 @@ set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfloat-abi=hard" ) #set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mtune=cortex-a53" ) #set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfpu=crypto-neon-fp-armv8" ) -#current flags for all -set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=armv6zk" ) -set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mtune=arm1176jzf-s" ) -set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfpu=vfp" ) +#pi4 flags +#set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=armv8-a" ) +#set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mtune=cortex-a72" ) +#set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfpu=crypto-neon-fp-armv8" ) + +#current flags +set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=armv8-a" ) +set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mtune=cortex-a72" ) +set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfpu=crypto-neon-fp-armv8" ) set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "" ) set( CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -march=armv7-a" ) diff --git a/src/toolchain-arm-none-eabi-rpiA.cmake b/src/toolchain-arm-none-eabi-rpiA.cmake index 1a21fec2..2c43f2c2 100644 --- a/src/toolchain-arm-none-eabi-rpiA.cmake +++ b/src/toolchain-arm-none-eabi-rpiA.cmake @@ -59,6 +59,7 @@ set( CMAKE_OBJCOPY ${TC_PATH}${CROSS_COMPILE}objcopy #use hardware floating point set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfloat-abi=hard" ) +set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mno-unaligned-access" ) #pi1 flags #set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=armv6zk" ) diff --git a/src/toolchain-arm-none-eabi-rpiA4.cmake b/src/toolchain-arm-none-eabi-rpiA4.cmake index 40454a9a..090c17b7 100644 --- a/src/toolchain-arm-none-eabi-rpiA4.cmake +++ b/src/toolchain-arm-none-eabi-rpiA4.cmake @@ -59,6 +59,7 @@ set( CMAKE_OBJCOPY ${TC_PATH}${CROSS_COMPILE}objcopy #use hardware floating point set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfloat-abi=hard" ) +set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mno-unaligned-access" ) #pi1 flags #set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=armv6zk" ) @@ -75,10 +76,15 @@ set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfloat-abi=hard" ) #set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mtune=cortex-a53" ) #set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfpu=crypto-neon-fp-armv8" ) -#current flags for all -set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=armv6zk" ) -set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mtune=arm1176jzf-s" ) -set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfpu=vfp" ) +#pi4 flags +#set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=armv8-a" ) +#set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mtune=cortex-a72" ) +#set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfpu=crypto-neon-fp-armv8" ) + +#current flags +set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=armv8-a" ) +set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mtune=cortex-a72" ) +set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfpu=crypto-neon-fp-armv8" ) set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "" ) set( CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -march=armv7-a" )