Skip to content

Conversation

JeanMarcR
Copy link
Owner

@JeanMarcR JeanMarcR commented Jan 22, 2021

Summary of changes

We would like to introduce the new STM32WL family.

Complementing the STM32 RF connectivity portfolio, the STM32WL System-On-Chip integrates both a general purpose microcontroller and a sub-GHz radio on the same chip.
Built on Arm® Cortex®‐M4 and Cortex®-M0+ cores (single- and dual-core architectures available - 48 MHz), STM32WL microcontrollers support multiple modulations– LoRa®, (G)FSK, (G)MSK, BPSK – to ensure flexibility in wireless applications with LoRaWAN®, Sigfox, W-MBUS or any other suitable protocol in a fully open way.
Thanks to a deep integration, the innovative and open architecture is optimized for LoRaWAN® legacy, Sigfox, proprietary protocols, flexible resource use, power management and helps lower BOM cost while offering a better user experience.

Developed using the same technology as the one implemented in our ultra-low-power STM32L4 microcontrollers, the STM32WL series provides similar digital and analog peripherals for basic or complex application use cases requiring an extended battery life and a long RF range through its sub-GHz transceiver.

To ensure worldwide compatibility, the STM32WL MCUs feature a dual power output and a wide linear frequency range fitting any unlicensed RF spectrum need.

Overall, the STM32WL series is the STM32 family’s pioneer in sub-GHz wireless connectivity, offering ease-of-use and reliability, while being perfectly tailored for a wide range of industrial and consumer applications.

Cube FW files are now available:
https://www.st.com/en/embedded-software/stm32cubewl.html

MBED-OS port has been implemented for NUCLEO_WL55JC target:

256 Kbytes of Flash memory
64 Kbytes of SRAM

https://www.st.com/en/microcontrollers-microprocessors/stm32wl55jc.html

Impact of changes

Migration actions required

Documentation


Pull request type

[x] Target update
[] Feature update (New feature / Functionality change / New API)
[] Major update (Breaking change E.g. Return code change / API behaviour change)

Test results

[] No Tests required for this change (E.g docs only update)
[x] Covered by existing mbed-os tests (Greentea or Unittest)
[] Tests / results supplied as part of this PR
Test executed on STMicroelectronics test bench with toolchain: ARM

Reviewers


@@ -171,7 +171,7 @@ def format_flags(self):
'--cpreproc --cpreproc_opts=-D__ASSERT_MSG,' +
",".join("-D{}".format(s) for s in
self.toolchain.get_symbols(for_asm=True)))
flags['asm_flags'] = asm_flag_string
flags['asm_flags'] = "{} {}".format(" ".join(self.toolchain.flags['asm']), asm_flag_string)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this patch from PR => followed by ARMmbed#10424

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -2,6 +2,7 @@
# SPDX-License-Identifier: Apache-2.0

# Sets cpu core options

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove patch from this PR => ARMmbed#14185

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines 4113 to 4131
"device_has_remove": [
]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to remove

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

"CRC",
"FLASH",
"SERIAL_ASYNCH",
"ANALOGOUT",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Miss ANALOGIN ?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I am updating.

