edgeimpulse / ei-ti-code-composer-examples

Examples and walkthroughs integrating Edge Impulse with TI Code Composer projects
3 stars 1 forks source link

Cannot compile on Windows due to path length #1

Open ShawnHymel opened 2 years ago

ShawnHymel commented 2 years ago

From a few users: https://forum.edgeimpulse.com/t/the-file-name-or-extension-is-too-long-0xce/4310

It seems these examples will not compile on Windows with CCS due to "the filename or extension is too long" errors. They have tried enabling long path names in Windows to no avail.

ShawnHymel commented 2 years ago

win-error

Dasch0 commented 2 years ago

I've gotten some feedback from TI support on a workaround for this issue:

Basically, ccstudio works by compiling every single .c/cpp file in the project to an object file, and then passing them to the linker. The problem is that depending on what model you’ve output, lots of the tensorflow/cmsis kernel .o files aren’t actually used, but you still end up with a massive linker command (see the ORDERED_OBJS variable in /Release/makefile) that is >52000 characters. The windows command line has a hard limit at 32768 characters, and long path name support won’t fix this.

The workaround is that we need to modify the makefile generated by ccstudio to provide a .opt file of objects to the linker instead of writing them all inline. It turns out the IDE already generates this in /Release/ccsObjs.opt, but the autogenerated makefile does not use it when invoking the linker. With that, workaround steps are:

  1. Attempt to build your project normally, such that you have a /Debug or /Release directory. This will autogenerate a makefile for your project.

  2. Open Project->Properties->Build, and uncheck “Generate Makefiles automatically”

  3. Modify the line of /Release/makefile that invokes the linker (for my test project, line 953), replacing $(ORDERED_OBJS) with @"./ccsObjs.opt" Example of the resulting linker invocation from my resulting makefile:

###@Line 951
# Tool invocations
ei_simple_ble_5_30_CC1352P7_1_tirtos_ticlang.out: $(OBJS) $(CMD_SRCS) $(A_SRCS) $(GEN_CMDS)
    @echo 'Building target: "$@"'
    @echo 'Invoking: Arm Linker'
    "/Applications/ti/ccs1110/ccs/tools/compiler/ti-cgt-armllvm_1.3.0.LTS/bin/tiarmclang" @"/Users/das/ei_ccs_demo_workspace/ei_simple_ble_5_30_CC1352P7_1_tirtos_ticlang/Release/syscfg/ti_ble_app_config.opt" @"/Users/das/ei_ccs_demo_workspace/ei_simple_ble_5_30_CC1352P7_1_tirtos_ticlang/Release/syscfg/ti_build_config.opt" @"/Users/das/ti/simplelink_cc13x2_26x2_sdk_5_20_00_52/source/ti/ble5stack/config/build_components.opt" @"/Users/das/ti/simplelink_cc13x2_26x2_sdk_5_20_00_52/source/ti/ble5stack/config/factory_config.opt"  -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mlittle-endian -mthumb -Oz -DEI_CLASSIFIER_ALLOCATION_STATIC=1 -DEI_PORTING_TI=1 -DDeviceFamily_CC13X2X7 -DFLASH_ROM_BUILD -DNVOCMP_NWSAMEITEM=1 -gdwarf-3 -march=armv7e-m -Wl,-m"ei_simple_ble_5_30_CC1352P7_1_tirtos_ticlang.map" -Wl,-i"/Users/das/ti/simplelink_cc13x2_26x2_sdk_5_20_00_52/source" -Wl,-i"/Users/das/ti/simplelink_cc13x2_26x2_sdk_5_20_00_52/kernel/tirtos/packages" -Wl,-i"/Users/das/ei_ccs_demo_workspace/ei_simple_ble_5_30_CC1352P7_1_tirtos_ticlang/Release/syscfg" -Wl,-i"/Applications/ti/ccs1110/ccs/tools/compiler/ti-cgt-armllvm_1.3.0.LTS/lib" -Wl,--reread_libs -Wl,--define=FLASH_ROM_BUILD=2 -Wl,--diag_suppress=16002-D -Wl,--diag_suppress=10247-D -Wl,--diag_suppress=10325-D -Wl,--diag_suppress=10229-D -Wl,--diag_suppress=16032-D -Wl,--diag_wrap=off -Wl,--display_error_number -Wl,--warn_sections -Wl,--xml_link_info="ei_simple_ble_5_30_CC1352P7_1_tirtos_ticlang_linkInfo.xml" -Wl,--rom_model -o "ei_simple_ble_5_30_CC1352P7_1_tirtos_ticlang.out" @"./ccsObjs.opt" $(A_SRCS)
    @echo 'Finished building target: "$@"'
    @echo ' '
    @$(MAKE) --no-print-directory post-build

The total linker invocation is now only 1768 characters.

I'd like to fix this in the makefile generation rather than require manual editing, so I'll leave the issue open for now