This is a fixup commit for the previous commit (8D7B9D84).
ZPU is a stack machine where all code, constants, variables and function stack
are stored in a single memory block. Compiler doesn't through any warnings
or errors if the allocated memory is exhausted, so we have to check this
manually.
Our memory size is only 16383 bytes and we already had situation when all of it
is exhausted leading to unpredictable behaviour. Unfortunately we can't know
how much memory exactly do we need, but we estimated that 1300 bytes is enough
for us now, so this is what we're checking.
It'c not critical for production use, because it onlu affect time to lock
on startup or on manual frequency correction, but it makes lock faster
when in testing environment, e.g. in out post-manufacturing testing.
We will then disable forced TCXO DAC setting by UHD host library. This way we
avoid de-calibration on every UHD restart in case of operational GPSDO.
Setting GPSDO LPF to the current calculated frequency after setting the DAC
maually should help GPSDO to converge faster. Right now it starts really slow,
because it starts from a perfect target value.
Users think that these messages indicate some sort of an issue, but
they are part of a normal UHD startup process. So we make them look
rather informational and less scary.
Now we really get to +-1 Hz of the base TCXO frequency precision.
Previously we ignored least significant bits of the frequency due to integer
arithmetics rounding, which meant that we could get up to about 80 ppb of
static frequency error which is not good enough for telco systems.
ZPU firmware was setup to poll uart2 (== UDP port 47172) on the quad_uart.v
core. And uart2 is connected to RXD[3] and TXD[3] in the top level. However,
the GPS UART lines are connected to RXD[2] and TXD[2] in the UCF -- which
would be UART1 in from the quad_uart.v/firmware's perspective.
This fix makes ZPU firmware use uart1 (UDP/49171) instead of uart2.
(The other alternative was to change this assignment in FPGA firmware:
https://github.com/fairwaves/UHD-Fairwaves/blob/4fa97a15a241/fpga/usrp2/top/N2x0/u2plus_umtrx_v2.v#L631)
Quick way to see GPS NMEA data (GPS antenna should be connected and GPS
LED should blink once a second):
echo hello | nc -u 192.168.10.2 49171
Huge kudos to @guruofquality for debugging this problem.