Skip to content

Commit 87ac07c

Browse files
committed
Patches: add fixes for RP2040
1 parent dee2eb0 commit 87ac07c

3 files changed

+134
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
From 9e746195369ab17fba04be4af8b3cccb94d66987 Mon Sep 17 00:00:00 2001
2+
From: Martino Facchin <[email protected]>
3+
Date: Fri, 7 May 2021 16:08:53 +0200
4+
Subject: [PATCH 75/77] RP2040: USBPhy: implement stall() and unstall()
5+
6+
---
7+
.../TARGET_RP2040/USBPhy_RP2040.cpp | 12 +++++++++---
8+
1 file changed, 9 insertions(+), 3 deletions(-)
9+
10+
diff --git a/targets/TARGET_RASPBERRYPI/TARGET_RP2040/USBPhy_RP2040.cpp b/targets/TARGET_RASPBERRYPI/TARGET_RP2040/USBPhy_RP2040.cpp
11+
index fbece56a1d..9beb225a30 100644
12+
--- a/targets/TARGET_RASPBERRYPI/TARGET_RP2040/USBPhy_RP2040.cpp
13+
+++ b/targets/TARGET_RASPBERRYPI/TARGET_RP2040/USBPhy_RP2040.cpp
14+
@@ -111,7 +111,11 @@ void USBPhyHw::connect()
15+
// and when a setup packet is received
16+
usb_hw->inte = USB_INTS_BUFF_STATUS_BITS |
17+
USB_INTS_BUS_RESET_BITS |
18+
- USB_INTS_SETUP_REQ_BITS;
19+
+ USB_INTS_SETUP_REQ_BITS |
20+
+ USB_INTS_HOST_CONN_DIS_BITS |
21+
+ USB_INTS_HOST_RESUME_BITS |
22+
+ USB_INTS_ERROR_RX_OVERFLOW_BITS |
23+
+ USB_INTS_STALL_BITS;
24+
25+
// Present full speed device by enabling pull up on DP
26+
usb_hw_set->sie_ctrl = USB_SIE_CTRL_PULLUP_EN_BITS;
27+
@@ -301,12 +305,14 @@ void USBPhyHw::endpoint_remove(usb_ep_t endpoint)
28+
29+
void USBPhyHw::endpoint_stall(usb_ep_t endpoint)
30+
{
31+
-
32+
+ int ep_num = endpoint & 0x7f;
33+
+ usb_dpram->ep_buf_ctrl[ep_num].out |= USB_BUF_CTRL_STALL;
34+
}
35+
36+
void USBPhyHw::endpoint_unstall(usb_ep_t endpoint)
37+
{
38+
-
39+
+ int ep_num = endpoint & 0x7f;
40+
+ usb_dpram->ep_buf_ctrl[ep_num].out &= ~USB_BUF_CTRL_STALL;
41+
}
42+
43+
bool USBPhyHw::endpoint_read(usb_ep_t endpoint, uint8_t *data, uint32_t size)
44+
--
45+
2.31.1
46+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
From 4f5478196db0edb50d3b7c5d9a4af53b68173d35 Mon Sep 17 00:00:00 2001
2+
From: Martino Facchin <[email protected]>
3+
Date: Tue, 11 May 2021 09:41:45 +0200
4+
Subject: [PATCH 76/77] RP2040: include multicore library in build
5+
6+
---
7+
targets/TARGET_RASPBERRYPI/TARGET_RP2040/.mbedignore | 1 -
8+
.../pico-sdk/rp2_common/pico_multicore/multicore.c | 8 ++++----
9+
2 files changed, 4 insertions(+), 5 deletions(-)
10+
11+
diff --git a/targets/TARGET_RASPBERRYPI/TARGET_RP2040/.mbedignore b/targets/TARGET_RASPBERRYPI/TARGET_RP2040/.mbedignore
12+
index c7a477981a..0581f97d6e 100644
13+
--- a/targets/TARGET_RASPBERRYPI/TARGET_RP2040/.mbedignore
14+
+++ b/targets/TARGET_RASPBERRYPI/TARGET_RP2040/.mbedignore
15+
@@ -5,7 +5,6 @@ pico-sdk/rp2_common/pico_printf*
16+
pico-sdk/boards/include/boards/*
17+
pico-sdk/common/pico_base/include/pico/*
18+
pico-sdk/rp2_common/boot_stage2/*
19+
-pico-sdk/rp2_common/pico_multicore/*
20+
pico-sdk/rp2_common/pico_malloc/*
21+
pico-sdk/rp2_common/pico_stdlib/
22+
pico-sdk/rp2_common/pico_mem_ops/*
23+
diff --git a/targets/TARGET_RASPBERRYPI/TARGET_RP2040/pico-sdk/rp2_common/pico_multicore/multicore.c b/targets/TARGET_RASPBERRYPI/TARGET_RP2040/pico-sdk/rp2_common/pico_multicore/multicore.c
24+
index 0ceea4def8..6b2321f12f 100644
25+
--- a/targets/TARGET_RASPBERRYPI/TARGET_RP2040/pico-sdk/rp2_common/pico_multicore/multicore.c
26+
+++ b/targets/TARGET_RASPBERRYPI/TARGET_RP2040/pico-sdk/rp2_common/pico_multicore/multicore.c
27+
@@ -4,12 +4,12 @@
28+
* SPDX-License-Identifier: BSD-3-Clause
29+
*/
30+
31+
-#include "pico/stdlib.h"
32+
-#include "pico/multicore.h"
33+
+#include "hardware/structs/sio.h"
34+
+#include "pico/time.h"
35+
#include "hardware/sync.h"
36+
+#include "pico/multicore.h"
37+
#include "hardware/irq.h"
38+
#include "hardware/structs/scb.h"
39+
-#include "hardware/structs/sio.h"
40+
#include "hardware/regs/psm.h"
41+
#include "hardware/claim.h"
42+
#if PICO_USE_STACK_GUARDS
43+
@@ -259,4 +259,4 @@ bool multicore_lockout_end_timeout_us(uint64_t timeout_us) {
44+
45+
void multicore_lockout_end_blocking() {
46+
multicore_lockout_end_block_until(at_the_end_of_time);
47+
-}
48+
\ No newline at end of file
49+
+}
50+
--
51+
2.31.1
52+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
From 71f9df30c44e5dce7c944ab38ec9299d7e3d48ce Mon Sep 17 00:00:00 2001
2+
From: Martino Facchin <[email protected]>
3+
Date: Wed, 12 May 2021 16:00:01 +0200
4+
Subject: [PATCH 77/77] RP2040: USB: retry handling irqs if some went missing
5+
6+
---
7+
targets/TARGET_RASPBERRYPI/TARGET_RP2040/USBPhy_RP2040.cpp | 6 +++++-
8+
1 file changed, 5 insertions(+), 1 deletion(-)
9+
10+
diff --git a/targets/TARGET_RASPBERRYPI/TARGET_RP2040/USBPhy_RP2040.cpp b/targets/TARGET_RASPBERRYPI/TARGET_RP2040/USBPhy_RP2040.cpp
11+
index 9beb225a30..5b5185dfee 100644
12+
--- a/targets/TARGET_RASPBERRYPI/TARGET_RP2040/USBPhy_RP2040.cpp
13+
+++ b/targets/TARGET_RASPBERRYPI/TARGET_RP2040/USBPhy_RP2040.cpp
14+
@@ -391,6 +391,9 @@ void USBPhyHw::endpoint_abort(usb_ep_t endpoint)
15+
16+
void USBPhyHw::process()
17+
{
18+
+
19+
+again:
20+
+
21+
// reset interrupt
22+
if (usb_hw->ints & USB_INTS_BUS_RESET_BITS) {
23+
// Clear the device address
24+
@@ -509,7 +512,8 @@ void USBPhyHw::process()
25+
{
26+
volatile int ints = usb_hw->ints;
27+
volatile int going = 1;
28+
- while(ints && going);
29+
+ goto again;
30+
+ //while(ints && going);
31+
}
32+
33+
34+
--
35+
2.31.1
36+

0 commit comments

Comments
 (0)