on dabao targets the duart is unavailable, so, it's convenient to
have a uart-based debug option in the HAL. this patch creates a
flag that can allow either target.
- add range checking to control access to main array or secure
array. This is purely a software enforced check, but it is in
theory backed by hardware gating that is a back stop in case
an adversary can gain arbitrary code access
- rework the rram primitive to return an error type
- add a `std` implementation stub. It is still missing an IRQ
context handler which ensures that all RRAM writes are atomic,
e.g. you can't take an interrupt in the middle of an RRAM
write because it would screw up the buffer staging.
auth_data actually changes with each signing operation (ostensibly
to prevent replay of signatures coming from tokens) so it has
to be presented as data parallel to the signature, instead of
as a static filed baked into the key header.
This commit revises the header record to reflect this organizatio
of data and also revises the signature check to be in-line
with the protocol.
have to absorb a version change due to xous-semver change
might as well also update the utra/svd generator dependencies
since that's been held off for a long time now.
this is the agnostic version of all of the board targets, which
allows the boot1 to lookup based on the current configuration
which configurations to apply.
I think I've talked myself into giving away $0.20 of parts with
every dabao board so that everyone can run at full frequency.
Originally I thought I'd limit to the minimal configuration with
low frequency operation but since this is the main developer
platform all the benchmarks and first impressions will come
through this board. Crippling it with a slower clock frequency
by omitting the supplementary digital regulator seems
short-sighted, even if it means up slightly subsidizing things
with this extra cost.
this cleans up one unsafe step where we have to assume an
alignment of the data at the cost of the structure being copied
to stack. I think this is a fine trade-off.
this implements the API/HAL split on the HAL side, and also
reveals SPIM channel as a constant that can be just read out
so that spim accessors that need to build from raw parts
can do it without having to re-allocate IOs.
In the API layer, the boards aren't setup with convenience flags.
they are all laid out and the caller needs to know which board
it's trying to resolve. This is because the API layer is agnostic
to board and assumes the tool working with it knows what board
it's working with already.
The HAL layer tries to hide the board-specific stuff, and so
API defines are re-imported there in a board-transparent fashion.
Also add swap descriptors to the API crate, so that the image
generation tools can refer to the exact same structures as
are used inside the code, simplifying image creation maintenance.
this puts a domain separator in every signature block
a domain separator meaning, even though the same private key
maybe be used to sign multiple blocks, because a functional code
is embedded in the block that is tied to the block's function, you
can't take a pre-signed block and shove it into another block's slot
and expect it to work.
the top of memory is reserved for various security structures
the security structures do have some hardware protection
but life is better when we also help programmers avoid triggering
the protections by accident and then just being confused.
just pulled it out of a uuid generator, checked it has no
collisions. At some point, maybe some official repo will allow
us to be "real" but ain't nobody got time for those politics
today.
- combohash constants are moved to API: these need to be in a
dependency-free library so that we can refer to these values in
any context without creating circular dependencies
- sigcheck code is now put into the HAL layer, instead of in the
individual bootloaders. This is because the sigcheck code is re-usable
between boot0/boot1.
- sram timing trimming data has been entered from the XLS file
and put into an array for easy access
- more board initialization functions have been adedd, and cleaned
up to adhere to the rule that pin allocations don't change the state
of the pins, allowing pin allocation calls to be idemptoent (e.g.
you can call it several times without negative effects - the reason
being that the pin setups also return the pin maps, which can then
be passed to the functions of interest to manipulate the pin states)
A macro is added, a bit like this one:
```
encode_oneway! {
#[offset = 80]
pub enum BootWaitCoding {
Disable,
Enable,
}
}
```
Which encodes possible one-way counter states along with their
offset in the one-way counter array.
The states in the enum correspond to the evolution of the counter,
modulo the number of elements in the enume.
The macro also creates a getter for the states, and an incrementer
to try and make this whole process less error-prone.
By adding a resolver to a given glyph set, the glyph set is
automatically pulled into the image.
Glyph set is now co-located in the bao-video process, instead
of the loader.
The orignial argument for putting the font data in the loader
is that it's a large, static blob; by putting it in the loader,
updates can be more compact, and fonts don't need to be schlepped
over every time you have an application update.
This came with consequences. It made verifying the loader more
complicated (because its memory space is split between the graphics
manager and root keys). It also means we have to fix the partition
size for the loader at "fairly large" for fonts, even if we don't
need all of them in all of the configs.
With baochip, we have swap memory! Off-chip memory is cheap and
only the fonts actually used by the host get mapped into main memory.
This means we don't have as much of a trade-off in terms of
cost for fonts if we put them in off-chip swap storage. Also,
the updates are split between swap and main memory, and the roadmap
includes an item for swap to be individually loadable programs
so that if the video server doesn't need an update, it won't be
pulled into the update set.
a small, 256-byte record is added to the top of baremetal records
that is a "poke table" that incorporates what values to put where
for baremetal targets, as well as a zeroization region.
This is generally more efficient because most values are set to
zero, and the only things that generally have a non-zero value
are 'static' variables, which are used extremely sparingly.
The code base had evolved through several code names, interim
names, company names and chip names that alternatively did or did
not exist.
Baochip is the definitive name of the company, and the Baochip1x
(full part number BAO1X2S4F-WA) is the definitivey part number of
the SoC. For convenience, the part number is shortened to 'bao1x'
in most feature flags and variable references.
This commit fixes all of the odd names and removes some unmaintained
early targets.
usb-device has a limitation for this hardware in that it can't
initiate an ep0-receive. It has a hook for flipping ep0 from
IN to OUT (as a modal thing) but for our stack you need to
explicitly setup EP0 to receive - an exact amount of data based
on what's expected - exactly at the point of the setup packet
arriving saying an OUT transaction is pending.
The hack to work-around this is to simply intercept those setup
packets in the handle_event_inner() interrupt handler and initiate
the receive. In fact, the data is completely ignored (in our
application it's setting a baud rate which is fictional in our
system). However, clients such as windows will time out and
refuse to communicate if the OUT packet is not ACK'd, even if
it is ignored.
- endpoint allocator now handles more edge cases. likely there
are still more weird cases to be considered, but it at least
handles the CDC-ACM case of a lone interrupt endpoint that
can't be mix-and-matched with other devices
- initiate OUT to kick off reads
- remove dead code
- handle bulk and interrupt cases for both read and write
- clean up reset edge cases - still more work to do there,
the stack does not recover on second plugin
- better debug output
previously we had no way to correlate an incoming packet
to an actual read from the USB stack because we didn't store
the EP that originated the request
This fixes that issue and also passes on the pending EP requests
correctly to the rest of the stack
there is either a code bug or a compiler issue that is causing
something on stack to be smashed that is causing trouble for
the code base as a whole. Or it could be improperly initialized
statics? unclear. this needs to be worked through.
however, a series of changes were made that make the code
work. The biggest tell is that the code generally works perfectly
when optimizations are off, but when optimizations are on some
shenanigans have to happen to convince the compiler to not split
constant values across the entire arc of the function. More
diagnostics to follow.
NACK bit is now checked after running the transaction, and if
it is set an appropriate error code is returned.
The trait implementation for i2c baremetal calls is also
updated in this commit
in the Xous context, because the IRQ banks are owned by a global
object, not every server can simply refer to the IRQ bits by just
dereferencing a pointer. Instead, it needs to send a message to
the cram_hal_service with an API number which then catches this
and does the dereference on behalf of the caller.
multiple IRQs related to the UDMA will eventually get mapped into
the global IRQ handler for UDMA. Create an enum type that will
help us differentiate this and add a trait that returns the raw bits
for a given IRQ type.
Probably a fancier wrapper should be made to interptet the IRQ
bits but unfortunately there isn't a uniform pattern to the IRQ
mappings, it's pretty much whatever fit into the IRQ space based
on the underlying function. At the moment not even sure if this
is the right register to be chasing, so we'll use this for probing
that aspect and then get fancy later, maybe.
the switch based on target is now absorbed into the new() function.
This paves the way for us to add more CSR ranges into the global
configuration object, i.e. IRQ csrs for I2C.
our implementantation of Buffer can't (currently) dynamically grow
the size of the object to serialize things that are bigger than
a page, so we have to enforce Vec-like objects to have a serialized
size of less than the page limit.
This is a bit of a moving target because it depends on implementation
specific details. A conservative bodge was put in to try and
work around this problem for now.
This was introducing a mysterious "line" artifact on text rendering
in new systems.
Probably need to do some real on-device testing of this change
because the automated tests won't catch a dirty bit error on
the LCD.
cramium-soc i think should be deprecated everywhere because
it is redundant with the board targets: anywhere you see a board
target that includes the crossbar soc it should also transitively
pull in the cramium-soc dependency equivalents.
we'll chase this out more later, but for now we're just trying
to get the PDDB to compile
This is a bad idea because yield_slice() causes the active
process to hand off to a new one (without an IRQ). However,
the idea of most flash operations is we really want them
atomic - we can't have something else decide to go and muck
with flash while say, we are waiting for a page erase to
complete. So, implement spin locking to block the CPU
during phases where the hardware operation is non-interruptable.
BOOKEND test sentinels are moved out of xous-rs, and into the
board definitions allowing us more flexibility on configuration
board-specific test configs (before it was a xous-wide constant,
which seems a bad idea because it makes migrating test infra
hard as the manufacturing infra updates)
MMAP_VIRT as a range is also added is this commit
this allows us move board-specific parameters out of xous-rs
and into a board library that is consistent with the new board
libraries, reducing special case code for Precursor
- writes need at least a "pipe cleaner" to set the pipe in the correct
state
- may also need a "double-write" to commit the data - this is to be
explored with a smaller test case
- DMA write only works over all corners at 700MHz when
FCLK=ACLK (i.e. FCLK is at half rate)
a lot of routines were left blank in the initial port to get
through the core graphics primitives porting. This commit
fills in those missing bits in a fashion that optimizes the
modals for drawing on small displays.
so, there is a fundamental abstraction mismatch in the blitstr
library. In Precursor, I created a rule that you can't draw text
on black backgrounds without some special permissions in highly
trusted contexts.
For baosec, this restriction is removed because the whole OS
can run inside a single chip (i.e. we have eliminated most
easy RAM modification attacks, requires probing/glitching; but
as a trade-off, we don't have as much RAM so we can't afford the
extra abstractions).
The compromise is for OLED-type platforms where inverse drawing
is very common to save power, all text ops are assumed to be XOR
operations (so you're always flipping pixels instead of drawing
at a defined color).
this can accelerate drawing of complicated objects, such as
QR codes, that are composed of many rectangles.
there are some warts...in theory, this should be able to seralize
arbitrary-sized lists, but there must be some bug somewhere
that is preventing it from happening. For now, the list length
is clipped to the capacity of a page of memory.
the text bounds api call is needed in v2 because there is no gam
to mediate this call
clear allows for a fast clear operation that may have hardware
dependent consequences
acquire/release of modals mode is added to the graphics server
as well to implement a feature previously handled by the gam
this is an unsafe bit of code that is necessary because the
panic handler needs to run in its own thread with a hardware
handle to the frame buffer. this allows panics in the main
graphics thread to not cause the panic handler to fail.
So the organization of the code is now the following tiers:
libs/cramium-api: contains hardware-abstracted API code to the hardware
layers (traits, some constants, enums, etc.). For example, "here is
an IO trait that lets you configure and set GPIO pins", which could
then be implemented in hardware or emulation. The APIs aren't entirely
generic across all SoCs because they are tweaked to accommodate
quirks of the cramium SoC.
libs/cramium-hal: contains board-specific driver codes that do not
require persistent services to be started. Possibly misnamed because
it also includes not just cramium-chip items, but also e.g. peripherals
to the cramium SoC, such as the PMIC and camera.
services/cramium-hal-service: contains the `main` process that manages
shared resources, such as UDMA, IO pins, IFRAM. These drivers cannot
be delegated to a `lib` crate because there can be only one instance
of these resources, and instead we have to dynamically allocate
access to these through IPC messaging.
services/cramium-emu: hosted mode emulation of things in
cramium-hal-service.
services/bao-video: contains a `main` process that integrates
the camera and OLED driver. This means that all graphic drawing
primitives also interface with this crate. These are condensed
into a single process space to speed up execution, and kept
separate from cramium-hal-services because we want the video
services to not be blocked by, for example, a thread that is
handling I2C things.
ux-api can't do rkyv derives and rely on std items in a
no-std environment. This is necessary because some of the
base layer APIs (frame buffers, points, etc.) are relied
upon in a no-std loader environment to render diagnostics
to the screen. Thus ux-api needs to have a baseline of
primitives available without a std flag.
I thought originally cramium-emu would be a library crate, but
actually, it makes more sense as a "services" crate. The APIs
that cramium-emu would live in cramium-api, and cramium-emu
itself is a bit closer to cramium-hal-service, filling in
the executable bits of code that allow emulation to run.
This is a distillation of cramium-hal items into "pure API"
items so that we can have a parallel cramium-emu crate.
The idea is that the API crate sits on top of both implementations;
the HAL goes to hardware, and EMU goes to hosted mode emulations.
a bunch of imports were in here that should be in blitstr2
let's test this out and see how well these abstractions hold up
as we configure the rest of the OS around it.
ux-api is meant to be a platform-independent set of APIs for
elements involving UX interchange in xous. In particular, it
sets up the path for portability of the gfx/minigfx crates and modals.
realizing a bunch of stuff like the stack expects you to enqueue
the OUT receiver with calls to read() that happen to block, fixing
max packet size that can be different for in and out end points,
and handling quirks of the core when sending setup packets longer than
64 bytes.
the UsbBus implementation is being totally rewritten for the
inside-out IRQ protected scheme.
we can now get past some preliminaries in the link protocol
(i.e., address setting and the first config descriptor), but
a long way to go still in debugging.
the uart in the shared library is claimed by the first process
that touches it, so prints in the shared library at early boot have
to be carefully configured
verilator doesn't implement the TRNG, so the TRNG is bodged.
A warning is left in to help remind us/alert us if the bodge
is accidentally put into production.
the 'dabao' board type is introduced, which is the breakout board
codename.
camera and display are feature-gated behind their respective board
definitions.
mass storage is...somewhat stable now, on both linux and windows,
but there are some corrupt packets. need to look into whether
electrical issue, or if we're stomping the transfer buffers because
we've not managed them correctly.
Also need to reflect on how to turn this API into something
safer...the hardware is doing *so much* in this API, the driver
is basically global mutable state with arbitrary slices you can
write over the ends once you hand things off to the driver.
this is for higher resolution QR code scanning
makes it incompatible with simultaneous USB usage
however, when camera is off, the USB stack can be started, and
vice-versa. Basically, you can't both do active USB and camera
at the same time, but you can do one or the other.
- add USB mass storage state tracking for handler-based intervention
- fix some wait loops
need to regression test this againt a xous-mode USB operation
split the handler out into a function pointer
add callbacks for completion handling of EPs - in-line with
the reference code
improve the pei handling
change visibliity of structures to allow for out of crate
handlers