Skip to content

Commit 7554303

Browse files
authored
Merge branch 'arduino:master' into master
2 parents 8736ab0 + bbc6284 commit 7554303

File tree

18 files changed

+146
-50
lines changed

18 files changed

+146
-50
lines changed

cores/arduino/mbed/targets/TARGET_RASPBERRYPI/TARGET_RP2040/pico-sdk/rp2_common/hardware_rtc/include/hardware/rtc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ typedef void (*rtc_callback_t)(void);
3434
/*! \brief Initialise the RTC system
3535
* \ingroup hardware_rtc
3636
*/
37-
void rtc_init(void);
37+
void _rtc_init(void);
3838

3939
/*! \brief Set the RTC to the specified time
4040
* \ingroup hardware_rtc

libraries/Wire/Wire.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ void arduino::MbedI2C::end() {
4545
}
4646
#ifdef DEVICE_I2CSLAVE
4747
if (slave != NULL) {
48+
slave_th.terminate();
49+
slave_th.free_stack();
4850
delete slave;
4951
}
5052
#endif

package_full.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#Get version from git(hub) tag
2-
export VERSION="2.5.2"
2+
export VERSION="2.6.1"
33

44
FLAVOURS=`ls *.variables`
55

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
From 6303e807ab476b4e111e1eb7f6a7fd789d1650f3 Mon Sep 17 00:00:00 2001
2+
From: Martino Facchin <m.facchin@arduino.cc>
3+
Date: Mon, 15 Nov 2021 16:47:42 +0100
4+
Subject: [PATCH] RP2040: backport p2040_usb_device_enumeration fix
5+
6+
---
7+
.../rp2040_usb_device_enumeration.c | 42 +++++++++++++++----
8+
1 file changed, 33 insertions(+), 9 deletions(-)
9+
10+
diff --git a/targets/TARGET_RASPBERRYPI/TARGET_RP2040/pico-sdk/rp2_common/pico_fix/rp2040_usb_device_enumeration/rp2040_usb_device_enumeration.c b/targets/TARGET_RASPBERRYPI/TARGET_RP2040/pico-sdk/rp2_common/pico_fix/rp2040_usb_device_enumeration/rp2040_usb_device_enumeration.c
11+
index 8319e36cb7..91583205bb 100644
12+
--- a/targets/TARGET_RASPBERRYPI/TARGET_RP2040/pico-sdk/rp2_common/pico_fix/rp2040_usb_device_enumeration/rp2040_usb_device_enumeration.c
13+
+++ b/targets/TARGET_RASPBERRYPI/TARGET_RP2040/pico-sdk/rp2_common/pico_fix/rp2040_usb_device_enumeration/rp2040_usb_device_enumeration.c
14+
@@ -8,6 +8,8 @@
15+
#include "pico/time.h"
16+
#include "hardware/structs/usb.h"
17+
#include "hardware/gpio.h"
18+
+#include "hardware/structs/iobank0.h"
19+
+#include "hardware/structs/padsbank0.h"
20+
#include "pico/fix/rp2040_usb_device_enumeration.h"
21+
22+
#define LS_SE0 0b00
23+
@@ -36,7 +38,7 @@ static inline uint8_t hw_line_state(void) {
24+
return (usb_hw->sie_status & USB_SIE_STATUS_LINE_STATE_BITS) >> USB_SIE_STATUS_LINE_STATE_LSB;
25+
}
26+
27+
-int64_t hw_enumeration_fix_wait_se0_callback(alarm_id_t id, void *user_data) {
28+
+int64_t hw_enumeration_fix_wait_se0_callback(__unused alarm_id_t id, __unused void *user_data) {
29+
if (hw_line_state() == LS_SE0) {
30+
// Come back in 1ms and check again
31+
return 1000;
32+
@@ -69,25 +71,42 @@ static void hw_enumeration_fix_wait_se0(void) {
33+
hw_enumeration_fix_busy_wait_se0();
34+
}
35+
36+
-int64_t hw_enumeration_fix_force_ls_j_done(alarm_id_t id, void *user_data) {
37+
+int64_t hw_enumeration_fix_force_ls_j_done(__unused alarm_id_t id, __unused void *user_data) {
38+
hw_enumeration_fix_finish();
39+
return 0;
40+
}
41+
42+
+static uint32_t gpio_ctrl_prev = 0;
43+
+static uint32_t pad_ctrl_prev = 0;
44+
+static const uint dp = 15;
45+
+static const uint dm = 16;
46+
+
47+
static void hw_enumeration_fix_force_ls_j(void) {
48+
- // Force LS_J
49+
- const uint dp = 15;
50+
- //const uint dm = 16;
51+
- gpio_set_function(dp, 8);
52+
- // TODO: assert dm is not funcseld to usb
53+
+ // DM must be 0 for this to work. This is true if it is selected
54+
+ // to any other function. fn 8 on this pin is only for debug so shouldn't
55+
+ // be selected
56+
+ if (gpio_get_function(dm) == 8) {
57+
+ panic("Not expecting DM to be function 8");
58+
+ }
59+
+
60+
+ // Before changing any pin state, take a copy of the current gpio control register
61+
+ gpio_ctrl_prev = iobank0_hw->io[dp].ctrl;
62+
+ // Also take a copy of the pads register
63+
+ pad_ctrl_prev = padsbank0_hw->io[dp];
64+
+
65+
+ // Enable bus keep and force pin to tristate, so USB DP muxing doesn't affect
66+
+ // pin state
67+
+ gpio_set_pulls(dp, true, true);
68+
+ gpio_set_oeover(dp, GPIO_OVERRIDE_LOW);
69+
+ // Select function 8 (USB debug muxing) without disturbing other controls
70+
+ hw_write_masked(&iobank0_hw->io[dp].ctrl,
71+
+ 8 << IO_BANK0_GPIO15_CTRL_FUNCSEL_LSB, IO_BANK0_GPIO15_CTRL_FUNCSEL_BITS);
72+
73+
// J state is a differential 1 for a full speed device so
74+
// DP = 1 and DM = 0. Don't actually need to set DM low as it
75+
// is already gated assuming it isn't funcseld.
76+
gpio_set_inover(dp, GPIO_OVERRIDE_HIGH);
77+
78+
- // TODO: What to do about existing DP state here?
79+
-
80+
// Force PHY pull up to stay before switching away from the phy
81+
hw_set_alias(usb_hw)->phy_direct = USB_USBPHY_DIRECT_DP_PULLUP_EN_BITS;
82+
hw_set_alias(usb_hw)->phy_direct_override = USB_USBPHY_DIRECT_OVERRIDE_DP_PULLUP_EN_OVERRIDE_EN_BITS;
83+
@@ -118,4 +137,9 @@ static void hw_enumeration_fix_finish(void) {
84+
85+
// Get rid of DP pullup override
86+
hw_clear_alias(usb_hw)->phy_direct_override = USB_USBPHY_DIRECT_OVERRIDE_DP_PULLUP_EN_OVERRIDE_EN_BITS;
87+
+
88+
+ // Finally, restore the gpio ctrl value back to GPIO15
89+
+ iobank0_hw->io[dp].ctrl = gpio_ctrl_prev;
90+
+ // Restore the pad ctrl value
91+
+ padsbank0_hw->io[dp] = pad_ctrl_prev;
92+
}
93+
--
94+
2.33.1
95+

patches/0045-RP2040-restore-GPIO15-functionality-after-USB_DEVICE.patch

Lines changed: 0 additions & 39 deletions
This file was deleted.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
From 8ccd98f8d597f315f33fbe943f5a8c5f8d0e28d1 Mon Sep 17 00:00:00 2001
2+
From: Martino Facchin <m.facchin@arduino.cc>
3+
Date: Mon, 6 Dec 2021 12:02:28 +0100
4+
Subject: [PATCH] RP2040: correct system clock frequency
5+
6+
Fixes https://github.com/arduino/ArduinoCore-mbed/issues/271
7+
---
8+
.../TARGET_RP2040/TARGET_NANO_RP2040_CONNECT/board.c | 2 +-
9+
.../TARGET_RP2040/TARGET_RASPBERRY_PI_PICO/board.c | 2 +-
10+
2 files changed, 2 insertions(+), 2 deletions(-)
11+
12+
diff --git a/targets/TARGET_RASPBERRYPI/TARGET_RP2040/TARGET_NANO_RP2040_CONNECT/board.c b/targets/TARGET_RASPBERRYPI/TARGET_RP2040/TARGET_NANO_RP2040_CONNECT/board.c
13+
index 1f775638f9..b9ad1319af 100644
14+
--- a/targets/TARGET_RASPBERRYPI/TARGET_RP2040/TARGET_NANO_RP2040_CONNECT/board.c
15+
+++ b/targets/TARGET_RASPBERRYPI/TARGET_RP2040/TARGET_NANO_RP2040_CONNECT/board.c
16+
@@ -1,3 +1,3 @@
17+
#include "PinNames.h"
18+
19+
-uint32_t SystemCoreClock = 120000000;
20+
\ No newline at end of file
21+
+uint32_t SystemCoreClock = 125000000;
22+
\ No newline at end of file
23+
diff --git a/targets/TARGET_RASPBERRYPI/TARGET_RP2040/TARGET_RASPBERRY_PI_PICO/board.c b/targets/TARGET_RASPBERRYPI/TARGET_RP2040/TARGET_RASPBERRY_PI_PICO/board.c
24+
index 1f775638f9..b9ad1319af 100644
25+
--- a/targets/TARGET_RASPBERRYPI/TARGET_RP2040/TARGET_RASPBERRY_PI_PICO/board.c
26+
+++ b/targets/TARGET_RASPBERRYPI/TARGET_RP2040/TARGET_RASPBERRY_PI_PICO/board.c
27+
@@ -1,3 +1,3 @@
28+
#include "PinNames.h"
29+
30+
-uint32_t SystemCoreClock = 120000000;
31+
\ No newline at end of file
32+
+uint32_t SystemCoreClock = 125000000;
33+
\ No newline at end of file
34+
--
35+
2.34.1
36+

platform.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DARDUIN
8282
recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}"
8383

8484
## Preprocess linker script
85-
recipe.hooks.linking.prelink.1.pattern="{compiler.path}{compiler.c.elf.cmd}" -E -P -x c {build.extra_ldflags} "{build.variant.path}/{build.ldscript}" -o {build.path}/{build.ldscript}
85+
recipe.hooks.linking.prelink.1.pattern="{compiler.path}{compiler.c.elf.cmd}" -E -P -x c {build.extra_ldflags} "{build.variant.path}/{build.ldscript}" -o "{build.path}/{build.ldscript}"
8686

8787
## Combine gc-sections, archives, and objects
8888
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} {build.extra_flags} {build.extra_ldflags} "@{compiler.mbed.ldflags}" "-T{build.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nosys.specs {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} -Wl,--whole-archive "{build.path}/{archive_file}" {compiler.mbed} -Wl,--no-whole-archive -Wl,--start-group {compiler.mbed.extra_ldflags} {compiler.libraries.ldflags} -Wl,--end-group
@@ -103,7 +103,7 @@ recipe.objcopy.zip.pattern="{tools.nrfutil.cmd}" dfu genpkg --dev-type 0x0052 --
103103
## Compute size
104104
recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf"
105105
recipe.size.regex.data=^(?:\.data|\.bss)\s+([0-9]+).*
106-
recipe.size.regex=^(?:\.data|\.text)\s+([0-9]+).*
106+
recipe.size.regex=^(?:\.data|\.text)\S*?\s+([0-9]+).*
107107

108108
## Save hex
109109
recipe.output.tmp_file={build.project_name}.bin

variants/ARDUINO_NANO33BLE/defines.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
-DFEATURE_STORAGE=1
3434
-D__FPU_PRESENT=1
3535
-D__MBED__=1
36-
-DMBED_BUILD_TIMESTAMP=1632403401.7148244
36+
-DMBED_BUILD_TIMESTAMP=1637232276.1675022
3737
-D__MBED_CMSIS_RTOS_CM
3838
-DMBED_MPU_CUSTOM
3939
-DMBED_TICKLESS

variants/EDGE_CONTROL/defines.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
-DFEATURE_STORAGE=1
3939
-D__FPU_PRESENT=1
4040
-D__MBED__=1
41-
-DMBED_BUILD_TIMESTAMP=1632403591.1261852
41+
-DMBED_BUILD_TIMESTAMP=1637232401.5872405
4242
-D__MBED_CMSIS_RTOS_CM
4343
-DMBED_MPU_CUSTOM
4444
-DMBED_TICKLESS

variants/NANO_RP2040_CONNECT/defines.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@
1212
-DDEVICE_PORT_OUT=1
1313
-DDEVICE_PWMOUT=1
1414
-DDEVICE_RESET_REASON=1
15+
-DDEVICE_RTC=1
1516
-DDEVICE_SERIAL=1
1617
-DDEVICE_SERIAL_FC=1
1718
-DDEVICE_SPI=1
1819
-DDEVICE_USBDEVICE=1
1920
-DDEVICE_USTICKER=1
2021
-DDEVICE_WATCHDOG=1
2122
-D__MBED__=1
22-
-DMBED_BUILD_TIMESTAMP=1632403376.6567667
23+
-DMBED_BUILD_TIMESTAMP=1637232257.481197
2324
-D__MBED_CMSIS_RTOS_CM
2425
-DMBED_MPU_CUSTOM
2526
-DPICO_FLASH_SIZE_BYTES=16*1024*1024
2.54 KB
Binary file not shown.

variants/NICLA/defines.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
-DFEATURE_BLE=1
3333
-D__FPU_PRESENT=1
3434
-D__MBED__=1
35-
-DMBED_BUILD_TIMESTAMP=1632403632.3026016
35+
-DMBED_BUILD_TIMESTAMP=1637232432.6955237
3636
-D__MBED_CMSIS_RTOS_CM
3737
-DMBED_MPU_CUSTOM
3838
-DMBED_TICKLESS

variants/PORTENTA_H7_M4/defines.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
-DFEATURE_BLE=1
4444
-D__FPU_PRESENT=1
4545
-D__MBED__=1
46-
-DMBED_BUILD_TIMESTAMP=1632403527.8572242
46+
-DMBED_BUILD_TIMESTAMP=1637232354.9239724
4747
-D__MBED_CMSIS_RTOS_CM
4848
-DMBED_MPU_CUSTOM
4949
-DMBED_TICKLESS
0 Bytes
Binary file not shown.

variants/PORTENTA_H7_M7/defines.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
-DFEATURE_BLE=1
4545
-D__FPU_PRESENT=1
4646
-D__MBED__=1
47-
-DMBED_BUILD_TIMESTAMP=1632403464.1729383
47+
-DMBED_BUILD_TIMESTAMP=1637232307.3555584
4848
-D__MBED_CMSIS_RTOS_CM
4949
-DMBED_TICKLESS
5050
-DMBEDTLS_FS_IO
0 Bytes
Binary file not shown.

variants/RASPBERRY_PI_PICO/defines.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@
1212
-DDEVICE_PORT_OUT=1
1313
-DDEVICE_PWMOUT=1
1414
-DDEVICE_RESET_REASON=1
15+
-DDEVICE_RTC=1
1516
-DDEVICE_SERIAL=1
1617
-DDEVICE_SERIAL_FC=1
1718
-DDEVICE_SPI=1
1819
-DDEVICE_USBDEVICE=1
1920
-DDEVICE_USTICKER=1
2021
-DDEVICE_WATCHDOG=1
2122
-D__MBED__=1
22-
-DMBED_BUILD_TIMESTAMP=1632403438.5330071
23+
-DMBED_BUILD_TIMESTAMP=1637232303.3760371
2324
-D__MBED_CMSIS_RTOS_CM
2425
-DMBED_MPU_CUSTOM
2526
-DPICO_NO_BINARY_INFO=1
2.54 KB
Binary file not shown.

0 commit comments

Comments
 (0)