Keith Packard [Fri, 17 May 2013 10:34:50 +0000 (03:34 -0700)]
libaltos: use PurgeComm in Windows altos_close to abort in-progress ops
Instead of manually signalling the related events, use PurgeComm which
can then abort the operations itself. Also make sure all of the
relevant handles are set to INVALID before closing them to avoid race conditions.
Keith Packard [Fri, 17 May 2013 10:21:08 +0000 (03:21 -0700)]
altos/cc1111: Hack on USB driver to make Windows happy
The Windows modem driver is quite chatty at startup time, getting and
setting the comm parameters each time the device is opened. Sometimes,
when setting the parameters, the cc1111 would STALL EP0.
Most of the time, Windows would happily pass this as an error back to
AltosUI which would then re-try the open (and succeed, most of the
time).
Sometimes, Windows would stall for 30 seconds before passing the error
back. This made the whole UI freeze, and I suspect most people assumed
our app had died.
A bit of analysis with the beagle USB sniffer and I discovered the
STALL settings, but there wasn't any correlation between the data on
the wire and when the STALL would be generated.
So, I found a couple of other cc1111 USB stacks on the net and just
looked to see how our driver differed. There wasn't anything clearly
related, but there were a list of small differences:
1) Other drivers didn't bother waiting for the hardware to
ack the USBADDR setting; doing it this way means we can set
the address *before* acking the setup packet. It'll get
set eventually, at which point the device will start responding to
packets again.
Easy to fix, and saves a bit of code space too.
2) The other drivers set the STALL bit for setup packets which aren't
understood. This shouldn't have any effect on 'good' systems as
those shouldn't ever be generating bogus setup packets anyways.
The driver already handled the STALL state in the interrupt
handler, the only requirement was to figure out when to explicitly
set the STALL bit.
That required moving the state updating code from the start of the
ep0 setup handling to the end, after the setup packet had been
examined and data queued in or out as appropriate.
3) Our driver explicitly queued an IN packet for any setup request
that wasn't waiting for an OUT pack. This appears to tie in with
the USBADDR change above as before I made that change, this change
caused the driver to fail to respond to most setup packets.
This was simple once the above change was made, just move the
generation of the IN packet inside the code that switched to the
IN state.
Keith Packard [Tue, 14 May 2013 07:38:34 +0000 (00:38 -0700)]
altosui: Use GPS alt + baro height for KML altitude
GPS altitude is generally more absolutely correct than baro altitude,
so use that as the nominal pad altitude when generating a KML
file. This results in a KML file that has the flight trace start and
end closer to the ground, which is always nice.
Keith Packard [Tue, 14 May 2013 07:24:53 +0000 (00:24 -0700)]
altoslib: Use sequence numbers to track GPS updates to AltosRecord
State objects now record what GPS sequence ID they have to know when
the GPS data has been updated. Record objects bump the GPS sequence
each time new GPS data is recorded. This way, record objects aren't
modified as they're iterated over to generate the list of state
objects which makes it possible to iterate multiple times and get the
same resulting set of states.
Keith Packard [Tue, 14 May 2013 05:27:00 +0000 (22:27 -0700)]
altoslib: Correct hexfile address ranges
Stop trying to use sentinal values for addresses and just keep a
boolean tracking whether they've been initialized. Avoids precision
errors in the variables.
Keith Packard [Mon, 29 Apr 2013 06:06:24 +0000 (23:06 -0700)]
altos: Wait after configuring boot pin before testing it
Clearly the pin isn't quite ready just after it's been configured, so
hang around for a while (100 nops) to let things setting down before
testing the value of the pin. Makes booting a lot more reliable.
Keith Packard [Sat, 27 Apr 2013 07:24:08 +0000 (00:24 -0700)]
altos: Get rodata into flash, make sure sections are aligned
.rodata* needs to be in flash; otherwise strings get left in ram.
Failing to align sections makes the initialized data get dumped into
the wrong place in memory.
Keith Packard [Sun, 24 Mar 2013 22:30:24 +0000 (15:30 -0700)]
ao-tools/lib: Add loading support for 32-bit ihx files
These place the upper 16 bits of the address in a special record. That
requires handling records in file order, so don't sort them in address
order anymore, instead find the bounds of the loaded data by scanning
them all.
Keith Packard [Sun, 24 Mar 2013 22:27:42 +0000 (15:27 -0700)]
altos/stm: Add comments to the .ld files explaining how the romconfig stuff works
Would be nice to be able to explicitly define addresses for the
romconfig variables, but I can't figure out how to make that
work. Instead, just explicitly load the files in teh right order to
make things land in the right places.
Keith Packard [Sat, 23 Mar 2013 09:23:03 +0000 (02:23 -0700)]
altos: Add erase command to stm-flash app. Validate addresses.
This also leaves the code writing fixed values and printing read data
in ascii instead of binary. Useful for debugging, will want changing
for the product.
Keith Packard [Sat, 23 Mar 2013 09:18:55 +0000 (02:18 -0700)]
altos: Validate boot chain start address
If the first block of boot memory has been smashed, and the start
address is bogus, don't bother trying to jump to the
application. This makes the system more resiliant to flash failures,
presuming the loader erases the first block, programs the other blocks
and then finally comes back to program the first block.
Keith Packard [Sat, 23 Mar 2013 09:17:04 +0000 (02:17 -0700)]
altos: Mark .boot section as (NOLOAD)
For some reason, the silly linker marks things in section .boot as
data rather than bss, so they'd end up initialized by default. Force
them to be NOLOAD so they preserve values across reboot so that boot
chaining works properly.
Keith Packard [Mon, 6 May 2013 23:08:52 +0000 (16:08 -0700)]
altos: Set APRS deviation to 3kHz
I finally found a bunch of references to APRS on the net and they all
appear to assume a 3kHz deviation. Let's see if this works better with
Yaesu radios.
Keith Packard [Wed, 1 May 2013 15:56:57 +0000 (08:56 -0700)]
altos: Mark GPS telemetry packets with GPS time stamp
This provides a reasonable accurate indication of the system time when
the GPS location data was received, and also makes sure GPS packets
get some timestamp when no other telemetry is being transmitted.
Keith Packard [Tue, 30 Apr 2013 06:20:25 +0000 (23:20 -0700)]
altos: Compute "real" RSSI value in radio code as needed
Instead of dragging around the weird CC1111 RSSI values, just compute
a dBm value in a signed 8-bit integer, ao_radio_rssi. Use that
everywhere we need RSSI internally. We leave the weird CC1111 value in
the packet reply as that's what the host expects.
Keith Packard [Mon, 29 Apr 2013 06:05:18 +0000 (23:05 -0700)]
altos: Clear any broken cc1120 TX fifo bits before transmitting
This just goes and clears the transmitter before using it, just in
case it got wedged somehow. It also clears the bits while waiting for
the radio to go idle, otherwise it'd never make it.
Keith Packard [Mon, 29 Apr 2013 06:02:12 +0000 (23:02 -0700)]
altos: Provide timeout value to ao_radio_recv
Instead of using ao_alarm around calls to ao_radio_recv, provide an
explicit timeout value as needed by radio functions with more
complicated system interaction than the cc1111. The timeout is 8 bits
of clock ticks.