Good news! My Portenta H7 Lite is alive again. This happened after I connected the RESET wire as described by tjaekel in Portenta H7: debug messages via SWO Viewer - Hardware / Portenta - Arduino Forum . After that I was able to connect though ST-Link v2 using the hardware reset option. Thank you tjaekel for describing all your efforts in detail! I am now debugging in the STM32 Eclipse IDE and can proceed with my work.
It is a bit nebulous to me how all this fixed it - I think setting the PMIC registers helped. Here is the code that can run on an Arduino Uno using its I2C (Wire) implementation. Maybe it helps someone else.
#include <Wire.h>
const int nMichele = 12;//13;
uint16_t regAddrMichele[nMichele] = {0x4f, 0x50, 0x4c, 0x4d, 0x52, 0x53, 0x9c, 0x9e, 0x42, 0x94, 0x3b, 0x35};//, 0x42};
byte regValMichele[nMichele] = {0x00, 0x0f, 0x05, 0x03, 0x09, 0x0f, 0x80, 0x20, 0x02, 0xa0, 0x0f, 0x0f};//, 0x01};
const int nTJaekel = 160;
byte regValTJaekel[nTJaekel] =
{0x7c ,0x00 ,0x11 ,0x00 ,0x00 ,0x00 ,0x88 ,0x00 ,0x00 ,0x07 ,0x00 ,0x04 ,0x07 ,0x04 ,0x00 ,0x03
,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x07 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00
,0x00 ,0x05 ,0x00 ,0x00 ,0x00 ,0x3f ,0x00 ,0x00 ,0x08 ,0x1f ,0x04 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00
,0x00 ,0x00 ,0x06 ,0x06 ,0x06 ,0x0f ,0x00 ,0x00 ,0x0a ,0x0a ,0x0a ,0x0f ,0x00 ,0x00 ,0x0d ,0x0d
,0x0d ,0x03 ,0x01 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x05 ,0x03 ,0x00 ,0x00
,0x0f ,0x00 ,0x09 ,0x0f ,0x00 ,0x00 ,0x00 ,0x00 ,0x21 ,0x80 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x01
,0x02 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x0c ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00
,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00
,0x68 ,0x00 ,0xff ,0x00 ,0xac ,0x00 ,0x20 ,0x03 ,0x04 ,0x02 ,0x00 ,0x00 ,0x00 ,0x40 ,0x05 ,0x6b
,0x00 ,0x00 ,0x00 ,0x00 ,0xa0 ,0x06 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x80 ,0x00 ,0x20 ,0x00};
uint16_t regAddrTJaekel[nTJaekel] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
10,11,12,13,14,15,16,17,18,19,
20,21,22,23,24,25,26,27,28,29,
30,31,32,33,34,35,36,37,38,39,
40,41,42,43,44,45,46,47,48,49,
50,51,52,53,54,55,56,57,58,59,
60,61,62,63,64,65,66,67,68,69,
70,71,72,73,74,75,76,77,78,79,
80,81,82,83,84,85,86,87,88,89,
90,91,92,93,94,95,96,97,98,99,
100,101,102,103,104,105,106,107,108,109,
110,111,112,113,114,115,116,117,118,119,
120,121,122,123,124,125,126,127,128,129,
130,131,132,133,134,135,136,137,138,139,
140,141,142,143,144,145,146,147,148,149,
150,151,152,153,154,155,156,157,158,159
};
const byte one = 0x01;
const byte zero = 0x00;
const byte sendRestart = false;
void readI2C(byte devAddr, int m, int n)
{
Serial.println();
for (int i = 0; i < m; i++)
{
Serial.print(byte(i*16), HEX);
Serial.print(" | ");
for (int j = 0; j < n; j++)
{
Wire.beginTransmission(devAddr);
int nWritten = 0;
nWritten += Wire.write(uint16_t(i*16+j));
int error = Wire.endTransmission(sendRestart);
if (error != 0)
{
Serial.print("Transmission error, code = ");
Serial.println(error);
}
int nRead = Wire.requestFrom(devAddr, one);
if (nRead == 1)
{
byte valRead = Wire.read();
Serial.print(valRead, HEX);
Serial.print(" ");
}
}
Serial.println();
}
}
void writeI2C(byte devAddr, uint16_t regAddr[], byte regVal[], int n)
{
Serial.println();
for (int i = 0; i < n; i++)
{
Wire.beginTransmission(devAddr);
int nWritten = 0;
nWritten += Wire.write(regAddr[i]);
nWritten += Wire.write(regVal[i]);
int error = Wire.endTransmission();
if (error != 0)
{
Serial.print("Transmission error, code = ");
Serial.println(error);
} else {
Serial.print("Wrote ");
Serial.print(nWritten);
}
Wire.beginTransmission(devAddr);
nWritten = 0;
nWritten += Wire.write(regAddr[i]);
error = Wire.endTransmission(sendRestart);
int nRead = Wire.requestFrom(devAddr, one);
if (nRead == 1)
{
byte valRead = Wire.read();
Serial.print(" bytes to register ");
Serial.print(regAddr[i], HEX);
Serial.print(": wrote ");
Serial.print(regVal[i], HEX);
Serial.print(", read ");
if (valRead != regVal[i]) {
Serial.print(valRead, HEX);
Serial.println(" *** ERROR ***");
} else {
Serial.println(valRead, HEX);
}
} else {
Serial.print("Error in reception, bytes received = ");
Serial.println(nRead);
}
}
}
void scanI2C() {
byte error, address;
int Devices;
Serial.println();
Serial.println("I2C Scanner");
Serial.println("Scanning...");
Devices = 0;
for(address = 1; address < 127; address++ )
{
Wire.beginTransmission(address);
error = Wire.endTransmission();
if (error == 0)
{
Serial.print("I2C device found at address 0x");
if (address<16)
Serial.print("0");
Serial.print(address,HEX);
Serial.println(" !");
Devices++;
}
else if (error==4)
{
Serial.print("Unknown error at address 0x");
if (address<16)
Serial.print("0");
Serial.println(address,HEX);
}
}
if (Devices == 0)
Serial.println("No I2C devices found");
else
Serial.println("done");
}
void setup() {
Serial.begin(9600);
scanI2C();
Wire.begin();
Wire.setTimeout(1000);
byte devAddr = 0x08;
readI2C(devAddr, 16, 16);
//writeI2C(devAddr, regAddrMichele, regValMichele, nMichele);
writeI2C(devAddr, regAddrTJaekel, regValTJaekel, nTJaekel);
readI2C(devAddr, 16, 16);
}
void loop()
{
scanI2C();
delay(5000);
}