@@ -37,7 +37,7 @@ void trng_init(trng_t *obj)
{
uint32_t dummy;

#if defined(RCC_PERIPHCLK_RNG) /* STM32L4 / STM32H7 / STM32WB / STM32G4 */
#if defined(RCC_PERIPHCLK_RNG) /* STM32L4 / STM32H7 / STM32WB */ /* STM32WL*/

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keep STM32G4 comment

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


#include "stm32wlxx.h"
#include "mbed_error.h"
#include "stm32wlxx_ll_hsem.h"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not used ?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed not used. Updated.

Comment on lines 37 to 45
void Error_Handler(void)
{
/* USER CODE BEGIN Error_Handler_Debug */
/* User can add his own implementation to report the HAL error return state */
while (1)
{
}
/* USER CODE END Error_Handler_Debug */
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to remove

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines 91 to 92
/* Peripheral clock enable */
/* __HAL_RCC_RNG_CLK_ENABLE(); A DECOMMENTER PEUT-ETRE */

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to remove

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
{
Error_Handler();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use MBED_ASSERT

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

* @retval None
*/

void SetSysClock(void)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add MBED_WEAK to allow application to reconfigure clock

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

#define __VTOR_PRESENT 1U /*!< Vector Table Register supported */
#define __NVIC_PRIO_BITS 4U /*!< STM32WLxx uses 4 Bits for the Priority Levels */
#define __Vendor_SysTickConfig 0U /*!< Set to 1 if different SysTick Config is used */
#define __FPU_PRESENT 0U /*!< FPU present */

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To remove warning:

Suggested change
#define __FPU_PRESENT 0U /*!< FPU present */
#define __FPU_PRESENT 0 /*!< FPU present */

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

forget this comment, keep original file

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

@@ -0,0 +1,57 @@
#! armcc -E

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#! armcc -E
#! armclang -E --target=arm-arm-none-eabi -x c -mcpu=cortex-<CORE_TYPE>

Please make sure the shebang in all scatter files specify armclang rather than armcc.🙌

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack
@JeanMarcR see patch on our internal branch

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

taunomagnusson and others added 18 commits January 24, 2021 02:15
…I have done a decent effort to port it / check it. However - Warning - Not everything is verified the the G431 Spec Sheets.
…ile. Added support for USB - connected the HSI48 clock to USB (and RNG). Warning: I'm assuming Flash latency is the same as for G474RE.
…ersion. I have not verified if it is truly needed, but it is better to err on the safe side.
…4 devices has 2 Flash Banks. Fix: Commented out SYSCFG_MEMRMP_FB_MODE since stm32g431KB only has 1 Flash Bank. flash_api.c checks for this #define and if it's set understands it as if the chip has 2 flash banks. STM32G4xx_HAL_Driver/stm32g4xx_hal.c also needs to check for this #define since it has flash bank swapping commands that are called in the startup sequence. Fix: Check for SYSCFG_MEMRMP_FB_MODE in Enable/Disable Flash bank swapping.
…ing has been fixed on G4xxx level (ARMmbed/mbed-os patch ARMmbed#14149)
… physical USBDEVICE should define it in targets.json)
…with RNG clock fixes. Removing USB Clock enablement (USB will not work out-of-the box but will require users to modify system_clock.c to enable its clock) - this inline with changes to targets.json where I removed the USBDEVICE define
…eripheralPins.py -t M40_Nucleo_NUCLEO-G431KB'. Had to do some modifications since the autogenerated files contained errors.
@JeanMarcR JeanMarcR changed the title STM32WL introduction Adding NUCLEO_WL55JC support Jan 25, 2021
hugueskamba and others added 2 commits January 25, 2021 10:48
The Mbed TLS Greentea tests can now be built with CMake.
Set DOMAIN_NS=1 only for _NS cores. We had it otherway around.
I verified one non NS target that was failing to build, plus also checked the old tools
that had this definitions:

```
   91:     "Cortex-M23-NS":   ["__CORTEX_M23", "ARM_MATH_ARMV8MBL", "DOMAIN_NS=1",
   92                          "__CMSIS_RTOS", "__MBED_CMSIS_RTOS_CM"],
   93      "Cortex-M23":      ["__CORTEX_M23", "ARM_MATH_ARMV8MBL", "__CMSIS_RTOS",
   94                          "__MBED_CMSIS_RTOS_CM"],
```
@@ -323,7 +323,7 @@ int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32
core_util_critical_section_enter();

/* Enable SYSCFG Clock */
#if !defined(TARGET_STM32WB)
#if (!defined(TARGET_STM32WB) && !defined(TARGET_STM32WL))
__HAL_RCC_SYSCFG_CLK_ENABLE();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this file, there is
if defined(DUAL_CORE)
without && (H7) ==> to be added

Good catch @ludoch-stm

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@JeanMarcR JeanMarcR force-pushed the STM32WL_JMR branch 2 times, most recently from 3a2a264 to bc4def6 Compare January 25, 2021 15:29
Tauno Magnusson added 3 commits January 26, 2021 01:21
…on. Also added so that the CK48 Clock Mux selects HSI48 for both RNG and USB. Without these the RNG/USB will be clocked at PLLQ (170 MHz) and not work.
…e HSI48 CLK for USB. Assumption is that the STM32G4 reset value (defaults to HSI48 selected for USB) is preserved throughout Mbed initialization.
…bedtls

CMake: Add support for Mbed TLS Greentea tests
rajkan01 and others added 24 commits February 2, 2021 07:43
…vert

BLE: return OK when stopping advertising set that is not active
LoraRadio test update for baremetal support
Support for ST STM32 NUCLEO-G431KB Development Board
Adding USB HS Support to the SDP-K1
STM: Fix Hal_GetTick wrap around errors
Move the mbed_set_mbed_target_linker_script function into its own file
and make it set the linkerscript on the target passed in, rather than
setting the linkerscript on the top level mbed-core target. We use
CMake's automatic forwarding of usage requirements to forward the linker
script to the top level target.

This commit also adds a condition to check whether the MBED_TARGET is a
CMake buildsystem target. If it is we will just link to it in the
idiomatic CMake way, if it's not then we use the 'old' mechanism of
setting the linkerscript for the mbed-core target. This check will be
useful when we refactor MBED_TARGETS to be CMake buildsystem targets as
it will allow us to do the refactoring incrementally.
Refactor all ST targets to be CMake buildsystem targets. This removes
the need for checking MBED_TARGET_LABELS repeatedly and allows us to be
more flexible in the way we include MBED_TARGET source in the build.

A side effect of this is it will allow us to support custom targets
without breaking the build for 'standard' targets, as we use CMake's
standard mechanism for adding build rules to the build system, rather
than implementing our own layer of logic to exclude files not needed for
the target being built. Using this approach, if an MBED_TARGET is not
linked to using `target_link_libraries` its source files will not be
added to the build. This means custom target source can be added to the
user's application CMakeLists.txt without polluting the build system
when trying to compile for a standard MBED_TARGET.
…actor-st-mbed-targets

Refactor ST Mbed targets to be CMake buildsystem targets
BlockDevices: specify mbed namespace where needed
Add code concerning all STM32 platforms
Add code concerning all STM32WL platforms
- STM32 Cube Firmware

Update CMakeLists.txt due to mbedtools evolution
Add code concerning all STM32WL55xC platforms
- Scatter loader and start-up files for
  ARM, GCC and IAR compilers.
- cmsis file
- Update CMakeLists.txt due to mbtools evolution
Add code concerning all STM32WL55JC platforms
- system clock, pin and peripheral definition
  mbedtools make file

Modify CmakeList to adapt to mbedtools evolution
Add STM32WL information in targets.json file
Add STM32WL information in index.json file
Adding sector
Add link option in file used for compilation.
Due to a bug in mbedtools environment.
@JeanMarcR JeanMarcR force-pushed the STM32WL_JMR branch 2 times, most recently from 11b34d8 to 6220ca5 Compare February 8, 2021 12:58
JeanMarcR pushed a commit that referenced this pull request Jun 30, 2021
Many test stub functions are meant to return a value, but weren't. Clang
would generate a warning for each instance where we weren't returning
anything in a function that was meant to return a value.

    warning: non-void function does not return a value [-Wreturn-type]

For a specific example, my_radio::time_on_air() is supposed to return a
uint32_t, but wasn't returning anything. We'll return a zero instead of
relying on undefined behavior.

Without this, clang 11.0.1 was generating a virtual function
implementation with a `ud2` instruction to abort at run-time, causing
some execution of some unit tests to abort.

    Running main() from gmock_main.cc
    [==========] Running 10 tests from 1 test suite.
    [----------] Global test environment set-up.
    [----------] 10 tests from Test_LoRaPHYUS915
    [ RUN      ] Test_LoRaPHYUS915.constructor
    [       OK ] Test_LoRaPHYUS915.constructor (0 ms)
    [ RUN      ] Test_LoRaPHYUS915.restore_default_channels
    [       OK ] Test_LoRaPHYUS915.restore_default_channels (0 ms)
    [ RUN      ] Test_LoRaPHYUS915.rx_config
    [       OK ] Test_LoRaPHYUS915.rx_config (0 ms)
    [ RUN      ] Test_LoRaPHYUS915.tx_config
    Process 35669 stopped
    * thread #1, name = 'lorawan-loraphy-', stop reason = signal SIGILL: privileged instruction
        frame #0: 0x0000000000276f73 lorawan-loraphy-us915-unittest`my_radio::time_on_air(this=0x0000000800c2b048, modem=MODEM_LORA, pkt_len='\0') at Test_LoRaPHYUS915.cpp:90:5
       87       };
       88
       89       virtual uint32_t time_on_air(radio_modems_t modem, uint8_t pkt_len)
    -> 90       {
       91       };
       92
       93       virtual bool perform_carrier_sense(radio_modems_t modem,
    (lldb) disassemble --pc
    lorawan-loraphy-us915-unittest`my_radio::time_on_air:
    ->  0x276f73 <+67>: ud2
        0x276f75:       int3
        0x276f76:       int3
        0x276f77:       int3
    (lldb)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.