Sorry. I misunderstood your question yesterday.
I try now to give you the correct answer.
Some time ago I had found this information in another thread. It's a bit tricky but it works.
The (hardware) device id is stored in the epcs configuration data.
You can retrieve it with the following procedure:
- read the config data in EPCS memory a byte at a time, starting at offset zero
- discard 0xFF for an arbitrarily long time
- if you find anything other than 0x56, this is not config data
- extracting bit 4 (mask 0x10) from EPCS bytes 52 to 59 and packing them (LSB first) will give the device ID (e.g. 0xF1 to 0xF6 for Cyclone III)
- like searching for the Software-Device ID code, the configuration bitstream length is encoded in a particular bit of a run of bytes:
Total length field is 32 bits; the 7 most significant bits are encoded in bit 4 (mask 0x10) of EPCS bytes 33 to 39; the remaining 25 bits are encoded in bit 5 (mask 0x20) of EPCS bytes 48 to 72 (LSB first in each run). The length is expressed in bits, so we must discard the last 3 bits to get the byte length
This algorithm is implemented in Nios bootloader in order to find out the firmware location in epcs.