Skip to content

Commit 43c2cce

Browse files
committed
Remove standard library as much as possible
- clean up
1 parent a685935 commit 43c2cce

File tree

7 files changed

+52
-46
lines changed

7 files changed

+52
-46
lines changed

IDE/Renesas/e2studio/RX72N/app_RenesasRX01/.cproject

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
</option>
7777
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.renesas.cdt.managedbuild.renesas.ccrx.compiler.option.define.1700820161" name="Macro definition (-define)" superClass="com.renesas.cdt.managedbuild.renesas.ccrx.compiler.option.define" useByScannerDiscovery="false" valueType="definedSymbols">
7878
<listOptionValue builtIn="false" value="WOLFBOOT_RENESAS_APP"/>
79+
<listOptionValue builtIn="false" value="XMEMCPY=memcpy"/>
7980
<listOptionValue builtIn="false" value="ENABLE_LED"/>
8081
<listOptionValue builtIn="false" value="TARGET_rx72n"/>
8182
</option>
@@ -160,6 +161,10 @@
160161
<listOptionValue builtIn="false" value=""/>
161162
</option>
162163
<option id="com.renesas.cdt.managedbuild.renesas.ccrx.librarian.option.lang.1980410131" name="Library configuration (-lang)" superClass="com.renesas.cdt.managedbuild.renesas.ccrx.librarian.option.lang" useByScannerDiscovery="false" value="com.renesas.cdt.managedbuild.renesas.ccrx.librarian.option.lang.c99" valueType="enumerated"/>
164+
<option id="com.renesas.cdt.managedbuild.renesas.ccrx.librarian.option.headNew.167212127" name="new (EC++): Memory allocation and deallocation routines (-head=new)" superClass="com.renesas.cdt.managedbuild.renesas.ccrx.librarian.option.headNew" value="false" valueType="boolean"/>
165+
<option id="com.renesas.cdt.managedbuild.renesas.ccrx.librarian.option.headString.1340645414" name="string.h (C89/C99): String handling operations (-head=string)" superClass="com.renesas.cdt.managedbuild.renesas.ccrx.librarian.option.headString" value="false" valueType="boolean"/>
166+
<option id="com.renesas.cdt.managedbuild.renesas.ccrx.librarian.option.headStdlib.1744295691" name="stdlib.h (C89/C99): General purpose library features (-head=stdlib)" superClass="com.renesas.cdt.managedbuild.renesas.ccrx.librarian.option.headStdlib" value="false" valueType="boolean"/>
167+
<option id="com.renesas.cdt.managedbuild.renesas.ccrx.librarian.option.headStdio.839444691" name="stdio.h (C89/C99): Input/Output (-head=stdio)" superClass="com.renesas.cdt.managedbuild.renesas.ccrx.librarian.option.headStdio" value="true" valueType="boolean"/>
163168
</tool>
164169
<tool id="com.renesas.cdt.managedbuild.renesas.ccrx.base.converter.1261529969" name="Converter" superClass="com.renesas.cdt.managedbuild.renesas.ccrx.base.converter">
165170
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.renesas.cdt.managedbuild.renesas.ccrx.converter.option.userBefore.1841151594" name="User-defined options (added before all specified options)" superClass="com.renesas.cdt.managedbuild.renesas.ccrx.converter.option.userBefore" useByScannerDiscovery="false" valueType="stringList">

IDE/Renesas/e2studio/RX72N/app_RenesasRX01/src/app_RenesasRX01.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ static void printPartitions(void)
103103
printf("\n=== Boot Partition[%08x] ===\n", WOLFBOOT_PARTITION_BOOT_ADDRESS);
104104
printPart((uint8_t*)WOLFBOOT_PARTITION_BOOT_ADDRESS);
105105
printf("\n=== Update Partition[%08x] ===\n", WOLFBOOT_PARTITION_UPDATE_ADDRESS);
106-
printPart((uint8_t*)WOLFBOOT_PARTITION_UPDATE_ADDRESS);
106+
printPart((uint8_t*)(uintptr_t)WOLFBOOT_PARTITION_UPDATE_ADDRESS);
107107
}
108108

109109
void main(void)

IDE/Renesas/e2studio/RX72N/include/user_settings.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,4 @@
280280
#endif
281281
#define PRINTF_ENABLED
282282
#define NVM_FLASH_WRITEONCE
283-
#ifdef XMEMCPY
284-
#undef XMEMCPY
285-
#define XMEMCPY ram_memcpy
286-
#endif
287283
#endif /* !H_USER_SETTINGS_ */

IDE/Renesas/e2studio/RX72N/wolfBoot/.cproject

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,20 +190,20 @@
190190
<option id="com.renesas.cdt.managedbuild.renesas.ccrx.linker.option.showSymbol.232531454" name="Output symbol information (-show=symbol)" superClass="com.renesas.cdt.managedbuild.renesas.ccrx.linker.option.showSymbol" value="true" valueType="boolean"/>
191191
<option id="com.renesas.cdt.managedbuild.renesas.ccrx.linker.option.useExternalSubCommand.1102670470" name="Use external sub-command file" superClass="com.renesas.cdt.managedbuild.renesas.ccrx.linker.option.useExternalSubCommand" value="false" valueType="boolean"/>
192192
<option id="com.renesas.cdt.managedbuild.renesas.ccrx.linker.option.subCommandFilePath.579401942" name="Sub-command file path (-subcommand)" superClass="com.renesas.cdt.managedbuild.renesas.ccrx.linker.option.subCommandFilePath" value="C:\workspace\wolfBoot_work\IDE\Renesas\e2studio\RX72N\wolfBoot\user_sections.prm" valueType="string"/>
193+
<option id="com.renesas.cdt.managedbuild.renesas.ccrx.linker.option.useCustomLinkageOrder.1063431467" name="Use custom linkage order" superClass="com.renesas.cdt.managedbuild.renesas.ccrx.linker.option.useCustomLinkageOrder" value="false" valueType="boolean"/>
193194
</tool>
194195
<tool id="com.renesas.cdt.managedbuild.renesas.ccrx.base.librarian.824424223" name="Library Generator" superClass="com.renesas.cdt.managedbuild.renesas.ccrx.base.librarian">
195196
<option id="com.renesas.cdt.managedbuild.renesas.ccrx.librarian.option.fpu.1603488290" name="Use floating point arithmetic instructions (-fpu/-nofpu)" superClass="com.renesas.cdt.managedbuild.renesas.ccrx.librarian.option.fpu" useByScannerDiscovery="false" value="com.renesas.cdt.managedbuild.renesas.ccrx.librarian.option.fpu.yes" valueType="enumerated"/>
196-
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.renesas.cdt.managedbuild.renesas.ccrx.librarian.option.userBefore.710836496" name="User-defined options (added before all specified options)" superClass="com.renesas.cdt.managedbuild.renesas.ccrx.librarian.option.userBefore" useByScannerDiscovery="false" valueType="stringList">
197-
<listOptionValue builtIn="false" value=""/>
198-
</option>
197+
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="true" id="com.renesas.cdt.managedbuild.renesas.ccrx.librarian.option.userBefore.710836496" name="User-defined options (added before all specified options)" superClass="com.renesas.cdt.managedbuild.renesas.ccrx.librarian.option.userBefore" useByScannerDiscovery="false" valueType="stringList"/>
199198
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.renesas.cdt.managedbuild.renesas.ccrx.librarian.option.userAfter.1811485073" name="User-defined options (added after all specified options)" superClass="com.renesas.cdt.managedbuild.renesas.ccrx.librarian.option.userAfter" useByScannerDiscovery="false" valueType="stringList">
200199
<listOptionValue builtIn="false" value=""/>
201200
</option>
202201
<option id="com.renesas.cdt.managedbuild.renesas.ccrx.librarian.option.lang.1059295426" name="Library configuration (-lang)" superClass="com.renesas.cdt.managedbuild.renesas.ccrx.librarian.option.lang" useByScannerDiscovery="false" value="com.renesas.cdt.managedbuild.renesas.ccrx.librarian.option.lang.c99" valueType="enumerated"/>
203-
<option id="com.renesas.cdt.managedbuild.renesas.ccrx.librarian.option.headString.597910302" name="string.h (C89/C99): String handling operations (-head=string)" superClass="com.renesas.cdt.managedbuild.renesas.ccrx.librarian.option.headString" value="true" valueType="boolean"/>
204-
<option id="com.renesas.cdt.managedbuild.renesas.ccrx.librarian.option.headStdlib.56265103" name="stdlib.h (C89/C99): General purpose library features (-head=stdlib)" superClass="com.renesas.cdt.managedbuild.renesas.ccrx.librarian.option.headStdlib" value="true" valueType="boolean"/>
202+
<option id="com.renesas.cdt.managedbuild.renesas.ccrx.librarian.option.headString.597910302" name="string.h (C89/C99): String handling operations (-head=string)" superClass="com.renesas.cdt.managedbuild.renesas.ccrx.librarian.option.headString" value="false" valueType="boolean"/>
203+
<option id="com.renesas.cdt.managedbuild.renesas.ccrx.librarian.option.headStdlib.56265103" name="stdlib.h (C89/C99): General purpose library features (-head=stdlib)" superClass="com.renesas.cdt.managedbuild.renesas.ccrx.librarian.option.headStdlib" value="false" valueType="boolean"/>
205204
<option id="com.renesas.cdt.managedbuild.renesas.ccrx.librarian.option.headStdio.1171897703" name="stdio.h (C89/C99): Input/Output (-head=stdio)" superClass="com.renesas.cdt.managedbuild.renesas.ccrx.librarian.option.headStdio" value="true" valueType="boolean"/>
206-
<option id="com.renesas.cdt.managedbuild.renesas.ccrx.librarian.option.headNew.749632663" name="new (EC++): Memory allocation and deallocation routines (-head=new)" superClass="com.renesas.cdt.managedbuild.renesas.ccrx.librarian.option.headNew" value="true" valueType="boolean"/>
205+
<option id="com.renesas.cdt.managedbuild.renesas.ccrx.librarian.option.headNew.749632663" name="new (EC++): Memory allocation and deallocation routines (-head=new)" superClass="com.renesas.cdt.managedbuild.renesas.ccrx.librarian.option.headNew" value="false" valueType="boolean"/>
206+
<option id="com.renesas.cdt.managedbuild.renesas.ccrx.librarian.option.mode.790485950" name="Generation mode of the standard library" superClass="com.renesas.cdt.managedbuild.renesas.ccrx.librarian.option.mode" value="com.renesas.cdt.managedbuild.renesas.ccrx.librarian.option.mode.buildOnlyWhenOptionsChanged" valueType="enumerated"/>
207207
</tool>
208208
<tool id="com.renesas.cdt.managedbuild.renesas.ccrx.base.converter.1791438439" name="Converter" superClass="com.renesas.cdt.managedbuild.renesas.ccrx.base.converter">
209209
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.renesas.cdt.managedbuild.renesas.ccrx.converter.option.userBefore.1209192614" name="User-defined options (added before all specified options)" superClass="com.renesas.cdt.managedbuild.renesas.ccrx.converter.option.userBefore" useByScannerDiscovery="false" valueType="stringList">

hal/renesas-rx.c

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,13 @@
6161

6262
/* forward declaration */
6363
int hal_flash_init(void);
64-
64+
#if defined(WOLFBOOT_RENESAS_TSIP) && !defined(WOLFBOOT_RENESAS_APP)
6565
static void hal_panic(void)
6666
{
6767
while(1)
6868
;
6969
}
70+
#endif
7071

7172
#ifdef ENABLE_LED
7273
void hal_led_on(void)
@@ -104,6 +105,21 @@ void hal_delay_us(uint32_t us)
104105
}
105106
}
106107

108+
static flash_err_t flash_check_error()
109+
{
110+
uint32_t st = FLASH_FSTATR;
111+
112+
if (st & FLASH_FSTATR_ILGLERR) return FLASH_ERR_ILGL;
113+
if (st & FLASH_FSTATR_PRGERR) return FLASH_ERR_PRG;
114+
if (st & FLASH_FSTATR_ERSERR) return FLASH_ERR_ERS;
115+
if (st & FLASH_FSTATR_FLWEERR) return FLASH_ERR_FLWE;
116+
if (st & FLASH_FSTATR_FESETERR) return FLASH_ERR_FESET;
117+
if (st & FLASH_FSTATR_SECERR) return FLASH_ERR_SEC;
118+
if (st & FLASH_FSTATR_OTERR) return FLASH_ERR_OT;
119+
120+
return FLASH_OK;
121+
122+
}
107123
#ifdef DEBUG_UART
108124

