G-Two / smoke-x-receiver

An ESP32+LoRa application to bridge a ThermoWorks Smoke X remote thermometer to Home Assistant via MQTT
MIT License
14 stars 5 forks source link

Image too large for 8MB flash #2

Closed MikonosII closed 2 years ago

MikonosII commented 2 years ago

I get an error that the image is too large for the flash memory. Looking through the image it is larger than 8MB is there something to remove to make the file smaller.

G-Two commented 2 years ago

The image shouldn't be that large. Can you paste in your results for make size and make www? My results are pasted below:

Total sizes:
Used static DRAM:   49208 bytes ( 131528 remain, 27.2% used)
      .data size:   16536 bytes
      .bss  size:   32672 bytes
Used static IRAM:   91436 bytes (  39636 remain, 69.8% used)
      .text size:   90412 bytes
   .vectors size:    1024 bytes
Used stat D/IRAM:  140644 bytes ( 171164 remain, 45.1% used)
      .data size:   16536 bytes
      .bss  size:   32672 bytes
      .text size:   90412 bytes
   .vectors size:    1024 bytes
Used Flash size :  854473 bytes
      .text     :  697409 bytes
      .rodata   :  156808 bytes
Total image size: 1070417 bytes (.bin may be padded larger)

  File                          Size                                                           Gzipped

  dist/js/about.js              492.52 KiB                                                     138.13 KiB
  dist/js/chunk-vendors.js      292.94 KiB                                                     91.09 KiB
  dist/js/app.js                8.22 KiB                                                       3.09 KiB
  dist/css/chunk-vendors.css    142.59 KiB                                                     22.67 KiB
  dist/css/app.css              0.78 KiB                                                       0.43 KiB
  dist/css/about.css            0.33 KiB                                                       0.16 KiB

  Images and other types of assets omitted.
MikonosII commented 2 years ago

Total sizes: Used static DRAM: 72992 bytes ( 107744 remain, 40.4% used) .data size: 16400 bytes .bss size: 56592 bytes Used static IRAM: 91248 bytes ( 39824 remain, 69.6% used) .text size: 90224 bytes .vectors size: 1024 bytes Used stat D/IRAM: 164240 bytes ( 147568 remain, 52.7% used) .data size: 16400 bytes .bss size: 56592 bytes .text size: 90224 bytes .vectors size: 1024 bytes Used Flash size : 833554 bytes .text : 688286 bytes .rodata : 145012 bytes Total image size: 1048850 bytes (.bin may be padded larger)

File Size Gzipped

dist/js/about.js 492.02 KiB 137.93 KiB dist/js/chunk-vendors.js 292.94 KiB 91.09 KiB dist/js/app.js 8.14 KiB 3.06 KiB dist/css/chunk-vendors.css 142.59 KiB 22.67 KiB dist/css/app.css 0.78 KiB 0.43 KiB dist/css/about.css 0.33 KiB 0.16 KiB

Images and other types of assets omitted.

MikonosII commented 2 years ago

Looks like i cannot read, i added an extra number in the total size when i was looking last night... i get the following error when trying to make flash

DONE Build complete. The dist directory is ready to be deployed. INFO Check out deployment instructions at https://cli.vuejs.org/guide/deployment.html

Traceback (most recent call last): File "/home/XXX/smoke-x-receiver/esp-idf/components/spiffs/spiffsgen.py", line 409, in create_file block.update_obj(contents_chunk) File "/home/XXX/smoke-x-receiver/esp-idf/components/spiffs/spiffsgen.py", line 323, in update_obj raise SpiffsFullError() main.SpiffsFullError: None

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/XXX/smoke-x-receiver/esp-idf/components/spiffs/spiffsgen.py", line 413, in create_file raise SpiffsFullError main.SpiffsFullError: None

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/XXX/smoke-x-receiver/esp-idf/components/spiffs/spiffsgen.py", line 538, in main() File "/home/XXX/smoke-x-receiver/esp-idf/components/spiffs/spiffsgen.py", line 530, in main spiffs.create_file('/' + os.path.relpath(full_path, args.base_dir).replace('\', '/'), full_path) File "/home/XXX/smoke-x-receiver/esp-idf/components/spiffs/spiffsgen.py", line 424, in create_file block = self._create_block() File "/home/XXX/smoke-x-receiver/esp-idf/components/spiffs/spiffsgen.py", line 371, in _create_block raise SpiffsFullError('the image size has been exceeded') main.SpiffsFullError: the image size has been exceeded make: *** [Makefile:42: storage_bin] Error 1

G-Two commented 2 years ago

It might be an OS or shell compatibility issue with a find command I put in the Makefile to delete extraneous files

www:
    npm install --prefix web_ui
    npm run --prefix web_ui build
    find -E web_ui/dist -regex ".*/*\.(js|css|ico|html)" -delete
    rm -f web_ui/dist/mockServiceWorker.js

What result do you get when you run du -sh web_ui/dist/*? This directory is what gets packed into spiffs.

proj/smoke_x_receiver % du -sh web_ui/dist/*                                                                                              (dev)smoke_x_receiver
 32K    web_ui/dist/css
4.0K    web_ui/dist/favicon.ico.gz
4.0K    web_ui/dist/index.html.gz
236K    web_ui/dist/js
MikonosII commented 2 years ago

188K web_ui/dist/css 8.0K web_ui/dist/favicon.ico 4.0K web_ui/dist/favicon.ico.gz 4.0K web_ui/dist/index.html 4.0K web_ui/dist/index.html.gz 1.1M web_ui/dist/js

MikonosII commented 2 years ago

It might be an OS or shell compatibility issue with a find command I put in the Makefile to delete extraneous files find -E web_ui/dist -regex "./.(js|css|ico|html)" -delete

Yes the -E is undefinded in ubuntu what was the -E flag doing in your OS?

G-Two commented 2 years ago

I'm using macOS

     -E      Interpret regular expressions followed by -regex and -iregex primaries as extended (modern) regular expressions rather than basic
             regular expressions (BRE's).  The re_format(7) manual page fully describes both formats.
G-Two commented 2 years ago

Try updating the Makefile with this:

www:
    npm install --prefix web_ui
    npm run --prefix web_ui build
+   find web_ui/dist -type f -name '*.js' -delete
+   find web_ui/dist -type f -name '*.css' -delete
+   find web_ui/dist -type f -name '*.ico' -delete
+   find web_ui/dist -type f -name '*.html' -delete
-   find -E web_ui/dist -regex ".*/*\.(js|css|ico|html)" -delete
-   rm -f web_ui/dist/mockServiceWorker.js
MikonosII commented 2 years ago

SUCCESS! Thank you!

G-Two commented 2 years ago

Great! Thanks for reporting the issue and testing the code. I'll push a new commit right now with the Makefile fix (it works fine on macOS, so this is a good change to make it OS agnostic). It'll also include a few stability fixes and web UI improvements. Let me know if you run into any other issues (especially if you have an X4, as all my testing has been with an X2).