Skip to content

Commit e4419e7

Browse files
committed
Merge pull request #1 from mbedmicro/master
Update
2 parents ed05011 + cc0476d commit e4419e7

File tree

73 files changed

+13620
-327
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+13620
-327
lines changed

libraries/fs/fat/FATFileSystem.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,15 @@ int FATFileSystem::remove(const char *filename) {
108108
return 0;
109109
}
110110

111+
int FATFileSystem::rename(const char *oldname, const char *newname) {
112+
FRESULT res = f_rename(oldname, newname);
113+
if (res) {
114+
debug_if(FFS_DBG, "f_rename() failed: %d\n", res);
115+
return -1;
116+
}
117+
return 0;
118+
}
119+
111120
int FATFileSystem::format() {
112121
FRESULT res = f_mkfs(_fsid, 0, 512); // Logical drive number, Partitioning rule, Allocation unit size (bytes per cluster)
113122
if (res) {

libraries/fs/fat/FATFileSystem.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class FATFileSystem : public FileSystemLike {
4141

4242
virtual FileHandle *open(const char* name, int flags);
4343
virtual int remove(const char *filename);
44+
virtual int rename(const char *oldname, const char *newname);
4445
virtual int format();
4546
virtual DirHandle *opendir(const char *name);
4647
virtual int mkdir(const char *name, mode_t mode);

libraries/mbed/common/retarget.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,15 @@ extern "C" int remove(const char *path) {
323323
}
324324

325325
extern "C" int rename(const char *oldname, const char *newname) {
326-
return -1;
326+
FilePath fpOld(oldname);
327+
FilePath fpNew(newname);
328+
FileSystemLike *fsOld = fpOld.fileSystem();
329+
FileSystemLike *fsNew = fpNew.fileSystem();
330+
331+
/* rename only if both files are on the same FS */
332+
if (fsOld != fsNew || fsOld == NULL) return -1;
333+
334+
return fsOld->rename(fpOld.fileName(), fpNew.fileName());
327335
}
328336

329337
extern "C" char *tmpnam(char *s) {

libraries/mbed/targets/cmsis/TARGET_NORDIC/TARGET_MCU_NRF51822/TOOLCHAIN_GCC_ARM/NRF51822.ld

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ SECTIONS
4343
KEEP(*(.Vectors))
4444
*(.text*)
4545

46-
*(.init)
47-
*(.fini)
46+
KEEP(*(.init))
47+
KEEP(*(.fini))
4848

4949
/* .ctors */
5050
*crtbegin.o(.ctors)
@@ -62,7 +62,7 @@ SECTIONS
6262

6363
*(.rodata*)
6464

65-
*(.eh_frame*)
65+
KEEP(*(.eh_frame*))
6666
} > FLASH
6767

6868

@@ -89,22 +89,22 @@ SECTIONS
8989
. = ALIGN(4);
9090
/* preinit data */
9191
PROVIDE_HIDDEN (__preinit_array_start = .);
92-
*(.preinit_array)
92+
KEEP(*(.preinit_array))
9393
PROVIDE_HIDDEN (__preinit_array_end = .);
9494

9595
. = ALIGN(4);
9696
/* init data */
9797
PROVIDE_HIDDEN (__init_array_start = .);
98-
*(SORT(.init_array.*))
99-
*(.init_array)
98+
KEEP(*(SORT(.init_array.*)))
99+
KEEP(*(.init_array))
100100
PROVIDE_HIDDEN (__init_array_end = .);
101101

102102

103103
. = ALIGN(4);
104104
/* finit data */
105105
PROVIDE_HIDDEN (__fini_array_start = .);
106-
*(SORT(.fini_array.*))
107-
*(.fini_array)
106+
KEEP(*(SORT(.fini_array.*)))
107+
KEEP(*(.fini_array))
108108
PROVIDE_HIDDEN (__fini_array_end = .);
109109

110110
*(.jcr)
@@ -149,4 +149,3 @@ SECTIONS
149149
/* Check if data + heap + stack exceeds RAM limit */
150150
ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
151151
}
152-
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
/* Linker script for mbed LPC1549 */
2+
3+
/* Linker script to configure memory regions. */
4+
MEMORY
5+
{
6+
/* Define each memory region */
7+
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 256K
8+
Ram0_16 (rwx) : ORIGIN = 0x2000000 + 0x100, LENGTH = (16K - 0x100)
9+
Ram1_16 (rwx) : ORIGIN = 0x2004000, LENGTH = 16K
10+
Ram2_4 (rwx) : ORIGIN = 0x2008000, LENGTH = 4K
11+
12+
}
13+
14+
/* Linker script to place sections and symbol values. Should be used together
15+
* with other linker script that defines memory regions FLASH and RAM.
16+
* It references following symbols, which must be defined in code:
17+
* Reset_Handler : Entry of reset handler
18+
*
19+
* It defines following symbols, which code can use without definition:
20+
* __exidx_start
21+
* __exidx_end
22+
* __etext
23+
* __data_start__
24+
* __preinit_array_start
25+
* __preinit_array_end
26+
* __init_array_start
27+
* __init_array_end
28+
* __fini_array_start
29+
* __fini_array_end
30+
* __data_end__
31+
* __bss_start__
32+
* __bss_end__
33+
* __end__
34+
* end
35+
* __HeapLimit
36+
* __StackLimit
37+
* __StackTop
38+
* __stack
39+
*/
40+
ENTRY(Reset_Handler)
41+
42+
SECTIONS
43+
{
44+
.text :
45+
{
46+
KEEP(*(.isr_vector))
47+
*(.text*)
48+
49+
KEEP(*(.init))
50+
KEEP(*(.fini))
51+
52+
/* .ctors */
53+
*crtbegin.o(.ctors)
54+
*crtbegin?.o(.ctors)
55+
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
56+
*(SORT(.ctors.*))
57+
*(.ctors)
58+
59+
/* .dtors */
60+
*crtbegin.o(.dtors)
61+
*crtbegin?.o(.dtors)
62+
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
63+
*(SORT(.dtors.*))
64+
*(.dtors)
65+
66+
*(.rodata*)
67+
68+
KEEP(*(.eh_frame*))
69+
} > FLASH
70+
71+
.ARM.extab :
72+
{
73+
*(.ARM.extab* .gnu.linkonce.armextab.*)
74+
} > FLASH
75+
76+
__exidx_start = .;
77+
.ARM.exidx :
78+
{
79+
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
80+
} > FLASH
81+
__exidx_end = .;
82+
83+
__etext = .;
84+
85+
.data : AT (__etext)
86+
{
87+
__data_start__ = .;
88+
Image$$RW_IRAM1$$Base = .;
89+
*(vtable)
90+
*(.data*)
91+
92+
. = ALIGN(4);
93+
/* preinit data */
94+
PROVIDE (__preinit_array_start = .);
95+
KEEP(*(.preinit_array))
96+
PROVIDE (__preinit_array_end = .);
97+
98+
. = ALIGN(4);
99+
/* init data */
100+
PROVIDE (__init_array_start = .);
101+
KEEP(*(SORT(.init_array.*)))
102+
KEEP(*(.init_array))
103+
PROVIDE (__init_array_end = .);
104+
105+
106+
. = ALIGN(4);
107+
/* finit data */
108+
PROVIDE (__fini_array_start = .);
109+
KEEP(*(SORT(.fini_array.*)))
110+
KEEP(*(.fini_array))
111+
PROVIDE (__fini_array_end = .);
112+
113+
. = ALIGN(4);
114+
/* All data end */
115+
__data_end__ = .;
116+
117+
} > Ram0_16
118+
119+
120+
.bss :
121+
{
122+
__bss_start__ = .;
123+
*(.bss*)
124+
*(COMMON)
125+
__bss_end__ = .;
126+
Image$$RW_IRAM1$$ZI$$Limit = . ;
127+
} > Ram0_16
128+
129+
130+
.heap :
131+
{
132+
__end__ = .;
133+
end = __end__;
134+
*(.heap*)
135+
__HeapLimit = .;
136+
} > Ram0_16
137+
138+
/* .stack_dummy section doesn't contains any symbols. It is only
139+
* used for linker to calculate size of stack sections, and assign
140+
* values to stack symbols later */
141+
.stack_dummy :
142+
{
143+
*(.stack)
144+
} > Ram0_16
145+
146+
/* Set stack top to end of RAM, and stack limit move down by
147+
* size of stack_dummy section */
148+
__StackTop = ORIGIN(Ram0_16) + LENGTH(Ram0_16);
149+
__StackLimit = __StackTop - SIZEOF(.stack_dummy);
150+
PROVIDE(__stack = __StackTop);
151+
152+
/* Check if data + heap + stack exceeds RAM limit */
153+
ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
154+
}

0 commit comments

Comments
 (0)