Skip to content

nelcea/EmbeddedSwift-nRF52-HeapOrStack

Repository files navigation

Introduction

This repository is a collection of small test programs to try and better understand the way Embedded Swift allocates memory on the stack or the heap. It's using nRF Connect SDK v2.7.0 and tests have been performed on a nRF52840 dk

Project configueration

Memory allocation is configured to use CONFIG_NEWLIB_LIBC=y The heap is configured to be 64kB (CONFIG_HEAP_MEM_POOL_SIZE=65536 in prj.conf)

A posix_memalign implementation is provided in Stubcs.c This function prints to the console the requested size and alignment. Most test have been performed using malloc() for the memory allocation. Main - 8.swift has also been tested using k_malloc() instead (a function provided by Zephyr, not libc).

Note: neither malloc, nor k_malloc do respect the requested alignment. This is OK for testing but should not be used for production code.

There's a print_address() C function defined in BridgingHeader.h to print the address of a given pointer.

Running the tests

The different tests are located in files named "Main - n.swift". To run a test, rename its file to Main.swift.

At the end of each source code, there is a small description of the test and the output from running it on the nRF 52840 dk. There's also some interpretation of the test output.

TODO

Also look at information from linker script.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors