Hi,
For a work related project, I need to use µpython on a Cerb40 (https://www.ghielectronics.com/catalog/product/353).
I haven't seen any port to this board, so maybe I can be helping.
I have tried to compile and push standart µpython to the board but it does not work (that's not very surprising).
The board is powered by a STM32F405 but has a quartz on it.
I am quite experienced in python, but not really in embeded things.
Where should I begin the modificiations and how could I debug the whole thing (for now when I plug it, nothing appears on the computer, but how can I see where the issue is comming from ?)
Thanks.
Port to FEZ Cerb40 1.1
Re: Port to FEZ Cerb40 1.1
What frequency does the external crystal run at?
HSE_VALUE defaults to 8000000
You should set this in your board specific stm32f4xx_hal_conf.h file (for example, the NETDUINO_PLUS_2 has a 25 MHz crystal)
HSE_VALUE defaults to 8000000
You should set this in your board specific stm32f4xx_hal_conf.h file (for example, the NETDUINO_PLUS_2 has a 25 MHz crystal)
Re: Port to FEZ Cerb40 1.1
The quartz is 12MHz.
We changed stm32f4xx_hal_conf.h with this :
Nevertheless, with this, the USB wasn't working.
We say that micropython was running on the board with hardware debug (when the press reset, a GPIO was put to 0 then to 1 again).
Digging a little more, we realized that on the CERB40 the USB_VBUS isn't routed. Nevertheless it needs to be at 1 if we want the USB to work.
So in usbd_conf.c we added this in function void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd):
We tried to set the GPIO9 to INPUT with a PULLUP, nevertheless it didn't work, the voltage at the GPIO was roulgly 1.2V (strange).
So we setted the GPIO to output and HIGH.
I don't know if I can push code like this on the github because it may burn all boards, changing INPUT to OUTPUT...
Do you have an idea to make it work with the PULLUP in input mode ?
Thanks.
We changed stm32f4xx_hal_conf.h with this :
Code: Select all
#if !defined (HSE_VALUE)
#define HSE_VALUE ((uint32_t)12000000) /*!< Value of the External oscillator in Hz */
#endif /* HSE_VALUE */
We say that micropython was running on the board with hardware debug (when the press reset, a GPIO was put to 0 then to 1 again).
Digging a little more, we realized that on the CERB40 the USB_VBUS isn't routed. Nevertheless it needs to be at 1 if we want the USB to work.
So in usbd_conf.c we added this in function void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd):
Code: Select all
#if defined(IGNORE_USB_VBUS)
GPIO_InitStruct.Pin = GPIO_PIN_9;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
GPIOA->BSRRL = GPIO_PIN_9;
#else
GPIO_InitStruct.Pin = GPIO_PIN_9;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
#endif
So we setted the GPIO to output and HIGH.
I don't know if I can push code like this on the github because it may burn all boards, changing INPUT to OUTPUT...
Do you have an idea to make it work with the PULLUP in input mode ?
Thanks.
Re: Port to FEZ Cerb40 1.1
Personally, I think that the correct way for this to be implemented is to do something along the lines of having a config option which defines the VBUS pin.
If the config option isn't defined, then VBUS detection would be turned off.
So, keeping things aligned with existing defines, we would add something like:
Not only do you need to modify where the pin is initialized, but you also need to modify this code as well:
https://github.com/micropython/micropyt ... #L343-L347
If USB VBUS detection isn't used, then we shouldn't initialize any pin for it. Configuring the pin as an input or an output could affect the board in undesirable ways depending on what's connected to that pin.
I think that others have tripped over this as well, so I'm going to go ahead and file an issue to make this configurable. I opened https://github.com/micropython/micropython/issues/1048
If the config option isn't defined, then VBUS detection would be turned off.
So, keeping things aligned with existing defines, we would add something like:
Code: Select all
#define MICROPY_HW_USB_VBUS_DETECT_PIN (pin_A9)
https://github.com/micropython/micropyt ... #L343-L347
If USB VBUS detection isn't used, then we shouldn't initialize any pin for it. Configuring the pin as an input or an output could affect the board in undesirable ways depending on what's connected to that pin.
I think that others have tripped over this as well, so I'm going to go ahead and file an issue to make this configurable. I opened https://github.com/micropython/micropython/issues/1048
Re: Port to FEZ Cerb40 1.1
Thanks guys, this config option is now implemented.
When the port to the FEZ works, maybe we can add it to the stmhal/ code in the main repository? I guess that it would simply be a new dir in stmhal/boards?
When the port to the FEZ works, maybe we can add it to the stmhal/ code in the main repository? I guess that it would simply be a new dir in stmhal/boards?
Re: Port to FEZ Cerb40 1.1
I just ordered a couple of these (Cerb40 II):
https://www.ghielectronics.com/catalog/product/450 - at 24.95, the price makes them attractive for a project I have in mind.
So I'll add a board for that. If I can dig up schematics for the Cerb40 or otherwise figure out the differences, then I can accomodate those as well.
https://www.ghielectronics.com/catalog/product/450 - at 24.95, the price makes them attractive for a project I have in mind.
So I'll add a board for that. If I can dig up schematics for the Cerb40 or otherwise figure out the differences, then I can accomodate those as well.
Re: Port to FEZ Cerb40 1.1
There is a Pull Request which adds support for the Cerb40: https://github.com/micropython/micropython/pull/1070
I have the 2.0 board, but looking at the schematics an earlier board, I think that this will work for those as well.
I have the 2.0 board, but looking at the schematics an earlier board, I think that this will work for those as well.
Re: Port to FEZ Cerb40 1.1
I added a wiki page for the board: https://github.com/micropython/micropyt ... -Cerb40-II
To build the firmware, you'll need to use BOARD=CERB40
To build the firmware, you'll need to use BOARD=CERB40