code size hello world for KL03

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

code size hello world for KL03

1,499 Views
simonefantuzzi
Contributor II

Hello.

We are developing some code for a small project using Kinetis instead of HCS08 microcontrollers.

We are using a Freedom with a KL03 micro Kinetis (frdm-kl03z). By compiling the demo "hello world" I found this code size:

 

arm-none-eabi-size --format=berkeley "hello_world_frdmkl03z48m.elf"

   text       data        bss        dec        hex    filename

  10500        116       1404      12020       2ef4    hello_world_frdmkl03z48m.elf

 

Using KDS with gcc compiler.

 

It seems to me a lot of memory for a simple project like that. Also if I delete everything leaving only hardware_init(); instruction,  I have more than 6kbyte of text flash.

Do you have an idea how to reduce library impact on code?

How can we optimize it? (I try to change optimization in toolchain settings but nothing changes).

 

We absolutely need to stay far under 16k flash for an application using SPI UART and flash read/write.

 

Thanks and best regards

Labels (1)
0 Kudos
Reply
5 Replies

975 Views
mjbcswitzerland
Specialist V

Hi Simone

I have attached a FRDM-KL03Z "hello world" project built using the uTasker project (19'600 Baud - due to large capacitor on Rx input - echos rx characters).

This is including an OS running and the LPUART operates with DMA. The size if 5.3k (Built with KDS and GCC).

text  data   bss   dec   hex    filename
4604     2   262  4868  1304    uTaskerV1.4.elf

With dynamic low power mode operation enabled it requires 5.6k.

With Flash parameter support (with read, write, delete flash routines) it requires 6.7k.

If you need SPI UARTs the project includes support for the sc16IS7xx (up to 4 additonal UARTs).

I think that you need to avoid library routines to ensure that you have smallest code size.

Regards

Mark

Kinetis: µTasker Kinetis support

KL03: µTasker FRDM-KL03Z support

For the complete "out-of-the-box" Kinetis experience and faster time to market

975 Views
simonefantuzzi
Contributor II

Hello Mark,

thank for your quick and useful answer. Size you gave, encourage me to give a deeper try.

I see your attachement and I need just to start with source code to check how to optimize.

I have just some trouble with utasker in my project. I downloaded and imported uTaskerKinetisV1.4.7.zip

Then I needed to compile and run it on my freedom FRDM-KL03 but I cannot find the  correct configurations. I saw on website µTasker FRDM-KL03Z support but I can't complete operations to have a "hello world" prj.

BTW the define FRDM_KL03Z is not present in the config.h and neither I can't find linker script KL_32_2.ld .

I tried to mange it with "${workspace_loc:/${ProjName}/Applications/uTaskerV1.4/GNU_Kinetis/KL_32_4.ld}"  but I cannot download correctly the application on the board.

What I'm wrong or where can I start from?

Thank again

Best Regards

0 Kudos
Reply

975 Views
mjbcswitzerland
Specialist V

Hi Simone

The V1.4.7 project doesn't include support for the KL03.

Updated packages are at µTasker Kinetis Developer's Page (please check your personal mail box for instructions).

The version from 3.3.2015 is pre-configured for the FRDM-KL03Z so will build with KDS without needing any adjustments. Don't panic when the file is about 18k in size because it has a lot of features enabled as can be seen on the UART menu. If you remove the define USE_MAINTENANCE in config.h it will already remove all of the menu interface (and its string consts) and become a lot smaller.

You didn't confirm whether you need SPI UARTs but it is possible to add one or two SC16IS7xx to SPI0 (see define NUMBER_EXTERNAL_SERIAL which can be set to 2 or 4) to increase the KL03's UARTs from one LPUART to 3 or 5 in total, including the SPI based ones (code size +1.5k)

Regards

Mark

Kinetis: µTasker Kinetis support

KL03: µTasker FRDM-KL03Z support

For the complete "out-of-the-box" Kinetis experience and faster time to market

975 Views
simonefantuzzi
Contributor II

Hi Mark,

thank again. It's all very useful and it worked on KDS really immediately.

It seems also that memory size could be fitted on the 16k micro. But I need to complete my project.

I will enable SPI but what I need will be a specific protocol (for an external device) and not the UART-SPI.

Others needs we'll have are analog input and flash read/write for parameters (1k or more).

About flash i saw in ustasker config.h that "due to restricted flash size in this device flash is used only for program code". I was wondering if this can be a problem.

Now I have to decide if use all utasker system (with all benefits but also drawbacks of a more complex structure) or start from beginning with an easy-way setup ( I remember that I was used to program simpler HCS08 uC).

Best regards

0 Kudos
Reply

975 Views
mjbcswitzerland
Specialist V

Hi Simone

There is no problem in using the uParameterSystem (it can be used on any number of flash sectors and either use a single block or a swap block, which ensures no potential loss of parameters in case there is a power cycle during saves). The reason why the flash functions are disabled by default for small parts is that they add the parameter blocks and also a small file system area which of course takes away space that the application could use. So that as much can be put into the application as possible (the flash functions are not very exciting for people preferring to see other stuff) it is simply disabled. If you need flash operations you just need to enable it and also dimension the sizes of the areas to be used (and respect that this will take some potential code space away).

You will find SPI solutions for several SPI Flash parts as well as the SPI UARTs and the nRF24L01+ (also for SPI connected Ethernet controller) and these can be easily adapted for other devices.

There is an ADC interface included (see also links below).

Don't forget that the complete project can also be simulated (all peripherals, including interrupt and DMA operations), developed and debugged in (approx.) real time with Visual Studio and I don't think that you will find the structure more complex once you have used it for a short time, since it allows code to be written and developed more modularly due to its OS. The elements have been developed and refined over several years of industrial usage so when developing new drivers etc. from scratch you will need to consider the amount of work required before they reach the required level of maturity that can only be guaranteed after adequate periods of intensive test and improvements. Most operation is well documented (many specific documents and application notes) and in case of diffiulties there is immediate support available to guide through solving them.

Finally, if you later use other Kinetis parts from the KE, KL or K families the project can be used there without needing to port code (the HAL adapts itself automatically to any part, assuming the peripherals are available) and even if you need to move from KDS to IAR or Green Hills etc. the project will still work directly.

Regards

Mark

Kinetis: µTasker Kinetis support

KL03: µTasker FRDM-KL03Z support

Internal Flash and SPI Flash Parameters: http://www.utasker.com/docs/uTasker/uTaskerFileSystem_3.PDF / http://www.utasker.com/docs/uTasker/uTaskerFileSystemSPI_FLASH_003.PDF

ADC/DAC: http://www.utasker.com/docs/uTasker/uTaskerADC.pdf

For the complete "out-of-the-box" Kinetis experience and faster time to market

0 Kudos
Reply