Skip to content

not enough memory? or How to create Resource object directly in heap w/o using Stack #1

Closed
@sbechet

Description

@sbechet

Hello,

I tried to test your example. Very interesting!

Nevertheless i can't make it work. It seems to be a memory problem :
stm32f103 is 20KB only.

  • 13024 bytes for pixels
  • 1628 bytes for attributes
  • 320 bytes for attribute_definitions
    14972 bytes + some reserved types rust bytes

let mut display = VgaDisplay { create a 14972 bytes stack entry then init::LateResources { seems to do a memcpy at fixed Resources space in memory heap as we can see directly in ghidra :

0800047a 09 f1 36 00     add.w      r0,r9,#0x36
0800047e 29 46           mov        r1,r5
08000480 43 f6 7c 22     movw       r2,#14972
08000484 00 f0 9e f8     bl         compiler_builtins::compiler_builtins::arm::__a   undefined __aeabi_memcpy()

So we have an overlap between heap and stack.

A solution can be not to create stack display.

$ rustup show
Default host: x86_64-unknown-linux-gnu
rustup home:  /home/myhome/rustup

installed toolchains
--------------------

stable-x86_64-unknown-linux-gnu (default)
nightly-x86_64-unknown-linux-gnu

installed targets for active toolchain
--------------------------------------

thumbv7m-none-eabi
x86_64-unknown-linux-gnu

active toolchain
----------------

stable-x86_64-unknown-linux-gnu (default)
rustc 1.42.0 (b8cedc004 2020-03-09)


$ rustup default
stable-x86_64-unknown-linux-gnu (default)

$ rustc --version
rustc 1.42.0 (b8cedc004 2020-03-09)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions