Skip to content

Commit 162acab

Browse files
Jamie Smithjeromecoutant
andauthored
STM32U5 HAL update, NUCLEO_U575ZI upload method file (#184)
* STM32U5: STM32Cube_FW_U5_V1.2.0 * Update STM32U5 upload method config files * Fix HAL sleep manager test bug causing test failure on STM32U5 --------- Co-authored-by: Jerome Coutant <[email protected]>
1 parent 36506c9 commit 162acab

File tree

255 files changed

+207793
-13237
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

255 files changed

+207793
-13237
lines changed

hal/tests/TESTS/mbed_hal/sleep/sleep_test_utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ bool compare_timestamps(unsigned int delta_ticks, unsigned int ticker_width, uns
7878
return false;
7979
}
8080
} else {
81-
if ((actual >= lower_bound && actual <= counter_mask) || (actual >= 0 && actual <= upper_bound)) {
81+
if ((actual >= lower_bound && actual <= counter_mask) || (actual <= upper_bound)) {
8282
return true;
8383
} else {
8484
return false;

hal/tests/TESTS/mbed_hal/sleep_manager/main.cpp

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "unity/unity.h"
1919
#include "greentea-client/test_env.h"
2020
#include <limits.h>
21+
#include <cinttypes>
2122
#include "mbed.h"
2223
#include "mbed_lp_ticker_wrapper.h"
2324
#include "hal/us_ticker_api.h"
@@ -31,6 +32,8 @@
3132
#define SLEEP_DURATION_US 50000ULL
3233

3334
// Tolerance for extra sleep time in the deep sleep test.
35+
// This accounts for the time that the processor spends going to sleep and waking up.
36+
// The hal_deepsleep() docs specify this to be less than 10ms
3437
// Current leader is the MIMXRT105x, which takes almost 5ms to enter/exit deep sleep.
3538
#define DEEP_SLEEP_TOLERANCE_US 5000ULL
3639

@@ -147,7 +150,7 @@ void test_sleep_auto()
147150
const ticker_info_t *lp_ticker_info = get_lp_ticker_data()->interface->get_info();
148151
const unsigned lp_ticker_mask = ((1 << lp_ticker_info->bits) - 1);
149152
const ticker_irq_handler_type lp_ticker_irq_handler_org = set_lp_ticker_irq_handler(lp_ticker_isr);
150-
uint32_t us_ts1, us_ts2, lp_ts1, lp_ts2, us_diff1, us_diff2, lp_diff1, lp_diff2;
153+
uint32_t us_diff1, us_diff2, lp_diff1, lp_diff2;
151154

152155
const unsigned int sleep_duration_lp_ticks = us_to_ticks(SLEEP_DURATION_US, lp_ticker_info->frequency);
153156
const unsigned int sleep_duration_us_ticks = us_to_ticks(SLEEP_DURATION_US, us_ticker_info->frequency);
@@ -156,28 +159,28 @@ void test_sleep_auto()
156159
// interrupts on some targets, which wake us from sleep.
157160
busy_wait_ms(SERIAL_FLUSH_TIME_MS);
158161

159-
/* Some targets may need an interrupt short time after LPTIM interrupt is
160-
* set and forbid deep_sleep during that period. Let this period pass */
161-
TEST_ASSERT_TRUE(sleep_manager_can_deep_sleep_test_check());
162-
163-
sleep_manager_lock_deep_sleep();
164-
165162
/* Let's avoid the Lp ticker wrap-around case */
166163
wraparound_lp_protect();
167-
uint32_t lp_wakeup_ts_raw = lp_ticker_read() + sleep_duration_lp_ticks;
164+
165+
uint32_t start_lp_time = lp_ticker_read();
166+
uint32_t start_us_time = us_ticker_read();
167+
uint32_t lp_wakeup_ts_raw = start_lp_time + sleep_duration_lp_ticks;
168168
timestamp_t lp_wakeup_ts = overflow_protect(lp_wakeup_ts_raw, lp_ticker_info->bits);
169169
lp_ticker_set_interrupt(lp_wakeup_ts);
170170

171-
us_ts1 = us_ticker_read();
172-
lp_ts1 = lp_ticker_read();
171+
/* Some targets may need an interrupt short time after LPTIM interrupt is
172+
* set and forbid deep_sleep during that period. Let this period pass */
173+
TEST_ASSERT_TRUE(sleep_manager_can_deep_sleep_test_check());
174+
175+
sleep_manager_lock_deep_sleep();
173176

174177
sleep_manager_sleep_auto();
175178

176-
us_ts2 = us_ticker_read();
177-
lp_ts2 = lp_ticker_read();
179+
uint32_t end_us_time = us_ticker_read();
180+
uint32_t end_lp_time = lp_ticker_read();
178181

179-
us_diff1 = (us_ts1 <= us_ts2) ? (us_ts2 - us_ts1) : (us_ticker_mask - us_ts1 + us_ts2 + 1);
180-
lp_diff1 = (lp_ts1 <= lp_ts2) ? (lp_ts2 - lp_ts1) : (lp_ticker_mask - lp_ts1 + lp_ts2 + 1);
182+
us_diff1 = (start_us_time <= end_us_time) ? (end_us_time - start_us_time) : (us_ticker_mask - start_us_time + end_us_time + 1);
183+
lp_diff1 = (start_lp_time <= end_lp_time) ? (end_lp_time - start_lp_time) : (lp_ticker_mask - start_lp_time + end_lp_time + 1);
181184

182185
// Deep sleep locked -- ordinary sleep mode used:
183186
// * us_ticker powered ON,
@@ -189,30 +192,30 @@ void test_sleep_auto()
189192
TEST_ASSERT_UINT64_WITHIN_MESSAGE(sleep_duration_us_ticks / 10ULL, sleep_duration_us_ticks, us_diff1, "us ticker sleep time incorrect - perhaps deep sleep mode was used?");
190193

191194
sleep_manager_unlock_deep_sleep();
192-
/* Some targets may need an interrupt short time after LPTIM interrupt is
193-
* set and forbid deep_sleep during that period. Let this period pass */
194-
TEST_ASSERT_TRUE(sleep_manager_can_deep_sleep_test_check());
195195

196196
// Wait for hardware serial buffers to flush. This is because serial transmissions generate
197197
// interrupts on some targets, which wake us from sleep.
198198
busy_wait_ms(SERIAL_FLUSH_TIME_MS);
199199

200200
/* Let's avoid the Lp ticker wrap-around case */
201201
wraparound_lp_protect();
202-
lp_wakeup_ts_raw = lp_ticker_read() + us_to_ticks(SLEEP_DURATION_US, lp_ticker_info->frequency);
202+
start_lp_time = lp_ticker_read();
203+
start_us_time = us_ticker_read();
204+
lp_wakeup_ts_raw = start_lp_time + us_to_ticks(SLEEP_DURATION_US, lp_ticker_info->frequency);
203205
lp_wakeup_ts = overflow_protect(lp_wakeup_ts_raw, lp_ticker_info->bits);
204206
lp_ticker_set_interrupt(lp_wakeup_ts);
205207

206-
us_ts1 = us_ticker_read();
207-
lp_ts1 = lp_ticker_read();
208+
/* Some targets may need an interrupt short time after LPTIM interrupt is
209+
* set and forbid deep_sleep during that period. Let this period pass */
210+
TEST_ASSERT_TRUE(sleep_manager_can_deep_sleep_test_check());
208211

209212
sleep_manager_sleep_auto();
210213

211-
us_ts2 = us_ticker_read();
212-
lp_ts2 = lp_ticker_read();
214+
end_us_time = us_ticker_read();
215+
end_lp_time = lp_ticker_read();
213216

214-
us_diff2 = (us_ts1 <= us_ts2) ? (us_ts2 - us_ts1) : (us_ticker_mask - us_ts1 + us_ts2 + 1);
215-
lp_diff2 = (lp_ts1 <= lp_ts2) ? (lp_ts2 - lp_ts1) : (lp_ticker_mask - lp_ts1 + lp_ts2 + 1);
217+
us_diff2 = (start_us_time <= end_us_time) ? (end_us_time - start_us_time) : (us_ticker_mask - start_us_time + end_us_time + 1);
218+
lp_diff2 = (start_lp_time <= end_lp_time) ? (end_lp_time - start_lp_time) : (lp_ticker_mask - start_lp_time + end_lp_time + 1);
216219

217220
// Deep sleep unlocked -- deep sleep mode used:
218221
// * us_ticker powered OFF,
@@ -225,6 +228,7 @@ void test_sleep_auto()
225228
const unsigned int deepsleep_tolerance_lp_ticks = us_to_ticks(DEEP_SLEEP_TOLERANCE_US, lp_ticker_info->frequency);
226229
const unsigned int deepsleep_tolerance_us_ticks = us_to_ticks(DEEP_SLEEP_TOLERANCE_US, us_ticker_info->frequency);
227230

231+
228232
// us ticker should not have incremented during deep sleep. It should be zero, plus some tolerance for the time to enter deep sleep.
229233
TEST_ASSERT_UINT64_WITHIN_MESSAGE(deepsleep_tolerance_us_ticks, 0, us_diff2, "us ticker sleep time incorrect - perhaps deep sleep mode was not used?");
230234
TEST_ASSERT_UINT64_WITHIN_MESSAGE(deepsleep_tolerance_lp_ticks, sleep_duration_lp_ticks, lp_diff2, "lp ticker sleep time incorrect");
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
This software component is provided to you as part of a software package and
2+
applicable license terms are in the Package_license file. If you received this
3+
software component outside of a package or without applicable license terms,
4+
the terms of the Apache-2.0 license shall apply.
5+
You may obtain a copy of the Apache-2.0 at:
6+
https://opensource.org/licenses/Apache-2.0
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/**
2+
******************************************************************************
3+
* @file partition_stm32u5xx.h
4+
* @author MCD Application Team
5+
* @brief CMSIS STM32U5xx Device Header File for Initial Setup for
6+
* Secure / Non-Secure Zones based on CMSIS CORE V5.4.0
7+
*
8+
* The file is included in system_stm32u5xx_s.c in secure application.
9+
* It includes the configuration section that allows to select the
10+
* STM32U5xx device partitioning file for system core secure attributes
11+
* and interrupt secure and non-secure assignment.
12+
*
13+
******************************************************************************
14+
* @attention
15+
*
16+
* Copyright (c) 2021 STMicroelectronics.
17+
* All rights reserved.
18+
*
19+
* This software is licensed under terms that can be found in the LICENSE file
20+
* in the root directory of this software component.
21+
* If no LICENSE file comes with this software, it is provided AS-IS.
22+
*
23+
******************************************************************************
24+
*/
25+
26+
/** @addtogroup CMSIS
27+
* @{
28+
*/
29+
30+
/** @addtogroup stm32u5xx
31+
* @{
32+
*/
33+
34+
#ifndef PARTITION_STM32U5XX_H
35+
#define PARTITION_STM32U5XX_H
36+
37+
#ifdef __cplusplus
38+
extern "C" {
39+
#endif /* __cplusplus */
40+
41+
/** @addtogroup Secure_configuration_section
42+
* @{
43+
*/
44+
45+
#if defined(STM32U575xx)
46+
#include "partition_stm32u575xx.h"
47+
#elif defined(STM32U585xx)
48+
#include "partition_stm32u585xx.h"
49+
#elif defined(STM32U595xx)
50+
#include "partition_stm32u595xx.h"
51+
#elif defined(STM32U5A5xx)
52+
#include "partition_stm32u5a5xx.h"
53+
#elif defined(STM32U599xx)
54+
#include "partition_stm32u599xx.h"
55+
#elif defined(STM32U5A9xx)
56+
#include "partition_stm32u5a9xx.h"
57+
#elif defined(STM32U535xx)
58+
#include "partition_stm32u535xx.h"
59+
#elif defined(STM32U545xx)
60+
#include "partition_stm32u545xx.h"
61+
#else
62+
#error "Please select first the target STM32U5xx device used in your application (in stm32u5xx.h file)"
63+
#endif
64+
65+
#ifdef __cplusplus
66+
}
67+
#endif /* __cplusplus */
68+
69+
#endif /* PARTITION_STM32U5XX_H */
70+
/**
71+
* @}
72+
*/
73+
74+
/**
75+
* @}
76+
*/
77+
78+
79+
80+

0 commit comments

Comments
 (0)