Skip to content
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

Immediate Panic on Portenta H7 M4 Core #333

Closed
trylaarsdam opened this issue Oct 28, 2023 · 5 comments · Fixed by #331 or #353
Closed

Immediate Panic on Portenta H7 M4 Core #333

trylaarsdam opened this issue Oct 28, 2023 · 5 comments · Fixed by #331 or #353
Labels
conclusion: resolved Issue was resolved topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project

Comments

@trylaarsdam
Copy link

I'm trying to use BLE on the Portenta H7 M4 core (which I believe should be possible since the M4 has access to the HCI UART lines, but if someone knows definitively that it is not possible please let me know), however when I include the library, and flash to the Portenta, when I call BLE.begin(); from the M4 core, it immediately causes an MbedOS panic.

Here's a sample that is reproducible on my end:

// M4 Core
#include "Arduino.h"
#include "ArduinoBLE.h"

void setup() {
     BLE.begin(); // panics
}
void loop() {

}

There are mentions to the M4 core in the library and no mentions in Arduino's docs that the M4 core is not able to perform BLE operations, so any pointers or suggestions on how to initialize the BLE radio from the M4 core would be appreciated.

@per1234 per1234 added type: imperfection Perceived defect in any part of project topic: code Related to content of the project itself labels Oct 28, 2023
@facchinm
Copy link
Contributor

Fix is WIP here #331

@per1234 per1234 linked a pull request Oct 30, 2023 that will close this issue
@trylaarsdam
Copy link
Author

Fantastic, good to know.

@per1234 per1234 added the conclusion: resolved Issue was resolved label Feb 16, 2024
@trylaarsdam
Copy link
Author

trylaarsdam commented Feb 19, 2024

@aentinger Just tested this again since it was merged and this issue is not fixed on the Portenta. The board doesn't immediately panic now, but it just freezes on HCI.begin() which is called by BLE.begin()

Here is my source code which should provide an easy test case to reproduce. This is with the src folder of the current master branch of this repo in my src folder.

#ifdef CORE_CM4
#include <Arduino.h>
// includes from BLE lib 
#include "utility/ATT.h"
#include "utility/HCI.h"
#include "utility/GAP.h"
#include "utility/GATT.h"
#include "utility/L2CAPSignaling.h" 
#include "local/BLELocalDevice.h"
#define BT_REG_ON PJ_12
void setup()
{
	pinMode(LEDB, OUTPUT);
	pinMode(LED_BUILTIN, OUTPUT);
	digitalWrite(LED_BUILTIN, HIGH);
	digitalWrite(LEDB, HIGH);

	// from BLE.begin()
	pinMode(BT_REG_ON, OUTPUT);
	digitalWrite(BT_REG_ON, LOW);
	delay(500);
	digitalWrite(BT_REG_ON, HIGH);
	delay(500);

	if (!HCI.begin())
	{
		// never reached
		digitalWrite(LED_BUILTIN, LOW);
	}

	// BLE.begin continues here, but it doesn't get here anyway...

	// never reached
	digitalWrite(LEDB, LOW);
}

void loop()
{
}

#endif

#ifdef CORE_CM7
#include <Arduino.h>

void setup()
{
	bootM4();
}

void loop()
{
}
#endif

I've also reproduced this issue in the Arduino IDE, by locally cloning this library and simply including ArduinoBLE.h and calling BLE.begin() on the M4 core.

facchinm added a commit to facchinm/ArduinoBLE that referenced this issue Feb 21, 2024
@facchinm
Copy link
Contributor

@trylaarsdam can you try #353 on top of current master branch? In the M4 refactor we did indeed miss some defines and the module was never turned on on Portenta

@trylaarsdam
Copy link
Author

@facchinm unfortunately no change in behavior when I use your branch. When on the M4 core BLE.begin still freezes indefinitely when HCI.begin is called.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conclusion: resolved Issue was resolved topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
3 participants