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

Crashed when used in conjunction of NimBLE-Arduino + Wi-Fi #356

Closed
rascove opened this issue Sep 8, 2024 · 8 comments
Closed

Crashed when used in conjunction of NimBLE-Arduino + Wi-Fi #356

rascove opened this issue Sep 8, 2024 · 8 comments
Assignees
Labels
wontfix This will not be worked on

Comments

@rascove
Copy link

rascove commented Sep 8, 2024

Hi, I'm working on a PlatformIO project that requires the ESP32 (LilyGo T5 4.7) to subscribe and publish to an MQTT broker using Wi-Fi and scan nearby BLE devices, while displaying some data on the e-Paper. I'm using NimBLE-Arduino and built-in Wi-Fi libraries in conjunction with the epdiy.

If I use only two of these libraries (epdiy + Wi-Fi, epdiy + NimBLE-Arduino, or NimBLE-Arduino + Wi-Fi), the project can be successfully executed on the device, however as soon as I added all three libraries at the same time, the device keeps on rebooting. These are the source code, the configuration file, and the log from serial monitor for your reference:

#include <Arduino.h>
#include <Epd_Highlevel.h>
#include <Epdiy.h>
#include <FiraSans.h>
#include <NimBLEDevice.h>
#include <WiFi.h>

void setup()
{
	Serial.begin(115200);
	NimBLEDevice::init("");

	NimBLEScan* scanner = NimBLEDevice::getScan();

	scanner->setActiveScan(true);
	WiFi.begin("SSID", "PWD");

	while (WiFi.status() != WL_CONNECTED)
		delay(500);

	epd_init(&epd_board_lilygo_t5_47, &ED047TC1, EPD_LUT_64K);

	EpdiyHighlevelState hl = epd_hl_init(EPD_BUILTIN_WAVEFORM);
	uint8_t* fb = epd_hl_get_framebuffer(&hl);
	int cursor = 0;

	epd_clear();
	epd_write_default(&FiraSans, "Initialising...", &cursor, &cursor, fb);
	epd_poweron();
	epd_hl_update_screen(&hl, MODE_GC16, 27);
	delay(500);
	epd_poweroff();

	NimBLEScanResults foundDevices = scanner->start(10);

	Serial.print("Devices found: ");
	Serial.println(foundDevices.getCount());
}

void loop()
{
}
[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
board_build.f_cpu = 240000000L
upload_speed = 921600
monitor_speed = 115200
lib_deps =
    https://github.com/vroland/epdiy.git
    h2zero/NimBLE-Arduino
build_flags =
    -DBOARD_HAS_PSRAM
    -DCONFIG_EPD_DISPLAY_TYPE_ED047TC1
    -DCONFIG_EPD_BOARD_REVISION_LILYGO_T5_47
    -DCONFIG_ESP32_WIFI_SW_COEXIST_ENABLE
rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:1184
load:0x40078000,len:13232
load:0x40080400,len:3028
entry 0x400805e4

assert failed: epd_hl_init highlevel.c:50 (state.dirty_columns != NULL)


Backtrace: 0x40084ae1:0x3ffcd210 0x40096a6d:0x3ffcd230 0x4009cbdd:0x3ffcd250 0x400d356f:0x3ffcd380 0x400d2aee:0x3ffcd3b0 0x400e8c5e:0x3ffcd430

Thank you very much in advance.

@martinberlin
Copy link
Collaborator

Hi @rascove

I'm working on a PlatformIO project that requires the ESP32 (LilyGo T5 4.7)

You will be much better off writing an issue in their Repository. Because we do not produce this Hardware and not even their code which is based on epdiy v2 ( And as you can see here the PCB is already version 7 )

You could try the same code in a different hardware maybe. And also make some tests with the latest version of the Firmware of this repository.

@martinberlin martinberlin removed their assignment Sep 10, 2024
@martinberlin martinberlin added the wontfix This will not be worked on label Sep 10, 2024
@rascove
Copy link
Author

rascove commented Sep 10, 2024

Thanks for the feedback @martinberlin , I'll do that as well.

I'm posting this here because the error is caused when the EpdiyHighlevelState is being initialised, as shown in the serial log: assert failed: epd_hl_init highlevel.c:50 (state.dirty_columns != NULL).

Anyway, thank you very much and have a great day ahead.

@martinberlin
Copy link
Collaborator

Sure, but you are using a library that is from Lilygo and since long time updated here.
If you switch to this repository with the latest library then esp32 version of Lilygo is still supported. (Not S3)
Anyways buying a product from Lilygo is the hardware provider who should give support.

@rascove
Copy link
Author

rascove commented Sep 11, 2024

Hi @martinberlin , thanks for the response but please refer to my code and PlatformIO configuration. I'm not using LilyGo T5 library at all, in fact, I'm using this repository's own example to build the project.

@martinberlin
Copy link
Collaborator

Don't really understand why then:

#include <Epd_Highlevel.h>
#include <Epdiy.h>

Use first letter uppercase. The example code in this repositories are not like this and it won't find the include if you uppercase first letter.
I will try when I find sometime your code, but I need to find my Lilygo first. I highly recommend you to switching to a v7 board though, to use the latest code using LCD Module. I've still one v7 unit available in tindie.com if you search for "epdiy"

@rascove
Copy link
Author

rascove commented Sep 11, 2024

Ah, I'm so sorry about that. I'm using Windows so the filename is not case-sensitive, and coming from Java background, it's my habit to capitalise the first letter of the library.

But thank you very much for your kind assistance, @martinberlin , I really appreciate that. Unfortunately I don't have a control for the type of e-Paper used as it was purchased by the client.

@martinberlin
Copy link
Collaborator

martinberlin commented Sep 11, 2024

Also this line of the assert where it stops:

state.dirty_columns
    = heap_caps_aligned_alloc(16, epd_width() / 2, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);

Creates the RAM space to allocate the variable. If it's not allocated then the assert will fail. Try to locate it in PSRAM, but that will be slower, and not sure if it will work. It might be that using this combination of libraries won't work with the hardware.
That's why I was suggesting to update to v7. You will need to deep debug this and check how much Heap RAM you have available, I guess this could be the most probable cause.

@rascove
Copy link
Author

rascove commented Sep 14, 2024

Hi @martinberlin ,

Sorry for the late response and thank you very much for your advice about the insufficient RAM. It gave me the idea to initialise the BLE stack in the PSRAM instead, which is already provided by the NimBLE-Arduino library. And now, all three libraries can be used altogether.

Once again, thank you very much and have a great day ahead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants