Closed radonnachie closed 2 years ago
@jack-h ?
So, the firmware basically does this (See CosmicFengine.fpga.get_status()
which contains a version number (which might be updated by a user on a new compile) and a build-time timestamp. The latter could be used for the functionality you describe.
The caveat is that you can't read a register at all without providing a register map via fpg file, so, if the supplied fpg file is the wrong one, you won't necessarily be able to determine the version of the running firmware, you might just end up interpreting some random chunk of memory space as the version register. Admittedly, since this chunk is unlikely to contain the same timestamp as the supplied fpg, the software would likely correctly determine a firmware loaded/expected mismatch. It would be better is some amount of versioning info was available in a register with fixed location - alas, this isn't the case.
All the above being said, my preferred behavior would be to warn a user if they provide an fpga which doesn't match the programmed one, but not to automatically go reprogramming, since this is very destructive. Also, I could easily imagine scenarios (I actually do this all the time) where one doesn't know what the programmed image is, so provides an "approximate" (i.e., same register map) fpg file to facilitate reading the version register(s).
More generally, I'm of the general belief that simply instantiating a board connection shouldn't interfere with what the board is doing at the time.
When creating a local python instance, one provides an fpg_file for reference, it isn't programmed: it is up to the user to program the instance there after.
If the firmware writes a unique ID to a register, we can determine whether or not the reference fpg_file needs to be programmed at instantiation.