Commit graph

156 commits

Author SHA1 Message Date
bunnie
035bdaf986 complete wifi on/off interface
fully integrates wifi on and off commands. measured standby power
when wifi is off is "immeasurable" (0 mA), so probably < 1-2mA.

fix ui transitions so that the off request is respected, through
sleep/resume cycles as well.
2022-09-20 19:36:55 +08:00
bunnie
6f86aee991 give loopback its own rx buffer
instead of sharing the wifi buffer loopback has its own buffer.
this eliminates a race condition that happens whenever an Rx
happens to happen on the wifi interface while there's loopback
traffic in progress.

also, i see a lot of opportunities to optimize the net stack now
that i have tweaked this path; it might be interesting to break
the receive interrupt out directly into the COM crate instead
of passing it through LLIO then NET then COM and having COM
drain the RX buffer immediately into a local "infinite" sized
queue.

The llio->net->com loop exists because the interrupt handler
for all the i/o is shared within one hardware block, but maybe
i can create an additional interrupt responder for the com
interface just to optimize things a bit in a future SOC update.

Alternatively, I could move all the interrupts into COM and not
have them resident in LLIO. This would optimize for COM latency
at the expence of I2C latency, but that's probably OK because
I2C is much less latency sensitive (i2c and com interrupt, as
mentioned above, share the same hardware block for external
pin-based interrupts).
2022-08-05 15:12:57 +08:00
bunnie
f282cce900 add a loopback re-queue function to the com
the caller also needs to schedule the rx function explicitly,
not handled by these functions.
2022-08-03 03:32:27 +08:00
bunnie
ef164871a1 move COM link error handling up the stack a bit
this allows us to have better error reporting and handle
the cases where the EC is updating and just generating random
vectors more...palatable.
2022-07-16 23:11:13 +08:00
bunnie
b83c75bbf0 enhance com debugging 2022-07-14 03:49:32 +08:00
bunnie
65ee48f100 retrofit com to output semver structures 2022-07-13 04:36:54 +08:00
bunnie
3ee086b257 fix interrupts (broke them trying to do some exceptional error handling) 2022-07-11 04:39:10 +08:00
bunnie
25e8da849e rework semver returns and fix flash verify bugs in COM 2022-07-11 04:07:00 +08:00
bunnie
734a382ae9 add FLASH_VERIFY to COM command set. Add apilevel to com_rs.
This adds the FLASH_VERIFY command, which is going to be used
to help automate some update logic.

The notion of an apilevel has also been added to every com_rs
command; this can be used by the COM to figure out what commands
are valid for talking to the current reported EC version.

The version parsing of the string passed back from the EC has
been replaced with the code in the xous-semver crate.
2022-07-10 01:04:34 +08:00
bunnie
e32ea4d3f5 fix #174 2022-06-10 21:36:53 +08:00
Sean Cross
3ae9d8abf0 apps/services: remove xous::xous_main macro usage
This macro will be removed, since it is no longer necessary. Remove this
macro across the project and replace it with a standard `main()`
function.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-05-31 13:33:30 +08:00
bunnie
2f8c850cd6 fix issue #152 2022-05-24 18:10:47 +08:00
bunnie
4a23cf671d fix hosted mode MAC address 2022-05-17 03:07:56 +08:00
Sean Cross
e91705c0ae services: com: add discriminants to opcodes
Signed-off-by: Sean Cross <sean@xobs.io>
2022-03-17 11:30:03 +08:00
bunnie
fd5c6568d1 trim out some excess redraw calls that are slowing down boot 2022-02-05 18:55:46 +08:00
bunnie
a7c9027d05 make the COM reset no longer open loop; unblock as soon as EC responds 2022-02-05 15:44:47 +08:00
bunnie
06b9f88926 improve test oqc interface with new API 2022-02-04 17:11:42 +08:00
bunnie
43842fb1ce mirror the link ping code into the LinkReset command on the COM
we've got it, might as well use it.
2022-01-31 23:37:43 +08:00
bunnie
3d7ee0663c improve the link sync-up for the EC after a WF200 reset 2022-01-31 23:32:59 +08:00
bunnie
827888ccbb fix up the REFCOUNT on connections
Was doing disjoint loads and stores on an Atomic, really, should
be using the fetch_add, fetch_sub variants to be proper.

Didn't seem to impact anything but maybe there's a future version
of me that high fives me for doing this.
2022-01-31 23:13:10 +08:00
bunnie
faa51908d7 maybe, just maybe...we finally have version info baked into the kernel correctly. 2022-01-31 23:02:32 +08:00
bunnie
2a1ab53e6b fix termination condition detection error 2022-01-31 12:40:26 +08:00
bunnie
9762894550 add timeout on wf200 reset 2022-01-31 05:01:58 +08:00
bunnie
4690075c40 clean build, but...much testing to do. 2022-01-31 04:03:31 +08:00
bunnie
82a7b7ebb3 make wf200 reset a blocking call so other status bits don't de-sync 2022-01-30 19:07:29 +08:00
bunnie
177ad38db2 derive SSID scan on shellchat from the connection manager
The connection manager keeps track of all our SSIDs, not the COM.
2022-01-30 16:53:15 +08:00
bunnie
69a8f2777f change default value on the null SSID string value 2022-01-28 23:32:45 +08:00
bunnie
25bccd9446 THE BALDEST YAK: keyboard injection now working
I wrote in a commit yesterday how there was no ROI on doing this
yet somehow I kept on doing it. I blame poor impulse control.

Turns out there was a series of race conditions and bugs that
caused this thing to "mostly work" on the first go at it but
really hard to debug and get very right.

1. Litex UART has a weird undocumented API. You advance the Rx
FIFO by writing `1` to the PENDING bit, and no other way. However,
you determine if there are any more characters to receive by
reading the EMPTY bit and seeing if it is 1. The previous method
wrote `1` to the PENDING bit and then used the PENDING bit to
see if a character was available, under the theory that the
PENDING bit would be set again if there was still a character.
This is somewhat true, except that the PENDING bit is set only
some amount of time later which is about comparable to a few
CPU instructions, so if you had a fast loop path the PENDING
bit would show as cleared and you'd exit, which would cause
no further interrupts to fire because the interrupt was
effecitvely not acknowledged.

This isn't written up anywhere but I figured this out by
just reading the source code for Litex UART and BIOS:
e8be391504/litex/soc/cores/uart.py (L264-L279)
ccd3ab17be/litex/soc/software/libbase/uart.c (L38-L44)

2. I had the Key Injector IP block in the `sys` domain, which
would have its clock cut when the CPU went to sleep, which would
cause input characters to disappear when the CPU went into power
saving. moving this to "always on" domain fixes that.

3. I had the UART PHY in the always on block (so you could
send or receive exactly one character), but not the
separate UART block (which contained the FIFOs).
The UART block would also go into power
savings, and this would cause FIFO entries to go missing.

4. Escape sequences get sent as a burst of characters. The Key Injector
originally did not have a FIFO of its own, so it would only
remember the *last* key of the sequence that was written, causing
some keys to be dropped occassionally. Adding a 16-deep FIFO
to the injector fixes this.

5. The code I had to read out the injector's results was designed with
the "strobe" bit (to indicate that the FIFO had characters) in the
same regsiter as the character itself. Thus the loop that 1. checked
if the fifo was empty then 2. read and forwarded the character
would actually perform two reads from the FIFO. However, this "mostly worked"
I think because the FIFO retains the last value that was written
even when it was empty, so if only one character was read at a time
everything was fine. It only didn't work when you stuffed two characters
in there, as you'd drop the first one. Reading the FIFO once and
then interpreting the code with a bitmask fixes this.

6. The escape sequences, in their full glory with no dropped characters,
required a refactored parsing routine, which I have now added.

7. backspace->delete mappings, the bane of computer engineers since 1960.

