I am trying to port micropython to my own board which has an STM32F767 on board. The issue I'm having is that my board does not have an LSE oscillator on board, only a 24MHz HSE.
Micropython by default uses the LSE 32kHz oscillator to generate the baud rates, but this is not necessary in the general case when configuring the device. Is there a way to force micropython to generate the uart clock from the HSE source? When I say "Is there a way" I of course mean "is there an easy way"...
Porting to STM32-based custom board
Re: Porting to STM32-based custom board
So it turns out that even though I don't have the 32kHz clock I still need to set the LSE_VALUE in my board, otherwise the compiler complains.
I have successfully compiled to a REPL on my serial port!!! Happy days!
Now I should be able to develop the rest of the app much faster.
I have successfully compiled to a REPL on my serial port!!! Happy days!
Now I should be able to develop the rest of the app much faster.
Re: Porting to STM32-based custom board
My board has an SD Card, on the SDMMC2 port. Micropython fails to build with the defines for the pins as:
Specifically, the failure is at the pin_G10 line (and I suspect also the pin_G11 and pin_G12). STM32Cube IDE allows these as valid pins, but my build gives the following error:
Is this an issue because I copied the pins.csv file directly from the NUCLEO_F767ZI folder, and didn't edit it? Is there a guide to writing the pins.csv file anywhere?
I am very excited by my progress so far just in one day.
Code: Select all
#define MICROPY_HW_SDMMC2_CK (pin_D6)
#define MICROPY_HW_SDMMC2_CMD (pin_D7)
#define MICROPY_HW_SDMMC2_D0 (pin_G9)
#define MICROPY_HW_SDMMC2_D1 (pin_G10)
#define MICROPY_HW_SDMMC2_D2 (pin_G11)
#define MICROPY_HW_SDMMC2_D3 (pin_G12)
#define MICROPY_HW_SDCARD_DETECT_PIN (pin_D5)
#define MICROPY_HW_SDCARD_DETECT_PULL (GPIO_PULLUP)
#define MICROPY_HW_SDCARD_DETECT_PRESENT (GPIO_PIN_RESET)
Code: Select all
boards/UC_BASEBOARD/mpconfigboard.h:94:46: error: 'pin_G10' undeclared (first use in this function); did you mean 'pin_A10'?
I am very excited by my progress so far just in one day.
Re: Porting to STM32-based custom board
I've now edited my pins.csv file, and it seems like the board is working (I can toggle my LEDs, and I have a REPL).
So, super progress in less than a day!
Anyway, I also had to edit leds.c as my board has 6 LEDs rather than the maximum of 4 allowed by the original source. It was a very easy fix!
Happy to submit a patch if it's wanted.
So, super progress in less than a day!
Anyway, I also had to edit leds.c as my board has 6 LEDs rather than the maximum of 4 allowed by the original source. It was a very easy fix!
Happy to submit a patch if it's wanted.
Re: Porting to STM32-based custom board
Hi,
That's fantastic! Sorry I didn't get to your messages in time, but looks like you got it all going.
I guess no harm in sending a patch if it's not too much work!
That's fantastic! Sorry I didn't get to your messages in time, but looks like you got it all going.
I guess no harm in sending a patch if it's not too much work!
Re: Porting to STM32-based custom board
Hi Jimmo:
Sorry but I don't know where to submit the patch directly, so here is the patch in unified diff format:
As you can see I just extended the LED defines through to 6 LEDs.
Cheers,
Matt.
Sorry but I don't know where to submit the patch directly, so here is the patch in unified diff format:
Code: Select all
ports/stm32/led.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/ports/stm32/led.c b/ports/stm32/led.c
index 923171884..e0ca89a55 100644
--- a/ports/stm32/led.c
+++ b/ports/stm32/led.c
@@ -58,6 +58,12 @@ STATIC const pyb_led_obj_t pyb_led_obj[] = {
{{&pyb_led_type}, 3, MICROPY_HW_LED3},
#if defined(MICROPY_HW_LED4)
{{&pyb_led_type}, 4, MICROPY_HW_LED4},
+ #if defined(MICROPY_HW_LED5)
+ {{&pyb_led_type}, 5, MICROPY_HW_LED5},
+ #if defined(MICROPY_HW_LED6)
+ {{&pyb_led_type}, 6, MICROPY_HW_LED6},
+ #endif
+ #endif
#endif
#endif
#endif
@@ -77,7 +83,9 @@ void led_init(void) {
#if defined(MICROPY_HW_LED1_PWM) \
|| defined(MICROPY_HW_LED2_PWM) \
|| defined(MICROPY_HW_LED3_PWM) \
- || defined(MICROPY_HW_LED4_PWM)
+ || defined(MICROPY_HW_LED4_PWM) \
+ || defined(MICROPY_HW_LED5_PWM) \
+ || defined(MICROPY_HW_LED6_PWM)
// The following is semi-generic code to control LEDs using PWM.
// It currently supports TIM1, TIM2 and TIM3, channels 1-4.
@@ -98,6 +106,12 @@ void led_init(void) {
#ifndef MICROPY_HW_LED4_PWM
#define MICROPY_HW_LED4_PWM { NULL, 0, 0, 0 }
#endif
+#ifndef MICROPY_HW_LED5_PWM
+#define MICROPY_HW_LED5_PWM { NULL, 0, 0, 0 }
+#endif
+#ifndef MICROPY_HW_LED6_PWM
+#define MICROPY_HW_LED6_PWM { NULL, 0, 0, 0 }
+#endif
#define LED_PWM_TIM_PERIOD (10000) // TIM runs at 1MHz and fires every 10ms
Cheers,
Matt.