Skip to content

[New series] STM32MP1xx (just Cube package) #605

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

Merged
merged 8 commits into from
Oct 24, 2019

Conversation

kbumsik
Copy link
Contributor

@kbumsik kbumsik commented Aug 20, 2019

Summary

This PR adds STM32CubeMP1 package. In detail this adds the following:

  • STM32CubeMP1 CMSIS
  • STM32CubeMP1 HAL
  • OpenAMP middleware from STM32CubeMP1. This is used for serial-like communications between the host MPU (Cortex-A7) and the Arduino MCU (Cortex-M4).
  • Some simple and tedious fixes for Arduino Core

I'm currently working on STM32MP157 Discovery boards port. While the work is pretty much done and I will make a new PR for it soon (hopefully in this week), for now I would like to make a separate PR that just adds a STM32CubeMP1 package so that it will reduce excessive noises in the next PR.

I pulled STM32CubeMP1 v1.1.0 from its Github release directly.


This change is Reviewable

@kbumsik kbumsik changed the title [New line] STM32MP1xx (just STM32CubeMP1 package) [New line] STM32MP1xx (just Cube package) Aug 20, 2019
@kbumsik kbumsik changed the title [New line] STM32MP1xx (just Cube package) [New seris] STM32MP1xx (just Cube package) Aug 20, 2019
@fpistm fpistm added the new variant Add support of new bard label Aug 20, 2019
@kbumsik kbumsik changed the title [New seris] STM32MP1xx (just Cube package) [New series] STM32MP1xx (just Cube package) Aug 20, 2019
@fpistm fpistm self-requested a review August 20, 2019 06:28
@fpistm
Copy link
Member

fpistm commented Aug 20, 2019

Hi @kbumsik
Thanks for this PR, I will review it soon.

@fpistm
Copy link
Member

fpistm commented Aug 20, 2019

For Astyle issue, you should add system/Middlewares/OpenAMP/
in https://github.com/stm32duino/Arduino_Core_STM32/blob/master/CI/astyle/.astyleignore

@kbumsik
Copy link
Contributor Author

kbumsik commented Aug 20, 2019

Thanks for mentioning about Astyle.

BTW I need to discuss one thing for the upcoming PR. As STM32MP1 is indeed a special board among other STM32 MCUs, it is necessary to include a new README document on how to use STM32MP1 Discovery board with Arduino IDE. For example, instructions about a special upload tool (STM32Prog is not supported) and some warnings regarding collision of Arduino binary and Linux device tree.

Where is the best place to put the READMEs? Maybe in Arduino_Core_STM32/variants/__STM32MP1_Boards__?

@fpistm
Copy link
Member

fpistm commented Aug 20, 2019

Where is the best place to put the READMEs? Maybe in Arduino_Core_STM32/variants/__STM32MP1_Boards__?

Good question, I guess, as a first step, this could be add in the variant.

@fpistm
Copy link
Member

fpistm commented Sep 27, 2019

Hi @kbumsik

I'm currently working on STM32MP157 Discovery boards port. While the work is pretty much done and I will make a new PR for it soon (hopefully in this week)

Do you succeed?

@kbumsik
Copy link
Contributor Author

kbumsik commented Sep 27, 2019

@fpistm Pretty much, except I2C is not working properly for unknown reasons and that is the only reason I haven't made a PR for weeks :(
I think it's the time I should just open a PR as a WIP for now to show the progress. I will open it after the weekend, since this will be pretty big PR. Are you planning to review the current PR after that?

@fpistm
Copy link
Member

fpistm commented Sep 27, 2019

OK thanks for the quick feedback.
I will try to get a board then I will be able to review and test.

@kbumsik
Copy link
Contributor Author

kbumsik commented Sep 27, 2019

Great, I got another person who can test the actual hardware :D I will soon make a PR then.

@fpistm
Copy link
Member

fpistm commented Oct 10, 2019

Hi @kbumsik
I will made a new PR with the latest CubeFw and updated path as the HAL/LL source files are now in a built-in library.

@fpistm fpistm added this to the 1.8.0 milestone Oct 15, 2019
@aedancullen
Copy link

If you need another person to test on hardware, I also have a STM32MP157C-DK2 board and will be working on getting this up and running.

@fpistm
Copy link
Member

fpistm commented Oct 21, 2019

Hi @aedancullen
thanks for your proposition, any help are welcome.
I will update the MP1 Cube package because there is a new version and the way it is integrated in the core has changed since this PR was done.
Anyway, @kbumsik variant is always correct, so I'm waiting his PR for the variant.

@kbumsik kbumsik force-pushed the stm32mp1xx-package branch from a2c2456 to 23eceb0 Compare October 22, 2019 05:20
@kbumsik kbumsik mentioned this pull request Oct 22, 2019
2 tasks
@kbumsik
Copy link
Contributor Author

kbumsik commented Oct 22, 2019

@fpistm @aedancullen I was quite busy for a moment but now I can make a PR: #717 :)
I updated the Cube library to 1.1.0.
The weird thing is, that the some issues with peripherals like I2C I mentioned suddenly disappeared after I updated the Cube library and rebasing it to the latest master. Now all peripherals looks fine...😮 I don't know what happened but it is a good thing anyway.

#717 also has the same commits as this PR. I will clean up #717 after this PR is merged.

Though the hardware issues seems to be resolved, I would appreciate if anyone test my PR :)

@fpistm
Copy link
Member

fpistm commented Oct 24, 2019

Thanks @kbumsik for the update

It misses the HAL version in the https://github.com/stm32duino/Arduino_Core_STM32/blob/master/system/Drivers/STM32YYxx_HAL_Driver_version.md

During my review I found 3 files diff in the HAL (compare to the one installed by CubeMX 5.4.0):

3 files diff

--- Arduino_Core_STM32/system/Drivers/STM32MP1xx_HAL_Driver/Inc/stm32mp1xx_hal_tim_ex.h
+++ STM32Cube/Repository/STM32Cube_FW_MP1_V1.1.0/Drivers/STM32MP1xx_HAL_Driver/Inc/stm32mp1xx_hal_tim_ex.h
@@ -261,7 +261,13 @@
 #define IS_TIM_BREAKINPUT(__BREAKINPUT__)  (((__BREAKINPUT__) == TIM_BREAKINPUT_BRK)  || \
                                             ((__BREAKINPUT__) == TIM_BREAKINPUT_BRK2))
 
+#if defined(COMP1) && defined(COMP2)
+#define IS_TIM_BREAKINPUTSOURCE(__SOURCE__)  (((__SOURCE__) == TIM_BREAKINPUTSOURCE_BKIN)  || \
+                                              ((__SOURCE__) == TIM_BREAKINPUTSOURCE_COMP1) || \
+                                              ((__SOURCE__) == TIM_BREAKINPUTSOURCE_COMP2))
+#else
 #define IS_TIM_BREAKINPUTSOURCE(__SOURCE__)  ((__SOURCE__) == TIM_BREAKINPUTSOURCE_BKIN)
+#endif /* COMP1 && COMP2 */
 
 #define IS_TIM_BREAKINPUTSOURCE_STATE(__STATE__)  (((__STATE__) == TIM_BREAKINPUTSOURCE_DISABLE)  || \
                                                    ((__STATE__) == TIM_BREAKINPUTSOURCE_ENABLE))
--- Arduino_Core_STM32/system/Drivers/STM32MP1xx_HAL_Driver/Inc/stm32mp1xx_ll_tim.h
+++ STM32Cube/Repository/STM32Cube_FW_MP1_V1.1.0/Drivers/STM32MP1xx_HAL_Driver/Inc/stm32mp1xx_ll_tim.h
@@ -122,13 +122,13 @@
 /* Generic bit definitions for TIMx_AF1 register */
 #define TIMx_AF1_BKINE          TIM1_AF1_BKINE       /*!< BRK BKINE input enable */
 #if defined(DFSDM1_Channel0)
-#define TIMx_AF1_BKDFBKE        TIM1_AF1_BKDF1BK0E     /*!< BRK DFSDM1_BREAK[0] enable */
+#define TIMx_AF1_BKDFBKE        TIM1_AF1_BKDFBKE     /*!< BRK DFSDM1_BREAK[0] enable */
 #endif /* DFSDM1_Channel0 */
 #define TIMx_AF1_BKINP        TIM1_AF1_BKINP       /*!< BRK BKIN input polarity */
 /* Generic bit definitions for TIMx_AF2 register */
 #define TIMx_AF2_BK2INE         TIM1_AF2_BK2INE      /*!< BRK B2KINE input enable */
 #if defined(DFSDM1_Channel0)
-#define TIMx_AF2_BK2DFBKE       TIM1_AF2_BK2DF1BK1E    /*!< BRK DFSDM_BREAK[0] enable */
+#define TIMx_AF2_BK2DFBKE       TIM1_AF2_BK2DFBKE    /*!< BRK DFSDM_BREAK[0] enable */
 #endif /* DFSDM1_Channel0 */
 #define TIMx_AF2_BK2INP       TIM1_AF2_BK2INP      /*!< BRK BK2IN input polarity */
 #define TIMx_AF1_ETRSEL    TIM1_AF1_ETRSEL    /*!< TIMx ETR source selection */
@@ -1058,6 +1058,8 @@
   * @{
   */
 #define LL_TIM_BKIN_SOURCE_BKIN                TIM1_AF1_BKINE      /*!< BKIN input from AF controller */
+#define LL_TIM_BKIN_SOURCE_BKCOMP1             TIM1_AF1_BKCMP1E    /*!< internal signal: COMP1 output */
+#define LL_TIM_BKIN_SOURCE_BKCOMP2             TIM1_AF1_BKCMP2E    /*!< internal signal: COMP2 output */
 #define LL_TIM_BKIN_SOURCE_DF1BK               TIM1_AF1_BKDF1BK0E  /*!< internal signal: DFSDM1 break output */
 /**
   * @}
@@ -3731,8 +3733,12 @@
   * @note Macro IS_TIM_BREAKSOURCE_INSTANCE(TIMx) can be used to check whether
   *       or not a timer instance allows for break input selection.
   * @rmtoll AF1          BKINE         LL_TIM_EnableBreakInputSource\n
+  *         AF1          BKCMP1E       LL_TIM_EnableBreakInputSource\n
+  *         AF1          BKCMP2E       LL_TIM_EnableBreakInputSource\n
   *         AF1          BKDF1BK0E     LL_TIM_EnableBreakInputSource\n
   *         AF2          BK2INE        LL_TIM_EnableBreakInputSource\n
+  *         AF2          BK2CMP1E      LL_TIM_EnableBreakInputSource\n
+  *         AF2          BK2CMP2E      LL_TIM_EnableBreakInputSource\n
   *         AF2          BK2DF1BK1E    LL_TIM_EnableBreakInputSource
   * @param  TIMx Timer instance
   * @param  BreakInput This parameter can be one of the following values:
@@ -3740,6 +3746,8 @@
   *         @arg @ref LL_TIM_BREAK_INPUT_BKIN2
   * @param  Source This parameter can be one of the following values:
   *         @arg @ref LL_TIM_BKIN_SOURCE_BKIN
+  *         @arg @ref LL_TIM_BKIN_SOURCE_BKCOMP1
+  *         @arg @ref LL_TIM_BKIN_SOURCE_BKCOMP2
   *         @arg @ref LL_TIM_BKIN_SOURCE_DF1BK
   * @retval None
   */
@@ -3754,8 +3762,12 @@
   * @note Macro IS_TIM_BREAKSOURCE_INSTANCE(TIMx) can be used to check whether
   *       or not a timer instance allows for break input selection.
   * @rmtoll AF1          BKINE         LL_TIM_DisableBreakInputSource\n
+  *         AF1          BKCMP1E       LL_TIM_DisableBreakInputSource\n
+  *         AF1          BKCMP2E       LL_TIM_DisableBreakInputSource\n
   *         AF1          BKDF1BK0E     LL_TIM_DisableBreakInputSource\n
   *         AF2          BK2INE        LL_TIM_DisableBreakInputSource\n
+  *         AF2          BK2CMP1E      LL_TIM_DisableBreakInputSource\n
+  *         AF2          BK2CMP2E      LL_TIM_DisableBreakInputSource\n
   *         AF2          BK2DF1BK1E    LL_TIM_DisableBreakInputSource
   * @param  TIMx Timer instance
   * @param  BreakInput This parameter can be one of the following values:
@@ -3763,6 +3775,8 @@
   *         @arg @ref LL_TIM_BREAK_INPUT_BKIN2
   * @param  Source This parameter can be one of the following values:
   *         @arg @ref LL_TIM_BKIN_SOURCE_BKIN
+  *         @arg @ref LL_TIM_BKIN_SOURCE_BKCOMP1
+  *         @arg @ref LL_TIM_BKIN_SOURCE_BKCOMP2
   *         @arg @ref LL_TIM_BKIN_SOURCE_DF1BK
   * @retval None
   */
@@ -3777,14 +3791,19 @@
   * @note Macro IS_TIM_BREAKSOURCE_INSTANCE(TIMx) can be used to check whether
   *       or not a timer instance allows for break input selection.
   * @rmtoll AF1          BKINP         LL_TIM_SetBreakInputSourcePolarity\n
+  *         AF1          BKCMP1P       LL_TIM_SetBreakInputSourcePolarity\n
+  *         AF1          BKCMP2P       LL_TIM_SetBreakInputSourcePolarity\n
   *         AF2          BK2INP        LL_TIM_SetBreakInputSourcePolarity\n
+  *         AF2          BK2CMP1P      LL_TIM_SetBreakInputSourcePolarity\n
+  *         AF2          BK2CMP2P      LL_TIM_SetBreakInputSourcePolarity
   * @param  TIMx Timer instance
   * @param  BreakInput This parameter can be one of the following values:
   *         @arg @ref LL_TIM_BREAK_INPUT_BKIN
   *         @arg @ref LL_TIM_BREAK_INPUT_BKIN2
   * @param  Source This parameter can be one of the following values:
   *         @arg @ref LL_TIM_BKIN_SOURCE_BKIN
-  *         @arg @ref LL_TIM_BKIN_SOURCE_DF1BK
+  *         @arg @ref LL_TIM_BKIN_SOURCE_BKCOMP1
+  *         @arg @ref LL_TIM_BKIN_SOURCE_BKCOMP2
   * @param  Polarity This parameter can be one of the following values:
   *         @arg @ref LL_TIM_BKIN_POLARITY_LOW
   *         @arg @ref LL_TIM_BKIN_POLARITY_HIGH
--- Arduino_Core_STM32/system/Drivers/STM32MP1xx_HAL_Driver/Src/stm32mp1xx_hal_tim_ex.c
+++ STM32Cube/Repository/STM32Cube_FW_MP1_V1.1.0/Drivers/STM32MP1xx_HAL_Driver/Src/stm32mp1xx_hal_tim_ex.c
@@ -1826,6 +1826,24 @@
       bkin_polarity_bitpos = TIM1_AF1_BKINP_Pos;
       break;
     }
+#if defined(COMP1) && defined(COMP2)
+    case TIM_BREAKINPUTSOURCE_COMP1:
+    {
+      bkin_enable_mask = TIM1_AF1_BKCMP1E;
+      bkin_enable_bitpos = TIM1_AF1_BKCMP1E_Pos;
+      bkin_polarity_mask = TIM1_AF1_BKCMP1P;
+      bkin_polarity_bitpos = TIM1_AF1_BKCMP1P_Pos;
+      break;
+    }
+    case TIM_BREAKINPUTSOURCE_COMP2:
+    {
+      bkin_enable_mask = TIM1_AF1_BKCMP2E;
+      bkin_enable_bitpos = TIM1_AF1_BKCMP2E_Pos;
+      bkin_polarity_mask = TIM1_AF1_BKCMP2P;
+      bkin_polarity_bitpos = TIM1_AF1_BKCMP2P_Pos;
+      break;
+    }
+#endif /* COMP1 && COMP2 */
 
     default:
     {

@fpistm
Copy link
Member

fpistm commented Oct 24, 2019

I think I found the issue they made some update after GitHub release 1.1.0:
STMicroelectronics/STM32CubeMP1@0e09d0c
So in fact you added the 1.1.0 + 1 commit ;)

That's fine.

@fpistm fpistm merged commit 8110ed4 into stm32duino:master Oct 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new variant Add support of new bard
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants