9 years, 3 months ago.

Port Application to a KL25Z64 MCU

Hi, I have developed an application using the FRDM-KL25Z board, but now I need it to run on the MKL25Z64VLK4, which is the 64k FLASH variant of the default mcu that comes with the freedom board.

Any suggestions on how I can achieve this?

Thanks.

Question relating to:

The FRDM-KL25Z is an ultra-low-cost development platform for Kinetis L Series KL1x (KL14/15) and KL2x (KL24/25) MCUs built on ARM® Cortex™-M0+ processor. Features include easy access to MCU I/O, battery-ready, …

2 Answers

9 years, 3 months ago.

Assuming everything else is the same (RAM mainly), make sure your used flash size is <64k and it will work properly.

The RAM is actually half the size as well (8k), I guess I do need to make changes?

posted by Alexander Agudelo 12 Sep 2015

Yes, RAM is the main issue. First of all, it of course needs to fit in the reduced RAM. (KL25 by default compiles with ARM lib, uARM lib is smaller and might help you if it is a bit too large. Don't ask me how to set that, also depends on which compiler you use. Because I don't know if currently you can do the required changes in the online compiler. For sure the only way which used to work was deleting the .sct file and importing a new one from your PC).

Anyway, I could post what you need to do here, but that was done before, have a look at: https://developer.mbed.org/questions/4669/KL25Z-production-with-less-flash-memory/

This would be great to make as Cookbook page, but the mbed staff has decreed that cookbook is going to be removed for whatever reason makes sense to them.

posted by Erik - 12 Sep 2015

I actually compile my project offline with GCC. So my startup_MKL25Z4.s is a bit different from the one you indicated in your post. Mine has Stack_Size, 0x80 and Heap_Size, 0x80 sections. I'm guessing I just need to change those two to 0x40?

I didn't really see anything in that file to modify the RAM. I found in my MKL25Z4.ld however, the following structure:

MEMORY { VECTORS (rx) : ORIGIN = 0x00000000, LENGTH = 0x00000400 FLASH_PROTECTION (rx) : ORIGIN = 0x00000400, LENGTH = 0x00000010 FLASH (rx) : ORIGIN = 0x00000410, LENGTH = 128K - 0x00000410 RAM (rwx) : ORIGIN = 0x1FFFF0C0, LENGTH = 16K - 0xC0 }

I'm hoping changing some values there would do the trick?

posted by Alexander Agudelo 12 Sep 2015

Not familiar with how GCC handles it, but 0x80 would seem more like an initial size than the actual size. The most important part would be setting the stack pointer which by default is set to the top of the RAM, to the new top of the RAM. It could be that 16k - 0xC0 which needs to be modifief to 8k-0xC0, but i am not sure about it.

posted by Erik - 13 Sep 2015
9 years, 3 months ago.

Couple of problems here. There are three files you need to change in the cmsis>TOOLCHAIN_ARM_STD. The .s file is greyed out, it can be exported and changed but you can't import it back. I have tried this on another target. The others you can do this trick. Must be a recent change, Erik and I did this for the Teensy3.1 port.

The other problem is programming it. You will not be able to use the FRDM board to do this as it looks for exact MCU type, yours is different so nothing gets loaded.

What you could do is develop the program on Mbed and export it to another compiler where it may be possible to change the target, flash and RAM settings. You will then need a Flash programmer, I use a Segger Flasher Portable, cheapest option but still a lot of money unless you are going to program 100's of these.

Otherwise you will need to add this as a separate target platform on Mbed and I really don't think that will happen particularly as any platform on Mbed has to have some form of programming/debug interface.

If at all possible use the Mbed standard KL25Z, its much easy to make you own design board and use the FRDM for the programing interface. I use both the 64pin QFP and 32pin QFN chips.

edit..

Can you squeeze your code onto the KL05 ? this uses uARM so will compile smaller than the KL25, you can add the platform and try.

Not sure, but can you use the FRDM board to program it if you use it as CMSIS DAP debugger? It won't work as drag and drop programmer, but I am not sure if it also does not work when it operates as debugger.

posted by Erik - 12 Sep 2015

We have a custom boot-loader so uploading new programs is not an issue. My only (other) problem is that all programs I compile start at 0x00000000, but the boot-loader requires the application to execute from a specific location: 0x00008000.

Any advice on this?

posted by Alexander Agudelo 12 Sep 2015

Ahh so this is not actually a Mbed related question, pity you did not mention the whole storey form the outset.

Try using KDS or Keil, you can easily set the flash/RAM and change the program start position. I know you can modify Mbed exported project in Keil, not sure about KDS though. Perhaps others may have more info on this. You could also ask questions and search their forums.

Using uTasker bootloader? that has the same flash load offset. If so he has quite a few tutorial videos that are good.

@Erik I have never tried using CMSIS DAP debugger, I have only used the MSD drag and drop programming function. Time vs Money, decide to get the Segger Flasher Portable. Programs every ARM chip, any start position, .BIN or .HEX and can select Flash erase sectors and works fast. You get what you pay for.

posted by Paul Staron 13 Sep 2015

Thanks @Paul,

I’m not sure why you say this is not mbed related? The full project is based on mbed. The only non-mbed bit is the bootloader for which I’m not really asking anything.

I think the questions are quite valid:

  • How to port an mbed application to another MCU, and,
  • How to change the startup location

KDS is not an option, importing an mbed project is not that straightforward and ProcessorExpert generates a huge binary. So I’d prefer to stick to mbed for now.

The bootloader is based on Freescale’s KBOOT.

I'll continue experimenting and report back if any findings.

posted by Alexander Agudelo 14 Sep 2015

Yes please, that would be good if you would report back how you get on Alexander. I have been trying to find a way to do this with the K22F chip. This does have a very usable flash resident MSD type boot capability. But I came unstuck using the existing libraries and compiling on Mbed with that start offset. Its set in the compiler and only the Mbed guys can set this.

I want to utilise the larger 1Mb flash K22F version so I can store static graphics to use on a larger LCD display, programming this using the Segger flasher. But found since the last Mbed update one of the important files that is 'greyed' out could not longer be edited and imported back.

The other problem of course is the programming part. For Mbed to accept a 'new' target platform even if it shares much of the same library functions, it must have a 'drag and drop' programming facility and ideally a CMSIS-DAP debug capability. That clearly requires a secondary interface chip with suitable firmware so others can use the platform without an independent programmer.

I'm hoping that V3.0 may extend the compiler functions making it possible to edit the start up parameters for users to do what we are trying using our own programming facility, but not holding my breath here.

posted by Paul Staron 14 Sep 2015