The good thing with many vendors is: they offer development tools free of charge. And the limitations are typically reasonable for many projects. The Eclipse based CodeWarrior for MCU10 is not an exception: it comes in a free (‘Special’) Edition which allows up to 128 KByte of code to download for my ARM/Kinetis projects.
But, when I tried to debug an Example I have downloaded from the web, I get this dialog:
“Download size limit has been exceeded. Please check your license.”
Obviously I’m running beyond the limits. But what is my code size? To find out, I enable link map generation in the build tool settings:
At the bottom of the linker map I find the code size information:
# Memory map: v_addr p_addr size name 00000000 00000000 000001E0 .interrupts m_interrupts 00000800 00000800 00007F48 .app_text m_text 20000000 20000000 00000000 .usb_bdt_sec m_bdt 1FFF0000 00008748 00000D68 .app_data m_data 1FFF0D68 1FFF0D68 000003E8 .bss m_data 1FFF1150 000094B0 00000018 .romp m_data 00000400 00000400 00000000 .cfmprotect m_cfmprotrom
m_text with 0x7F48 is way below 128 KByte. Checking the brochure shows “C: 128K” for Kinetis and Special Edition:
Oh! it says ‘C‘! Could it be that I have C++ in that example project? I have not seen any C++ files. Maybe the linker map file helps here again?
And indeed, having a look in the linker map file shows usage of C++ functions. For this I searched for “cxx” and “cpp”:
000069A0 00000000 .text $t (librt_Thumb_LE_v7M.a cxxabi_rtti.o ) 000069B0 00000016 .text __cxxabiv1::__pointer_type_info::~__pointer_type_info[virtual]() (librt_Thumb_LE_v7M.a cxxabi_rtti.o ) 000069B0 00000000 .text $t (librt_Thumb_LE_v7M.a cxxabi_rtti.o ) 000069C8 00000004 .text __ARM_resolve_target2(void*) (librt_Thumb_LE_v7M.a cppsemantics.o ) ... 00008728 00000000 .rodata .rodata (librt_Thumb_LE_v7M.a cppsemantics.o ) 00008728 0000000C .rodata __ARM::is_foreign_exception(_Unwind_Control_Block*)::is_foreign_exception_static (librt_Thumb_LE_v7M.a cppsemantics.o ) 00008734 00000014 .rodata virtual table for std::bad_exception (librt_Thumb_LE_v7M.a cppsemantics.o )
But: I do not remember using C++? Looking at the names, it is clear that this is something from the libraries, and has to do with exception handling. Well, this gives a hint, as there is an option to enable exception handling in the compiler. And indeed, that project had that option enabled (not sure why?).
So the solution is to disable the ‘Enable Exceptions’ in the compiler settings:
Now the debugger does not complain any more, and I am able to debug my (purely C) application. And as a positive side effect: the code size changed from 0x7F48 to 0x6084 (more than 7 KByte less code!) 🙂
If I run into a Special Edition code limit, it might be that the application contains C++ code. It is a good idea to check if the compiler has ‘Enable Exceptions’ set in the build options. Disabling that option not only prevents including C++ library code, but as well makes the application file much smaller.
Happy Special Edition Debugging 🙂