Skip to content

Portenta H7: Why does blue LED blink... #124

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
KurtE opened this issue May 17, 2025 · 7 comments · Fixed by #128
Closed

Portenta H7: Why does blue LED blink... #124

KurtE opened this issue May 17, 2025 · 7 comments · Fixed by #128

Comments

@KurtE
Copy link

KurtE commented May 17, 2025

Describe the bug
On every or almost every sketch I run on the Portenta H7, the BLUE led continuously blinks.
I believe it is probably connected to the charging circuit and there is no battery connected to my board.
And it do not blink like this when running on MBED.

Hopefully a simple one to resolve.

@mjs513
Copy link

mjs513 commented May 17, 2025

Just for the record I am seeing the same thing as @KurtE

@KurtE
Copy link
Author

KurtE commented May 19, 2025

Notes to self and probably only myself.....

When I boot up a simple sketch like blink on MBED: I see that the following stuff is output over I2C1, to device 0x08

write to 0x08 ack data: 0x4F 0x00 
write to 0x08 ack data: 0x50 0x0F 
write to 0x08 ack data: 0x4C 0x05 
write to 0x08 ack data: 0x4D 0x03 
write to 0x08 ack data: 0x52 0x09 
write to 0x08 ack data: 0x53 0x0F 
write to 0x08 ack data: 0x9C 0x80 
write to 0x08 ack data: 0x9E 0x20 
write to 0x08 ack data: 0x42 0x02 
write to 0x08 ack data: 0x94 0xA0 
write to 0x08 ack data: 0x3B 0x0F 
write to 0x08 ack data: 0x35 0x0F 
write to 0x08 ack data: 0x42 0x01 

And when I run it on Zephyr:

write to 0x08 ack data: 0x4F 0x00 
write to 0x08 ack data: 0x50 0x0F 
write to 0x08 ack data: 0x4C 0x05 
write to 0x08 ack data: 0x4D 0x03 
write to 0x08 ack data: 0x52 0x09 
write to 0x08 ack data: 0x53 0x0F 
write to 0x08 ack data: 0x9C 0x80 
write to 0x08 ack data: 0x9E 0x20 
write to 0x08 ack data: 0x42 0x02 
write to 0x08 ack data: 0x94 0xA0 
write to 0x08 ack data: 0x3B 0x0F 
write to 0x08 ack data: 0x35 0x0F 
write to 0x08 ack data: 0x00 
read to 0x08 ack data: 0x7C
write to 0x08 ack data: 0x32 0x06 
write to 0x08 ack data: 0x35 
read to 0x08 ack data: 0x0F
write to 0x08 ack data: 0x38 0x07 
write to 0x08 ack data: 0x3B 
read to 0x08 ack data: 0x0F
write to 0x08 ack data: 0x3E 0x0F 
write to 0x08 ack data: 0x42 
read to 0x08 ack data: 0x02
write to 0x08 ack data: 0x42 0x02 
write to 0x08 ack data: 0x41 
read to 0x08 ack data: 0x03
write to 0x08 ack data: 0x4C 0x05 
write to 0x08 ack data: 0x4D 
read to 0x08 ack data: 0x03
write to 0x08 ack data: 0x4F 0x00 
write to 0x08 ack data: 0x50 
read to 0x08 ack data: 0x0F
write to 0x08 ack data: 0x52 0x09 
write to 0x08 ack data: 0x53 
read to 0x08 ack data: 0x0F

Which I believe is the device that controls a lot of power managment:
https://www.nxp.com/docs/en/data-sheet/PF1550.pdf
Now to see if any of it makes sense

@KurtE
Copy link
Author

KurtE commented May 21, 2025

Quick update... The 2nd post was barking up the wrong tree ....
The LED that is blinking is not the charge LED, but instead the BLUE one part of the RGB LED stuff.

I believe it is probably related to the code in the MBED version where the

void initVariant() {
  RTCHandle.Instance = RTC;
  // Turn off LED from bootloader
  pinMode(PK_6, OUTPUT);
  digitalWrite(PK_6, HIGH);

I have tried to add similar code to an initVariant function for zephyr PortentaH7, but that did not stop blink, tried adding to
sketch as well did not stop it. Guessing there is some timer or the like running ... still looking.

@facchinm
Copy link
Member

Hi Kurt, the blue led blinking is coming from the M4 core default sketch 😅
There's a config in zephyr to disable it from booting but it only works if the option bit for automatic M4 boot is disabled.
This snippet should do the trick https://github.com/arduino/ArduinoCore-mbed/blob/main/libraries/RPC/src/RPC.cpp#L111-L129 (to automatically apply it, you can flash the M7 with an RPC sketch using the mbed core).
Let me know if it works!

@KurtE
Copy link
Author

KurtE commented May 21, 2025

Thanks @facchinm will try it out later...

Which leads into another set of questions, on How you see things proceeding, like controlling the second core.
But I think it may be better for a discussion...

@KurtE
Copy link
Author

KurtE commented May 22, 2025

@facchinm -

Let me know if it works!

So far no luck. If I understood correctly, I tried running this sketch on MBED:

#include <RPC.h>
void setup() {
  // put your setup code here, to run once:
  // If CM4 is already booted, disable auto-boot and reset.
  Serial.begin(115200);
  while (!Serial && millis() < 10000) {}
  FLASH_OBProgramInitTypeDef OBInit;

  OBInit.Banks = FLASH_BANK_1;
  HAL_FLASHEx_OBGetConfig(&OBInit);
  if (OBInit.USERConfig & FLASH_OPTSR_BCM4) {
    OBInit.OptionType = OPTIONBYTE_USER;
    OBInit.USERType = OB_USER_BCM4;
    OBInit.USERConfig = 0;
    check_return_status("HAL_FLASH_OB_Unlock ", HAL_FLASH_OB_Unlock());
    check_return_status("HAL_FLASH_Unlock ", HAL_FLASH_Unlock());
    check_return_status("HAL_FLASHEx_OBProgram ", HAL_FLASHEx_OBProgram(&OBInit));
    check_return_status("HAL_FLASH_OB_Launch ", HAL_FLASH_OB_Launch());
    check_return_status("HAL_FLASH_OB_Lock ", HAL_FLASH_OB_Lock());
    check_return_status("HAL_FLASH_Lock ", HAL_FLASH_Lock());
    Serial.println("CM4 autoboot disabled\n");
    NVIC_SystemReset();
    return;
  } else {
    Serial.println("FLASH_OPTSR_BCM4 not set");
  }
}

void check_return_status(const char *sz, HAL_StatusTypeDef ret) {
  if (ret == HAL_OK) return; 
  Serial.print(sz);
  Serial.print("failed: ");
  Serial.println(ret);
}

void loop() {
  // put your main code here, to run repeatedly:
}

When I ran it on MBED it simply printed that: FLASH_OPTSR_BCM4 not set

Soon as I burn bootloader for zephyr blue led is back...
Will play some more.

EDIT: simply running blink on MBED and add RPC.begin() gives me the blink of the BLUE led...
So default sketch I assume was burned in to the actual firmware of Portenta H7, probably if no other valid M4 sketch
has been programmed in at the appropriate location.

@facchinm
Copy link
Member

Sorry for the delay, the config to be added to Portenta .conf is CONFIG_STM32H7_BOOT_M4_AT_INIT=n to complete the trick

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants