Foxyloxy has quit [Ping timeout: 260 seconds]
Foxyloxy has joined #rust-embedded
PyroPeter has quit [Ping timeout: 268 seconds]
PyroPeter has joined #rust-embedded
fabic has joined #rust-embedded
dcz_ has joined #rust-embedded
fabic has quit [Ping timeout: 252 seconds]
dcz_ has quit [Ping timeout: 265 seconds]
fabic has joined #rust-embedded
fabic has quit [Ping timeout: 265 seconds]
tokomak has joined #rust-embedded
<re_irc> <> = note: rust-lld: error: undefined symbol: WWDG1
<re_irc> <> >>> stm32h7-ac8ecc3dfb39351a.stm32h7.267aa5c4-cgu.0.rcgu.o:(__INTERRUPTS) in archive /Users/jack/src/daisy/target/thumbv7em-none-eabihf/debug/deps/libstm32h7-ac8ecc3dfb39351a.rlib
<re_irc> <> Any ideas what would cause:
<re_irc> <> >>> referenced by stm32h7.267aa5c4-cgu.0
<re_irc> <> I'm converting an example i wrote that worked fine into an rtic app.
<re_irc> <> * `grep cortex-m-rt Cargo.lock` make sure you have exactly one version, multiple different versions will cause problems
<re_irc> <> Usually too much `cortex-m-rt` or not enough `cortex-m-rt`.
<re_irc> <> * Ensure you enabled the `"rt"` feature in the peripheral access crate.
<re_irc> <> Hey korken89, I noticed that `MpMcQueue`, as currently implemented, requires a non-zero initializer, which means it ends up in `.data` instead of `.bss`
<re_irc> <> which can be a problem, because it can "infect" structs that contain an MpMcQueue, like my slab allocator, that is like 64KiB large :D
<re_irc> <> I'm uh... working around that with some creative usage of `UnsafeCell<MaybeUninit<MpMcQueue>>` at the moment, which isn't great, but isn't terrible
<re_irc> <> Is it fixable? I'm not that read into that queue
<re_irc> <> If you can fix a PR I'll merge it :)
<re_irc> <> Mostly it would involve having it be a bit "lazy", e.g. to keep an init flag, and to do the initialization at runtime, either on an explicit `init`, or on first access
<re_irc> <> though that would be potentially non-time-deterministic, and might add a slight cost for the init check on every access
<re_irc> <> I figured having a huge MpMcQueue (or an MpMcQueue attached to something huge) is kind of a niche, and it means everyone who doesn't do that will pay for an extra cycle or two on every operation
<re_irc> <> But it was making my binary like... 70-80KiB larger than it needed to be (seriously, went from 90KiB -> 9 KiB, so flashing got way faster)
<re_irc> <> Maybe worth having a type state wrapper?
<re_irc> <> Like you did not or less
<re_irc> <> The goal is to store this in a `static`, so type state changes are suboptimal
<re_irc> <> (or impossible)
<re_irc> <> Right
<re_irc> <> Yeah then it's only a wrapper with a flag left I guess
fabic has joined #rust-embedded
<re_irc> <> The change isn't too bad, other than a lot of unsafe:
<re_irc> <> in the heapless lib itself, it would mainly mean making the "cell indexes" zero at init time, then doing the initialization loop on-demand
<re_irc> <> This is the problematic part:
<re_irc> <> (which I don't understand)
<re_irc> <> Yeah, us both then :) the mpmc is from before my time.
<re_irc> <> But it sounds like a wrapper with uninit if the most straight forward version
<re_irc> <> (needs to be unsafecell + uninit to keep the ability to make the `init` function only take an `&self`)
<re_irc> <> or really
<re_irc> <> inside of heapless itself
<re_irc> <> you don't need any unsafe at all
<re_irc> <> just an atomicbool that checks for init, and if not, runs the init loop
<re_irc> <> but then on every other interface you need an explicit `self.check_init();` call to do it if needed
<re_irc> <> so you're adding (probably after inlining, in the steady state) an atomic load, a check, and a jump
<re_irc> <> Since I'm outside, without forking heapless, I need the unsafecell + uninit to simulate this behavior. But it could be done safely, at the cost of a slight perf reduction.
<re_irc> <> Anyway, I'll open an issue and write what I find.
<re_irc> <> I can do the PR, it's just "is the runtime cost worth the speedup in flashing"
<re_irc> <> For me, rapidly iterating? Yes :D
<re_irc> <> for prod firmware? ehhhhh probably not
<re_irc> <> hi, who using a nucleo board here ? i did a sketch with but it seems to have difficulties to start when i use a usb power plug instead usb from computer
<re_irc> <> I guess I just talked myself out of it :)
<re_irc> <> yruama_lairba: are you using something like `semihosting`?
<re_irc> <> The semihosting libs will typically block until a debugger is attached
<re_irc> <> Or RTT with a block-on-full mode?
<re_irc> <> which means if you connect it to not-a-computer, your program will never run
<re_irc> <> i use RTT
<re_irc> <> Do you have your code somewhere?
<re_irc> <> sometimes my program run
<re_irc> <> (like a git repo you can share?)
<re_irc> <> sorry i didn't shared it yet the source is very messy
<re_irc> <> where i can put it for temporary ?
<re_irc> <> You can probably change how you init `rtt`, check out this macro:
<re_irc> <> In your RTT setup do you have `BlockIfFull`? You can try changing it to `NoBlockSkip`.
<re_irc> <> Though it looks like `NoBlockSkip` is the default?
<re_irc> <> Oh, hmmm 🤔
<re_irc> <> Oh, do you perhaps have any RTT _reads_ occuring?
<re_irc> <> github is a pretty good place :)
<re_irc> <> jamesmunns: not for temporary stuff in my opinion
<re_irc> <> I have loads of temporary things and hacky repos on my github page :D
<re_irc> <> fair enough
<re_irc> <> ok, so wait ~10 min, i prepare this
<re_irc> <> newam: thanks, that was indeed it. I updated cortex-m-rt to 0.7 but the hal crate uses 0.6. changing to 0.6 everywhere worked.
DepthDeluxe has joined #rust-embedded
<re_irc> <> Discovery boards have a very strict interpretation of the usb standards
<re_irc> <> If the ST Link cannot negotiate 500 mA, of will not take the CPU out of reset
<re_irc> <> And usb power bricks do not negotiate
<re_irc> <> Nucleo boards may be the same
<re_irc> <> You can inject 5V by other means and bypass the ST Link
<re_irc> <> i'm back, here is the repo
<re_irc> <> almindor: Maybe try `#[no_mangle]`
<re_irc> <> yruama_lairba: I don't see anything immediately bad
<re_irc> <> thejpster's advice might be good to try
<re_irc> <> The other suggestion I have is to blink an LED at a slow pace in your `idle` loop, so you can always tell if the firmware is running or not
<re_irc> <> There's a bi colour led
<re_irc> <> The user manual for the board will tell you what the colours mean
<re_irc> <> usually I turn it ON in the init, so I know the code made it through init, then you know if the led stops blinking, it is stuck somewhere
<re_irc> <> ah yeah, the stlink status led will be a good clue too.
<re_irc> <> But one combination is "not running because couldn't negotiate 500 mA"
<re_irc> <> i should add this blinking led, because i'm have a side effect make me thinking it's work while it's not
<re_irc> <> thejpster: checked on datasheet what the tricolor led does, it's just indicate state of communication
<re_irc> <> for now, what i just want to no, can the issue comes from using rtt while not having a computer connected ?
<re_irc> <> Yes and if the st link can't communicate it won't let your code run
<re_irc> <> So you don't exceed the 100 mA USB limit
<re_irc> <> thejpster: so why somtimes my code seems to run anyway ?
<re_irc> <> Define "sometimes"
<re_irc> <> i mean if i push the reset button on the board, it sometimes work (and don't stop)
<re_irc> <> All parts of the STM32 Nucleo board and shield can be powered from the ST-LINK USB connector CN1 (U5V or VBUS). Note that only the ST-LINK part is power supplied before the USB enumeration as the host PC only provides 100 mA to the board at that time. During the USB enumeration, the STM32 Nucleo board requires 300 mA of current to the host PC. If the host is able to provide the required power, the targeted...
<re_irc> ... STM32 microcontroller is powered and the red LED LD3 is turned ON, thus the STM32 Nucleo board and its shield can consume a maximum of 300 mA current, not more. If the host is not able to provide the required current, the targeted STM32 microcontroller and the MCU part including the extension board are not power supplied. As a consequence, the red LED LD3 remains turned OFF. In such a case it is mandatory to use an external...
<re_irc> ... power supply as explained in the next Section 6.3.2: External power supply inputs: VIN and E5V.
<re_irc> <> I'm afraid I don't know why reset might not work sometimes. I just know that you can't use a dumb USB phone charger.
<re_irc> <> If you are using a PC to power the board and you are still having issues with reset, then that sounds like some different issue.
<re_irc> <> ok, so when i get i it working, it's not suposed to be ?
<re_irc> <> no, i meaned i was hitting reset while beeing powered by a phone charger
<re_irc> <> Is JP1 fitted?
<re_irc> <> don't know, my board is just on default setup
<re_irc> <> If JP1 is not fitted, it might be flapping - it selects a "100 mA limit" mode which allows it to work on phone charger.
<re_irc> <> See the note at the bottom of page 20/68 in the PDF I linked.
<re_irc> <> If JP1 is fitted then you can ignore me - it should work fine on a phone charger and your reset issue is something else.
<re_irc> <> can't find jP1 ???
<re_irc> <> ok, jp1 not set
crabbedhaloablut has joined #rust-embedded
<re_irc> <> try putting a jumper on it
<re_irc> <> doesn't change anything
<re_irc> <> ok, issue is not exactly what i though, my firmware may be wrong
<re_irc> <> in fact it deosn't work too wheen i just connect in my computer
<re_irc> <> it doesn't work too when i just run a rtt session
<re_irc> <> weird, heisen bug, it's behaviour change when i try to observe it
<re_irc> <> now it doesn't work anymore with the exactly same condition as before
dcz_ has joined #rust-embedded
<re_irc> <> Does anyone know how to make a `*-ptr`? Ie, with the CMSIS wrapper, imitating this line of C: ` float32_t *inputF32, *outputF32;`
<re_irc> <> From (this example)[
<re_irc> <> }
<re_irc> <> called like this:
<re_irc> <> It seems like `inputF32` and `outputF32` would be buffers, but you add floats(?) to them, so I'm pretty confusedd
<re_irc> <> I'm not sure if they should be initialized like this:
<re_irc> <> let mut input = 0.;
<re_irc> <> ```rust
<re_irc> <> let mut output = 0.;
<re_irc> <> ```rust
<re_irc> <> let mut output = [0.; TEST_SIZE];
<re_irc> <> let input = make_sin(50.);
<re_irc> <> Maybe something like this, also this leads to other errors:
<re_irc> <> Although that triggers issues of adding normal data to pointers in `inputF32 + (i as f32 * BLOCK_SIZE as f32)`
<re_irc> <> I probably just need to read up on pointers; current understanding is magic syntax you copy+paste to make DMA work
<re_irc> <> Gunna start streaming aboot now:
<re_irc> <> Maybe a `as *const _ as u32` thrown in for good measure
<re_irc> <> It seems like this gets past the errors, perhaps:
<re_irc> <> ```rust
<re_irc> <> let mut output = [0.; TEST_SIZE];
<re_irc> <> let input = make_sin(50.);
<re_irc> <> Looks like it could use an API-smoothing wrapper, if this is really how you do it
<re_irc> <> I just changed things around until the compiler stopped throwing errors, which is how I learned Rust
DepthDeluxe has left #rust-embedded [Leaving]
emerent has quit [Ping timeout: 260 seconds]
emerent has joined #rust-embedded
<re_irc> <> You shouldn't add floats to pointers, it doesn't make sense
<re_irc> <> The C lib is probably adding integers to it, not floats
<re_irc> <> It's just how you work with "slices" in C, you pass a pointer to the (first) element and the length, so the function just does pointer arithmetic to access the elements
<re_irc> <> what the hell is that even supposed to do O.o
<re_irc> <> what's the signature of `arm_fir_f32`?
<re_irc> <> maybe you want `&input[i*BLOCK_SIZE..]`/`&output[i*BLOCK_SIZE..]`? but I'm really not sure
dcz_ has quit [Ping timeout: 252 seconds]
<re_irc> <> const float32_t * pSrc,
<re_irc> <> uint32_t blockSize
<re_irc> <> float32_t * pDst,
<re_irc> <> void arm_fir_f32 ( const arm_fir_instance_f32 * S,
<re_irc> <> )
<re_irc> <> Is the C type sig. I'm not sure what the Rust is; figuring it out by adjusting based on compiler messages. I think I'm almost there
<re_irc> <> well it has to come from somewhere, and that somewhere has the function signature...
<re_irc> <> So, I infer it's common to manipulate arrays in C using pointers vice &mut arrays, or something
<re_irc> <> I'm not sure how to get the Rus fn sig, which is a big issue
<re_irc> <> it's made using Bindgen
<re_irc> <> which crate is it from?
<re_irc> <>, a wrapper jacobrosenthal wrote
<re_irc> <> There are no references in C land
<re_irc> <> Right now I"m making a translation guide between C type sigs and rusts
<re_irc> <> Like, when you use the various syntaxes to get certain C type sigs
<re_irc> <> `.as_ptr()`, `.as_mut_ptr()`, `as *const _ as *const f32,` etc. I have a feeling the right combination of those will make this compile
<re_irc> <> I think you want `input[i*BLOCK_SIZE..].as_ptr()` and `output[i*BLOCK_SIZE..].as_mut_ptr()`
<re_irc> <> You can do a lot of crazy non-sense stuff with raw pointers, just because it compiles it doesn't mean it will work
<re_irc> <> And overall, I don't intend to use this wrapper directly once I figure out. Will... wrap the wrapper if you will, in the form of simple functions
<re_irc> <> Valid point
<re_irc> <> no unsafe required.
<re_irc> <> Will give that syntax a shot
<re_irc> <> I'll add PRs to the lib as required with the helper functions and/or examples without them
<re_irc> <> jacobrosenthal: Would you prefer this as an add-in to your wrapper crate, or separate, using your crate as a dep?
<re_irc> <> also, if it doesn't work, post actual errors instead of "it throws errors"
<re_irc> <> Ie a more Rusty API to this bindgen-generated fn calls
<re_irc> <> Yeah, sorry
<re_irc> <> I'll work this for a while and post results. really appreciate this
fabic has quit [Ping timeout: 268 seconds]
<re_irc> <> So, could you look at it as, both Rust and C have a 'low-level' pointer API that maps 1:1, eg with bindgen. Rust also has a higher-level API using arrays and refs, which is easier to work with and safer?
<re_irc> <> And of note, Rust's low level pointer API is substantially more verbose
<re_irc> <> sounds about right to me
<re_irc> <> pretty sure that's intentional - it's very rare that you need to use it, and if you do, you have to write out exactly what you want to do
<re_irc> <> in addition to references and arrays, there are also slices, which are a pointer+length pair (which also comes up all the time in C, but is usually handled using two distinct variables)
tokomak has quit [Ping timeout: 260 seconds]
<re_irc> <> I really like how they did this - Nice 'high-level' rust API for normal use, and 1:1 mapping for C-compatibility. That had to have been deliberate
<re_irc> <> I've evidently dodged the pointer API for a while
<re_irc> <> absolutely, Rust was designed as a language that could incrementally replace existing C++ code at mozilla, which necessitates good C interoperability
<re_irc> <> `-sys` crates are usually just the "bindgen" interface
<re_irc> <> Thanks you. That makes sense; I was wondering about the suffix. I'll make this as a separate crate that pulls in the dep
<re_irc> <> Ok, have this that compiles. Does this look right? C types I'm mimicking are in inline comments:
<re_irc> <> can someon explain how this tidbit works with the linker?
<re_irc> <> I don't understand how the stack size is calculated here, I understand stack "goes up" but the recursive sizing really trips me up
<re_irc> <> REGION_STACK is just RAM which is at 8k, does that mean it'll just take 8k - any previous position for the length and pseudo-recursively assign that to _start_stack ?
<re_irc> <> stack grows downwards, ie when you push something, SP is *decremented*
<re_irc> <> yes that part is clear
<re_irc> <> so stack start/end are "backwards", it's ultra confusing
<re_irc> <> "stack start" is the starting value of SP, which is the *end* of the stack memory region (highest address)
<re_irc> <> oh so when "." "arrives" at the stack declaration it's just taken as _estack and then we jump to complete RAM end and declare it _sstack and that's it
<re_irc> <> "stack end" is the lowest address the stack can grow to, so the *start* of the memory region 🤣
<re_irc> <> yeah
<re_irc> <> `.` is the "current cursor", when you place stuff such as code/data/bss it gets placed at `.`, and `.` gets incremented
<re_irc> <> so when you do `_estack = .;`, `.` has the value of the first address after whatever came before, probably data/bss
<re_irc> <> yeah ok makes sense now, what really tripped me was the "recursive" REGION_STACK (which is just alias for RAM)
<re_irc> <> I was like "how can you do length on this when you're still deciding it later" :D
<re_irc> <> ORIGIN(REGION_STACK), LENGTH(REGION_STACK) come from the MEMORY declaration, they're known beforehand
<re_irc> <> yeah, I didn't realize coz RAM has explicit length, I thought REGION_STACK length would be a separate thing
<re_irc> <> :D
<re_irc> <> linker scripts suck
<re_irc> <> is there even highlighting for them anywhere? :D
<re_irc> <> seriously tho I couldn't find one for VSCode :D
<re_irc> <> hmm found which doesn't show in search for me, installing from file worked tho
<re_irc> <> firefrommoonlight: Yeah that was my thought Also I have usages in this repo
<re_irc> <> Sweet. Looks like Lab2 has FIR examples. Will compare and adjust
<re_irc> <> That MaybeUnit thing looks interesting. If you note in my code I inited the S struct twice with a note about it being awk. I guess MU dodges that
<re_irc> <> Is there an advantage to using the `extern C` code at the bottom of the examples, and the `cty` `_t` integer types, over using native rust types, and the API produced by BIndgen directly?
<re_irc> <> Oh I'm sort of considering that a teaching resource so it builds up th abstraction Inside the example then generalizes is
<re_irc> <> First you would just copy the a file and link it job done. But then you'd want to make it a library and make it support more chips and have a cleaner api
<re_irc> <> Advantage is not using a library that downloads gigs of data to get the single a file you needed :)
<re_irc> <> Thank you for your explanation (And your work on this)
<re_irc> <> I'm working through a lowpass FIR example now based on the official CMSIS one. Not filtering properly yet, but compiling, and passing through the input
<re_irc> <> Type signature of the wrapper:
<re_irc> <> pub fn rust_arm_fir_f32(
<re_irc> <> ```rust
<re_irc> <> input: &[f32],
<re_irc> <> thoughts on that API?
<re_irc> <> My intent is to hide the C-interface stuff so my application code uses normal Rust
<re_irc> <> I think it's working; I just didn't have a good grasp on how the freq mentioned in the example mapped to a dimensionless array
<re_irc> <> Got it to kill high freq signals using hte coeffs from the official ARM example
<re_irc> <> (copy demt output array into python, and plot)
<re_irc> <> - jacobrosenthal Let me know what changes you think I should make
<re_irc> <> I'll add more fns as I learn how to use them