Hello,
I am trying to develop an application that uses etcher-sdk to write SD cards for Raspberry Pi and similar SBCs. I wanted to embed this capability in a larger application rather than just telling my users to use balena etcher.
Another requirement I had: I wanted to write custom configuration files to the SD card on top of the disk image. So far I was able to achieve this by using the balena-image-fs module to modify the disk image file itself before I write it to the SD card. This is great because in theory it doesn’t depend on the linux OS to mount the disk image and write the files to the ext-formatted partition. It should work on Windows too.
So that’s great, I’m really happy with it so far.
The next difficult step for me: I want to also read files off of the SD card after it has been flashed. Why? In short, because that custom configuration which was written to the disk image may not actually work when the machine boots. For whatever reason: maybe the user typed the wifi credential incorrectly. Or maybe my code has a bug. Or maybe a goblin bit the wifi chip off of the PCB. Who knows. Point is, it’s not guaranteed to be able to work or connect to the internet. So in case that happens, it is imperative that the user can easily figure out what happened. My plan was, I would write a script to /etc/rc.local
, then that script would run on boot & append lines to /var/log/mylog.txt
on the SD card as it proceeds through its process. Then when the process fails, the user can simply turn off the SBC, remove the SD card, plug it back into their computer, and then my software will recognize it , read the /var/log/mylog.txt
file and display it.
Of course, I want this to work no matter whether my application is running under linux, windows, or Mac OS. I have been hacking away at this problem for a few days exploring lots of different modules and I haven’t found anything that looks like I can make it work very easily.
Just today, I had a new idea, what if I could use the etcher SDK in reverse, to create a new disk image from the SD card. It’s very silly, but it would potentially work as I can definitely read files from the disk image using balena-image-fs .
Anyway, does anyone have any advice or thoughts ?? Please let me know!