Skip to content

Commit ead0728

Browse files
authored
Adds new Challenger WiFi6/BLE5 board to the mix. (#1595)
1 parent 14eb8d3 commit ead0728

File tree

9 files changed

+622
-0
lines changed

9 files changed

+622
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ Read the [Contributing Guide](https://github.com/earlephilhower/arduino-pico/blo
3636
* ExtremeElectronics RC2040
3737
* Invector Labs Challenger RP2040 WiFi
3838
* Invector Labs Challenger RP2040 WiFi/BLE
39+
* Invector Labs Challenger RP2040 WiFi6/BLE
3940
* Invector Labs Challenger NB RP2040 WiFi
4041
* Invector Labs Challenger RP2040 LTE
4142
* Invector Labs Challenger RP2040 LoRa

boards.txt

Lines changed: 247 additions & 0 deletions
Large diffs are not rendered by default.

package/package_pico_index.template.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@
113113
{
114114
"name": "iLabs Challenger 2040 WiFi/BLE"
115115
},
116+
{
117+
"name": "iLabs Challenger 2040 WiFi6/BLE"
118+
},
116119
{
117120
"name": "iLabs Challenger NB 2040 WiFi"
118121
},
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"build": {
3+
"arduino": {
4+
"earlephilhower": {
5+
"boot2_source": "boot2_w25q080_2_padded_checksum.S",
6+
"usb_vid": "0x2E8A",
7+
"usb_pid": "0x105F"
8+
}
9+
},
10+
"core": "earlephilhower",
11+
"cpu": "cortex-m0plus",
12+
"extra_flags": "-D ARDUINO_CHALLENGER_2040_WIFI6_BLE_RP2040 -DARDUINO_ARCH_RP2040 -DUSBD_MAX_POWER_MA=500 -DWIFIESPAT2",
13+
"f_cpu": "133000000L",
14+
"hwids": [
15+
[
16+
"0x2E8A",
17+
"0x00C0"
18+
],
19+
[
20+
"0x2E8A",
21+
"0x105F"
22+
]
23+
],
24+
"mcu": "rp2040",
25+
"variant": "challenger_2040_wifi6_ble"
26+
},
27+
"debug": {
28+
"jlink_device": "RP2040_M0_0",
29+
"openocd_target": "rp2040.cfg",
30+
"svd_path": "rp2040.svd"
31+
},
32+
"frameworks": [
33+
"arduino"
34+
],
35+
"name": "Challenger 2040 WiFi6/BLE",
36+
"upload": {
37+
"maximum_ram_size": 270336,
38+
"maximum_size": 8388608,
39+
"require_upload_port": true,
40+
"native_usb": true,
41+
"use_1200bps_touch": true,
42+
"wait_for_upload_port": false,
43+
"protocol": "picotool",
44+
"protocols": [
45+
"blackmagic",
46+
"cmsis-dap",
47+
"jlink",
48+
"raspberrypi-swd",
49+
"picotool",
50+
"picoprobe",
51+
"pico-debug"
52+
]
53+
},
54+
"url": "https://www.raspberrypi.org/products/raspberry-pi-pico/",
55+
"vendor": "iLabs"
56+
}

tools/makeboards.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ def MakeBoardJSON(name, vendor_name, product_name, vid, pid, pwr, boarddefine, f
388388
MakeBoard("challenger_2040_subghz", "iLabs", "Challenger 2040 SubGHz", "0x2e8a", "0x1032", 250, "CHALLENGER_2040_SUBGHZ_RP2040", 8, "boot2_w25q080_2_padded_checksum")
389389
MakeBoard("challenger_2040_wifi", "iLabs", "Challenger 2040 WiFi", "0x2e8a", "0x1006", 250, "CHALLENGER_2040_WIFI_RP2040", 8, "boot2_w25q080_2_padded_checksum", ["WIFIESPAT2"])
390390
MakeBoard("challenger_2040_wifi_ble", "iLabs", "Challenger 2040 WiFi/BLE", "0x2e8a", "0x102C", 500, "CHALLENGER_2040_WIFI_BLE_RP2040", 8, "boot2_w25q080_2_padded_checksum", ["WIFIESPAT2"])
391+
MakeBoard("challenger_2040_wifi6_ble", "iLabs", "Challenger 2040 WiFi6/BLE", "0x2e8a", "0x105F", 500, "CHALLENGER_2040_WIFI6_BLE_RP2040", 8, "boot2_w25q080_2_padded_checksum", ["WIFIESPAT2"])
391392
MakeBoard("challenger_nb_2040_wifi", "iLabs", "Challenger NB 2040 WiFi", "0x2e8a", "0x100d", 500, "CHALLENGER_NB_2040_WIFI_RP2040", 8, "boot2_w25q080_2_padded_checksum", ["WIFIESPAT2"])
392393
MakeBoard("challenger_2040_sdrtc", "iLabs", "Challenger 2040 SD/RTC", "0x2e8a", "0x102d", 250, "CHALLENGER_2040_SDRTC_RP2040", 8, "boot2_w25q080_2_padded_checksum")
393394
MakeBoard("challenger_2040_nfc", "iLabs", "Challenger 2040 NFC", "0x2e8a", "0x1036", 250, "CHALLENGER_2040_NFC_RP2040", 8, "boot2_w25q080_2_padded_checksum")
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
/*
2+
ESP8285/ESP32C3 helper class for the Challenger RP2040 WiFi enabled boards
3+
4+
Copyright (c) 2021,2022 P. Oldberg <[email protected]>
5+
6+
This library is free software; you can redistribute it and/or
7+
modify it under the terms of the GNU Lesser General Public
8+
License as published by the Free Software Foundation; either
9+
version 2.1 of the License, or (at your option) any later version.
10+
11+
This library is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
Lesser General Public License for more details.
15+
16+
You should have received a copy of the GNU Lesser General Public
17+
License along with this library; if not, write to the Free Software
18+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19+
*/
20+
21+
#include <Arduino.h>
22+
#include <ChallengerWiFi.h>
23+
24+
Challenger2040WiFiClass::Challenger2040WiFiClass(HardwareSerial* serial) {
25+
_serial = serial;
26+
27+
pinMode(PIN_ESP_RST, OUTPUT);
28+
digitalWrite(PIN_ESP_RST, LOW); // Hold ESP in reset
29+
pinMode(PIN_ESP_MODE, OUTPUT);
30+
digitalWrite(PIN_ESP_MODE, HIGH); // Prepare for normal start
31+
32+
pinMode(D15, OUTPUT);
33+
digitalWrite(D15, HIGH); // This is to correct for the
34+
// patched PCB.
35+
}
36+
37+
// Do a HW reset by applying a low pulse to the reset line for 1mSec
38+
void Challenger2040WiFiClass::doHWReset() {
39+
pinMode(D15, OUTPUT);
40+
digitalWrite(D15, HIGH); // This is to correct for the
41+
delay(1);
42+
digitalWrite(PIN_ESP_RST, LOW); // Hold ESP in reset
43+
delay(1);
44+
digitalWrite(PIN_ESP_RST, HIGH); // Release ESP reset
45+
}
46+
47+
// Set the mode flag high to indicate normal run operation and do a HW
48+
// reset.
49+
void Challenger2040WiFiClass::runReset() { // Prepare ESP for normal op
50+
digitalWrite(PIN_ESP_MODE, HIGH); // Prepare for normal start
51+
doHWReset();
52+
}
53+
54+
// Set the mode flag low to indicate flash operation and do a HW
55+
// reset.
56+
void Challenger2040WiFiClass::flashReset() { // Prepare ESP for flashing
57+
digitalWrite(PIN_ESP_MODE, LOW); // Prepare for normal start
58+
doHWReset();
59+
}
60+
61+
// Wait for the modem to reply with a "ready" prompt. This can be done
62+
// after a sw or hw reset have been performed to ensure that the AT
63+
// interpreter is up and running.
64+
bool Challenger2040WiFiClass::waitForReady() {
65+
int timeout = 20; // Aprox max 2 sec
66+
67+
_serial->setTimeout(100);
68+
String rdy = _serial->readStringUntil('\n');
69+
while (!rdy.startsWith("ready") && timeout--) {
70+
rdy = _serial->readStringUntil('\n');
71+
}
72+
_serial->setTimeout(1000); // Reset default timeout to 1000
73+
if (timeout) {
74+
return true;
75+
}
76+
return false;
77+
}
78+
79+
// Reset the ESP and wait for the "ready" prompt to be returned.
80+
bool Challenger2040WiFiClass::reset() {
81+
runReset();
82+
_serial->begin(DEFAULT_ESP_BAUDRATE);
83+
return waitForReady();
84+
}
85+
86+
// Checks to see if the modem responds to the "AT" poll command.
87+
bool Challenger2040WiFiClass::isAlive() {
88+
int timeout = 100;
89+
90+
_serial->setTimeout(250);
91+
_serial->println(F("AT"));
92+
String rdy = _serial->readStringUntil('\n');
93+
while (!rdy.startsWith(F("OK")) && timeout--) {
94+
_serial->println(F("AT"));
95+
rdy = _serial->readStringUntil('\n');
96+
}
97+
_serial->setTimeout(1000);
98+
99+
if (timeout) {
100+
return true;
101+
}
102+
return false;
103+
}
104+
105+
// Change the baud rate of the ESP device as well as the local UART.
106+
// No checking is done on the input baud rate so the user must know what
107+
// baud rates are valid. The function ends by checking if the ESP is
108+
// reachable by doing an "AT" poll.
109+
bool Challenger2040WiFiClass::changeBaudRate(int baud) {
110+
_serial->print(F("AT+UART_CUR="));
111+
_serial->print(baud);
112+
_serial->println(F(",8,1,0,0"));
113+
delay(100);
114+
_serial->end();
115+
_serial->begin(baud);
116+
return isAlive();
117+
}
118+
119+
// This method should be called id the builtin object isn't needed any more
120+
// It basically just releases the UART pins for other use.
121+
void Challenger2040WiFiClass::release() {
122+
_serial->end();
123+
}
124+
125+
// We can assign a new hardware serial port to accommodate the ESP device here.
126+
// The function will release the previously used serial port and assign the
127+
// new port. The ESP will be left in a reset state ready to start normal
128+
// operation when exiting the function.
129+
// This function is useful for when using the PIO serial ports to communicate
130+
// with the ESP instead of the built in hardware serial port.
131+
void Challenger2040WiFiClass::setSerial(HardwareSerial* serial) {
132+
133+
release();
134+
_serial = serial;
135+
136+
pinMode(PIN_ESP_RST, OUTPUT);
137+
digitalWrite(PIN_ESP_RST, LOW); // Hold ESP in reset
138+
pinMode(PIN_ESP_MODE, OUTPUT);
139+
digitalWrite(PIN_ESP_MODE, HIGH); // Prepare for normal start
140+
}
141+
142+
// Return the current serial object
143+
HardwareSerial* Challenger2040WiFiClass::getSerial() {
144+
return _serial;
145+
}
146+
147+
Challenger2040WiFiClass Challenger2040WiFi;
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
ESP8285/ESP32C3 helper class for the Challenger RP2040 WiFi enabled boards
3+
4+
Copyright (c) 2021,2022 P. Oldberg <[email protected]>
5+
6+
This library is free software; you can redistribute it and/or
7+
modify it under the terms of the GNU Lesser General Public
8+
License as published by the Free Software Foundation; either
9+
version 2.1 of the License, or (at your option) any later version.
10+
11+
This library is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
Lesser General Public License for more details.
15+
16+
You should have received a copy of the GNU Lesser General Public
17+
License along with this library; if not, write to the Free Software
18+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19+
*/
20+
21+
#pragma once
22+
23+
#define DEFAULT_ESP32_BAUDRATE 115200
24+
#define DEFAULT_ESP_BAUDRATE DEFAULT_ESP32_BAUDRATE
25+
26+
class Challenger2040WiFiClass {
27+
public:
28+
Challenger2040WiFiClass(HardwareSerial* = &ESP_SERIAL_PORT);
29+
void doHWReset();
30+
void runReset();
31+
void flashReset();
32+
bool waitForReady();
33+
bool reset();
34+
bool isAlive();
35+
bool changeBaudRate(int);
36+
void release();
37+
void setSerial(HardwareSerial*);
38+
HardwareSerial* getSerial();
39+
private:
40+
HardwareSerial* _serial;
41+
};
42+
43+
extern Challenger2040WiFiClass Challenger2040WiFi;
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
ESP8285/ESP32C3 helper class for the Challenger RP2040 WiFi enabled boards
3+
4+
Copyright (c) 2021,2022 P. Oldberg <[email protected]>
5+
6+
This library is free software; you can redistribute it and/or
7+
modify it under the terms of the GNU Lesser General Public
8+
License as published by the Free Software Foundation; either
9+
version 2.1 of the License, or (at your option) any later version.
10+
11+
This library is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
Lesser General Public License for more details.
15+
16+
You should have received a copy of the GNU Lesser General Public
17+
License along with this library; if not, write to the Free Software
18+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19+
*/
20+
#include <Arduino.h>
21+
#include <ChallengerWiFi.h>
22+
23+
/**
24+
Just make sure we try to reset the ESP device before the user starts
25+
using the device.
26+
*/
27+
void initVariant() {
28+
Challenger2040WiFi.reset();
29+
}

0 commit comments

Comments
 (0)