leroilion / teensy-core

1 stars 0 forks source link

Teensy 3.2 support #1

Open FFY00 opened 5 years ago

FFY00 commented 5 years ago

I am trying to use this with a Teensy 3.2. I modified the cross file acordingly but I've ran into a problem.

/usr/bin/arm-none-eabi-g++  -o hid-sample 'hid-sample@exe/src_hid-sample.cpp.o' -Wl,--no-undefined -Wl,--as-needed -Wl,--start-group subprojects/teensy-core/libteensy-core.a -Wl,--end-group -T/home/anubis/git/mcu-hid-sample/subprojects/teensy-core/teensy3/mk20dx256.ld '-Wl,-rpath,$ORIGIN/subprojects/teensy-core' -Wl,-rpath-link,/home/anubis/git/mcu-hid-sample/build/subprojects/teensy-core -Os -Wl,--gc-sections -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 
/usr/lib/gcc/arm-none-eabi/8.2.0/../../../../arm-none-eabi/bin/ld: subprojects/teensy-core/libteensy-core.a(teensy3_mk20dx128.c.o): in function `ResetHandler':
/home/anubis/git/mcu-hid-sample/build/../subprojects/teensy-core/teensy3/mk20dx128.c:769: undefined reference to `__rtc_localtime'
/usr/lib/gcc/arm-none-eabi/8.2.0/../../../../arm-none-eabi/bin/ld: subprojects/teensy-core/libteensy-core.a(teensy3_mk20dx128.c.o):(.vectors+0x3c): undefined reference to `systick_isr'
/usr/lib/gcc/arm-none-eabi/8.2.0/../../../../arm-none-eabi/bin/ld: subprojects/teensy-core/libteensy-core.a(teensy3_yield.cpp.o): in function `yield':
/home/anubis/git/mcu-hid-sample/build/../subprojects/teensy-core/teensy3/EventResponder.h:198: undefined reference to `EventResponder::firstYield'
/usr/lib/gcc/arm-none-eabi/8.2.0/../../../../arm-none-eabi/bin/ld: /home/anubis/git/mcu-hid-sample/build/../subprojects/teensy-core/teensy3/EventResponder.h:198: undefined reference to `EventResponder::runningFromYield'
/usr/lib/gcc/arm-none-eabi/8.2.0/../../../../arm-none-eabi/bin/ld: /home/anubis/git/mcu-hid-sample/build/../subprojects/teensy-core/teensy3/EventResponder.h:198: undefined reference to `EventResponder::lastYield'

I fixed the first error by adding -Wl,--defsym=__rtc_localtime=(current timestamp) to the linker args but I still get:

/usr/bin/arm-none-eabi-g++  -o hid-sample 'hid-sample@exe/src_hid-sample.cpp.o' -Wl,--no-undefined -Wl,--as-needed -Wl,--start-group subprojects/teensy-core/libteensy-core.a -Wl,--end-group -T/home/anubis/git/mcu-hid-sample/subprojects/teensy-core/teensy3/mk20dx256.ld -Wl,--defsym=__rtc_localtime=1550189305 '-Wl,-rpath,$ORIGIN/subprojects/teensy-core' -Wl,-rpath-link,/home/anubis/git/mcu-hid-sample/build/subprojects/teensy-core -Os -Wl,--gc-sections -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 
/usr/lib/gcc/arm-none-eabi/8.2.0/../../../../arm-none-eabi/bin/ld: subprojects/teensy-core/libteensy-core.a(teensy3_mk20dx128.c.o):(.vectors+0x3c): undefined reference to `systick_isr'
/usr/lib/gcc/arm-none-eabi/8.2.0/../../../../arm-none-eabi/bin/ld: subprojects/teensy-core/libteensy-core.a(teensy3_yield.cpp.o): in function `yield':
/home/anubis/git/mcu-hid-sample/build/../subprojects/teensy-core/teensy3/EventResponder.h:198: undefined reference to `EventResponder::firstYield'
/usr/lib/gcc/arm-none-eabi/8.2.0/../../../../arm-none-eabi/bin/ld: /home/anubis/git/mcu-hid-sample/build/../subprojects/teensy-core/teensy3/EventResponder.h:198: undefined reference to `EventResponder::runningFromYield'
/usr/lib/gcc/arm-none-eabi/8.2.0/../../../../arm-none-eabi/bin/ld: /home/anubis/git/mcu-hid-sample/build/../subprojects/teensy-core/teensy3/EventResponder.h:198: undefined reference to `EventResponder::lastYield'
leroilion commented 5 years ago

I didn't work on this repo since I create it and I don't know if I have a teensy 3.2 at home. But I can try ...

Can you send me your cross file compilation ? Do you have a repo with all your project ?

FFY00 commented 5 years ago

I'll send the cross file when I get home. I am just trying to build a simple arduino program, the project shouldn't matter. I can send it if you want but if you try to build https://github.com/leroilion/teensy-blink it should have the same behavior.

FFY00 commented 5 years ago

Here's my teensy-32-cross.txt.

[binaries]
c = 'arm-none-eabi-gcc'
cpp = 'arm-none-eabi-g++'
ar = 'arm-none-eabi-ar'
strip = 'arm-none-eabi-strip'
objcopy = 'arm-none-eabi-objcopy'

[host_machine]
system = 'bare-metal'
cpu_family = 'arm'
cpu = 'cortex-m4'
endian = 'little'

[properties]

teensy_mcu = 'mk20dx256'
teensy_ldscript = 'teensy3/mk20dx256.ld'

c_args = [
    '-DF_CPU=72000000',
    '-DUSB_SERIAL',
    '-DLAYOUT_US_ENGLISH',
    '-mthumb',
    '-ffunction-sections',
    '-fdata-sections',
    '-nostdlib',
    '-DTEENSYDUINO=138',
    '-D__MK20DX256__',
    '-DARDUINO=10804',
    '-mcpu=cortex-m4',
    '-mfloat-abi=hard',
    '-mfpu=fpv4-sp-d16'
    ]

cpp_args = [
    '-DF_CPU=72000000',
    '-DUSB_SERIAL',
    '-DLAYOUT_US_ENGLISH',
    '-mthumb',
    '-ffunction-sections',
    '-fdata-sections',
    '-nostdlib',
    '-DTEENSYDUINO=138',
    '-D__MK20DX256__',
    '-DARDUINO=10804',
    '-mcpu=cortex-m4',
    '-mfloat-abi=hard',
    '-mfpu=fpv4-sp-d16',
    '-std=gnu++11',
    '-felide-constructors',
    '-fno-exceptions',
    '-fno-rtti'
    ]

c_link_args = [
    '-Os',
    '-Wl,--gc-sections',
    '-mthumb',
    '-mcpu=cortex-m4',
    '-mfloat-abi=hard',
    '-mfpu=fpv4-sp-d16'
    ]

cpp_link_args = [
    '-Os',
    '-Wl,--gc-sections',
    '-mthumb',
    '-mcpu=cortex-m4',
    '-mfloat-abi=hard',
    '-mfpu=fpv4-sp-d16',
    ]
FFY00 commented 5 years ago

The slution for this was to update the core library. Still doesn't work though, I ended upd diging and making a draft pull request to the upstream repo (https://github.com/PaulStoffregen/cores/pull/356). If you could take a look and see if you can help, it would be appreciated.

I would also appreciate if you could verify that my changes didn't break anything for the Teensy 3.5. I have a sample repo ready to go at https://github.com/FFY00/teensy-meson-sample if you want to test, you probably just need to change the gcc path in the cross files.

Thank you :grin: