Spiffs file system shortcut/auto upload

HI all,

Hopefully this is a quick one, I know that if i have my spiffs configuration .CSV file in my root and I run “pio run -t uploadfs” my data folder gets packed up and sent to the spiffs file system all nice and tidy, buuuuuut… I want to ideally be able to do it either, whenever I have modified the contents of the data folder or just when I run a code upload get the spiffs stuff sent automatically with the build of code/&/or change to spiffs. I am sure i am just missing an environment setting and I have gone RTFM blind from the past few days of help files :crazy_face: and a Happy 4th of July to my 'murican friends.

If it’s not implemented, which it isn’t to the best of my knowledge, it’s best to open a feature request in Issues · platformio/platformio-core · GitHub

2 Likes

Splitting that in to two parts

  1. whenever I have modified the contents of the data folder
    Don’t think this is implemented… and would suggest it won’t… as it would require a daemon/watcher to be running the whole time, and some sort of time delay because you don’t want it to be updated twice if you make two edits a few seconds apart (which would then have to be configurable, because how long of a delay is enough or too much?, as well as the feature itself being enabled at all).

  2. just when I run a code upload get the spiffs stuff sent automatically
    Don’t know of an option for this, which would be handy. I wonder if it could be added via the extra_scripts functionality?

1 Like

Yup, I’ll have a look into it on option 2, something that only does it if the contents has changed would also be nice.

To be honest an extra Icon next to the normal upload stuff would be good enough image

1 Like

+1 for this feature!

Not really. Just compare the modification times of the files like makefile does. This only has to run when the task runs.

Here is a nice script to run pre-build. It builds and uploads the data image only when a file has been changed, added, or deleted.

import os

projDirPath  = '<your project path>'
dataDirPath  = projDirPath + '\\data'
timeFilePath = projDirPath + '\\spiffs-timesum.txt'

if(not os.path.exists(timeFilePath)):
  timeFile = open(timeFilePath, "w")
  timeFile.write("0.0")
  timeFile.close()

timeFile = open(timeFilePath, "r")
oldTime = float(timeFile.read())
timeFile.close()
# print(oldTime)

newTime = float((sum(os.path.getmtime(os.path.join(dataDirPath, file_name)) for file_name in os.listdir(dataDirPath))))
# print(newTime)

if newTime != oldTime:
  print("\nfile updated in data directory -- building/uploading spiffs image\n")
  os.system('pio run -t uploadfs')

timeFile = open(timeFilePath, "w")
timeFile.write(str(newTime))
timeFile.close()

EDIT: Oops, this uploads the data folder and starts a firmware upload, which then runs this script again in an infinite loop. I’ll have to fix this and edit this script to only upload the data folder. Hold tight …

1 Like

I have no idea how to run a script automatically before or after a build without this infinite loop problem. I guess I’ll run this in vscode from a shortcut key. I really wanted to do it without thinking when uploading the firmware. Oh well …

Did a better resolution than the aforementioned script ever arise? Was this feature ever requested or implemented? Did anyone ever come along with a more turn key solution?