diff --git a/cores/nRF5/nordic/nrfx/mdk/gcc_startup_nrf52.S b/cores/nRF5/linker/gcc_startup_nrf52.S similarity index 97% rename from cores/nRF5/nordic/nrfx/mdk/gcc_startup_nrf52.S rename to cores/nRF5/linker/gcc_startup_nrf52.S index fa2e6887..2778fac5 100644 --- a/cores/nRF5/nordic/nrfx/mdk/gcc_startup_nrf52.S +++ b/cores/nRF5/linker/gcc_startup_nrf52.S @@ -25,6 +25,8 @@ NOTICE: This file has been modified by Nordic Semiconductor ASA. .syntax unified .arch armv7e-m +/* Adafruit define stack & heap inside linker script */ +/* #ifdef __STARTUP_CONFIG #include "startup_config.h" #ifndef __STARTUP_CONFIG_STACK_ALIGNEMENT @@ -69,7 +71,7 @@ __HeapBase: .size __HeapBase, . - __HeapBase __HeapLimit: .size __HeapLimit, . - __HeapLimit - +*/ .section .isr_vector .align 2 .globl __isr_vector @@ -243,6 +245,17 @@ Reset_Handler: .L_loop1_done: + +/* Adafruit fill stack region with pattern 0xADADADAD */ + ldr r0, =__StackLimit + ldr r1, =__StackSize + ldr r2, =0xADADADAD +.L_fill: + str r2, [r0] + adds r0, 4 + subs r1, 4 + bne .L_fill + /* This part of work usually is done in C library startup code. Otherwise, * define __STARTUP_CLEAR_BSS to enable it in this startup. This section * clears the RAM where BSS data is located. diff --git a/cores/nRF5/nordic/nrfx/mdk/gcc_startup_nrf52840.S b/cores/nRF5/linker/gcc_startup_nrf52840.S similarity index 97% rename from cores/nRF5/nordic/nrfx/mdk/gcc_startup_nrf52840.S rename to cores/nRF5/linker/gcc_startup_nrf52840.S index ad544b7a..20cfb278 100644 --- a/cores/nRF5/nordic/nrfx/mdk/gcc_startup_nrf52840.S +++ b/cores/nRF5/linker/gcc_startup_nrf52840.S @@ -24,7 +24,8 @@ NOTICE: This file has been modified by Nordic Semiconductor ASA. .syntax unified .arch armv7e-m - +/* Adafruit define stack & heap inside linker script */ +/* #ifdef __STARTUP_CONFIG #include "startup_config.h" #ifndef __STARTUP_CONFIG_STACK_ALIGNEMENT @@ -69,7 +70,7 @@ __HeapBase: .size __HeapBase, . - __HeapBase __HeapLimit: .size __HeapLimit, . - __HeapLimit - +*/ .section .isr_vector .align 2 .globl __isr_vector @@ -243,6 +244,16 @@ Reset_Handler: .L_loop1_done: +/* Adafruit fill stack region with pattern 0xADADADAD */ + ldr r0, =__StackLimit + ldr r1, =__StackSize + ldr r2, =0xADADADAD +.L_fill: + str r2, [r0] + adds r0, 4 + subs r1, 4 + bne .L_fill + /* This part of work usually is done in C library startup code. Otherwise, * define __STARTUP_CLEAR_BSS to enable it in this startup. This section * clears the RAM where BSS data is located. diff --git a/cores/nRF5/linker/nrf52_common.ld b/cores/nRF5/linker/nrf52_common.ld index 03e11a73..e51fc3d9 100755 --- a/cores/nRF5/linker/nrf52_common.ld +++ b/cores/nRF5/linker/nrf52_common.ld @@ -60,8 +60,8 @@ PROVIDE(__stack = __StackTop); /* Flash region */ __flash_arduino_start = ORIGIN(FLASH); __flash_arduino_end = ORIGIN(FLASH) + LENGTH(FLASH); -__flash_bond_start = ORIGIN(FLASH_BOND); - +/* __flash_bond_start = ORIGIN(FLASH_BOND); */ + SECTIONS { .text : @@ -148,26 +148,26 @@ SECTIONS . = ALIGN(4); __bss_end__ = .; } > RAM - - /*.heap (COPY):*/ + .heap : { + __HeapBase = .; __end__ = .; PROVIDE(end = .); - __HeapBase = .; - *(.heap*) + KEEP(*(.heap*)) . = ALIGN(__StackLimit); __HeapLimit = .; } > RAM - - /* .stack section doesn't contains any symbols. It is only - * used for linker to calculate size of stack sections */ - .stack : + /* .stack_dummy section doesn't contains any symbols. It is only + * used for linker to calculate size of stack sections, and assign + * values to stack symbols later */ + /* + .stack_dummy (COPY): { - . = ALIGN(__StackLimit); - . = ALIGN(__StackTop); + KEEP(*(.stack*)) } > RAM + */ /* Check if data + heap + stack exceeds RAM limit */ ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack") diff --git a/nrf52_flash.h b/libraries/FileSystem/src/nffs_port.c similarity index 71% rename from nrf52_flash.h rename to libraries/FileSystem/src/nffs_port.c index 9dd9e8af..23552419 100644 --- a/nrf52_flash.h +++ b/libraries/FileSystem/src/nffs_port.c @@ -1,6 +1,6 @@ /**************************************************************************/ /*! - @file nrf52_flash.h + @file nffs_port.c @author hathach (tinyusb.org) @section LICENSE @@ -33,28 +33,29 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /**************************************************************************/ -#ifndef NRF52_FLASH_H_ -#define NRF52_FLASH_H_ -#include -#include +#include "kernel.h" +#include "nffs/nffs.h" -#ifdef __cplusplus - extern "C" { -#endif +nffs_os_mempool_t nffs_file_pool = sizeof(struct nffs_file); +nffs_os_mempool_t nffs_dir_pool = sizeof(struct nffs_dir); +nffs_os_mempool_t nffs_inode_entry_pool = sizeof(struct nffs_inode_entry); +nffs_os_mempool_t nffs_block_entry_pool = sizeof(struct nffs_hash_entry); +nffs_os_mempool_t nffs_cache_inode_pool = sizeof(struct nffs_cache_inode); +nffs_os_mempool_t nffs_cache_block_pool = sizeof(struct nffs_cache_block); -#define NRF52K_FLASH_SECTOR_SZ 4096 +int nffs_os_mempool_init(void) +{ + return 0; +} -// const struct hal_flash* dev is required for nffs flash interface but not used -// by nrf52_flash, just simply pass NULL when invoked +void* nffs_os_mempool_get(nffs_os_mempool_t *pool) +{ + return pvPortMalloc(*pool); +} -int nrf52_flash_init(const struct hal_flash *dev); -int nrf52_flash_erase_sector(const struct hal_flash *dev, uint32_t sector_address); -int nrf52_flash_write(const struct hal_flash *dev, uint32_t address, const void *src, uint32_t num_bytes); -int nrf52k_flash_read(const struct hal_flash *dev, uint32_t address, void *dst, uint32_t num_bytes); - -#ifdef __cplusplus - } -#endif - -#endif /* NRF52_FLASH_H_ */ +int nffs_os_mempool_free(nffs_os_mempool_t *pool, void *block) +{ + vPortFree(block); + return 0; +} diff --git a/nrf52_flash.c b/nrf52_flash.c deleted file mode 100644 index 34c427f1..00000000 --- a/nrf52_flash.c +++ /dev/null @@ -1,291 +0,0 @@ -/**************************************************************************/ -/*! - @file nrf52_flash.c - @author hathach (tinyusb.org) - - @section LICENSE - - Software License Agreement (BSD License) - - Copyright (c) 2018, Adafruit Industries (adafruit.com) - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the copyright holders nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY - EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -/**************************************************************************/ - -#include -#include "Arduino.h" -#include "nrf52_flash.h" - -#if CFG_DEBUG -#define CFG_DEBUG_NFFS 0 - -#if CFG_DEBUG_NFFS -static void print_buf(const uint8_t* address, uint32_t count) -{ - for(uint32_t i=0; i