Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building example outside of the example folder does not work #428

Open
Murmele opened this issue Jan 7, 2024 · 0 comments
Open

Building example outside of the example folder does not work #428

Murmele opened this issue Jan 7, 2024 · 0 comments

Comments

@Murmele
Copy link

Murmele commented Jan 7, 2024

When modifying the example so that it is indipended of the paths (using the upstream hal libraries) the example works only when it is in the examples folder. Copying out did not work.
I found the .cargo/config.toml file in the examples folder makes the difference.

Steps to reproduce

  1. Get for example hello-world running in the examples folder (remove all cfg, and change depedencies to use the upstream)
  2. Check the size with cargo size --bin hello-world --release -- -A
hello-world  :
section               size        addr
.vector_table          256         0x0
.text                 3836       0x100
.rodata                240       0xffc
.data                    0  0x20000000
.gnu.sgstubs             0      0x1100
.bss                     4  0x20000000
.uninit                  0  0x20000004
.comment                64         0x0
.ARM.attributes         58         0x0
.debug_frame         29572         0x0
.debug_loc             109         0x0
.debug_abbrev         4385         0x0
.debug_info         179411         0x0
.debug_aranges        8968         0x0
.debug_ranges       145744         0x0
.debug_str          296198         0x0
.debug_pubnames     101827         0x0
.debug_pubtypes        827         0x0
.debug_line         192161         0x0
Total               963660
  1. Copy the example project somewhere else and repeat step 2 again.

Observed

No program in binary

hello-world  :
section               size   addr
.comment                64    0x0
.ARM.attributes         58    0x0
.debug_frame         29572    0x0
.debug_loc             109    0x0
.debug_abbrev         4385    0x0
.debug_info         179411    0x0
.debug_aranges        8968    0x0
.debug_ranges       145744    0x0
.debug_str          296198    0x0
.debug_pubnames     101827    0x0
.debug_pubtypes        827    0x0
.debug_line         192161    0x0
Total               959324

Expected

The result is the same as in step 2

How to fix

Copy the config.toml file into the project .cargo folder and set correct target for running.

[target.'cfg(all(target_arch = "arm", target_os = "none"))']
runner = 'arm-none-eabi-gdb'
rustflags = [
    "-C", "link-arg=-Tlink.x",
]

[build]
target = "thumbv7em-none-eabihf"     # Cortex-M4F and Cortex-M7F (with FPU)

I did not found any documentation that this step is required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant