accessing flash raw partition

Hi all,

On my system I have a flash chip and I created 2 partitions, the first
one contains a filessystem and the second one is raw and contains the
boot loader and the QNX image.

I would like to access the raw partition (/dev/fs0p1) to be able to
update the QNX image. I works with command line tools:
flashctl -p /dev/fs0p1 -l 4M -e -v
cp /tmp/QNX.bin /dev/fs0p1

But I would like to access it from my own program. I tried with write()
and writeblock() but it failed, only the first call to write succeed and
for the second call I get an error.

Any idea?