Commit graph

166 commits

Author SHA1 Message Date
bunnie
043dfd84ae update formatting to latest nightly rules 2024-09-24 01:49:45 +08:00
bunnie
ef718853b2 cleanup borrow issues in com 2024-09-22 23:59:52 +08:00
bunnie
3eb61d3002 regex search/replace instances of xous_ipc::String to String
includes some light touch-up to the API to clean up a consequence
of String not being copy-able anymore
2024-09-22 14:20:24 +08:00
bunnie
61e77ac6e4 fix a doc warning that slipped through the cracks 2024-08-19 03:07:09 +08:00
bunnie
d38ad8a289 format services/com 2024-01-14 22:06:28 +08:00
bunnie
8a67c95d70 cleanup new lints from Rust 1.72 2023-09-17 17:38:49 +08:00
bunnie
680c8b88c7 fix missing init() methods in hosted mode emulation structures 2023-07-16 18:31:14 +08:00
bunnie
a9542f96de restore Box() around com structure 2023-07-16 17:33:43 +08:00
Sean Cross
5ff4498112 com: install interrupt handler after ::new()
Signed-off-by: Sean Cross <sean@xobs.io>
2023-07-16 15:33:27 +08:00
Jean-Pierre De Jesus DIAZ
3e2eb63663
imports: remove com_rs-ref
The crate just re-exports the com_rs crate. This patch changes usages of
com_rs-ref to use com_rs directly.

Signed-off-by: Jean-Pierre De Jesus DIAZ <me@jeandudey.tech>
2023-05-02 14:33:17 +02:00
bunnie
2cda7fc418 give the EC some time to boot before querying its version 2023-03-15 02:26:56 +08:00
bunnie
80ce119c95 fix RSSI calculations 2022-12-12 15:31:06 +08:00
bunnie
749b701687 print backlight debug in hosted mode 2022-11-23 02:52:03 +08:00
bunnie
67fc21fbdd harmonize hosted mode selection, but retain an explicit hosted flag
In general, hosted mode is assumed "by default" if the target
is not Xous. This allows packages to be built cleanly on command
lines that don't know to pass a --feature flag to specify a target.

However, an explicit "hosted" flag is still retained so that we
can confirm the build system intent. This saves us from the failure
mode that we thought we were building for target A, but accidentally
ommitted the flag, and instead we've been silently building for
"hosted" mode without any warning. The main consumer of the "hosted"
flag is now just the build.rs script inside of the utralib.
2022-10-25 17:21:02 +08:00
bunnie
9a4b530046 deprecate instances of llio reboot in favor of susres reboot 2022-10-17 05:05:37 +08:00
Jean-Pierre De Jesus DIAZ
d651ce51cc
services/com: Implement From instead of Into
Signed-off-by: Jean-Pierre De Jesus DIAZ <me@jeandudey.tech>
2022-10-12 15:38:38 +02:00
bunnie
f815ed85b5 fix rust 1.64.0 rkyv warning regressions on unused enum types
rkyv-derived enums throw warnings that they are unused.
Not sure how to get rid of them; I've tried surrounding them in
`#[allow(dead_code)]` directives, and also explicitly creating
each enum variant that I'm aware of through some dummy code and
some log prints of the dummy code calls to ensure the results are
used, and the warnings still persist.

Significantly, the warnings only happen for enums that take
a value. Simple rkyv enums do not throw a warning.

These warnings overwhelm the build logs, so they need to be isolated
in order for us to ensure that the build is clean of other more
important warnings.

The method chosen to isolate them is to take the enums that are
problematic, carve them into their own special file, and add
a file-wide `#![allow(dead_code)]` directive. This only happens
in 7 service crates, and this change commits all of the modifications
in a single big commit that could be undone later if this turns out
to be a compiler regression or something similar.

I also opened an issue with the rkyv maintainer to see what his
opinion is on the situation.

https://github.com/rkyv/rkyv/issues/318
2022-10-09 17:17:20 +08:00
bunnie
4e40ae6c5d move from target selectors to feature selectors for back-ends
This will allow for e.g. xous on riscv32-imac but not a precursor
target, for example: by using feature selectors we get to have
a bigger range of targets that we support, such as for implementations
that haven't been upstreamed or have official target-triples.

The downsides are:

- patch override libraries don't absorb feature flags. so, for
example, the AES crate that is used to patch other crates won't
be aware of the target features without modifying the referencing
crates.

- features are normally meant to be additive, but target features
are mutually exclusive. The mutex is enforced by a check in
utralib that throws a panic on build if two targets are accidentally
selected at the same time.
2022-10-02 02:56:44 +08:00
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
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