I'll post the diff and the error I'm currently seeing below, but I think it makes sense to talk method first.
How do you port to a new stm32 target?
What I know:
In "boards", you need:
- BOARD_NAME/mpconfigboard.h
- BOARD_NAME/mpconfigboard.mk
- BOARD_NAME/pins.csv
- BOARD_NAME/stm32X4xx_hal_conf.h
- stm32X4xx_af.csv
- stm32X4xxxx.ld
Then, I start with the linker script, which I seem to be able to figure out well enough using all the other examples.
Next, I mostly ignore the af and pins file - I'm thinking I should get the build passing before I dive into the right names and mapping. Especially af is huge and I'm not looking forward to extract all these mappings from the datasheet, but I never got that far ... .
mpconfigboard.mk again seems quite simple and with the examples of the other ports I think I'm doing this right.
Then, mpconfigboard.h, where I make sure that I have the right pins and mostly disable everything but UART for the first try. For my first build, I just want to get the UART REPL, all the other stuff comes later.
Lastly, stm32X4xx_hal_conf.h, where I think I also only have to disable the HAL features I don't have on the controller, and where I have to get the clock right.
Is there anything fundamentally wrong with that approach?
Onwards to the specific problem:
When building, I get this error (both with #define MICROPY_HW_ENABLE_TIMER (1)
and (0)):
Code: Select all
timer.c:614:17: error: implicit declaration of function '__HAL_RCC_TIM3_CLK_ENABLE'; did you mean '__HAL_RCC_TIM7_CLK_ENABLE'? [-Werror=implicit-function-declaration]
case 3: __HAL_RCC_TIM3_CLK_ENABLE(); break;
^~~~~~~~~~~~~~~~~~~~~~~~~
__HAL_RCC_TIM7_CLK_ENABLE
timer.c: At top level:
timer.c:699:49: error: 'TIM3' undeclared here (not in a function); did you mean 'TIM1'?
https://github.com/micropython/micropyt ... tm32l433rc
complete build error
Code: Select all
CC timer.c
timer.c: In function 'pyb_timer_init_helper':
timer.c:614:17: error: implicit declaration of function '__HAL_RCC_TIM3_CLK_ENABLE'; did you mean '__HAL_RCC_TIM7_CLK_ENABLE'? [-Werror=implicit-function-declaration]
case 3: __HAL_RCC_TIM3_CLK_ENABLE(); break;
^~~~~~~~~~~~~~~~~~~~~~~~~
__HAL_RCC_TIM7_CLK_ENABLE
timer.c: At top level:
timer.c:699:49: error: 'TIM3' undeclared here (not in a function); did you mean 'TIM1'?
#define TIM_ENTRY(id, irq) [id - 1] = (uint32_t)TIM##id | irq
^
timer.c:709:5: note: in expansion of macro 'TIM_ENTRY'
TIM_ENTRY(3, TIM3_IRQn),
^~~~~~~~~
timer.c:709:18: error: 'TIM3_IRQn' undeclared here (not in a function); did you mean 'TIM7_IRQn'?
TIM_ENTRY(3, TIM3_IRQn),
^
timer.c:699:59: note: in definition of macro 'TIM_ENTRY'
#define TIM_ENTRY(id, irq) [id - 1] = (uint32_t)TIM##id | irq
^~~
cc1: all warnings being treated as errors
make: *** [../../py/mkrules.mk:47: build-PL_L433RC/timer.o] Error 1
make: *** Waiting for unfinished jobs....
In file included from ../../py/mpstate.h:35:0,
from ../../py/runtime.h:29,
from pin.c:31:
build-PL_L433RC/genhdr/pins_af_const.h:6:56: error: 'GPIO_AF14_TIM17' undeclared here (not in a function); did you mean 'GPIO_AF14_TIM15'?
{ MP_ROM_QSTR(MP_QSTR_AF14_TIM17), MP_ROM_INT(GPIO_AF14_TIM17) },
^
../../py/obj.h:87:67: note: in definition of macro 'MP_OBJ_NEW_SMALL_INT'
#define MP_OBJ_NEW_SMALL_INT(small_int) ((mp_obj_t)((((mp_uint_t)(small_int)) << 1) | 1))
^~~~~~~~~
build-PL_L433RC/genhdr/pins_af_const.h:6:45: note: in expansion of macro 'MP_ROM_INT'
{ MP_ROM_QSTR(MP_QSTR_AF14_TIM17), MP_ROM_INT(GPIO_AF14_TIM17) },
^~~~~~~~~~
build-PL_L433RC/genhdr/pins_af_const.h:11:56: error: 'GPIO_AF2_TIM3' undeclared here (not in a function); did you mean 'GPIO_AF2_TIM1'?
{ MP_ROM_QSTR(MP_QSTR_AF2_TIM3), MP_ROM_INT(GPIO_AF2_TIM3) },
^
../../py/obj.h:87:67: note: in definition of macro 'MP_OBJ_NEW_SMALL_INT'
#define MP_OBJ_NEW_SMALL_INT(small_int) ((mp_obj_t)((((mp_uint_t)(small_int)) << 1) | 1))
^~~~~~~~~
build-PL_L433RC/genhdr/pins_af_const.h:11:45: note: in expansion of macro 'MP_ROM_INT'
{ MP_ROM_QSTR(MP_QSTR_AF2_TIM3), MP_ROM_INT(GPIO_AF2_TIM3) },
^~~~~~~~~~
build-PL_L433RC/genhdr/pins_af_const.h:12:56: error: 'GPIO_AF2_TIM4' undeclared here (not in a function); did you mean 'GPIO_AF2_TIM3'?
{ MP_ROM_QSTR(MP_QSTR_AF2_TIM4), MP_ROM_INT(GPIO_AF2_TIM4) },
^
../../py/obj.h:87:67: note: in definition of macro 'MP_OBJ_NEW_SMALL_INT'
#define MP_OBJ_NEW_SMALL_INT(small_int) ((mp_obj_t)((((mp_uint_t)(small_int)) << 1) | 1))
^~~~~~~~~
build-PL_L433RC/genhdr/pins_af_const.h:12:45: note: in expansion of macro 'MP_ROM_INT'
{ MP_ROM_QSTR(MP_QSTR_AF2_TIM4), MP_ROM_INT(GPIO_AF2_TIM4) },
^~~~~~~~~~
build-PL_L433RC/genhdr/pins_af_const.h:13:56: error: 'GPIO_AF2_TIM5' undeclared here (not in a function); did you mean 'GPIO_AF2_TIM4'?
{ MP_ROM_QSTR(MP_QSTR_AF2_TIM5), MP_ROM_INT(GPIO_AF2_TIM5) },
^
../../py/obj.h:87:67: note: in definition of macro 'MP_OBJ_NEW_SMALL_INT'
#define MP_OBJ_NEW_SMALL_INT(small_int) ((mp_obj_t)((((mp_uint_t)(small_int)) << 1) | 1))
^~~~~~~~~
build-PL_L433RC/genhdr/pins_af_const.h:13:45: note: in expansion of macro 'MP_ROM_INT'
{ MP_ROM_QSTR(MP_QSTR_AF2_TIM5), MP_ROM_INT(GPIO_AF2_TIM5) },
^~~~~~~~~~
build-PL_L433RC/genhdr/pins_af_const.h:14:56: error: 'GPIO_AF3_TIM8' undeclared here (not in a function); did you mean 'GPIO_AF2_TIM5'?
{ MP_ROM_QSTR(MP_QSTR_AF3_TIM8), MP_ROM_INT(GPIO_AF3_TIM8) },
^
../../py/obj.h:87:67: note: in definition of macro 'MP_OBJ_NEW_SMALL_INT'
#define MP_OBJ_NEW_SMALL_INT(small_int) ((mp_obj_t)((((mp_uint_t)(small_int)) << 1) | 1))
^~~~~~~~~
build-PL_L433RC/genhdr/pins_af_const.h:14:45: note: in expansion of macro 'MP_ROM_INT'
{ MP_ROM_QSTR(MP_QSTR_AF3_TIM8), MP_ROM_INT(GPIO_AF3_TIM8) },
^~~~~~~~~~
make: *** [../../py/mkrules.mk:47: build-PL_L433RC/pin.o] Error 1