Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STM32F0 benchmarks #1462

Merged
merged 1 commit into from
Mar 29, 2019
Merged

Conversation

Delsian
Copy link
Contributor

@Delsian Delsian commented Mar 29, 2019

Pretty strange results for more than one stepper, but I've run tests few times and results the same.

Signed-off-by: Eugene Krashtan <[email protected]>
@KevinOConnor KevinOConnor merged commit b35e07c into Klipper3d:master Mar 29, 2019
@KevinOConnor
Copy link
Collaborator

Thanks.

FYI, the reason for the poor performance (relative to the similar SAMD21 chip) is due to the lack of -fwhole-program. gcc just doesn't do a good job of inlining without that flag.

-Kevin

@Delsian Delsian deleted the stm32f0-benchmark branch March 29, 2019 14:34
@Delsian
Copy link
Contributor Author

Delsian commented Mar 29, 2019

@KevinOConnor Unfortunately in my GCC version I can use either -fwhole-program or -fno-use-linker-plugin, but not both :(

@KevinOConnor
Copy link
Collaborator

Can you describe the problem you are seeing? It compiles fine for me with the following changes:

diff --git a/src/stm32f0/Makefile b/src/stm32f0/Makefile
index 16136b52..093be66f 100644
--- a/src/stm32f0/Makefile
+++ b/src/stm32f0/Makefile
@@ -9,9 +9,6 @@ dirs-y += src/stm32f0 src/generic
 dirs-y += lib/cmsis-stm32f0/source
 dirs-y += lib/hal-stm32f0/source
 
-CFLAGS = -I$(OUT) -Isrc -I$(OUT)board-generic/ -std=gnu11 -O2 -MD \
-    -Wall -Wold-style-definition $(call cc-option,$(CC),-Wtype-limits,) \
-    -ffunction-sections -fdata-sections
 CFLAGS += -flto -fno-use-linker-plugin
 CFLAGS += -mthumb -mcpu=cortex-m0 -g3
 CFLAGS += -Ilib/cmsis-core -Iout/board
@@ -60,7 +57,7 @@ $(OUT)klipper.bin: $(OUT)klipper.elf
 $(OUT)klipper.hex: $(OUT)klipper.elf
        @echo "  Creating hex file $@"
        $(Q)$(OBJCOPY) -O ihex $< $@
-       
+
 flash: $(OUT)klipper.hex
        @echo "  Flashing hex file $<"
        $(Q)$(STLINK) --format ihex --reset write $<
diff --git a/src/stm32f0/can.c b/src/stm32f0/can.c
index 6ce9aad4..cc0c0bf1 100644
--- a/src/stm32f0/can.c
+++ b/src/stm32f0/can.c
@@ -149,7 +149,7 @@ void HAL_CAN_ErrorCallback(CAN_HandleTypeDef *h)
   * @brief This function handles HDMI-CEC and CAN global interrupts /
   *  HDMI-CEC wake-up interrupt through EXTI line 27.
   */
-void CEC_CAN_IRQHandler(void)
+void __visible CEC_CAN_IRQHandler(void)
 {
     HAL_CAN_IRQHandler(&hcan);
 }
diff --git a/src/stm32f0/main.c b/src/stm32f0/main.c
index 89d8a6e5..da1f129c 100644
--- a/src/stm32f0/main.c
+++ b/src/stm32f0/main.c
@@ -149,7 +149,7 @@ void HAL_MspInit(void)
  * on Cortex-M0 chips
  ****************************************************************/
 
-void hard_fault_handler_c(unsigned long *hardfault_args){
+void __visible hard_fault_handler_c(unsigned long *hardfault_args){
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-but-set-variable"
     volatile unsigned long stacked_r0 ;
diff --git a/src/stm32f0/serial.c b/src/stm32f0/serial.c
index 103a0d70..7c3ba892 100644
--- a/src/stm32f0/serial.c
+++ b/src/stm32f0/serial.c
@@ -15,7 +15,7 @@
 UART_HandleTypeDef huart2;
 static uint8_t rxbuf, txbuf;
 
-void USART2_IRQHandler(void)
+void __visible USART2_IRQHandler(void)
 {
   HAL_UART_IRQHandler(&huart2);
 }
diff --git a/src/stm32f0/timer.c b/src/stm32f0/timer.c
index 0b285d4e..f51e69ba 100644
--- a/src/stm32f0/timer.c
+++ b/src/stm32f0/timer.c
@@ -77,7 +77,7 @@ SysTick_Handler(void)
     irq_enable();
 }
 
-void TIM2_IRQHandler(void)
+void __visible TIM2_IRQHandler(void)
 {
     if(TIM2->SR & TIM_SR_UIF) {
         TIM2->SR &= ~TIM_SR_UIF; // clear UIF flag

We use -fwhole-program on a number of different gcc versions and on a number of different ARM targets, so I think it would be worthwhile to track down what the root cause of the problem is.

-Kevin

@Delsian
Copy link
Contributor Author

Delsian commented Mar 30, 2019

@KevinOConnor Yes, you are right, I forgot about __visible
This variant should work better.

@KevinOConnor
Copy link
Collaborator

BTW, is the code in lib/cmsis-stm32f0/ the pristine code from st? I noticed that only startup_stm32f042x6.s has a reference to hard_fault_handler_c - that's certainly odd.

-Kevin

@Delsian
Copy link
Contributor Author

Delsian commented Apr 1, 2019

@KevinOConnor yes, I put this change for debugging purposes. Probably we can drop this change as everything working, I hope we don't need huge code changes in future.

@KevinOConnor
Copy link
Collaborator

I don't have the original st code, so I can't remove the changes. I'd like the code in the lib/ directory to have accurate documentation on where the code originates from. So, please submit a pull request returning the code in the lib/ directory to the pristine code from st, or update the lib/README with a list of all the changes in the code (for example, take a look at how the changes to the lib/sam4e/ directory are documented).

Thanks,
-Kevin

cruwaller pushed a commit to cruwaller/klipper that referenced this pull request Apr 3, 2019
FHeilmann pushed a commit to FHeilmann/klipper that referenced this pull request Jan 28, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Oct 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants