Compare commits

..
13 Commits
Author SHA1 Message Date
Earle F. Philhower, III 1f5139d209 Update version 2022-07-24 12:58:02 -07:00
Earle F. Philhower, III 2397d034e3 Remove SPI init from CYW43 ethernet shim 2022-07-23 14:20:10 -07:00
Earle F. Philhower, III c889a3c1f0 Add NTP waitSet callback (#705)
Allows printing "."s or flashing an LED while NTP is waiting for sync.
2022-07-23 14:07:11 -07:00
Earle F. Philhower, III cfc05dab2c Add basic ESP32 WiFiClientSecure support (#704)
Simple sketches should work without modification, but some modes (listed
in the docs) are not possible to support on the Pico W with BearSSL.

Fixes #691
2022-07-23 10:59:40 -07:00
Earle F. Philhower, III 4a174106cc Add BearSSL to README 2022-07-22 12:48:52 -07:00
Earle F. Philhower, III f04c8536c8 Make AP mode report WL_CONNECTED (#702) 2022-07-22 12:32:28 -07:00
Earle F. Philhower, III a97dc38e87 Uploading for the first time docs from @fjansson (#699)
Fixes #688
2022-07-21 12:09:49 -07:00
Earle F. Philhower, III 042c6af887 Add USB VID/PID to Platform.IO HWIDs (#698) 2022-07-21 12:08:21 -07:00
Earle F. Philhower, III 0e18f0986a Enable IPv4 or IPv4/IPv6 stacks, Ethernet class (#695)
IPv4-only mode saves 20KB+ of flash memory.

Add some backwards compatibility with the global Arduino Ethernet
class when running in IPv4 only mode.

Fixes #687

* Speed P.IO build by not cloning 2GB of sources
* Document P.IO new option
2022-07-21 11:57:21 -07:00
Maximilian Gerhardt 40f4fdf246 Fix PlatformIO linking for variant-specific overrides (#696) 2022-07-21 04:49:09 -07:00
Benjamin AignerandBenjamin Aigner 67b3c8fc25 Adding a Joystick library, concurrently usable with Keyboard & Mouse (#692)
Co-authored-by: Benjamin Aigner <beni@asterics-foundation.org>
2022-07-21 04:40:04 -07:00
Earle F. Philhower, III b88ad3d143 Support original Pico with ROM B0 (#693)
The SDK disabled float/double support for some functions by default on the
original B0 ROMs.  Manually re-enable it.

Fixes #689
2022-07-20 12:07:34 -07:00
Maximilian Gerhardt be9e25785c Correct PlatformIO build for Pico W, add to CI (#686)
* Add LWIP defines from platform.txt

* Add WiFi example to PIO CI
2022-07-19 08:09:47 -07:00
69 changed files with 1275 additions and 144 deletions
+10 -1
View File
@@ -185,7 +185,14 @@ jobs:
steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'
submodules: 'true'
- name: Initialize needed submodules
run: |
cd pico-sdk
git submodule update --init
cd ../libraries/Adafruit_TinyUSB_Arduino
git submodule update --init
cd ../..
- name: Cache pip
uses: actions/cache@v2
with:
@@ -212,3 +219,5 @@ jobs:
run: pio ci --board=rpipico --board=adafruit_feather -O "platform_packages=framework-arduinopico@symlink:///home/runner/work/arduino-pico/arduino-pico" libraries/rp2040/examples/Fade/Fade.ino
- name: Build TinyUSB Example
run: pio ci --board=rpipico --board=adafruit_feather -O "platform_packages=framework-arduinopico@symlink:///home/runner/work/arduino-pico/arduino-pico" -O "build_flags=-DUSE_TINYUSB" libraries/Adafruit_TinyUSB_Arduino/examples/CDC/cdc_multi/cdc_multi.ino
- name: Build WiFi Example
run: pio ci --board=rpipicow -O "platform_packages=framework-arduinopico@symlink:///home/runner/work/arduino-pico/arduino-pico" libraries/WiFi/examples/ScanNetworks/ScanNetworks.ino
+3
View File
@@ -19,6 +19,9 @@
[submodule "libraries/Mouse"]
path = libraries/Mouse
url = https://github.com/earlephilhower/Mouse
[submodule "libraries/Joystick"]
path = libraries/Joystick
url = https://github.com/benjaminaigner/Joystick
[submodule "libraries/Adafruit_TinyUSB_Arduino"]
path = libraries/Adafruit_TinyUSB_Arduino
url = https://github.com/adafruit/Adafruit_TinyUSB_Arduino.git
+2 -1
View File
@@ -182,6 +182,7 @@ If you want to contribute or have bugfixes, drop me a note at <earlephilhower@ya
* DHCP server for AP host mode from the [Micropython Project](https://micropython.org), distributed under the MIT License.
* [FreeRTOS](https://freertos.org) is Copyright Amazon.com, Inc. or its affiliates, and distributed under the MIT license.
* [lwIP](https://savannah.nongnu.org/projects/lwip/) is (c) the Swedish Institute of Computer Science and licenced under the BSD license.
* [BearSSL](https://bearssl.org) library written by Thomas Pornin, is distributed under the [MIT License](https://bearssl.org/#legal-details).
-Earle F. Philhower, III
-Earle F. Philhower, III
earlephilhower@yahoo.com
+577
View File
File diff suppressed because it is too large Load Diff
+76 -31
View File
@@ -91,7 +91,7 @@ const uint8_t *tud_descriptor_device_cb(void) {
.iSerialNumber = USBD_STR_SERIAL,
.bNumConfigurations = 1
};
if (__USBInstallSerial && !__USBInstallKeyboard && !__USBInstallMouse && !__USBInstallMIDI) {
if (__USBInstallSerial && !__USBInstallKeyboard && !__USBInstallMouse && !__USBInstallJoystick && !__USBInstallMIDI) {
// Can use as-is, this is the default USB case
return (const uint8_t *)&usbd_desc_device;
}
@@ -102,6 +102,9 @@ const uint8_t *tud_descriptor_device_cb(void) {
if (__USBInstallMouse) {
usbd_desc_device.idProduct |= 0x4000;
}
if (__USBInstallJoystick) {
usbd_desc_device.idProduct |= 0x0100;
}
if (__USBInstallMIDI) {
usbd_desc_device.idProduct |= 0x2000;
}
@@ -120,6 +123,17 @@ int __USBGetMouseReportID() {
return __USBInstallKeyboard ? 2 : 1;
}
int __USBGetJoystickReportID() {
int i = 1;
if (__USBInstallKeyboard) {
i++;
}
if (__USBInstallMouse) {
i++;
}
return i;
}
static int __hid_report_len = 0;
static uint8_t *__hid_report = nullptr;
@@ -131,37 +145,68 @@ static uint8_t *GetDescHIDReport(int *len) {
}
void __SetupDescHIDReport() {
if (__USBInstallKeyboard && __USBInstallMouse) {
uint8_t desc_hid_report[] = {
TUD_HID_REPORT_DESC_KEYBOARD(HID_REPORT_ID(1)),
TUD_HID_REPORT_DESC_MOUSE(HID_REPORT_ID(2))
};
__hid_report = (uint8_t *)malloc(sizeof(desc_hid_report));
if (__hid_report) {
__hid_report_len = sizeof(desc_hid_report);
memcpy(__hid_report, desc_hid_report, __hid_report_len);
}
} else if (__USBInstallKeyboard && ! __USBInstallMouse) {
uint8_t desc_hid_report[] = {
TUD_HID_REPORT_DESC_KEYBOARD(HID_REPORT_ID(1))
};
__hid_report = (uint8_t *)malloc(sizeof(desc_hid_report));
if (__hid_report) {
__hid_report_len = sizeof(desc_hid_report);
memcpy(__hid_report, desc_hid_report, __hid_report_len);
}
} else if (! __USBInstallKeyboard && __USBInstallMouse) {
uint8_t desc_hid_report[] = {
TUD_HID_REPORT_DESC_MOUSE(HID_REPORT_ID(1))
};
__hid_report = (uint8_t *)malloc(sizeof(desc_hid_report));
if (__hid_report) {
__hid_report_len = sizeof(desc_hid_report);
memcpy(__hid_report, desc_hid_report, __hid_report_len);
}
} else {
//allocate memory for the HID report descriptors. We don't use them, but need the size here.
uint8_t desc_hid_report_mouse[] = { TUD_HID_REPORT_DESC_MOUSE(HID_REPORT_ID(1)) };
uint8_t desc_hid_report_joystick[] = { TUD_HID_REPORT_DESC_GAMEPAD(HID_REPORT_ID(1)) };
uint8_t desc_hid_report_keyboard[] = { TUD_HID_REPORT_DESC_KEYBOARD(HID_REPORT_ID(1)) };
int size = 0;
//accumulate the size of all used HID report descriptors
if (__USBInstallKeyboard) {
size += sizeof(desc_hid_report_keyboard);
}
if (__USBInstallMouse) {
size += sizeof(desc_hid_report_mouse);
}
if (__USBInstallJoystick) {
size += sizeof(desc_hid_report_joystick);
}
//no HID used at all
if (size == 0) {
__hid_report = nullptr;
__hid_report_len = 0;
return;
}
//allocate the "real" HID report descriptor
__hid_report = (uint8_t *)malloc(size);
if (__hid_report) {
__hid_report_len = size;
//now copy the descriptors
//1.) keyboard descriptor, if requested
if (__USBInstallKeyboard) {
memcpy(__hid_report, desc_hid_report_keyboard, sizeof(desc_hid_report_keyboard));
}
//2.) mouse descriptor, if necessary. Additional offset & new array is necessary if there is a keyboard.
if (__USBInstallMouse) {
//determine if we need an offset (USB keyboard is installed)
if (__USBInstallKeyboard) {
uint8_t desc_local[] = { TUD_HID_REPORT_DESC_MOUSE(HID_REPORT_ID(2)) };
memcpy(__hid_report + sizeof(desc_hid_report_keyboard), desc_local, sizeof(desc_local));
} else {
memcpy(__hid_report, desc_hid_report_mouse, sizeof(desc_hid_report_mouse));
}
}
//3.) joystick descriptor. 2 additional checks are necessary for mouse and/or keyboard
if (__USBInstallJoystick) {
uint8_t reportid = 1;
int offset = 0;
if (__USBInstallKeyboard) {
reportid++;
offset += sizeof(desc_hid_report_keyboard);
}
if (__USBInstallMouse) {
reportid++;
offset += sizeof(desc_hid_report_mouse);
}
uint8_t desc_local[] = { TUD_HID_REPORT_DESC_GAMEPAD(HID_REPORT_ID(reportid)) };
memcpy(__hid_report + offset, desc_local, sizeof(desc_local));
}
}
}
@@ -181,7 +226,7 @@ const uint8_t *tud_descriptor_configuration_cb(uint8_t index) {
void __SetupUSBDescriptor() {
if (!usbd_desc_cfg) {
bool hasHID = __USBInstallKeyboard || __USBInstallMouse;
bool hasHID = __USBInstallKeyboard || __USBInstallMouse || __USBInstallJoystick;
uint8_t interface_count = (__USBInstallSerial ? 2 : 0) + (hasHID ? 1 : 0) + (__USBInstallMIDI ? 2 : 0);
+2
View File
@@ -24,6 +24,7 @@
// Weak function definitions for each type of endpoint
extern void __USBInstallSerial() __attribute__((weak));
extern void __USBInstallKeyboard() __attribute__((weak));
extern void __USBInstallJoystick() __attribute__((weak));
extern void __USBInstallMouse() __attribute__((weak));
extern void __USBInstallMIDI() __attribute__((weak));
@@ -34,6 +35,7 @@ extern mutex_t __usb_mutex;
// HID report ID inquiry (report ID will vary depending on the number/type of other HID)
int __USBGetKeyboardReportID();
int __USBGetMouseReportID();
int __USBGetJoystickReportID();
// Called by main() to init the USB HW/SW.
void __USBStart();
+2 -2
View File
@@ -1,5 +1,5 @@
#pragma once
#define ARDUINO_PICO_MAJOR 2
#define ARDUINO_PICO_MINOR 3
#define ARDUINO_PICO_REVISION 2
#define ARDUINO_PICO_VERSION_STR "2.3.2"
#define ARDUINO_PICO_REVISION 3
#define ARDUINO_PICO_VERSION_STR "2.3.3"
+2
View File
@@ -179,8 +179,10 @@ bool IPAddress::isValid(const char* arg) {
return IPAddress().fromString(arg);
}
namespace arduino {
const IPAddress INADDR_ANY; // generic "0.0.0.0" for IPv4 & IPv6
const IPAddress INADDR_NONE(255,255,255,255);
};
void IPAddress::clear() {
(*this) = INADDR_ANY;
+24 -6
View File
@@ -27,11 +27,14 @@
#include <lwip/ip_addr.h>
#include <lwip/ip4_addr.h>
namespace arduino {
#if !LWIP_IPV6
struct ip_addr: ipv4_addr { };
#endif // !LWIP_IPV6
// forward declarations of global name space friend classes
class EthernetClass;
class DhcpClass;
class DNSClient;
namespace arduino {
// to display a netif id with printf:
#define NETIFID_STR "%c%c%u"
@@ -48,8 +51,19 @@ struct ip_addr: ipv4_addr { };
class IPAddress: public Printable {
private:
#if !LWIP_IPV6
// Ugly hack to allow Arduino Ethernet library to twiddle internal bits.
// This can only work in IPv4-only mode, of course.
union {
ip_addr_t _ip;
struct {
uint8_t bytes[4];
} _address;
};
static_assert(sizeof(_ip) == sizeof(_address), "IP_ADDR_T size != _ADDRESS size");
#else
ip_addr_t _ip;
#endif
// Access the raw byte array containing the address. Because this returns a pointer
// to the internal structure rather than a copy of the address this function should only
@@ -149,6 +163,10 @@ class IPAddress: public Printable {
friend class DhcpClass;
friend class DNSClient;
friend ::EthernetClass;
friend ::DhcpClass;
friend ::DNSClient;
/*
lwIP address compatibility
*/
@@ -167,7 +185,6 @@ class IPAddress: public Printable {
bool isLocal () const { return ip_addr_islinklocal(&_ip); }
#if LWIP_IPV6
IPAddress(const ip_addr_t& lwip_addr) { ip_addr_copy(_ip, lwip_addr); }
IPAddress(const ip_addr_t* lwip_addr) { ip_addr_copy(_ip, *lwip_addr); }
@@ -175,6 +192,7 @@ class IPAddress: public Printable {
IPAddress& operator=(const ip_addr_t& lwip_addr) { ip_addr_copy(_ip, lwip_addr); return *this; }
IPAddress& operator=(const ip_addr_t* lwip_addr) { ip_addr_copy(_ip, *lwip_addr); return *this; }
#if LWIP_IPV6
uint16_t* raw6()
{
setV6();
+28 -1
View File
@@ -1,7 +1,7 @@
:orphan:
WiFiClientSecure Class
----------------------
======================
`BearSSL::WiFiClientSecure` is the object which actually handles TLS encrypted WiFi connections to a remote server or client. It extends `WiFiClient` and so can be used with minimal changes to code that does unsecured communications.
@@ -117,3 +117,30 @@ setSSLVersion(uint32_t min, uint32_t max)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Valid values for min and max are `BR_TLS10`, `BR_TLS11`, `BR_TLS12`. Min and max may be set to the same value if only a single TLS version is desired.
ESP32 Compatibility
===================
Simple ESP32 ``WiFiClientSecure`` compatibility is built-in, allow for some sketches to run without any modification.
The following methods are implemented:
.. code :: cpp
void setCACert(const char *rootCA);
void setCertificate(const char *client_ca);
void setPrivateKey(const char *private_key);
bool loadCACert(Stream& stream, size_t size);
bool loadCertificate(Stream& stream, size_t size);
bool loadPrivateKey(Stream& stream, size_t size);
int connect(IPAddress ip, uint16_t port, int32_t timeout);
int connect(const char *host, uint16_t port, int32_t timeout);
int connect(IPAddress ip, uint16_t port, const char *rootCABuff, const char *cli_cert, const char *cli_key);
int connect(const char *host, uint16_t port, const char *rootCABuff, const char *cli_cert, const char *cli_key);
Note that the SSL backend is very different between Arduino-Pico and ESP32-Arduino (BearSSL vs. mbedTLS). This means
that, for instance, the SSL connection will check valid dates of certificates (and hence require system time to be
set on the Pico, which is automatically done in this case).
TLS-Pre Shared Keys (PSK) is not supported by BearSSL, and hence not implemented here. Neither is ALPN.
For more advanced control, it is recommended to port to the native Pico calls which allows much more flexibility and control.
+2 -2
View File
@@ -54,9 +54,9 @@ author = u'Earle F. Philhower, III'
# built documents.
#
# The short X.Y version.
version = u'2.3.2'
version = u'2.3.3'
# The full version, including alpha/beta/rc tags.
release = u'2.3.2'
release = u'2.3.3'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
+20
View File
@@ -65,6 +65,26 @@ Them hit the upload button and your sketch should upload and run.
In some cases the Pico will encounter a hard hang and its USB port will not respond to the auto-reset request. Should this happen, just
follow the initial procedure of holding the BOOTSEL button down while plugging in the Pico to enter the ROM bootloader.
Unable to Upload First Sketch
-----------------------------
If the Arduino IDE has never seen a serial port from a working device (Pico, AVR, or any other serial port), you
may not be able to install using the prior directions because the ``Tools->Port`` menu will be grayed out and
empty. In this case, a special workaround identified by @fjansson in `this issue report <https://github.com/earlephilhower/arduino-pico/issues/688>`_ .
To allow subsequent uploads to automatically work, you will need to manually install a UF2 binary onto the Raspberry Pi Pico one time to
allow it to present a Serial port for the Arduino IDE to detect and save.
Perform the following steps to program a dummy sketch:
1. Open a new, empty sketch (doesn't work with a read-only example sketch).
2. Compile it by pressing the "Verify" checkmark button.
3. Select the ``Sketch -> Export Compiled Binary`` menu. Select a location e.g. the desktop. A folder is created there, containing a file ending in .uf2
4. Copy this file to the Pico's drive, by drag and drop in the Explorer.
The Pico restarts and now now has a serial port. Now the Port menu in Arduino is not gray anymore, select the port there.
After this, normal uploading from the Arduino editor should work.
Windows 7 Driver Notes
----------------------
+12
View File
@@ -222,6 +222,18 @@ default Pico SDK USB stack. To change it, add
Note that the special "No USB" setting is also supported, through the
shortcut-define ``PIO_FRAMEWORK_ARDUINO_NO_USB``.
IP Stack
---------
The lwIP stack can be configured to support only IPv4 (default) or additionally IPv6. To activate IPv6 support, add
.. code:: ini
; IPv6
build_flags = -DPIO_FRAMEWORK_ARDUINO_ENABLE_IPV6
to the ``platformio.ini``.
Selecting a different core version
----------------------------------
+3 -2
View File
@@ -12,8 +12,9 @@ serial port, ``Serial`` as well as supporting automatic reset-to-upload
from the IDE.
The Arduino-Pico core includes ported versions of the basic Arduino
``Keyboard`` and ``Mouse`` libraries. These libraries allow you to
emulate a keyboard or mouse with the Pico in your sketches.
``Keyboard``, ``Mouse`` and ``Joystick`` libraries. These libraries
allow you to emulate a keyboard, a gamepad or mouse (or all together)
with the Pico in your sketches.
See the examples and Arduino Reference at
https://www.arduino.cc/reference/en/language/functions/usb/keyboard/
+35
View File
@@ -39,3 +39,38 @@ returns a sane value before continuing a sketch:
Serial.print("Current time: ");
Serial.print(asctime(&timeinfo));
}
bool NTP.waitSet(uint32_t timeout)
----------------------------------
This call will wait up to timeout milliseconds for the time to be set, and returns
success or failure. It will also begin NTP with a default "pool.ntp.org" server if
it is not already running. Using this method, the above code becomes:
.. code :: cpp
void setClock() {
NTP.begin("pool.ntp.org", "time.nist.gov");
NTP.waitSet();
time_t now = time(nullptr);
struct tm timeinfo;
gmtime_r(&now, &timeinfo);
Serial.print("Current time: ");
Serial.print(asctime(&timeinfo));
}
bool NTP.waitSet(void (\*cb)(), uint32_t timeout)
-------------------------------------------------
Allows for a callback that will be called every 1/10th of a second while waiting for
NTP sync. For example, using lambdas you can simply print "."s:"
.. code :: cpp
void setClock() {
NTP.begin("pool.ntp.org", "time.nist.gov");
NTP.waitSet([]() { Serial.print("."); });
time_t now = time(nullptr);
struct tm timeinfo;
gmtime_r(&now, &timeinfo);
Serial.print("Current time: ");
Serial.print(asctime(&timeinfo));
}
Binary file not shown.
BIN
View File
Binary file not shown.
Submodule libraries/Joystick added at af745f3e62
@@ -57,13 +57,12 @@ void setClock() {
NTP.begin("pool.ntp.org", "time.nist.gov");
Serial.print("Waiting for NTP time sync: ");
time_t now = time(nullptr);
while (now < 8 * 3600 * 2) {
delay(500);
NTP.waitSet([]() {
Serial.print(".");
now = time(nullptr);
}
});
Serial.println("");
time_t now = time(nullptr);
struct tm timeinfo;
gmtime_r(&now, &timeinfo);
Serial.print("Current time: ");
@@ -164,13 +164,10 @@ void setClock() {
NTP.begin("pool.ntp.org", "time.nist.gov");
Serial.print("Waiting for NTP time sync: ");
time_t now = time(nullptr);
while (now < 8 * 3600 * 2) {
delay(500);
Serial.print(".");
now = time(nullptr);
}
NTP.waitSet([]() { Serial.print("."); } );
Serial.println("");
time_t now = time(nullptr);
struct tm timeinfo;
gmtime_r(&now, &timeinfo);
Serial.print("Current time: ");
@@ -45,13 +45,12 @@ void setup() {
NTP.begin("pool.ntp.org", "time.nist.gov");
Serial.print("Waiting for NTP time sync: ");
time_t now = time(nullptr);
while (now < 8 * 3600 * 2) {
delay(500);
NTP.waitSet([]() {
Serial.print(".");
now = time(nullptr);
}
});
Serial.println("");
time_t now = time(nullptr);
struct tm timeinfo;
gmtime_r(&now, &timeinfo);
Serial.print("Current time: ");
@@ -22,16 +22,14 @@ const char *path = "/";
// Set time via NTP, as required for x.509 validation
void setClock() {
configTime(3 * 3600, 0, "pool.ntp.org", "time.nist.gov");
NTP.begin("pool.ntp.org", "time.nist.gov");
Serial.print("Waiting for NTP time sync: ");
time_t now = time(nullptr);
while (now < 8 * 3600 * 2) {
delay(500);
NTP.waitSet([]() {
Serial.print(".");
now = time(nullptr);
}
});
Serial.println("");
time_t now = time(nullptr);
struct tm timeinfo;
gmtime_r(&now, &timeinfo);
Serial.print("Current time: ");
+1
View File
@@ -59,6 +59,7 @@ noLowPowerMode KEYWORD2
ping KEYWORD2
beginMulticast KEYWORD2
setTimeout KEYWORD2
waitSet KEYWORD2
#######################################
+4 -1
View File
@@ -152,7 +152,7 @@ uint8_t WiFiClass::beginAP(const char *ssid, const char* passphrase) {
#endif
bool WiFiClass::connected() {
return _wifi.connected() && localIP().isSet();
return (_apMode && _wifiHWInitted) || (_wifi.connected() && localIP().isSet());
}
/* Change Ip configuration settings disabling the dhcp client
@@ -470,6 +470,9 @@ int32_t WiFiClass::RSSI(uint8_t networkItem) {
return: one of the value defined in wl_status_t
*/
uint8_t WiFiClass::status() {
if (_apMode && _wifiHWInitted) {
return WL_CONNECTED;
}
switch (cyw43_wifi_link_status(&cyw43_state, _apMode ? 1 : 0)) {
case CYW43_LINK_DOWN: return WL_IDLE_STATUS;
case CYW43_LINK_JOIN: return localIP().isSet() ? WL_CONNECTED : WL_CONNECTING;
+1
View File
@@ -19,6 +19,7 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "WiFi.h"
#include "WiFiClient.h"
#include "WiFiClientSecureBearSSL.h"
+41 -6
View File
@@ -23,15 +23,11 @@
#include <list>
#include <errno.h>
#include <algorithm>
//#include <Esp.h>
//#include "debug.h"
#include "WiFi.h"
//#include "PolledTimeout.h"
#include "WiFiClient.h"
#include "WiFiClientSecureBearSSL.h"
#include "WiFiNTP.h"
#include "StackThunk.h"
#include "lwip/opt.h"
#include "lwip/ip.h"
@@ -95,6 +91,10 @@ void WiFiClientSecureCtx::_clear() {
_cipher_cnt = 0;
_tls_min = BR_TLS10;
_tls_max = BR_TLS12;
if (_esp32_ta) {
delete _esp32_ta;
_esp32_ta = nullptr;
}
}
void WiFiClientSecureCtx::_clearAuthenticationSettings() {
@@ -103,6 +103,10 @@ void WiFiClientSecureCtx::_clearAuthenticationSettings() {
_use_self_signed = false;
_knownkey = nullptr;
_ta = nullptr;
if (_esp32_ta) {
delete _esp32_ta;
_esp32_ta = nullptr;
}
}
@@ -166,12 +170,28 @@ WiFiClientSecureCtx::WiFiClientSecureCtx(ClientContext *client,
}
void WiFiClientSecureCtx::setClientRSACert(const X509List *chain, const PrivateKey *sk) {
if (_esp32_chain) {
delete _esp32_chain;
_esp32_chain = nullptr;
}
if (_esp32_sk) {
delete _esp32_sk;
_esp32_sk = nullptr;
}
_chain = chain;
_sk = sk;
}
void WiFiClientSecureCtx::setClientECCert(const X509List *chain,
const PrivateKey *sk, unsigned allowed_usages, unsigned cert_issuer_key_type) {
if (_esp32_chain) {
delete _esp32_chain;
_esp32_chain = nullptr;
}
if (_esp32_sk) {
delete _esp32_sk;
_esp32_sk = nullptr;
}
_chain = chain;
_sk = sk;
_allowed_usages = allowed_usages;
@@ -1071,7 +1091,11 @@ bool WiFiClientSecureCtx::_installClientX509Validator() {
DEBUG_BSSL("_installClientX509Validator: OOM for _x509_minimal\n");
return false;
}
br_x509_minimal_init(_x509_minimal.get(), &br_sha256_vtable, _ta ? _ta->getTrustAnchors() : nullptr, _ta ? _ta->getCount() : 0);
if (_esp32_ta) {
br_x509_minimal_init(_x509_minimal.get(), &br_sha256_vtable, _esp32_ta->getTrustAnchors(), _esp32_ta->getCount());
} else {
br_x509_minimal_init(_x509_minimal.get(), &br_sha256_vtable, _ta ? _ta->getTrustAnchors() : nullptr, _ta ? _ta->getCount() : 0);
}
br_x509_minimal_set_rsa(_x509_minimal.get(), br_ssl_engine_get_rsavrfy(_eng));
#ifndef BEARSSL_SSL_BASIC
br_x509_minimal_set_ecdsa(_x509_minimal.get(), br_ssl_engine_get_ec(_eng), br_ssl_engine_get_ecdsa(_eng));
@@ -1107,6 +1131,14 @@ bool WiFiClientSecureCtx::_connectSSL(const char* hostName) {
_freeSSL();
_oom_err = false;
// The ESP32 doesn't check cert time, but we do. So enable NTP silently
if (_esp32_ta || _esp32_chain || _esp32_sk) {
if (!NTP.running()) {
NTP.begin("pool.ntp.org");
NTP.waitSet();
}
}
#ifdef DEBUG_ESP_SSL
// BearSSL will reject all connections unless an authentication option is set, warn in DEBUG builds
if (!_use_insecure && !_use_fingerprint && !_use_self_signed && !_knownkey && !_certStore && !_ta) {
@@ -1160,6 +1192,9 @@ bool WiFiClientSecureCtx::_connectSSL(const char* hostName) {
DEBUG_BSSL("_connectSSL: Attempting to use EC cert in minimal cipher mode (no EC)\n");
return false;
#endif
} else if (_esp32_sk && _esp32_chain) {
br_ssl_client_set_single_rsa(_sc.get(), _esp32_chain->getX509Certs(), _esp32_chain->getCount(),
_esp32_sk->getRSA(), br_rsa_pkcs1_sign_get_default());
}
// Restore session from the storage spot, if present
@@ -159,6 +159,101 @@ public:
// consume bytes after use (see peekBuffer)
virtual void peekConsume(size_t consume) override;
#endif
// ESP32 compatibility
void setCACert(const char *rootCA) {
if (_esp32_ta) {
delete _esp32_ta;
}
_esp32_ta = new X509List(rootCA);
}
void setCertificate(const char *client_ca) {
if (_esp32_chain) {
delete _esp32_chain;
}
_esp32_chain = new X509List(client_ca);
}
void setPrivateKey(const char *private_key) {
if (_esp32_sk) {
delete _esp32_sk;
}
_esp32_sk = new PrivateKey(private_key);
}
bool loadCACert(Stream& stream, size_t size) {
bool ret = false;
auto buff = new char[size];
if (size == stream.readBytes(buff, size)) {
setCACert(buff);
ret = true;
}
delete[] buff;
return ret;
}
bool loadCertificate(Stream& stream, size_t size) {
bool ret = false;
auto buff = new char[size];
if (size == stream.readBytes(buff, size)) {
setCertificate(buff);
ret = true;
}
delete[] buff;
return ret;
}
bool loadPrivateKey(Stream& stream, size_t size) {
bool ret = false;
auto buff = new char[size];
if (size == stream.readBytes(buff, size)) {
setPrivateKey(buff);
ret = true;
}
delete[] buff;
return ret;
}
int connect(IPAddress ip, uint16_t port, int32_t timeout) {
auto save = _timeout;
_timeout = timeout * 1000; // timeout is in secs, _timeout in milliseconds
auto ret = connect(ip, port);
_timeout = save;
return ret;
}
int connect(const char *host, uint16_t port, int32_t timeout) {
auto save = _timeout;
_timeout = timeout * 1000; // timeout is in secs, _timeout in milliseconds
auto ret = connect(host, port);
_timeout = save;
return ret;
}
int connect(IPAddress ip, uint16_t port, const char *rootCABuff, const char *cli_cert, const char *cli_key) {
if (_esp32_ta) {
delete _esp32_ta;
_esp32_ta = nullptr;
}
if (_esp32_chain) {
delete _esp32_chain;
_esp32_chain = nullptr;
}
if (_esp32_sk) {
delete _esp32_sk;
_esp32_sk = nullptr;
}
if (rootCABuff) {
setCertificate(rootCABuff);
}
if (cli_cert && cli_key) {
setCertificate(cli_cert);
setPrivateKey(cli_key);
}
return connect(ip, port);
}
int connect(const char *host, uint16_t port, const char *rootCABuff, const char *cli_cert, const char *cli_key) {
IPAddress ip;
if (WiFi.hostByName(host, ip, _timeout)) {
return connect(ip, port, rootCABuff, cli_cert, cli_key);
} else {
return 0;
}
}
protected:
bool _connectSSL(const char *hostName); // Do initial SSL handshake
@@ -241,6 +336,11 @@ private:
bool _installServerX509Validator(const X509List *client_CA_ta); // Setup X509 client cert validation, if supplied
uint8_t *_streamLoad(Stream& stream, size_t size);
// ESP32 compatibility
X509List *_esp32_ta = nullptr;
X509List *_esp32_chain = nullptr;
PrivateKey *_esp32_sk = nullptr;
}; // class WiFiClientSecureCtx
@@ -443,6 +543,40 @@ public:
return _ctx->peekConsume(consume);
}
#endif
// ESP32 compatibility
void setCACert(const char *rootCA) {
return _ctx->setCACert(rootCA);
}
void setCertificate(const char *client_ca) {
return _ctx->setCertificate(client_ca);
}
void setPrivateKey(const char *private_key) {
return _ctx->setPrivateKey(private_key);
}
bool loadCACert(Stream& stream, size_t size) {
return _ctx->loadCACert(stream, size);
}
bool loadCertificate(Stream& stream, size_t size) {
return _ctx->loadCertificate(stream, size);
}
bool loadPrivateKey(Stream& stream, size_t size) {
return _ctx->loadPrivateKey(stream, size);
}
int connect(IPAddress ip, uint16_t port, int32_t timeout) {
return _ctx->connect(ip, port, timeout);
}
int connect(const char *host, uint16_t port, int32_t timeout) {
return _ctx->connect(host, port, timeout);
}
int connect(IPAddress ip, uint16_t port, const char *rootCABuff, const char *cli_cert, const char *cli_key) {
return _ctx->connect(ip, port, rootCABuff, cli_cert, cli_key);
}
int connect(const char *host, uint16_t port, const char *rootCABuff, const char *cli_cert, const char *cli_key) {
return _ctx->connect(host, port, rootCABuff, cli_cert, cli_key);
}
private:
std::shared_ptr<WiFiClientSecureCtx> _ctx;
+31 -1
View File
@@ -20,6 +20,7 @@
#pragma once
#include <Arduino.h>
#include <time.h>
#include <lwip/apps/sntp.h>
class NTPClass {
@@ -37,6 +38,7 @@ public:
sntp_setserver(0, server);
sntp_setoperatingmode(SNTP_OPMODE_POLL);
sntp_init();
_running = true;
}
}
@@ -51,15 +53,17 @@ public:
}
sntp_setoperatingmode(SNTP_OPMODE_POLL);
sntp_init();
_running = true;
}
void begin(const char *server, int timeout = 3600) {
IPAddress addr;
if (WiFi.hostByName(server, addr)) {
begin(addr, timeout);
}
_running = true;
}
void begin(const char *s1, const char *s2, int timeout = 3600) {
IPAddress a1, a2;
if (WiFi.hostByName(s1, a1)) {
@@ -69,7 +73,33 @@ public:
begin(a1, timeout);
}
}
_running = true;
}
bool waitSet(uint32_t timeout = 10000) {
return waitSet(nullptr, timeout);
}
bool waitSet(void (*cb)(), uint32_t timeout = 10000) {
if (!running()) {
begin("pool.ntp.org");
}
uint32_t start = millis();
while ((time(nullptr) < 10000000) && (millis() - start < timeout)) {
delay(100);
if (cb) {
cb();
}
}
return time(nullptr) < 10000000;
}
bool running() {
return _running;
}
private:
bool _running = false;
};
// ESP8266 compat
@@ -187,6 +187,10 @@ public:
}
void setTimeout(int timeout_ms) {
if (timeout_ms < 100) {
// Crude logic to allow for seconds or milliseconds to work. Timeouts of < 100ms don't make much sense, so assume the user meant seconds, not milliseconds
timeout_ms *= 1000;
}
_timeout_ms = timeout_ms;
}
+2 -2
View File
@@ -1,13 +1,13 @@
#include <LwipEthernet.h>
#include <SPI.h>
//#include <SPI.h>
//#ifndef ETHERNET_SPI_CLOCK_DIV
//#define ETHERNET_SPI_CLOCK_DIV SPI_CLOCK_DIV4 // 4MHz (SPI.h)
//#endif
void SPI4EthInit() {
SPI.begin();
//SPI.begin();
// SPI.setClockDivider(ETHERNET_SPI_CLOCK_DIV);
// SPI.setBitOrder(MSBFIRST);
// SPI.setDataMode(SPI_MODE0);
+1 -1
View File
@@ -179,7 +179,7 @@ int LwipIntfDev<RawDev>::hostByName(const char* aHostname, IPAddress& aResult, i
#if LWIP_IPV4 && LWIP_IPV6
err_t err = dns_gethostbyname_addrtype(aHostname, &addr, &_dns_found_callback, &cb, LWIP_DNS_ADDRTYPE_DEFAULT);
#else
err_t err = dns_gethostbyname(aHostname, &addr, &wifi_dns_found_callback, &cb);
err_t err = dns_gethostbyname(aHostname, &addr, &_dns_found_callback, &cb);
#endif
if (err == ERR_OK) {
aResult = IPAddress(&addr);
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "framework-arduinopico",
"version": "1.20302.0",
"version": "1.20303.0",
"description": "Arduino Wiring-based Framework (RPi Pico RP2040)",
"keywords": [
"framework",
+5 -5
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=2.3.2
version=2.3.3
runtime.tools.pqt-gcc.path={runtime.platform.path}/system/arm-none-eabi
runtime.tools.pqt-python3.path={runtime.platform.path}/system/python3
@@ -41,12 +41,11 @@ compiler.warning_flags.default=-Werror=return-type
compiler.warning_flags.more=-Wall -Werror=return-type -Wno-ignored-qualifiers
compiler.warning_flags.all=-Wall -Wextra -Werror=return-type -Wno-ignored-qualifiers
compiler.netdefines=-DPICO_CYW43_ARCH_THREADSAFE_BACKGROUND=1 -DCYW43_LWIP=0 -DLWIP_IPV6=1 -DLWIP_IPV4=1 -DLWIP_IGMP=1 -DLWIP_CHECKSUM_CTRL_PER_NETIF=1
compiler.netdefines=-DPICO_CYW43_ARCH_THREADSAFE_BACKGROUND=1 -DCYW43_LWIP=0 {build.lwipdefs} -DLWIP_IGMP=1 -DLWIP_CHECKSUM_CTRL_PER_NETIF=1
compiler.defines={build.led} {build.usbstack_flags} -DCFG_TUSB_MCU=OPT_MCU_RP2040 -DUSB_VID={build.vid} -DUSB_PID={build.pid} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' {compiler.netdefines}
compiler.includes="-iprefix{runtime.platform.path}/" "@{runtime.platform.path}/lib/platform_inc.txt" "-I{runtime.platform.path}/include"
compiler.flags=-march=armv6-m -mcpu=cortex-m0plus -mthumb -ffunction-sections -fdata-sections {build.flags.exceptions} {build.flags.stackprotect}
compiler.wrap="@{runtime.platform.path}/lib/platform_wrap.txt"
compiler.libpico="{runtime.platform.path}/lib/libpico.a"
compiler.libbearssl="{runtime.platform.path}/lib/libbearssl.a"
compiler.c.cmd=arm-none-eabi-gcc
@@ -92,8 +91,9 @@ build.usbstack_flags=
build.flags.libstdcpp=-lstdc++
build.flags.exceptions=-fno-exceptions
build.flags.stackprotect=
build.libpico=libpico.a
build.boot2=boot2_generic_03h_4_padded_checksum
build.lwipdefs=-DLWIP_IPV6=0 -DLWIP_IPV4=1
# Allow Pico boards do be auto-discovered by the IDE
discovery.rp2040.pattern="{runtime.tools.pqt-python3.path}/python3" -I "{runtime.platform.path}/tools/discovery.py"
@@ -123,7 +123,7 @@ recipe.hooks.linking.prelink.1.pattern="{runtime.tools.pqt-python3.path}/python3
recipe.hooks.linking.prelink.2.pattern="{compiler.path}{compiler.S.cmd}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} -c "{runtime.platform.path}/boot2/{build.boot2}.S" "-I{runtime.platform.path}/pico-sdk/src/rp2040/hardware_regs/include/" "-I{runtime.platform.path}/pico-sdk/src/common/pico_binary_info/include" -o "{build.path}/boot2.o"
## Combine gc-sections, archives, and objects
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} {compiler.ldflags} "-Wl,--script={build.path}/memmap_default.ld" "-Wl,-Map,{build.path}/{build.project_name}.map" -o "{build.path}/{build.project_name}.elf" -Wl,--start-group {object_files} "{build.path}/{archive_file}" "{build.path}/boot2.o" {compiler.libraries.ldflags} {compiler.libpico} {compiler.libbearssl} -lm -lc {build.flags.libstdcpp} -lc -Wl,--end-group
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} {compiler.ldflags} "-Wl,--script={build.path}/memmap_default.ld" "-Wl,-Map,{build.path}/{build.project_name}.map" -o "{build.path}/{build.project_name}.elf" -Wl,--start-group {object_files} "{build.path}/{archive_file}" "{build.path}/boot2.o" {compiler.libraries.ldflags} "{runtime.platform.path}/lib/{build.libpico}" {compiler.libbearssl} -lm -lc {build.flags.libstdcpp} -lc -Wl,--end-group
## Create output (UF2 file)
recipe.objcopy.uf2.pattern="{runtime.tools.pqt-elf2uf2.path}/elf2uf2" "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.uf2"
+6 -2
View File
@@ -3,8 +3,8 @@
"arduino": {
"earlephilhower": {
"boot2_source": "boot2_w25x10cl_4_padded_checksum.S",
"usb_vid": "0x239a",
"usb_pid": "0x80f1"
"usb_vid": "0x239A",
"usb_pid": "0x80F1"
}
},
"core": "earlephilhower",
@@ -15,6 +15,10 @@
[
"0x2E8A",
"0x00C0"
],
[
"0x239A",
"0x80F1"
]
],
"mcu": "rp2040",
+6 -2
View File
@@ -3,8 +3,8 @@
"arduino": {
"earlephilhower": {
"boot2_source": "boot2_w25q080_2_padded_checksum.S",
"usb_vid": "0x239a",
"usb_pid": "0x80fd"
"usb_vid": "0x239A",
"usb_pid": "0x80FD"
}
},
"core": "earlephilhower",
@@ -15,6 +15,10 @@
[
"0x2E8A",
"0x00C0"
],
[
"0x239A",
"0x80FD"
]
],
"mcu": "rp2040",
+5 -1
View File
@@ -3,7 +3,7 @@
"arduino": {
"earlephilhower": {
"boot2_source": "boot2_w25q080_2_padded_checksum.S",
"usb_vid": "0x239a",
"usb_vid": "0x239A",
"usb_pid": "0x8105"
}
},
@@ -15,6 +15,10 @@
[
"0x2E8A",
"0x00C0"
],
[
"0x239A",
"0x8105"
]
],
"mcu": "rp2040",
+5 -1
View File
@@ -3,7 +3,7 @@
"arduino": {
"earlephilhower": {
"boot2_source": "boot2_w25q080_2_padded_checksum.S",
"usb_vid": "0x239a",
"usb_vid": "0x239A",
"usb_pid": "0x8107"
}
},
@@ -15,6 +15,10 @@
[
"0x2E8A",
"0x00C0"
],
[
"0x239A",
"0x8107"
]
],
"mcu": "rp2040",
+6 -2
View File
@@ -3,8 +3,8 @@
"arduino": {
"earlephilhower": {
"boot2_source": "boot2_w25q080_2_padded_checksum.S",
"usb_vid": "0x239a",
"usb_pid": "0x80f7"
"usb_vid": "0x239A",
"usb_pid": "0x80F7"
}
},
"core": "earlephilhower",
@@ -15,6 +15,10 @@
[
"0x2E8A",
"0x00C0"
],
[
"0x239A",
"0x80F7"
]
],
"mcu": "rp2040",
+6 -2
View File
@@ -3,8 +3,8 @@
"arduino": {
"earlephilhower": {
"boot2_source": "boot2_w25q080_2_padded_checksum.S",
"usb_vid": "0x239a",
"usb_pid": "0x80e3"
"usb_vid": "0x239A",
"usb_pid": "0x80E3"
}
},
"core": "earlephilhower",
@@ -15,6 +15,10 @@
[
"0x2E8A",
"0x00C0"
],
[
"0x239A",
"0x80E3"
]
],
"mcu": "rp2040",
+5 -1
View File
@@ -3,7 +3,7 @@
"arduino": {
"earlephilhower": {
"boot2_source": "boot2_w25q080_2_padded_checksum.S",
"usb_vid": "0x239a",
"usb_vid": "0x239A",
"usb_pid": "0x8109"
}
},
@@ -15,6 +15,10 @@
[
"0x2E8A",
"0x00C0"
],
[
"0x239A",
"0x8109"
]
],
"mcu": "rp2040",
+4
View File
@@ -15,6 +15,10 @@
[
"0x2E8A",
"0x00C0"
],
[
"0x2341",
"0x0058"
]
],
"mcu": "rp2040",
+5 -1
View File
@@ -3,7 +3,7 @@
"arduino": {
"earlephilhower": {
"boot2_source": "boot2_w25q080_2_padded_checksum.S",
"usb_vid": "0x2e8a",
"usb_vid": "0x2E8A",
"usb_pid": "0x1023"
}
},
@@ -15,6 +15,10 @@
[
"0x2E8A",
"0x00C0"
],
[
"0x2E8A",
"0x1023"
]
],
"mcu": "rp2040",
+6 -2
View File
@@ -3,8 +3,8 @@
"arduino": {
"earlephilhower": {
"boot2_source": "boot2_w25q080_2_padded_checksum.S",
"usb_vid": "0x2e8a",
"usb_pid": "0x100b"
"usb_vid": "0x2E8A",
"usb_pid": "0x100B"
}
},
"core": "earlephilhower",
@@ -15,6 +15,10 @@
[
"0x2E8A",
"0x00C0"
],
[
"0x2E8A",
"0x100B"
]
],
"mcu": "rp2040",
+6 -2
View File
@@ -3,8 +3,8 @@
"arduino": {
"earlephilhower": {
"boot2_source": "boot2_w25q080_2_padded_checksum.S",
"usb_vid": "0x2e8a",
"usb_pid": "0x102d"
"usb_vid": "0x2E8A",
"usb_pid": "0x102D"
}
},
"core": "earlephilhower",
@@ -15,6 +15,10 @@
[
"0x2E8A",
"0x00C0"
],
[
"0x2E8A",
"0x102D"
]
],
"mcu": "rp2040",
+5 -1
View File
@@ -3,7 +3,7 @@
"arduino": {
"earlephilhower": {
"boot2_source": "boot2_w25q080_2_padded_checksum.S",
"usb_vid": "0x2e8a",
"usb_vid": "0x2E8A",
"usb_pid": "0x1032"
}
},
@@ -15,6 +15,10 @@
[
"0x2E8A",
"0x00C0"
],
[
"0x2E8A",
"0x1032"
]
],
"mcu": "rp2040",
+5 -1
View File
@@ -3,7 +3,7 @@
"arduino": {
"earlephilhower": {
"boot2_source": "boot2_w25q080_2_padded_checksum.S",
"usb_vid": "0x2e8a",
"usb_vid": "0x2E8A",
"usb_pid": "0x1006"
}
},
@@ -15,6 +15,10 @@
[
"0x2E8A",
"0x00C0"
],
[
"0x2E8A",
"0x1006"
]
],
"mcu": "rp2040",
+5 -1
View File
@@ -3,7 +3,7 @@
"arduino": {
"earlephilhower": {
"boot2_source": "boot2_w25q080_2_padded_checksum.S",
"usb_vid": "0x2e8a",
"usb_vid": "0x2E8A",
"usb_pid": "0x102C"
}
},
@@ -15,6 +15,10 @@
[
"0x2E8A",
"0x00C0"
],
[
"0x2E8A",
"0x102C"
]
],
"mcu": "rp2040",
+6 -2
View File
@@ -3,8 +3,8 @@
"arduino": {
"earlephilhower": {
"boot2_source": "boot2_w25q080_2_padded_checksum.S",
"usb_vid": "0x2e8a",
"usb_pid": "0x100b"
"usb_vid": "0x2E8A",
"usb_pid": "0x100B"
}
},
"core": "earlephilhower",
@@ -15,6 +15,10 @@
[
"0x2E8A",
"0x00C0"
],
[
"0x2E8A",
"0x100B"
]
],
"mcu": "rp2040",
+6 -2
View File
@@ -3,8 +3,8 @@
"arduino": {
"earlephilhower": {
"boot2_source": "boot2_w25q080_2_padded_checksum.S",
"usb_vid": "0x2e8a",
"usb_pid": "0x100f"
"usb_vid": "0x2E8A",
"usb_pid": "0x100F"
}
},
"core": "earlephilhower",
@@ -15,6 +15,10 @@
[
"0x2E8A",
"0x00C0"
],
[
"0x2E8A",
"0x100F"
]
],
"mcu": "rp2040",
+5 -1
View File
@@ -3,7 +3,7 @@
"arduino": {
"earlephilhower": {
"boot2_source": "boot2_w25q080_2_padded_checksum.S",
"usb_vid": "0x2e8a",
"usb_vid": "0x2E8A",
"usb_pid": "0x1000"
}
},
@@ -15,6 +15,10 @@
[
"0x2E8A",
"0x00C0"
],
[
"0x2E8A",
"0x1000"
]
],
"mcu": "rp2040",
+4
View File
@@ -15,6 +15,10 @@
[
"0x2E8A",
"0x00C0"
],
[
"0x3343",
"0x4253"
]
],
"mcu": "rp2040",
+6 -2
View File
@@ -3,8 +3,8 @@
"arduino": {
"earlephilhower": {
"boot2_source": "boot2_generic_03h_4_padded_checksum.S",
"usb_vid": "0x2e8a",
"usb_pid": "0x008a"
"usb_vid": "0x2E8A",
"usb_pid": "0x008A"
}
},
"core": "earlephilhower",
@@ -15,6 +15,10 @@
[
"0x2E8A",
"0x00C0"
],
[
"0x2E8A",
"0x008A"
]
],
"mcu": "rp2040",
+6 -2
View File
@@ -3,8 +3,8 @@
"arduino": {
"earlephilhower": {
"boot2_source": "boot2_generic_03h_4_padded_checksum.S",
"usb_vid": "0x2e8a",
"usb_pid": "0xf00a"
"usb_vid": "0x2E8A",
"usb_pid": "0xF00A"
}
},
"core": "earlephilhower",
@@ -15,6 +15,10 @@
[
"0x2E8A",
"0x00C0"
],
[
"0x2E8A",
"0xF00A"
]
],
"mcu": "rp2040",
+5 -1
View File
@@ -3,7 +3,7 @@
"arduino": {
"earlephilhower": {
"boot2_source": "boot2_w25q080_2_padded_checksum.S",
"usb_vid": "0x2e8a",
"usb_vid": "0x2E8A",
"usb_pid": "0x1010"
}
},
@@ -15,6 +15,10 @@
[
"0x2E8A",
"0x00C0"
],
[
"0x2E8A",
"0x1010"
]
],
"mcu": "rp2040",
+5 -1
View File
@@ -3,7 +3,7 @@
"arduino": {
"earlephilhower": {
"boot2_source": "boot2_w25q080_2_padded_checksum.S",
"usb_vid": "0x2e8a",
"usb_vid": "0x2E8A",
"usb_pid": "0x1005"
}
},
@@ -15,6 +15,10 @@
[
"0x2E8A",
"0x00C0"
],
[
"0x2E8A",
"0x1005"
]
],
"mcu": "rp2040",
+6 -2
View File
@@ -3,8 +3,8 @@
"arduino": {
"earlephilhower": {
"boot2_source": "boot2_w25q080_2_padded_checksum.S",
"usb_vid": "0x2e8a",
"usb_pid": "0x000a"
"usb_vid": "0x2E8A",
"usb_pid": "0x000A"
}
},
"core": "earlephilhower",
@@ -15,6 +15,10 @@
[
"0x2E8A",
"0x00C0"
],
[
"0x2E8A",
"0x000A"
]
],
"mcu": "rp2040",
+6 -2
View File
@@ -3,8 +3,8 @@
"arduino": {
"earlephilhower": {
"boot2_source": "boot2_w25q080_2_padded_checksum.S",
"usb_vid": "0x2e8a",
"usb_pid": "0xf00a"
"usb_vid": "0x2E8A",
"usb_pid": "0xF00A"
}
},
"core": "earlephilhower",
@@ -15,6 +15,10 @@
[
"0x2E8A",
"0x00C0"
],
[
"0x2E8A",
"0xF00A"
]
],
"mcu": "rp2040",
+6 -2
View File
@@ -3,8 +3,8 @@
"arduino": {
"earlephilhower": {
"boot2_source": "boot2_w25q080_2_padded_checksum.S",
"usb_vid": "0x2e8a",
"usb_pid": "0x000a"
"usb_vid": "0x2E8A",
"usb_pid": "0x000A"
}
},
"core": "earlephilhower",
@@ -15,6 +15,10 @@
[
"0x2E8A",
"0x00C0"
],
[
"0x2E8A",
"0x000A"
]
],
"mcu": "rp2040",
+5 -1
View File
@@ -4,7 +4,7 @@
"earlephilhower": {
"boot2_source": "boot2_generic_03h_4_padded_checksum.S",
"usb_vid": "0x1209",
"usb_pid": "0xa182"
"usb_pid": "0xA182"
}
},
"core": "earlephilhower",
@@ -15,6 +15,10 @@
[
"0x2E8A",
"0x00C0"
],
[
"0x1209",
"0xA182"
]
],
"mcu": "rp2040",
+5 -1
View File
@@ -3,7 +3,7 @@
"arduino": {
"earlephilhower": {
"boot2_source": "boot2_generic_03h_4_padded_checksum.S",
"usb_vid": "0x1b4f",
"usb_vid": "0x1B4F",
"usb_pid": "0x0026"
}
},
@@ -15,6 +15,10 @@
[
"0x2E8A",
"0x00C0"
],
[
"0x1B4F",
"0x0026"
]
],
"mcu": "rp2040",
+5 -1
View File
@@ -3,7 +3,7 @@
"arduino": {
"earlephilhower": {
"boot2_source": "boot2_w25q080_2_padded_checksum.S",
"usb_vid": "0x1b4f",
"usb_vid": "0x1B4F",
"usb_pid": "0x0026"
}
},
@@ -15,6 +15,10 @@
[
"0x2E8A",
"0x00C0"
],
[
"0x1B4F",
"0x0026"
]
],
"mcu": "rp2040",
+5 -1
View File
@@ -3,7 +3,7 @@
"arduino": {
"earlephilhower": {
"boot2_source": "boot2_w25q080_2_padded_checksum.S",
"usb_vid": "0x2e8a",
"usb_vid": "0x2E8A",
"usb_pid": "0x1007"
}
},
@@ -15,6 +15,10 @@
[
"0x2E8A",
"0x00C0"
],
[
"0x2E8A",
"0x1007"
]
],
"mcu": "rp2040",
+5 -1
View File
@@ -3,7 +3,7 @@
"arduino": {
"earlephilhower": {
"boot2_source": "boot2_w25q080_2_padded_checksum.S",
"usb_vid": "0x2e8a",
"usb_vid": "0x2E8A",
"usb_pid": "0x1027"
}
},
@@ -15,6 +15,10 @@
[
"0x2E8A",
"0x00C0"
],
[
"0x2E8A",
"0x1027"
]
],
"mcu": "rp2040",
+5 -1
View File
@@ -3,7 +3,7 @@
"arduino": {
"earlephilhower": {
"boot2_source": "boot2_w25q080_2_padded_checksum.S",
"usb_vid": "0x2e8a",
"usb_vid": "0x2E8A",
"usb_pid": "0x1029"
}
},
@@ -15,6 +15,10 @@
[
"0x2E8A",
"0x00C0"
],
[
"0x2E8A",
"0x1029"
]
],
"mcu": "rp2040",
+5 -1
View File
@@ -3,7 +3,7 @@
"arduino": {
"earlephilhower": {
"boot2_source": "boot2_w25q080_2_padded_checksum.S",
"usb_vid": "0x2e8a",
"usb_vid": "0x2E8A",
"usb_pid": "0x1028"
}
},
@@ -15,6 +15,10 @@
[
"0x2E8A",
"0x00C0"
],
[
"0x2E8A",
"0x1028"
]
],
"mcu": "rp2040",
+6 -1
View File
@@ -21,11 +21,16 @@ target_compile_definitions(pico PUBLIC
PICO_FLASH_SIZE_BYTES=16777216
PICO_XOSC_STARTUP_DELAY_MULTIPLIER=64
LWIP_IPV4=1
LWIP_IPV6=1
LWIP_IPV6=${IPV6}
LWIP_UDP=1
LWIP_IGMP=1
LWIP_CHECKSUM_CTRL_PER_NETIF=1
CYW43_WARN=//
PICO_FLOAT_SUPPORT_ROM_V1=1
PICO_DOUBLE_SUPPORT_ROM_V1=1
PICO_RP2040_B0_SUPPORTED=1
PICO_RP2040_B1_SUPPORTED=1
PICO_RP2040_B2_SUPPORTED=1
)
target_compile_options(pico PUBLIC
+9 -1
View File
@@ -8,7 +8,7 @@ export PATH="$(cd ../../system/arm-none-eabi/bin; pwd):$PATH"
rm -rf build
mkdir build
cd build
cmake ..
cmake .. -DIPV6=0
make -j
# Put everything in its place
@@ -17,6 +17,14 @@ mv generated/pico_base/pico/version.h ../../../include/pico_base/pico/.
cp ../lwipopts.h ../../../include/.
cp ../tusb_config.h ../../../include/.
cd ..
rm -rf build
mkdir build
cd build
cmake .. -DIPV6=1
make -j
mv libpico.a ../../../lib/libpico-ipv6.a
rm -rf boot
mkdir boot
cd boot
+24 -2
View File
@@ -83,6 +83,14 @@ def BuildWithoutUSBStack(name):
print("%s.menu.usbstack.nousb=No USB" % (name))
print('%s.menu.usbstack.nousb.build.usbstack_flags="-DNO_USB -DDISABLE_USB_SERIAL -I{runtime.platform.path}/tools/libpico"' % (name))
def BuildIPStack(name):
print("%s.menu.ipstack.ipv4only=IPv4 Only" % (name))
print('%s.menu.ipstack.ipv4only.build.libpico=libpico.a' % (name))
print('%s.menu.ipstack.ipv4only.build.lwipdefs=-DLWIP_IPV6=0 -DLWIP_IPV4=1' % (name))
print("%s.menu.ipstack.ipv4ipv6=IPv4 and IPv6" % (name))
print('%s.menu.ipstack.ipv4ipv6.build.libpico=libpico-ipv6.a' % (name))
print('%s.menu.ipstack.ipv4ipv6.build.lwipdefs=-DLWIP_IPV6=1 -DLWIP_IPV4=1' % (name))
def BuildHeader(name, vendor_name, product_name, vidtouse, pidtouse, vid, pid, pwr, boarddefine, variant, uploadtool, flashsize, ramsize, boot2):
prettyname = vendor_name + " " + product_name
print()
@@ -133,7 +141,7 @@ def BuildGlobalMenuList():
print("menu.dbglvl=Debug Level")
print("menu.boot2=Boot Stage 2")
print("menu.usbstack=USB Stack")
print("menu.ipstack=IP Stack")
def MakeBoard(name, vendor_name, product_name, vid, pid, pwr, boarddefine, flashsizemb, boot2):
for a, b, c in [ ["", "", "uf2conv"], ["picoprobe", " (Picoprobe)", "picoprobe"], ["picodebug", " (pico-debug)", "picodebug"]]:
@@ -171,6 +179,7 @@ def MakeBoard(name, vendor_name, product_name, vid, pid, pwr, boarddefine, flash
BuildWithoutUSBStack(n)
else:
BuildUSBStack(n)
BuildIPStack(n)
if name == "generic":
BuildBoot(n)
MakeBoardJSON(name, vendor_name, product_name, vid, pid, pwr, boarddefine, flashsizemb, boot2)
@@ -197,6 +206,10 @@ def MakeBoardJSON(name, vendor_name, product_name, vid, pid, pwr, boarddefine, f
[
"0x2E8A",
"0x00C0"
],
[
"VID",
"PID"
]
],
"mcu": "rp2040",
@@ -229,7 +242,16 @@ def MakeBoardJSON(name, vendor_name, product_name, vid, pid, pwr, boarddefine, f
},
"url": "https://www.raspberrypi.org/products/raspberry-pi-pico/",
"vendor": "VENDORNAME"
}\n""".replace('VARIANTNAME', name).replace('BOARDDEFINE', boarddefine).replace('BOOT2', boot2).replace('VID', vid).replace('PID', pid).replace('VENDORNAME', vendor_name).replace('PRODUCTNAME', product_name).replace('FLASHSIZE', str(1024*1024*flashsizemb)).replace('USBPWR', str(pwr))
}\n"""\
.replace('VARIANTNAME', name)\
.replace('BOARDDEFINE', boarddefine)\
.replace('BOOT2', boot2)\
.replace('VID', vid.upper().replace("X", "x"))\
.replace('PID', pid.upper().replace("X", "x"))\
.replace('VENDORNAME', vendor_name)\
.replace('PRODUCTNAME', product_name)\
.replace('FLASHSIZE', str(1024*1024*flashsizemb))\
.replace('USBPWR', str(pwr))
jsondir = os.path.abspath(os.path.dirname(__file__)) + "/json"
f = open(jsondir + "/" + name + ".json", "w")
f.write(json)
+26 -12
View File
@@ -79,6 +79,12 @@ env.Replace(
SIZEPROGREGEXP=r"^(?:\.boot2|\.text|\.data|\.rodata|\.text.align|\.ARM.exidx)\s+(\d+).*"
)
# pico support library depends on ipv6 enable/disable
if "PIO_FRAMEWORK_ARDUINO_ENABLE_IPV6" in flatten_cppdefines:
libpico = File(os.path.join(FRAMEWORK_DIR, "lib", "libpico-ipv6.a"))
else:
libpico = File(os.path.join(FRAMEWORK_DIR, "lib", "libpico.a"))
env.Append(
ASFLAGS=env.get("CCFLAGS", [])[:],
@@ -106,13 +112,6 @@ env.Append(
"ARDUINO_ARCH_RP2040",
("F_CPU", "$BOARD_F_CPU"),
("BOARD_NAME", '\\"%s\\"' % env.subst("$BOARD")),
# LWIP-related
("PICO_CYW43_ARCH_THREADSAFE_BACKGROUND", 1),
("CYW43_LWIP", 0),
("LWIP_IPV6", 1),
("LWIP_IPV4", 1),
("LWIP_IGMP", 1),
("LWIP_LWIP_CHECKSUM_CTRL_PER_NETIF", 1),
],
CPPPATH=[
@@ -147,7 +146,7 @@ env.Append(
# link lib/libpico.a by full path, ignore libstdc++
LIBS=[
File(os.path.join(FRAMEWORK_DIR, "lib", "libpico.a")),
libpico,
File(os.path.join(FRAMEWORK_DIR, "lib", "libbearssl.a")),
"m", "c", stdcpp_lib, "c"]
)
@@ -228,6 +227,19 @@ def configure_usb_flags(cpp_defines):
board.update("build.hwids", hw_ids)
board.update("upload.maximum_ram_size", ram_size)
def configure_network_flags(cpp_defines):
env.Append(CPPDEFINES=[
("PICO_CYW43_ARCH_THREADSAFE_BACKGROUND", 1),
("CYW43_LWIP", 0),
("LWIP_IPV4", 1),
("LWIP_IGMP", 1),
("LWIP_CHECKSUM_CTRL_PER_NETIF", 1)
])
if "PIO_FRAMEWORK_ARDUINO_ENABLE_IPV6" in cpp_defines:
env.Append(CPPDEFINES=[("LWIP_IPV6", 1)])
else:
env.Append(CPPDEFINES=[("LWIP_IPV6", 0)])
#
# Process configuration flags
#
@@ -246,6 +258,7 @@ if not "USE_TINYUSB" in cpp_defines:
)
# configure USB stuff
configure_usb_flags(cpp_defines)
configure_network_flags(cpp_defines)
# ensure LWIP headers are in path after any TINYUSB distributed versions, also PicoSDK USB path headers
env.Append(CPPPATH=[os.path.join(FRAMEWORK_DIR, "include")])
@@ -285,10 +298,11 @@ if variant != "":
os.path.join(FRAMEWORK_DIR, "variants", variant)
])
libs.append(
env.BuildLibrary(
os.path.join("$BUILD_DIR", "FrameworkArduinoVariant"),
os.path.join(FRAMEWORK_DIR, "variants", variant)))
# link variant's source files as object files into the binary.
# otherwise weak function overriding won't work in the linking stage.
env.BuildSources(
os.path.join("$BUILD_DIR", "FrameworkArduinoVariant"),
os.path.join(FRAMEWORK_DIR, "variants", variant))
libs.append(
env.BuildLibrary(