Compare commits

...
6 Commits
Author SHA1 Message Date
Earle F. Philhower, III bd64b97a20 Update version 2024-08-08 11:00:00 -07:00
Earle F. Philhower, III 525408e181 Add RP2040.memcpyDMA for DMA-managed memory copies (#2324)
RP2040::memcpyDMA implements a DMA-controlled memory copy call identical in
function to standard memcpy, but using an onboard DMA engine.  For large
memory transfers this can be significantly faster than using the CPU-based
memcpy.  Only 4-byte aligned source, destination, and counts are allowed.
If any inputs are not 4-byte aligned, then standard memcpy will occur so
it will behave correctly for any inputs.
2024-08-08 10:49:33 -07:00
Earle F. Philhower, III e022d47e80 Minor BearSSL changes for 8266/upstream (#2323)
No functionality differences expected.
2024-08-08 08:44:17 -07:00
Earle F. Philhower, III 28b0edac21 Add checks for Adafruit TinyUSB to USB libs (#2319)
The included USB libraries are not compatible with Adafruit TinyUSB, so
add a #error message when they're built with the define set.
2024-08-04 10:10:08 -07:00
Dominic Pearman 4bd7d99c96 Documentation: moved 'ESP32 Compatibility' to subsection (#2311)
Lowered level of segment 'ESP32 Compatibility' in documentation of 'WiFiClientSecure Class' to be a subsection thereof.
2024-08-03 07:32:39 -07:00
Earle F. Philhower, III 06572e365b Fix minor LWIP wrapper errors (#2310)
Somehow returning the results of a `void` function from another `void`
wrapper didn't trigger any warnings.  Also missed tcp_bind actual
GCC wrapping.
2024-08-02 16:24:54 -07:00
19 changed files with 136 additions and 30 deletions
+32
View File
@@ -27,6 +27,7 @@
#include <hardware/structs/rosc.h>
#include <hardware/structs/systick.h>
#include <pico/multicore.h>
#include <hardware/dma.h>
#include <pico/rand.h>
#include <pico/util/queue.h>
#include <pico/bootrom.h>
@@ -311,6 +312,36 @@ public:
return id;
}
#pragma GCC push_options
#pragma GCC optimize ("Os")
void *memcpyDMA(void *dest, const void *src, size_t n) {
// Allocate a DMA channel on 1st call, reuse it every call after
if (memcpyDMAChannel < 1) {
memcpyDMAChannel = dma_claim_unused_channel(true);
dma_channel_config c = dma_channel_get_default_config(memcpyDMAChannel);
channel_config_set_transfer_data_size(&c, DMA_SIZE_32);
channel_config_set_read_increment(&c, true);
channel_config_set_write_increment(&c, true);
channel_config_set_irq_quiet(&c, true);
dma_channel_set_config(memcpyDMAChannel, &c, false);
}
// If there's any misalignment or too small, use regular memcpy which can handle it
if ((n < 64) || (((uint32_t)dest) | ((uint32_t)src) | n) & 3) {
return memcpy(dest, src, n);
}
int words = n / 4;
dma_channel_set_read_addr(memcpyDMAChannel, src, false);
dma_channel_set_write_addr(memcpyDMAChannel, dest, false);
dma_channel_set_trans_count(memcpyDMAChannel, words, false);
dma_channel_start(memcpyDMAChannel);
while (dma_channel_is_busy(memcpyDMAChannel)) {
/* busy wait dma */
}
return dest;
}
#pragma GCC pop_options
// Multicore comms FIFO
_MFIFO fifo;
@@ -336,4 +367,5 @@ private:
PIO _pio;
int _sm;
PIOProgram *_ccountPgm;
int memcpyDMAChannel = -1;
};
+2 -2
View File
@@ -1,5 +1,5 @@
#pragma once
#define ARDUINO_PICO_MAJOR 3
#define ARDUINO_PICO_MINOR 9
#define ARDUINO_PICO_REVISION 4
#define ARDUINO_PICO_VERSION_STR "3.9.4"
#define ARDUINO_PICO_REVISION 5
#define ARDUINO_PICO_VERSION_STR "3.9.5"
+3 -3
View File
@@ -247,19 +247,19 @@ extern "C" {
extern void __real_tcp_setprio(struct tcp_pcb *pcb, u8_t prio);
void __wrap_tcp_setprio(struct tcp_pcb *pcb, u8_t prio) {
LWIPMutex m;
return __real_tcp_setprio(pcb, prio);
__real_tcp_setprio(pcb, prio);
}
extern void __real_tcp_backlog_delayed(struct tcp_pcb* pcb);
void __wrap_tcp_backlog_delayed(struct tcp_pcb* pcb) {
LWIPMutex m;
return __real_tcp_backlog_delayed(pcb);
__real_tcp_backlog_delayed(pcb);
}
extern void __real_tcp_backlog_accepted(struct tcp_pcb* pcb);
void __wrap_tcp_backlog_accepted(struct tcp_pcb* pcb) {
LWIPMutex m;
return __real_tcp_backlog_accepted(pcb);
__real_tcp_backlog_accepted(pcb);
}
extern struct udp_pcb *__real_udp_new(void);
struct udp_pcb *__wrap_udp_new(void) {
+1 -1
View File
@@ -120,7 +120,7 @@ Valid values for min and max are `BR_TLS10`, `BR_TLS11`, `BR_TLS12`. Min and ma
ESP32 Compatibility
===================
~~~~~~~~~~~~~~~~~~~
Simple ESP32 ``WiFiClientSecure`` compatibility is built-in, allow for some sketches to run without any modification.
The following methods are implemented:
+2 -2
View File
@@ -54,9 +54,9 @@ author = u'Earle F. Philhower, III'
# built documents.
#
# The short X.Y version.
version = u'3.9.4'
version = u'3.9.5'
# The full version, including alpha/beta/rc tags.
release = u'3.9.4'
release = u'3.9.5'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
+10
View File
@@ -99,3 +99,13 @@ bootloader.
void rp2040.rebootToBootloader()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Will reboot the RP2040 into USB UF2 upload mode.
DMA-based MEMCPY
----------------
The onboard DMA engines can copy 4-byte aligned quantities faster than the CPU.
void \*rp2040.memcpyDMA(void \*dest, const void \*src, size_t count);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Uses a DMA engine to transfer data from src to dest in 4-byte chunks without CPU
intervention. If any arguments are not 4-byte aligned, or if the count is not a
multiple of 4, then it will fall back to CPU-managed memcpy.
+1 -1
View File
@@ -1,2 +1,2 @@
// Do not edit -- Automatically generated by tools/sdk/ssl/bearssl/Makefile
#define BEARSSL_GIT f294aa0
#define BEARSSL_GIT 5166f2b
BIN
View File
Binary file not shown.
+1
View File
@@ -166,6 +166,7 @@
-Wl,--wrap=tcp_arg
-Wl,--wrap=tcp_new
-Wl,--wrap=tcp_bind
-Wl,--wrap=tcp_listen
-Wl,--wrap=tcp_listen_with_backlog
-Wl,--wrap=tcp_accept
+4
View File
@@ -19,6 +19,10 @@
#pragma once
#ifdef USE_TINYUSB
#error FatFSUSB is not compatible with Adafruit TinyUSB
#endif
#include <Arduino.h>
class FatFSUSBClass {
+6 -5
View File
@@ -18,11 +18,14 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _JOYSTICK_h
#define _JOYSTICK_h
#pragma once
#ifdef USE_TINYUSB
#error Joystick is not compatible with Adafruit TinyUSB
#endif
#include <HID_Joystick.h>
#include "class/hid/hid.h"
#include <class/hid/hid.h>
//======================================================================
class Joystick_ : public HID_Joystick {
@@ -31,5 +34,3 @@ public:
virtual void send_now(void) override;
};
extern Joystick_ Joystick;
#endif /* _JOYSTICK_h */
+5 -4
View File
@@ -20,8 +20,11 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef KEYBOARD_h
#define KEYBOARD_h
#pragma once
#ifdef USE_TINYUSB
#error Keyboard is not compatible with Adafruit TinyUSB
#endif
#include <HID_Keyboard.h>
@@ -34,5 +37,3 @@ public:
Keyboard_(void);
};
extern Keyboard_ Keyboard;
#endif
+5 -4
View File
@@ -19,8 +19,11 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef MOUSE_h
#define MOUSE_h
#pragma once
#ifdef USE_TINYUSB
#error Mouse is not compatible with Adafruit TinyUSB
#endif
#include <HID_Mouse.h>
@@ -30,5 +33,3 @@ public:
virtual void move(int x, int y, signed char wheel = 0) override;
};
extern Mouse_ Mouse;
#endif
+6 -5
View File
@@ -1,5 +1,5 @@
/*
Mouse.h
MouseAbsolute.h
Copyright (c) 2015, Arduino LLC
Original code (pre-library): Copyright (c) 2011, Peter Barrett
@@ -19,8 +19,11 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef MOUSEABSOLUTE_h
#define MOUSEABSOLUTE_h
#pragma once
#ifdef USE_TINYUSB
#error MouseAbsolute is not compatible with Adafruit TinyUSB
#endif
#include <HID_Mouse.h>
@@ -30,5 +33,3 @@ public:
virtual void move(int x, int y, signed char wheel = 0) override;
};
extern MouseAbsolute_ MouseAbsolute;
#endif
@@ -19,6 +19,10 @@
#pragma once
#ifdef USE_TINYUSB
#error SingleFileDrive is not compatible with Adafruit TinyUSB
#endif
#include <Arduino.h>
class SingleFileDrive {
@@ -0,0 +1,51 @@
// Simple speed and functionality test for DMA memcpy
// Released to the public domain by Earle F. Philhower, III, 2024
uint32_t src[1024];
uint32_t dest[1024];
void setup() {
// Set up a simple test pattern in src, verify after each pass
srand(0xc0de);
for (int i = 0; i < 1024; i++) {
src[i] = ((~i) & 1024) | ((i) << 22);
}
}
void verify(const char *name, uint32_t *src) {
for (int i = 0; i < 1024; i++) {
uint32_t expected = ((~i) & 1024) | ((i) << 22);
if (expected != src[i]) {
Serial.printf("ERROR, mismatch @ %d on %s memcpy\n", i, name);
while (true) {
// Idle forever, this is fatal!
}
}
}
}
void loop() {
uint64_t start, stop;
start = rp2040.getCycleCount();
for (int i = 0; i < 1000; i++) {
memcpy(dest, src, 4 * 1024);
memcpy(src, dest, 4 * 1024);
}
stop = rp2040.getCycleCount();
verify("CPU", src);
verify("CPU", dest);
Serial.printf("CPU: %lld clock cycles for 4K\n", (stop - start) / 1000);
start = rp2040.getCycleCount();
for (int i = 0; i < 1000; i++) {
rp2040.memcpyDMA(dest, src, 4 * 1024);
rp2040.memcpyDMA(src, dest, 4 * 1024);
}
stop = rp2040.getCycleCount();
verify("DMA", src);
verify("DMA", dest);
Serial.printf("DMA: %lld clock cycles for 4K\n\n\n", (stop - start) / 1000);
delay(1000);
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "framework-arduinopico",
"version": "1.30904.0",
"version": "1.30905.0",
"description": "Arduino Wiring-based Framework (RPi Pico RP2040)",
"keywords": [
"framework",
+1 -1
View File
@@ -20,7 +20,7 @@
# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification
name=Raspberry Pi RP2040 Boards
version=3.9.4
version=3.9.5
# Required discoveries and monitors
# ---------------------------------