Commit graph

288 commits

Author SHA1 Message Date
bunnie
8a574f937f bump for xous-rs version pin update 2023-04-27 22:18:30 +08:00
bunnie
1392fdcf33 bump pins for updated log API 2023-04-16 02:27:37 +08:00
bunnie
849c136b90 bump versions because API crate changed 2023-04-12 23:02:30 +08:00
bunnie
8357ab31a5 bump all pins because utralib got updated 2023-04-09 00:48:35 +08:00
bunnie
9c94d6b4c0 bump versions because xous-rs API changed for gdb-stub 2023-04-08 23:49:24 +08:00
bunnie
e469eba167 bump version for utralib patch 2023-04-04 02:13:02 +08:00
bunnie
106cf5dfe6 fix RTC corruption issue on shutdown
Alright, this one was very tricky.

The problem here turns out that if the very last operation
on the RTC was a write before powering off, any spurious
clock/data noise is interpreted as a valid write to the RTC!

Thus, if the last thing you do to the RTC before a suspend is
a write of some sort, the RTC is going to be corrupted. During
shutdown, the RTC lines slam up and down a couple of times:

- they drop low as vcore discharges
- they then pop high once vcore is dead
- they then slowly drop low as vddio drops

in both of these cases, they drop with a very slow (>10ms)
fall time, which gives ample time for the RTC to get excited
and think maybe some data is being written to it! Also on boot,
there is a brief glitch of SDA/SCL at the same time, which looks
very much like a start condition.

Anyways, this patch does two things:

1. Performs a dummy read to a register that is "far from" any
critical data resisters. This puts the I2C state machine
of the RTC in "read" mode, so any future clock cycles just
keep wheeling through the RTC bank as a read, instead of clocking
in data as a write. There is a non-zero chance that the noise
"could" emulate a valid I2C transaction (it'd have to create
the bit pattern that addresses the RTC, with the right timing),
but in practice this hasn't been seen.

2. Disables the RTC block on suspend, prior to suspend. This
will prevent the RTC engine from issuing any new commands as
the core starts to shut down. It's conceivable that e.g. the
"start" bit could randomly flip high as the power goes down
and since the I2C engine is now in the always-on domain it'll
dutifully start clocking out bits as the power goes away.

This patch seems to have stabilized the RTC corruption problem
that was previously witnessed.
2023-03-24 01:31:25 +08:00
bunnie
19b3014f4b have the RTC recover more gracefully from a "line noise" shutdown
simply throwing errors over and over again in a loop doesn't help anyone.
2023-03-24 01:30:41 +08:00
bunnie
4800cca65e add helper function to extract bcd time values 2023-03-24 01:30:15 +08:00
bunnie
6f80923609 fix hosted mode...again... 2023-03-23 21:38:17 +08:00
bunnie
80bbdd10a5 fix double-free error (take 2) 2023-03-23 21:34:29 +08:00
bunnie
e26df60599 disable WFI during I2C transactions
CPU is sleeping during I2C transactions, leaving the bus in a state
where the I2C transaction is continuously being fired over and over
again because the way LiteX creates CSRStorage, it gives the
CPU precedence over the block's update.

Basically what happens is that the CPU writes something to the
I2C, goes to sleep, and leaves the I2C block selected. This causes
the I2C block unable to clear its own I2C transaction initiation
register, subsequently leading to the I2C transaction being repeated
over and over again until the CPU wakes up and stops jamming the
bus in that state.

By forcing WFI on during I2C transactions, the CPU is more responsive
during I2C and also we prevent the I2C transactions from being restarted.

