Porting Amazon FreeRTOS to different STMicroelectronics Board / uController

donnerdave wrote on May 29, 2019:

What’s the best way to “port” Amazon FreeRTOS to a STMicroelectronics microcontroller / chip OTHER than the STM32L475VG / “STM32L4 Discovery Kit IoT Node”?

Happy to use System Workbench for STM32, the Eclipse based IDE upon which the “Getting Started with the STMicroelectronics STM32L4 …” project is based.

The project files in AmazonFreeRTOS\demos\st\stm32l475_discovery\ac6 are specific to the board / microcontroller – it looks like many of these files were generated by System Workbench for STM32; how do I target my microcontroller, rather than the STM32L475VG on the demo board?

Additionally, AmazonFreeRTOS\demos\st\stm32l475_discovery\common\application_code\st_code has oodles of code specific to the uC and board (e.g. startup_stm32l475xx.s – “STM32L475xx devices vector table for GCC toolchain.”, copyright by STMicroelectronics and authored by “MCD Application Team”). Is there a repository of these files, so that I can use the proper ones for my uC? Are these files generated / marshalled by another tool, for example STM32CubeMX? Or …

I’ve muddled through so far by copying the AmazonFreeRTOS\demos\st\stm32l475_discovery directory, renaming it for my uC and board, and modifying the config / source as needed – but it seems that there has to be a more effective and comprehensive way to target my system.

Thanks,

Dave

Gaurav-Aggarwal-AWS wrote on May 29, 2019:

To get a project for your ST microcontroller you can use STM32CubeMX which will include all the startup code (AmazonFreeRTOS\demos\st\stm32l475_discovery\ac6 and AmazonFreeRTOS\demos\st\stm32l475_discovery\common\application_code\st_code).

To port AmazonFreeRTOS to your custom hardware you can follow this porting guide: https://docs.aws.amazon.com/freertos/latest/portingguide/porting-guide.html

Are you using one of the boards from ST or have you designed your custom hardware?

Thanks.

donnerdave wrote on June 03, 2019:

Thanks Gaurav – is there an additional dependency on the directory AmazonFreeRTOS\lib\third_party\mcu_vendor\st\ ?

The porting guide describes this directory as appropriate for “vendor-supplied libraries that are common across an MCU family” – yet the initial subdirectory in the st directory is labelled “stm32l475_discovery” (i.e. the STMicroelectronics supported development board) – is the intention for this directory to be common to all STM32L4 boards?

As to your other question – we’re not using one of the ST dev boards, but are using our own hardware based on an MXChip module (STM32F411 uC, Cypress CYW43362 WiFi). Initial development was done under the Cypress WICED IoT framework, but we’re moving to Amazon FreeRTOS to take advantage of AWS IoT integration and OTA.

One additional question (happy to break this out to another topic, if appropriate) – is the STM32CubeMX configuration file that was used with the stm32l475_discovery ( presumably stm32l475_discovery.ioc ) available? Would love to have it as a resource in crafting one for our unique hardware. Thanks!

awsrwill wrote on June 04, 2019:

The demos use a couple of different hardware support libraries which are usually provided by chip vendors. For STM32 cores, the HAL (“Hardware Abstraction Layer”) packages should work the same across all STM32 chips of the same line (STM32L4, STM32F1, etc). But we do also use BSP (“Board Support Package”) libraries which provide more detailed abstractions for individual boards.

In this case, we are using the STM32L4 HAL alongside the BSP library for ST’s “B-L475E-IOT01A” board. Those libraries are both located under ‘lib/third_party/mcu_vendor/st/…’, and they are required dependencies for the demo project. But if you are using custom hardware, you can exclude the “B-L475E-IOT01A” library in lieu of one that describes the parts and connections on your custom board.

I don’t think that the existing Sockets/MQTT/etc libraries rely on any particular BSP library, but the WiFi libraries do because they need to change depending on what sort of WiFi module is being used. To support custom hardware, you will probably need to write a version of the AFR WiFi library to support your board’s WiFi module. You can look at the existing ‘aws_wifi.c’ files to see how the WiFi API is implemented for other boards, and the repository also contains a template file which you can copy and fill out: [https://github.com/aws/amazon-freertos/blob/master/lib/wifi/portable/vendor/board/aws_wifi.c]

We use the vendor-provided BSP library to set up the STM32 demo projects’ pin configurations, so unfortunately we don’t have STM32CubeMX project files available. But if you want to see how the demo application sets up its pins, you can view those initialization methods here:

[https://github.com/aws/amazon-freertos/blob/1da069bffe6641a5ab0b21c1605402cfd10ec1c5/demos/st/stm32l475_discovery/common/application_code/st_code/es_wifi_io.c#L99]

I hope that helps, and please let us know if you have further questions.