Hi Lwazi and Alan,
Seems like the attachment was stripped out of my last email by the
mailing-list. My patch looked like this:
diff --git a/nuttx/arch/arm/src/common/arm_initialize.c
b/nuttx/arch/arm/src/common/arm_initialize.c
index c5c43507..c73c94c6 100644
--- a/nuttx/arch/arm/src/common/arm_initialize.c
+++ b/nuttx/arch/arm/src/common/arm_initialize.c
@@ -90,6 +90,10 @@ static inline void arm_color_intstack(void)
*
****************************************************************************/
+#ifdef CONFIG_ARM_SEMIHOSTING_SYSLOG
+void setup_arm_semi_open_stdout(void);
+#endif
+
void up_initialize(void)
{
#if CONFIG_ARCH_INTERRUPTSTACK > 7
@@ -135,6 +139,10 @@ void up_initialize(void)
arm_serialinit();
#endif
+#ifdef CONFIG_ARM_SEMIHOSTING_SYSLOG
+ setup_arm_semi_open_stdout();
+#endif
+
/* Initialize the network */
arm_netinitialize();
diff --git a/nuttx/arch/arm/src/common/arm_semi_syslog.c
b/nuttx/arch/arm/src/common/arm_semi_syslog.c
index 702dbe35..17a20709 100644
--- a/nuttx/arch/arm/src/common/arm_semi_syslog.c
+++ b/nuttx/arch/arm/src/common/arm_semi_syslog.c
@@ -35,14 +35,38 @@
* Pre-processor Definitions
****************************************************************************/
+#define SEMI_SYSLOG_OPEN 0x01
#define SEMI_SYSLOG_WRITEC 0x03
#define SEMI_SYSLOG_WRITE0 0x04
+#define SEMI_SYSLOG_WRITE 0x05
#define SEMI_SYSLOG_READC 0x07
/****************************************************************************
* Public Functions
****************************************************************************/
+/****************************************************************************
+ * Name: arm_semi_open_stdout
+ ****************************************************************************/
+
+static int stdout_fd = -1;
+
+int arm_semi_open_stdout(void)
+{
+ int32_t params[3] = {
+ (int32_t)":tt",
+ 4, // Write
+ 3, // Length of ":tt"
+ };
+
+ return smh_call(SEMI_SYSLOG_OPEN, ¶ms[0]);
+}
+
+void setup_arm_semi_open_stdout(void)
+{
+ stdout_fd = arm_semi_open_stdout();
+}
+
/****************************************************************************
* Name: up_putc
****************************************************************************/
@@ -62,10 +86,20 @@ void up_putc(int ch)
void up_nputs(const char *str, size_t len)
{
- if (len == ~((size_t)0))
+ if (str[len - 1] == '\0')
{
smh_call(SEMI_SYSLOG_WRITE0, (char *)str);
}
+ else if (len > 1 && stdout_fd != -1)
+ {
+ int32_t params[3] = {
+ stdout_fd,
+ (int32_t)str,
+ len
+ };
+
+ smh_call(SEMI_SYSLOG_WRITE, ¶ms[0]);
+ }
else
{
while (len-- > 0)
I'm using WRITE (which requires opening a file) instead of WRITE0 here because
I wasn't receiving NULL-terminated strings from syslog buffer.
Lwazi, did you do anything else to get it to use 0-terminated string?
Jean
> On 16 Oct 2025, at 02:24, Alan C. Assis <[email protected]> wrote:
>
> Thank you Lwazi,
> I'll take a look after the Workshop.
>
> BR,
>
> Alan
>
> On Wed, Oct 15, 2025 at 12:18 AM Lwazi Dube <[email protected]> wrote:
>
>> Alan,
>> I have fixed the performance issue. It is fast now. I had to make 3
>> changes.
>>
>> 1)
>> CONFIG_SYSLOG_BUFFER=y
>>
>> 2)
>> diff --git a/drivers/syslog/syslog_channel.c
>> b/drivers/syslog/syslog_channel.c
>> index 6bd80e6f5a..d1e47b54cf 100644
>> --- a/drivers/syslog/syslog_channel.c
>> +++ b/drivers/syslog/syslog_channel.c
>> @@ -170,6 +170,7 @@ static const struct syslog_channel_ops_s
>> g_default_channel_ops =
>> syslog_default_putc,
>> syslog_default_putc,
>> NULL,
>> + syslog_default_write,
>> syslog_default_write
>> };
>>
>> 3)
>> diff --git a/arch/arm/src/common/arm_semi_syslog.c
>> b/arch/arm/src/common/arm_semi_syslog.c
>> index 702dbe35da..9fecac295d 100644
>> --- a/arch/arm/src/common/arm_semi_syslog.c
>> +++ b/arch/arm/src/common/arm_semi_syslog.c
>> @@ -62,16 +62,14 @@ void up_putc(int ch)
>>
>> void up_nputs(const char *str, size_t len)
>> {
>> - if (len == ~((size_t)0))
>> - {
>> +#ifdef CONFIG_SYSLOG_BUFFER
>> + *(char *)(str + len) = 0;
>> smh_call(SEMI_SYSLOG_WRITE0, (char *)str);
>> - }
>> - else
>> - {
>> +#else
>> while (len-- > 0)
>> {
>> up_putc(*str++);
>> }
>> - }
>> +#endif
>> }
>> #endif
>>