Problem to program a custom board (MK66FN2M0)

Status
Not open for further replies.

ahespel

New member
Hi everyone,

I have some issues to program my custom board with the same family teensy3.6 chip : the MK66FN2M0.

Let's recap my way of thinking :
I used to work a lot with Arduino so I developed some Arduino libraries. I was looking for a bigger microprocessor, in terms of memory flash and cpu speed especially, than my old Atmega2560, which would keep the Arduino compatibility.
Hence, I bought the teensy 3.6. I decided to make my custom board with the MK66F2M0 chip which comes from the same family at the tennsy3.6 chip (the MK66FX1M0) but with 2 mains differences, as far as I know, the size of flash memory (twice bigger than teensy 3.6) and the size of eeprom (no eeprom available with the MK66FN2M0 chip).
While I made the custom board (schematics, routing and fabrication), I still could work on teensy 3.6 to be ready (or almost ready) when the custom board will show up.

Happy to receive my board, I'm feeling dumb to not succeed in programming my chip. According to me, I just have to compile my code with a custom board in Arduino IDE. So, I modify the board.txt file (see enclosureView attachment boards.txt) to fit my custom board and with a preprocessor compilation directive (__MK66FN2M0__), I get rid of all the eeprom stuff (especially teensy3/eeprom.c) to avoid any conflict.

Once the hex file generated, I program my chip with a segger J-link probe but nothing happens. I tried with a simple blinky program but the problem still remains. With the segger probe, I looked at the register memory and the clock gate to Port Module was disabled which means the gpio has not been configured.
To exclude any design problem on my custom board, I tried with MCUExpresso IDE and the SDk provided and I manage to blink the LED.

I guess the problem comes from a bad configuration which may halt the processor but i do not succeed in finding the problem.
I hope I have made this sufficiently clear and someone can help me.

I'm using windows 7 and Arduino 1.6.5

Thanks in advance and have a great day !
 
You know Teensy boards uses a companion chip to program the main chip?
PJRC sells this companion chip for custom boards like yours. It's not a blank chip: contains a special firmware (IP of PJRC), needed to program a blank MK66FX1M0. Not sure it would work with a MK66F2M0, you should ask them.
 
The MK66FN2M0 needs different linking instructions in the corresponding ld file (different flash memory block addressing). As long as you do not use one of the supported MCUs by PJRC, you won't find these included in the Teensyduino core files and builder.
 
Thanks XFer for your quick response.

I'm aware of that but, maybe I'm wrong, I thought, in the teensy, 3.6 the MKL02 is only used as bootloader. So I can replace this chip by my segger probe. Of course, this only works if the companion chip does not modify the hex file generated by Arduino.
 
Not sure it would work with a MK66F2M0, you should ask them.

I can tell you the bootloader will NOT work with the MK66FN2M0 chip.

Regarding porting all the code we publish to this chip, most of it should work but "the devil is in the details". We don't support the MK66FN2M0 chip. You're on your own!
 
The MK66FN2M0 needs different linking instructions in the corresponding ld file (different flash memory block addressing). As long as you do not use one of the supported MCUs by PJRC, you won't find these included in the Teensyduino core files and builder.

I also added the mk66fn2m0.ld. Since this chip is the same family than the teensy one, I naively changed only the Flash length in Memory.
Code:
MEMORY
{
	FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 2048K
	RAM  (rwx) : ORIGIN = 0x1FFF0000, LENGTH = 256K
}

So do you mean I have to modify the SECTIONS part as well ?
Thanks for your help.
 
You'd have to look up the needed details in the processor's reference manual. I haven't dived into the memory organization details of that uP and I won't as it doesn't have any nutritional value for me.

As Paul said:
We don't support the MK66FN2M0 chip. You're on your own!
 
Of course, this only works if the companion chip does not modify the hex file generated by Arduino.

I can tell you the PJRC bootloader does not modify your HEX file. But there is special handling of the FOPT & FSEC bytes.

Earlier versions on Teensy 3.0 & 3.1 (using the MINI54 chip) would disregard whatever your HEX file specified for the flash config bytes.

Teensy 3.6 instead preprograms FOPT to 0xF9 and FSEC to 0xDE before your HEX file is received. Since some bits are already written to zeros in those 2 bytes, they'll remain zero even if your HEX file wants them to be 1s. This is done so you can't (easily) brick your board.

We don't do anything like try to lock you into only buying hardware from PJRC. The special handling on those 2 bytes is only to prevent doing something like disabling mass erase, which of course means your board can never be reprogrammed (unless your code has some provision to unlock or erase itself).
 
Status
Not open for further replies.
Back
Top