Update.
After many tests I think I have pinpointed where it goes wrong but not exactly why.
With the "bad" devices when driving pin 12 low the device does not turn off as expected while the "good" devices do. With the "good" devices I even get a serial monitor message saying "Brown??" (or sometimes partly, like "Bro") which I assume is a "Brown out" message generated "deep" in Espressif's libraries. I think that make sense since the power supply is kind of "brutally" removed from the ESP when pin 12 is driven low.
So basically on some "bad" M5 Core INK devices this piece of C++ code that should shut down the board by driving pin 12 low does not work:
m5gfx::gpio_lo( pwrHoldPin );
(Line #672 in PowerClass.cpp)
I have also verified it in UIFlow2.0 by "manually" pulling pin 12 low:
import M5
import time
import hardware
M5.begin()
pin12 = hardware.Pin(12, mode=hardware.Pin.OUT, pull=hardware.Pin.PULL_UP)
time.sleep(3)
pin12.off()
With above UIFlow2.0 python code the "good" devices shut down completely as expected, while the "bad" ones does not.
But there is more. While troubleshooting I (for other reasons) updated the platform.io version from 6.3.0 to 6.6.0 (I'm using Platform.IO with Vs-code to compile C++ code for the CoreINK) and then the "bad" devices began to work as expected i.e. they were shutting down by pulling pin 12 low. I noticed that the ESP-IDF version is 5.2.1 in Platform.io version 6.6.0 but t is version 5.1.1 in version 6.4.0 (for some reason Platform.io V 6.3.x is not listed on GitHub).