-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Program to Big.... Using BLE libraries! #1075
Comments
The BLE library is HUGE. And it is not possible to reduce the size. I struggled with the same problem and the only solution was to change the partition size to add more available program space by reducing (or eliminating) the SPIFFS and EEPROM partitions. There is a small tutorial how to Change partition size |
Thanks , I know how to change partition size, but this is not the right solution! |
From what I know that's complete up to Espressif inside the ESP-IDF. I guess you would need to post an issue in the ESP-IDF repo |
A posted an issue to nkolban site hoping to get some guidance on how to tailor configuration files. |
Hi all, I faced the same issue and did not found a easy solution, so I finally forked the library and create a "light version" of it. I saved about ~30KB program size with this version. |
@jjoe64 I am trying your library, but getting this error...
|
Just curious - will the BLE_scan example work with this light(er) version of the library? Thanks |
@m-menon most of flash is taken by esp-idf bt stack when you init bluetooth. BT stack is very heavy. Try to test it with |
@chegewara thanks. Sure, I will test it out. The BT stuff is heavy and there is no easy way to shrinking it. I can work around with the partition scheme for now and get things to work. The library itself is excellent and thanks for that. |
I faced the same problem SO I fixed mine just to change some settings in Arduino IDE. So I selected this Huge App Partition and my huge code got accepted with no freaking errors for my ESP32 Board. |
Same here. Thanks for finding this. Using Arduino IDE 1.8.8 BLE, WIFI and MQTT on a WeMos® ESP32 WiFi + Bluetooth-ontwikkelingsraad Ultra Low Power Consumption Dual Core ESP-32 ESP-32S Vergelijkbaar ESP8266 #include "BLEDevice.h" |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I've used BLE on several other platforms and none of those had libraries that were anywhere near this big. I made a "Simple" app for the ESP32 with a Web Interface to change data and a BLE Interface to read it, and the size is almost 1.5 MB! The library sizes really limit the applications that the ESP32 can be used for - certainly no real commercial applications. It's a shame as I had great hopes for the ESP32. |
@APBeck3rd good for you. For example i am using esp32 with BLE in few projects and none is even close to 1.5MB, it around 1.3MB (my AWSFreeRTOS app, with full BLE stack, mqtt and TFT working on m5stack is 1.17MB, only issue is heap shortage). But i understand what you are saying and the problem is not library, the problem is that esp-idf bluetooth stack library is for BLE and classic bluetooh and even if you are using only BLE whole library is linked. Maybe esp-idf v4.x will have NimBLE implementer, which is already merged to master branch. NimBLE library is light weight because its only BLE driver. Lets hope someone will add NimBLE support for arduino too (maybe even this year). |
Hi @chegewara , it is great knowing esp-idf has a lighter version of BLE library. I am running into the same issue trying to make a application which has the BLUFI and some other sub-tasks for LED driving, GPIOs manipulation etc... It was fine before I added the BLUFI example to my application, but now I am having the same issue that everyone else in this thread have faced. Now thanks to you I have just known about NimBLE, is there any available library that has light footprint like NimBLE but supporting BLUFI. |
Hi @QuangNguyen1412 |
I was thinking the same way, thanks for the info @chegewara |
[STALE_SET] This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions. |
Not stale |
[STALE_CLR] This issue has been removed from the stale queue. Please ensure activity to keep it openin the future. |
When will NimBLE support be added to Arduino? I noticed the branch, IDF release/v3.3, in this project but it does not include the libnimble.a library that is in IDF v3.3. |
@yuetloo it won't be available until it is in a stable release of esp-idf and that release has been integrated to this repo. The only version of esp-idf that has NimBLE today is the master and v4 if esp-idf and neither have a stable release yet, only an early beta/alpha for v4 (which may be from before NimBLE integration). |
I'm really struggling with the BLE library size as I need OTA and BLE and using BLE make my sketch about 47% of 3M e.g. no space for 2 X OTA and Factory ... also I definitely need both as I need to do a OTA over a BLE- e.g. any help with significantly reducing the BLE lib or how to do a OTA with having only two partitions will be of GREAT HELP |
You can use BLE and OTA if you change your partition scheme when uploading, you can use minimal SPIFFS for example |
Why? |
I still want to know the answer, I think the issue is still valid. I hope someone eventually updates this thread with a solution that might become available and we can be notified. |
My solution was to use custom OTA table with only two OTA partitions without Factory partition 👍 Name, Type, SubType, Offset, Size, Flagsnvs, data, nvs, 0x9000, 0x4000, |
there is also a issue with OTA update of big partitions - especially when BLE is use ( as it consumes CPU) if you try standard OTA update the watchdog restarts the app while partition is erased - the work around is to have a custom partition cleaner on chunks of 512K and next tell teh OTA that partition size is 1024 custom eraser 👍 inline esp_err_t OTAEraseWTD() LOG64_SET(F("OTA: Erase WTD...")); erase_partition = esp_ota_get_next_update_partition(NULL);
} uint32_t blockBegin = 0;
} return ESP_OK; } and in OTABegin : ..... err = OTAEraseWTD();
} LOG64_SET(F("OTA: Erase WTD Finish : ")); err = esp_ota_begin(update_partition, 2048, &update_handle); |
This issue is valid and will be valid as long as esp32 will be programmed with arduino and has nothing to do with BLE. This question has been answered here few times already and in few more similar issue topics. Im not trying to be mean, just like i said, its been already answered in that over 2 years period. |
I actually agree that the issue is still there - may be not connected with arduino GUI- but still the BLE library is wrongly huge and need to be fixed |
Thank you for sharing. So far I have been using minimal spiffs for now, but as I add some more functionality to my project I expect I will come up against the size limit again. I'll give that custom partition table a go. My project does require OTA too, so that potential issue you detailed might save me a whole lot of time and frustration! |
My project is 1.6mb with BLE ( 1M BLE ) and the OTA is over BLE - when we started if you try to transport 1.6MB over BLE it was taking about 28 minutes - which is crazy - we managed to get it down to 2 minutes which is OK - but there are a lot of tricks - on which tread to respond - avoid race conditions dealing with WTD and MTU size ... out of the box the BLE lib is only for proof of concept and OTA can work only on WIFI on small projects .. |
Im having few projects with OTA over BLE, most recent is m5stack factory app with OTA over BLE functionality, which will allow very new users to flash prebuild binaries from android and maybe iOS app too. Im not saying BLE library size is not a problem, but it is mostly because of esp-idf library size and cant be change. In arduino BLE library we could shrink it by few kB, but it requires a lot of work to remove C++ variable types and replace with plain C types. There is already one PR merged that is optimizing library size and heap usage. If anyone feel confident feel free to create PR with changes. |
I'm kind of seriously surprised that you able to get stability from OTA over BLE with big near 2mb bin uploads without issues with the WTD - there were plenty of users in the forums with similar issues - in the beginning we got the OTA in source and fixed it, later decided to just patch it using the the described way - the video is when we were at the middle of the optimisation - from 24min to 15min - currently is 2 minutes.. the MTU that we use is : and the safe size for chunk to be erased without WTD is : //OTA constats we also have the same app on iOS also when initialising BLE the following setting are required to work stable on iOS and Android with Bluetooth 4.2 before 4.2 things are not good bleServer->getAdvertising()->setScanResponse(true); and class bleServiceCallbacks: public BLEServerCallbacks .... |
also I'm suggesting using flash frequency 40mhz and DIO -to play safe and get production stability |
also the fastest way to transport data over BLE is to have request/response type type style e.g. the phone sends , the client replay that it is received the phone sends next chunk - the replay need to be done on the BLE lib callback thread ( and take good care about race conditions and as simple as possible synchronisations) the data sometime get truncated by the BLE lib e.g. len of the sent packet should be the first bytes of the packet - |I will also suggest a simple 1 byte checksum the speed that we currently get is about 5-7KBytes / sec |
I have simplified, maybe not production ready, OTA over BLE code. No data check. From notification/indication callback call function to flash data chunk, thats all. |
[STALE_SET] This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions. |
[STALE_DEL] This stale issue has been automatically closed. Thank you for your contributions. |
This library below might be worth mentioning as a light weight BLE only lib for ESP32; |
I was flashing esp32 using examples->camera webserver. I was getting similar error(sketch is too big). "Arduino IDE: Tools -> Partition Scheme:change "Default" to "Huge APP(3MB No OTA)"" |
A crude workaround for the big Bluetooth library is to employ an ESP32 module with a bigger Flash memory. |
I have done dozens ble apps, including AWSfreeRTOS with ble, and i never had to use bigger flash size than 4MB. Always with OTA. Also you can find modules with 8MB flash. |
Tools -> Partition sheme -> Huge App (select this Partition) |
This works for me. |
<3333333333333333333333333333 |
Has anyone found a small BT Classic library? I'm having size issues with BLE library + OTA (i need both), I'll not use BLE, only classic bluetooth. |
Hardware:
Board: ESP32 Dev Module
Core Installation/update date: 31/dec/2017?
IDE name: Arduino IDE 1.8.4
Flash Frequency: ?40Mhz?
Upload Speed: ?115200?
Description:
Using BLE library to add BLE uart connection capability to an existing code, has increased the size of the .bin of more than 630kb and build failed:
Debug Messages:
`Program too big. The size is 1349762 bytes (of a 1310720 byte maximum). Ensure debugging is OFF and/or see http://www.arduino.cc/en/Guide/Troubleshooting#size for tips on reducing it.
Build failed for project 'ESP32_OpenSprinkler'
I Never thought I could have hit that limit!!
Any way to decrease size of those libraries??
The text was updated successfully, but these errors were encountered: