In Rust programs one common theme, which is not great for optimizing memory footprint, is the heavy use of collect()
. Iterators are a great abstraction exactly for the reason that you can view items as a set without having to brute force deploy them as such in memory. One area where no language paradigm can protect against is the overuse of computing resource.
One good recipe against this e.g. in a commercial setting would be to set a constraint for core components to be no_std
compatible and have total artistic freedom in user interfacing parts or e.g. storage backend interfacing part i.e. only in I/O code.
Then early steps are slower but sort of investments instead of debt when memory is considered early on…
There’s little gain with the added complexity of Rust to something like Go if this consideration is not done. Sometimes something like Go could do even a better job because then at least garbage collector considers memory constraints..
Preparing for v0.1 of my #zmodem2 crate: https://github.com/jarkkojs/zmodem2/issues/9. It is heapless and has a context structure that takes less than 2 KB of memory. Not sync but sequential because I want for first version to have just correct implementation of the protocol. Works also in no_std
environment.
Great my little zmodem2
crate is now supporting no_std
. Not that useful yet before I have made file transfer API sequential (repeated calls, one per subpacket), or even fully async
compatible (or postpone async
to 0.2).
https://github.com/jarkkojs/zmodem2/commit/bc83180cacf04b5611c4068062408ef0ed75f797
sometimes the most #fortran solution is the best :-) not pretty, probably not too “rustacean” but gets the job done…
https://github.com/jarkkojs/zmodem2/commit/a4ad4508a99b66f46ab9daf0f08956c532285107
now it is pretty easy also add quirks later on without having to maintain a grazy ruleset.
Typography: it matters!
#KerningToo #humor #humour #typography #graphicdesign #writing #writingcommunity
November 2023 - My Linux Kernel work
"-Wstringop-overflow
Late in October I sent a patch to globally enable the -Wstringop-overflow compiler option, which finally landed in linux-next on November 28th. It’s expected to be merged into mainline during the next merge window, likely in the last couple of weeks of December, but “We’ll see”. I plan to send a pull request for this to Linus when the time is right. 🙂 [...]"
You can read the whole post here:
https://embeddedor.com/blog/2023/12/05/november-2023-linux-kernel-work/
Learned how async works in Rust and it looks like straight-forward to convert #zmodem2 crate to that as I have state machine alike structure for both send and return. Given how slow these transfers I make it async only, not async opt-in feature.
After that only some minor things need to be added and fixed and I can finally start gluing it to https://github.com/jarkkojs/tior and start working on its UI again.
For tior I’ll switch also switch to serial2
crate, which provides simpler API, a pro-active maintainer and fully working Windows serial support, which is not the case with seriaport
.
With the asynchronous ZMODEM crate (right now the standard is invoking external program) it is possible to implement file transfer dialog, which shows progress, cancels the transfer according to the specification and generally not get a feeling that system is somehow halted :-)
James Bottomley posted new version of the #HMAC encryption patches for #TPM2: https://lore.kernel.org/linux-integrity/20231127190854.13310-1-James.Bottomley@HansenPartnership.com/T/#t
I spent some time refactoring the tpm_buf
changes because they were the major glitch for me in the earlier versions, and those patches have been included now to this series, which is of course great. The series is probably rather sooner than later ready for inclusion to the mainline.
This adds up to the TPM2 sealed hard drive encryption by mitigating bus interposers by a factor. An interposer is an actor intercepting traffic between the CPU and a discrete TPM chip (i.e. not firmware TPM).
A bus interposer can reset a TPM and replay PCR’s as the chip returns to its initial state, which resets them. To mitigate this, kernel creates HMAC session for each TPM transaction and derives session key from the so.called null hierarchy, which essentially provides a new random seed per TPM reset.
Therefore, interposer’s ability to reset TPM decreases because kernel will not be able to communicate with the TPM and that way indirectly a malicious act can be detected by far better chances than ever before.
IMHO, this fits quite nicely to the stuff that #OpenSUSE and #Ubuntu have been working on lately.
I switched to #helix editor because three advantages weight me more than disadvantage of having to learn away for #vim shortcuts:
init.lua
(and that big pile of plugins).So for the price of few weeks inconvenience I can stop spending time on text editor configuration and/or figuring out on how to install it.
I used #vim and later on neovim fo the period 1998-2023, even before using Linux. I switched to vim in MS-DOS from text editor called #QEDIT :-)
I think I fixup lookup tables for escaping #zmodem traffic by intercepting traffic from lrzsz with “defacto” parameters, i.e. send large chunk of uniform distributed random data. That way I can be sure that I have all the cases, including those not in the specification form 1988.
Later on I can use that as a CI test for my crate. Sort of fuzzing approach. I just need to record all bytes that follow ASCII 24 and that builds my table.
embedded-io
and embedded-io-async
seem to be something i would want to use also for crates meant to be used with std just to future-proof portability. great that there is solution for std::io
issue finally. for me the disability to e.g. not being able to use std::io::Error
in no_std
code has been a huge turndown.
and since these are provided by the Rust HAL team there’s some trust for long-term lifespan. 3rd party solutions in the basic error types and BufRead
is a maintenance risk imho.
this is good enough as far as i’m concerned
So I did a pull request to the hex
crate:
https://github.com/KokaKiwi/rust-hex/pull/83
This sort of scenario is not too uncommon in data flows especially when you want to squeeze everything bit out. E.g. for something like #ZMODEM you’d prefer the implementation to scale from microcontroller to Intel Xeon.
Usage example in my crate:
if encoding == Encoding::ZHEX {
hex::decode_in_slice(&mut out).or::<io::Error>(Err(ErrorKind::InvalidData.into()))?;
out.truncate(out.len() / 2);
}