109125
#ifndef DEBUG_UART_SCI
@@ -210,7 +226,6 @@ void uart_write(const char* buf, unsigned int sz)
210226
void hal_clk_init(void)
211227
{
212228
uint32_t reg, i;
213-
uint16_t stc;
214229
uint8_t cksel = CFG_CKSEL;
215230

216231
PROTECT_OFF(); /* write protect off */
@@ -521,16 +536,8 @@ int hal_flash_init(void)
521536
/* write up to 128 bytes at a time */
522537
#define FLASH_FACI_CODE_BLOCK_SZ \
523538
(FLASH_FACI_CMD_PROGRAM_CODE_LENGTH * FLASH_FACI_CMD_PROGRAM_DATA_LENGTH)
524-
#define FLASH_OK 0
525-
#define FLASH_ERR_ALIGN -1
526-
#define FLASH_ERR_PRG -2
527-
#define FLASH_ERR_ILGL -3
528-
#define FLASH_ERR_ERS -4
529539
#ifdef __CCRX__
530540
#pragma section FRAM
531-
#define MEMCPY ram_memcpy
532-
#else
533-
#define MEMCPY memcpy
534541
#endif
535542
int RAMFUNCTION hal_flash_write(uint32_t addr, const uint8_t *data, int len)
536543
{
@@ -540,18 +547,19 @@ int RAMFUNCTION hal_flash_write(uint32_t addr, const uint8_t *data, int len)
540547
uint32_t block_base;
541548
uint32_t offset;
542549
int write_size;
550+
int ret;
543551

544552
while (len > 0) {
545553
/* Align address to 128-byte boundary */
546554
block_base = addr & ~(FLASH_FACI_CODE_BLOCK_SZ - 1);
547555
offset = addr - block_base;
548556

549-
MEMCPY(codeblock, (uint8_t*)block_base, FLASH_FACI_CODE_BLOCK_SZ);
557+
XMEMCPY(codeblock, (uint8_t*)block_base, FLASH_FACI_CODE_BLOCK_SZ);
550558
write_size = FLASH_FACI_CODE_BLOCK_SZ - offset;
551559
if (write_size > len)
552560
write_size = len;
553561

554-
MEMCPY(&codeblock[offset], data, write_size);
562+
XMEMCPY(&codeblock[offset], data, write_size);
555563
data16 = (uint16_t*)codeblock;
556564

557565

@@ -572,14 +580,8 @@ int RAMFUNCTION hal_flash_write(uint32_t addr, const uint8_t *data, int len)
572580

573581
/* Wait for FCU operation to complete */
574582
while ((FLASH_FSTATR & FLASH_FSTATR_FRDY) == 0);
575-
if (FLASH_FSTATR & FLASH_FSTATR_ILGLERR) {
576-
return FLASH_ERR_ILGL;
577-
}
578-
if (FLASH_FSTATR & FLASH_FSTATR_PRGERR) {
579-
return FLASH_ERR_PRG;
580-
}
581-
if (FLASH_FSTATR & FLASH_FSTATR_ERSERR) {
582-
return FLASH_ERR_PRG;
583+
if ((ret = flash_check_error()) != FLASH_OK) {
584+
return ret;
583585
}
584586
len -= write_size;
585587
addr += write_size;
@@ -621,7 +623,6 @@ int RAMFUNCTION hal_flash_erase(uint32_t address, int len)
621623

622624
static int RAMFUNCTION hal_flash_write_faw(uint32_t faw)
623625
{
624-
volatile uint8_t* cmdArea = (volatile uint8_t*)FLASH_FACI_CMD_AREA;
625626

626627
#ifndef BIG_ENDIAN_ORDER
627628
#if defined(__CCRX__)
@@ -692,6 +693,6 @@ void* hal_get_primary_address(void)
692693

693694
void* hal_get_update_address(void)
694695
{
695-
return (void*)WOLFBOOT_PARTITION_UPDATE_ADDRESS;
696+
return (void*)(uintptr_t)WOLFBOOT_PARTITION_UPDATE_ADDRESS;
696697
}
697698
#endif

hal/renesas-rx.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,4 +411,15 @@ void hal_delay_us(uint32_t us);
411411
#define ICU_PIBR(x) (*(volatile uint8_t *)(SYSTEM_BASE + 0x7700 + (x)))
412412
#define ICU_PIAR(x) (*(volatile uint8_t *)(SYSTEM_BASE + 0x7900 + (x)))
413413

414+
typedef enum {
415+
FLASH_ERR_ILGL = -7,
416+
FLASH_ERR_PRG = -6,
417+
FLASH_ERR_ERS = -5,
418+
FLASH_ERR_FLWE = -4,
419+
FLASH_ERR_FESET = -3,
420+
FLASH_ERR_SEC = -2,
421+
FLASH_ERR_OT = -1,
422+
FLASH_ERR_UNKNOWN = -99,
423+
FLASH_OK = 0
424+
} flash_err_t;
414425
#endif /* !_WOLFBOOT_RENESAS_RX_H_ */

src/string.c

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#endif
2828

2929
#include <stddef.h>
30-
#ifndef TARGET_library
30+
#if !defined(TARGET_library) && !defined(__CCRX__)
3131
#include <string.h>
3232
#else
3333
size_t strlen(const char *s); /* forward declaration */
@@ -40,7 +40,7 @@ size_t strlen(const char *s); /* forward declaration */
4040
#endif
4141
#endif
4242

43-
#if !defined(__IAR_SYSTEMS_ICC__) && !defined(TARGET_X86_64_EFI)
43+
#if !defined(__IAR_SYSTEMS_ICC__) && !defined(TARGET_X86_64_EFI) && !defined(__CCRX__)
4444
/* for RAMFUNCTION */
4545
#include "image.h"
4646
#endif
@@ -76,7 +76,6 @@ int isalpha(int c)
7676
return (isupper(c) || islower(c));
7777
}
7878

79-
#if !defined(__CCRX__) /* Renesas CCRX */
8079
#if !defined(__IAR_SYSTEMS_ICC__) && !defined(TARGET_X86_64_EFI)
8180
void *memset(void *s, int c, size_t n)
8281
{
@@ -115,7 +114,6 @@ int strcmp(const char *s1, const char *s2)
115114

116115
return diff;
117116
}
118-
#endif /* Renesas CCRX */
119117

120118
int strcasecmp(const char *s1, const char *s2)
121119
{
@@ -153,7 +151,6 @@ int strncasecmp(const char *s1, const char *s2, size_t n)
153151
return diff;
154152
}
155153

156-
#if !defined(__CCRX__) /* Renesas CCRX */
157154
char *strncat(char *dest, const char *src, size_t n)
158155
{
159156
size_t i = 0;
@@ -240,11 +237,8 @@ void* memchr(void const *s, int c_in, size_t n)
240237
}
241238
return NULL;
242239
}
243-
244-
#endif /* __CCRX__ Renesas CCRX */
245240
#endif /* !BUILD_LOADER_STAGE1 || (PRINTF_ENABLED && DEBUG_UART) */
246241

247-
#if !defined(__CCRX__) /* Renesas CCRX */
248242
#if !(defined(BUILD_LOADER_STAGE1) && defined(ARCH_PPC)) || defined(DEBUG_UART)
249243
size_t strlen(const char *s)
250244
{
@@ -256,15 +250,14 @@ size_t strlen(const char *s)
256250
return i;
257251
}
258252
#endif
259-
#endif /* CCRX */
253+
260254
#if !defined(__IAR_SYSTEMS_ICC__) && !defined(TARGET_X86_64_EFI)
261255
/* some of the hal_flash_ functions need this during updates */
262256
#ifdef __CCRX__
263-
#pragma section FRAM
264-
void RAMFUNCTION *ram_memcpy(void *dst, const void *src, size_t n)
265-
#else
266-
void RAMFUNCTION *memcpy(void *dst, const void *src, size_t n)
257+
#define RAMFUNCTION
258+
#pragma section FRAM
267259
#endif
260+
void RAMFUNCTION *memcpy(void *dst, const void *src, size_t n)
268261
{
269262
size_t i;
270263
const char *s = (const char *)src;

0 commit comments

Comments
 (0)