This was verified using an oscilloscope.
2023-03-23 21:20:33 +08:00
bunnie
33960277c1 fix hosted mode 2023-03-23 17:52:59 +08:00
bunnie
78e9824950 log if an unexpected interrupt happens on I2C 2023-03-23 16:01:13 +08:00
bunnie
4af7699f0d remove double-free path in I2C driver 2023-03-23 15:30:55 +08:00
bunnie
704aaf98af bump versions for kernel interface changes 2023-03-22 02:48:55 +08:00
bunnie
ce9d5522c9 recover gracefully from I2C errors on resume
fix an issue where I2C, if not working well on resume, is not
recovered correctly. This patch improves that and hardens
the RTC code so that it handles a case that normally panics
with a try-harder loop.
2023-03-19 00:55:07 +08:00
bunnie
2b40e3e262 fix hosted mode 2023-03-18 00:12:56 +08:00
bunnie
ee6561f5d9 fix bugs in i2c timeout handler
seems to work now, recovers from timeout conditions more gracefully.
2023-03-18 00:06:35 +08:00
bunnie
900dbc3c51 fix hosted mode 2023-03-17 22:15:46 +08:00
bunnie
76a7d05156 add timeout logic to I2C driver 2023-03-17 22:12:02 +08:00
bunnie
5efbff0098 add note about GPIO usage vs WFI mode 2023-03-17 02:24:57 +08:00
bunnie
303f595d6f bump versions to cleanup renode.rs sync issue 2023-03-14 16:34:53 +08:00
bunnie
82e3aa322f bump toml files in prep for publish 2023-03-08 03:54:37 +08:00
bunnie
9be79e1038 remove CRG from llio as it is unused 2023-02-28 03:55:21 +08:00
bunnie
9b3aeeecc2 improve debug telemetry on llio 2023-02-27 01:25:29 +08:00
bunnie
981abbf503 cleanup some comments, tweak the stress test
the battery switchover behavior is guaranteed by the time management
servers, so we don't redundantly set it in the alarms.
2023-02-01 03:51:09 +08:00
bunnie
e4caa84463 work around some more RTC derpiness
This isn't in the spec sheet, and I can't figure out why it
is the case, but emperically it is the case.

The RTC is much more reliable at absorbing values writen
to it if they are immediately read back.

I suspect it may have something to do with their internal
synchronizer that locks out updates to registers while
any of the time registers are being updated. It doesn't say
that a read is required to clear that lock, but empricially
sometimes I find the RTC gets "hung" returning 0xFF all
the time, unless some dummy reads follow up writes.
2023-02-01 03:17:31 +08:00
bunnie
c50c9358c5 add option for disabling repeated start condition
A very tiny bit of fine print in the RTC datasheet
indicates that the RTC hardware unit is derpy and it does
not support repeated starts. In this case, a stop condition
must be issued between a write that sets an address, and
the subsequent read transaction.
2023-02-01 03:15:53 +08:00
bunnie
7cf448c0d1 fix more corner cases on suspend/resume vs i2c mutex 2023-01-31 19:11:47 +08:00
bunnie
f860f7bb33 add a mutex guard around I2C transactions
Individual I2C register reads and writes, even if to multiple bytes,
are atomic.

However, some i2c operations require multiple reads and writes
to be strung together without interruption for them to be valid.
A "mutex" is added, which if a program using I2C calls it prior
to their I2C operation, it will block if another program is
already using the I2C block for an uninterruptable series of
operations. The caller will automatically be unblocked once
the untinterruptable transactionts are completed.

Note that this is a collaborative exercise, a caller can still
try to initiate an I2C operation without getting a mutex first,
in which case it could interrupt another block that is doing something
uninterruptable. At the moment this merely generates a warning on
the console, but eventually, this will become a panic.
2023-01-31 18:22:10 +08:00
bunnie
9256e7cc09 bump versions to absorb xous-names fix 2023-01-31 15:07:32 +08:00
bunnie
84368c3f3a bump versions for publication 2023-01-31 02:18:12 +08:00
bunnie
232a4b6c6c bump xous version 2023-01-18 00:02:46 +08:00
bunnie
41d4837551 bump versions to absorb WDT change 2023-01-06 17:48:12 +08:00
bunnie
bb5d7b3adf bump versions to absorb hosted mode fix 2023-01-05 14:07:24 +08:00
bunnie
36398810dd bump version numbers to absorb new syscalls 2022-12-30 15:24:36 +08:00
bunnie
5370ce396d bump all revs due to SoC artifact update 2022-12-12 16:07:20 +08:00
bunnie
02f9701546 make an explicit dvt feature to simplify flags 2022-12-08 17:42:12 +08:00
bunnie
4dd983bfc4 adjust security parameters for dvt build 2022-12-08 17:19:05 +08:00
bunnie
1d1b3a35b7 commit version bump 2022-11-26 10:00:44 +08:00
bunnie
aa9977cc58 bump all the things because we changed utralib again 2022-11-17 22:13:40 +08:00
bunnie
dabbfd6c35 bump all the things to absorb the SoC change 2022-11-17 19:39:18 +08:00
bunnie
a7162fd03c bump xous-names dependents 2022-11-07 22:19:38 +08:00
bunnie
30583bdf07 bump versions with xous change 2022-11-06 03:48:12 +08:00
bunnie
ba28dd8795 bump to absorb utralib straggler configs 2022-10-28 15:11:17 +08:00
bunnie
dfb10ed7f2 bump crate numbers to publish lang-fr change into xous-rs 2022-10-28 14:01:09 +08:00
bunnie
0ee9ec1d80 bump version numbers for crate publication 2022-10-25 22:38:58 +08:00
Jean-Pierre De Jesus DIAZ
f5176ea380
Remove xous-rs unused features
The rationale is that xous-rs should have only architecture
specific code, e.g.: riscv, arm, x86, etc. To make other
crates that depend on it not specify the features.

This could be useful when using xous-rs with `libstd`
for example.

Signed-off-by: Jean-Pierre De Jesus DIAZ <me@jeandudey.tech>
2022-10-25 13:29:15 +02:00
bunnie
d331d405ee bump version numbers for publication 2022-10-25 17:23:40 +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
805a7d528c flip back to using remote references 2022-10-20 16:30:06 +08:00
bunnie
8e05925cfa somehow the transition to local paths got missed in the merge 2022-10-18 00:39:01 +08:00
bunnie
0584ad2f2c switch to local paths to see if this helps the build 2022-10-18 00:26:56 +08:00
bunnie
4d1da235a9 bump revs that depend on susres to absorb changes 2022-10-17 05:11:09 +08:00
bunnie
4b368d71db bump versions of crates 2022-10-15 01:31:54 +08:00
bunnie
63a87ca1bc bump all the versions 2022-10-14 16:54:43 +08:00
bunnie
ff30131f43 absorb more fixes into the kernel 2022-10-13 04:08:56 +08:00
bunnie
3503965f98 bump versions to absorb xous-rs changes 2022-10-13 03:41:16 +08:00
Jean-Pierre De Jesus DIAZ
479694869a
services/llio: Implement From instead of Into
Signed-off-by: Jean-Pierre De Jesus DIAZ <me@jeandudey.tech>
2022-10-12 15:38:42 +02:00
bunnie
f8a2ea51bb remove rkyv warnings from xous-api-names 2022-10-10 03:16:40 +08:00
bunnie
02b80425f5 bump xous-rs to absorb change in language specification 2022-10-10 03:07:44 +08:00
bunnie
3bca9de2a0 bump version numbers for xous-kernel patch
this fixes tests in CI
2022-10-05 23:51:35 +08:00
bunnie
969f93b001 cross-repo update versions from xous-rs bump 2022-10-05 18:32:44 +08:00
bunnie
9dcc0a3386 absorb ticktimer api bump, propagated from susres bump 2022-10-03 04:40:06 +08:00
bunnie
d2b2383d1a bump susres version 2022-10-03 04:36:32 +08:00
bunnie
b184bfbe6a move ticktimer to remote api 2022-10-03 03:37:38 +08:00
bunnie
89ca75c4bf move over to remote susres api 2022-10-03 02:24:44 +08:00
bunnie
6123e8ff9b xous-names conversion to crates.io 2022-10-03 01:18:20 +08:00
bunnie
de514ac66f rename packages in prep for upload to crates.io 2022-10-03 00:24:45 +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
fb29c9b2c1 refactor utra target line to use explicit feature targets
still need to rework the crate feature selection
2022-10-02 02:20:03 +08:00
bunnie
ecab0ba045 fix default-features in services 2022-09-27 02:44:46 +08:00
bunnie
d667d7e1f5 bump xous-ipc version 2022-09-27 01:14:43 +08:00
bunnie
f188e0f866 re-bump xous-ipc to 0.9.9 2022-09-26 16:50:38 +08:00
bunnie
507ab42836 downgrade xous-ipc to 0.9.7 until i have permissions to push a new version 2022-09-26 16:11:26 +08:00
bunnie
3579dfdd17 update xous-ipc and xous versions 2022-09-26 16:07:35 +08:00
bunnie
114d60bc53 migrate logserver API to external package 2022-09-26 14:06:46 +08:00
bunnie
6cf5135a7d fix #129
just strip out the unused code.
2022-09-23 03:01:18 +08:00
bunnie
d6b8310495 fix a typo
man that would have been a hard bug to track down.
2022-09-22 01:27:10 +08:00
bunnie
900df7b223 add testing feature for rekey in hosted mode to LLIO (dna swap) 2022-07-19 03:16:51 +08:00
bunnie
a1c7abd66d fix version reporting bug
u8 encoded field has to be masked before expanding to u16
2022-07-14 01:59:44 +08:00
bunnie
af1013a1f3 rework SoC semver reporting to use xous-semver 2022-07-11 15:39:42 +08:00
bunnie
c46579117b add the "trusted init" check to hosted mode
need to debug a problem with the IMEF connecting/disconnecting
causing trusted init to fail when there is more than one
plugin in the system.
2022-06-18 01:30:49 +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
e14e6206ed include a getrandom implementation that allows us to use modern randcore
A lot of packages are depending on 0.6 api, which requires a crate
that has OS specific TRNG calls. This patch keeps the 0.5 calls
inside the TRNG crate as direct API calls, and migrates to support
a 0.6 api to a patched version of getrandom that supports Xous.
2022-05-29 02:47:51 +08:00
bunnie
78611f97c4 remove USB checkup functions from LLIO crate 2022-05-17 02:25:28 +08:00
bunnie
15d16ab490 add warnings to remind about moving USB disable to the usbdev server once it's possible 2022-05-06 13:40:32 +08:00
bunnie
1b25f4c11d fix hosted mode 2022-04-06 13:38:44 +08:00
bunnie
33d8275321 refactor I2C to use deferred message responses instead of busy waits
This is a start on issue #111, where instead of starting a throw-away
server and doing a "yield" loop to emulate blocking behavior, messages
are instead stored so they don't drop, thus keeping a blocking
message blocking.
2022-04-06 03:35:43 +08:00
bunnie
c503316c3d refactor suspend/resume ordering
Add a "Later" stage, and have exactly one "Last" stage.

