Skip to content

Commit c0e5c5d

Browse files
facchinmpennam
authored andcommitted
STM32H747: enable M4 on all supported boards
TODO: * check if RTC deinitialization impacts the M7 side * check if analogRead is strongly affetced by different HSE
1 parent 97156be commit c0e5c5d

File tree

10 files changed

+53
-434
lines changed

10 files changed

+53
-434
lines changed

boards.txt

+13-4
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ edge_control.bootloader.file=EDGE_CONTROL/bootloader.hex
5050
##############################################################
5151

5252
menu.split=Flash split
53+
menu.target_board=Target board
5354
menu.security=Security setting
5455

5556
envie_m7.name=Arduino Portenta H7 (M7 core)
@@ -145,7 +146,7 @@ envie_m7_thread_debug.build.board=PORTENTA_H7_M7
145146

146147
##############################################################
147148

148-
envie_m4.name=Arduino Portenta H7 (M4 core)
149+
envie_m4.name=STM32H747 M4 coprocessor
149150
envie_m4.build.core=arduino
150151
envie_m4.build.crossprefix=arm-none-eabi-
151152
envie_m4.build.compiler_path={runtime.tools.arm-none-eabi-gcc-7-2017q4.path}/bin/
@@ -154,6 +155,15 @@ envie_m4.menu.split.50_50=1MB M7 + 1MB M4
154155
envie_m4.menu.split.75_25=1.5MB M7 + 0.5MB M4
155156
envie_m4.menu.split.100_0=2MB M7 + M4 in SDRAM
156157

158+
envie_m4.menu.target_board.portenta=Portenta H7
159+
envie_m4.menu.target_board.portenta.compiler.mbed.arch.define=-DPORTENTA_H7_PINS
160+
envie_m4.menu.target_board.opta=Opta
161+
envie_m4.menu.target_board.opta.compiler.mbed.arch.define=-DOPTA_PINS
162+
envie_m4.menu.target_board.nvision=Nicla Vision
163+
envie_m4.menu.target_board.nvision.compiler.mbed.arch.define=-DNVISION_PINS
164+
envie_m4.menu.target_board.giga=Giga
165+
envie_m4.menu.target_board.giga.compiler.mbed.arch.define=-DGIGA_PINS
166+
157167
envie_m4.build.variant=PORTENTA_H7_M4
158168
envie_m4.build.mcu=cortex-m4
159169
envie_m4.build.fpu=-mfpu=fpv4-sp-d16
@@ -165,15 +175,14 @@ envie_m4.menu.split.100_0.build.extra_ldflags=-DCM4_BINARY_START=0x60000000 -DCM
165175
envie_m4.build.architecture=cortex-m4
166176
envie_m4.build.board=PORTENTA_H7_M4
167177
envie_m4.build.ldscript=linker_script.ld
168-
envie_m4.compiler.mbed.arch.define=
178+
#envie_m4.compiler.mbed.arch.define=
169179
envie_m4.compiler.mbed.defines={build.variant.path}/defines.txt
170180
envie_m4.compiler.mbed.ldflags={build.variant.path}/ldflags.txt
171181
envie_m4.compiler.mbed.cflags={build.variant.path}/cflags.txt
172182
envie_m4.compiler.mbed.cxxflags={build.variant.path}/cxxflags.txt
173183
envie_m4.compiler.mbed.includes={build.variant.path}/includes.txt
174184
envie_m4.compiler.mbed.extra_ldflags=-lstdc++ -lsupc++ -lm -lc -lgcc -lnosys
175185
envie_m4.compiler.mbed="{build.variant.path}/libs/libmbed.a"
176-
#envie_m4.compiler.mbed="{build.variant.path}/libs/libmbed.a" "{build.variant.path}/libs/libopenamp.a"
177186
envie_m4.vid.0=0x2341
178187
envie_m4.pid.0=0x005b
179188
envie_m4.build.vid=0x2341
@@ -206,7 +215,7 @@ envie_m4.bootloader.tool.default=openocd
206215
envie_m4.bootloader.config=-f target/stm32h7x_dual_bank.cfg
207216
envie_m4.bootloader.programmer=-f interface/stlink.cfg
208217
envie_m4.bootloader.extra_action.preflash=stm32h7x option_write 0 0x01c 0xb86aaf0
209-
envie_m4.bootloader.file=PORTENTA_H7/portentah7_bootloader_mbed_hs_v2.elf
218+
envie_m4.bootloader.file=
210219

