Development workflows - mount a folder from your device to your local system for development and testing

Hi Maggie,

Great post as always :slight_smile:

Just chiming in with the workflow I’m using.
My projects are generally done in Java and usually consist of using multiple peripherals and connecting to a server to obtain configuration and send measurements.

In general, I try to (unit) test my code locally before going through the hoops to run it on the target hardware. This works to some degree, but completely misses all the timing issues you get from running a bunch of different peripherals at the same time.

At the moment when I want to debug something that’s in development, I will run my container with the balena-idle command and then either push a new jar through live-push, or pull it via sftp.
I’ve added an environment variable to launch it with debug parameters: ENV JAVA_DEBUG="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=0.0.0.0:1234".

Where I usually just run java -jar ${app_jarfile}, I use java ${JAVA_DEBUG} -jar ${app_jarfile} for debugging, and then connect to the process with the remote java debugger in Eclipse.
This requires me to configure the IP address of the device in the debug/launch configuration manually.

In general, my debugging cycle requires these steps:

  1. Find the IP of the device to use;
  2. Configure the device not to run the production executable, but be ready for debugging;
  3. Deploy the newly built executable (~20MB for my larger project);
  4. Run the executable with debug parameters;
  5. Configure and launch the debugger;

Steps 1 and 3 could be automated by simply changing the Dockerfile to call the executable with the debug parameters, instead of waiting for me to do it manually; though I kinda like the device to be idle when not actively debugging, this also prevents annoying restart cycles when something gets messed up.

For step 2, the live push seems to work okay most of the time; though sometimes it breaks, NFS could help.

I’m fairly certain that step 4 can be done more easily by setting up local port forwarding to the device in question. This would effectively move the re-configuration part outside of the IDE.

Now on to your suggestion.
I think that git clone on the device, can be pretty tricky if you’re still working on fine-tuning your Dockerfile and need to rebuild your container/image as it might cause you to pull in from the repo over and over again.
It might be more efficient to clone to a folder on your development machine, and have your device mount that instead; your local network will also probably be faster than your internet connection, causing syncs to be faster.

Hope you can find some use for this post :slight_smile:

1 Like