"Last" to suspend is the ticktimer -- this is crucial for
basically everything else to work. The other really
low level stuff that needs to work to the last minute is
now in the "Later" bin.
2022-03-30 02:30:39 +08:00
bunnie
da89a61a28 retire work around for rust issue 90195 in I2C 2022-03-29 16:24:14 +08:00
bunnie
2da52a1d5c fix millis vs seconds bug in hosted mode 2022-03-28 15:39:42 +08:00
bunnie
c69b9e451d unbreak hosted mode 2022-03-28 04:04:38 +08:00
bunnie
c78273f540 refactor time setting to make a little more sense
now you set time in local time. If time zone hasn't been set already,
it'll prompt you to enter a time zone.

The main oddity is now that you have to know your time zone as
an offset from UTC. This can be fixed later with a proper symbolic
TZ to numeric mapping, but, that's actually a surprisingly hard
feature to implement.
2022-03-28 03:37:27 +08:00
bunnie
ed8f4d71cf fix suspend/resume issue with RTC (forgot to mask out bits on control register) 2022-03-28 01:19:02 +08:00
bunnie
ee695d0181 turn off time init check after it returns true
this reduces a bit of message chatter for a call that may be
called quite frequently.
2022-03-27 17:08:16 +08:00
bunnie
2340686e80 rate limit error messages 2022-03-27 16:45:00 +08:00
bunnie
2751aa03d3 add a localtime server plus other annotations
std::time::SystemTime returns time in UTC.

That's great, but a lot of times we want local time.

Unfortunately, we can't use `chrono` to do that, because
chrono figures out what your time zone is usind `libc`, which
is a thing Xous doesn't have.

the `LocalTime` server is Xous' solution to that problem. it
returns the corret time offset based on the time zone.

You can still use `chrono` to convert the returned time into
strings and to compute durations.
2022-03-27 04:08:36 +08:00