Skip to content

Commit

Permalink
[K32W] Save PDM to external flash on the DK6 board (#7307)
Browse files Browse the repository at this point in the history
* [K32W] Save PDM to external flash on the DK6 board

This will free up 32.5K of internal flash space.

Signed-off-by: Doru Gucea <[email protected]>

* Restyled by whitespace

* Restyled by clang-format

* Restyled by gn

Signed-off-by: Doru Gucea <[email protected]>

Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Jun 22, 2021
1 parent fd12ae4 commit d41ee77
Show file tree
Hide file tree
Showing 8 changed files with 962 additions and 2,402 deletions.
56 changes: 24 additions & 32 deletions examples/platform/k32w/app/ldscripts/chip-k32w061-linker.ld
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
*/
BOOT_RESUME_STACK_SIZE = 1024;

/* Set Stack size to 4K minus 32Bytes reserved for ROM code at end of BANK7 so
the stack fits in BANK7. In practice the active stack size at the time of
going to sleep is more important than the total available stack size */
STACK_SIZE = (4096 - 32);
STACK_SIZE = (4096);

MEM_RAM0_BASE = 0x4000400;
MEM_RAM0_SIZE = 0x0015c00;
MEM_RAM0_BASE = 0x4000400;
MEM_RAM0_SIZE = 0x0015c00;

MEM_RAM1_BASE = 0x4020000;
MEM_RAM1_SIZE = 0x10000;

MEMORY
{
Expand All @@ -57,37 +57,29 @@ MEMORY
}

/* Define a symbol for the top of each memory region */
__top_RAM0 = MEM_RAM0_BASE + MEM_RAM0_SIZE; /* 87K bytes */
__top_RAM1 = MEM_RAM1_BASE + MEM_RAM1_SIZE; /* 64K bytes */

/* To be improved. At this moment the second RAM bank is dedicated entirely to heap. */
/* To be improved. At this moment the second RAM bank is dedicated entirely to heap + stack. */
HEAP_SIZE = DEFINED(HEAP_SIZE) ? HEAP_SIZE : 0xF000;

/*** flash memory characteristics definitions required for OTA ***/
m_flash_start = 0x00000000;
m_flash_end = 0x0009FFFF;
m_flash_size = 0x000A0000;
m_sector_size = 512;
m_fsl_prodInfo_size = m_sector_size;

m_fsl_prodInfo_end = m_flash_size - 17 * m_sector_size - 1;
m_fsl_prodInfo_start = m_fsl_prodInfo_end - m_fsl_prodInfo_size + 1;
/* set external flash properties - external flash is present on the DK6 board */
m_ext_flash_size = 0x00100000;
m_ext_flash_base = 0x00000000;
m_ext_flash_sector_size = 4096;

NV_STORAGE_MAX_SECTORS = 63;
NV_STORAGE_SIZE = NV_STORAGE_MAX_SECTORS * m_sector_size;
NV_STORAGE_START_ADDRESS = m_fsl_prodInfo_start - 1;
NV_STORAGE_END_ADDRESS = NV_STORAGE_START_ADDRESS - NV_STORAGE_SIZE + 1;
NVMSectorCountLink = 63;

INT_STORAGE_END = NV_STORAGE_START_ADDRESS - 1;
INT_STORAGE_START = 0x48000;
INT_STORAGE_SIZE = INT_STORAGE_END - INT_STORAGE_START;
NV_STORAGE_SIZE = NVMSectorCountLink * m_ext_flash_sector_size;
NV_STORAGE_MAX_SECTORS = NVMSectorCountLink;
NV_STORAGE_SECTOR_SIZE = m_ext_flash_sector_size;
NV_STORAGE_START_ADDRESS = m_ext_flash_size - 1;
NV_STORAGE_END_ADDRESS = NV_STORAGE_START_ADDRESS - NV_STORAGE_SIZE + 1;

FREESCALE_PROD_DATA_BASE_ADDR = m_fsl_prodInfo_start;
INT_STORAGE_SECTOR_SIZE = m_sector_size;
m_app_size = 0xA0000; /* 640K: to accommodate all libs in debug */
m_app_size = 0x00a0000; /* 640K */

__ram_vector_table__ = 1;
vector_table_size = 0x120;
M_VECTOR_RAM_SIZE = DEFINED(__ram_vector_table__) ? vector_table_size : 0x0;
__ram_vector_table__ = 1;
vector_table_size = 0x120;
M_VECTOR_RAM_SIZE = DEFINED(__ram_vector_table__) ? vector_table_size : 0x0;

ENTRY(ResetISR)

Expand Down Expand Up @@ -319,7 +311,7 @@ SECTIONS
__nv_storage_end_address = NV_STORAGE_END_ADDRESS;
__nv_storage_start_address = NV_STORAGE_START_ADDRESS;

PROVIDE(_vStackTop = __top_RAM0 - 32);
PROVIDE(_vStackTop = __top_RAM1);
PROVIDE(__mac_buffer_base = (__mac_buffer_start & 0xfffe0000));
PROVIDE(BOOT_GetStartPowerMode = 0x03000e9d);
PROVIDE(ROM_GetFlash = 0x03000e0d);
Expand All @@ -328,5 +320,5 @@ SECTIONS
PROVIDE(Chip_LOWPOWER_ChipSoftwareReset = 0x03003fa1);

__StackLimit = _vStackTop - STACK_SIZE;
ASSERT(__StackLimit >= _end_boot_resume_stack, "Possible stack corruption with data/bss/boot_stack")
ASSERT (LENGTH(Flash640) >= (_etext + SIZEOF(.data)), "Application does not fit into flash!")
}
7 changes: 6 additions & 1 deletion third_party/k32w_sdk/k32w_sdk.gni
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ template("k32w_sdk") {
"${k32w_sdk_root}/middleware/wireless/bluetooth/host/config",
"${k32w_sdk_root}/middleware/wireless/bluetooth/host/interface",
"${k32w_sdk_root}/middleware/wireless/framework/Common",
"${k32w_sdk_root}/middleware/wireless/framework/Flash/External/Interface",
"${k32w_sdk_root}/middleware/wireless/framework/Flash/Internal",
"${k32w_sdk_root}/middleware/wireless/framework/FunctionLib",
"${k32w_sdk_root}/middleware/wireless/framework/GPIO",
Expand Down Expand Up @@ -107,7 +108,7 @@ template("k32w_sdk") {
"${k32w_sdk_root}/middleware/wireless/ble_controller/lib/lib_ble_controller.a",
"${k32w_sdk_root}//middleware/wireless/bluetooth/host/lib/lib_ble_5-0_host_peripheral_cm4_noFP.a",
"${k32w_sdk_root}/middleware/wireless/ieee-802.15.4/lib/libMiniMac_Dynamic_MMAC.a",
"${k32w_sdk_root}/middleware/wireless/framework/PDM/Library/libPDM.a",
"${k32w_sdk_root}/middleware/wireless/framework/PDM/Library/libPDM_extFlash.a",
"${k32w_sdk_root}/middleware/wireless/framework/SecLib/lib_crypto_m4.a",
"${k32w_sdk_root}/middleware/wireless/framework/XCVR/lib/libRadio.a",
]
Expand All @@ -127,6 +128,9 @@ template("k32w_sdk") {
"gTotalHeapSize_c=0xF000",
"gUartDebugConsole_d=1",
"gUsePdm_d=1",
"PDM_EXT_FLASH=1",
"gEepromType_d=gEepromDevice_MX25R8035F_c",
"gOTA_externalFlash_d=1",
"gLEDSupported_d",
"gKeyBoardSupported_d",
"gPdmNbSegments=63",
Expand Down Expand Up @@ -256,6 +260,7 @@ template("k32w_sdk") {
"${k32w_sdk_root}/middleware/wireless/bluetooth/application/common/ble_host_tasks.c",
"${k32w_sdk_root}/middleware/wireless/bluetooth/host/config/ble_globals.c",
"${k32w_sdk_root}/middleware/wireless/framework/Common/MicroInt_arm_sdk2.c",
"${k32w_sdk_root}/middleware/wireless/framework/Flash/External/Source/Eeprom_MX25R8035F.c",
"${k32w_sdk_root}/middleware/wireless/framework/Flash/Internal/Flash_Adapter.c",
"${k32w_sdk_root}/middleware/wireless/framework/FunctionLib/FunctionLib.c",
"${k32w_sdk_root}/middleware/wireless/framework/GPIO/GPIO_Adapter.c",
Expand Down
Loading

0 comments on commit d41ee77

Please sign in to comment.