Skip to content

Instantly share code, notes, and snippets.

@martinribelotta
Created August 19, 2019 16:08
Show Gist options
  • Save martinribelotta/df78a8dd642760b7ea74870a8b007c98 to your computer and use it in GitHub Desktop.
Save martinribelotta/df78a8dd642760b7ea74870a8b007c98 to your computer and use it in GitHub Desktop.
LPC43xx RAM sections
#include "sections.h"
// See section names in linker script (*.ld)
// See: https://github.com/martinribelotta/micropython/blob/master/ciaa-nxp/ciaa_lpc4337.ld
// BSS is for non initialized variables (clear to zero on init)
static __BSS(RAM2) char heap[32*1024];
// DATA is for initialized variables
static __DATA(RAM2) char heap[32*1024] = { 0xff };
/* Posible section names:
* Section MEMORY name
* (default) -> RamLoc32 (32K)
* RAM2 -> RamLoc40 (40K)
* RAM3 -> RamAHB32 (32K)
* RAM4 -> RamAHB16 (16K)
* RAM5 -> RamAHB_ETB16 (16K)
*/
#ifndef __SECTIONS_H__
#define __SECTIONS_H__
#ifndef __SECTION_EXT
#define __SECTION_EXT(type, bank, name) __attribute__ ((section("." #type ".$" #bank "." #name)))
#endif
#ifndef __SECTION
#define __SECTION(type, bank) __attribute__ ((section("." #type ".$" #bank)))
#endif
#ifndef __DATA_EXT
#define __DATA_EXT(bank, name) __SECTION_EXT(data, bank, name)
#endif
#ifndef __BSS_EXT
#define __BSS_EXT(bank, name) __SECTION_EXT(bss, bank, name)
#endif
#ifndef __DATA
#define __DATA(bank) __SECTION(data, bank)
#endif
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment