I am thinking about a way to update the contents of the flash disk via ethernet. What I did is:
Setup a nfs server to offer home dir for the target
Mounted the home dir of the target to the nfs server
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
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?
Thank very much in advance.
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.
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…
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.
Telnet to my target as root.
Mount an nfs partition from the server, which includes the disk image, copy, flashctl, shutdown
Erase the flash disk
Copy the image to /dev/fs0 using my static linked program
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.