Update flashdisk online

Hi, There,

I have a x86 SBC with QNX with 16M flash disk.

I am thinking about a way to update the contents of the flash disk via ethernet. What I did is:

  1. Setup a nfs server to offer home dir for the target
  2. Mounted the home dir of the target to the nfs server
  3. Copied image files and ‘cp’ ‘flashctl’ and a script file with:

unmount flash disk

./flashctl -p/dev/fs0p1 -u

erase the flash disk

./flashctl -v -p/dev/fs0 -e
#copy the image to flash disk
cp -V image /dev/fs0
to the home dir

  1. run the script from target

The script can erase the flashdisk, but had a problem with the last line of the script. Because at that time, all the files including the share libs on the flashdisk were erased, the ‘cp’ complaind that can not find the shared lib.

One way possible way might be writing a program (which does not need a shared lib) to cp the image to flashdisk. Are there any other better ways?

Any comments?
Thank very much in advance.
Best regards

That message probably means runtime loader (ldqnx.so) could not be found. It is needed even if you only use static libs.

What you need for your procedure to work is a ramdisk holding all stuff neccessary during the ‘transition period’ while old filesystem is already erased but new one does not yet exist. Usually /proc/boot is sufficient for that, but I don’t know what is your setup.

The cp only needs libc.so and ldqnx.so (which is a link to libc.so). I suspect all you need is something like ‘ln -sP /proc/boot/libc.so /usr/lib/ldqnx.so’. Plus of course all the utilities required to perform the transition - the flashctl, slay, devf-whatever (it may need to be restarted). You could just copy them into /dev/shmem and run from there.

You could also setup LD_LIBRARY_PATH to point to your nfs mounted directory where library are sitting?

Great! I will test the methods tomorrow.
Thank you sooooo much. :slight_smile:

I am not sure if mmap() is supported on NFS filesystems in QNX (you need mmap to load a shared lib). I’d be rather surprized if it was supported.

But regardless of that, LD_LIBRARY_PATH does not help you with the runtime loader. It is expected to be in /usr/lib/ldqnx.so (you can’t use an environment variable to point to a location of an entity that interprets that variable).


Iqor is right! I failed to re-direct the ‘cp’ to use the lib from NFS by setting the LD_LIBRARY_PATH to NFS directory.

Now, the possible solution might be write a some program that do not use any lib and copy the disk image from NFS to the flash disk.

Again, I think the ability of updating the system from NFS should be a very convenient function for the system. You can remotely control your target and update them. You do not need to use any EPROM/flash programmer, floppy/hard driver anymore…

Any suggestions? Thank you in advance.

Hi, there

:slight_smile: :slight_smile::-):-):-):-):slight_smile:

I solved the problem finally. I wrote a program to copy the disk image to /dev/fs0 and use -static option in gcc to make sure it will not access the shared memory.
It works well. And I found ‘shutdown’ can also work without the libs.
The steps:

  1. Telnet to my target as root.
  2. Mount an nfs partition from the server, which includes the disk image, copy, flashctl, shutdown
  3. Erase the flash disk
  4. Copy the image to /dev/fs0 using my static linked program
  5. shutdown to reboot the target

Static linking is unnecessary. You need to realize one thing - the shared libc.so is ALWAYS present in the /proc/boot. Otherwise your system would never boot in the first place. Since most utilities only require libc, all you need is to include /proc/boot into LD_LIBRARY_PATH.

Hi, iqor,

But the static linked ‘copy’ program does work! Do you mean that I can use the normal link for the same program, add /proc/boot into LD_LIBRARY_PATH, and it will work?

I found the ‘cp’ offered by QNX 6.2.1 doesn’t work in my case even I added the /proc/boot.

objdump -x /bin/cp | grep NEED

NEEDED libc.so.2

So it needs libc.so.2 and nothing else. Since /proc/boot must have it for the system to boot, I don’t see how it can not work. Unless you made some mistake…


should take care of it. I do it all the time.