OK. very bald yak. Here I lay down the shears next to several
mooshi pillows stuffed with the finest Yak hair.
2022-01-28 15:17:47 +08:00
bunnie
5a1139a367 move cache flush on susres to just before the suspend event
- also nail down the interrupt handlers from firing from the COM
during suspend
- ensure that connects don't happen while scanning
2022-01-27 22:05:38 +08:00
bunnie
a94bb0e4d7 prevent interrupt storm on sleep from the COM 2022-01-27 15:01:01 +08:00
bunnie
5ef7126ede add better handling for wfx HIF err condition 2022-01-27 14:02:28 +08:00
bunnie
71c017641a fix up some debug messages and other minor nits 2022-01-27 04:07:22 +08:00
bunnie
4c4ca1577f fix connection manager state machine
seems to work a lot better, but needs a lot more testing
2022-01-27 03:56:39 +08:00
bunnie
0cafd10e28 refactor status bar to take advantage of the new fonts 2022-01-22 18:25:39 +08:00
bunnie
18130cddae fix suspend/resume regression
had to pin down the correct order of events to avoid lockups on suspend
2022-01-17 22:46:18 +08:00
bunnie
4f9374e860 add enhanced debugging to the COM for wf200 2022-01-14 15:27:24 +08:00
bunnie
a4bb889a5d update wlan status to a binary version with more detailed output 2022-01-14 02:23:57 +08:00
bunnie
0ba8650731 refactor SSID reporting
later on we'll have to add some UX around this but for now
the command line stuff is a bit nicer.
2022-01-13 21:12:14 +08:00
bunnie
b3788a54af clarify the dependency policy 2022-01-10 16:50:10 +08:00
bunnie
995915ed4e nail down a couple more dependencies, and add a policy note to Cargo.toml
Each Cargo.toml now includes a comment which remnids maintainers
of the dependency policy for Xous (that is, nail down every dependency
to the minor number).
2022-01-10 15:54:27 +08:00
bunnie
dd943c5416 pin down versions and harmonize versions across servers
Versions are pinned down to the minor number. Yes, this means that
we don't automatically pull in features and bug updates from crates.io,
but it also means we don't pull in new attack surfaces and code that
hasn't been tested or reviewed. I'd like this process to be very deliberate
and not automatic for Xous.

The `rand` crate is almost pinned down to a single version, except
for an odd dependency that's pulled in by hosted mode that depends
on rand 0.8.4 via a subordinate dependency via the `tempfile` crate.
Pondering if it's worth it to try and eliminate that, because the
0.8.4 version doesn't get compiled into any version that touches
real hardware. It just makes it harder to analyze the Cargo.lock
file, mostly. I think I'll leave it as-is.
2022-01-10 15:39:55 +08:00
bunnie
b275b1d3c2 move some low-level hardware facing services to "Late" suspend status
So far it's been no problem to suspend these in any order, but as
more services come to rely upon them it's better if they suspend after
any client applications have been suspended.
2022-01-10 13:48:49 +08:00
bunnie
c5fe1bc99b add sequencing to suspend/resume order of operations
this is necessary because we want to make sure that the SPINOR
service does not shut down before the PDDB service finishes syncing
its disks.
2022-01-10 13:45:56 +08:00
bunnie
dd18d94a03 e2e demo of pddb working now, we can store an ssid/password pair...finally. 2022-01-09 13:12:36 +08:00
bunnie
7aa2c7b054 a very basic e2e pddb application that tries to restore a network connection
lots of problems to solve still, but let's pick that up on the refactor
stage -- for now we want to get some evidence that the pddb API is
workable.
2022-01-09 01:29:28 +08:00
bunnie
489a26dd11 fix an issue where we don't decrement the connection counter on drop 2022-01-05 20:01:54 +08:00
bunnie
f53c57ba3f fix up a number of issues in ping
Now that I understand how smoltcp does ping better I have regrets.
The demo example in smoltcp uses a funky macro that was a bit
misleading. I have gotten rid of that but I probably would have made
different decisions in implementing this had I understood the API better.

Anyways. It works, but has some trouble handling the cases of timeouts
sometimes.
2021-10-22 04:08:43 +08:00
bunnie
e6643e725d implement UDP rx 2021-10-18 04:02:55 +08:00
bunnie
3cf1cbaeb6 add visible warnings around COM timeouts 2021-10-17 21:43:39 +08:00
bunnie
f1296d0dfd convert route table to use heap not static memory, since we have heap 2021-10-15 15:44:16 +08:00