211220
##############################################################
212221

mbed-os-to-arduino

+2-2
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ generate_flags () {
183183
for fl in c cxx ld; do
184184
jq -r '.flags | .[] | select(. != "-MMD")' ./BUILD/"$BOARDNAME"/GCC_ARM${PROFILE}/.profile-${fl} \
185185
> "$ARDUINOVARIANT"/${fl}flags.txt
186-
if [[ $ARDUINOVARIANT == *PORTENTA* ]]; then
186+
if [[ $ARDUINOVARIANT == *PORTENTA* || $ARDUINOVARIANT == *GIGA* || $ARDUINOVARIANT == *NICLA_VISION* || $ARDUINOVARIANT == *OPTA* ]]; then
187187
echo "Patching '-fno-exceptions' flag for $ARDUINOVARIANT/${fl}flags.txt"
188188
sed -i '/-fno-exceptions/d' "$ARDUINOVARIANT"/${fl}flags.txt
189189
set +e
@@ -200,7 +200,7 @@ generate_flags () {
200200
*(.pdm_buffer)\n \
201201
} > RAM_D3\n"
202202

203-
if [[ $ARDUINOVARIANT == *PORTENTA*M7* ]]; then
203+
if [[ $ARDUINOVARIANT == *PORTENTA*M7* || $ARDUINOVARIANT == *GIGA* || $ARDUINOVARIANT == *OPTA* ]]; then
204204
OPENAMP_SECTION="${OPENAMP_SECTION} \
205205
_dtcm_lma = __etext + SIZEOF(.data);\n \
206206
.dtcm : AT(_dtcm_lma) {\n \

variants/PORTENTA_H7_M4/conf/mbed_app.json

+5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
"platform.all-stats-enabled": true,
1111
"rtos.main-thread-stack-size": 32768,
1212
"cordio.max-connections": 5,
13+
"target.lse_available": 0,
14+
"target.device_has_remove": [
15+
"USBDEVICE",
16+
"EMAC"
17+
],
1318
"target.macros_add": [
1419
"BT_UART_NO_3M_SUPPORT",
1520
"NO_VTOR_RELOCATE",

variants/PORTENTA_H7_M4/defines.txt

+10-12
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,23 @@
22
-DARM_MATH_CM4
33
-DBT_UART_NO_3M_SUPPORT
44
-DCM4_BOOT_BY_APPLICATION
5+
-D__CMSIS_RTOS
56
-DCOMPONENT_4343W_FS=1
67
-DCOMPONENT_CYW43XXX=1
78
-DCOMPONENT_FLASHIAP=1
89
-DCOMPONENT_QSPIF=1
910
-DCOMPONENT_WHD=1
1011
-DCORE_CM4
12+
-D__CORTEX_M4
1113
-DCYW43XXX_UNBUFFERED_UART
1214
-DDEVICE_ANALOGIN=1
1315
-DDEVICE_ANALOGOUT=1
1416
-DDEVICE_CAN=1
1517
-DDEVICE_CRC=1
16-
-DDEVICE_EMAC=1
1718
-DDEVICE_FLASH=1
1819
-DDEVICE_I2C=1
19-
-DDEVICE_I2CSLAVE=1
2020
-DDEVICE_I2C_ASYNCH=1
21+
-DDEVICE_I2CSLAVE=1
2122
-DDEVICE_INTERRUPTIN=1
2223
-DDEVICE_LPTICKER=1
2324
-DDEVICE_PORTIN=1
@@ -31,20 +32,22 @@
3132
-DDEVICE_SERIAL_FC=1
3233
-DDEVICE_SLEEP=1
3334
-DDEVICE_SPI=1
34-
-DDEVICE_SPISLAVE=1
3535
-DDEVICE_SPI_ASYNCH=1
36+
-DDEVICE_SPISLAVE=1
3637
-DDEVICE_STDIO_MESSAGES=1
3738
-DDEVICE_TRNG=1
38-
-DDEVICE_USBDEVICE=1
3939
-DDEVICE_USTICKER=1
4040
-DDEVICE_WATCHDOG=1
4141
-DEXTRA_IDLE_STACK_REQUIRED
4242
-DFEATURE_BLE=1
43-
-DMBEDTLS_FS_IO
44-
-DMBEDTLS_SHA1_C
45-
-DMBED_BUILD_TIMESTAMP=1670863994.6037657
43+
-D__FPU_PRESENT=1
44+
-D__MBED__=1
45+
-DMBED_BUILD_TIMESTAMP=1674127650.1797109
46+
-D__MBED_CMSIS_RTOS_CM
4647
-DMBED_MPU_CUSTOM
4748
-DMBED_TICKLESS
49+
-DMBEDTLS_FS_IO
50+
-DMBEDTLS_SHA1_C
4851
-DMETAL_INTERNAL
4952
-DMETAL_MAX_DEVICE_REGIONS=2
5053
-DNO_ATOMIC_64_SUPPORT
@@ -76,11 +79,6 @@
7679
-DUSE_FULL_LL_DRIVER
7780
-DUSE_HAL_DRIVER
7881
-DVIRTIO_SLAVE_ONLY
79-
-D__CMSIS_RTOS
80-
-D__CORTEX_M4
81-
-D__FPU_PRESENT=1
82-
-D__MBED_CMSIS_RTOS_CM
83-
-D__MBED__=1
8482
-DMBED_NO_GLOBAL_USING_DIRECTIVE=1
8583
-DCORE_MAJOR=
8684
-DCORE_MINOR=

variants/PORTENTA_H7_M4/includes.txt

-17
Original file line numberDiff line numberDiff line change
@@ -148,23 +148,6 @@
148148
-iwithprefixbefore/mbed/connectivity/lorawan/lorastack/mac
149149
-iwithprefixbefore/mbed/connectivity/lorawan/lorastack/phy
150150
-iwithprefixbefore/mbed/connectivity/lorawan/system
151-
-iwithprefixbefore/mbed/connectivity/lwipstack
152-
-iwithprefixbefore/mbed/connectivity/lwipstack/include
153-
-iwithprefixbefore/mbed/connectivity/lwipstack/include/lwipstack
154-
-iwithprefixbefore/mbed/connectivity/lwipstack/lwip
155-
-iwithprefixbefore/mbed/connectivity/lwipstack/lwip-sys
156-
-iwithprefixbefore/mbed/connectivity/lwipstack/lwip-sys/arch
157-
-iwithprefixbefore/mbed/connectivity/lwipstack/lwip/src
158-
-iwithprefixbefore/mbed/connectivity/lwipstack/lwip/src/include
159-
-iwithprefixbefore/mbed/connectivity/lwipstack/lwip/src/include/compat
160-
-iwithprefixbefore/mbed/connectivity/lwipstack/lwip/src/include/compat/posix
161-
-iwithprefixbefore/mbed/connectivity/lwipstack/lwip/src/include/compat/posix/arpa
162-
-iwithprefixbefore/mbed/connectivity/lwipstack/lwip/src/include/compat/posix/net
163-
-iwithprefixbefore/mbed/connectivity/lwipstack/lwip/src/include/compat/posix/sys
164-
-iwithprefixbefore/mbed/connectivity/lwipstack/lwip/src/include/lwip
165-
-iwithprefixbefore/mbed/connectivity/lwipstack/lwip/src/include/lwip/priv
166-
-iwithprefixbefore/mbed/connectivity/lwipstack/lwip/src/include/lwip/prot
167-
-iwithprefixbefore/mbed/connectivity/lwipstack/lwip/src/include/netif
168151
-iwithprefixbefore/mbed/connectivity/mbedtls
169152
-iwithprefixbefore/mbed/connectivity/mbedtls/include
170153
-iwithprefixbefore/mbed/connectivity/mbedtls/include/mbedtls
-51.5 KB
Binary file not shown.
-119 KB
Binary file not shown.

variants/PORTENTA_H7_M4/mbed_config.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@
380380
#define MBED_CONF_TARGET_LPTICKER_LPTIM 1 // set by target:MCU_STM32H7
381381
#define MBED_CONF_TARGET_LPTICKER_LPTIM_CLOCK 1 // set by target:MCU_STM32
382382
#define MBED_CONF_TARGET_LPUART_CLOCK_SOURCE USE_LPUART_CLK_LSE|USE_LPUART_CLK_PCLK1|USE_LPUART_CLK_PCLK3 // set by target:MCU_STM32
383-
#define MBED_CONF_TARGET_LSE_AVAILABLE 1 // set by target:PORTENTA_H7
383+
#define MBED_CONF_TARGET_LSE_AVAILABLE 0 // set by application[*]
384384
#define MBED_CONF_TARGET_LSE_BYPASS 1 // set by target:PORTENTA_H7
385385
#define MBED_CONF_TARGET_LSE_DRIVE_LOAD_LEVEL RCC_LSEDRIVE_LOW // set by target:MCU_STM32H7
386386
#define MBED_CONF_TARGET_MPU_ROM_END 0x0fffffff // set by target:Target
+9-143
Original file line numberDiff line numberDiff line change
@@ -1,145 +1,11 @@
1-
#pragma once
2-
#include <macros.h>
3-
#include "PeripheralPins.h"
4-
5-
#ifndef __PINS_ARDUINO__
6-
#define __PINS_ARDUINO__
7-
8-
#ifdef __cplusplus
9-
extern "C" unsigned int PINCOUNT_fn();
10-
extern "C" bool isBetaBoard();
1+
#if defined(PORTENTA_H7_PINS)
2+
#include "../PORTENTA_H7_M7/pins_arduino.h"
3+
#elif defined(OPTA_PINS)
4+
#include "../OPTA/pins_arduino.h"
5+
#elif defined(NVISION_PINS)
6+
#include "../NICLA_VSION/pins_arduino.h"
7+
#elif defined(GIGA_PINS)
8+
#include "../GIGA/pins_arduino.h"
119
#endif
12-
#define PINS_COUNT (PINCOUNT_fn())
13-
#define NUM_DIGITAL_PINS (22u)
14-
#define NUM_ANALOG_INPUTS (7u)
15-
#define NUM_ANALOG_OUTPUTS (1u)
16-
17-
extern PinName digitalPinToPinName(pin_size_t P);
18-
19-
// LEDs
20-
// ----
21-
#define PIN_LED (24u)
22-
#define LED_BUILTIN PIN_LED
23-
#define LEDR (23u)
24-
#define LEDG (24u)
25-
#define LEDB (25u)
26-
27-
// Analog pins
28-
// -----------
29-
#define PIN_A0 (15u)
30-
#define PIN_A1 (16u)
31-
#define PIN_A2 (17u)
32-
#define PIN_A3 (18u)
33-
#define PIN_A4 (19u)
34-
#define PIN_A5 (20u)
35-
#define PIN_A6 (21u)
36-
#define PIN_A7 (22u)
37-
38-
static const uint8_t A0 = PIN_A0;
39-
static const uint8_t A1 = PIN_A1;
40-
static const uint8_t A2 = PIN_A2;
41-
static const uint8_t A3 = PIN_A3;
42-
static const uint8_t A4 = PIN_A4;
43-
static const uint8_t A5 = PIN_A5;
44-
static const uint8_t A6 = PIN_A6;
45-
static const uint8_t A7 = PIN_A7;
46-
#define ADC_RESOLUTION 12
47-
48-
// Digital pins
49-
// -----------
50-
#define D0 (0u)
51-
#define D1 (1u)
52-
#define D2 (2u)
53-
#define D3 (3u)
54-
#define D4 (4u)
55-
#define D5 (5u)
56-
#define D6 (6u)
57-
#define D7 (7u)
58-
#define D8 (8u)
59-
#define D9 (9u)
60-
#define D10 (10u)
61-
#define D11 (11u)
62-
#define D12 (12u)
63-
#define D13 (13u)
64-
#define D14 (14u)
65-
#define D15 (15u)
66-
#define D16 (u16)
67-
#define D17 (u17)
68-
#define D18 (u18)
69-
#define D19 (u19)
70-
#define D20 (u20)
71-
#define D21 (u21)
72-
73-
//DACs
74-
#define DAC A6
75-
76-
// Serial
77-
#define PIN_SERIAL_RX (13ul)
78-
#define PIN_SERIAL_TX (14ul)
79-
80-
// SPI
81-
#define PIN_SPI_MISO (10u)
82-
#define PIN_SPI_MOSI (8u)
83-
#define PIN_SPI_SCK (9u)
84-
#define PIN_SPI_SS (7u)
85-
86-
static const uint8_t SS = PIN_SPI_SS; // SPI Slave SS not used. Set here only for reference.
87-
static const uint8_t MOSI = PIN_SPI_MOSI;
88-
static const uint8_t MISO = PIN_SPI_MISO;
89-
static const uint8_t SCK = PIN_SPI_SCK;
90-
91-
// Wire
92-
#define PIN_WIRE_SDA (11u)
93-
#define PIN_WIRE_SCL (12u)
94-
95-
#define SerialHCI UART2
96-
97-
#define SERIAL_HOWMANY 2
98-
99-
#define SERIAL2_TX PA_15
100-
#define SERIAL2_RX PF_6
101-
#define SERIAL2_RTS PF_8
102-
#define SERIAL2_CTS PF_9
103-
104-
#define SERIAL1_TX (digitalPinToPinName(PIN_SERIAL_TX))
105-
#define SERIAL1_RX (digitalPinToPinName(PIN_SERIAL_RX))
106-
107-
//#define SERIAL_CDC 1
108-
#define HAS_UNIQUE_ISERIAL_DESCRIPTOR
109-
#define BOARD_VENDORID 0x2341
110-
#define BOARD_PRODUCTID 0x025b
111-
#define BOARD_NAME "Envie M4"
112-
113-
#define DFU_MAGIC_SERIAL_ONLY_RESET 0xb0
114-
115-
uint8_t getUniqueSerialNumber(uint8_t* name);
116-
void _ontouch1200bps_();
117-
118-
#define WIRE_HOWMANY 3
119-
120-
#define I2C_SDA (digitalPinToPinName(PIN_WIRE_SDA))
121-
#define I2C_SCL (digitalPinToPinName(PIN_WIRE_SCL))
122-
123-
#define I2C_SDA_INTERNAL (PB_7)
124-
#define I2C_SCL_INTERNAL (PB_6)
125-
#define I2C_SDA1 I2C_SDA_INTERNAL
126-
#define I2C_SCL1 I2C_SCL_INTERNAL
127-
#define I2C_SDA2 (PH_12)
128-
#define I2C_SCL2 (PH_11)
129-
130-
#define SPI_HOWMANY 1
131-
132-
#define SPI_MISO (digitalPinToPinName(PIN_SPI_MISO))
133-
#define SPI_MOSI (digitalPinToPinName(PIN_SPI_MOSI))
134-
#define SPI_SCK (digitalPinToPinName(PIN_SPI_SCK))
135-
136-
#define digitalPinToPort(P) (digitalPinToPinName(P)/16)
137-
138-
#define SERIAL_PORT_USBVIRTUAL Serial
139-
#define SERIAL_PORT_MONITOR Serial
140-
#define SERIAL_PORT_HARDWARE Serial
141-
#define SERIAL_PORT_HARDWARE_OPEN Serial1
142-
143-
#define CRYPTO_WIRE Wire1
14410

145-
#endif //__PINS_ARDUINO__
11+
#undef SERIAL_CDC

0 commit comments

Comments
 (0)