diff --git a/demos/STM32/RT-STM32L476-DISCOVERY-SB_CLIENT/Makefile b/demos/STM32/RT-STM32L476-DISCOVERY-SB_CLIENT/Makefile index f58158437..b19f9ed5b 100644 --- a/demos/STM32/RT-STM32L476-DISCOVERY-SB_CLIENT/Makefile +++ b/demos/STM32/RT-STM32L476-DISCOVERY-SB_CLIENT/Makefile @@ -121,6 +121,7 @@ LDSCRIPT= ./sandbox.ld # setting. CSRC = $(ALLCSRC) \ $(TESTSRC) \ + $(CHIBIOS)/os/sb/various/syscalls.c \ main.c # C++ sources that can be compiled in ARM or THUMB mode depending on the global diff --git a/demos/STM32/RT-STM32L476-DISCOVERY-SB_CLIENT/main.c b/demos/STM32/RT-STM32L476-DISCOVERY-SB_CLIENT/main.c index 08c24333f..971985e65 100644 --- a/demos/STM32/RT-STM32L476-DISCOVERY-SB_CLIENT/main.c +++ b/demos/STM32/RT-STM32L476-DISCOVERY-SB_CLIENT/main.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "sbuser.h" @@ -41,7 +42,8 @@ int main(void) { #endif while (true) { msg_t msg = sbMsgWait(); - sbFileWrite(1U, (const uint8_t *)"Hello World!!\r\n", 15U); + printf("Hello World (%u)!!\r\n", (unsigned)msg); +// sbFileWrite(1U, (const uint8_t *)"Hello World!!\r\n", 15U); sbMsgReply(msg); // sbSleepMilliseconds(500); } diff --git a/demos/STM32/RT-STM32L476-DISCOVERY-SB_CLIENT/sandbox.ld b/demos/STM32/RT-STM32L476-DISCOVERY-SB_CLIENT/sandbox.ld index ebd74474a..3db505c1d 100644 --- a/demos/STM32/RT-STM32L476-DISCOVERY-SB_CLIENT/sandbox.ld +++ b/demos/STM32/RT-STM32L476-DISCOVERY-SB_CLIENT/sandbox.ld @@ -19,7 +19,7 @@ */ MEMORY { - flash0 : org = 0x080FC000, len = 16k + flash0 : org = 0x080F8000, len = 32k ram0 : org = 0x20017000, len = 4k } diff --git a/demos/STM32/RT-STM32L476-DISCOVERY-SB_HOST/STM32L476xG_SB.ld b/demos/STM32/RT-STM32L476-DISCOVERY-SB_HOST/STM32L476xG_SB.ld index 84c062c0c..d966b78a2 100644 --- a/demos/STM32/RT-STM32L476-DISCOVERY-SB_HOST/STM32L476xG_SB.ld +++ b/demos/STM32/RT-STM32L476-DISCOVERY-SB_HOST/STM32L476xG_SB.ld @@ -19,14 +19,14 @@ */ MEMORY { - flash0 : org = 0x08000000, len = 1M - 16k + flash0 : org = 0x08000000, len = 1M - 32k flash1 : org = 0x00000000, len = 0 flash2 : org = 0x00000000, len = 0 flash3 : org = 0x00000000, len = 0 flash4 : org = 0x00000000, len = 0 flash5 : org = 0x00000000, len = 0 flash6 : org = 0x00000000, len = 0 - flash7 : org = 0x08000000 + 1M - 16k, len = 16k + flash7 : org = 0x08000000 + 1M - 32k, len = 32k ram0 : org = 0x20000000, len = 96k - 4k ram1 : org = 0x00000000, len = 0 ram2 : org = 0x00000000, len = 0 diff --git a/demos/STM32/RT-STM32L476-DISCOVERY-SB_HOST/debug/RT-STM32L476-DISCOVERY-SB_HOST (OpenOCD, Flash and Run).launch b/demos/STM32/RT-STM32L476-DISCOVERY-SB_HOST/debug/RT-STM32L476-DISCOVERY-SB_HOST (OpenOCD, Flash and Run).launch index 4c94ad2ac..067183753 100644 --- a/demos/STM32/RT-STM32L476-DISCOVERY-SB_HOST/debug/RT-STM32L476-DISCOVERY-SB_HOST (OpenOCD, Flash and Run).launch +++ b/demos/STM32/RT-STM32L476-DISCOVERY-SB_HOST/debug/RT-STM32L476-DISCOVERY-SB_HOST (OpenOCD, Flash and Run).launch @@ -33,7 +33,7 @@ - + diff --git a/demos/STM32/RT-STM32L476-DISCOVERY-SB_HOST/main.c b/demos/STM32/RT-STM32L476-DISCOVERY-SB_HOST/main.c index 92083aed7..342a897b8 100644 --- a/demos/STM32/RT-STM32L476-DISCOVERY-SB_HOST/main.c +++ b/demos/STM32/RT-STM32L476-DISCOVERY-SB_HOST/main.c @@ -30,6 +30,7 @@ sb_class_t sbx1; */ static THD_WORKING_AREA(waThread1, 128); static THD_FUNCTION(Thread1, arg) { + unsigned i = 1U; (void)arg; chRegSetThreadName("blinker"); @@ -42,7 +43,8 @@ static THD_FUNCTION(Thread1, arg) { chThdSleepMilliseconds(50); palSetLine(LINE_LED_RED); chThdSleepMilliseconds(200); - (void) sbSendMessage(&sbx1, 0xF00F55AAU); + (void) sbSendMessage(&sbx1, (msg_t)i); + i++; } } @@ -75,7 +77,7 @@ static THD_FUNCTION(Unprivileged1, arg) { sb_config.r0_base, MPU_RASR_ATTR_AP_RO_RO | MPU_RASR_ATTR_CACHEABLE_WT_NWA | - MPU_RASR_SIZE_16K | + MPU_RASR_SIZE_32K | MPU_RASR_ENABLE); mpuConfigureRegion(MPU_REGION_1, sb_config.r1_base, diff --git a/os/sb/various/syscalls.c b/os/sb/various/syscalls.c new file mode 100644 index 000000000..8a3205769 --- /dev/null +++ b/os/sb/various/syscalls.c @@ -0,0 +1,117 @@ +/* + ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "sbuser.h" + +#define MAKERR(e) (-(int)(e)) + +__attribute__((used)) +int _close_r(struct _reent *r, int file) { + uint32_t err; + + err = sbFileClose((uint32_t)file); + if (SB_ERR_ISERROR(err)) { + __errno_r(r) = MAKERR(err); + return -1; + } + + return 0; +} + +__attribute__((used)) +int _write_r(struct _reent *r, int file, char * ptr, int len) { + uint32_t err; + + err = sbFileWrite((uint32_t)file, (const uint8_t *)ptr, (size_t)len); + if (SB_ERR_ISERROR(err)) { + __errno_r(r) = MAKERR(err); + return -1; + } + + return (int)err; +} + +__attribute__((used)) +int _read_r(struct _reent *r, int file, char * ptr, int len) { + uint32_t err; + + err = sbFileRead((uint32_t)file, (uint8_t *)ptr, (size_t)len); + if (SB_ERR_ISERROR(err)) { + __errno_r(r) = MAKERR(err); + return -1; + } + + return (int)err; +} + +__attribute__((used)) +int _lseek_r(struct _reent *r, int file, int ptr, int dir) { + uint32_t err; + + err = sbFileSeek((uint32_t)file, (uint32_t)ptr, (uint32_t)dir); + if (SB_ERR_ISERROR(err)) { + __errno_r(r) = MAKERR(err); + return -1; + } + + return (int)err; +} + +__attribute__((used)) +int _fstat_r(struct _reent *r, int file, struct stat * st) { + (void)r; + (void)file; + + memset(st, 0, sizeof(*st)); + st->st_mode = S_IFCHR; + return 0; +} + +__attribute__((used)) +int _isatty_r(struct _reent *r, int fd) { + (void)r; + (void)fd; + + return 1; +} + +__attribute__((used)) +caddr_t _sbrk_r(struct _reent *r, int incr) { + extern uint8_t __heap_end__, __heap_base__; + static uint8_t *p = &__heap_base__; + uint8_t *prevp; + + prevp = p; + if ((p + incr > &__heap_end__) || + (p + incr < &__heap_base__)) { + __errno_r(r) = ENOMEM; + return (caddr_t)-1; + } + + p += incr; + return (caddr_t)prevp; +} + +/*** EOF ***/