You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2021/02/24 16:03:39 UTC
[GitHub] [incubator-nuttx] yunkya2 opened a new pull request #2916: arm/rp2040: Raspberry Pi Pico SMP support
yunkya2 opened a new pull request #2916:
URL: https://github.com/apache/incubator-nuttx/pull/2916
## Summary
Added SMP support for Raspberry Pi Pico port.
## Impact
rp2040 only
## Testing
New configuration `raspberrypi-pico:smp` passes `ostest` and `smp`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] masayuki2009 merged pull request #2916: arm/rp2040: Raspberry Pi Pico SMP support
Posted by GitBox <gi...@apache.org>.
masayuki2009 merged pull request #2916:
URL: https://github.com/apache/incubator-nuttx/pull/2916
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] xiaoxiang781216 commented on pull request #2916: arm/rp2040: Raspberry Pi Pico SMP support
Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on pull request #2916:
URL: https://github.com/apache/incubator-nuttx/pull/2916#issuecomment-1001851968
You can follow the instruction here:
https://github.com/apache/incubator-nuttx/blob/master/boards/arm/rp2040/raspberrypi-pico/README.txt
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] patacongo commented on pull request #2916: arm/rp2040: Raspberry Pi Pico SMP support
Posted by GitBox <gi...@apache.org>.
patacongo commented on pull request #2916:
URL: https://github.com/apache/incubator-nuttx/pull/2916#issuecomment-785334871
One thing I was thinking about for SMP on the RP4020 is the caching. I asked earlier about this and was told that there some kind of caching or pre-fetch was supported. Then I wondered about how coherency is maintained. This is a really complex issue on Cortex-A.
Is there a single pre-fetch cache? Or separate caches for each CPU? If they are shared then there is no issue. If there are not, then how is coherency maintained if one CPU modifies data (or instructions) that is in the the cache of the other?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] yunkya2 commented on pull request #2916: arm/rp2040: Raspberry Pi Pico SMP support
Posted by GitBox <gi...@apache.org>.
yunkya2 commented on pull request #2916:
URL: https://github.com/apache/incubator-nuttx/pull/2916#issuecomment-1002441758
As the last line of your attached screenshot shows, you need to set the environment variable PICO_SDK_PATH before NuttX build to specify the directory where Raspberry Pi Pico SDK exists.
Please follow the instructions written in README.txt
> 1. Download Raspberry Pi Pico SDK
>
> $ git clone -b 1.1.2 https://github.com/raspberrypi/pico-sdk.git
>
> 2. Set PICO_SDK_PATH environment variable
>
> $ export PICO_SDK_PATH=<absolute_path_to_pico-sdk_directory>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] igordrago commented on pull request #2916: arm/rp2040: Raspberry Pi Pico SMP support
Posted by GitBox <gi...@apache.org>.
igordrago commented on pull request #2916:
URL: https://github.com/apache/incubator-nuttx/pull/2916#issuecomment-1001845625
Hi,
new on the block, could you give me directions in order to have the Nuttx running on Pi Pico?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] igordrago edited a comment on pull request #2916: arm/rp2040: Raspberry Pi Pico SMP support
Posted by GitBox <gi...@apache.org>.
igordrago edited a comment on pull request #2916:
URL: https://github.com/apache/incubator-nuttx/pull/2916#issuecomment-1002173951
Xiao, thank you very much, as i m using a new linux installation, could you suggest any make implementation for the compilation do work? How about the compiler?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] igordrago commented on pull request #2916: arm/rp2040: Raspberry Pi Pico SMP support
Posted by GitBox <gi...@apache.org>.
igordrago commented on pull request #2916:
URL: https://github.com/apache/incubator-nuttx/pull/2916#issuecomment-1002706965
I used sudo make instead of make, which caused the issue. Now worked. Tks for the help!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] igordrago commented on pull request #2916: arm/rp2040: Raspberry Pi Pico SMP support
Posted by GitBox <gi...@apache.org>.
igordrago commented on pull request #2916:
URL: https://github.com/apache/incubator-nuttx/pull/2916#issuecomment-1002676336

Yes I just did, the env variable is set
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] igordrago commented on pull request #2916: arm/rp2040: Raspberry Pi Pico SMP support
Posted by GitBox <gi...@apache.org>.
igordrago commented on pull request #2916:
URL: https://github.com/apache/incubator-nuttx/pull/2916#issuecomment-1002267525

Hi,
the compilation proccess appeared to be ok, no errors by following the instructios, however the output file was nuttx instead of nuttx.uf2. Copying nuttx to the Pico nothing happens.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] masayuki2009 commented on a change in pull request #2916: arm/rp2040: Raspberry Pi Pico SMP support
Posted by GitBox <gi...@apache.org>.
masayuki2009 commented on a change in pull request #2916:
URL: https://github.com/apache/incubator-nuttx/pull/2916#discussion_r582344410
##########
File path: arch/arm/src/rp2040/rp2040_cpupause.c
##########
@@ -0,0 +1,437 @@
+/****************************************************************************
+ * arch/arm/src/rp2040/rp2040_cpupause.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <assert.h>
+#include <debug.h>
+#include <string.h>
+#include <stdio.h>
+
+#include <nuttx/arch.h>
+#include <nuttx/spinlock.h>
+#include <nuttx/sched_note.h>
+
+#include "arm_arch.h"
+#include "sched/sched.h"
+#include "arm_internal.h"
+#include "hardware/rp2040_sio.h"
+
+#ifdef CONFIG_SMP
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#if 0
+#define DPRINTF(fmt, args...) llinfo(fmt, ##args)
+#else
+#define DPRINTF(fmt, args...) do {} while (0)
+#endif
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/* These spinlocks are used in the SMP configuration in order to implement
+ * up_cpu_pause(). The protocol for CPUn to pause CPUm is as follows
+ *
+ * 1. The up_cpu_pause() implementation on CPUn locks both g_cpu_wait[m]
+ * and g_cpu_paused[m]. CPUn then waits spinning on g_cpu_paused[m].
+ * 2. CPUm receives the interrupt it (1) unlocks g_cpu_paused[m] and
+ * (2) locks g_cpu_wait[m]. The first unblocks CPUn and the second
+ * blocks CPUm in the interrupt handler.
+ *
+ * When CPUm resumes, CPUn unlocks g_cpu_wait[m] and the interrupt handler
+ * on CPUm continues. CPUm must, of course, also then unlock g_cpu_wait[m]
+ * so that it will be ready for the next pause operation.
+ */
+
+static volatile spinlock_t g_cpu_wait[CONFIG_SMP_NCPUS];
+static volatile spinlock_t g_cpu_paused[CONFIG_SMP_NCPUS];
+
+/****************************************************************************
+ * Name: rp2040_handle_irqreq
+ *
+ * Description:
+ * If an irq handling request is found on cpu, call up_enable_irq() or
+ * up_disable_irq().
+ *
+ * Input Parameters:
+ * irqreq - The IRQ number to be handled (>0 : enable / <0 : disable)
+ *
+ ****************************************************************************/
+
+static void rp2040_handle_irqreq(int irqreq)
Review comment:
@gustavonihei
Actually, it is guarded on the caller side.
```
if (irqreq != 0)
{
/* Handle IRQ enable/disable request */
rp2040_handle_irqreq(irqreq);
return OK;
}
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] igordrago commented on pull request #2916: arm/rp2040: Raspberry Pi Pico SMP support
Posted by GitBox <gi...@apache.org>.
igordrago commented on pull request #2916:
URL: https://github.com/apache/incubator-nuttx/pull/2916#issuecomment-1002173951
Xiao, thank you very much, as i m using a new linux installation, could you suggest any make implementation for the compilation do work?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] btashton commented on pull request #2916: arm/rp2040: Raspberry Pi Pico SMP support
Posted by GitBox <gi...@apache.org>.
btashton commented on pull request #2916:
URL: https://github.com/apache/incubator-nuttx/pull/2916#issuecomment-785347296
The XIP controller handles this for us on this chip:
"""
The cache is 16 kB, two way set-associative, 1 cycle hit. It is internal to
the XIP subsystem, and only affects accesses to
XIP flash, so software does not have to consider cache coherence, unless
performing flash programming operations.
"""
--Brennan
On Wed, Feb 24, 2021, 11:58 AM patacongo <no...@github.com> wrote:
> One thing I was thinking about for SMP on the RP4020 is the caching. I
> asked earlier about this and was told that there some kind of caching or
> pre-fetch was supported. Then I wondered about how coherency is maintained.
> This is a really complex issue on Cortex-A.
>
> Is there a single pre-fetch cache? Or separate caches for each CPU? If
> they are shared then there is no issue. If there are not, then how is
> coherency maintained if one CPU modifies data (or instructions) that is in
> the the cache of the other?
>
> —
> You are receiving this because you are subscribed to this thread.
> Reply to this email directly, view it on GitHub
> <https://github.com/apache/incubator-nuttx/pull/2916#issuecomment-785334871>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AABKJPNOX3JIME5IPKZDSWLTAVK6ZANCNFSM4YEY2BVQ>
> .
>
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] xiaoxiang781216 commented on pull request #2916: arm/rp2040: Raspberry Pi Pico SMP support
Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on pull request #2916:
URL: https://github.com/apache/incubator-nuttx/pull/2916#issuecomment-1002211912
gmake should work, you can follow the setup instruction here:
https://nuttx.apache.org/docs/latest/quickstart/install.html
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] masayuki2009 edited a comment on pull request #2916: arm/rp2040: Raspberry Pi Pico SMP support
Posted by GitBox <gi...@apache.org>.
masayuki2009 edited a comment on pull request #2916:
URL: https://github.com/apache/incubator-nuttx/pull/2916#issuecomment-785415866
@patacongo
It seems that rp2040 architecture is almost same as lc823450. Both have dual CPUs without CPU cache but have XIP cache for QSPI, so there is no cache coherency issues.
As @btashton commented, rp2040 has a 16KB XIP cache that is used for instruction cache if the code is fetched from an external QSPI flash. Also, rp2040 has 64KB x 4banks + 4KB x 2 banks SRAM (total 264KB) that is not big but we can run NuttX on SRAM as well (see the nshsram configuration). Of course, the SRAM size is limited, it would be better to use QSPI for code and assign code to SRAM for a critical part such as interrupt handlers.
The big difference between rp2040 and lc823450 is that rp2040 has word-striped SRAM.
The datasheet says
```
2.6.2 SRAM
...
SRAM is mapped to system addresses starting at 0x20000000.
The first 256kB address region is word-striped across the four larger banks,
which provides a significant memory parallelism benefits for most use cases.
```
I think this is an amazing feature to improve performance when both CPUs access the SRAM.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] masayuki2009 commented on pull request #2916: arm/rp2040: Raspberry Pi Pico SMP support
Posted by GitBox <gi...@apache.org>.
masayuki2009 commented on pull request #2916:
URL: https://github.com/apache/incubator-nuttx/pull/2916#issuecomment-785415866
@patacongo
It seems that rp2040 architecture is almost same as lc823450. Both have dual CPUs without CPU cache but have XIP cache for QSPI, so there is no cache coherency issues.
As @btashton commented, rp2040 has a 16KB XIP cache that is used for instruction cache if the code is fetched from an external QSPI flash. Also, rp2040 has 64KB x 4banks + 4KB x 2 banks SRAM (total 264KB) that is not big but we can run NuttX on SRAM as well (see the nshsram configuration). Of course, the SRAM size is limited, it would be better to use QSPI for code and assign code to SRAM for a critical part such as interrupt handlers.
The big difference between rp2040 and lc823450 is that rp2040 has word-striped SRAM.
The datasheet says
```
2.6.2 SRAM
...
SRAM is mapped to system addresses starting at 0x20000000.
The first 256kB address region is word-striped across the four larger banks,
which provides a significant memory parallelism benefits for most use cases.
```
I think this is amazing to improve performance when both CPUs access the SRAM.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] masayuki2009 commented on pull request #2916: arm/rp2040: Raspberry Pi Pico SMP support
Posted by GitBox <gi...@apache.org>.
masayuki2009 commented on pull request #2916:
URL: https://github.com/apache/incubator-nuttx/pull/2916#issuecomment-785423137
@yunkya2
It works!
```
sh> uname -a
NuttX 3.6.1 318f7cef9b Feb 25 2021 07:06:35 arm raspberrypi-pico
nsh> ps
PID CPU PRI POLICY TYPE NPX STATE EVENT SIGMASK STACK COMMAND
0 0 0 FIFO Kthread N-- Assigned 00000000 001024 CPU0 IDLE
1 1 0 FIFO Kthread N-- Running 00000000 002052 CPU1 IDLE
3 0 100 RR Task --- Running 00000000 002036 init
nsh> free
total used free largest
Umem: 264000 10736 253264 234688
nsh> smp
Main[0]: Running on CPU0
Main[0]: Initializing barrier
Thread[1]: Started
...
Thread[8]: Now running on CPU1
Main[0]: Now running on CPU0
Main[0]: Thread 5 completed with result=0
Main[0]: Thread 6 completed with result=0
Main[0]: Thread 7 completed with result=0
Main[0]: Thread 8 completed with result=0
nsh> ostest
stdio_test: write fd=1
stdio_test: Standard I/O Check: printf
stdio_test: write fd=2
...
Final memory usage:
VARIABLE BEFORE AFTER
======== ======== ========
arena 40740 40740
ordblks 4 4
mxordblk 394c0 374a0
uordblks 5450 75a0
fordblks 3b2f0 391a0
user_main: Exiting
ostest_main: Exiting with status 0
nsh>
````
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #2916: arm/rp2040: Raspberry Pi Pico SMP support
Posted by GitBox <gi...@apache.org>.
gustavonihei commented on a change in pull request #2916:
URL: https://github.com/apache/incubator-nuttx/pull/2916#discussion_r582134246
##########
File path: arch/arm/src/rp2040/rp2040_cpupause.c
##########
@@ -0,0 +1,437 @@
+/****************************************************************************
+ * arch/arm/src/rp2040/rp2040_cpupause.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <assert.h>
+#include <debug.h>
+#include <string.h>
+#include <stdio.h>
+
+#include <nuttx/arch.h>
+#include <nuttx/spinlock.h>
+#include <nuttx/sched_note.h>
+
+#include "arm_arch.h"
+#include "sched/sched.h"
+#include "arm_internal.h"
+#include "hardware/rp2040_sio.h"
+
+#ifdef CONFIG_SMP
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#if 0
+#define DPRINTF(fmt, args...) llinfo(fmt, ##args)
+#else
+#define DPRINTF(fmt, args...) do {} while (0)
+#endif
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/* These spinlocks are used in the SMP configuration in order to implement
+ * up_cpu_pause(). The protocol for CPUn to pause CPUm is as follows
+ *
+ * 1. The up_cpu_pause() implementation on CPUn locks both g_cpu_wait[m]
+ * and g_cpu_paused[m]. CPUn then waits spinning on g_cpu_paused[m].
+ * 2. CPUm receives the interrupt it (1) unlocks g_cpu_paused[m] and
+ * (2) locks g_cpu_wait[m]. The first unblocks CPUn and the second
+ * blocks CPUm in the interrupt handler.
+ *
+ * When CPUm resumes, CPUn unlocks g_cpu_wait[m] and the interrupt handler
+ * on CPUm continues. CPUm must, of course, also then unlock g_cpu_wait[m]
+ * so that it will be ready for the next pause operation.
+ */
+
+static volatile spinlock_t g_cpu_wait[CONFIG_SMP_NCPUS];
+static volatile spinlock_t g_cpu_paused[CONFIG_SMP_NCPUS];
+
+/****************************************************************************
+ * Name: rp2040_handle_irqreq
+ *
+ * Description:
+ * If an irq handling request is found on cpu, call up_enable_irq() or
+ * up_disable_irq().
+ *
+ * Input Parameters:
+ * irqreq - The IRQ number to be handled (>0 : enable / <0 : disable)
+ *
+ ****************************************************************************/
+
+static void rp2040_handle_irqreq(int irqreq)
Review comment:
If `irqreq == 0` is not an acceptable parameter, we should guard it with an assertion.
Otherwise, `up_disable_irq` will the invoked with a `-0` argument.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org