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

How to build this project? #2

Open
master-q opened this issue May 5, 2015 · 12 comments
Open

How to build this project? #2

master-q opened this issue May 5, 2015 · 12 comments

Comments

@master-q
Copy link
Contributor

master-q commented May 5, 2015

I'm tring to build your project.
However I stop at following error.

$ rustc --version
rustc 1.1.0-nightly (435622028 2015-05-04) (built 2015-05-05)
$ cd mbed-rust-frdm-k64f-blinky
$ make
rustc -L . --target thumbv7m-none-eabi -C target-cpu=cortex-m4  -C relocation-model=static -C opt-level=0 -g -Z no-landing-pads  -A dead_code -A unused_variables  --emit obj -o src/mbed-rust-frdm-k64-blinky.o src/mbed-rust-frdm-k64-blinky.rs
src/mbed-rust-frdm-k64-blinky.rs:15:1: 15:11 error: no_std is experimental
src/mbed-rust-frdm-k64-blinky.rs:15 #![no_std]
                                    ^~~~~~~~~~
src/mbed-rust-frdm-k64-blinky.rs:15:1: 15:11 help: add #![feature(no_std)] to the crate attributes to enable
error: aborting due to previous error
Makefile:43: recipe for target 'src/mbed-rust-frdm-k64-blinky.o' failed
make: *** [src/mbed-rust-frdm-k64-blinky.o] Error 101

Do you have any infomation for it?

@0xc0170
Copy link
Owner

0xc0170 commented May 5, 2015

Place above #![feature(no_std)], this should fix that error. The last time I built was using older rustc - 2 months ago, waiting for 1.0. We can start cleaning this, so lets keep this issue open until the project is in linking complete phase

@master-q
Copy link
Contributor Author

master-q commented May 5, 2015

Thank's for your advice. However still error...

$ git diff | cat
diff --git a/src/mbed-rust-frdm-k64-blinky.rs b/src/mbed-rust-frdm-k64-blinky.rs
index c643f9a..a28120d 100644
--- a/src/mbed-rust-frdm-k64-blinky.rs
+++ b/src/mbed-rust-frdm-k64-blinky.rs
@@ -11,8 +11,7 @@
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 // See the License for the specific language governing permissions and
 // limitations under the License.
-
-#![no_std]
+#![feature(no_std)]
 #![crate_type = "rlib"]
 #![feature(lang_items, asm)]

$ make
rustc -L . --target thumbv7m-none-eabi -C target-cpu=cortex-m4  -C relocation-model=static -C opt-level=0 -g -Z no-landing-pads  -A dead_code -A unused_variables  --emit obj -o src/mbed-rust-frdm-k64-blinky.o src/mbed-rust-frdm-k64-blinky.rs
src/mbed-rust-frdm-k64-blinky.rs:1:1: 1:1 error: can't find crate for `std`
src/mbed-rust-frdm-k64-blinky.rs:1 // Copyright 2015 Martin Kojtal (0xc0170)
                                   ^
error: aborting due to previous error
Makefile:43: recipe for target 'src/mbed-rust-frdm-k64-blinky.o' failed
make: *** [src/mbed-rust-frdm-k64-blinky.o] Error 101

@0xc0170
Copy link
Owner

0xc0170 commented May 5, 2015

Check this https://github.com/rust-lang/rust/pull/21988/files, feature should be above

@master-q
Copy link
Contributor Author

master-q commented May 5, 2015

I got some progress! Where is core?

$ git diff | cat
diff --git a/src/mbed-rust-frdm-k64-blinky.rs b/src/mbed-rust-frdm-k64-blinky.rs
index c643f9a..d8c0117 100644
--- a/src/mbed-rust-frdm-k64-blinky.rs
+++ b/src/mbed-rust-frdm-k64-blinky.rs
@@ -11,9 +11,9 @@
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 // See the License for the specific language governing permissions and
 // limitations under the License.
-
-#![no_std]
 #![crate_type = "rlib"]
+#![feature(no_std)]
+#![no_std]
 #![feature(lang_items, asm)]

 #![allow(dead_code)]
$ make
rustc -L . --target thumbv7m-none-eabi -C target-cpu=cortex-m4  -C relocation-model=static -C opt-level=0 -g -Z no-landing-pads  -A dead_code -A unused_variables  --emit obj -o src/mbed-rust-frdm-k64-blinky.o src/mbed-rust-frdm-k64-blinky.rs
src/mbed-rust-frdm-k64-blinky.rs:22:1: 22:19 error: can't find crate for `core`
src/mbed-rust-frdm-k64-blinky.rs:22 extern crate core;
                                    ^~~~~~~~~~~~~~~~~~
