Hi Jean,

Could you please double check my defconfig for stm32f4discovery (a create a
config using the nsh as base removing USART support and enabling
SEMIHOSTING SYSLOG):

$ diff -Nau boards/arm/stm32/stm32f4discovery/configs/nsh/defconfig
defconfig
--- boards/arm/stm32/stm32f4discovery/configs/nsh/defconfig 2025-04-19
12:44:26.547700216 -0300
+++ defconfig 2025-10-11 16:27:34.782188509 -0300
@@ -6,8 +6,10 @@
 # modifications.
 #
 # CONFIG_ARCH_FPU is not set
+# CONFIG_DEV_CONSOLE is not set
 # CONFIG_NSH_ARGCAT is not set
 # CONFIG_NSH_CMDOPT_HEXDUMP is not set
+# CONFIG_SERIAL is not set
 CONFIG_ARCH="arm"
 CONFIG_ARCH_BOARD="stm32f4discovery"
 CONFIG_ARCH_BOARD_STM32F4_DISCOVERY=y
@@ -16,6 +18,7 @@
 CONFIG_ARCH_CHIP_STM32=y
 CONFIG_ARCH_CHIP_STM32F407VG=y
 CONFIG_ARCH_STACKDUMP=y
+CONFIG_ARM_SEMIHOSTING_SYSLOG=y
 CONFIG_BOARD_LATE_INITIALIZE=y
 CONFIG_BOARD_LOOPSPERMSEC=16717
 CONFIG_BUILTIN=y
@@ -23,7 +26,6 @@
 CONFIG_FS_PROCFS=y
 CONFIG_HAVE_CXX=y
 CONFIG_HAVE_CXXINITIALIZE=y
-CONFIG_HOST_WINDOWS=y
 CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_INTELHEX_BINARY=y
 CONFIG_LINE_MAX=64
@@ -43,8 +45,4 @@
 CONFIG_STM32_JTAG_SW_ENABLE=y
 CONFIG_STM32_PWR=y
 CONFIG_STM32_SPI1=y
-CONFIG_STM32_USART2=y
 CONFIG_SYSTEM_NSH=y
-CONFIG_USART2_RXBUFSIZE=128
-CONFIG_USART2_SERIAL_CONSOLE=y
-CONFIG_USART2_TXBUFSIZE=128

The final firmware is working fine on gdb, but I cannot see any log commit
from openocd or gdb.

OpenOCD side:

$ sudo /usr/bin/openocd -f interface/stlink.cfg -f target/stm32f4x.cfg -c
init
[sudo] password for alan:
Open On-Chip Debugger 0.12.0
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "hla_swd". To
override use 'transport select <transport>'.
Info : The selected transport took over low-level target control. The
results might differ compared to plain JTAG/SWD
Info : clock speed 2000 kHz
Info : STLINK V2J14S0 (API v2) VID:PID 0483:3748
Info : Target voltage: 3.203670
Info : [stm32f4x.cpu] Cortex-M4 r0p1 processor detected
Info : [stm32f4x.cpu] target has 6 breakpoints, 4 watchpoints
Info : starting gdb server for stm32f4x.cpu on 3333
Info : Listening on port 3333 for gdb connections
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
[stm32f4x.cpu] halted due to breakpoint, current mode: Thread
xPSR: 0x81000000 pc: 0x0800449e msp: 0x20001728
Info : accepting 'gdb' connection on tcp/3333
Info : device id = 0x10036413
Info : flash size = 1024 KiB
Info : flash size = 512 bytes
[stm32f4x.cpu] halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x080004fe msp: 0x20001750
Info : dropped 'gdb' connection
^Cshutdown command invoked


GDB:
$ gdb-multiarch nuttx
GNU gdb (Ubuntu 15.0.50.20240403-0ubuntu1) 15.0.50.20240403-git
...
Reading symbols from nuttx...

(gdb) target extended-remote 127.0.0.1:3333
Remote debugging using 127.0.0.1:3333
0x0800449e in up_idle ()

(gdb) monitor reset halt
[stm32f4x.cpu] halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x080004fe msp: 0x20001750

(gdb) monitor arm semihosting enable
semihosting is enabled

(gdb) monitor arm semihosting_fileio enable
semihosting fileio is enabled

(gdb) c
Continuing.
^C
Program received signal SIGINT, Interrupt.
0x0800449e in up_idle ()
(gdb) quit
A debugging session is active.

Please let me know if you followed the same steps.

BR,

Alan

On Sat, Oct 11, 2025 at 4:18 PM Alan C. Assis <[email protected]> wrote:

> While trying to create the documentation to semihosting syslog I disabled
> the STM32 USART2 driver to avoid the system using the up_putc() from
> stm32_serial.c.
>
> But the arch/arm/src/stm32/Make.defs it adding many source files even when
> the peripheral is not enabled:
>
> CHIP_CSRCS  = stm32_allocateheap.c stm32_start.c stm32_rcc.c stm32_lse.c
> CHIP_CSRCS += stm32_lsi.c stm32_gpio.c stm32_exti_gpio.c stm32_flash.c
> CHIP_CSRCS += stm32_irq.c stm32_lowputc.c
> CHIP_CSRCS += stm32_serial.c stm32_spi.c stm32_i2s.c stm32_sdio.c
> stm32_tim.c
> CHIP_CSRCS += stm32_waste.c stm32_ccm.c stm32_uid.c stm32_capture.c
> CHIP_CSRCS += stm32_dfumode.c
>
> The stm32_serial.c only should be compiled when CONFIG_STM32_USART is
> enabled.
>
> I submitted a PR to fix it and the up_nputs() issue and Lwazi commented
> before:
>
> https://github.com/apache/nuttx/pull/17187
>
> BR,
>
> Alan
>
> On Fri, Oct 10, 2025 at 9:49 AM Jean Thomas <[email protected]>
> wrote:
>
>> Hi Lwazi,
>>
>> I've got semihosting syslog working, thanks to your precious insight.
>>
>> I had to add this into my defconfig:
>>  - CONFIG_ARM_SEMIHOSTING_SYSLOG=y
>>  - CONFIG_DEV_CONSOLE=n
>>  - CONFIG_SYSLOG_DEFAULT=y
>>
>> And remove:
>>  - CONFIG_UART0_SERIAL_CONSOLE=y
>>
>> I also had to enclose up_putc in rp2040_serial.c like you did in
>> uart_16550, and also modified arm_lowputc to direct output to up_putc.
>>
>> Best regards,
>> Jean.
>>
>> > On 9 Oct 2025, at 22:45, Lwazi Dube <[email protected]> wrote:
>> >
>> > I just tried this on an am335x board (armv7a) and got some logs after
>> the
>> > gdb prompt.
>> >
>> > 1) I am using openocd 0.12.0
>> >
>> > 2) The board's uart driver is uart_16550. I exclude (16550) up_putc so
>> that
>> > the other one in "arm_semi_syslog.c" is used.
>> >
>> > #ifndef CONFIG_ARM_SEMIHOSTING_SYSLOG <-----
>> > #ifdef HAVE_16550_CONSOLE
>> > void up_putc(int ch)
>> > {
>> >  FAR struct u16550_s *priv = (FAR struct u16550_s *)CONSOLE_DEV.priv;
>> >
>> >  u16550_putc(priv, ch);
>> > }
>> > #endif
>> > #endif
>> >
>> > 3) Fix multiple definition error in "arm_nputs.c" ...
>> >
>> > #ifndef CONFIG_ARM_SEMIHOSTING_SYSLOG <----
>> > void up_nputs(const char *str, size_t len)
>> > {
>> >  while (len-- > 0 && *str)
>> >    {
>> >      up_putc(*str++);
>> >    }
>> > }
>> > #endif
>> >
>> > 4)
>> > [*] Enable Debug Features
>> >         *** Debug SYSLOG Output Controls ***
>> >   [*]   Enable Error Output
>> >   [*]     Enable Warnings Output
>> >   [*]       Enable Informational Debug Output
>> >
>> >  [*]   Memory Manager Debug Features
>> >   [*]     Memory Manager Error Output
>> >   [*]     Memory Manager Warnings Output
>> >   [*]     Memory Manager Informational Output
>> >
>> > 5) Load and run using gdb
>> >
>> > adapter speed: 16000 kHz
>> > core state: ARM
>> > semihosting is enabled
>> > semihosting fileio is enabled
>> > (gdb) load
>> > Loading section .text, size 0x205c4 lma 0x8a000000
>> > Loading section .ARM.exidx, size 0x8 lma 0x8a0205c4
>> > Loading section .data, size 0x394 lma 0x8a0205cc
>> > Start address 0x8a0002e0, load size 133472
>> > Transfer rate: 210 KB/sec, 12133 bytes/write.
>> > (gdb) c
>> > Continuing.
>> > mm_initialize: Heap: name=Umem, start=0x8a0229e4 size=368956956
>> > mm_addregion: Region 1: base=0x8a022b44 size=368956600
>> > mm_malloc: Allocated 0x8a022b58, size 72
>> > mm_malloc: Allocated 0x8a022ba0, size 40
>> > mm_malloc: Allocated 0x8a022bc8, size 48
>> > mm_malloc: Allocated 0x8a022bf8, size 48
>> > mm_malloc: Allocated 0x8a022c28, size 48
>> > mm_malloc: Allocated 0x8a022c58, size 48
>> > mm_malloc: Allocated 0x8a022c88, size 48
>> > mm_malloc: Allocated 0x8a022cb8, size 48
>> > mm_malloc: Allocated 0x8a022ce8, size 1000
>> > mm_malloc: Allocated 0x8a0230d0, size 2056
>> >
>> > Program stopped.
>> > _vector_start () at armv7-a/arm_vectortab.S:68
>> > 68              ldr             pc, .Lsvchandler                /* 0x08:
>> > Software interrupt */
>> > (gdb)
>> >
>> >
>> > On Wed, 8 Oct 2025 at 14:00, Adam Feuer <[email protected]> wrote:
>> >
>> >> Thanks Jean and Alan. At work right now, and I also don't remember
>> exactly
>> >> what I did for that– I'll need to reply privately.
>> >>
>> >> Yes, Alan, if I do remember what I did I would be grateful if you did
>> >> update the docs.
>> >>
>> >> -adam
>> >>
>> >> On Wed, Oct 8, 2025 at 10:06 AM Alan C. Assis <[email protected]>
>> wrote:
>> >>
>> >>> Hi Jean,
>> >>>
>> >>> Looking at boards/ seems like the semihost for file system is the most
>> >>> common usage, but yes there is one and only one board with SEMIHOST
>> >> SYSLOG
>> >>> support, that you found.
>> >>>
>> >>> According to git blame this support was added by Adam Feuer (CC here),
>> >> but
>> >>> there is no Documentation/ about it.
>> >>>
>> >>> Adam, do you remember how to test it? If you can share details here I
>> >> will
>> >>> expand the semihost documentation to include syslog support.
>> >>>
>> >>> BR,
>> >>>
>> >>> Alan
>> >>>
>> >>> On Wed, Oct 8, 2025 at 1:41 PM Jean Thomas <[email protected]>
>> >> wrote:
>> >>>
>> >>>> Hi everyone,
>> >>>>
>> >>>> I've been trying to get ARM semihosting syslog working on a RP2040
>> board
>> >>>> for a little while (debugged using Pi's debugprobe). I added this
>> into
>> >> my
>> >>>> defconfig:
>> >>>>
>> >>>> CONFIG_ARM_SEMIHOSTING_SYSLOG=y
>> >>>> CONFIG_SYSLOG_CHARDEV=y
>> >>>>
>> >>>> (inspired by sama5d3-xplained's ethernet-over-usb-2-high-speed
>> >> defconfig)
>> >>>>
>> >>>> and this in my OpenOCD script:
>> >>>>
>> >>>> monitor arm semihosting enable
>> >>>> monitor arm semihosting_fileio enable
>> >>>>
>> >>>> Syslog disappears from the UART console, but doesn't appear in
>> >> OpenOCD...
>> >>>> Am I doing something wrong? Does someone have an example of a working
>> >>>> syslog over ARM semihosting example? Is there an easy way to debug
>> >> what's
>> >>>> going on?
>> >>>>
>> >>>> Cheers,
>> >>>> Jean
>> >>>
>> >>>
>> >>
>> >> --
>> >> Adam Feuer <[email protected]>
>> >>
>>
>>

Reply via email to