USB detect Portenta H7 Lite only in bootloader mode

Hey there, recently I got my hands on Porthenta H7 Lite. The issue is that My PC USB do to recognize it. When I plug it into the USB I get a red LED blink, but the IDK detect nothing on my ports. When I double press the reset button the LED turns to green blink, and IDK detects it. So I can upload a sketch, but when that Is done it gets disconnected again, and I can not use serial monitor. Is that normal?

I have manage to pin down the issue to Wire.requestFrom (slaveAddress, answerSize)
line, from this code:

#include<Wire.h>
#define slaveAddress 0x08
#define ServerAddress 0x09

struct GPSsensorData {
  float StrLatitude;
  float StrLongitude;
  float StrhDOP;
  float StrCourse;
  float StrSpeed;
  byte StrnumberSat;
};
GPSsensorData GPSreadingsR;
static const byte answerSize=21;

void setup()
{
  Wire.begin(0x09); //Optional adress of main Arduino.
  Serial.begin(9600);
}

void loop()
{
  //Data request
  Serial.println(" ");
  Serial.println("Data request...");
  Wire.requestFrom (slaveAddress, answerSize);


  Serial.print ("Recieved Latitude: ");
  Serial.println (GPSreadingsR.StrLatitude);
  Serial.print ("Recieved Longitude: ");
  Serial.println (GPSreadingsR.StrLongitude);
  Serial.print ("Recieved HDOP: ");
  Serial.println (GPSreadingsR.StrhDOP);
  Serial.print ("Recieved Course: ");
  Serial.println (GPSreadingsR.StrCourse);
  Serial.print ("Recieved Speed: ");
  Serial.println (GPSreadingsR.StrSpeed);
  Serial.print ("Recieved number of satellites: ");
  Serial.println (GPSreadingsR.StrnumberSat);

  delay(500);

}

At this point there is only the Porthenta . I have not yet hooked up anything to it. Could this be the issue?

First of all: in order to upload (flash) a new user FW (image) - you have to enter bootloader mode.
This is done by double-press of reset - you should see a green fading flashing LED. If not: bootloader is not ready (and you cannot write a new FW version).
This double press of RESET is needed before start to upload with new FW, e.g. from IDE "run" button.

A red LED means: your own FW has crashed, potentially a bus error (e.g. a wrong address inside MCU accessed, code has crashed).

Why the USB-C UART is not working via?:

Serial.begin(UART_BAUDRATE); 

no idea:
Maybe, it is the:

Wire.begin(0x09);

When I initialize I2C (which is Wire) as MCU MASTER device, I do just:

Wire.begin();

Without any parameter! The I2C slave address, here your 0x09, matters just if you fire a master I2C transaction:
Then, via:

Wire.beginTransmission(slaveAddr);

the slave address is used.

So, just disable some code and try to get UART (as USB-C UART) working first, than add code, enable code and see where the problem starts to happen.

I think it is your:

Wire.begin(0x09);

The "constructor" of Wire (for I2C) takes just a parameter (as slave address) if you want to configure the I2C as a SLAVE. But I think you want to use as a MASTER (therefore, no parameter on Wire.begin()).
So, your:

Wire.requestFrom (slaveAddress, answerSize);

is a MASTER read request. This will potentially conflict with fact that you have configured your MCU as a SLAVE.

Bring up your code step by step and elaborate if you want to use I2C (Wire) as MASTER or as SLAVE (from MCU point of view). The other code seems to conflict with the initialization/intention.

Hi Tjaekel,

I thank you, for taking time to answer me. What you were saying was not very clear to me, so I took the time to understand it better. And this is why I delayed a bit the answer.

I understand about the boot loader mode, the issue is that the H7 was not visible to my PC at all, and there was no connection with the serial monitor, but you are right. It was crashing from the code, so maybe that is normal behavior due to circumstances.

You are also right about where the issue is. It works with no error when I loose that address in Wire.begin(); However, as far as I understand it, I define server address with the parameters in the brackets, not slave address. And I am wondering maybe I will not need to define the server address at all, after all in the examples it is defined but never used.

It is strange however, that the code did work on a connection between Uno, and Nano.

Thank you again, I will mark your answer as a solution.

Hi valkan, cool.
Thank you for the feedback (not all people in forum are so friendly like you :rofl:)

We are talking about I2C here: there is not a concept like "client" and "server". There is just:
"master" and "slave".
I think:
if you call Wire.begin(slaveAddr) - it configures the MCU I2C as a "slave" device.
But later you kick-off an I2C transaction like a "master" would do.
As I know: the I2C peripheral in MCU can act only as a "master" OR a "slave" but not with both roles at the same time.

The crash seems to be related to this issue: you configure Wire as a "slave" but you use it as a "master".
A slave will never actively initiate an I2C transaction: it will just wait for a master sending so that slave would receive (and respond). But a slave can never start a request by its own.
I think: it is a "code bug" inside Arduino library: to allow a "slave" to start a "master" transaction.

Just make sure, if you want to have I2C as "master" (as I see in your code later) or as a "slave" (now with a "slave" address for Wire.begin(slaveAddr) - putting the I2C into slave mode).

Happy coding... and many regards.

I just try to be respectful :slight_smile: After all you, and the community here were very helpful.

Note taken for Wire.begin, and master/slave.

Thank you again!