Skip to content

Commit 7177b02

Browse files
Merge branch 'arduino:main' into client-fixes
2 parents bee676f + 702daa0 commit 7177b02

File tree

15 files changed

+507
-165
lines changed

15 files changed

+507
-165
lines changed

boards.txt

+4
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,8 @@ nicla_sense.upload.wait_for_upload_port=true
443443
nicla_sense.upload.native_usb=true
444444
nicla_sense.upload.maximum_size=527616
445445
nicla_sense.upload.maximum_data_size=64288
446+
nicla_sense.programmer.protocol=cmsis-dap
447+
nicla_sense.programmer.transport_script={runtime.platform.path}/debugger/select_swd.cfg
446448

447449
nicla_sense.bootloader.tool=openocd
448450
nicla_sense.bootloader.tool.default=openocd
@@ -496,6 +498,8 @@ nicla_voice.upload.wait_for_upload_port=true
496498
nicla_voice.upload.native_usb=true
497499
nicla_voice.upload.maximum_size=527616
498500
nicla_voice.upload.maximum_data_size=64288
501+
nicla_voice.programmer.protocol=cmsis-dap
502+
nicla_voice.programmer.transport_script={runtime.platform.path}/debugger/select_swd.cfg
499503

500504
nicla_voice.bootloader.tool=openocd
501505
nicla_voice.bootloader.tool.default=openocd

libraries/Ethernet/src/Ethernet.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,13 @@ int arduino::EthernetClass::begin(uint8_t *mac, IPAddress ip, IPAddress dns, IPA
5555

5656
eth_if->set_dhcp(false);
5757
eth_if->set_network(_ip, _netmask, _gateway);
58+
59+
auto ret = _begin(mac, timeout, responseTimeout);
60+
5861
char if_name[5];
5962
eth_if->get_interface_name(if_name);
6063
eth_if->add_dns_server(_dnsServer1, if_name);
6164

62-
auto ret = _begin(mac, timeout, responseTimeout);
6365
return ret;
6466
}
6567

libraries/PDM/src/STM32H747_dfsdm/audio.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,10 @@ int py_audio_init(size_t channels, uint32_t frequency)
391391

392392
void py_audio_gain_set(int gain_db)
393393
{
394-
attenuation = 8 - gain_db;
394+
attenuation = 8 - (gain_db / 3);
395+
if (attenuation < 0) {
396+
attenuation = 0;
397+
}
395398
}
396399

397400
void py_audio_deinit()

libraries/RPC/LICENSE

+373
Large diffs are not rendered by default.

libraries/RPC/src/RPC.cpp

+31
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Copyright (c) 2024 Arduino SA
2+
// SPDX-License-Identifier: MPL-2.0
13
#include "RPC.h"
24

35
#define ENDPOINT_ID_RAW 0
@@ -161,6 +163,35 @@ int RPCClass::begin() {
161163
#endif
162164

163165
#ifdef CORE_CM4
166+
#if (CM4_BINARY_START >= 0x60000000) && (CM4_BINARY_START < 0xe0000000)
167+
class M4Init {
168+
public:
169+
M4Init() {
170+
// If the Cortex-M4 core is booting from SDRAM, the memory region must be
171+
// configured as Strongly Ordered. Note that the Cortex-M4 core does not
172+
// seem to implement speculative prefetching, so there is no need to protect
173+
// the whole region from speculative prefetching with a second MPU region.
174+
HAL_MPU_Disable();
175+
MPU_Region_InitTypeDef MPU_InitStruct;
176+
MPU_InitStruct.Number = MPU_REGION_NUMBER1;
177+
MPU_InitStruct.Enable = MPU_REGION_ENABLE;
178+
MPU_InitStruct.BaseAddress = CM4_BINARY_START;
179+
MPU_InitStruct.Size = MPU_REGION_SIZE_1MB;
180+
MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;
181+
MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
182+
MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE;
183+
MPU_InitStruct.IsShareable = MPU_ACCESS_NOT_SHAREABLE;
184+
MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;
185+
MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;
186+
MPU_InitStruct.SubRegionDisable = 0x00;
187+
HAL_MPU_ConfigRegion(&MPU_InitStruct);
188+
HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT);
189+
}
190+
};
191+
192+
M4Init __m4init __attribute__ ((init_priority (101)));
193+
#endif
194+
164195
int RPCClass::begin() {
165196
eventThread = new rtos::Thread(osPriorityHigh, 16*1024, nullptr, "rpc_evt");
166197
eventThread->start(&eventHandler);

libraries/RPC/src/RPC.h

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Copyright (c) 2024 Arduino SA
2+
// SPDX-License-Identifier: MPL-2.0
13
#ifdef __cplusplus
24

35
#ifndef __ARDUINO_RPC_IMPLEMENTATION__

libraries/RPC/src/RPC_client.h

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Copyright (c) 2024 Arduino SA
2+
// SPDX-License-Identifier: MPL-2.0
13
#include "Arduino.h"
24
#include "mbed.h"
35
#include "rpc/dispatcher.h"

libraries/RPC/src/SerialRPC.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Copyright (c) 2024 Arduino SA
2+
// SPDX-License-Identifier: MPL-2.0
13
#include "SerialRPC.h"
24
#include "RPC.h"
35

@@ -22,4 +24,4 @@ arduino::SerialRPCClass::operator bool() {
2224
return RPC;
2325
}
2426

25-
arduino::SerialRPCClass SerialRPC;
27+
arduino::SerialRPCClass SerialRPC;

libraries/RPC/src/SerialRPC.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Copyright (c) 2024 Arduino SA
2+
// SPDX-License-Identifier: MPL-2.0
13
#ifndef __SERIAL_RPC__
24
#define __SERIAL_RPC__
35

@@ -69,4 +71,4 @@ class SerialRPCClass : public Stream {
6971

7072
extern arduino::SerialRPCClass SerialRPC;
7173

72-
#endif
74+
#endif

libraries/WiFi/src/WiFi.cpp

+6-4
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,18 @@ int arduino::WiFiClass::begin(const char* ssid, const char* passphrase, wl_enc_t
6666
wifi_if->set_dhcp(!_useStaticIP);
6767
if (_useStaticIP) {
6868
wifi_if->set_network(_ip, _netmask, _gateway);
69-
char if_name[5];
70-
wifi_if->get_interface_name(if_name);
71-
wifi_if->add_dns_server(_dnsServer2, if_name);
72-
wifi_if->add_dns_server(_dnsServer1, if_name); // pushes dnsServer2 at index 1
7369
}
7470

7571
nsapi_error_t result = wifi_if->connect(ssid, passphrase, _security);
7672

7773
if(result == NSAPI_ERROR_IS_CONNECTED) {
7874
wifi_if->disconnect();
75+
} else
76+
if (_useStaticIP) {
77+
char if_name[5];
78+
wifi_if->get_interface_name(if_name);
79+
wifi_if->add_dns_server(_dnsServer2, if_name);
80+
wifi_if->add_dns_server(_dnsServer1, if_name); // pushes dnsServer2 at index 1
7981
}
8082
_currentNetworkStatus = (result == NSAPI_ERROR_OK && setSSID(ssid)) ? WL_CONNECTED : WL_CONNECT_FAILED;
8183

libraries/openamp_arduino/src/openamp_conf.h

+3
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@ extern int __OPENAMP_region_end__[];
151151
#define SHM_START_ADDRESS ((metal_phys_addr_t)__OPENAMP_region_start__)
152152
#define SHM_SIZE (size_t)((void *)__OPENAMP_region_end__ - (void *) __OPENAMP_region_start__)
153153

154+
#define SHM_RSC_SIZE (1024)
155+
#define SHM_RSC_ADDR ((void *)__OPENAMP_region_start__ - SHM_RSC_SIZE)
156+
154157
#endif
155158

156159
#define VRING_RX_ADDRESS SHM_START_ADDRESS

libraries/openamp_arduino/src/rsc_table.c

+44-123
Original file line numberDiff line numberDiff line change
@@ -21,137 +21,58 @@
2121
******************************************************************************
2222
*/
2323

24-
/** @addtogroup RSC_TABLE
25-
* @{
26-
*/
27-
28-
/** @addtogroup resource_table
29-
* @{
30-
*/
31-
32-
/** @addtogroup resource_table_Private_Includes
33-
* @{
34-
*/
35-
36-
3724
#if defined(__ICCARM__) || defined (__CC_ARM)
3825
#include <stddef.h> /* needed for offsetof definition*/
3926
#endif
4027
#include "rsc_table.h"
4128
#include "openamp/open_amp.h"
4229

43-
/**
44-
* @}
45-
*/
46-
47-
/** @addtogroup resource_table_Private_TypesDefinitions
48-
* @{
49-
*/
50-
51-
/**
52-
* @}
53-
*/
54-
55-
/** @addtogroup resource_table_Private_Defines
56-
* @{
57-
*/
58-
59-
/* Place resource table in special ELF section */
60-
#if defined(__GNUC__)
61-
#define __section_t(S) __attribute__((__section__(#S)))
62-
#define __resource __section_t(.resource_table)
63-
#endif
64-
65-
#define RPMSG_IPU_C0_FEATURES 1
66-
#define VRING_COUNT 2
67-
68-
/* VirtIO rpmsg device id */
69-
#define VIRTIO_ID_RPMSG_ 7
70-
7130
#if defined (__LOG_TRACE_IO_)
7231
extern char system_log_buf[];
7332
#endif
7433

75-
#if defined(__GNUC__)
76-
#if !defined (__CC_ARM)
77-
/* Since GCC is not initializing the resource_table at startup, it is declared as volatile to avoid compiler optimization
78-
* for the CM4 (see resource_table_init() below)
79-
*/
80-
volatile struct shared_resource_table __resource __attribute__((used)) resource_table;
81-
#else
82-
struct shared_resource_table __resource __attribute__((used)) resource_table = {
83-
#endif
84-
#elif defined(__ICCARM__)
85-
__root struct shared_resource_table resource_table @ ".resource_table" = {
86-
#endif
87-
88-
#if defined(__ICCARM__) || defined (__CC_ARM)
89-
.version = 1,
90-
.num = 2,
91-
.reserved = {0, 0},
92-
.offset = {
93-
offsetof(struct shared_resource_table, vdev),
94-
offsetof(struct shared_resource_table, cm_trace),
95-
},
96-
97-
/* Virtio device entry */
98-
.vdev= {
99-
RSC_VDEV, VIRTIO_ID_RPMSG_, 0, RPMSG_IPU_C0_FEATURES, 0, 0, 0,
100-
VRING_COUNT, {0, 0},
101-
},
102-
103-
/* Vring rsc entry - part of vdev rsc entry */
104-
.vring0 = {VRING_TX_ADDRESS, VRING_ALIGNMENT, VRING_NUM_BUFFS, VRING0_ID, 0},
105-
.vring1 = {VRING_RX_ADDRESS, VRING_ALIGNMENT, VRING_NUM_BUFFS, VRING1_ID, 0},
106-
107-
#if defined (__LOG_TRACE_IO_)
108-
.cm_trace = {
109-
RSC_TRACE,
110-
(uint32_t)system_log_buf, SYSTEM_TRACE_BUF_SZ, 0, "cm4_log",
111-
},
112-
#endif
113-
} ;
114-
#endif
115-
116-
void resource_table_init(int RPMsgRole, void **table_ptr, int *length)
117-
{
118-
119-
#if defined (__GNUC__) && ! defined (__CC_ARM)
120-
#ifdef CORE_CM7
121-
/*
122-
* Currently the GCC linker doesn't initialize the resource_table global variable at startup
123-
* it is done here by the CM7 application.
124-
*/
125-
memset(&resource_table, '\0', sizeof(struct shared_resource_table));
126-
resource_table.num = 1;
127-
resource_table.version = 1;
128-
resource_table.offset[0] = offsetof(struct shared_resource_table, vdev);
129-
130-
resource_table.vring0.da = VRING_TX_ADDRESS;
131-
resource_table.vring0.align = VRING_ALIGNMENT;
132-
resource_table.vring0.num = VRING_NUM_BUFFS;
133-
resource_table.vring0.notifyid = VRING0_ID;
134-
135-
resource_table.vring1.da = VRING_RX_ADDRESS;
136-
resource_table.vring1.align = VRING_ALIGNMENT;
137-
resource_table.vring1.num = VRING_NUM_BUFFS;
138-
resource_table.vring1.notifyid = VRING1_ID;
139-
140-
141-
resource_table.vdev.type = RSC_VDEV;
142-
resource_table.vdev.id = VIRTIO_ID_RPMSG_;
143-
resource_table.vdev.num_of_vrings=VRING_COUNT;
144-
resource_table.vdev.dfeatures = RPMSG_IPU_C0_FEATURES;
145-
#else
146-
/* For CM4 let's wait until the resource_table is correctly initialized */
147-
while(resource_table.vring1.da != VRING_RX_ADDRESS)
148-
{
149-
150-
}
151-
#endif
152-
#endif
153-
154-
(void)RPMsgRole;
155-
*length = sizeof(resource_table);
156-
*table_ptr = &resource_table;
34+
void resource_table_init(int RPMsgRole, void **table_ptr, int *length) {
35+
(void)RPMsgRole;
36+
volatile struct shared_resource_table *resource_table = SHM_RSC_ADDR;
37+
38+
#ifdef CORE_CM7
39+
memset(resource_table, 0, SHM_RSC_SIZE);
40+
resource_table->num = 1;
41+
resource_table->version = 1;
42+
resource_table->offset[0] = offsetof(struct shared_resource_table, vdev);
43+
#if defined (__LOG_TRACE_IO_)
44+
resource_table->offset[1] = offsetof(struct shared_resource_table, cm_trace);
45+
#endif
46+
47+
resource_table->vring0.da = VRING_TX_ADDRESS;
48+
resource_table->vring0.align = VRING_ALIGNMENT;
49+
resource_table->vring0.num = VRING_NUM_BUFFS;
50+
resource_table->vring0.notifyid = VRING0_ID;
51+
52+
resource_table->vring1.da = VRING_RX_ADDRESS;
53+
resource_table->vring1.align = VRING_ALIGNMENT;
54+
resource_table->vring1.num = VRING_NUM_BUFFS;
55+
resource_table->vring1.notifyid = VRING1_ID;
56+
57+
#if defined (__LOG_TRACE_IO_)
58+
resource_table->cm_trace.type;
59+
resource_table->cm_trace.da;
60+
resource_table->cm_trace.len;
61+
resource_table->cm_trace.reserved = 0;
62+
resource_table->cm_trace.name = (uint8_t[]){"cm_trace"};
63+
#endif
64+
65+
resource_table->vdev.type = RSC_VDEV;
66+
resource_table->vdev.id = VIRTIO_ID_RPMSG;
67+
resource_table->vdev.num_of_vrings=VRING_COUNT;
68+
resource_table->vdev.dfeatures = (1 << VIRTIO_RPMSG_F_NS);
69+
#else
70+
// For CM4, wait until the resource_table is initialized by the host
71+
while(resource_table->vring1.da != VRING_RX_ADDRESS) {
72+
73+
}
74+
#endif
75+
76+
*length = SHM_RSC_SIZE;
77+
*table_ptr = resource_table;
15778
}

0 commit comments

Comments
 (0)