error: aborting due to previous error
Makefile:43: recipe for target 'src/mbed-rust-frdm-k64-blinky.o' failed
make: *** [src/mbed-rust-frdm-k64-blinky.o] Error 101

@0xc0170
Copy link
Owner

0xc0170 commented May 5, 2015

Ah , its not written in the readme, check my other rust example, where is written how to build core (its target in the makefile, make libcore) - You need a rust clone to build libcore. https://github.com/0xc0170/frdm-kl25z-rust

@master-q
Copy link
Contributor Author

master-q commented May 5, 2015

The libcore.rlib was built. However also error occurs.
The core library is unstable?

$ make libcore
$ file libcore.rlib
libcore.rlib: current ar archive
$ make
rustc -L . --target thumbv7m-none-eabi -C target-cpu=cortex-m4  -C relocation-model=static -C opt-level=0 -g -Z no-landing-pads  -A dead_code -A unused_variables  --emit obj -o src/mbed-rust-frdm-k64-blinky.o src/mbed-rust-frdm-k64-blinky.rs
src/mbed-rust-frdm-k64-blinky.rs:22:1: 22:19 error: use of unstable library feature 'core'
src/mbed-rust-frdm-k64-blinky.rs:22 extern crate core;
                                    ^~~~~~~~~~~~~~~~~~
src/mbed-rust-frdm-k64-blinky.rs:22:1: 22:19 help: add #![feature(core)] to the crate attributes to enable
src/DigitalOut.rs:17:5: 17:27 error: use of unstable library feature 'core'
src/DigitalOut.rs:17 use core::intrinsics::init;
                         ^~~~~~~~~~~~~~~~~~~~~~
src/DigitalOut.rs:17:5: 17:27 help: add #![feature(core)] to the crate attributes to enable
src/DigitalOut.rs:19:5: 19:26 error: use of unstable library feature 'core'
src/DigitalOut.rs:19 use core::slice::SliceExt;
                         ^~~~~~~~~~~~~~~~~~~~~
src/DigitalOut.rs:19:5: 19:26 help: add #![feature(core)] to the crate attributes to enable
src/DigitalOut.rs:40:45: 40:49 error: use of unstable library feature 'core'
src/DigitalOut.rs:40             let mut gpio_out : DigitalOut = init();
                                                                 ^~~~
src/DigitalOut.rs:40:45: 40:49 help: add #![feature(core)] to the crate attributes to enable
src/DigitalOut.rs:42:41: 42:53 error: use of unstable library feature 'core'
src/DigitalOut.rs:42             gpio_init_out(gpio_out.gpio.as_mut_ptr(), pin);
                                                             ^~~~~~~~~~~~
src/DigitalOut.rs:42:41: 42:53 help: add #![feature(core)] to the crate attributes to enable
src/DigitalOut.rs:48:19: 48:31 error: use of unstable library feature 'core'
src/DigitalOut.rs:48         self.gpio.as_mut_ptr()
                                       ^~~~~~~~~~~~
src/DigitalOut.rs:48:19: 48:31 help: add #![feature(core)] to the crate attributes to enable
src/DigitalOut.rs:53:34: 53:46 error: use of unstable library feature 'core'
src/DigitalOut.rs:53             gpio_write(self.gpio.as_mut_ptr(), value);
                                                      ^~~~~~~~~~~~
src/DigitalOut.rs:53:34: 53:46 help: add #![feature(core)] to the crate attributes to enable
src/DigitalOut.rs:59:33: 59:45 error: use of unstable library feature 'core'
src/DigitalOut.rs:59             gpio_read(self.gpio.as_mut_ptr())
                                                     ^~~~~~~~~~~~
src/DigitalOut.rs:59:33: 59:45 help: add #![feature(core)] to the crate attributes to enable
src/DigitalOut.rs:15:5: 15:23 warning: unused import, #[warn(unused_imports)] on by default
src/DigitalOut.rs:15 use core::marker::Copy;
                         ^~~~~~~~~~~~~~~~~~
src/DigitalOut.rs:16:5: 16:32 warning: unused import, #[warn(unused_imports)] on by default
src/DigitalOut.rs:16 use core::intrinsics::transmute;
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
src/DigitalOut.rs:18:5: 18:14 warning: unused import, #[warn(unused_imports)] on by default
src/DigitalOut.rs:18 use core::mem;
                         ^~~~~~~~~
error: aborting due to 8 previous errors

@master-q
Copy link
Contributor Author

master-q commented May 6, 2015

More progress! I think the compile error is an issue of my environment. I'll try to fix it.

