Author Topic: KDS: 'post-build' failed  (Read 15629 times)

Offline MirceaMurar

  • Newbie
  • *
  • Posts: 7
    • View Profile
KDS: 'post-build' failed
« on: July 06, 2016, 04:44:58 PM »
Dear all,

Please help me overcome this issue    :'( :'( :'(.

I have encountered an error when building uTaskerv1.4 with KDS 3.
The error says: makefile:97: recipe for target 'post-build' failed

Since this is my first project with uTasker I would like to share the steps I've done:
1. Downloaded and installed KDS version 3.
2. Replaced mbed firmware with PEMicro OpenSDA v2.0 firmware for a FRDM K64F board
    I think firmware replacement was ok since I was able to develop from scratch a new application to blink an LED using KDS and successfully flash it and debug it using PEMicro OpenSDA v2.0

3. Unzip uTaskerKinetisV1.4.7 and open it with Visual Studio 2015.
4. In config.h I commented KINETIS_KE00 and un-commented KINETIS_K64. I also enabled Ethernet interface.
5. Build and simulated it under Visual Studio 2015 was ok.

6. Copy the project in a different folder and followed the steps for KDS found on:
http://www.utasker.com/kinetis/compilers.html#KDS
- delete .settings folder and all .* files and copy the .settings and all .* files from uTaskerKinetisV1.4.7\Applications\uTaskerV1.4\KinetisDesignStudio\Project_Settings

7. import program
- checked if cortex-m4 is selected
-linker modified to: "${uTaskerLinkerScripts}/K_1M_256.ld"

8. Triggered Built with option : uTaskerV1.4_FLASH

Received the error: recipe for target 'post-build' failed.

I tried the whole procedure for several times and I got the same error.

Some text that I got within KDS console can be found bellow:

Building target: uTaskerV1.4.elf
Invoking: Cross ARM C++ Linker
arm-none-eabi-g++ -mcpu=cortex-m4 -mthumb -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -Wall  -g -T "C:/Users/Z210/Desktop/utasker KDS/uTaskerKinetisV1.4.7/Applications/uTaskerV1.4/KinetisCodeWarrior/Linker_Files/K_1M_256.ld" -nostartfiles -Xlinker --gc-sections -Wl,-Map,"uTaskerV1.4.map" -o "uTaskerV1.4.elf"  ./uTasker/utFAT/mass_storage.o  ./uTasker/uGLCDLIB/GLCD.o ./uTasker/uGLCDLIB/LCD.o  ./uTasker/MODBUS/MODBUS.o  ./uTasker/Driver.o ./uTasker/GlobalTimer.o ./uTasker/SSC_drv.o ./uTasker/Tty_drv.o ./uTasker/USB_drv.o ./uTasker/Watchdog.o ./uTasker/can_drv.o ./uTasker/eth_drv.o ./uTasker/iic_drv.o ./uTasker/low_power.o ./uTasker/uFile.o ./uTasker/uMalloc.o ./uTasker/uNetwork.o ./uTasker/uTasker.o  ./stack/Ethernet.o ./stack/NetBIOS.o ./stack/arp.o ./stack/dhcp.o ./stack/dns.o ./stack/ftp.o ./stack/ftp_client.o ./stack/http.o ./stack/icmp.o ./stack/igmp.o ./stack/ip.o ./stack/ip_utils.o ./stack/pop3.o ./stack/ppp.o ./stack/smtp.o ./stack/snmp.o ./stack/tcp.o ./stack/telnet.o ./stack/tftp.o ./stack/udp.o ./stack/webutils.o ./stack/zero_config.o  ./Hardware/Kinetis/kinetis.o  ./Applications/uTaskerV1.4/KeyScan.o ./Applications/uTaskerV1.4/NetworkIndicator.o ./Applications/uTaskerV1.4/application.o ./Applications/uTaskerV1.4/debug.o ./Applications/uTaskerV1.4/modbus_app.o ./Applications/uTaskerV1.4/snmp_mib_handlers.o ./Applications/uTaskerV1.4/usb_application.o ./Applications/uTaskerV1.4/webInterface.o   
Finished building target: uTaskerV1.4.elf
 
make --no-print-directory post-build
"C:/Users/Z210/Desktop/utasker KDS/uTaskerKinetisV1.4.7/Applications/uTaskerV1.4/KinetisDesignStudio/uTaskerV1.4_FLASH/generate.bat
c:/freescale/kds_v3/eclipse/../bin/sh: syntax error: unterminated quoted string
makefile:97: recipe for target 'post-build' failed
make[1]: [post-build] Error 2 (ignored)

 
Invoking: Cross ARM GNU Create Flash Image
arm-none-eabi-objcopy -O ihex "uTaskerV1.4.elf"  "uTaskerV1.4.hex"
Finished building: uTaskerV1.4.hex
 
Invoking: Cross ARM GNU Create Listing
arm-none-eabi-objdump --source --all-headers --demangle --line-numbers --wide "uTaskerV1.4.elf" > "uTaskerV1.4.lst"
Finished building: uTaskerV1.4.lst
 
Invoking: Cross ARM GNU Print Size
arm-none-eabi-size --format=berkeley "uTaskerV1.4.elf"
   text      data       bss       dec       hex   filename
  75107        88      2165     77360     12e30   uTaskerV1.4.elf
Finished building: uTaskerV1.4.siz
 

18:31:13 Build Finished (took 21s.548ms)

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: KDS: 'post-build' failed
« Reply #1 on: July 06, 2016, 06:03:49 PM »
Hi

The KDS project is building correctly so you can program to the HW and run it (also debug it with the debugger).

What is failing is the post-build step which executes the bat file
/Applications/uTaskerV1.4/KinetisDesignStudio/uTaskerV1.4_FLASH/generate.bat
This has the following content and can also be run directly from DOS (without being called by KDS):

arm-none-eabi-objcopy  --output-target=binary uTaskerV1.4.elf ..\Applications\uTaskerV1.4\KinetisDesignStudio\uTaskerV1.4_FLASH\uTaskerV1.4.bin
arm-none-eabi-objcopy  --output-target=srec uTaskerV1.4.elf ..\Applications\uTaskerV1.4\KinetisDesignStudio\uTaskerV1.4_FLASH\uTaskerV1.4.srec
arm-none-eabi-objcopy  --output-target=ihex uTaskerV1.4.elf ..\Applications\uTaskerV1.4\KinetisDesignStudio\uTaskerV1.4_FLASH\uTaskerV1.4.hex

As you see, it is simply converting the generted *.elf file (that was successfully built) to binary, srec and ihex versions, that are useful for loading with certain tools.
Unfortunately I don't undertand why it is causing an error but it may have something to do with the environment not being able to handle a path or not finding a utility (things may also change between KDS versions and cause things that were working to start failing...)

You could check the location of the objcopy on your machine and call it absolutely (I think that KDS usually enters it into the machine's search path). Usually there is also a copy of objcopy.exe in the /tools directory that could be used instead.
Try to get the bat file to work on your machine from DOS, then check that it works as post-build step in the KDS environment - in the worst case you can execute the bat file outside of KDS. Also, KDS allows one of these output formats to be generated automatically (see linker settings) and the bat file is used only to be able to "always" have the three formats available, which KDS can't do (since it only allows selecting one at a time). If you always load from KDS with the debugger you don't need the step at all...

Regards

Mark


Offline MirceaMurar

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: KDS: 'post-build' failed
« Reply #2 on: July 06, 2016, 07:44:33 PM »
Hello Mark,

thanks for your fast reply and your hints...indeed it works even with that post-build error.
The program that I tested first was the original version of uTaskerKinetisV1.4.7.

Now I loaded in KDS my application which of course uses a modified version of uTaskerKinetisV1.4.7.
Still even if non-important changes were made I got a real error at build (I believe something with the interrupt vector):

Sorry for large console output!

Building target: uTaskerV1.4.elf
Invoking: Cross ARM C++ Linker
arm-none-eabi-g++ -mcpu=cortex-m4 -mthumb -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -Wall  -g -T "C:\Users\Z210\Desktop\utasker KDS\V1.12\uTaskerKinetisV1.4.7\Applications\uTaskerV1.4\KinetisCodeWarrior\Linker_Files\K_1M_256.ld" -nostartfiles -Xlinker --gc-sections -Wl,-Map,"uTaskerV1.4.map" -o "uTaskerV1.4.elf"  ./uTasker/utFAT/mass_storage.o  ./uTasker/uGLCDLIB/GLCD.o ./uTasker/uGLCDLIB/LCD.o  ./uTasker/MODBUS/MODBUS.o  ./uTasker/Driver.o ./uTasker/GlobalTimer.o ./uTasker/SSC_drv.o ./uTasker/Tty_drv.o ./uTasker/USB_drv.o ./uTasker/Watchdog.o ./uTasker/can_drv.o ./uTasker/eth_drv.o ./uTasker/iic_drv.o ./uTasker/low_power.o ./uTasker/uFile.o ./uTasker/uMalloc.o ./uTasker/uNetwork.o ./uTasker/uTasker.o  ./stack/Ethernet.o ./stack/NetBIOS.o ./stack/arp.o ./stack/dhcp.o ./stack/dns.o ./stack/ftp.o ./stack/ftp_client.o ./stack/http.o ./stack/icmp.o ./stack/igmp.o ./stack/ip.o ./stack/ip_utils.o ./stack/pop3.o ./stack/ppp.o ./stack/smtp.o ./stack/snmp.o ./stack/tcp.o ./stack/telnet.o ./stack/tftp.o ./stack/udp.o ./stack/webutils.o ./stack/zero_config.o  ./Hardware/Kinetis/kinetis.o  ./Applications/uTaskerV1.4/KeyScan.o ./Applications/uTaskerV1.4/NetworkIndicator.o ./Applications/uTaskerV1.4/application.o ./Applications/uTaskerV1.4/debug.o ./Applications/uTaskerV1.4/modbus_app.o ./Applications/uTaskerV1.4/snmp_mib_handlers.o ./Applications/uTaskerV1.4/usb_application.o ./Applications/uTaskerV1.4/webInterface.o   
c:/freescale/kds_v3/toolchain/bin/../lib/gcc/arm-none-eabi/4.8.4/../../../../arm-none-eabi/bin/ld.exe: section .ARM.exidx loaded at [00000000,00000007] overlaps section .vectors loaded at [00000000,00000007]
./Hardware/Kinetis/kinetis.o:(.rodata.ctTaskTable+0xc4): undefined reference to `fnMyFirstTask'
./Hardware/Kinetis/kinetis.o:(.rodata.ctTaskTable+0xd4): undefined reference to `fnMyPollingTask'
c:/freescale/kds_v3/toolchain/bin/../lib/gcc/arm-none-eabi/4.8.4/../../../../arm-none-eabi/lib/armv7e-m\libg.a(lib_a-sbrkr.o): In function `_sbrk_r':
sbrkr.c:(.text._sbrk_r+0xc): undefined reference to `_sbrk'
collect2.exe: error: ld returned 1 exit status
makefile:66: recipe for target 'uTaskerV1.4.elf' failed
make: *** [uTaskerV1.4.elf] Error 1


Best regards,
Mircea.

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: KDS: 'post-build' failed
« Reply #3 on: July 07, 2016, 01:29:22 PM »
Hi

I see several errors but can't explain then fully just form the output:

c:/freescale/kds_v3/toolchain/bin/../lib/gcc/arm-none-eabi/4.8.4/../../../../arm-none-eabi/bin/ld.exe: section .ARM.exidx loaded at [00000000,00000007] overlaps section .vectors loaded at [00000000,00000007]


It looks like you have added code which also has an reset vector. These two reset vectors now overlap. You need to identify where .ARM.exidx is originating from and remove it.

./Hardware/Kinetis/kinetis.o:(.rodata.ctTaskTable+0xc4): undefined reference to `fnMyFirstTask'
./Hardware/Kinetis/kinetis.o:(.rodata.ctTaskTable+0xd4): undefined reference to `fnMyPollingTask'

It looks like you added references to two new tasks but the code where the are located has not been added to the project. If they are in the /application directory they should automatically be added.

c:/freescale/kds_v3/toolchain/bin/../lib/gcc/arm-none-eabi/4.8.4/../../../../arm-none-eabi/lib/armv7e-m\libg.a(lib_a-sbrkr.o): In function `_sbrk_r':
sbrkr.c:(.text._sbrk_r+0xc): undefined reference to `_sbrk'

It looks like you have added code which uses malloc() or printf(), which seems to need malloc(). This requires extra libraries which are missing.

I would start with the operating version and add your own code one step at a time to identify when problems start. This would make it obvious when the build starts to fail.

Regards

Mark

Offline MirceaMurar

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: KDS: 'post-build' failed
« Reply #4 on: July 08, 2016, 09:27:02 PM »
Hello Mark,

thanks for your hints...I already start build the application step by step.

Even if Visual Studio does not complain about using strtof it seems KDS v3 does not like it and it might be the cause of:

c:/freescale/kds_v3/toolchain/bin/../lib/gcc/arm-none-eabi/4.8.4/../../../../arm-none-eabi/lib/armv7e-m\libg.a(lib_a-sbrkr.o): In function `_sbrk_r':
sbrkr.c:(.text._sbrk_r+0xc): undefined reference to `_sbrk'


I use strtof to get a floating point number from a string....it seems that I have to find a workaround using fnDecStrHex, unless there is an already implemented way to extract a floating point number from a string.

I will continue tomorrow.
Best regards,
Mircea.


Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: KDS: 'post-build' failed
« Reply #5 on: July 10, 2016, 10:56:55 AM »
Hi

Floating / double formatting can be quite complicated to avoid rounding effects but you could try with the following for converting a string input to a float.

Test:
        float fTest = fnFloatStrFloat("1235.0123");                      // test floating point input
        fTest = fnFloatStrFloat("-0.000123");
        fTest = fnFloatStrFloat("-456.123");


// Extract a float input from a string and return its float value
//   
extern float fnFloatStrFloat(CHAR *cNewAdd)
{
    int iNegative = 0;
    unsigned int uiDiv = 1;
    signed long slInteger = (signed long)fnDecStrHex(cNewAdd);           // convert the integer
    float fFraction = 0;
    if ((slInteger == 0) && (*cNewAdd == '-')) {                         // catch case of negative umber with zero integer part
        iNegative = 1;
    }
    while (*cNewAdd != 0) {
        if (*cNewAdd++ == '.') {
            while (*cNewAdd != 0) {
                if (*cNewAdd == '0') {                                   // coun the number of leading zeros in the mantissa
                    cNewAdd++;
                    uiDiv *= 10;
                }
                else {
                    break;
                }
            }
            fFraction = (float)fnDecStrHex(cNewAdd);                     // convert the mantissa to an integer value
            while (*cNewAdd++ != 0) {                                    // count the length of the mantissa
                uiDiv *= 10;
            }
            fFraction /= uiDiv;                                          // convert the mantissa integer to a fraction
            if (iNegative != 0) {                                        // special case of negative number with zero integer part
                fFraction = -fFraction;
                return fFraction;
            }
            break;
        }
    }
    if (slInteger < 0) {
        fFraction -= (float)slInteger;                                   // subtract the integer part to the fraction to obtain the comple floating point value
    }
    else {
        fFraction += (float)slInteger;                                   // add the integer part to the fraction to obtain the comple floating point value
    }
    return fFraction;
}


Regards

Mark

Offline MirceaMurar

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: KDS: 'post-build' failed
« Reply #6 on: July 15, 2016, 06:23:41 PM »
Hello Mark,

thanks for your reply.

I've found a workaround for converting a string into a float.
Since your approach is way much better I will try to implement it in near future.

Just as info...most of the errors thrown by KDS v3 were related to sprintf usage....anyway I found a way to avoid using it.

Best regards,
Mircea.