Skip to content

Commit 54356a7

Browse files
committed
minor-update
1 parent 82880ee commit 54356a7

File tree

7 files changed

+47
-55
lines changed

7 files changed

+47
-55
lines changed

hw/bsp/board.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,12 @@
4444

4545
// If using SES IDE, use the Syscalls/SEGGER_RTT_Syscalls_SES.c instead
4646
#if !(defined __SES_ARM) && !(defined __SES_RISCV) && !(defined __CROSSWORKS_ARM)
47-
4847
#include "SEGGER_RTT.h"
4948

50-
TU_ATTR_USED int sys_write(int fhdl, const void *buf, size_t count) {
49+
TU_ATTR_USED int sys_write(int fhdl, const char *buf, size_t count) {
5150
(void) fhdl;
5251
SEGGER_RTT_Write(0, (const char *) buf, (int) count);
53-
return count;
52+
return (int) count;
5453
}
5554

5655
TU_ATTR_USED int sys_read(int fhdl, char *buf, size_t count) {
@@ -63,10 +62,9 @@ TU_ATTR_USED int sys_read(int fhdl, char *buf, size_t count) {
6362

6463
#elif defined(LOGGER_SWO)
6564
// Logging with SWO for ARM Cortex
66-
6765
#include "board_mcu.h"
6866

69-
TU_ATTR_USED int sys_write (int fhdl, const void *buf, size_t count) {
67+
TU_ATTR_USED int sys_write (int fhdl, const char *buf, size_t count) {
7068
(void) fhdl;
7169
uint8_t const* buf8 = (uint8_t const*) buf;
7270

@@ -87,7 +85,7 @@ TU_ATTR_USED int sys_read (int fhdl, char *buf, size_t count) {
8785
#else
8886

8987
// Default logging with on-board UART
90-
TU_ATTR_USED int sys_write (int fhdl, const void *buf, size_t count) {
88+
TU_ATTR_USED int sys_write (int fhdl, const char *buf, size_t count) {
9189
(void) fhdl;
9290
return board_uart_write(buf, (int) count);
9391
}
@@ -100,6 +98,16 @@ TU_ATTR_USED int sys_read (int fhdl, char *buf, size_t count) {
10098

10199
#endif
102100

101+
//TU_ATTR_USED int _close(int fhdl) {
102+
// (void) fhdl;
103+
// return 0;
104+
//}
105+
106+
//TU_ATTR_USED int _fstat(int file, struct stat *st) {
107+
// memset(st, 0, sizeof(*st));
108+
// st->st_mode = S_IFCHR;
109+
//}
110+
103111
int board_getchar(void) {
104112
char c;
105113
return (sys_read(0, &c, 1) > 0) ? (int) c : (-1);

hw/bsp/family_support.cmake

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,9 @@ function(family_configure_common TARGET RTOS)
201201
# Generate linker map file
202202
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
203203
target_link_options(${TARGET} PUBLIC "LINKER:-Map=$<TARGET_FILE:${TARGET}>.map")
204+
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 12.0)
205+
target_link_options(${TARGET} PUBLIC "LINKER:--no-warn-rwx-segments")
206+
endif ()
204207
endif()
205208

206209
# ETM Trace option
@@ -289,13 +292,11 @@ function(family_configure_device_example TARGET RTOS)
289292
family_configure_example(${TARGET} ${RTOS})
290293
endfunction()
291294

292-
293295
# Configure host example with RTOS
294296
function(family_configure_host_example TARGET RTOS)
295297
family_configure_example(${TARGET} ${RTOS})
296298
endfunction()
297299

298-
299300
# Configure host + device example with RTOS
300301
function(family_configure_dual_usb_example TARGET RTOS)
301302
family_configure_example(${TARGET} ${RTOS})

hw/bsp/nrf/family.cmake

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,7 @@ function(add_board_target BOARD_TARGET)
8484
# linker file
8585
"LINKER:--script=${LD_FILE_GNU}"
8686
-L${NRFX_DIR}/mdk
87-
# nanolib
88-
--specs=nosys.specs
89-
--specs=nano.specs
87+
--specs=nosys.specs --specs=nano.specs
9088
)
9189
elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
9290
target_link_options(${BOARD_TARGET} PUBLIC

hw/bsp/nrf/family.mk

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ CFLAGS += \
1212
-DCFG_TUSB_MCU=OPT_MCU_NRF5X \
1313
-DCONFIG_GPIO_AS_PINRESET
1414

15+
#CFLAGS += -nostdlib
16+
#CFLAGS += -D__START=main
17+
1518
# suppress warning caused by vendor mcu driver
1619
CFLAGS += \
1720
-Wno-error=undef \

hw/bsp/stm32h7/family.cmake

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,7 @@ function(add_board_target BOARD_TARGET)
6666
target_link_options(${BOARD_TARGET} PUBLIC
6767
"LINKER:--script=${LD_FILE_GNU}"
6868
-nostartfiles
69-
# nanolib
70-
--specs=nosys.specs
71-
--specs=nano.specs
69+
--specs=nosys.specs --specs=nano.specs
7270
)
7371
elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
7472
target_link_options(${BOARD_TARGET} PUBLIC

src/osal/osal_none.h

Lines changed: 24 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424
* This file is part of the TinyUSB stack.
2525
*/
2626

27-
#ifndef _TUSB_OSAL_NONE_H_
28-
#define _TUSB_OSAL_NONE_H_
27+
#ifndef TUSB_OSAL_NONE_H_
28+
#define TUSB_OSAL_NONE_H_
2929

3030
#ifdef __cplusplus
31-
extern "C" {
31+
extern "C" {
3232
#endif
3333

3434
//--------------------------------------------------------------------+
@@ -43,39 +43,34 @@ TU_ATTR_WEAK void osal_task_delay(uint32_t msec);
4343
//--------------------------------------------------------------------+
4444
// Binary Semaphore API
4545
//--------------------------------------------------------------------+
46-
typedef struct
47-
{
46+
typedef struct {
4847
volatile uint16_t count;
49-
}osal_semaphore_def_t;
48+
} osal_semaphore_def_t;
5049

5150
typedef osal_semaphore_def_t* osal_semaphore_t;
5251

53-
TU_ATTR_ALWAYS_INLINE static inline osal_semaphore_t osal_semaphore_create(osal_semaphore_def_t* semdef)
54-
{
52+
TU_ATTR_ALWAYS_INLINE static inline osal_semaphore_t osal_semaphore_create(osal_semaphore_def_t* semdef) {
5553
semdef->count = 0;
5654
return semdef;
5755
}
5856

59-
TU_ATTR_ALWAYS_INLINE static inline bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr)
60-
{
57+
TU_ATTR_ALWAYS_INLINE static inline bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr) {
6158
(void) in_isr;
6259
sem_hdl->count++;
6360
return true;
6461
}
6562

6663
// TODO blocking for now
67-
TU_ATTR_ALWAYS_INLINE static inline bool osal_semaphore_wait (osal_semaphore_t sem_hdl, uint32_t msec)
68-
{
64+
TU_ATTR_ALWAYS_INLINE static inline bool osal_semaphore_wait(osal_semaphore_t sem_hdl, uint32_t msec) {
6965
(void) msec;
7066

71-
while (sem_hdl->count == 0) { }
67+
while (sem_hdl->count == 0) {}
7268
sem_hdl->count--;
7369

7470
return true;
7571
}
7672

77-
TU_ATTR_ALWAYS_INLINE static inline void osal_semaphore_reset(osal_semaphore_t sem_hdl)
78-
{
73+
TU_ATTR_ALWAYS_INLINE static inline void osal_semaphore_reset(osal_semaphore_t sem_hdl) {
7974
sem_hdl->count = 0;
8075
}
8176

@@ -90,19 +85,16 @@ typedef osal_semaphore_t osal_mutex_t;
9085
// Note: multiple cores MCUs usually do provide IPC API for mutex
9186
// or we can use std atomic function
9287

93-
TU_ATTR_ALWAYS_INLINE static inline osal_mutex_t osal_mutex_create(osal_mutex_def_t* mdef)
94-
{
88+
TU_ATTR_ALWAYS_INLINE static inline osal_mutex_t osal_mutex_create(osal_mutex_def_t* mdef) {
9589
mdef->count = 1;
9690
return mdef;
9791
}
9892

99-
TU_ATTR_ALWAYS_INLINE static inline bool osal_mutex_lock (osal_mutex_t mutex_hdl, uint32_t msec)
100-
{
93+
TU_ATTR_ALWAYS_INLINE static inline bool osal_mutex_lock (osal_mutex_t mutex_hdl, uint32_t msec) {
10194
return osal_semaphore_wait(mutex_hdl, msec);
10295
}
10396

104-
TU_ATTR_ALWAYS_INLINE static inline bool osal_mutex_unlock(osal_mutex_t mutex_hdl)
105-
{
97+
TU_ATTR_ALWAYS_INLINE static inline bool osal_mutex_unlock(osal_mutex_t mutex_hdl) {
10698
return osal_semaphore_post(mutex_hdl, false);
10799
}
108100

@@ -119,11 +111,10 @@ TU_ATTR_ALWAYS_INLINE static inline bool osal_mutex_unlock(osal_mutex_t mutex_hd
119111
//--------------------------------------------------------------------+
120112
#include "common/tusb_fifo.h"
121113

122-
typedef struct
123-
{
124-
void (*interrupt_set)(bool);
114+
typedef struct {
115+
void (* interrupt_set)(bool);
125116
tu_fifo_t ff;
126-
}osal_queue_def_t;
117+
} osal_queue_def_t;
127118

128119
typedef osal_queue_def_t* osal_queue_t;
129120

@@ -136,27 +127,23 @@ typedef osal_queue_def_t* osal_queue_t;
136127
}
137128

138129
// lock queue by disable USB interrupt
139-
TU_ATTR_ALWAYS_INLINE static inline void _osal_q_lock(osal_queue_t qhdl)
140-
{
130+
TU_ATTR_ALWAYS_INLINE static inline void _osal_q_lock(osal_queue_t qhdl) {
141131
// disable dcd/hcd interrupt
142132
qhdl->interrupt_set(false);
143133
}
144134

145135
// unlock queue
146-
TU_ATTR_ALWAYS_INLINE static inline void _osal_q_unlock(osal_queue_t qhdl)
147-
{
136+
TU_ATTR_ALWAYS_INLINE static inline void _osal_q_unlock(osal_queue_t qhdl) {
148137
// enable dcd/hcd interrupt
149138
qhdl->interrupt_set(true);
150139
}
151140

152-
TU_ATTR_ALWAYS_INLINE static inline osal_queue_t osal_queue_create(osal_queue_def_t* qdef)
153-
{
141+
TU_ATTR_ALWAYS_INLINE static inline osal_queue_t osal_queue_create(osal_queue_def_t* qdef) {
154142
tu_fifo_clear(&qdef->ff);
155143
return (osal_queue_t) qdef;
156144
}
157145

158-
TU_ATTR_ALWAYS_INLINE static inline bool osal_queue_receive(osal_queue_t qhdl, void* data, uint32_t msec)
159-
{
146+
TU_ATTR_ALWAYS_INLINE static inline bool osal_queue_receive(osal_queue_t qhdl, void* data, uint32_t msec) {
160147
(void) msec; // not used, always behave as msec = 0
161148

162149
_osal_q_lock(qhdl);
@@ -166,8 +153,7 @@ TU_ATTR_ALWAYS_INLINE static inline bool osal_queue_receive(osal_queue_t qhdl, v
166153
return success;
167154
}
168155

169-
TU_ATTR_ALWAYS_INLINE static inline bool osal_queue_send(osal_queue_t qhdl, void const * data, bool in_isr)
170-
{
156+
TU_ATTR_ALWAYS_INLINE static inline bool osal_queue_send(osal_queue_t qhdl, void const* data, bool in_isr) {
171157
if (!in_isr) {
172158
_osal_q_lock(qhdl);
173159
}
@@ -179,19 +165,17 @@ TU_ATTR_ALWAYS_INLINE static inline bool osal_queue_send(osal_queue_t qhdl, void
179165
}
180166

181167
TU_ASSERT(success);
182-
183168
return success;
184169
}
185170

186-
TU_ATTR_ALWAYS_INLINE static inline bool osal_queue_empty(osal_queue_t qhdl)
187-
{
171+
TU_ATTR_ALWAYS_INLINE static inline bool osal_queue_empty(osal_queue_t qhdl) {
188172
// Skip queue lock/unlock since this function is primarily called
189173
// with interrupt disabled before going into low power mode
190174
return tu_fifo_empty(&qhdl->ff);
191175
}
192176

193177
#ifdef __cplusplus
194-
}
178+
}
195179
#endif
196180

197-
#endif /* _TUSB_OSAL_NONE_H_ */
181+
#endif

tools/cmake/toolchain/arm_gcc.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ list(APPEND TOOLCHAIN_COMMON_FLAGS
2929
-fno-strict-aliasing
3030
)
3131

32-
set(TOOLCHAIN_EXE_LINKER_FLAGS
32+
list(APPEND TOOLCHAIN_EXE_LINKER_FLAGS
3333
-Wl,--print-memory-usage
3434
-Wl,--gc-sections
3535
-Wl,--cref

0 commit comments

Comments
 (0)