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

Support Teensy 3.0, 3.5, 3.6 #9

Open
jamesmunns opened this issue Sep 26, 2016 · 62 comments
Open

Support Teensy 3.0, 3.5, 3.6 #9

jamesmunns opened this issue Sep 26, 2016 · 62 comments

Comments

@jamesmunns
Copy link
Owner

Some combination of rust-lang/rfcs#1645 (comment) and perhaps a rebuild of teensy3-sys for the new targets, selected during build.rs based on feature flags.

@jamesmunns
Copy link
Owner Author

If anyone has access to a 3.0, 3.5, or 3.6, please get in touch with me. I would be happy to work on this once I have a way to test if it works.

@ratkins
Copy link

ratkins commented Oct 10, 2016

✋🏻

I have a couple of Teensy 3.0s on hand.

@jamesmunns
Copy link
Owner Author

jamesmunns commented Oct 10, 2016

@ratkins Awesome! I think these are the steps that are necessary to support the teensy 3.0:

  • Step 0: Fix this issue, where newer versions of cargo break the current build process
  • Step 1: Figure out if the linker script is needed at all to build the teensy3-rs crate (incl. teensy3-sys dependency)
  • Step 2a: If not necessary, just provide both linker scripts in the demo repo, and document how to switch between the two
  • Step 2b: If it is necessary: Figure out some way to select which linker script to use at compile time (probably cargo feature flags)
  • Step 3: Document how to switch between 3.0 or 3.1/3.2 mode (really just switching the linker file)

The process for 3.5/3.6 will be similar, however I'm pretty sure we will need to regen the bindings.rs specifically for the new target. Needs more research though.

Feel free to tackle any of the above, I wont have time to work on this until at least this weekend. I'm happy to provide support if you have any questions!

@TheZoq2
Copy link

TheZoq2 commented Oct 13, 2016

I have a 3.5 so I would love to help testing it

@pointlessone
Copy link

I've got 3.6. Would like to help testing it.

@TheZoq2
Copy link

TheZoq2 commented Oct 28, 2016

Have you started working on this @jamesmunns?

If not and the process is the same for the 3.5 as the 3.0, I wouldn't mind giving this a shot

@jamesmunns
Copy link
Owner Author

@TheZoq2 Please feel free to work on it, I've been a bit sick and tied up in catching up on work, so I haven't been able to make any progress.

I'm happy to support if you have any questions.

@TheZoq2
Copy link

TheZoq2 commented Oct 29, 2016

Ok, I did some work on this.

I got it to compile for the 3.5 and managed to upload and run the example project. However, it stops working after the first alive blink. If I uncomment the hello functioncall it seems to work.

I assume this might have something to do with

The process for 3.5/3.6 will be similar, however I'm pretty sure we will need to regen the bindings.rs specifically for the new target.

The only thing I had to do to make it work was change the "link-arg=-Tmk20... to mk66fx1m0.ld and change the same teensy-loader part of the makefile.

Here is my demo repo with the changes https://github.com/TheZoq2/teensy3-rs-demo

@jamesmunns Do you think regenerating the bindings will fix the serial issue, if so, how would I do that?

Edit: Slight update, I looked into this again and realised that mk66... is the teensy 3.6 CPU while mk64fx512 is 3.5. I changed it but it still crashes when trying to use serial.

Edit2: I looked in the board.txt file for the teensy install and found this line:

teensy35.build.flags.cpu=-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant

I tried adding those flags to the .cargo/config file like this:

    "-C", "link-arg=-mfloat-abi=hard",
    "-C", "link-arg=-mfpu=fpv4-sp-d16",
    "-C", "link-arg=-fsingle-precision-constant",

But if I add the mfloat-abi parameter, alive() function is never run and if I add the mfpu=... part, it gives me the following error

error: linking with `arm-none-eabi-gcc` failed: exit code: 1
  |
  = note: "arm-none-eabi-gcc" "-L" "/home/frans/.xargo/lib/rustlib/thumbv7em-none-eabi/lib" "/home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo.0.o" "-o" "/home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo" "-Wl,--gc-sections" "-nodefaultlibs" "-L" "/home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps" "-L" "/home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/build/teensy3-sys-61d202c8207ff0d7/out" "-L" "/home/frans/.cargo/registry/src/github.com-1ecc6299db9ec823/teensy3-sys-0.1.0/teensy3-core" "-L" "/home/frans/.xargo/lib/rustlib/thumbv7em-none-eabi/lib" "-Wl,-Bstatic" "-Wl,-Bdynamic" "/home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3-043aba3add261a0b.rlib" "/home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib" "/home/frans/.xargo/lib/rustlib/thumbv7em-none-eabi/lib/libcore.rlib" "-mcpu=cortex-m4" "-mthumb" "-mfloat-abi=hard" "-mfpu=fpv4-sp-d16" "-fsingle-precision-constant" "-Tmk64fx512.ld" "-Os" "-Wl,--gc-sections,--defsym=__rtc_localtime=0" "--specs=nano.specs" "-lm" "-Wl,--start-group" "-lnosys" "-lc" "-lgcc" "-Wl,--end-group"
  = note: /usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo.0.o does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo.0.o
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(pins_teensy.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(pins_teensy.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(mk20dx128.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(mk20dx128.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(analog.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(analog.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(yield.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(yield.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(HardwareSerial1.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(HardwareSerial1.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(HardwareSerial2.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(HardwareSerial2.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(serial3.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(serial3.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(usb_dev.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(usb_dev.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(usb_mem.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(usb_mem.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(usb_desc.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(usb_desc.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(serial1.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(serial1.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(serial2.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(serial2.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(usb_serial.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(usb_serial.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(HardwareSerial3.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(HardwareSerial3.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(Stream.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(Stream.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(Print.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(Print.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(avr_emulation.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(avr_emulation.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(usb_inst.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(usb_inst.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(WString.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(WString.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(IntervalTimer.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(IntervalTimer.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(nonstd.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(nonstd.o)
collect2: error: ld returned 1 exit status


error: aborting due to previous error

error: Could not compile `teensy3-rs-demo`.

@Emilgardis
Copy link

This is most likely a problem with that the new teensies have FPUs. See stack question, I believe it is related (don't have a 3.x yet). It is probably because the linker and compiler are using different flags. Also, you haven't pushed anything extra to your repo, could you push your changes?

@TheZoq2
Copy link

TheZoq2 commented Oct 30, 2016

Yep, im suspecting the FPU is the issue aswell since the problem only happens when I add the floating point related flags.

I pushed the latest changes to my repo

@jamesmunns
Copy link
Owner Author

@TheZoq2 Yes, I agree, if you would like to use the hard float abi, you will likely need to rebuild the C(++) code with matching flags. This exists in https://github.com/jamesmunns/teensy3-rs/blob/master/teensy3-sys/teensy3-core/Makefile#L60

You will need to get the .cargo/config and -sys's compiler flags to match

@jamesmunns
Copy link
Owner Author

@TheZoq2 The more I look at this, I do think you will need to regen the bindings, since the 3.1/3.2 and 3.5 and 3.6 use different CPUs, and the rust bindings are currently specific to the 3.1/3.2.

To regenerate them, you will need to use Servo's fork of bindgen, and run the tool against the contents here: https://github.com/jamesmunns/teensy3-rs/tree/master/teensy3-sys/teensy3-core, which comes from here: https://github.com/PaulStoffregen/cores/tree/master/teensy3 (not sure which version).

The command that was used to generate the current bindings is:

PATH="/home/simon/projects/servo/ports/geckolib/binding_tools/rust-bindgen/target/debug:$$PATH" bindgen --no-type-renaming --match teensy3 bindings.h -o src/bindings.rs -- -I/usr/lib/clang/3.8.1/include -x c++ -std=gnu++11 -target thumbv7em-none-eabi -DF_CPU=48000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -DUSING_MAKEFILE -D__MK20DX256__ -DARDUINO=10600 -DTEENSYDUINO=121

Some of the parameters above will likely need to be tweaked to match the 3.5/3.6 hardware parameters (such as CPU frequency, etc)

If you can get it building manually, I can help you with integrating it cleanly so that we can support 3.5 etc side-by-side.

@jamesmunns
Copy link
Owner Author

Also, im guessing the processor is crashing at "hello" because it is probably using the serial peripheral incorrectly (probably still configured like a 3.1/3.2, which probably has different settings/memory locations from the 3.5)

@TheZoq2
Copy link

TheZoq2 commented Oct 30, 2016

Im having a bit of trouble running bindgen. I compiled the latest version from git but if I run the same command you did, it says --match is an unknown option.

Also, What directory should I be in when running bindgen? I assume somewhere in teensy3-rs

@jamesmunns

@TheZoq2
Copy link

TheZoq2 commented Oct 30, 2016

I did some more looking into this and got it working somewhat by checking out an older version of bindgen. Looks like --match has been removed rust-lang/rust-bindgen#50

I tried running it in both the teensy3 and teensy3-sys folder but now I get thread 'main' panicked at 'Open src/bindings.rs failed', src/bin/bindgen.rs:247

@jamesmunns
Copy link
Owner Author

@TheZoq2 Hey sorry, I don't think that command will work exactly, it was run a while ago, on someone elses computer. It was meant to be a starting reference for you. Bindgen is probably vomiting because you don't have a src directory in your current path. You will probably need to run a similar command, in this directory: https://github.com/jamesmunns/teensy3-rs/tree/master/teensy3-sys

What you are doing is generating a file (bindings.rs) to replace this one: https://github.com/jamesmunns/teensy3-rs/blob/master/teensy3-sys/bindings.rs

@TheZoq2
Copy link

TheZoq2 commented Oct 30, 2016

Ah makes sense, I got it to run with the latest version but it's not working propperly.

It now gives me the following output:

./teensy3/WProgram.h:11:10: error: 'avr/pgmspace.h' file not found with <angled> include; use "quotes" instead
./teensy3/WProgram.h:12:10: error: 'avr/interrupt.h' file not found with <angled> include; use "quotes" instead
./teensy3/new.h:14:6: warning: function previously declared with an explicit exception specification redeclared with an implicit exception specification [-Wimplicit-exception-spec-mismatch]
./teensy3/new.h:15:6: warning: function previously declared with an explicit exception specification redeclared with an implicit exception specification [-Wimplicit-exception-spec-mismatch]
./teensy3/keylayouts.h:35:10: error: 'avr/pgmspace.h' file not found with <angled> include; use "quotes" instead
./teensy3/WProgram.h:53:9: error: functions that differ only in their return type cannot be overloaded
/usr/include/stdlib.h:282:17: note: previous declaration is here
bindings.h:2:10: fatal error: 'teensy3/SPI.h' file not found
./teensy3/WProgram.h:11:10: error: 'avr/pgmspace.h' file not found with <angled> include; use "quotes" instead, err: true
./teensy3/WProgram.h:12:10: error: 'avr/interrupt.h' file not found with <angled> include; use "quotes" instead, err: true
./teensy3/new.h:14:6: warning: function previously declared with an explicit exception specification redeclared with an implicit exception specification [-Wimplicit-exception-spec-mismatch], err: false
./teensy3/new.h:15:6: warning: function previously declared with an explicit exception specification redeclared with an implicit exception specification [-Wimplicit-exception-spec-mismatch], err: false
./teensy3/keylayouts.h:35:10: error: 'avr/pgmspace.h' file not found with <angled> include; use "quotes" instead, err: true
./teensy3/WProgram.h:53:9: error: functions that differ only in their return type cannot be overloaded, err: true
bindings.h:2:10: fatal error: 'teensy3/SPI.h' file not found, err: true

Followed by thousands of lines of this

bindings.h:2:10: fatal error: 'teensy3/SPI.h' file not found, err: true
ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
ERROR:bindgen::ir::item: Unhandled cursor kind: InclusionDirective (503)
ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
ERROR:bindgen::ir::item: Unhandled cursor kind: MacroDefinition (501)
ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
ERROR:bindgen::ir::item: Unhandled cursor kind: InclusionDirective (503)
ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))

I was able to fix the "file not found with things by editing WProgram.h and changing the angle brackets to " and I was able to fix the missing SPI.h by changing the #include statement in bindings.h to #include teensy3/SPI.h and I temporarily got rid of the missing wire file by commenting it out.

However, I can't get rid of the warnings or the errors about redeclaring functions. I also have no idea how to avoid the massive amount of errors from bindgen.

Im running this command

bindgen bindings.h -o ../teensy3/src/bindings.rs -- -I/usr/lib/clang/3.9.0/include -x c++ -std=gnu++11 -target thumbv7em-none-eabi -DF_CPU=48000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -DUSING_MAKEFILE -D__MK64FX512__ -DARDUINO=10600 -DTEENSYDUINO=121

In teensy3-sys where I have copied the current version of the teensy3 folder from the core repo.

Do you have any suggestions for things I can try to get this working?

@jamesmunns
Copy link
Owner Author

Try this, I think you're close! You need to tell clang where to find the files.

# Before:
bindgen bindings.h -o ../teensy3/src/bindings.rs -- -I/usr/lib/clang/3.9.0/include -x c++ -std=gnu++11 -target thumbv7em-none-eabi -DF_CPU=48000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -DUSING_MAKEFILE -D__MK64FX512__ -DARDUINO=10600 -DTEENSYDUINO=121

# After - Running from teensy3-rs/teensy3-sys
bindgen bindings.h -o ./bindings.rs -- -I./teensy3-core -I/usr/lib/clang/3.9.0/include -x c++ -std=gnu++11 -target thumbv7em-none-eabi -DF_CPU=48000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -DUSING_MAKEFILE -D__MK64FX512__ -DARDUINO=10600 -DTEENSYDUINO=121

@TheZoq2
Copy link

TheZoq2 commented Oct 31, 2016

That got me a bit closer but I have not got it working yet. Clang gives me an error about redefining the random function as long random() instead of int32_t random() as it is defined in stdlib. I can fix that by changing the function definition in WProgram.h.

The only remaining problem is that bindgen gives me thousands of lines of what I posted before.

Edit: Looks like I got a bindings.rs file as output even when I got the errors. I'll check if it works when I get home and have access to the hardware

@emilio
Copy link

emilio commented Oct 31, 2016

@TheZoq2 FWIW (I'm the bindgen maintainer), those lines are not worrisome, though are handy for debugging.

Specially: "invalid type" with an empty type name is expected.
And cursors not handled like Inclusion directives or similar are also expected, and not errors per se. I'll change bindgen to output this only while debugging (where it's really handy).

Edit: Oh, and yeah, bindgen still tries its best to generate correct output even when it spits errors :)

@TheZoq2
Copy link

TheZoq2 commented Oct 31, 2016

@emilio Alright, makes sense. At the end of the output, it prints some other errors aswell, are these harmless too?

ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
ERROR:bindgen::ir::item: Unhandled cursor kind: FunctionDecl (8)
ERROR:bindgen::ir::item: Unhandled cursor kind: FunctionDecl (8)
ERROR:bindgen::ir::item: Unhandled cursor kind: FunctionDecl (8)
ERROR:bindgen::ir::item: Unhandled cursor kind: FunctionDecl (8)
ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
ERROR:bindgen::ir::ty: invalid type Type(, kind: Invalid, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
ERROR:bindgen::ir::context: Valid declaration with no USR: Cursor(__va_list kind: StructDecl, loc: builtin definitions, usr: None), Some(Cursor(va_list kind: TypedefDecl, loc: /usr/lib/clang/3.9.0/include/stdarg.h:30:27, usr: Some("c:@T@va_list")))
ERROR:bindgen::ir::context: Valid declaration with no USR: Cursor(__builtin_va_list kind: TypedefDecl, loc: builtin definitions, usr: None), Some(Cursor(va_list kind: TypedefDecl, loc: /usr/lib/clang/3.9.0/include/stdarg.h:30:27, usr: Some("c:@T@va_list")))
ERROR:bindgen::ir::context: Valid declaration with no USR: Cursor(__va_list kind: StructDecl, loc: builtin definitions, usr: None), Some(Cursor(__gnuc_va_list kind: TypedefDecl, loc: /usr/lib/clang/3.9.0/include/stdarg.h:50:27, usr: Some("c:@T@__gnuc_va_list")))
ERROR:bindgen::ir::context: Valid declaration with no USR: Cursor(__builtin_va_list kind: TypedefDecl, loc: builtin definitions, usr: None), Some(Cursor(__gnuc_va_list kind: TypedefDecl, loc: /usr/lib/clang/3.9.0/include/stdarg.h:50:27, usr: Some("c:@T@__gnuc_va_list")))

@jamesmunns I think i'm pretty close to getting it working now, Bindgen seems to generate a valid bindings.rs file and if I set my own repo as a dependency to my demo repo, it compiles fine and runs the blinking fine. However, it still crashes when I run the hello function.

This is my current bindgen command

bindgen bindings.h -o ./bindings.rs -- -I/usr/lib/clang/3.9.0/include -I./teensy3-core -x c++ -std=gnu++11 -target thumbv7em-none-eabi -DF_CPU=144000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -DUSING_MAKEFILE -D__MK64FX512__ -DARDUINO=10600 -DTEENSYDUINO=121

I noticed some cargo.toml files in the teensy-rs repo. Running cargo build in https://github.com/TheZoq2/teensy3-rs/tree/master/teensy3 works fine but running cargo build in https://github.com/TheZoq2/teensy3-rs/tree/master/teensy3-sys gives me the following error

   Compiling teensy3-sys v0.1.0 (file:///home/frans/Documents/rust/teensy3-rs/teensy3-sys)
error: expected one of `!`, `(`, `+`, `::`, `;`, or `<`, found `__truth_type`
    --> bindings.rs:6215:38
     |
6215 | pub type __traitor___type = typename __truth_type<__value>::__type;
     |                                      ^^^^^^^^^^^^

Im not sure why im not getting that error when building in the other places.

Also, if I add the -mfpu=fpv4-sp-d16 to both bindgen and the .cargo/config file in the demo repo, the bindgens work fine (though it doesn't seem to affect bindings.rs file) but adding it in the demo repo gives me a linker error.

error: linking with `arm-none-eabi-gcc` failed: exit code: 1
  |
  = note: "arm-none-eabi-gcc" "-L" "/home/frans/.xargo/lib/rustlib/thumbv7em-none-eabi/lib" "/home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo.0.o" "-o" "/home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo" "-Wl,--gc-sections" "-nodefaultlibs" "-L" "/home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps" "-L" "/home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/build/teensy3-sys-61d202c8207ff0d7/out" "-L" "/home/frans/.cargo/registry/src/github.com-1ecc6299db9ec823/teensy3-sys-0.1.0/teensy3-core" "-L" "/home/frans/.xargo/lib/rustlib/thumbv7em-none-eabi/lib" "-Wl,-Bstatic" "-Wl,-Bdynamic" "/home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3-90bde4e3ddc4f74b.rlib" "/home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib" "/home/frans/.xargo/lib/rustlib/thumbv7em-none-eabi/lib/libcore.rlib" "-mcpu=cortex-m4" "-mthumb" "-Tmk64fx512.ld" "-mfloat-abi=hard" "-mfpu=fpv4-sp-d16" "-Os" "-Wl,--gc-sections,--defsym=__rtc_localtime=0" "--specs=nano.specs" "-lm" "-Wl,--start-group" "-lnosys" "-lc" "-lgcc" "-Wl,--end-group"
  = note: /usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo.0.o does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo.0.o
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(pins_teensy.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(pins_teensy.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(mk20dx128.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(mk20dx128.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(analog.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(analog.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(yield.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(yield.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(HardwareSerial1.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(HardwareSerial1.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(HardwareSerial2.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(HardwareSerial2.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(serial3.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(serial3.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(usb_dev.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(usb_dev.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(usb_mem.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(usb_mem.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(usb_desc.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(usb_desc.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(serial1.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(serial1.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(serial2.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(serial2.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(usb_serial.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(usb_serial.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(HardwareSerial3.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(HardwareSerial3.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(Stream.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(Stream.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(Print.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(Print.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(avr_emulation.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(avr_emulation.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(usb_inst.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(usb_inst.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(WString.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(WString.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(IntervalTimer.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(IntervalTimer.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(nonstd.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(nonstd.o)
collect2: error: ld returned 1 exit status


error: aborting due to previous error

Somewhat unrelated, I tried to do some floating point calculations with the flag combination that works but it tells me that f32 is undefined, I assume the float stuff is part of rusts stdlib which is not available.

@TheZoq2
Copy link

TheZoq2 commented Nov 16, 2016

I finally got some time to work on this again but no luck so far.

I upgraded bindgen to the latest version and most of the repeated errrors are gone, however I get some errors that I havn't seen before. Could any of these cause issues? @emilio

I also got the compiler to link with the -mfpu=fpv4-sp-d16 flag set but the first alive() call is never run with it turned on.

The last flag I think might be causing issues is the -mfloat-abi=hard. Adding it to bindgen works fine and doesn't seem to affect the bindings, however when adding it to the link args, I get the same error as before:

error: linking with `arm-none-eabi-gcc` failed: exit code: 1
  |
  = note: "arm-none-eabi-gcc" "-L" "/home/frans/.xargo/lib/rustlib/thumbv7em-none-eabi/lib" "/home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo.0.o" "-o" "/home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo" "-Wl,--gc-sections" "-nodefaultlibs" "-L" "/home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps" "-L" "/home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/build/teensy3-sys-61d202c8207ff0d7/out" "-L" "/home/frans/.cargo/registry/src/github.com-1ecc6299db9ec823/teensy3-sys-0.1.0/teensy3-core" "-L" "/home/frans/.xargo/lib/rustlib/thumbv7em-none-eabi/lib" "-Wl,-Bstatic" "-Wl,-Bdynamic" "/home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3-90bde4e3ddc4f74b.rlib" "/home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib" "/home/frans/.xargo/lib/rustlib/thumbv7em-none-eabi/lib/libcore.rlib" "-mcpu=cortex-m4" "-mthumb" "-Tmk64fx512.ld" "-mfpu=fpv4-sp-d16" "-mfloat-abi=hard" "-Os" "-Wl,--gc-sections,--defsym=__rtc_localtime=0" "--specs=nano.specs" "-lm" "-Wl,--start-group" "-lnosys" "-lc" "-lgcc" "-Wl,--end-group"
  = note: /usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo.0.o does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo.0.o
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3-90bde4e3ddc4f74b.rlib(teensy3-90bde4e3ddc4f74b.0.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3-90bde4e3ddc4f74b.rlib(teensy3-90bde4e3ddc4f74b.0.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(pins_teensy.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(pins_teensy.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(mk20dx128.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(mk20dx128.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(analog.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(analog.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(usb_serial.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(usb_serial.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(yield.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(yield.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(HardwareSerial1.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(HardwareSerial1.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(HardwareSerial2.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(HardwareSerial2.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(SPI.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(SPI.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(serial3.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(serial3.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(usb_dev.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(usb_dev.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(usb_mem.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(usb_mem.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(usb_desc.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(usb_desc.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(serial1.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(serial1.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(serial2.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(serial2.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(HardwareSerial3.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(HardwareSerial3.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(Stream.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(Stream.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(Print.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(Print.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(avr_emulation.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(avr_emulation.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(usb_inst.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(usb_inst.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(WString.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(WString.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(IntervalTimer.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(IntervalTimer.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(nonstd.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/deps/libteensy3_sys-843efc0a34d78876.rlib(nonstd.o)
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: error: /home/frans/Documents/rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/teensy3_rs_demo uses VFP register arguments, /home/frans/.xargo/lib/rustlib/thumbv7em-none-eabi/lib/libcore.rlib(core.0.o) does not
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/frans/.xargo/lib/rustlib/thumbv7em-none-eabi/lib/libcore.rlib(core.0.o)
collect2: error: ld returned 1 exit status

Some quick googling tells me that this is because the "standard library" im linking against hasn't been compiled with float-abi set to hard and the error message suggests the same thing. Perhaps I need to change the target?

@jamesmunns Any ideas?

@jamesmunns
Copy link
Owner Author

Hey @TheZoq2, I haven't forgotten about you. I don't know what the problem is, and I haven't had time to troubleshoot from my side.

If I get a chance, I'll let you know. Sorry for not being more helpful :(

@SimonSapin
Copy link
Collaborator

#18 does build-time bindgen. It has some compiler flags hard-coded in build.rs:

        "-mthumb",
        "-mcpu=cortex-m4",
        "-D__MK20DX256__",
        "-DF_CPU=48000000",

With that, I think the next step is to have Cargo features in both the teensy3 and teensy3-sys crates, one for each type/version of supported Teensy hardware. The build script would check that one and only one is enabled, check that it is consistent with $TARGET, and set compiler flags accordingly.

@jamesmunns
Copy link
Owner Author

@TheZoq2 @ratkins @pointlessone are you all/any of you still interested? @SimonSapin has done some seriously awesome groundwork to make the binding process more dynamic, and we might be able to make progress again, but I don't have access to hardware (other than the Teensy 3.2) to test. I will hopefully be able to merge #18, which will allow for compile-time switches, then I can help get the build options adapted correctly for the 3.0, 3.5, and 3.6.

@pointlessone
Copy link

@jamesmunns Unfortunately I'm busy with other things at the moment but I'm willing to sponsor the boards to you. Ping me on email if you're interested.

@TheZoq2
Copy link

TheZoq2 commented Apr 17, 2017

I'm still interested in this and I'll gladly help test things.

@jamesmunns
Copy link
Owner Author

@pointlessone, no worries, I understand how schedules are. I'll ping you when I have something I think should work, and if you have a bit of time to test it, that would be great, and if not, or if additional debugging is required, I can reach out to you to get boards, or set something up. Thanks for the offer!

Hopefully if TheZoq2 is around, we can work through some of the pains with the 3.5 board before we have to test the 3.6.

@ratkins
Copy link

ratkins commented Apr 17, 2017

Definitely interested, may be limited on time but will see if I can get to it this week.

@TheZoq2
Copy link

TheZoq2 commented Apr 21, 2017

I forgot to mention that I did that and it doesn't seem to reveal any more info. Here is with backtrace=1

  Compiling teensy3-sys v0.2.0 (file:///home/frans/Documents/rust/teensy3-rs/teensy3-sys)
error: failed to run custom build command for `teensy3-sys v0.2.0 (file:///home/frans/Documents/rust/teensy3-rs/teensy3-sys)`
process didn't exit successfully: `/home/frans/Documents/rust/teensy3-rs-demo/target/release/build/teensy3-sys-9761e12241629c3c/build-script-build` (exit code: 101)
--- stderr
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { repr: Os { code: 2, message: "No such file or directory" } }', /checkout/src/libcore/result.rs:859
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: build_script_build::main

And full:

   Compiling teensy3-sys v0.2.0 (file:///home/frans/Documents/rust/teensy3-rs/teensy3-sys)
error: failed to run custom build command for `teensy3-sys v0.2.0 (file:///home/frans/Documents/rust/teensy3-rs/teensy3-sys)`
process didn't exit successfully: `/home/frans/Documents/rust/teensy3-rs-demo/target/release/build/teensy3-sys-9761e12241629c3c/build-script-build` (exit code: 101)
--- stderr
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { repr: Os { code: 2, message: "No such file or directory" } }', /checkout/src/libcore/result.rs:859
stack backtrace:
   0:     0x55d23b1264f3 - std::sys::imp::backtrace::tracing::imp::unwind_backtrace::h0c49f46a3545f908
                               at /checkout/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1:     0x55d23b122874 - std::sys_common::backtrace::_print::hcef39a9816714c4c
                               at /checkout/src/libstd/sys_common/backtrace.rs:71
   2:     0x55d23b12a097 - std::panicking::default_hook::{{closure}}::h7c3c94835e02f846
                               at /checkout/src/libstd/sys_common/backtrace.rs:60
                               at /checkout/src/libstd/panicking.rs:355
   3:     0x55d23b129c1b - std::panicking::default_hook::h0bf7bc3112fb107d
                               at /checkout/src/libstd/panicking.rs:371
   4:     0x55d23b12a50b - std::panicking::rust_panic_with_hook::ha27630c950090fec
                               at /checkout/src/libstd/panicking.rs:549
   5:     0x55d23b12a3e4 - std::panicking::begin_panic::heb97fa3158b71158
                               at /checkout/src/libstd/panicking.rs:511
   6:     0x55d23b12a319 - std::panicking::begin_panic_fmt::h8144403278d84748
                               at /checkout/src/libstd/panicking.rs:495
   7:     0x55d23b12a2a7 - rust_begin_unwind
                               at /checkout/src/libstd/panicking.rs:471
   8:     0x55d23b15567d - core::panicking::panic_fmt::h3b0cca53e68f9654
                               at /checkout/src/libcore/panicking.rs:69
   9:     0x55d23ae5138e - core::result::unwrap_failed::hd3b632b237fba799
  10:     0x55d23ae542ce - build_script_build::main::h7fd3e3469e7e1b78
  11:     0x55d23b12a205 - std::panicking::try::do_call::h689a21caeeef92aa
                               at /checkout/src/libcore/ops.rs:2606
                               at /checkout/src/libstd/panicking.rs:454
  12:     0x55d23b13138a - __rust_maybe_catch_panic
                               at /checkout/src/libpanic_unwind/lib.rs:98
  13:     0x55d23b12acaa - std::rt::lang_start::hf63d494cb7dd034c
                               at /checkout/src/libstd/panicking.rs:433
                               at /checkout/src/libstd/panic.rs:361
                               at /checkout/src/libstd/rt.rs:57
  14:     0x7f647b5a6510 - __libc_start_main
  15:     0x55d23ae48f99 - _start
  16:                0x0 - <unknown>

@Emilgardis
Copy link

Emilgardis commented Apr 21, 2017

This doesn't tell as much as one would hope, but I think L162 in the buildscript is the problem.
Try changing the path to crate_dir.join("/src/cores/teensy3/WProgram.h")

@jamesmunns
Copy link
Owner Author

@Emilgardis I'm not sure why this is breaking, he pulled v0.2.0 of that crate and built previously.

Actually I think I know whats up, @TheZoq2, could you please checkout the submodules for teensy3-rs? e.g.

cd teensy3-rs
git submodule init
git submodule update --recursive

Sorry, I forgot that step in my previous instructions.

@jamesmunns
Copy link
Owner Author

After you get the submodules, you can try building again

@jamesmunns
Copy link
Owner Author

Also I will change the .unwrap()s to .expect()s in the next update, so we get clearer error messages :)

@jamesmunns
Copy link
Owner Author

Sorry to spam, but @TheZoq2, please try my steps without making @Emilgardis' changes (or at least try them one at a time).

@TheZoq2
Copy link

TheZoq2 commented Apr 21, 2017

Yep, checking out the submodules fixed the issue.

The program compiled fine and got further than last time. The led seems to blink several times which means it goes through the loop more than once. However, if I try to open the serial monitor it stops running.

I think that may be an issue with my PC though as it seems like serial doesn't work with the example sketches either. I will try on my laptop and see what happens

@jamesmunns
Copy link
Owner Author

@TheZoq2 Hooray! Progress! If you are still stuck, I should be available tomorrow most of the day. Just send me an email (its on my github profile) or @ me here, and we can find a way to chat (IRC, etc).

If it runs the loop too many times without serial being connected, I think it will crash (the output buffer is probably full and failing an assert!() somewhere). I haven't taken the time to troubleshoot that. I would suggest connecting quickly after startup of the device :)

@TheZoq2
Copy link

TheZoq2 commented Apr 21, 2017

Looks like my theory was correct, it runs well on my laptop and prints the serial message. Looks like it's working fine.

Also, the issue only happened as soon as I opened the serial monitor, without it on it ran fine, atleast for 10-20 seconds :D

@jamesmunns
Copy link
Owner Author

@TheZoq2 Sounds good! Feel free to play around with it a bit, and let me know if you can manage to break it somehow.

@ratkins I'll try and get the Teensy 3.0s up and working tomorrow, hopefully I should have something for you to try in the next 24 hours or so :)

Right now none of the boards have Hard Float enabled, but I'll get soft-float-only working for this stage/ticket, and tackle the hard float problem separately. This shouldn't be a problem since neither the Rust code nor the C code have it enabled (it will just impact performance).

@TheZoq2
Copy link

TheZoq2 commented Apr 21, 2017

Yep, i'll have a go at trying to break it tomorrow, finally being able to use rust on a microcontroller will be nice :)

@SimonSapin
Copy link
Collaborator

My understanding is that only 3.5 and 3.6 have floating-point hardware. Cortex-M4F vs Cortex-M4 on https://www.pjrc.com/teensy/techspecs.html

@jamesmunns
Copy link
Owner Author

@SimonSapin I'll look at that in #21. I think you're right, not sure what had me confused at the time.

@jamesmunns
Copy link
Owner Author

Hey @TheZoq2, could you please get on #rust-embedded on irc.mozilla.org?

@jamesmunns
Copy link
Owner Author

I think I have 3.0, 3.5 w/hard float, and 3.6 w/hard float ready to test. @ratkins and @TheZoq2 could you please check?

# skip if you already got it
git clone https://github.com/jamesmunns/teensy3-rs-demo.git
cd teensy3-rs-demo

# if you already have the branch, don't forget to pull
git checkout teensy_3_5_test

# Edit Cargo.toml with your board. Set the [features] section correctly
#   teensy_3_0 => ratkins
#   teensy_3_5 => TheZoq2
nano Cargo.toml

# Build for ratkins:
xargo build --release --target thumbv7em-none-eabi

# Build for TheZoq2 - note this changed
xargo build --release --target thumbv7em-none-eabihf

# Pick the right one:
arm-none-eabi-objcopy -O ihex -R .eeprom target/thumbv7em-none-eabi/release/teensy3-rs-demo target/hex
arm-none-eabi-objcopy -O ihex -R .eeprom target/thumbv7em-none-eabihf/release/teensy3-rs-demo target/hex

# Flash, first for ratkins, then TheZoq2
teensy_loader_cli -w -s --mcu=mk20dx128 target/hex
teensy_loader_cli -w -s --mcu=mk64fx512 target/hex

@ratkins
Copy link

ratkins commented Apr 23, 2017

Failing at the compile step:

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/machine/_mcontext.h:31:2: error: architecture not supported, err: true
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/sys/_types/_sigaltstack.h:39:2: error: unknown type name '__darwin_size_t', err: true
fatal error: too many errors emitted, stopping now [-ferror-limit=], err: true

Full output:

MacBook-Pro:teensy3-rs-demo ratkins$ xargo build --release --target thumbv7em-none-eabi
   Compiling teensy3-sys v0.2.0 (https://github.com/jamesmunns/teensy3-rs.git?branch=add-feature-flags#0882354f)
error: failed to run custom build command for `teensy3-sys v0.2.0 (https://github.com/jamesmunns/teensy3-rs.git?branch=add-feature-flags#0882354f)`
process didn't exit successfully: `/Users/ratkins/Documents/Rust/teensy3-rs-demo/target/release/build/teensy3-sys-a6191ef0cd4944fa/build-script-build` (exit code: 101)
--- stdout
cargo:rustc-link-search=/Users/ratkins/Documents/Rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/build/teensy3-sys-0191a30e6ce51f05/out
cargo:rustc-link-search=native=/Users/ratkins/Documents/Rust/teensy3-rs-demo/target/thumbv7em-none-eabi/release/build/teensy3-sys-0191a30e6ce51f05/out
cargo:rustc-link-lib=static=teensyduino
warning: optimization flag '-fsingle-precision-constant' is not supported [-Wignored-optimization-argument], err: false
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/sys/cdefs.h:761:2: error: Unsupported architecture, err: true
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/machine/_types.h:34:2: error: architecture not supported, err: true
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/sys/_types.h:55:9: error: unknown type name '__int64_t', err: true
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/sys/_types.h:56:9: error: unknown type name '__int32_t', err: true
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/sys/_types.h:57:9: error: unknown type name '__int32_t', err: true
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/sys/_types.h:60:9: error: unknown type name '__uint32_t', err: true
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/sys/_types.h:61:9: error: unknown type name '__uint32_t', err: true
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/sys/_types.h:62:9: error: unknown type name '__uint64_t', err: true
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/sys/_types.h:68:9: error: unknown type name '__darwin_natural_t', err: true
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/sys/_types.h:70:9: error: unknown type name '__uint16_t', err: true
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/sys/_types.h:71:9: error: unknown type name '__int64_t', err: true
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/sys/_types.h:72:9: error: unknown type name '__int32_t', err: true
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/sys/_types.h:73:9: error: unknown type name '__uint32_t', err: true
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/sys/_types.h:74:9: error: unknown type name '__int32_t', err: true
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/sys/_types.h:75:9: error: unknown type name '__uint32_t', err: true
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/sys/_types.h:76:9: error: unknown type name '__uint32_t', err: true
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/machine/signal.h:34:2: error: architecture not supported, err: true
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/machine/_mcontext.h:31:2: error: architecture not supported, err: true
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/sys/_types/_sigaltstack.h:39:2: error: unknown type name '__darwin_size_t', err: true
fatal error: too many errors emitted, stopping now [-ferror-limit=], err: true

--- stderr
warning: optimization flag '-fsingle-precision-constant' is not supported [-Wignored-optimization-argument]
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/sys/cdefs.h:761:2: error: Unsupported architecture
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/machine/_types.h:34:2: error: architecture not supported
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/sys/_types.h:55:9: error: unknown type name '__int64_t'
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/sys/_types.h:56:9: error: unknown type name '__int32_t'
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/sys/_types.h:57:9: error: unknown type name '__int32_t'
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/sys/_types.h:60:9: error: unknown type name '__uint32_t'
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/sys/_types.h:61:9: error: unknown type name '__uint32_t'
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/sys/_types.h:62:9: error: unknown type name '__uint64_t'
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/sys/_types.h:68:9: error: unknown type name '__darwin_natural_t'
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/sys/_types.h:70:9: error: unknown type name '__uint16_t'
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/sys/_types.h:71:9: error: unknown type name '__int64_t'
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/sys/_types.h:72:9: error: unknown type name '__int32_t'
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/sys/_types.h:73:9: error: unknown type name '__uint32_t'
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/sys/_types.h:74:9: error: unknown type name '__int32_t'
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/sys/_types.h:75:9: error: unknown type name '__uint32_t'
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/sys/_types.h:76:9: error: unknown type name '__uint32_t'
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/machine/signal.h:34:2: error: architecture not supported
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/machine/_mcontext.h:31:2: error: architecture not supported
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/sys/_types/_sigaltstack.h:39:2: error: unknown type name '__darwin_size_t'
fatal error: too many errors emitted, stopping now [-ferror-limit=]
thread 'main' panicked at 'error when generating bindings: ()', src/libcore/result.rs:859
stack backtrace:
   0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
   1: std::panicking::default_hook::{{closure}}
   2: std::panicking::default_hook
   3: std::panicking::rust_panic_with_hook
   4: std::panicking::begin_panic
   5: std::panicking::begin_panic_fmt
   6: rust_begin_unwind
   7: core::panicking::panic_fmt
   8: core::result::unwrap_failed
   9: build_script_build::main
  10: __rust_maybe_catch_panic
  11: std::rt::lang_start

error: `cargo` process didn't exit successfully
MacBook-Pro:teensy3-rs-demo ratkins$ 

How do I know if I have "A somewhat current arm-none-eabi-gcc toolchain", and how do I get one on macOS Sierra? (I thought I must have had this installed from the last go-round, but I have no /usr/lib/gcc as mentioned upthread.)

@TheZoq2
Copy link

TheZoq2 commented Apr 23, 2017

@ratkins I think you can check if you have the toolchain installed by trying to run arm-none-eabi-gcc --version. Mine says 6.3.1. Unfortunately I have no idea how to install it on a mac

@Emilgardis
Copy link

@ratkins

brew tap mpaw/arm-none-eabi
brew update
brew install gcc-arm-none-eabi

@TheZoq2
Copy link

TheZoq2 commented Apr 23, 2017

@jamesmunns I tested the hardfloat stuff but it doesn't seem to work.

This is the error I got when running xargo build --release --target thumbv7em-none-eabihf after running make clean

error: failed to run custom build command for `teensy3-sys v0.2.0 (https://github.com/jamesmunns/teensy3-rs.git?branch=add-feature-flags#0882354f)`
process didn't exit successfully: `/home/frans/Documents/rust/teensy/teensy3-rs-demo/target/release/build/teensy3-sys-71bb3d409156eb0c/build-script-build` (exit code: 101)
--- stdout
cargo:rustc-link-search=/home/frans/Documents/rust/teensy/teensy3-rs-demo/target/thumbv7em-none-eabihf/release/build/teensy3-sys-fa8696eef2013e76/out
cargo:rustc-link-search=native=/home/frans/Documents/rust/teensy/teensy3-rs-demo/target/thumbv7em-none-eabihf/release/build/teensy3-sys-fa8696eef2013e76/out
cargo:rustc-link-lib=static=teensyduino
error: unknown argument: '-fsingle-precision-constant', err: true
cores/teensy3/new.h:14:6: warning: function previously declared with an explicit exception specification redeclared with an implicit exception specification [-Wimplicit-exception-spec-mismatch], err: false
cores/teensy3/new.h:15:6: warning: function previously declared with an explicit exception specification redeclared with an implicit exception specification [-Wimplicit-exception-spec-mismatch], err: false

--- stderr
arm-none-eabi-ar: `u' modifier ignored since `D' is the default (see `U')
thread 'main' panicked at 'error when generating bindings: ()', /checkout/src/libcore/result.rs:859
note: Run with `RUST_BACKTRACE=1` for a backtrace.

make: *** [Makefile:2: build] Error 101

This is my cargo.toml

[package]
name = "teensy3-rs-demo"
version = "0.1.0"
authors = ["Simon Sapin <simon.sapin@exyr.org>", "James Munns <james.munns@gmail.com>"]

[dependencies.teensy3]
git = "https://github.com/jamesmunns/teensy3-rs.git"
branch = "add-feature-flags"
features = ["teensy_3_5"]

[profile.dev]
panic = "abort"
lto = true

[profile.release]
panic = "abort"
lto = true

Edit: We seem to be in different timezones, I'll be in the irc channel now though

@TheZoq2
Copy link

TheZoq2 commented Apr 23, 2017

@jamesmunns I tried the same thing on my desktop where I have not made any modifications to the code. This time I got the following error

error[E0428]: a value named `FP_NAN` has already been defined in this module
    --> /home/frans/Documents/rust/teensy/teensy3-rs-demo/target/thumbv7em-none-eabihf/release/build/teensy3-sys-fa8696eef2013e76/out/bindings.rs:6551:1
     |
364  | pub const FP_NAN: c_types::c_uint = 0;
     | -------------------------------------- previous definition of `FP_NAN` here
...
6551 | pub const FP_NAN: _bindgen_ty_1 = _bindgen_ty_1::FP_NAN;
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `FP_NAN` already defined

error[E0428]: a value named `FP_INFINITE` has already been defined in this module
    --> /home/frans/Documents/rust/teensy/teensy3-rs-demo/target/thumbv7em-none-eabihf/release/build/teensy3-sys-fa8696eef2013e76/out/bindings.rs:6552:1
     |
365  | pub const FP_INFINITE: c_types::c_uint = 1;
     | ------------------------------------------- previous definition of `FP_INFINITE` here
...
6552 | pub const FP_INFINITE: _bindgen_ty_1 = _bindgen_ty_1::FP_INFINITE;
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `FP_INFINITE` already defined

error[E0428]: a value named `FP_ZERO` has already been defined in this module
    --> /home/frans/Documents/rust/teensy/teensy3-rs-demo/target/thumbv7em-none-eabihf/release/build/teensy3-sys-fa8696eef2013e76/out/bindings.rs:6553:1
     |
366  | pub const FP_ZERO: c_types::c_uint = 2;
     | --------------------------------------- previous definition of `FP_ZERO` here
...
6553 | pub const FP_ZERO: _bindgen_ty_1 = _bindgen_ty_1::FP_ZERO;
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `FP_ZERO` already defined

error[E0428]: a value named `FP_SUBNORMAL` has already been defined in this module
    --> /home/frans/Documents/rust/teensy/teensy3-rs-demo/target/thumbv7em-none-eabihf/release/build/teensy3-sys-fa8696eef2013e76/out/bindings.rs:6554:1
     |
367  | pub const FP_SUBNORMAL: c_types::c_uint = 3;
     | -------------------------------------------- previous definition of `FP_SUBNORMAL` here
...
6554 | pub const FP_SUBNORMAL: _bindgen_ty_1 = _bindgen_ty_1::FP_SUBNORMAL;
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `FP_SUBNORMAL` already defined

error[E0428]: a value named `FP_NORMAL` has already been defined in this module
    --> /home/frans/Documents/rust/teensy/teensy3-rs-demo/target/thumbv7em-none-eabihf/release/build/teensy3-sys-fa8696eef2013e76/out/bindings.rs:6555:1
     |
368  | pub const FP_NORMAL: c_types::c_uint = 4;
     | ----------------------------------------- previous definition of `FP_NORMAL` here
...
6555 | pub const FP_NORMAL: _bindgen_ty_1 = _bindgen_ty_1::FP_NORMAL;
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `FP_NORMAL` already defined

error: aborting due to 5 previous errors

error: Could not compile `teensy3-sys`.

Edit: Changing between feature teensy_3_5 and 3_2 don't seem to affect the output at all

Edit2: I realized that I ran a system update on my desktop which meant I was using clang4. Switching to clang35 gives me the same error as on my laptop

@ratkins
Copy link

ratkins commented Apr 23, 2017

@TheZoq2 / @Emilgardis thanks for that. I did have it installed via Homebrew and it's now at 5.4.1 and I'm getting a different error:

MacBook-Pro:teensy3-rs-demo ratkins$ make
   Compiling cfg-if v0.1.0
   Compiling nom v1.2.4
   Compiling term v0.4.5
   Compiling strsim v0.6.0
   Compiling unicode-xid v0.0.4
   Compiling serde v0.9.14
   Compiling utf8-ranges v1.0.0
   Compiling rustc-serialize v0.3.24
   Compiling itoa v0.3.1
   Compiling void v1.0.2
   Compiling unreachable v0.1.1
   Compiling bitflags v0.8.2
   Compiling unicode-segmentation v1.1.0
   Compiling siphasher v0.2.2
   Compiling ansi_term v0.9.0
   Compiling phf_shared v0.7.21
   Compiling log v0.3.7
   Compiling num-traits v0.1.37
   Compiling regex-syntax v0.4.0
   Compiling phf v0.7.21
   Compiling cexpr v0.2.0
   Compiling vec_map v0.7.0
   Compiling unicode-width v0.1.4
   Compiling lazy_static v0.2.8
   Compiling glob v0.2.11
   Compiling dtoa v0.4.1
   Compiling libc v0.2.21
   Compiling atty v0.2.2
   Compiling thread-id v3.0.0
   Compiling rand v0.3.15
   Compiling term_size v0.3.0
   Compiling clap v2.23.3
   Compiling clang-sys v0.15.1
   Compiling memchr v1.0.1
   Compiling thread_local v0.3.3
   Compiling phf_generator v0.7.21
   Compiling aho-corasick v0.6.3
   Compiling phf_codegen v0.7.21
   Compiling target_build_utils v0.3.0
   Compiling serde_json v0.9.10
   Compiling syntex_pos v0.58.1
   Compiling syntex_errors v0.58.1
   Compiling regex v0.2.1
   Compiling syntex_syntax v0.58.1
   Compiling libloading v0.3.4
   Compiling env_logger v0.4.2
   Compiling quasi v0.32.0
   Compiling syntex v0.58.1
   Compiling aster v0.41.0
   Compiling quasi_codegen v0.32.0
   Compiling bindgen v0.23.1
   Compiling teensy3-sys v0.2.0 (https://github.com/jamesmunns/teensy3-rs.git?branch=add-feature-flags#0882354f)
error: failed to run custom build command for `teensy3-sys v0.2.0 (https://github.com/jamesmunns/teensy3-rs.git?branch=add-feature-flags#0882354f)`
process didn't exit successfully: `/Users/ratkins/Documents/Rust/teensy3-rs-demo/target/release/build/teensy3-sys-bda5326a5a8b0a8f/build-script-build` (exit code: 101)
--- stdout
cargo:rustc-link-search=/Users/ratkins/Documents/Rust/teensy3-rs-demo/target/release/build/teensy3-sys-d0c0b84141981d40/out
cargo:rustc-link-search=native=/Users/ratkins/Documents/Rust/teensy3-rs-demo/target/release/build/teensy3-sys-d0c0b84141981d40/out
cargo:rustc-link-lib=static=teensyduino
warning: optimization flag '-fsingle-precision-constant' is not supported [-Wignored-optimization-argument], err: false
warning: argument unused during compilation: '-mthumb' [-Wunused-command-line-argument], err: false
warning: argument unused during compilation: '-mcpu=cortex-m4' [-Wunused-command-line-argument], err: false
cores/teensy3/new.h:14:6: warning: function previously declared with an explicit exception specification redeclared with an implicit exception specification [-Wimplicit-exception-spec-mismatch], err: false
cores/teensy3/new.h:15:6: warning: function previously declared with an explicit exception specification redeclared with an implicit exception specification [-Wimplicit-exception-spec-mismatch], err: false
cores/teensy3/avr_emulation.h:226:3: error: cast from pointer to smaller type 'uint32_t' (aka 'unsigned int') loses information, err: true
cores/teensy3/avr_emulation.h:230:3: error: cast from pointer to smaller type 'uint32_t' (aka 'unsigned int') loses information, err: true
cores/teensy3/avr_emulation.h:234:3: error: cast from pointer to smaller type 'uint32_t' (aka 'unsigned int') loses information, err: true
cores/teensy3/avr_emulation.h:238:3: error: cast from pointer to smaller type 'uint32_t' (aka 'unsigned int') loses information, err: true
cores/teensy3/avr_emulation.h:242:3: error: cast from pointer to smaller type 'uint32_t' (aka 'unsigned int') loses information, err: true
cores/teensy3/avr_emulation.h:246:3: error: cast from pointer to smaller type 'uint32_t' (aka 'unsigned int') loses information, err: true
cores/teensy3/avr_emulation.h:250:3: error: cast from pointer to smaller type 'uint32_t' (aka 'unsigned int') loses information, err: true
cores/teensy3/avr_emulation.h:254:3: error: cast from pointer to smaller type 'uint32_t' (aka 'unsigned int') loses information, err: true
cores/teensy3/avr_emulation.h:260:3: error: cast from pointer to smaller type 'uint32_t' (aka 'unsigned int') loses information, err: true
cores/teensy3/avr_emulation.h:265:3: error: cast from pointer to smaller type 'uint32_t' (aka 'unsigned int') loses information, err: true
cores/teensy3/avr_emulation.h:270:3: error: cast from pointer to smaller type 'uint32_t' (aka 'unsigned int') loses information, err: true
cores/teensy3/avr_emulation.h:275:3: error: cast from pointer to smaller type 'uint32_t' (aka 'unsigned int') loses information, err: true
cores/teensy3/avr_emulation.h:280:3: error: cast from pointer to smaller type 'uint32_t' (aka 'unsigned int') loses information, err: true
cores/teensy3/avr_emulation.h:285:3: error: cast from pointer to smaller type 'uint32_t' (aka 'unsigned int') loses information, err: true
cores/teensy3/avr_emulation.h:290:3: error: cast from pointer to smaller type 'uint32_t' (aka 'unsigned int') loses information, err: true
cores/teensy3/avr_emulation.h:295:3: error: cast from pointer to smaller type 'uint32_t' (aka 'unsigned int') loses information, err: true
cores/teensy3/avr_emulation.h:445:3: error: cast from pointer to smaller type 'uint32_t' (aka 'unsigned int') loses information, err: true
cores/teensy3/avr_emulation.h:449:3: error: cast from pointer to smaller type 'uint32_t' (aka 'unsigned int') loses information, err: true
cores/teensy3/avr_emulation.h:453:3: error: cast from pointer to smaller type 'uint32_t' (aka 'unsigned int') loses information, err: true
fatal error: too many errors emitted, stopping now [-ferror-limit=], err: true

--- stderr
warning: optimization flag '-fsingle-precision-constant' is not supported [-Wignored-optimization-argument]
warning: argument unused during compilation: '-mthumb' [-Wunused-command-line-argument]
warning: argument unused during compilation: '-mcpu=cortex-m4' [-Wunused-command-line-argument]
cores/teensy3/new.h:14:6: warning: function previously declared with an explicit exception specification redeclared with an implicit exception specification [-Wimplicit-exception-spec-mismatch]
cores/teensy3/new.h:15:6: warning: function previously declared with an explicit exception specification redeclared with an implicit exception specification [-Wimplicit-exception-spec-mismatch]
cores/teensy3/avr_emulation.h:226:3: error: cast from pointer to smaller type 'uint32_t' (aka 'unsigned int') loses information
cores/teensy3/avr_emulation.h:230:3: error: cast from pointer to smaller type 'uint32_t' (aka 'unsigned int') loses information
cores/teensy3/avr_emulation.h:234:3: error: cast from pointer to smaller type 'uint32_t' (aka 'unsigned int') loses information
cores/teensy3/avr_emulation.h:238:3: error: cast from pointer to smaller type 'uint32_t' (aka 'unsigned int') loses information
cores/teensy3/avr_emulation.h:242:3: error: cast from pointer to smaller type 'uint32_t' (aka 'unsigned int') loses information
cores/teensy3/avr_emulation.h:246:3: error: cast from pointer to smaller type 'uint32_t' (aka 'unsigned int') loses information
cores/teensy3/avr_emulation.h:250:3: error: cast from pointer to smaller type 'uint32_t' (aka 'unsigned int') loses information
cores/teensy3/avr_emulation.h:254:3: error: cast from pointer to smaller type 'uint32_t' (aka 'unsigned int') loses information
cores/teensy3/avr_emulation.h:260:3: error: cast from pointer to smaller type 'uint32_t' (aka 'unsigned int') loses information
cores/teensy3/avr_emulation.h:265:3: error: cast from pointer to smaller type 'uint32_t' (aka 'unsigned int') loses information
cores/teensy3/avr_emulation.h:270:3: error: cast from pointer to smaller type 'uint32_t' (aka 'unsigned int') loses information
cores/teensy3/avr_emulation.h:275:3: error: cast from pointer to smaller type 'uint32_t' (aka 'unsigned int') loses information
cores/teensy3/avr_emulation.h:280:3: error: cast from pointer to smaller type 'uint32_t' (aka 'unsigned int') loses information
cores/teensy3/avr_emulation.h:285:3: error: cast from pointer to smaller type 'uint32_t' (aka 'unsigned int') loses information
cores/teensy3/avr_emulation.h:290:3: error: cast from pointer to smaller type 'uint32_t' (aka 'unsigned int') loses information
cores/teensy3/avr_emulation.h:295:3: error: cast from pointer to smaller type 'uint32_t' (aka 'unsigned int') loses information
cores/teensy3/avr_emulation.h:445:3: error: cast from pointer to smaller type 'uint32_t' (aka 'unsigned int') loses information
cores/teensy3/avr_emulation.h:449:3: error: cast from pointer to smaller type 'uint32_t' (aka 'unsigned int') loses information
cores/teensy3/avr_emulation.h:453:3: error: cast from pointer to smaller type 'uint32_t' (aka 'unsigned int') loses information
fatal error: too many errors emitted, stopping now [-ferror-limit=]
thread 'main' panicked at 'error when generating bindings: ()', src/libcore/result.rs:859
stack backtrace:
   0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
   1: std::panicking::default_hook::{{closure}}
   2: std::panicking::default_hook
   3: std::panicking::rust_panic_with_hook
   4: std::panicking::begin_panic
   5: std::panicking::begin_panic_fmt
   6: rust_begin_unwind
   7: core::panicking::panic_fmt
   8: core::result::unwrap_failed
   9: build_script_build::main
  10: __rust_maybe_catch_panic
  11: std::rt::lang_start

error: `cargo` process didn't exit successfully
make: *** [build] Error 101

So that seems to be the same error as @TheZoq2? I'm running Apple LLVM version 8.1.0 (clang-802.0.42) (the one that ships with Xcode 8.3.2). Is that ok?

@jamesmunns
Copy link
Owner Author

Hey @ratkins and @TheZoq2, thanks for testing! I will have to try and lock down the specific dependencies, and also probably try to test in a more reliable environment than "works on my machine".

I also am a little worried about how much value users actually get from generating the bindings and build time (if they use teensy3-sys as a crate, they should always get the same output). I may add a "use the prerendered bindings" flag so that users can choose to skip bindgen if they don't care.

At least one problem was caused by me adding this line: https://github.com/jamesmunns/teensy3-rs/blob/add-feature-flags/teensy3-sys/build.rs#L23 - I will revert this change. It looks like this will at least partially fix @TheZoq2 's issues.

@jamesmunns
Copy link
Owner Author

@TheZoq2 I pushed the changes, you can try again if you like. You may need to run xargo update, or maybe xargo clean to make sure it catches that the git repo (teensy3) has been updated.

@ratkins you are welcome to try again now, but it looks like different versions of llvm, or even Mac's version vs Linux's version of llvm is likely going to cause some problems.

I am using clang v3.9, from the PPA provided by Clang, on debian, in a docker image.

root@af8d8ce618dd:/# clang-3.9 --version
clang version 3.9.1-svn288847-1~exp1 (branches/release_39)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

@TheZoq2
Copy link

TheZoq2 commented Apr 24, 2017

Looks like your fixed worked @jamesmunns.

@ratkins
Copy link

ratkins commented Apr 24, 2017

Still similar errors for me:

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/sys/cdefs.h:761:2: error: Unsupported architecture, err: true
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/machine/_types.h:34:2: error: architecture not supported, err: true
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/sys/_types.h:55:9: error: unknown type name '__int64_t', err: true
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/sys/_types.h:56:9: error: unknown type name '__int32_t', err: true
...

From that I'm not even sure if it's trying to cross-compile?

@Chreutz
Copy link

Chreutz commented May 13, 2017

@jamesmunns Would it help the process if you had a 3.5/3.6 board ? I will gladly buy one for that cause if you would like it. I'm a little new in the low level embedded stuff, but I'd like to contribute, and I'll see how far I can get on a 3.5 the next couple of days.

@BlinkyStitt
Copy link

Teensy 4.0 is out now.

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

9 participants