TyberiusPrime / stm32f103_k2k

Keyboard firmware based on the keytokey library for stm32f103 / bluepills
Other
14 stars 3 forks source link

Build failure #3

Closed JoshMcguigan closed 4 years ago

JoshMcguigan commented 4 years ago

Thanks for all your work on this crate and keytokey!

I am attempting to build this crate, but I've run into a couple issues.

First, I pointed keytokey to the version in crates.io rather than the relative path, but that failed. Cloning the latest version of keytokey and using that resolved the issue.

But then I ran into a linking error while running cargo +nightly build:

error: linking with `rust-lld` failed: exit code: 1
  |
  = note: "rust-lld" "-flavor" "gnu" "-L" "/home/josh/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/thumbv7m-none-eabi/lib" "/home/josh/workspace/stm32f103_k2k/target/thumbv7m-none-eabi/debug/deps/k2k_advantage-9ee4e1eea0d05dcb.k2k_advantage.3an5gsiq-cgu.3.rcgu.o" "-o" "/home/josh/workspace/stm32f103_k2k/target/thumbv7m-none-eabi/debug/deps/k2k_advantage-9ee4e1eea0d05dcb" "--gc-sections" "-L" "/home/josh/workspace/stm32f103_k2k/target/thumbv7m-none-eabi/debug/deps" "-L" "/home/josh/workspace/stm32f103_k2k/target/debug/deps" "-L" "/home/josh/workspace/stm32f103_k2k/target/thumbv7m-none-eabi/debug/build/cortex-m-1c07643dc61d17fe/out" "-L" "/home/josh/workspace/stm32f103_k2k/target/thumbv7m-none-eabi/debug/build/cortex-m-9ec7cc9df9f14f15/out" "-L" "/home/josh/workspace/stm32f103_k2k/target/thumbv7m-none-eabi/debug/build/cortex-m-rt-2f556fc7761a41a7/out" "-L" "/home/josh/workspace/stm32f103_k2k/target/thumbv7m-none-eabi/debug/build/cortex-m-semihosting-f647944d1e94d52b/out" "-L" "/home/josh/workspace/stm32f103_k2k/target/thumbv7m-none-eabi/debug/build/stm32f1-b67bc1cfed6d8d6a/out" "-L" "/home/josh/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/thumbv7m-none-eabi/lib" "-Bstatic" "/tmp/rustcrJlfVb/libcortex_m-6e2117ef018ec09b.rlib" "/tmp/rustcrJlfVb/libcortex_m-cc0c9ada6a006dfe.rlib" "/tmp/rustcrJlfVb/libcortex_m_rt-a039bd583dee1948.rlib" "/home/josh/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/thumbv7m-none-eabi/lib/libcompiler_builtins-e4421fe9976098bd.rlib" "-Tlink.x" "-Bdynamic"
  = note: rust-lld: error: section '.text' will not fit in region 'FLASH': overflowed by 10 bytes
          rust-lld: error: section '.text' will not fit in region 'FLASH': overflowed by 44 bytes
          rust-lld: error: section '.text' will not fit in region 'FLASH': overflowed by 58 bytes
          rust-lld: error: section '.text' will not fit in region 'FLASH': overflowed by 60 bytes
          rust-lld: error: section '.text' will not fit in region 'FLASH': overflowed by 106 bytes
          rust-lld: error: section '.text' will not fit in region 'FLASH': overflowed by 108 bytes
          rust-lld: error: section '.text' will not fit in region 'FLASH': overflowed by 122 bytes
          rust-lld: error: section '.text' will not fit in region 'FLASH': overflowed by 206 bytes
          rust-lld: error: section '.text' will not fit in region 'FLASH': overflowed by 244 bytes
          rust-lld: error: section '.text' will not fit in region 'FLASH': overflowed by 252 bytes
          rust-lld: error: section '.text' will not fit in region 'FLASH': overflowed by 298 bytes
          rust-lld: error: section '.text' will not fit in region 'FLASH': overflowed by 306 bytes
          rust-lld: error: section '.text' will not fit in region 'FLASH': overflowed by 308 bytes
          rust-lld: error: section '.text' will not fit in region 'FLASH': overflowed by 318 bytes
          rust-lld: error: section '.text' will not fit in region 'FLASH': overflowed by 322 bytes
          rust-lld: error: section '.text' will not fit in region 'FLASH': overflowed by 332 bytes
          rust-lld: error: section '.text' will not fit in region 'FLASH': overflowed by 342 bytes
          rust-lld: error: section '.text' will not fit in region 'FLASH': overflowed by 346 bytes
          rust-lld: error: section '.text' will not fit in region 'FLASH': overflowed by 350 bytes
          rust-lld: error: section '.text' will not fit in region 'FLASH': overflowed by 384 bytes
          rust-lld: error: too many errors emitted, stopping now (use -error-limit=0 to see all errors)

error: aborting due to previous error

error: could not compile `k2k_advantage`.

To learn more, run the command again with --verbose.

Then after running rustup update nightly I get a different error:

error[E0432]: unresolved import `alloc::alloc::Alloc`
  --> /home/josh/.cargo/registry/src/github.com-1ecc6299db9ec823/linked_list_allocator-0.6.4/src/lib.rs:14:20
   |
14 | use alloc::alloc::{Alloc, AllocErr, Layout};
   |                    ^^^^^
   |                    |
   |                    no `Alloc` in `alloc`
   |                    help: a similar name exists in the module: `alloc`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0432`.
error: could not compile `linked_list_allocator`.
warning: build failed, waiting for other jobs to finish...
error: build failed

Any thoughts on this? Does this repo build currently on your machine?

TyberiusPrime commented 4 years ago

Thank you for your interested in my little project.

Ok, so the link errors are due to debug mode - release mode produces much smaller binaries and the debug build doesn't actually fit the stm32f013. Chechk flash.sh which I believe also strips some symbols for this purpose.

As for the second issue, apperantly the upstream library already has a fix, so try updating that first. See https://github.com/phil-opp/linked-list-allocator/issues/19

JoshMcguigan commented 4 years ago

Thanks for the feedback. I've created PR #4 with a few small changes I made to get this building on my machine.