I would think that when flashing FW a 1st check would be to determine Flash size .
Most memory's I'm familiar with addresses wrap, if the flash work the same , I would think
you could write a byte starting with highest page then check address 0 to see if it was written ,
repeat by writing byte to next highest page, check address 0 etc.. until size determined...
Then there is the possibility that the flash size may already exist somewhere in the boot loader ?