Allow full 8K stack for both cores, optionally (#1750)
Fixes #1749 Defining a global true `bool core1_separate_stack = true` will separate the two cores' stacks, with core 0 using the scratch RAM while core 1 will use 8K from the heap.
This commit is contained in:
parent
6a0cc90a4d
commit
7868ddee42
7 changed files with 43 additions and 22 deletions
|
|
@ -44,6 +44,7 @@ void initVariant() __attribute__((weak));
|
||||||
void initVariant() { }
|
void initVariant() { }
|
||||||
|
|
||||||
// Optional 2nd core setup and loop
|
// Optional 2nd core setup and loop
|
||||||
|
bool core1_separate_stack __attribute__((weak)) = false;
|
||||||
extern void setup1() __attribute__((weak));
|
extern void setup1() __attribute__((weak));
|
||||||
extern void loop1() __attribute__((weak));
|
extern void loop1() __attribute__((weak));
|
||||||
extern "C" void main1() {
|
extern "C" void main1() {
|
||||||
|
|
@ -132,8 +133,12 @@ extern "C" int main() {
|
||||||
if (!__isFreeRTOS) {
|
if (!__isFreeRTOS) {
|
||||||
if (setup1 || loop1) {
|
if (setup1 || loop1) {
|
||||||
delay(1); // Needed to make Picoprobe upload start 2nd core
|
delay(1); // Needed to make Picoprobe upload start 2nd core
|
||||||
|
if (core1_separate_stack) {
|
||||||
|
multicore_launch_core1_with_stack(main1, (uint32_t*)malloc(8192), 8192);
|
||||||
|
} else {
|
||||||
multicore_launch_core1(main1);
|
multicore_launch_core1(main1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
setup();
|
setup();
|
||||||
while (true) {
|
while (true) {
|
||||||
loop();
|
loop();
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ Similar to the `BearSSL::WiFiClientSecure` method, sets the receive and transmit
|
||||||
Setting Server Certificates
|
Setting Server Certificates
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
TLS servers require a certificate identifying itself and containing its public key, and a private key they will use to encrypt information with. The application author is responsible for generating this certificate and key, either using a self-signed generator or using a commercial certification authority. **Do not re-use the certificates included in the examples provided.**
|
TLS servers require a certificate identifying itself and containing its public key, and a private key they will use to encrypt information with. The application author is responsible for generating this certificate and key, either using a self-signed generator or using a commercial certification authority. **Do not reuse the certificates included in the examples provided.**
|
||||||
|
|
||||||
This example command will generate a RSA 2048-bit key and certificate:
|
This example command will generate a RSA 2048-bit key and certificate:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,22 @@ not necessarily simultaneously!).
|
||||||
See the ``Multicore.ino`` example in the ``rp2040`` example directory for a
|
See the ``Multicore.ino`` example in the ``rp2040`` example directory for a
|
||||||
quick introduction.
|
quick introduction.
|
||||||
|
|
||||||
|
Stack Sizes
|
||||||
|
-----------
|
||||||
|
|
||||||
|
When the Pico is running in single core mode, core 0 has the full 8KB of stack
|
||||||
|
space available to it. When using multicore ``setup1``/``loop1`` the 8KB is split
|
||||||
|
into two 4K stacks, one per core. It is possible for core 0's stack to overwrite
|
||||||
|
core 1's stack in this case, if you go beyond the 4K limitation.
|
||||||
|
|
||||||
|
To allocate a separate 8K stack for core 1, resulting in 8K stacks being available
|
||||||
|
for both cores, simply define the following variable in your sketch and set it
|
||||||
|
to ``true``:
|
||||||
|
|
||||||
|
.. code:: cpp
|
||||||
|
|
||||||
|
bool core1_separate_stack = true;
|
||||||
|
|
||||||
Pausing Cores
|
Pausing Cores
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,9 @@ void loop() {
|
||||||
Joystick.button(i, true);
|
Joystick.button(i, true);
|
||||||
delay(250);
|
delay(250);
|
||||||
Joystick.button(i, false);
|
Joystick.button(i, false);
|
||||||
delay(10); //we need a short delay here, sending packets with less than 1ms leads to packet loss!
|
delay(10); // We need a short delay here, sending packets with less than 1ms leads to packet loss!
|
||||||
}
|
}
|
||||||
//alternativ with manual send:
|
// Alternative with manual send:
|
||||||
Joystick.useManualSend(true);
|
Joystick.useManualSend(true);
|
||||||
Serial.println("Joystick buttons - manual send");
|
Serial.println("Joystick buttons - manual send");
|
||||||
for (uint8_t i = 1; i <= 32; i++) {
|
for (uint8_t i = 1; i <= 32; i++) {
|
||||||
|
|
@ -33,8 +33,8 @@ void loop() {
|
||||||
}
|
}
|
||||||
Joystick.useManualSend(false);
|
Joystick.useManualSend(false);
|
||||||
|
|
||||||
//iterate all joystick axis
|
// Iterate all joystick axis
|
||||||
//Note: although you can use 0-1023 here (10bit), internally 8bits are used (-127 to 127)
|
// Note: although you can use 0-1023 here (10bit), internally 8bits are used (-127 to 127)
|
||||||
Serial.println("Joystick X");
|
Serial.println("Joystick X");
|
||||||
for (uint16_t i = 0; i < 1023; i++) {
|
for (uint16_t i = 0; i < 1023; i++) {
|
||||||
Joystick.X(i);
|
Joystick.X(i);
|
||||||
|
|
@ -71,8 +71,8 @@ void loop() {
|
||||||
delay(20);
|
delay(20);
|
||||||
} Joystick.hat(-1);
|
} Joystick.hat(-1);
|
||||||
|
|
||||||
//use int8 mode for the axis.
|
// Use int8 mode for the axis.
|
||||||
//Note: hat is not used differently.
|
// Note: hat is not used differently.
|
||||||
Serial.println("Now all axis in 8bit mode, -127 to 127");
|
Serial.println("Now all axis in 8bit mode, -127 to 127");
|
||||||
Joystick.use8bit(true);
|
Joystick.use8bit(true);
|
||||||
Serial.println("Joystick X");
|
Serial.println("Joystick X");
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,9 @@ void loop() {
|
||||||
JoystickBLE.button(i, true);
|
JoystickBLE.button(i, true);
|
||||||
delay(250);
|
delay(250);
|
||||||
JoystickBLE.button(i, false);
|
JoystickBLE.button(i, false);
|
||||||
delay(10); //we need a short delay here, sending packets with less than 1ms leads to packet loss!
|
delay(10); // We need a short delay here, sending packets with less than 1ms leads to packet loss!
|
||||||
}
|
}
|
||||||
//alternativ with manual send:
|
// Alternative with manual send:
|
||||||
JoystickBLE.useManualSend(true);
|
JoystickBLE.useManualSend(true);
|
||||||
Serial.println("Joystick buttons - manual send");
|
Serial.println("Joystick buttons - manual send");
|
||||||
for (uint8_t i = 1; i <= 32; i++) {
|
for (uint8_t i = 1; i <= 32; i++) {
|
||||||
|
|
@ -33,8 +33,8 @@ void loop() {
|
||||||
}
|
}
|
||||||
JoystickBLE.useManualSend(false);
|
JoystickBLE.useManualSend(false);
|
||||||
|
|
||||||
//iterate all joystick axis
|
// Iterate all joystick axis
|
||||||
//Note: although you can use 0-1023 here (10bit), internally 8bits are used (-127 to 127)
|
// Note: although you can use 0-1023 here (10bit), internally 8bits are used (-127 to 127)
|
||||||
Serial.println("Joystick X");
|
Serial.println("Joystick X");
|
||||||
for (uint16_t i = 0; i < 1023; i++) {
|
for (uint16_t i = 0; i < 1023; i++) {
|
||||||
JoystickBLE.X(i);
|
JoystickBLE.X(i);
|
||||||
|
|
@ -71,8 +71,8 @@ void loop() {
|
||||||
delay(20);
|
delay(20);
|
||||||
} JoystickBLE.hat(-1);
|
} JoystickBLE.hat(-1);
|
||||||
|
|
||||||
//use int8 mode for the axis.
|
// Use int8 mode for the axis.
|
||||||
//Note: hat is not used differently.
|
// Note: hat is not used differently.
|
||||||
Serial.println("Now all axis in 8bit mode, -127 to 127");
|
Serial.println("Now all axis in 8bit mode, -127 to 127");
|
||||||
JoystickBLE.use8bit(true);
|
JoystickBLE.use8bit(true);
|
||||||
Serial.println("Joystick X");
|
Serial.println("Joystick X");
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,9 @@ void loop() {
|
||||||
JoystickBT.button(i, true);
|
JoystickBT.button(i, true);
|
||||||
delay(250);
|
delay(250);
|
||||||
JoystickBT.button(i, false);
|
JoystickBT.button(i, false);
|
||||||
delay(10); //we need a short delay here, sending packets with less than 1ms leads to packet loss!
|
delay(10); // We need a short delay here, sending packets with less than 1ms leads to packet loss!
|
||||||
}
|
}
|
||||||
//alternativ with manual send:
|
// Alternative with manual send:
|
||||||
JoystickBT.useManualSend(true);
|
JoystickBT.useManualSend(true);
|
||||||
Serial.println("Joystick buttons - manual send");
|
Serial.println("Joystick buttons - manual send");
|
||||||
for (uint8_t i = 1; i <= 32; i++) {
|
for (uint8_t i = 1; i <= 32; i++) {
|
||||||
|
|
@ -33,8 +33,8 @@ void loop() {
|
||||||
}
|
}
|
||||||
JoystickBT.useManualSend(false);
|
JoystickBT.useManualSend(false);
|
||||||
|
|
||||||
//iterate all joystick axis
|
// Iterate all joystick axis
|
||||||
//Note: although you can use 0-1023 here (10bit), internally 8bits are used (-127 to 127)
|
// Note: although you can use 0-1023 here (10bit), internally 8bits are used (-127 to 127)
|
||||||
Serial.println("Joystick X");
|
Serial.println("Joystick X");
|
||||||
for (uint16_t i = 0; i < 1023; i++) {
|
for (uint16_t i = 0; i < 1023; i++) {
|
||||||
JoystickBT.X(i);
|
JoystickBT.X(i);
|
||||||
|
|
@ -71,8 +71,8 @@ void loop() {
|
||||||
delay(20);
|
delay(20);
|
||||||
} JoystickBT.hat(-1);
|
} JoystickBT.hat(-1);
|
||||||
|
|
||||||
//use int8 mode for the axis.
|
// Use int8 mode for the axis.
|
||||||
//Note: hat is not used differently.
|
// Note: hat is not used differently.
|
||||||
Serial.println("Now all axis in 8bit mode, -127 to 127");
|
Serial.println("Now all axis in 8bit mode, -127 to 127");
|
||||||
JoystickBT.use8bit(true);
|
JoystickBT.use8bit(true);
|
||||||
Serial.println("Joystick X");
|
Serial.println("Joystick X");
|
||||||
|
|
|
||||||
|
|
@ -267,7 +267,7 @@ private:
|
||||||
/**
|
/**
|
||||||
set the power mode of phy inside WIZCHIP. Refer to @ref PHYCFGR in W5500, @ref PHYSTATUS in
|
set the power mode of phy inside WIZCHIP. Refer to @ref PHYCFGR in W5500, @ref PHYSTATUS in
|
||||||
W5200
|
W5200
|
||||||
@param pmode Settig value of power down mode.
|
@param pmode Setting value of power down mode.
|
||||||
*/
|
*/
|
||||||
int8_t wizphy_setphypmode(uint8_t pmode);
|
int8_t wizphy_setphypmode(uint8_t pmode);
|
||||||
|
|
||||||
|
|
@ -432,7 +432,7 @@ private:
|
||||||
/* PHYCFGR register value */
|
/* PHYCFGR register value */
|
||||||
enum {
|
enum {
|
||||||
PHYCFGR_RST = ~(1 << 7), //< For PHY reset, must operate AND mask.
|
PHYCFGR_RST = ~(1 << 7), //< For PHY reset, must operate AND mask.
|
||||||
PHYCFGR_OPMD = (1 << 6), // Configre PHY with OPMDC value
|
PHYCFGR_OPMD = (1 << 6), // Configure PHY with OPMDC value
|
||||||
PHYCFGR_OPMDC_ALLA = (7 << 3),
|
PHYCFGR_OPMDC_ALLA = (7 << 3),
|
||||||
PHYCFGR_OPMDC_PDOWN = (6 << 3),
|
PHYCFGR_OPMDC_PDOWN = (6 << 3),
|
||||||
PHYCFGR_OPMDC_NA = (5 << 3),
|
PHYCFGR_OPMDC_NA = (5 << 3),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue