linguini1 commented on PR #18861:
URL: https://github.com/apache/nuttx/pull/18861#issuecomment-4472268809

   Okay after reading through the examples, it seems the arm64 architecture 
makes the assumption that all arm64 chips can have their cores started the same 
way (done via `arm64_start_cpu`). I think (?) this assumption is broken for the 
RPi4B since Broadcom's proprietary firmware is loaded in at the start and does 
some initial setup (like probably spinning everything but CPU0), whereas the 
other arm64 devices NuttX supports are under full control of the NuttX kernel.
   
   My solution at the moment is just to add the spintable modification step in 
`arm64_start_cpu` like so:
   
   ```c
   #ifdef CONFIG_ARCH_CHIP_BCM2711
     /* According to the bcm2711.dtsi file in the Linux source tree [1], the
      * CPUs on the BCM2711 use a spin-table enable method and poll the
      * following addresses:
      *
      * CPU0: 0x000000d8 (BCM_MBOX_CLR06)
      * CPU1: 0x000000e0 (BCM_MBOX_CLR08)
      * CPU2: 0x000000e8 (BCM_MBOX_CLR10)
      * CPU3: 0x000000f0 (BCM_MBOX_CLR12)
      *
      * Some kernel docs about booting [2] have a handy explanation of how this
      * works:
      *
      * "polling their cpu-release-addr location, which must be contained in the
      * reserved region ... when a read of the location pointed to by the
      * cpu-release-addr returns a non-zero value, the CPU must jump to this
      * value" [2]
      *
      * In our case, we want these CPUs to load the NuttX kernel defined by
      * `_start`. We don't need to worry about CPU0, that one always starts.
      * These are 64-bit words (hence skipping every second register).
      *
      * [1] https://github.com/raspberrypi/linux/blob/rpi-6.12.y/
      *     arch/arm/boot/dts/broadcom/bcm2711.dtsi
      *
      * [2] https://www.kernel.org/doc/Documentation/arm64/booting.txt
      */
   
     putreg64((uint64_t)__start, BCM_SPINTBL_CPU(cpu_num));
   #endif
   ```
   which should hopefully do all the CPU startup at the right time and it will 
use the `__start` that all other arm64 cores use to start up. I will test this 
hopefully tomorrow.


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to