It looks like, the CM4 compile is clean, so it seems to have also a Serial object.
But I could imagine the following, why CM4 does not send anything to UART.
CM4 should be able to access the same UART peripheral in the MCU (from hardware point of view).
But think about, CM4 is like a completely different MCU, with its own code (CM7 and CM4 code must be compiled, linked independently, also loaded independently). So, both cores will have a runtime code, their own startup, their own memory regions (ROM and SRAM regions) and also their own Vector Table and ISR handlers.
So, I can imagine:
- CM4 runtime code generated from the same/similar source code for Serial, but it is compiled for CM4,
as part of CM4: so, CM4 has a Serial object and CM7 has a Serial object, but no the same, not a
single one
- CM4 might be released from Reset (via an instruction done by CM7), but it might not have same
full system configuration on CM4 startup (e.g. maybe it will not configure pins, does not enable
clocks etc.).
OK, assuming CM7 would initialize the Peripherals, clocks, domains in system, so that CM4 can also
potentially use UART.
- But, quite likely: if CM4 has its own Serial object (I cannot imagine that CM7 and CM4 share the same
code, the same objects etc.) - even all the code is there, but maybe the needed Interrupts for UART
are not properly configured for/in CM4
- CM4 has its own NVIC, own Vector Table, own ISR handlers: maybe the Vectors are set properly,
but maybe Interrupts are not configured, not enabled etc.
Also not clear:
Assuming there is mbed, with an RTOS, so that Queues (for multi-thread communication on CM7) is possible - does the CM4 runs also an RTOS, also an mbed?
And if so, both systems would be completely independent: a thread on CM7 might talk only to a thread
on CM7, not to a thread of CM4 (but threads in CM4 via an RTOS on CM4).
I guess, there is (and has to be) an RPC mechanism, so that CM4 and CM7 can talk to each other.
The STM32H7 provides Hardware Semaphores which have to be used for such inter-core synchronisation.
I would guess, the CM4 runtime system is not the 'same' as CM7, it might have just a very simple
startup code, it does not initialize the system really completely, just the CM7 as main and master core does.
I assume, the CM4 runtime environment is just a subset, a bare minimum and maybe also not really complete yet (e.g. in terms of CM4 interrupt configuration and handling, same functioning HAL drivers).
It would be great and appreciated to see all the source code, including mbed, the startup code(s), to understand what each core will do (has done) before the Arduino Scatch (setup() and loop()) would be called.
BTW:
Assuming, CM4 and CM7 have their own Serial object. You cannot assume, when CM7 does Serial.begin(), that CM4 can continue to use the Serial. The Serial is a different one (like two objects of the same class), so that CM4 has to do really all from the beginning as well. You cannot assume that CM7 and CM4 can 'share' something done by the 'other guy'.
Multi-Core systems are not really so easy, even both CM7 and CM4 can access physical Peripherals in system. They run for sure on different ROM and SRAM regions, they do not share code or data. For both cores there 'must' be a compile and link process, separated for CM7 and CM4.
Even, most of the code (instructions) are identical, but the internal processor architectures, e.g. NVIC, Vector Table, access to FPU, DSP instructions etc. are different (or not there on CM4).
If all the HAL drivers are 'generic' in a way, that a compile define (e.g CM7 vs. CM4) would select the correct source code (e.g. to setup a Vector, to enable an Interrupt) - no clue. Or both cores have their own set of HAL drivers. But what CM4 would initialize when it is released - also no clue.
I would assume the system this way:
- CM7 is master, running mbed, an RTOS, doing all the system config stuff, tested and implement quite
well
- but CM4 is just an 'auxiliary CPU', not a full stand-alone system, it might not run even an RTOS,
neither potentially a full blown mbed and RTOS
- and there are differences between both runtime systems, what they would initialize in system,
what they support via HAL drivers etc.
- and there might be an RPC mechanism provided so that CM4 and CM7 can communicate,
synchronize each other - but how far it is implemented, tested and existing - no idea
- even both CPUs sit in the same system, can use the same hardware peripherals, but they behave
in terms of software like two independent computers, not sharing any memory, code and data
(actually: this STM32H747 is not really a multi-core system, it is more a multi-processor system)
- so, I would not assume that all works and in the same way on CM4 as on CM7, I could imagine that
CM4 is pretty 'empty' in terms of runtime environment, HAL, drivers etc. ("we do not need all again
on CM4 if CM7 provides it already" - and it would blow up the ROM and RAM space needed)
I will try to use Serial (UART) on CM4, potentially easier via an RPC mechanism (instead to let CM4
do all the initialization, UART handling, ISRs etc.).
Otherwise, if both, CM7 and CM4 want to use the same physical UART at the end - it becomes even more tricky to make it exclusive on the Peripheral Device.
So, the CM7 is the master and provides via messages, queues, RPC, ways that CM4 can request something on CM7, e.g. to send a string via UART on behalf.
It might be a bit of work, but it makes the system a bit more 'easier' to understand it, to deal with
concurrent access to single resources (such as devices).