Teensy LC with Kinetis Design Studio - hex file not working

Status
Not open for further replies.
Hello eveyone,
I am using Kinetis Design studio for developing code for Teensy LC. I am have downloaded the SDK for MKL26Z64xxx4 which is the CPU in Teensy LC. I wrote code for GPIO blink and compiled it. I got a .hex file in the debug folder. I uploaded the hex file via teensyduino software. After that my computer is not recognizing Teensy LC. I uploaded a blink sketch via Arduino IDE and then my computer detected the teensy LC. In short nothing happened when I used the hex file from Kinetis Design studio. The CPU was dead. I have the following questions:

1. Can I upload hex file from Kinetis Design studio on Teensy LC using Teensyduino?
2. How to modify Teensy LC so that it works using the hex file from teensyduino?


Thanks in advance. Looking forward to your replies.
 
I saw where you posted this before - bottom line is using the external SDK bypasses all the PJRC efforts to build the code to make the Teensy work.

The most obvious is the loss of USB - perhaps it can be linked for SDK usage - but there are countless hours of effort by Paul to refine the USB interface to talk through the Teensy hardware.

Not everyone who buys an Intel processor runs Windows or Linux - but having one of those machines and not using a compatible supported toolset puts one at an odd place with respect to those that do. Doubly so if the Intel box is made by Apple.

Paul took perhaps a year on his own building on prior years of the T_3's before it to get the LC to market with usable software to make the hardware sing - same with the T_3.5 and T_3.6 after that.

Using the RAW tools of the SDK is the path Paul started on with nothing, but moved to the Arduino build tool chain with supported C++ compiler things may be very different in the SDK. Maybe there is a simple solution for it to work, but it is a wholly different path . . .
 
Thank you for the reply degraster. I know that it completely bypasses all the efforts made by pjrc. I highly appreciate Paul for all his work making Teensy such easy to use. I know this part is difficult. I know that Paul wrote a bootloader(teensyduino) to upload the hex file over USB. I am stuck at this point figuring out what it takes to upload the hex file to the microcontroller flash and make it working. I am interested in this part a lot. I am also interested in how the hex file is being produced for Teensy. I would be happy if Paul could answer this.
 
Yes I bought Teensy ++2.0 and Teensy LC. They are super easy to use and powerful with all the efforts from pjrc. Sure I reposted this keep it on a different thread. I shall wait for an answer.
 
The trick to wiggling a pin is not just setting the Data Direction Register and the IO State (High/Low). You also have to "get the engine running" ie all of the clock sources configured, all of the subsystems configured properly (such as watchdog timers).

As you know, the basic reference manual for this part is over 1300 pages long. I once missed a footnote on a page that was the key to three months of lost development time.....

The hex file from a Teensy build that blinks the LED is over 11,000 bytes because it contains all of the core startup and tool support code needed to make the Teensy environment so fun to use.

See Paul's response in https://forum.pjrc.com/threads/37859-Why-is-my-Blink-program-taking-11-748-bytes-of-flash-memory

You have not shared your code (and it is probably not actually necessary for you to do so as it is so far outside what we can help you with) but it would be interesting to know how large your hex file actually is... I say this as it gives an idea of how much core support your tool chain gives.

There is no secret to the Teensy build process or the files it uses. They are all on your computer. You just need to figure out how to transfer all the work and effort that Paul has accomplished to properly assemble the pieces from the over 3000 files that the Teensyduino installer adds to the Arduino base install. It adds up to a fantastic tool chain that will take you some effort to replicate and transfer properly into the Kinetis Design studio.

You say "I am stuck at this point figuring out what it takes to upload the hex file to the microcontroller flash and make it working"

My bet is that the upload of the hex file is not your main problem. My guess is that the contents of your hex file may have missed a memory configuration setting, startup vector, cpu clock source, or or or.

All this ease of use stuff is what I'm happy to pay Paul for and simply enjoy the Teensy Tools as they are.
 
Hello eveyone,
I am using Kinetis Design studio for developing code for Teensy LC. I am have downloaded the SDK for MKL26Z64xxx4 which is the CPU in Teensy LC. I wrote code for GPIO blink and compiled it. I got a .hex file in the debug folder. I uploaded the hex file via teensyduino software. After that my computer is not recognizing Teensy LC. I uploaded a blink sketch via Arduino IDE and then my computer detected the teensy LC. In short nothing happened when I used the hex file from Kinetis Design studio. The CPU was dead. I have the following questions:

1. Can I upload hex file from Kinetis Design studio on Teensy LC using Teensyduino?
2. How to modify Teensy LC so that it works using the hex file from teensyduino?


Thanks in advance. Looking forward to your replies.

I guess, I should be able to use KDS to program for Teensy. The only thing you have to do is to configure your PE for Teensy LC and if you wanted to avoid Prog button press for uploading you should must implement the right USB functionality. So answer to your first question is yes. But the 2nd question is wrong. You have to modify your development tools to work with Teensy, and obviously TLC is working with Teensyduino.

BTW, you can use PJRC's core also with KDS, bypassing PE, if you are using makefile based KDS projects.
 
Hello drmartin,
Ah I get it now. I just did the GPIO. I didn't initialize the clock, watchdog timers etc. My hex file is 14 KB. Here's my main.c.


#include "board.h"
#include "pin_mux.h"
#include "clock_config.h"
#include "fsl_gpio.h"
#include "fsl_device_registers.h" //for the memory mapping

/*!
* @brief Application entry point.
*/

void delay(void)
{
volatile uint32_t i = 0;
for (i = 0; i < 800000; ++i)
{
__asm("NOP"); /* delay */
}
}
volatile uint32_t *LED_PORT_CONFIG = ((volatile uint32_t *)0x4004B014);
int main(void) {
/* Init board hardware. */
BOARD_InitPins();
BOARD_BootClockRUN();
BOARD_InitDebugConsole();

/* Add your code here */
const uint32_t LED = 1 << 5;
*LED_PORT_CONFIG = 0x00000144;

//Set the direction
GPIOC->PDDR |= LED; //OUTPUT
//PORTC->PCR[5] = 0x104; //control register

GPIOC->PSOR = LED;

for (;;) { /* Infinite loop to avoid leaving the main function */
__asm("NOP");
/* something to use as a breakpoint stop while looping */
}
}

.............................................................................................................................................................................................................................................
...............................................................................................................................................................................................................................................
I went into the core files and found that main() is calling _init_Teensyduino_internal_() prior to setup() and loop() [Arduino reference]. In file pins_teensy.c line 517 the funtion is defined and the NVIC, clock and timer modules are being initialized. Are these the only regs to be initialized before actually doing anything? Am I missing anything apart from these? I check the thread which you shared. Thanks.
 
Hello WMXZ,
I didn't understand what you said. "The only thing you have to do is to configure your PE for Teensy LC " What is PE? How to configure it? Right now I will be using Teensyduino. I still have to figure out how to write and upload a bootloader on my own. I am good with Teensy USB bootloader for now.
 
I just compiled a fairly simple Blink with USB - the size of the HEX is misleading as it is an overtly readable ascii padded text file.

T_3.6 1KB blink.ino is 24KB Program storage space and 67KB .hex
T_LC 1KB blink.ino is 12.2KB Program storage space and 34KB .hex

So with 14KB .hex there is room for some missing bits.

Of course expecting NO_USB (no USB debug spew and button push to program):
T_LC that same .ino drops to 8.7KB Program storage space and 24KB .hex

Any missing startup code is there in the Teensy install path - right before main() is called. Skip the #ifdef's for USB, etc as desired. Starting with the IDE would be a good way to explore that code.

There are other compatible IDE's that don't bring any foreign tool chains to the build and give access to the evolved years of PJRC open source development - like Visual Micro I might finally try now that I've gotten used to the speed and power of my overclocked i7 that has been in a room by itself as a file server for most of the last 5 years.
 
I still have to figure out how to write and upload a bootloader on my own. I am good with Teensy USB bootloader for now.
You can do that with AVR based Teensies, but not with 3.x or LC. Because on ARM based Teensies, there is a separate bootloader chip there. And in any case, the bootloader is the part that is not open source, so if you'll gonna overwrite the one on AVR, making a backup copy of it might be a good idea. And if you'll brick it so it doesn't boot, you'll need an AVR programmer to unbrick it.

If you can make a .hex that works, you can use the standard Teensy bootloader with the Teensy Loader app and it should work fine.
 
Status
Not open for further replies.
Back
Top