June 25, 2013

MBED and other freedom boards

This is just a small update about my activity lately. I have been busy with mbed and porting new target into it. I decided to port at least one more freedom board. First choice was a board FRDM-KL05Z.

I started few days ago, the learning curve is quite fast in the beginning. I'll try to summarize my findings here in another post. The process is still ongoing, because I am not certain if I ported everything correctly, therefore I have to run all tests which are available in mbed to be certain that the target it's ready to be published.

Does any of you want any other freedom board to be part of mbed? Or do you have any problems with freedom boards? It's quite astonishing platform, but still seems to be fresh new, not much projects have been on the internet, or at least I have not searched thoroughly :-)

June 15, 2013

Kinetis L header files

I needed CMSIS header file for the Freedom board FRDM-KL05Z. I have spent at least half hour searching. Once I found it, I would like to share where you can find other headers. If you know any place where are all those cmsis headers available, leave a comment.
I started with KEIL webpage, there are published many header files for kinetis K or kinetis L. But no luck with KL05. Therefore I kept digging, until I found it in the sample code for KL25 (really? KL25 demo code contains other MCU header files).

Kinetis L Sample Code (KL25) [www.freescale.com]
This package is in the revision 6 at the moment. It contains the following CMSIS header files
  • MKL04
  • MKL05
  • MKL14
  • MKL15
  • MKL24
  • MKL25

CMSIS KL26 header file [www.keil.com]
There are more headers, just filter a search on google.

Once I find all possible CMSIS headers for Kinetis L, I'll publish them on github.

June 9, 2013

Kinetis K GCC startup

I have pushed "lightweight" gcc demo to my github repository. A generated CodeWarrior project for Kinetis K with GCC compiler contains a lot of "bloat" in my opinion therefore I decided to write trivial startup without including any libraries (only stdin included for C99 types). C++ support is not present, neither RAM target.

It contains a GPIO demo for the TWRK60N512 at the moment. The demo instantly toogles LED1 on the tower board and LED2 toogles only when the button SW1 is pressed.

The demo contains following files:
  • common/common.h - including purpose
  • cpu/headers/derivative.h - include cpu specific header
  • cpu/headers/MK60DZ10.h - freescale's header file
  • cpu/startup_k60.c - vectors plus reset handler
  • cpu/system_k60.c - system init function which inicializes CPU (clocks - 96MHz). This needs to be edited to reflect desired cpu clock freq
  • cpu/system_k60.h
  • k60n512_flash.ld - GNU linker for K60
  • main.h
  • main.c
  • Makefile
As could be seen, there are no drivers included. The demo itself only contains necessary files to initialize CPU and jump to the main function.

This example could be used with the tutorial which I wrote previously, openOCD with the kinetis K60. I used it as the test project.

Kinetis Kxx gcc startup on github : GPIO gcc Kinetis K (K60) [www.github.com/0xc0170/]

Update1: I added K20D72M board

June 2, 2013

GCC ARM Embedded + Eclipse on Kinetis with JLink

I have been writing my own start-up and a linker command file for K60 Tower board. Unfortunately, I am still having an unidentified problem with OSJTAG, I  had decided to use jlink with eclipse. I don't use yagarto tool chain, decided to go with GCC ARM embedded.
 There's been many resources on the internet, I'll post which helped me to set it correctly.

Getting Started with the ARM GCC Compiler on Windows PART 1 [thehackerworkshop.com]
Guide how to set eclipse development (GCC ARM, make, eclipse). This guide (Part 1 plus part 2) is more detailed than the original one published on emb4fun.

You can skip few steps in PART 2, right to the Step 5 if you are not using the ST discovery board. This is the most important one, once you set everything, add files, you should be able to compile and link your project files.

This is a highlight what you should look for:
  • C/C++ Build - External builder , build command - make (or set PATH correctly)
  • C/C++ Build - Discovery options - set arm-none-eabi-
  • In linker options inside Tool Settings - there's a flag where you type a path to a linker command file (an example : -T ./../Sources/PK60N512_flash.ld)
  • In compiler options inside Tool Settings - there's other flags option where you type at least these two flags -mcpu=cortex-m4 -mthumb (same should apply for assembler flags)

The last step before debugging, is to set gdb commands inside a created debug configuration (click 2x on the GDB hardware debugging to create a new one). This are taken from the example shared on yagarto webpage, targeted for K40. They are valid for jlink.

These are initialization commands:
target remote localhost:2331
monitor flash device = MK60DN512xxx10
monitor flash download = 1
monitor flash breakpoints = 1
monitor clrbp
monitor endian little
monitor speed 1000
monitor reset
monitor sleep 100
monitor speed auto
monitor writeu32 0xE000ED08 = 0x00000000

These are run commands:
monitor reg r13 = (0x00000000)
monitor reg pc = (0x00000004)
break main
continue

I did not want to repeat what you can find online, but if there's anything unclear, not able to debug your application using jlink on any Tower from Kinetis line, let me know and I can expand this into a small tutorial ;)

I am planning to publish a small gcc application for some tower boards, or perhaps all, depends on how much time I'll have these days ;) Because when you look into code what CodeWarrior generates with gcc, you marvel how much lines that code contains, most of it are unnecessary.

Update June 9th: a demo app for TWRK60N512 is published.