I have learnt much more:
If Portanta H7 is bricked (orange LED is on, nothing works, even Arduino bootloader does not work) - you can recover just with a second USB cable (maybe a need for an I2C master needed as well).
Situation
You see the orange LED (charging LED on PMIC) is ON: - the PMIC is not configured, the board does not have power!
You cannot use dfu-util: it shows an error: the Arduino bootloader is gone (overwritten, not running, not responding board due to missing power). Indication: when pressing reset button twice short after each other - you do not see a fading, flashing LED. The bootloader is dead - and no way to re-program the board.
Seeing orange LED or not a fading flashing LED after 2x reset - is a bad sign (bricked board).
No worries: luckily STM provides another bootloader in MCU (hard-coded, always there with the STM MCU chip).
Prerequisites
You should have:
-
the breakout board for Portenta H7 (just the tiny MCU does not help: the MCU module on breakout board is needed)
-
an USB-A to host cable: an USB cable which connects the USER USB on breakout board (as USB-A) to host (as a second USB connection!)
-
if PMIC is not configured - you see orange LED - any I2C master which can configure PMIC on broken board (I use, and in illustration shown: another Portenta H7 which has UART commands to fire I2C write transactions).
Recovery Procedure
So, connect the second USB-A cable to host (you need USB-C for power, but a second cable as USER USB to host PC).
Change the BOOT DIP switch on breakout board, press reset, let it boot into STM Bootloader, reprogram the PMIC on broken board (to get the power back) - if needed, flash FW again, or the Arduino Bootloader ..., change back the BOOT DIP switch and let boot the board. It should have discovered.
If orange LED is on - you had to release PMIC on broken board for powering this board - you had to write I2C registers from "any" I2C master, to configure PMIC on broken board.
The tool "dfu-util.exe" should find afterwards - press reset - but do not power-cycle the broken board! - the STM bootloader on broken board should be activated. Now you can flash any software (your FW, Arduino Bootloader etc.). The "dfu-util" should see now a DFU device. But: the USB IDs are different to the ones used for/by Arduino Bootloader!
Questions
Why does Portenta H7 have this Arduino bootloader?
It allocates space in MCU flash (64KB less code space for own FW). And it is flaky.
I can flash the board in the SAME WAY with STM Bootloader and same tool dfu-util.exe.
OK: we need the breakout board for doing so just to have this second USER USB and the BOOT DIP switch. MCU module w/o breakout board - no way to recover (or to use this STM bootloader).
Why is the PMIC "so sensitive"? It looks to me: board is bricked just due to fact that PMIC is not configured anymore (e.g. no FW running, e.g. also bootloader overwritten). In this case the board does not have power an no way to connect (with any means: even an external debugger, ST-LINK, will not see: board has just 0.02V as VDD - nothing responding. Therefore: the PMIC must be "released" from the outside)
I saw also issue, when programming the same I2C PMIC sequence I use in FW for PMIC config - it does not work when I do from the "outside": after writing to register 0x50 - I cannot read PMIC ChipID anymore (PMIC is dead).
So, I have changed the sequence of register writes into this sequence (below). And I use in my bare-metal project now also this changed PMIC register config sequence (w/o issues).
Is Arduino code still doing something not really right? (and therefore the Portenta H7 is flaky, bricked so often?)
//initialize the PMIC registers:
// LDO2 to 1.8V
data[0]=0x4F;
data[1]=0x0;
I2CUser_Write(PMIC_I2C_SLAVE_ADDR, data, sizeof(data));
/* ATTENTION: if I write this register - the I2C is dead, read ChipID does not work anymore
* write this register as the last one!
*/
#if 0
data[0]=0x50;
data[1]=0xF;
I2CUser_Write(PMIC_I2C_SLAVE_ADDR, data, sizeof(data));
#endif
// LDO1 to 1.0V
data[0]=0x4c;
data[1]=0x5;
I2CUser_Write(PMIC_I2C_SLAVE_ADDR, data, sizeof(data));
data[0]=0x4d;
data[1]=0xF; //was 0x3
I2CUser_Write(PMIC_I2C_SLAVE_ADDR, data, sizeof(data));
// LDO3 to 1.2V
data[0]=0x52;
data[1]=0x9;
I2CUser_Write(PMIC_I2C_SLAVE_ADDR, data, sizeof(data));
data[0]=0x53;
data[1]=0xF;
I2CUser_Write(PMIC_I2C_SLAVE_ADDR, data, sizeof(data));
osDelay(10);
//charger LED off - duty cycle
data[0]=0x9C;
data[1]=(1 << 7); //0x80
I2CUser_Write(PMIC_I2C_SLAVE_ADDR, data, sizeof(data));
// Disable charger led
data[0]=0x9E;
data[1]=(1 << 5); //0x20
I2CUser_Write(PMIC_I2C_SLAVE_ADDR, data, sizeof(data));
osDelay(10);
// SW3: set 2A as current limit
// Helps keeping the rail up at wifi startup
data[0]=0x42;
data[1]=2;
I2CUser_Write(PMIC_I2C_SLAVE_ADDR, data, sizeof(data));
osDelay(10);
// Change VBUS INPUT CURRENT LIMIT to 1.5A
data[0]=0x94;
data[1]=(20 << 3); //0xA0
I2CUser_Write(PMIC_I2C_SLAVE_ADDR, data, sizeof(data));
// SW2 to 3.3V (SW2_VOLT)
data[0]=0x3B;
data[1]=0xF;
I2CUser_Write(PMIC_I2C_SLAVE_ADDR, data, sizeof(data));
// SW1 to 3.0V (SW1_VOLT)
data[0]=0x35;
data[1]=0xF;
I2CUser_Write(PMIC_I2C_SLAVE_ADDR, data, sizeof(data));
#if 1
osDelay(10);
data[0]=0x50;
data[1]=0xF;
I2CUser_Write(PMIC_I2C_SLAVE_ADDR, data, sizeof(data));
#endif
I hope it helps you as well. Using the Portenta H7 can be a "nightmare". And when it comes to issues, like: orange LED is on, no access anymore to board - it might drive you crazy as it does for me. Meanwhile: I understand the board much better, have my own FW, I do not need anymore the Arduino bootloader (and I can use also the 64KB flash space occupied by Arduino).
BTW: why Arduino team is never responding here in forum? They let us find solutions our self, to share between us as users. Arduino promotes Portenta H7 as "professional" system, but all what I realize: it is not any professional system (too flaky and not any support, no responses here and even not from Arduino team, e.g. when requesting a BSP Source Code).
Have fun with this great piece of HW (which Portenta H7 really is), but maybe as me: "get rid of any Arduino stuff" (and I have it meanwhile! "Uffff").