$ git diff | cat
diff --git a/src/mbed-rust-frdm-k64-blinky.rs b/src/mbed-rust-frdm-k64-blinky.rs
index c643f9a..eae3e26 100644
--- a/src/mbed-rust-frdm-k64-blinky.rs
+++ b/src/mbed-rust-frdm-k64-blinky.rs
@@ -11,10 +11,10 @@
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 // See the License for the specific language governing permissions and
 // limitations under the License.
-
-#![no_std]
 #![crate_type = "rlib"]
-#![feature(lang_items, asm)]
+#![feature(no_std)]
+#![no_std]
+#![feature(lang_items, asm, core)]

 #![allow(dead_code)]
 #![allow(non_snake_case)]
$ make
rustc -L . --target thumbv7m-none-eabi -C target-cpu=cortex-m4  -C relocation-model=static -C opt-level=0 -g -Z no-landing-pads  -A dead_code -A unused_variables  --emit obj -o src/mbed-rust-frdm-k64-blinky.o src/mbed-rust-frdm-k64-blinky.rs
src/DigitalOut.rs:15:5: 15:23 warning: unused import, #[warn(unused_imports)] on by default
src/DigitalOut.rs:15 use core::marker::Copy;
                         ^~~~~~~~~~~~~~~~~~
src/DigitalOut.rs:16:5: 16:32 warning: unused import, #[warn(unused_imports)] on by default
src/DigitalOut.rs:16 use core::intrinsics::transmute;
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
src/DigitalOut.rs:18:5: 18:14 warning: unused import, #[warn(unused_imports)] on by default
src/DigitalOut.rs:18 use core::mem;
                         ^~~~~~~~~
arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -T K64FN1M0xxx12.ld -Wl,-Map=frdm-k64f-mbed-blinky.map,--cref -Wl,--wrap,main -Wl,--gc-sections --specs=nano.specs  -L . src/mbed-rust-frdm-k64-blinky.o board.o cmsis_nvic.o mbed_overrides.o retarget.o startup_MK64F12.o system_MK64F12.o -Wl,--start-group -lmbed -lstdc++ -lsupc++ -lm -lc -lgcc -Wl,--end-group /usr/lib/gcc/arm-none-eabi/4.8.4/libgcc.a -o frdm-k64f-mbed-blinky.elf
arm-none-eabi-gcc: error: board.o: No such file or directory
arm-none-eabi-gcc: error: cmsis_nvic.o: No such file or directory
arm-none-eabi-gcc: error: mbed_overrides.o: No such file or directory
arm-none-eabi-gcc: error: retarget.o: No such file or directory
arm-none-eabi-gcc: error: startup_MK64F12.o: No such file or directory
arm-none-eabi-gcc: error: system_MK64F12.o: No such file or directory
arm-none-eabi-gcc: error: /usr/lib/gcc/arm-none-eabi/4.8.4/libgcc.a: No such file or directory
Makefile:46: recipe for target 'frdm-k64f-mbed-blinky.elf' failed
make: *** [frdm-k64f-mbed-blinky.elf] Error 1

@master-q
Copy link
Contributor Author

master-q commented May 6, 2015

I built mbed libraries. However linker can't find gpio_write symbol...

