Skip to content

Commit 7868dde

Browse files
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.
1 parent 6a0cc90 commit 7868dde

File tree

7 files changed

+43
-22
lines changed

7 files changed

+43
-22
lines changed

cores/rp2040/main.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ void initVariant() __attribute__((weak));
4444
void initVariant() { }
4545

4646
// Optional 2nd core setup and loop
47+
bool core1_separate_stack __attribute__((weak)) = false;
4748
extern void setup1() __attribute__((weak));
4849
extern void loop1() __attribute__((weak));
4950
extern "C" void main1() {
@@ -132,7 +133,11 @@ extern "C" int main() {
132133
if (!__isFreeRTOS) {
133134
if (setup1 || loop1) {
134135
delay(1); // Needed to make Picoprobe upload start 2nd core
135-
multicore_launch_core1(main1);
136+
if (core1_separate_stack) {
137+
multicore_launch_core1_with_stack(main1, (uint32_t*)malloc(8192), 8192);
138+
} else {
139+
multicore_launch_core1(main1);
140+
}
136141
}
137142
setup();
138143
while (true) {

docs/bearssl-server-secure-class.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Similar to the `BearSSL::WiFiClientSecure` method, sets the receive and transmit
1313
Setting Server Certificates
1414
~~~~~~~~~~~~~~~~~~~~~~~~~~~
1515

16-
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.**
16+
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.**
1717

1818
This example command will generate a RSA 2048-bit key and certificate:
1919

docs/multicore.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,22 @@ not necessarily simultaneously!).
1616
See the ``Multicore.ino`` example in the ``rp2040`` example directory for a
1717
quick introduction.
1818

19+
Stack Sizes
20+
-----------
21+
22+
When the Pico is running in single core mode, core 0 has the full 8KB of stack
23+
space available to it. When using multicore ``setup1``/``loop1`` the 8KB is split
24+
into two 4K stacks, one per core. It is possible for core 0's stack to overwrite
25+
core 1's stack in this case, if you go beyond the 4K limitation.
26+
27+
To allocate a separate 8K stack for core 1, resulting in 8K stacks being available
28+
for both cores, simply define the following variable in your sketch and set it
29+
to ``true``:
30+
31+
.. code:: cpp
32+
33+
bool core1_separate_stack = true;
34+
1935
Pausing Cores
2036
-------------
2137

libraries/Joystick/examples/Joystick-AllFunctions/Joystick-AllFunctions.ino

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ void loop() {
2020
Joystick.button(i, true);
2121
delay(250);
2222
Joystick.button(i, false);
23-
delay(10); //we need a short delay here, sending packets with less than 1ms leads to packet loss!
23+
delay(10); // We need a short delay here, sending packets with less than 1ms leads to packet loss!
2424
}
25-
//alternativ with manual send:
25+
// Alternative with manual send:
2626
Joystick.useManualSend(true);
2727
Serial.println("Joystick buttons - manual send");
2828
for (uint8_t i = 1; i <= 32; i++) {
@@ -33,8 +33,8 @@ void loop() {
3333
}
3434
Joystick.useManualSend(false);
3535

36-
//iterate all joystick axis
37-
//Note: although you can use 0-1023 here (10bit), internally 8bits are used (-127 to 127)
36+
// Iterate all joystick axis
37+
// Note: although you can use 0-1023 here (10bit), internally 8bits are used (-127 to 127)
3838
Serial.println("Joystick X");
3939
for (uint16_t i = 0; i < 1023; i++) {
4040
Joystick.X(i);
@@ -71,8 +71,8 @@ void loop() {
7171
delay(20);
7272
} Joystick.hat(-1);
7373

74-
//use int8 mode for the axis.
75-
//Note: hat is not used differently.
74+
// Use int8 mode for the axis.
75+
// Note: hat is not used differently.
7676
Serial.println("Now all axis in 8bit mode, -127 to 127");
7777
Joystick.use8bit(true);
7878
Serial.println("Joystick X");

libraries/JoystickBLE/examples/BLEJoystick-AllFunctions/BLEJoystick-AllFunctions.ino

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ void loop() {
2020
JoystickBLE.button(i, true);
2121
delay(250);
2222
JoystickBLE.button(i, false);
23-
delay(10); //we need a short delay here, sending packets with less than 1ms leads to packet loss!
23+
delay(10); // We need a short delay here, sending packets with less than 1ms leads to packet loss!
2424
}
25-
//alternativ with manual send:
25+
// Alternative with manual send:
2626
JoystickBLE.useManualSend(true);
2727
Serial.println("Joystick buttons - manual send");
2828
for (uint8_t i = 1; i <= 32; i++) {
@@ -33,8 +33,8 @@ void loop() {
3333
}
3434
JoystickBLE.useManualSend(false);
3535

36-
//iterate all joystick axis
37-
//Note: although you can use 0-1023 here (10bit), internally 8bits are used (-127 to 127)
36+
// Iterate all joystick axis
37+
// Note: although you can use 0-1023 here (10bit), internally 8bits are used (-127 to 127)
3838
Serial.println("Joystick X");
3939
for (uint16_t i = 0; i < 1023; i++) {
4040
JoystickBLE.X(i);
@@ -71,8 +71,8 @@ void loop() {
7171
delay(20);
7272
} JoystickBLE.hat(-1);
7373

74-
//use int8 mode for the axis.
75-
//Note: hat is not used differently.
74+
// Use int8 mode for the axis.
75+
// Note: hat is not used differently.
7676
Serial.println("Now all axis in 8bit mode, -127 to 127");
7777
JoystickBLE.use8bit(true);
7878
Serial.println("Joystick X");

libraries/JoystickBT/examples/BTJoystick-AllFunctions/BTJoystick-AllFunctions.ino

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ void loop() {
2020
JoystickBT.button(i, true);
2121
delay(250);
2222
JoystickBT.button(i, false);
23-
delay(10); //we need a short delay here, sending packets with less than 1ms leads to packet loss!
23+
delay(10); // We need a short delay here, sending packets with less than 1ms leads to packet loss!
2424
}
25-
//alternativ with manual send:
25+
// Alternative with manual send:
2626
JoystickBT.useManualSend(true);
2727
Serial.println("Joystick buttons - manual send");
2828
for (uint8_t i = 1; i <= 32; i++) {
@@ -33,8 +33,8 @@ void loop() {
3333
}
3434
JoystickBT.useManualSend(false);
3535

36-
//iterate all joystick axis
37-
//Note: although you can use 0-1023 here (10bit), internally 8bits are used (-127 to 127)
36+
// Iterate all joystick axis
37+
// Note: although you can use 0-1023 here (10bit), internally 8bits are used (-127 to 127)
3838
Serial.println("Joystick X");
3939
for (uint16_t i = 0; i < 1023; i++) {
4040
JoystickBT.X(i);
@@ -71,8 +71,8 @@ void loop() {
7171
delay(20);
7272
} JoystickBT.hat(-1);
7373

74-
//use int8 mode for the axis.
75-
//Note: hat is not used differently.
74+
// Use int8 mode for the axis.
75+
// Note: hat is not used differently.
7676
Serial.println("Now all axis in 8bit mode, -127 to 127");
7777
JoystickBT.use8bit(true);
7878
Serial.println("Joystick X");

libraries/lwIP_w5500/src/utility/w5500.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ class Wiznet5500 {
267267
/**
268268
set the power mode of phy inside WIZCHIP. Refer to @ref PHYCFGR in W5500, @ref PHYSTATUS in
269269
W5200
270-
@param pmode Settig value of power down mode.
270+
@param pmode Setting value of power down mode.
271271
*/
272272
int8_t wizphy_setphypmode(uint8_t pmode);
273273

@@ -432,7 +432,7 @@ class Wiznet5500 {
432432
/* PHYCFGR register value */
433433
enum {
434434
PHYCFGR_RST = ~(1 << 7), //< For PHY reset, must operate AND mask.
435-
PHYCFGR_OPMD = (1 << 6), // Configre PHY with OPMDC value
435+
PHYCFGR_OPMD = (1 << 6), // Configure PHY with OPMDC value
436436
PHYCFGR_OPMDC_ALLA = (7 << 3),
437437
PHYCFGR_OPMDC_PDOWN = (6 << 3),
438438
PHYCFGR_OPMDC_NA = (5 << 3),

0 commit comments

Comments
 (0)