Importing compressed binary file

Hi team, is there any way to import a compressed file into the firmware during compile?
I’m trying to get past the firmware size limitation to flash onto the device.

I know I can use the SD card, but trying to do it without it. In a header file, I’m defining a large array of Unsigned Long Long [20k approximately) which stores a values up to 13 digits . I was thinking, perhaps I could compress it into a binary file, import, compile, flash the device. Then when it boots up, decompress and load into RAM.

The error I get is the following:
particle-firmware.elf section .text' will not fit in region APP_FLASH’
region `APP_FLASH’ overflowed by 11888 bytes
collect2: error: ld returned 1 exit status

Thank you!

@wasphax, the Boron has 2MB of external flash which can be accessed via LittleFS if you use DeviceOS 2.0.0-rc.2. You could write an app with the 20KB of data in a const array which it would write out to a LittleFS file on the external flash. Then download your regular app which would read the LittleFS file into RAM or simply access the data from there directly. Nice thing is that all this can be done OTA and if your data never changes, then you only flash it once.

3 Likes

Thanks @peekay123. I think I know what you mean.
First I found it through: On-board 4MB SPI flash
But I can see it’s in the docs: https://docs.particle.io/reference/device-os/firmware/boron/#file-system
Is that what you are referring to? Will give it a try now.

@wasphax, that’s the one!

1 Like

Could I get some clarification please. To get the data into the FileSystem, since I cannot include it at compile time, has to be done either:

  1. Do multiple flashes with writing partial data each time and then finally flashing the main app to use the data, or
  2. In the main app write a function to download the data from internet and save it. So no data is there at compile time.
    Or am I completely missing the point? @peekay123

@wasphax, you said you had 20K of data (large array of uint64_t values). That represents 8 bytes per value for a total of 160KB. So:

  1. Yes, you would need to do two or three apps with partial flashes before running your main app.

  2. Yes, you could use the HttpClient library to download (in chunks) the data from a (non-https) site which you then append to the LittleFS file as each chunk is downloaded. You could also use raw TCP to connect to a server and download the data in chunks as well.

2 Likes

got it, thank you for rconfirming @peekay123

So I ended up using TCP Client https://docs.particle.io/reference/device-os/firmware/boron/#tcpclient
Connecting to a server and downloading the data in bytes.
Then saving it using the File System. https://docs.particle.io/reference/device-os/firmware/boron/#file-system-open.

1 Like