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.
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.
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?
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
So it looks like:
Gets rid of the file system, and heap. With a null while loop in main(), that gets me to :
Significantly better, if still pretty fat.
BOARD_InitBootPins(); BOARD_InitBootClocks(); BOARD_InitBootPeripherals();
Bloats it right back up:
(Sorry for the stream-of-consciousness post . . . I'm moderated.)
By switching to Release, setting -Os (size optimization), -flto (Link-time optimization), RedLib(none) that can get it down to:
The same program, using Debug, -O0 no link-time optimization, RedLib(none):
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: