Skip to content

Commit 4950de9

Browse files
committed
move custom start up to linker folder
1 parent 49baa7e commit 4950de9

File tree

5 files changed

+65
-331
lines changed

5 files changed

+65
-331
lines changed

cores/nRF5/nordic/nrfx/mdk/gcc_startup_nrf52.S renamed to cores/nRF5/linker/gcc_startup_nrf52.S

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ NOTICE: This file has been modified by Nordic Semiconductor ASA.
2525
.syntax unified
2626
.arch armv7e-m
2727

28+
/* Adafruit define stack & heap inside linker script */
29+
/*
2830
#ifdef __STARTUP_CONFIG
2931
#include "startup_config.h"
3032
#ifndef __STARTUP_CONFIG_STACK_ALIGNEMENT
@@ -69,7 +71,7 @@ __HeapBase:
6971
.size __HeapBase, . - __HeapBase
7072
__HeapLimit:
7173
.size __HeapLimit, . - __HeapLimit
72-
74+
*/
7375
.section .isr_vector
7476
.align 2
7577
.globl __isr_vector
@@ -243,6 +245,17 @@ Reset_Handler:
243245

244246
.L_loop1_done:
245247

248+
249+
/* Adafruit fill stack region with pattern 0xADADADAD */
250+
ldr r0, =__StackLimit
251+
ldr r1, =__StackSize
252+
ldr r2, =0xADADADAD
253+
.L_fill:
254+
str r2, [r0]
255+
adds r0, 4
256+
subs r1, 4
257+
bne .L_fill
258+
246259
/* This part of work usually is done in C library startup code. Otherwise,
247260
* define __STARTUP_CLEAR_BSS to enable it in this startup. This section
248261
* clears the RAM where BSS data is located.

cores/nRF5/nordic/nrfx/mdk/gcc_startup_nrf52840.S renamed to cores/nRF5/linker/gcc_startup_nrf52840.S

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ NOTICE: This file has been modified by Nordic Semiconductor ASA.
2424

2525
.syntax unified
2626
.arch armv7e-m
27-
27+
/* Adafruit define stack & heap inside linker script */
28+
/*
2829
#ifdef __STARTUP_CONFIG
2930
#include "startup_config.h"
3031
#ifndef __STARTUP_CONFIG_STACK_ALIGNEMENT
@@ -69,7 +70,7 @@ __HeapBase:
6970
.size __HeapBase, . - __HeapBase
7071
__HeapLimit:
7172
.size __HeapLimit, . - __HeapLimit
72-
73+
*/
7374
.section .isr_vector
7475
.align 2
7576
.globl __isr_vector
@@ -243,6 +244,16 @@ Reset_Handler:
243244

244245
.L_loop1_done:
245246

247+
/* Adafruit fill stack region with pattern 0xADADADAD */
248+
ldr r0, =__StackLimit
249+
ldr r1, =__StackSize
250+
ldr r2, =0xADADADAD
251+
.L_fill:
252+
str r2, [r0]
253+
adds r0, 4
254+
subs r1, 4
255+
bne .L_fill
256+
246257
/* This part of work usually is done in C library startup code. Otherwise,
247258
* define __STARTUP_CLEAR_BSS to enable it in this startup. This section
248259
* clears the RAM where BSS data is located.

cores/nRF5/linker/nrf52_common.ld

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ PROVIDE(__stack = __StackTop);
6060
/* Flash region */
6161
__flash_arduino_start = ORIGIN(FLASH);
6262
__flash_arduino_end = ORIGIN(FLASH) + LENGTH(FLASH);
63-
__flash_bond_start = ORIGIN(FLASH_BOND);
64-
63+
/* __flash_bond_start = ORIGIN(FLASH_BOND); */
64+
6565
SECTIONS
6666
{
6767
.text :
@@ -148,26 +148,26 @@ SECTIONS
148148
. = ALIGN(4);
149149
__bss_end__ = .;
150150
} > RAM
151-
152-
/*.heap (COPY):*/
151+
153152
.heap :
154153
{
154+
__HeapBase = .;
155155
__end__ = .;
156156
PROVIDE(end = .);
157-
__HeapBase = .;
158-
*(.heap*)
157+
KEEP(*(.heap*))
159158
. = ALIGN(__StackLimit);
160159
__HeapLimit = .;
161160
} > RAM
162-
163161

164-
/* .stack section doesn't contains any symbols. It is only
165-
* used for linker to calculate size of stack sections */
166-
.stack :
162+
/* .stack_dummy section doesn't contains any symbols. It is only
163+
* used for linker to calculate size of stack sections, and assign
164+
* values to stack symbols later */
165+
/*
166+
.stack_dummy (COPY):
167167
{
168-
. = ALIGN(__StackLimit);
169-
. = ALIGN(__StackTop);
168+
KEEP(*(.stack*))
170169
} > RAM
170+
*/
171171

172172
/* Check if data + heap + stack exceeds RAM limit */
173173
ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**************************************************************************/
22
/*!
3-
@file nrf52_flash.h
3+
@file nffs_port.c
44
@author hathach (tinyusb.org)
55
66
@section LICENSE
@@ -33,28 +33,29 @@
3333
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3434
*/
3535
/**************************************************************************/
36-
#ifndef NRF52_FLASH_H_
37-
#define NRF52_FLASH_H_
3836

39-
#include <stdint.h>
40-
#include <hal/hal_flash_int.h>
41-
42-
#ifdef __cplusplus
43-
extern "C" {
44-
#endif
45-
46-
#define NRF52K_FLASH_SECTOR_SZ 4096
47-
48-
// const struct hal_flash* dev is required for nffs flash interface but not used
49-
// by nrf52_flash, just simply pass NULL when invoked
50-
51-
int nrf52_flash_init(const struct hal_flash *dev);
52-
int nrf52_flash_erase_sector(const struct hal_flash *dev, uint32_t sector_address);
53-
int nrf52_flash_write(const struct hal_flash *dev, uint32_t address, const void *src, uint32_t num_bytes);
54-
int nrf52k_flash_read(const struct hal_flash *dev, uint32_t address, void *dst, uint32_t num_bytes);
55-
56-
#ifdef __cplusplus
57-
}
58-
#endif
59-
60-
#endif /* NRF52_FLASH_H_ */
37+
#include "kernel.h"
38+
#include "nffs/nffs.h"
39+
40+
nffs_os_mempool_t nffs_file_pool = sizeof(struct nffs_file);
41+
nffs_os_mempool_t nffs_dir_pool = sizeof(struct nffs_dir);
42+
nffs_os_mempool_t nffs_inode_entry_pool = sizeof(struct nffs_inode_entry);
43+
nffs_os_mempool_t nffs_block_entry_pool = sizeof(struct nffs_hash_entry);
44+
nffs_os_mempool_t nffs_cache_inode_pool = sizeof(struct nffs_cache_inode);
45+
nffs_os_mempool_t nffs_cache_block_pool = sizeof(struct nffs_cache_block);
46+
47+
int nffs_os_mempool_init(void)
48+
{
49+
return 0;
50+
}
51+
52+
void* nffs_os_mempool_get(nffs_os_mempool_t *pool)
53+
{
54+
return pvPortMalloc(*pool);
55+
}
56+
57+
int nffs_os_mempool_free(nffs_os_mempool_t *pool, void *block)
58+
{
59+
vPortFree(block);
60+
return 0;
61+
}

0 commit comments

Comments
 (0)