Author Topic: Freescale KL26Z64 (Teensy LC) compiling errors for SerialBoot on IAR 7.4  (Read 8557 times)

Offline Frankde

  • Newbie
  • *
  • Posts: 6
    • View Profile
I am having a number of errors while linking the µTasker 1.4.x Dev.
These are noticed while building as "declared implicitly" and that's a pity
-----Message window----------------------------------------
Linking
Error[Li005]: no definition for "USB_HOST_POWER_ON" [referenced from C:\uTasker 1.4.x Dev\Applications\uTaskerSerialBoot\IAR7_Kinetis\FLASH\Obj\kinetis.o]

Error[Li005]: no definition for "RETAIN_LOADER_MODE" [referenced from C:\uTasker 1.4.x Dev\Applications\uTaskerSerialBoot\IAR7_Kinetis\FLASH\Obj\SDLoader.o]

Error[Li005]: no definition for "DEL_USB_SYMBOL" [referenced from C:\uTasker 1.4.x Dev\Applications\uTaskerSerialBoot\IAR7_Kinetis\FLASH\Obj\usb_application.o]

Error[Li005]: no definition for "SET_USB_SYMBOL" [referenced from C:\uTasker 1.4.x Dev\Applications\uTaskerSerialBoot\IAR7_Kinetis\FLASH\Obj\usb_application.o]

Error[Li005]: no definition for "USB_HOST_POWER_CONFIG" [referenced from C:\uTasker 1.4.x Dev\Applications\uTaskerSerialBoot\IAR7_Kinetis\FLASH\Obj\Loader.o]
Error while running Linker
---------------------------------------------
These can be traced back to SDLoader,  kinetis_USB_Host, usb_application & Loader.

Looks like I need to add a line in the Linker file or disable a function in the config file.
Anyone able to give guidance here?

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: Freescale KL26Z64 (Teensy LC) compiling errors for SerialBoot on IAR 7.4
« Reply #1 on: October 31, 2015, 07:11:24 PM »
Hi

These linker errors are due to missing macros for the TEENSY-LC:

USB_HOST_POWER_ON()
and USB_HOST_POWER_CONFIG() are required by USB host mode in order to enable the USB 5V. Since the Teensy-LC doesn't support USB host mode there is no such macro for it.
The solution is to disable USB-host loading mode since it can't be used with the TEENSY-LC (i.e. comment out USB_MSD_HOST in config.h)

The other missing macros are due to the SD card loader. This is used by the USB-host loader (SD card and memory stick are equivalent once mounted). Once the USB-MSD-host loader is disabled also these will not be required.

This means that by disabling USB-MSD-host loader mode, all issues for the Teensy-LC will be solved.
USB_MSD_LOADER can still be used for USB-MSD-device loading, which is the method most suitable for the Teensy-LC.

Note that the developer's version from 14.9.2015 is configured as default to allow USB-MSD-host to operate on the TWR-K21F120M in the serial loader and the USB-MSD-host option will need to be disabled for other boards that don't support it in their HW (indicated by the macros being missing).

Regards

Mark



Offline Frankde

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Freescale KL26Z64 (Teensy LC) compiling errors for SerialBoot on IAR 7.4
« Reply #2 on: November 01, 2015, 12:00:49 PM »
 :) Thanks Mark. That was line 538 and off it went. A breeze.

Offline Frankde

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Freescale KL26Z64 (Teensy LC) compiling errors for SerialBoot on IAR 7.4
« Reply #3 on: November 01, 2015, 04:55:59 PM »
Subsequently I commented out HID_Loader and KBOOT_HID_Loader as these appeared to confuse windows.
Result was fast blinking board LED and recognition by Windows intact.

Wanting to use Serial loader to change arduino applications on the Teensy_LC, I modified the linker file  KL_64_8.icf as follows (red)
define symbol __ICFEDIT_intvec_start__ = 0x00000000;
/*-Memory Regions-*/
define symbol __ICFEDIT_region_ROM_start__ = 0x00008080;
define symbol __ICFEDIT_region_ROM_end__   = 0x0000FFFF;


My first bet was to change the first line, but that showed no effect.
The assumption is of course that 8080 is the right address.

Then converted hex-files to bin-files (hex2bin v2.1) to drop them on the drive, but that shows no effect. Is that the start address I need to add in while converting?
Binary file start  = 00000000
Records start     = 00000000
Highest address = 00002CA7
Pad Byte           = FF

Also when I remove the board the file dropped to it does not return on reconnection.

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: Freescale KL26Z64 (Teensy LC) compiling errors for SerialBoot on IAR 7.4
« Reply #4 on: November 01, 2015, 05:23:14 PM »
Frank

With the KBOOT HID composite included the PC will need the Kboot *.inf file in order to install the driver.
This is only available if you have installed the KBOOT GUI on the PC, otherwise the USB will not be able to work.
The USB-MSD mode alone doesn't need a driver so removing the USB-HID (and KBOOT) was the fix.

Check out this for details about using Teensy Arduino projects together with the serial loader: http://www.utasker.com/forum/index.php?topic=1869.msg6789#msg6789 (there are also some general details in the appendix to the serial loader's user's manual)

When you build the project, check the HEX file output because you can then see the addresses that it uses (in first line), and verify that it is really 0x8080, after which you can convert it to binary.
Ref. :08808000FCFF0220552E010057
0x8080 is the start offset.
FCFF0220 - converted to big-endian = 0x2002fffc - this is the initial stack ponter value
552E0100 - coverted to big-endian = 0x0001e255 - this is the address of the first instruction to be executed

These are taken from a K64 project (with more RAM) but you can check them for validity since the SP address must be as expected (at least somewhere in the available RAM address range) and the start address must also be as expected (at least in the valid Flash address range).
If they are invalid the serial loader will ignore the content, which explains why you don't see the software if it wasn't correctly prepared.

Regards

Mark



Offline Frankde

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Freescale KL26Z64 (Teensy LC) compiling errors for SerialBoot on IAR 7.4
« Reply #5 on: November 02, 2015, 09:52:00 PM »
Thanks Mark, the page you mention is what I am using, alas for IAR.
Little by little the structure is getting clear, but not transparent yet, I clearly need more flying hours.
Here's the next step:

When I change the linker file (KL_64_8.icf):
define symbol __ICFEDIT_intvec_start__ = 0x00008080;
/*-Memory Regions-*/
define symbol __ICFEDIT_region_ROM_start__ = 0x00000000;
define symbol __ICFEDIT_region_ROM_end__   = 0x0000FFFF;
define symbol __ICFEDIT_region_RAM_start__ = 0x1ffff8c0;
define symbol __ICFEDIT_region_RAM_end__   = 0x200017FF;

I get a change in the project hex file going in the right direction. The change mentioned yesterday stubbornly stays at 000000. I do get a full line more than I bargained for though:
:100400000000000000000000FFFFFFFFBE08FFFF2C
:08808000F0170020C1A100006F


From the look of it I am confusing the flash addresses.
Should I dig deeper there?

Offline Frankde

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Freescale KL26Z64 (Teensy LC) compiling errors for SerialBoot on IAR 7.4
« Reply #6 on: November 05, 2015, 02:52:57 PM »
Yes I should, that memory part is interesting and I ma not only confusing the address, also the project.

USB serial loader is good when it can be recognized by Windows. No change in the linker file required. Can come later, when I need more memory for my project

The linker file described in the tutorial is for my project i.e. the arduino project.
File found in C:\..\arduino-1.6.5-r5\hardware\teensy\avr\cores\teensy3 so I can finally adapt mk20dx128.c and mkl26z64.id as instructed.
FLASH (rx) origin modified to 0x8080 --> gives the right starting address
Watchdog removed .
Vector table in RAM is used --> nothing to add
I want to have the loader installed and next the file applying drag & drop.

To test I use Blink from the tutorial, that is small and coverts to binary (hex2bin v2.1) for 10.076 byte.
After editing the linker file the start address is OK
Loading the blink example makes the teensy disappear for windows and the led is on continuously.

Next step: change the addresses for the flash (IAR mentioned that in the same fashion). Thanks Mark for warning!
SECTIONS
{
    .text : {
        . = 0; -> 0x8080
        KEEP(*(.vectors))
        *(.startup*)
        /* TODO: does linker detect startup overflow onto flashconfig? */
        . = 0x400; -> 0x8480
        KEEP(*(.flashconfig*))


My Blink file has grown to use 42.972 bytes. If true that is tight with the 32 k I have left
And of course the lights go off and teensy goes into reset.

We're getting close, nearly there.