Yesterday was my ‘lucky day’: My Kinetis-L Freedom board arrived :-). This board is really nice and features the KL25Z from the recently announced Kinetis L Family. And guess what is the first thing I want to flash on that processor? Yep: some FreeRTOS tasks. But to get there, a few important things have to be sorted out:
- Get the board up and running
- Get a compiler and Eclipse panels for the ARM Cortex-M0+
- Extend the Processor Expert FreeRTOS component to work with GCC and Cortex-M4 and M0+
- Test, Debug and Celebrate 🙂
The Freedom Board
The board can be ordered from Farnell for only about 10 Euro.
Note: I received a board directly from Freescale. The FRDM-KL25Z will be available publicly from end Sept. My Farnell/Element14 order shows 25. Sept. 2012.
The board has a nice and small form factor of 81 mm x 54 mm which makes it ideal for a lot of applications.
I love the headers as they will allow me to plug in other boards. The board is aimed to use Arduino shields. What shields are compatible is not clear yet, but the connector is able to provide 5V, while using 3.3V signals.
There are two mini USB connectors on the board: one is the target USB connector (the KL25Z implements USB), the other is the on-board debug connector. Yes, like the Tower board the Freedom board has on-board debug solution on it. Connecting the board using the debug connector automatically installs the drivers.
The debug connection features a bootloader similar to the Processor Expert USB Bootloader component. So with it is possible to program new firmware/software with simple copy or drag&drop of a file. Really nice, and looking forward to explore this more in the future.
Freescale ARM Cortex-M0+
The microcontroller on the board is a Kinetis KL25Z128 which is an ARM Cortex-M0+.

ARM Cortex-M0+
The instruction set is a subset of the Cortex-M4, while compatible with the Cortex-M0. The Cortex-M0+ is a very energy efficient microcontroller as demonstrated by Freescale at FTF 2012.
GCC and Eclipse Panels
The question is: what tool chain to use for Cortex-M0+? The good news is that there is a GCC maintained by ARM available both for Cortex-M0+ and Cortex-M4. Additionally, there are ARM GCC Eclipse panels available too. With this, it is not too hard to have a working Eclipse environment.
FreeRTOS Processor Expert Component
Next task was to make the Processor Expert component to work with GCC. This mainly means to change the port so it works with the GCC assembly syntax. For this the port.c of the FreeRTOS distribution had to be changed and extended. As I had a FreeRTOS port for CodeWarrior and Kinetis K-Family working, I was testing it first with a Cortex-M4 (Kinetis K60 Tower board). Below is an extract of the code which deals both with M4 and M0+:
__attribute__ ((naked)) void vPortSVCHandler(void) { #if FREERTOS_CPU_CORTEX_M==4 /* Cortex M4 */ __asm volatile ( " ldr r3, pxCurrentTCBConst2 \n" /* Restore the context. */ " ldr r1, [r3] \n" /* Use pxCurrentTCBConst to get the pxCurrentTCB address. */ " ldr r0, [r1] \n" /* The first item in pxCurrentTCB is the task top of stack. */ /* pop the core registers */ " ldmia r0!, {r4-r11} \n" " msr psp, r0 \n" " mov r0, #0 \n" " msr basepri, r0 \n" " orr r14, r14, #13 \n" " bx r14 \n" " \n" " .align 2 \n" "pxCurrentTCBConst2: .word pxCurrentTCB \n" ); #else /* Cortex M0+ */ __asm volatile ( " ldr r3, pxCurrentTCBConst2 \n" /* Restore the context. */ " ldr r1, [r3] \n" /* Use pxCurrentTCBConst to get the pxCurrentTCB address. */ " ldr r0, [r1] \n" /* The first item in pxCurrentTCB is the task top of stack. */ " add r0, r0, #16 \n" /* Move to the high registers. */ " ldmia r0!, {r4-r7} \n" /* Pop the high registers. */ " mov r8, r4 \n" " mov r9, r5 \n" " mov r10, r6 \n" " mov r11, r7 \n" " \n" " msr psp, r0 \n" /* Remember the new top of stack for the task. */ " \n" " sub r0, r0, #32 \n" /* Go back for the low registers that are not automatically restored. */ " ldmia r0!, {r4-r7} \n" /* Pop low registers. */ " mov r1, r14 \n" /* OR R14 with 0x0d. */ " movs r0, #0x0d \n" " orr r1, r0 \n" " bx r1 \n" " \n" ".align 2 \n" "pxCurrentTCBConst2: .word pxCurrentTCB \n" ); #endif }
My First Freedom Application
After a few iterations, my FreeRTOS Processor Expert component worked with all the previous cores and compilers, plus with GCC for Cortex-M4 and Cortex-M0+.
The Freedom board has a RGB LED on that board, so my first application was to run 3 task, each toggling one color of the LED. For this I added 3 LED components to my project:
Source code of the demo application where APP_RUN() is called from main():
/* * Application.c * Author: Erich Styger */ #include "Application.h" #include "LED1.h" #include "LED2.h" #include "LED3.h" #include "FRTOS1.h" #include "WAIT1.h" static portTASK_FUNCTION(Task1, pvParameters) { (void)pvParameters; /* parameter not used */ for(;;) { LED1_Neg(); FRTOS1_vTaskDelay(1000/portTICK_RATE_MS); } } static portTASK_FUNCTION(Task2, pvParameters) { (void)pvParameters; /* parameter not used */ for(;;) { LED2_Neg(); FRTOS1_vTaskDelay(1050/portTICK_RATE_MS); } } static portTASK_FUNCTION(Task3, pvParameters) { (void)pvParameters; /* parameter not used */ for(;;) { LED3_Neg(); FRTOS1_vTaskDelay(2080/portTICK_RATE_MS); } } void APP_Run(void) { uint16_t i; for(i=0;i<4;i++) { LED1_Neg(); LED2_Neg(); LED3_Neg(); WAIT1_Waitms(250); } if (FRTOS1_xTaskCreate( Task1, /* pointer to the task */ (signed portCHAR *)"Task1", /* task name for kernel awareness debugging */ configMINIMAL_STACK_SIZE, /* task stack size */ (void*)NULL, /* optional task startup argument */ tskIDLE_PRIORITY, /* initial priority */ (xTaskHandle*)NULL /* optional task handle to create */ ) != pdPASS) { /*lint -e527 */ for(;;){}; /* error! probably out of memory */ /*lint +e527 */ } if (FRTOS1_xTaskCreate( Task2, /* pointer to the task */ (signed portCHAR *)"Task2", /* task name for kernel awareness debugging */ configMINIMAL_STACK_SIZE, /* task stack size */ (void*)NULL, /* optional task startup argument */ tskIDLE_PRIORITY, /* initial priority */ (xTaskHandle*)NULL /* optional task handle to create */ ) != pdPASS) { /*lint -e527 */ for(;;){}; /* error! probably out of memory */ /*lint +e527 */ } if (FRTOS1_xTaskCreate( Task3, /* pointer to the task */ (signed portCHAR *)"Task3", /* task name for kernel awareness debugging */ configMINIMAL_STACK_SIZE, /* task stack size */ (void*)NULL, /* optional task startup argument */ tskIDLE_PRIORITY, /* initial priority */ (xTaskHandle*)NULL /* optional task handle to create */ ) != pdPASS) { /*lint -e527 */ for(;;){}; /* error! probably out of memory */ /*lint +e527 */ } FRTOS1_vTaskStartScheduler(); }
This creates a nice colorful changing ambient light: brightness with Freedom :-):
Happy Freedom 🙂
PS: the updated Processor Expert component for FreeRTOS with added GCC and Cortex-M0+ support is available here.
Erich,
Wow! I can’t wait for my board to come. I ordered from Newark as soon as I heard about the board (from your blog). But it’s back-ordered for at least a month.
Bill
LikeLike
Bill,
I *love* that board! My new lecture/semester starts mid of September: Hopefully I can get my boards from Farnell soon enough. My plan is that students should get that board and can keep it. I’m already using the Tower boards for my classes. The Freedom board will be a nice extension.
I’m working right now on porting the FatFS Processor Expert component to Kinetis and GCC, but I want to look into supporting all the other components on the Freedom board with Processor Expert. Will be for sure weekend(s) and nights full of fun (and work). Will see how much I can accomplish. We have really strong coffee 🙂
Erich
LikeLike
Yes, you WERE lucky. I’ve just ordered from Element14 in Australia and have been given an October delivery. Have to check back here when they turn up to see how far you’ve got. As I use a Linux hosted development environment, I can’t use MQX with CodeWarrior, as this only works with the Windows-delivered package, rather than any Eclipse-based CodeWarrior. So FreeRTOS is a must (and for other reasons.) Would also like to get it going on the QwikStik.
LikeLike
My experience with Farnell/Element14 is that they collect orders, and once it reaches a certain number, they produce a batch. So it could be that the boards get delivered earlier (at least I had that experience in the past with Farnell). And I have FreeRTOS running as well on the QwikStik. An article on this has been drafted, but the Freedom Board changed all my plans 🙂
LikeLike
Nice work. I would be really grateful if you could post your code, or at least a link to this page if the link will remain here, on the FreeRTOS Interactive! site.
Regards,
Richard (http://www.FreeRTOS.org)
LikeLike
Hi Richard,
thanks for the reminder. This was on the list, but too late yesterday night to do. Now it is published as well in the FreeRTOS forum.
Regards,
Erich
LikeLike
Very cool post. Thanks Erich!
It looks like you were lucky enough to receive one of the prototype boards. I have a friend “in the know” on this project and he indicated that all the devices shown with a cross-section fill in the block diagram will not be populated on the production run. This matches up with the feature list provided over on e14’s preorder site too, so may actually be true. 😉 Also, I’ve heard the production boards will be a different color.
I look forward to trying out FreeRTOS and ProcessorExpert when I get my KL25Z Freedom board. Looks like that is going to happen for most of us at the end of Sept (which likely means October the way these things go).
-ZP
LikeLike
Thanks 🙂 That would mean that the debug headers will not be populated. They are 1 mm ones, but not much needed as there is the on-board OpenSDA debugging solution. Having the I/O headers not populated is not a big problem for me: anyway I like to use my own headers so I can choose the one I want and need. My element14 order still says 25th of Sept. Keeping fingers crossed for my other boards I have per-ordered, plus of course for everyone else who has placed an order.
LikeLike
From the not-very-clear photograph on the Element14 site, those look like little Samtec headers FTSH-105-01-L-DV, Element14 part number 1667759. There is an unpopulated programming header on the Kwikstik (to use the Kwikstik as a programmer, that is) that uses these – easy enough to fit. If it is those, the mating cable is Element14 part number 1667659, in case that’s of use to anyone. I have a packet of them on my desk in front of me 🙂
LikeLike
Yes, it is such a little 1.27 mm header. But the board I have is using a through-hole footprint (not an SMD one as on the Quikstick).
LikeLike
Pingback: There is a Time and Date for both Worlds | MCU on Eclipse
A nice lady from Newark / Element 14 called me on the phone the other day. Wanted to let me know about all the cool things from Freescale and specifically this Freedom demo board. I told her I had already ordered one. She was amazed. I’ve bought from Newark before, (not necessarily my go-to supplier), so I guess they had my phone number.
/Bill
LikeLike
Pingback: Software and Hardware Breakpoints | MCU on Eclipse
Pingback: Debugger Shell: Test Automation | MCU on Eclipse
Pingback: A Shell for the Freedom KL25Z Board | MCU on Eclipse
Pingback: Tutorial: Enlightning the Freedom KL25Z Board | MCU on Eclipse
Pingback: Software and Hardware Breakpoints « The Embedded Beat: Freescale Blog Community
Pingback: Code Size Information with gcc for ARM/Kinetis | MCU on Eclipse
I just checked my Newark order, since it’s Sept 24, which was the expected ship date.
It now says 04 Oct 2012.
LikeLike
Sounds like they were being a bit over-optimistic. I ordered a couple of days after Erich did the original post – Element14 Australia have been saying mid-October all along.
Had a phone call the other day asking if i wanted to change parts – what I ordered on was a prototype part number, they were offering to upgrade to a production part number, about $3 cheaper, too. After having had to modify my Beagle Bone to fix a hardware bug, sufficient to say, I went for the upgrade 🙂
LikeLike
I received an email from Newark a week or two ago stating the part nr. had gone obsolete. But they never mentioned a replacement for the one I had pre-ordered. The order status still shows it with the Z suffix. I assume they won’t be making/shipping the prototype.
LikeLike
Yes, I was told from several sides that they will ship the black board (as shown on the element14/Farnell side), and not the white prototype board I have. The difference (apart of the color) will be that the JTAG headers and the headers on the side of the board will not be populated. The FAQ on http://www.element14.com/community/docs/DOC-49183/l/freedom-platform-faq states that I should get the headers, as I pre-ordered the boards (which would be great). There is as well a preview of the board/packaging available on http://www.element14.com/community/groups/preview-roadtest.
LikeLike
Interesting, as I have not received such an offer. I just called Element14 about very long ‘in progress’ state of my order, and I was told that the material is ‘in transit’, so between the manufacturer and the inventory. “You should have it in a week or so”. Well, keeping fingers crossed, and looking forward what (and when) I will get it.
LikeLike
Just for reference, on the 21st of July I ordered 2115294, at $14.17 AUD. This part number is no longer active/orderable. I was contacted by Element14 on the 17th of September and offered 2191861 – the new active part – at $10.72. Newer AND cheaper – just hope they don’t take too long 🙂
LikeLike
My order status has no date any for at least the past two weeks, and always shows ‘in progress’. I need to call Farnell/Element14 today to find out the state.
LikeLike
Overnight an email came in from Newark. With a UPS tracking number. The board was shipped (from South Carolina USA) and should be tomorrow (26 Sept).
$12.95 for the board, $6.36 for shipping!, and $0.78 sales tax.
LikeLike
At least it is on the way and you have something to play with :-).
LikeLike
It seems at least in US, “shipping & handling” is the new way to make money. I get packages from Thailand mailed here for less.
LikeLike
Mine just arrived. I’ll post some pictures tonight.
They didn’t waste any money on packing on this one.
The box and PCB are both marked FRDM-KL25Z. The PCB is black. The headers came loose in a plastic bag. Is this the pre-production verision?
LikeLike
Good timing! I just returned from a seminar and a Freedom Box in my hands :-). See https://mcuoneclipse.wordpress.com/2012/09/26/a-seminar-and-freedom-with-it/. From what you describe this is the production board for the ones who have preordered it.
LikeLike
I just came back from a Freescale Seminar with a Freedom board in my hand :-). See https://mcuoneclipse.wordpress.com/2012/09/26/a-seminar-and-freedom-with-it/. From your description you received a production board from the pre-order lot.
LikeLike
Pingback: CodeWarrior for MCU10.3 beta is now available | MCU on Eclipse
Pingback: S-Record, Intel Hex and Binary Files | MCU on Eclipse
I received a black board today. The headers are not soldered on and some are missing. Looks like the serial flash chip is missing. Overall, a little bit of bait and switch going on here, although to their credit, Element14 did ask if I still wanted it.
LikeLike
I have not received mine, but yes, I noticed this too when I got a board at a seminar yesterday, see https://mcuoneclipse.wordpress.com/2012/09/26/a-seminar-and-freedom-with-it/
LikeLike
If Freescale is going to succeed with this, they need to standardize on one IDE and provide a lot of support routines to make thing easy. What will be the dominant IDE – CodeWarrior 10.3?
LikeLike
I think users will decide, but everything converges at the eclipse based CodeWarrior at least for me. I wish the S12 would be in Eclipse as well, but maybe in 10.4?
LikeLike
thak u so much , yes i do it in linux shell (DOS good joke :D)
i try it
LikeLike
Pingback: Tutorial: Freedom with FreeRTOS and Kinetis-L | MCU on Eclipse
Pingback: Tutorial: Touching the Freedom KL25Z Board | MCU on Eclipse
Pingback: Processor Expert, gcc C++ and Kinetis-L and MQXLite | MCU on Eclipse
Pingback: A Library with ARM gcc and Eclipse | MCU on Eclipse
Pingback: Removal of Processor Expert for a Project | MCU on Eclipse
Pingback: Unsecuring the KL25Z Freedom Board | MCU on Eclipse
Pingback: Using the 8 MHz Crystal on the FRDM-KL25Z Freedom Board | MCU on Eclipse
Pingback: Defining Variables at Absolute Addresses with gcc | MCU on Eclipse
Pingback: How (not) to Secure my Microcontroller | MCU on Eclipse
Pingback: JTAG/SWD Debugging with the FRDM-KL25Z Board | MCU on Eclipse
Pingback: Optimizing the Kinetis gcc Startup | MCU on Eclipse
Pingback: Tutorial: Bits and Pins with Kinetis and the FRDM-KL25Z Board | MCU on Eclipse
Pingback: Debugging Hard Faults on ARM Cortex-M | MCU on Eclipse
Pingback: ARM Cortex-M0+ Interrupts and FreeRTOS | MCU on Eclipse
Pingback: KL25Z and I2C: Missing Repeated Start Condition | MCU on Eclipse
Pingback: Zero Cost 84×48 Graphical LCD for the Freedom Board | MCU on Eclipse
Pingback: HD44780 2×16 Character Display for Kinetis and Freedom Board | MCU on Eclipse
Pingback: PWM and Shell for a LED | MCU on Eclipse
Pingback: Tutorial: Ultrasonic Ranging with the Freedom Board | MCU on Eclipse
Pingback: The Freedom Zumo Robot | MCU on Eclipse
Pingback: Tutorial: IAR + FreeRTOS + Freedom Board | MCU on Eclipse
Pingback: USB MSD Host for the Freedom Board | MCU on Eclipse
Pingback: A new Freedom Board: FRDM-K20D50M with ARM Cortex M4 | MCU on Eclipse
Pingback: FRDM-KL25Z RevE Board arrived | MCU on Eclipse
Hi there, thanks for the job.
I have a FRDM-KL25Z board and I am using CodeWarrior for MCU v10.3. I followed all the instructions step by step, however I somehow cannot get the result as you had. I’m also having the same problem for the tutorial you published in this link: https://mcuoneclipse.com/2012/09/29/tutorial-freedom-with-freertos-and-kinetis-l/
The exact problem is, despite there is no build or run problems and/or warnings, I do not see the light or any progress. For this code, the first loop in APP_Run() which negates three LEDs and waits for 250 ms 4 times is runs and the LEDs turn off in the rest. That makes me think “Tasks are created, but do not run, schedule and get in a cycle.” But I am not sure.
I will be glad if you help it. It is important for my current internship by the way 🙂
LikeLike
Hello Caner,
hard to guess what your problem is. I recommend that you set a breakpoint in one of the tasks: if it stops there, then tasks have been created and are running.
Maybe you can try my project on GitHub (https://github.com/ErichStyger/mcuoneclipse/tree/master/Examples) in case you have misconfigured something. That way you should have a working example. Otherwise send me your project to my email listed on the About page of this blog and I’ll have a look.
I hope this helps.
LikeLike
Hi Caner,
It’s been so long time and wonder if you’ve got it work already. If not, hope the following would be helpful because I experienced the same problem.
I initially got it to work by increasing the Memory=>Total Heap Size to 8192. The default was 2048.
Then I fine tuned Scheduler=>Minimal Stack Size to 24, after which Memory=>Total Heap Size could be set to 640 to work.
LikeLike
Pingback: Introdução à KL25Z – CodeWarrior, Processor Expert e interrupções periódicas | void Hardwarizando( ) {
Hi
Is something wrong with official freertos port for cortex M0+ (what I suppose is port for Cortex M0, I look in to freeertos verison 9.0.0)? (I asked becouse you do not use it I suppose)
LikeLike
Hi Greg,
nothing wrong with that. FreeRTOS 9.0.0 includes not only M0+, but as well ports for all the other supported architectures.
The port I maintain has the following differences (from top of my head):
– Processor Expert intergration
– supports S08, S12, ColdFire V1/V2, DSC, ARM M0+ and M4/M7 ports
– extended tickless idle mode with extra decision hooks
– Keil, IAR, CW and GNU support
– additional debugger helpers (OpenOCD/CMSIS-DAP)
– intergrates a few extra fixes which will be in a release post v9.0.0
– conditional heap memory usage
– intergration with Segger RTT and Percepio Tracealizer
– command line shell support with no-buffer-overflow string functions
You certainly can use the normal 9.0.0 port too.
LikeLike
well, a lot of nice features!
Is there a “single” page describing extra features ? 🙂
LikeLike
Hi Greg,
I’m affraid that there is no such single page, and have not advertised it much. There is an article about tickless idle mode (https://mcuoneclipse.com/2013/07/06/low-power-with-freertos-tickless-idle-mode/).
There is a tag ‘FreeRTOS’ you can use for posts/updates about FreeRTOS: https://mcuoneclipse.com/tag/freertos/
I hope this helps,
Erich
LikeLike
Pingback: Black Magic Open Source Debug Probe for ARM with Eclipse and GDB | MCU on Eclipse