$ ls ../mbed/build/mbed/TARGET_K64F/TOOLCHAIN_GCC_ARM/
K64FN1M0xxx12.ld  board.o  cmsis_nvic.o  libmbed.a  mbed_overrides.o  retarget.o  startup_MK64F12.o  system_MK64F12.o
$ cp ../mbed/build/mbed/TARGET_K64F/TOOLCHAIN_GCC_ARM/* .
$ make
rustc -L . --target thumbv7m-none-eabi -C target-cpu=cortex-m4  -C relocation-model=static -C opt-level=0 -g -Z no-landing-pads  -A dead_code -A unused_variables  --emit obj -o src/mbed-rust-frdm-k64-blinky.o src/mbed-rust-frdm-k64-blinky.rs
src/DigitalOut.rs:15:5: 15:23 warning: unused import, #[warn(unused_imports)] on by default
src/DigitalOut.rs:15 use core::marker::Copy;
                         ^~~~~~~~~~~~~~~~~~
src/DigitalOut.rs:16:5: 16:32 warning: unused import, #[warn(unused_imports)] on by default
src/DigitalOut.rs:16 use core::intrinsics::transmute;
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
src/DigitalOut.rs:18:5: 18:14 warning: unused import, #[warn(unused_imports)] on by default
src/DigitalOut.rs:18 use core::mem;
                         ^~~~~~~~~
arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -T K64FN1M0xxx12.ld -Wl,-Map=frdm-k64f-mbed-blinky.map,--cref -Wl,--wrap,main -Wl,--gc-sections --specs=nano.specs  -L . src/mbed-rust-frdm-k64-blinky.o board.o cmsis_nvic.o mbed_overrides.o retarget.o startup_MK64F12.o system_MK64F12.o -Wl,--start-group -lmbed -lstdc++ -lsupc++ -lm -lc -lgcc -Wl,--end-group /usr/lib/gcc/arm-none-eabi/4.8/libgcc.a -o frdm-k64f-mbed-blinky.elf
src/mbed-rust-frdm-k64-blinky.o: In function `mbed_rust_frdm_k64_blinky::DigitalOut::DigitalOut::write':
/home/kiwamu/src/mbed-rust-frdm-k64f-blinky.masterq/src/DigitalOut.rs:53: undefined reference to `gpio_write'
collect2: error: ld returned 1 exit status
Makefile:46: recipe for target 'frdm-k64f-mbed-blinky.elf' failed
make: *** [frdm-k64f-mbed-blinky.elf] Error 1

@0xc0170
Copy link
Owner

0xc0170 commented May 6, 2015

libmbed.a - library is part of this project. I commited the prebuilt mbed library because I had to do some modifications, I described it here http://0xc0170.github.io/rust/2015/02/18/mbed-with-rust-update-1/ (the very end). I am planning to create an issue on mbed and possibly to send a proposal how we can fix it (don't inline HAL functions and some extensions I found valuable when using rust for example).

@master-q
Copy link
Contributor Author

master-q commented May 6, 2015

How about commit *.o files?

$ ls *.o
board.o  cmsis_nvic.o  mbed_overrides.o  retarget.o  startup_MK64F12.o  system_MK64F12.o

I think your gitignore file shut out these.

@master-q
Copy link
Contributor Author

master-q commented May 6, 2015

I got it!

$ cp ../mbed/build/mbed/TARGET_K64F/TOOLCHAIN_GCC_ARM/*.o .
$ make
rustc -L . --target thumbv7m-none-eabi -C target-cpu=cortex-m4  -C relocation-model=static -C opt-level=0 -g -Z no-landing-pads  -A dead_code -A unused_variables  --emit obj -o src/mbed-rust-frdm-k64-blinky.o src/mbed-rust-frdm-k64-blinky.rs
src/DigitalOut.rs:15:5: 15:23 warning: unused import, #[warn(unused_imports)] on by default
src/DigitalOut.rs:15 use core::marker::Copy;
                         ^~~~~~~~~~~~~~~~~~
src/DigitalOut.rs:16:5: 16:32 warning: unused import, #[warn(unused_imports)] on by default
src/DigitalOut.rs:16 use core::intrinsics::transmute;
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
src/DigitalOut.rs:18:5: 18:14 warning: unused import, #[warn(unused_imports)] on by default
src/DigitalOut.rs:18 use core::mem;
                         ^~~~~~~~~
arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -T K64FN1M0xxx12.ld -Wl,-Map=frdm-k64f-mbed-blinky.map,--cref -Wl,--wrap,main -Wl,--gc-sections --specs=nano.specs  -L . src/mbed-rust-frdm-k64-blinky.o board.o cmsis_nvic.o mbed_overrides.o retarget.o startup_MK64F12.o system_MK64F12.o -Wl,--start-group -lmbed -lstdc++ -lsupc++ -lm -lc -lgcc -Wl,--end-group /usr/lib/gcc/arm-none-eabi/4.8/libgcc.a -o frdm-k64f-mbed-blinky.elf
arm-none-eabi-objcopy -O binary frdm-k64f-mbed-blinky.elf frdm-k64f-mbed-blinky.bin
arm-none-eabi-size --totals frdm-k64f-mbed-blinky.elf
   text    data     bss     dec     hex filename
  20716     112     460   21288    5328 frdm-k64f-mbed-blinky.elf
  20716     112     460   21288    5328 (TOTALS)

However I doesn't have frdm-k64f board...

@master-q
Copy link
Contributor Author

master-q commented May 6, 2015

libmbed.a - library is part of this project. I commited the prebuilt mbed library because I had to do some modifications, I described it here http://0xc0170.github.io/rust/2015/02/18/mbed-with-rust-update-1/ (the very end). I am planning to create an issue on mbed and possibly to send a proposal how we can fix it (don't inline HAL functions and some extensions I found valuable when using rust for example).

Could you open the patch for mbed? I would like to test your project on LPC1768.

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

2 participants