• R/O
  • SSH
  • HTTPS

chibios: Commit


Commit MetaInfo

Revision12994 (tree)
Zeit2019-09-16 01:20:33
Autorgdisirio

Log Message

Added C library support in sandbox (newlib).

Ändern Zusammenfassung

Diff

--- trunk/demos/STM32/RT-STM32L476-DISCOVERY-SB_CLIENT/Makefile (revision 12993)
+++ trunk/demos/STM32/RT-STM32L476-DISCOVERY-SB_CLIENT/Makefile (revision 12994)
@@ -121,6 +121,7 @@
121121 # setting.
122122 CSRC = $(ALLCSRC) \
123123 $(TESTSRC) \
124+ $(CHIBIOS)/os/sb/various/syscalls.c \
124125 main.c
125126
126127 # C++ sources that can be compiled in ARM or THUMB mode depending on the global
--- trunk/demos/STM32/RT-STM32L476-DISCOVERY-SB_CLIENT/main.c (revision 12993)
+++ trunk/demos/STM32/RT-STM32L476-DISCOVERY-SB_CLIENT/main.c (revision 12994)
@@ -17,6 +17,7 @@
1717 #include <stdint.h>
1818 #include <stdbool.h>
1919 #include <stddef.h>
20+#include <stdio.h>
2021
2122 #include "sbuser.h"
2223
@@ -41,7 +42,8 @@
4142 #endif
4243 while (true) {
4344 msg_t msg = sbMsgWait();
44- sbFileWrite(1U, (const uint8_t *)"Hello World!!\r\n", 15U);
45+ printf("Hello World (%u)!!\r\n", (unsigned)msg);
46+// sbFileWrite(1U, (const uint8_t *)"Hello World!!\r\n", 15U);
4547 sbMsgReply(msg);
4648 // sbSleepMilliseconds(500);
4749 }
--- trunk/demos/STM32/RT-STM32L476-DISCOVERY-SB_HOST/main.c (revision 12993)
+++ trunk/demos/STM32/RT-STM32L476-DISCOVERY-SB_HOST/main.c (revision 12994)
@@ -30,6 +30,7 @@
3030 */
3131 static THD_WORKING_AREA(waThread1, 128);
3232 static THD_FUNCTION(Thread1, arg) {
33+ unsigned i = 1U;
3334
3435 (void)arg;
3536 chRegSetThreadName("blinker");
@@ -42,7 +43,8 @@
4243 chThdSleepMilliseconds(50);
4344 palSetLine(LINE_LED_RED);
4445 chThdSleepMilliseconds(200);
45- (void) sbSendMessage(&sbx1, 0xF00F55AAU);
46+ (void) sbSendMessage(&sbx1, (msg_t)i);
47+ i++;
4648 }
4749 }
4850
@@ -75,7 +77,7 @@
7577 sb_config.r0_base,
7678 MPU_RASR_ATTR_AP_RO_RO |
7779 MPU_RASR_ATTR_CACHEABLE_WT_NWA |
78- MPU_RASR_SIZE_16K |
80+ MPU_RASR_SIZE_32K |
7981 MPU_RASR_ENABLE);
8082 mpuConfigureRegion(MPU_REGION_1,
8183 sb_config.r1_base,
--- trunk/os/sb/various/syscalls.c (nonexistent)
+++ trunk/os/sb/various/syscalls.c (revision 12994)
@@ -0,0 +1,117 @@
1+/*
2+ ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
3+
4+ Licensed under the Apache License, Version 2.0 (the "License");
5+ you may not use this file except in compliance with the License.
6+ You may obtain a copy of the License at
7+
8+ http://www.apache.org/licenses/LICENSE-2.0
9+
10+ Unless required by applicable law or agreed to in writing, software
11+ distributed under the License is distributed on an "AS IS" BASIS,
12+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ See the License for the specific language governing permissions and
14+ limitations under the License.
15+*/
16+
17+#include <stdint.h>
18+#include <stdbool.h>
19+#include <stddef.h>
20+#include <stdlib.h>
21+#include <errno.h>
22+#include <string.h>
23+#include <sys/stat.h>
24+#include <sys/types.h>
25+
26+#include "sbuser.h"
27+
28+#define MAKERR(e) (-(int)(e))
29+
30+__attribute__((used))
31+int _close_r(struct _reent *r, int file) {
32+ uint32_t err;
33+
34+ err = sbFileClose((uint32_t)file);
35+ if (SB_ERR_ISERROR(err)) {
36+ __errno_r(r) = MAKERR(err);
37+ return -1;
38+ }
39+
40+ return 0;
41+}
42+
43+__attribute__((used))
44+int _write_r(struct _reent *r, int file, char * ptr, int len) {
45+ uint32_t err;
46+
47+ err = sbFileWrite((uint32_t)file, (const uint8_t *)ptr, (size_t)len);
48+ if (SB_ERR_ISERROR(err)) {
49+ __errno_r(r) = MAKERR(err);
50+ return -1;
51+ }
52+
53+ return (int)err;
54+}
55+
56+__attribute__((used))
57+int _read_r(struct _reent *r, int file, char * ptr, int len) {
58+ uint32_t err;
59+
60+ err = sbFileRead((uint32_t)file, (uint8_t *)ptr, (size_t)len);
61+ if (SB_ERR_ISERROR(err)) {
62+ __errno_r(r) = MAKERR(err);
63+ return -1;
64+ }
65+
66+ return (int)err;
67+}
68+
69+__attribute__((used))
70+int _lseek_r(struct _reent *r, int file, int ptr, int dir) {
71+ uint32_t err;
72+
73+ err = sbFileSeek((uint32_t)file, (uint32_t)ptr, (uint32_t)dir);
74+ if (SB_ERR_ISERROR(err)) {
75+ __errno_r(r) = MAKERR(err);
76+ return -1;
77+ }
78+
79+ return (int)err;
80+}
81+
82+__attribute__((used))
83+int _fstat_r(struct _reent *r, int file, struct stat * st) {
84+ (void)r;
85+ (void)file;
86+
87+ memset(st, 0, sizeof(*st));
88+ st->st_mode = S_IFCHR;
89+ return 0;
90+}
91+
92+__attribute__((used))
93+int _isatty_r(struct _reent *r, int fd) {
94+ (void)r;
95+ (void)fd;
96+
97+ return 1;
98+}
99+
100+__attribute__((used))
101+caddr_t _sbrk_r(struct _reent *r, int incr) {
102+ extern uint8_t __heap_end__, __heap_base__;
103+ static uint8_t *p = &__heap_base__;
104+ uint8_t *prevp;
105+
106+ prevp = p;
107+ if ((p + incr > &__heap_end__) ||
108+ (p + incr < &__heap_base__)) {
109+ __errno_r(r) = ENOMEM;
110+ return (caddr_t)-1;
111+ }
112+
113+ p += incr;
114+ return (caddr_t)prevp;
115+}
116+
117+/*** EOF ***/
Show on old repository browser