My five cents (all is more speculative, just based on mixing my knowledge).
First I thought: "if you swap the sketches - these CORE_CM7 has to be flipped as well". But after a deeper look: it looks reasonable.
The remaining questions is just: who does create the RPC (and the HW semaphore used by it), and who owns it?
As I understand:
The RPC mechanism uses the real HW semaphores in STM32H7xx system (MCU), the HSEM.
Such a HSEM has an "ownership": it knows who has created, allocated or released such a semaphore. The CPU ID is used deep inside, on the bus, to distinguish which CPU has created, released or allocated.
I think, I saw, that CM7 startup code initializes such a HSEM. It is used also during startup to figure out, if and when the other core, the CM4, has booted and is running.
I could imagine: the underlaying HSEM is always and just initialized by CM7 core (which boots always and first). So, any system boot with CM7 running first, might create already the semaphore.
I do not know what "RPC.begin()" will do: maybe just releasing the HSEM but assuming it was already created (by CM7).
If you flip now the sketches - possible, that the logic has a "dead lock": now the CM4 wants to create, release ... the semaphore. But is was and is still generated and initialized by CM7 core. The CM4 might not be able to take or "re-initialize" the HSEM. And all is stuck.
Semaphores, for my understanding (interpretation) have an "ownership" and a clear "master - slave" association. The "master", which has created the semaphore, has to release it before a "slave" can use or also allocate it.
If you flip now your sketches - potentially this HSEM creating and "ownership" has not changed. It can end up in: "the CM4 now as the master cannot create, release ... the HSEM because it is still owned by the CM7". The logic how the HSEM in the lower-level code is created, used - has not changed.
I would assume this: the dual-core STM is used and configured by the startup code (BSP) in a way, that CM4 is always a "slave", the CM7 the "master". When flipping the sketch code - it does not change this 'assumption' and logic on HSEM (and RPC calls). You cannot turn the CM4 into a "master" because it is not intended to do so, neither supported by HW and BSP (startup code).
It could be also a HW limitation, e.g. that only CM7 can initialize and setup a HW semaphore (not sure, but for sure the HSEM sees and uses the Core ID). Also for sure: the dual-core STM HW is not designed for the case that CM4 boots first and release the CM7. It has a fix boot sequence: both cores could boot in parallel (there is user programmable fuse bit) or: the CM7 only (and always) but it can release the CM4.
As what I have seen: the CM4 fuse bit to release CM4 on boot is not enabled (the default is overwritten to keep the CM4 in reset on Portenta H7).
So, flipping the logic can also result in: CM4 wants to release CM7 - but this is not supported, not the intended way (just CM7 as master can release CM4).
So, flipping the sketch code might interfere with the HW logic, the BSP (startup) code etc, esp. when it comes to the "ownership" of 'shared system resources', such as HSEM.
Sorry, speculative. Why do you want to make it working? To start CM4 as master is for sure not the intended, not a supported way. Keep going to consider CM7 is the "master of the system", the CM4 is 'just' a "slave of the CM7" (but not the way around).
When swapping sketch code - this "constraint" (assumption) should not change (and remains in place from a HW perspective).