Main Site Documentation

Porting .NET MF to STM32F4 - changing the USB peripheral used by Tinybooter


#1

Hello,

while working on a custom .NET MF port to a custom board with STM32F4, I have run into a need to change the MCU’s USB peripheral being used by TinyBooter to communicate with the host PC&MFDeploy.

The original port from Oberon, Inc. (http://netmf4stm32.codeplex.com/) and all the other ports, including the FEZCerberus_Community use the USB_OTG_FS peripheral (pins PA11 and PA2). In my case, I would like to switch it to the USB_OTG_HS peripheral (MCU pins PB14 and PB15). The MCU being used is STM32F407ZG.

My source code is based on the original .NET MF PK 4.2 source linked above, but it is not much different from the above-mentioned FEZCerberus_Community port 4.3 when it comes to the files and data structures described below.

I tried to change the following defines in platform_selector.h from USB1 to USB2, however with no effect. The tinybooter still communicates with PC via USB_OTG_FS.


 #define DEBUG_TEXT_PORT                 USB2
 #define STDIO                           USB2
 #define DEBUGGER_PORT                   USB2
 #define MESSAGING_PORT                  USB2

What I traced so far, the constants get propagated and they get to the

DeviceCode/Initialization/OEM_Model_SKU_NetworkID.cpp

file to the global variable HalSystemConfig. The HalSystemConfig structure is then used by various parts of the .NET MF – the Application/TinyBooter/TinyBooter.cpp seems important for my case. There I got stuck a bit with deciphering what happens next.

Could you hint me where to look next in order to make the USB working? Thank you for any help.


#2

At first glance, nothing wrong with these settings.
I tried this with COM3 and it should work.
No one used USB FS, maybe it’s not tested…
You can debug with USB on a COM port using an USB COM adapter, it work for Cerberus. And USB FS is not faster than a COM port.


#3

I presume that in platform_selector.h you have:


 #define TOTAL_USB_CONTROLLER            2
 #define USB_MAX_QUEUES                  6  // 6 endpoints (EP0 + 5)

Not the Ceberus version:

What are your SPI configurations? The Oberon Discovery SW uses PB15 & 15 as an SPI port so perhaps on initialisation that resets the pins to SPI as opposed to USB_HS?

After that I think the next place to check is:
C:\MicroFrameworkPK_v4_2\DeviceCode\Targets\Native\STM32F4\DeviceCode\STM32F4_USB\STM32F4_usb_functions.cpp

That seems to be where the actual pins used are set and which port, USBx, is FS or HS.
COM1=FS, COM2=HS.

Not sure I’ve helped really.


#4

Hello Stephen61 and NicolasG, thx for your hints! I’ll check this out and let you know, however now I am a bit delayed by a problem with custom interop that I am discussing in another thread. As for the USB, for now I am able to get by using the “standard” USB_HS.