0

I am attempting to set up ARM-Semihosting to free up the use of the USB and Uart ports on my project. I am using the baremetal Wizio-Pico platform for Platformio. I've fought with it to the point where calling puts_raw() will print to the Debug Console. However, when I try to use puts() or printf() nothing is output. I've tried stepping through the program from a breakpoint on both puts() and printf() but it just moves to the sleep_ms call right below it. This makes me think that there is something wrong with the implementation of puts and printf when using the PICO_STDIO_SEMIHOSTING flag.

I am hoping to get printf working so that I don't have to change my code depending on the stdio method defined by the build flags.

Platformio.ini

[env]
platform = wizio-pico
framework = baremetal
board = raspberry-pi-pico
lib_compat_mode = off
lib_archive = false
;;lib_extra_dirs = "/lib"
build_src_filter = 
  +<*.h>
  +<App/main-${PIOENV}.cpp>
  +<App/main-${PIOENV}.c>
  +<Common/*.cpp>
  +<Common/*.c>

build_flags = 
  -D TARGET_RP2040 

board_build.boot= w25q080


[DEBUG]
upload_protocol = picoprobe
debug_tool = picoprobe
build_flags = -D DEBUG

[env:semihosting]
extends = DEBUG

;board_build.nano = disable

lib_deps=
  wiring

build_unflags =
    -lnosys
    --specs=nosys.specs

build_flags =
  ${env.build_flags}
  ${DEBUG.build_flags}
  -D PICO_STDIO_SEMIHOSTING
  -D PICO_STDIO_ENABLE_CRLF_SUPPORT=0
  -D LIB_PICO_PRINTF_PICO
  -l rdimon
  --specs=rdimon.specs

debug_extra_cmds =
  monitor arm semihosting enable
  monitor arm semihosting_fileio enable
  monitor reset halt
  monitor debug_level -2

main-semihosting.c

#include <stdio.h>
#include "pico/stdlib.h"
#include "pico/printf.h"


int main(){
    stdio_init_all();

    while(1) {
        puts_raw("yo"); // Works!
        puts("ya\n"); // Doesn't work
        printf("ye\n"); // Doesn't Work
        
        sleep_ms(1000);
    }
}
Dacoolinus
  • 388
  • 1
  • 10
  • what debugging have you done? following the system calls, how they are built into your binary, etc. – old_timer Jan 31 '23 at 01:50
  • @old_timer I put a breakpoint on both puts and printf and attempted to step through but instead of stepping into those functions it just skipped to the next instruction below. (puts straight to printf, printf straight to sleep_ms). – Dacoolinus Feb 01 '23 at 21:23

0 Answers0