Skip to content

Commit

Permalink
enable M4 fpu earlier else it crashes
Browse files Browse the repository at this point in the history
  • Loading branch information
mean committed Jan 23, 2021
1 parent 2af5aa7 commit ab73585
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ include(applyPatch)
#
include(./platformConfig.cmake)
APPLY_PATCH_IF_NEEDED(patched gd32_patch.diff "add gd32f303 support")
APPLY_PATCH_IF_NEEDED(patchedm4 m4_activate_fpu.diff "activate m4 fpu (gd32f303)")


cmake_minimum_required(VERSION 2.8)
Expand Down
17 changes: 17 additions & 0 deletions patches/m4_activate_fpu.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--- a/STM32F1/variants/generic_gd32f303c/wirish/boards_setup.cpp 2021-01-23 10:40:52.302219033 +0100
+++ b/STM32F1/variants/generic_gd32f303c/wirish/boards_setup.cpp 2021-01-21 18:21:33.188439887 +0100
@@ -98,6 +98,14 @@
#elif F_CPU == 48000000
rcc_set_prescaler(RCC_PRESCALER_USB, RCC_USB_SYSCLK_DIV_1);
#endif
+
+ // Activate FPU Here, asap !
+ uint32_t *cpacr=(uint32_t *) 0xE000ED88;
+ uint32_t v=cpacr[0];
+ v|=0xF<<20;
+ cpacr[0]=v;
+
+
}

__weak void board_setup_gpio(void) {

0 comments on commit ab73585

Please sign in to comment.