Startup / config code space for MKL03Z8VFG4

cancel
Showing results for 
Search instead for 
Did you mean: 

Startup / config code space for MKL03Z8VFG4

227 Views
baxsie
Contributor I

I have a MKL03Z8VFG4  project that I am just starting.

To check that MCUXpresso was installed correctly, I used the web site to create an SDK for it, configured the LED pins and was able to blink the LEDs.

For my "bare metal" design, I created an SDK for MKL03Z32xxx4 using the web site. I got the ports configured using the Config Tool, Open Pins. So far, so good.

Here is the result after the build. This is with the example printf("Hello World\n"); commented out, with that in it would not fit at all:

Memory region  Used Size | Region Size | % Used
-------------------------+-------------+-------
PROGRAM_FLASH:   5720 B  |    8 KB     | 69.82%
         SRAM:    596 B  |    2 KB     | 29.10%

That is pretty sad for not a single line of user code.

So my question is:

Is there a slim / minimal startup code example for the MKL03Z8VFG4 somewhere?

Thanks in advance for any assistance you can offer.

0 Kudos
5 Replies

89 Views
mjbcswitzerland
Specialist V

Hi

Take a look at http://www.utasker.com/kinetis/FRDM-KL03Z.html to see some things that can be achieved with the KL03 even with file system and operating system.
A further advantage is that all code written for the KL03 can also run on almost any other Kinetis part without needing to install different libraries and port.

Regards

Mark

0 Kudos

89 Views
baxsie
Contributor I

Thank you for your reply. Mark.

So what size flash image be under utasker for a simple program that contained nothing except for port and clock inits, and a loop that toggled a single bit?

0 Kudos

89 Views
mjbcswitzerland
Specialist V

Hi

235 bytes, including reset vector and flash configuration - watchdog disable, clock setup to 48MHz HIRC, configure port, toggle output in while loop.

However, this is not the size that the binary file physically is due to the fact that the binary file can never be smaller than 1040 bytes because the Flash configuration is at 0x400..0x40f and so any binary will start at 0x00000000 and end at 0x40f even if there is no code between 0x008 and 0x400.

SRAM used is 0 bytes. Although some stack (not counted by the size output) will be used when operating.

Adding a SYSTICK periodic interrupt to toggle the output instead, with a set of default handlers and handlers for errors such as hard fault, with general interrupt support:
530 bytes Flash + 4 bytes SRAM

Regards

Mark

0 Kudos

89 Views
baxsie
Contributor I

So it looks like:

  • Project Explorer tab
  • (right click on project) -> Properties
  • C/C++ Build -> Settings
  • MCU Linker -> Managed Linker Script
  • Library- -> Pull Down "Redlib (none)"

Gets rid of the file system, and heap. With a null while loop in main(), that gets me to :

Memory region  Used Size | Region Size | % Used
-------------------------+-------------+-------
PROGRAM_FLASH:   1800 B  |    8 KB     | 21.97%
         SRAM:    400 B  |    2 KB     | 19.53%

Significantly better, if still pretty fat.

Adding in:

 BOARD_InitBootPins();
 BOARD_InitBootClocks();
 BOARD_InitBootPeripherals();

Bloats it right back up:

Memory region  Used Size | Region Size | % Used
-------------------------+-------------+-------
PROGRAM_FLASH:   3480 B  |    8 KB     | 42.48%
         SRAM:    404 B  |    2 KB     | 19.73%

(Sorry for the stream-of-consciousness post . . . I'm moderated.)

0 Kudos

89 Views
baxsie
Contributor I

By switching to Release, setting -Os (size optimization), -flto (Link-time optimization), RedLib(none) that can get it down to:

Memory region  Used Size | Region Size | % Used
-------------------------+-------------+-------
PROGRAM_FLASH:   1504 B  |    8 KB     | 18.36%
         SRAM:    264 B  |    2 KB     | 12.89%

The same program, using Debug, -O0 no link-time optimization, RedLib(none):

Memory region  Used Size | Region Size | % Used
-------------------------+-------------+-------
PROGRAM_FLASH:   3588 B  |    8 KB     | 43.80%
         SRAM:    404 B  |    2 KB     | 19.73%

So, while I think 1504 bytes is still pretty huge for startup code, it is much better than the 5700 bytes I initially saw.

Here is a screen shot of the Release and Active code space usage:

Release_vs_Debug.png

0 Kudos