rustembeddedrust-cargoobjdump

Cargo objdump doesn't show any binary


I have an STM32F446 microcontroller and I've watched a few different videos about getting started and have tried following them as best I am able (none are for my exact setup of course, so I'm having trouble filling in the gaps I suppose), including this 'guide' from the embedonomicon. The embedonomicon is what I am following most closely.

I think I have done all the initial portions properly (setting up the linker and the main.rs), but when I use cargo objdump --release -- --disassemble --no-show-raw-insn I only get the following:

stm32:  file format elf32-littlearm

From what I understand, there is supposed to be a bunch of binary or hexadecimal or something showing me the contents of the binary file created when I've compiled the project, but nothing else shows up.

I have tried searching in vain to figure out why everything compiles and the command runs, but no binary of any sort shows up. Unfortunately, I can only find people who have had issues with the command failing or the program not compiling in the first place. But, I even viewed the binary file using format-hex stm32 | more, so I know it is not empty.

If someone could please tell me whether or not I have some issue in my command and there should be more information displayed, or whether or not I must have done some previous step wrong and the output of the objdump is correct, I would be very grateful. I am very new to the world of bare-metal programming and there is so much information out there for so many different micro-controllers, that it is hard for me to even know where to look, much less how to adapt other solutions to my specific situation. I truly have not seen anything I think would fix it, but I know I've probably missed something somewhere. Please forgive me if I have.


Solution

  • Just in case anyone else is ever in my same boat, I believe I discovered the answer. The various different tutorials I was trying to piece-meal together made it really difficult to discover this.

    1. I'm sure in the right context, the embedonomicon is right to do this, but for me, setting

      [target.thumbv7em-none-eabi]
      rustflags = ["-C", "link-arg=-Tlink.x"]
      

      was not correct. I'm not sure why, but when I got rid of the [target.thumbv7em-none-eabi] and moved the rustflags line to be on its own, it started actually giving me information (errors).

    2. The variety of different tutorials all use different crates and different levels of abstraction, and most of them in some form or another had the link-arg=-Tlink.x. However, I believe they must have been using a crate that I did not know how to implement which would use the Rust linker and then the linker which it had me write myself was somehow piped in. Again, no idea how that all works. This was most confusing because the embedonomicon had the linker script I wrote called link.x. Every other tutorial still had the rustflags line with -Tlink.x but had the linker they wrote called memory.x. Anyway, if you're not using whatever crate (I believe the cortex-m-rt crate) that most of the other guides were using, then that link.x should be whatever your linker name is (in my case, memory.x)

    1. I have no idea if this matters or not at all, but some guides had the .cargo/config file with the extension .toml, but I removed that along with those other changes and it works fine. Not sure if it would work with the .toml, too.

    Now I am getting the anticipated output from objdump. I hope this is helpful if anyone else ever struggles with what I did.