Freedom 300 arty a7 not able to read input

hi there,
I have an arty a7 100t board and my SDK is as follows:
riscv tool chain version: @gnu-mcu-eclipse/riscv-none-gcc@8.2.0-2.1.1
freedom-e-sdk version: GitHub - sifive/freedom-e-sdk at v20180402

the problem is, the read(STDOUT_FILENO, test_buffer, test_size) function is not working as the

volatile uint32_t * uart_rx = (uint32_t *)(UART0_CTRL_ADDR + UART_REG_RXFIFO);

is not getting any input data from the FIFO, and the *uart_rx_cnt is always 0.
The output printing is fine, but the colour of the LEDs is wrong and the button is not working as described in the demo_gpio.c

GPIO_REG(GPIO_OUTPUT_VAL) |= (1 << GREEN_LED_OFFSET); // this emits yellow light (R+G)
GPIO_REG(GPIO_OUTPUT_VAL) |= (0x1 << RED_LED_OFFSET); // this emits blue light
 GPIO_REG(GPIO_OUTPUT_VAL) |= (1 << BLUE_LED_OFFSET); // this emits green light

am I missing anything? why the UART is not able to read from the keyboard input? I tried with

echo "test\n" > /dev/ttyUSB1

and ‘send string’ in coolterm
Thanks.

Check the implementation of the _read() function and be sure it reads from the desired USART.

/* See LICENSE of license details. */

#include <stdint.h>
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>

#include "platform.h"
#include "stub.h"
#include "weak_under_alias.h"

ssize_t __wrap_read(int fd, void* ptr, size_t len)
{
  uint8_t * current = (uint8_t *)ptr;
  volatile uint32_t * uart_rx = (uint32_t *)(UART0_CTRL_ADDR + UART_REG_RXFIFO);
  volatile uint8_t * uart_rx_cnt = (uint8_t *)(UART0_CTRL_ADDR + UART_REG_RXCTRL + 2);

  ssize_t result = 0;

  if (isatty(fd)) {
    for (current = (uint8_t *)ptr;
        (current < ((uint8_t *)ptr) + len) && (*uart_rx_cnt > 0);
        current ++) {
      *current = *uart_rx;
      result++;
    }
    return result;
  }

  return _stub(EBADF);
}
weak_under_alias(read);

this is the wrap function that wraps the read().
sorry I am not sure whether this actually reads from the FIFO. is there a way to verify this?

thanks.

Hi @thomas98 ,

I’m wondering if this thread might help with the UART input issue: UART getc() does not work - #3 by gsavin

From your link it seems like you may be using an older version of the freedom-e-sdk and I want to point out that there’s newer releases such as: Release freedom-e-sdk v20.05.01.00 · sifive/freedom-e-sdk · GitHub

Is this a Freedom E300 issue or a HiFive1 rev B issue? It’s categorized as a HiFive1 rev B but seems like it could be a Freedom E300 issue.

Hi Jim,
yes this is a Freedom E300 issue but the category is archived and read-only so I just posted it here, sorry for that. yes, I am using an old freedom-e-sdk release, and the getc() uses freedom-metal which is not introduced in this verison. i will try with the latest sdk and riscv-gnu to see what happens.

thanks.

The use of __wrap_read() functions is specific to SiFive toolchains.

The xPack RISC-V GCC uses the standard newlib mechanism, which requires you to have a _read() function in your application.

Hi Liviu,
sorry I am a bit confused. does it mean that I have to write my own _read() function? can I just copy the content from __wrap_read() into _read()? also, why only _read() is required to work but not _write()? the write() call to the __wrap_write() is working without the need of _write().

Thanks.

The standard behaviour of newlib is to call _read() from somewhere deep inside the read() function, to implement the desired functionality.

I guess you can start with content copied from that wrapper.

I suggest you either take a look at the newlib sources, or at least google for the subject.

One reference I’ve found helpful in understanding this area is Embecosm’s “Howto: Porting newlib” website. See, e.g.,
https://www.embecosm.com/appnotes/ean9/ean9-howto-newlib-1.0.html#id2719321
While that discussion pertains to porting Newlib to an “OpenRISC 1000” implementation, the ideas are rather similar to what you would do for RISC-V. I found it easier to study the Newlib source tree after reading this.

sure, thank you.

thanks for the reference. although i am not sure how these all connected into one piece. I tried run_gdb and it did seem to call the __wrap_read() function which is not supposed to be called if I am using the newlib, why is that?

If the application has references to __wrap_read(), you probably used the SiFive toolchain or libraries.

Also, please try Jim’s suggestion to update the version of F-E-SDK. I’m pretty sure the newer versions don’t use __wrap_read() any more.

indeed, when i run

thomas@thomas-VirtualBox:~/freedom-e-sdk$ make software PROGRAM=demo_gpio BOARD=freedom-e300-arty

it builds all the system call functions in bsp/libwrap/sys, which belongs to the SiFive toolchain. Then, how can I use the riscv gcc toolchain?

thanks.

make[1]: Entering directory '/home/thomas/freedom-e-sdk/software/demo_gpio'
riscv-none-embed-gcc -O2 -fno-builtin-printf -DUSE_PLIC -DUSE_M_TIME -g -march=rv32ima -mabi=ilp32 -mcmodel=medany -I/home/thomas/freedom-e-sdk/bsp/include -I/home/thomas/freedom-e-sdk/bsp/drivers/ -I/home/thomas/freedom-e-sdk/bsp/env -I/home/thomas/freedom-e-sdk/bsp/env/freedom-e300-arty -c -o /home/thomas/freedom-e-sdk/bsp/env/start.o /home/thomas/freedom-e-sdk/bsp/env/start.S
riscv-none-embed-gcc -O2 -fno-builtin-printf -DUSE_PLIC -DUSE_M_TIME -g -march=rv32ima -mabi=ilp32 -mcmodel=medany -I/home/thomas/freedom-e-sdk/bsp/include -I/home/thomas/freedom-e-sdk/bsp/drivers/ -I/home/thomas/freedom-e-sdk/bsp/env -I/home/thomas/freedom-e-sdk/bsp/env/freedom-e300-arty -c -o /home/thomas/freedom-e-sdk/bsp/env/entry.o /home/thomas/freedom-e-sdk/bsp/env/entry.S
riscv-none-embed-gcc -O2 -fno-builtin-printf -DUSE_PLIC -DUSE_M_TIME -g -march=rv32ima -mabi=ilp32 -mcmodel=medany -I/home/thomas/freedom-e-sdk/bsp/include -I/home/thomas/freedom-e-sdk/bsp/drivers/ -I/home/thomas/freedom-e-sdk/bsp/env -I/home/thomas/freedom-e-sdk/bsp/env/freedom-e300-arty -include sys/cdefs.h -c -o demo_gpio.o demo_gpio.c
riscv-none-embed-gcc -O2 -fno-builtin-printf -DUSE_PLIC -DUSE_M_TIME -g -march=rv32ima -mabi=ilp32 -mcmodel=medany -I/home/thomas/freedom-e-sdk/bsp/include -I/home/thomas/freedom-e-sdk/bsp/drivers/ -I/home/thomas/freedom-e-sdk/bsp/env -I/home/thomas/freedom-e-sdk/bsp/env/freedom-e300-arty -include sys/cdefs.h -c -o /home/thomas/freedom-e-sdk/bsp/drivers/plic/plic_driver.o /home/thomas/freedom-e-sdk/bsp/drivers/plic/plic_driver.c
/home/thomas/freedom-e-sdk/bsp/drivers/plic/plic_driver.c: In function 'volatile_memzero':
/home/thomas/freedom-e-sdk/bsp/drivers/plic/plic_driver.c:16:36: warning: comparison of distinct pointer types lacks a cast
   for (ptr = (uint32_t *)base; ptr < (base + size); ptr++){
                                    ^
riscv-none-embed-gcc -O2 -fno-builtin-printf -DUSE_PLIC -DUSE_M_TIME -g -march=rv32ima -mabi=ilp32 -mcmodel=medany -I/home/thomas/freedom-e-sdk/bsp/include -I/home/thomas/freedom-e-sdk/bsp/drivers/ -I/home/thomas/freedom-e-sdk/bsp/env -I/home/thomas/freedom-e-sdk/bsp/env/freedom-e300-arty -include sys/cdefs.h -c -o /home/thomas/freedom-e-sdk/bsp/env/freedom-e300-arty/init.o /home/thomas/freedom-e-sdk/bsp/env/freedom-e300-arty/init.c
riscv-none-embed-gcc -O2 -fno-builtin-printf -DUSE_PLIC -DUSE_M_TIME -g -march=rv32ima -mabi=ilp32 -mcmodel=medany -I/home/thomas/freedom-e-sdk/bsp/include -I/home/thomas/freedom-e-sdk/bsp/drivers/ -I/home/thomas/freedom-e-sdk/bsp/env -I/home/thomas/freedom-e-sdk/bsp/env/freedom-e300-arty -c -o /home/thomas/freedom-e-sdk/bsp/libwrap/stdlib/malloc.o /home/thomas/freedom-e-sdk/bsp/libwrap/stdlib/malloc.c
riscv-none-embed-gcc -O2 -fno-builtin-printf -DUSE_PLIC -DUSE_M_TIME -g -march=rv32ima -mabi=ilp32 -mcmodel=medany -I/home/thomas/freedom-e-sdk/bsp/include -I/home/thomas/freedom-e-sdk/bsp/drivers/ -I/home/thomas/freedom-e-sdk/bsp/env -I/home/thomas/freedom-e-sdk/bsp/env/freedom-e300-arty -c -o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/open.o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/open.c
riscv-none-embed-gcc -O2 -fno-builtin-printf -DUSE_PLIC -DUSE_M_TIME -g -march=rv32ima -mabi=ilp32 -mcmodel=medany -I/home/thomas/freedom-e-sdk/bsp/include -I/home/thomas/freedom-e-sdk/bsp/drivers/ -I/home/thomas/freedom-e-sdk/bsp/env -I/home/thomas/freedom-e-sdk/bsp/env/freedom-e300-arty -c -o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/lseek.o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/lseek.c
riscv-none-embed-gcc -O2 -fno-builtin-printf -DUSE_PLIC -DUSE_M_TIME -g -march=rv32ima -mabi=ilp32 -mcmodel=medany -I/home/thomas/freedom-e-sdk/bsp/include -I/home/thomas/freedom-e-sdk/bsp/drivers/ -I/home/thomas/freedom-e-sdk/bsp/env -I/home/thomas/freedom-e-sdk/bsp/env/freedom-e300-arty -c -o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/read.o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/read.c
riscv-none-embed-gcc -O2 -fno-builtin-printf -DUSE_PLIC -DUSE_M_TIME -g -march=rv32ima -mabi=ilp32 -mcmodel=medany -I/home/thomas/freedom-e-sdk/bsp/include -I/home/thomas/freedom-e-sdk/bsp/drivers/ -I/home/thomas/freedom-e-sdk/bsp/env -I/home/thomas/freedom-e-sdk/bsp/env/freedom-e300-arty -c -o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/write.o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/write.c
riscv-none-embed-gcc -O2 -fno-builtin-printf -DUSE_PLIC -DUSE_M_TIME -g -march=rv32ima -mabi=ilp32 -mcmodel=medany -I/home/thomas/freedom-e-sdk/bsp/include -I/home/thomas/freedom-e-sdk/bsp/drivers/ -I/home/thomas/freedom-e-sdk/bsp/env -I/home/thomas/freedom-e-sdk/bsp/env/freedom-e300-arty -c -o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/fstat.o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/fstat.c
riscv-none-embed-gcc -O2 -fno-builtin-printf -DUSE_PLIC -DUSE_M_TIME -g -march=rv32ima -mabi=ilp32 -mcmodel=medany -I/home/thomas/freedom-e-sdk/bsp/include -I/home/thomas/freedom-e-sdk/bsp/drivers/ -I/home/thomas/freedom-e-sdk/bsp/env -I/home/thomas/freedom-e-sdk/bsp/env/freedom-e300-arty -c -o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/stat.o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/stat.c
riscv-none-embed-gcc -O2 -fno-builtin-printf -DUSE_PLIC -DUSE_M_TIME -g -march=rv32ima -mabi=ilp32 -mcmodel=medany -I/home/thomas/freedom-e-sdk/bsp/include -I/home/thomas/freedom-e-sdk/bsp/drivers/ -I/home/thomas/freedom-e-sdk/bsp/env -I/home/thomas/freedom-e-sdk/bsp/env/freedom-e300-arty -c -o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/close.o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/close.c
riscv-none-embed-gcc -O2 -fno-builtin-printf -DUSE_PLIC -DUSE_M_TIME -g -march=rv32ima -mabi=ilp32 -mcmodel=medany -I/home/thomas/freedom-e-sdk/bsp/include -I/home/thomas/freedom-e-sdk/bsp/drivers/ -I/home/thomas/freedom-e-sdk/bsp/env -I/home/thomas/freedom-e-sdk/bsp/env/freedom-e300-arty -c -o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/link.o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/link.c
riscv-none-embed-gcc -O2 -fno-builtin-printf -DUSE_PLIC -DUSE_M_TIME -g -march=rv32ima -mabi=ilp32 -mcmodel=medany -I/home/thomas/freedom-e-sdk/bsp/include -I/home/thomas/freedom-e-sdk/bsp/drivers/ -I/home/thomas/freedom-e-sdk/bsp/env -I/home/thomas/freedom-e-sdk/bsp/env/freedom-e300-arty -c -o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/unlink.o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/unlink.c
riscv-none-embed-gcc -O2 -fno-builtin-printf -DUSE_PLIC -DUSE_M_TIME -g -march=rv32ima -mabi=ilp32 -mcmodel=medany -I/home/thomas/freedom-e-sdk/bsp/include -I/home/thomas/freedom-e-sdk/bsp/drivers/ -I/home/thomas/freedom-e-sdk/bsp/env -I/home/thomas/freedom-e-sdk/bsp/env/freedom-e300-arty -c -o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/execve.o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/execve.c
riscv-none-embed-gcc -O2 -fno-builtin-printf -DUSE_PLIC -DUSE_M_TIME -g -march=rv32ima -mabi=ilp32 -mcmodel=medany -I/home/thomas/freedom-e-sdk/bsp/include -I/home/thomas/freedom-e-sdk/bsp/drivers/ -I/home/thomas/freedom-e-sdk/bsp/env -I/home/thomas/freedom-e-sdk/bsp/env/freedom-e300-arty -c -o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/fork.o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/fork.c
riscv-none-embed-gcc -O2 -fno-builtin-printf -DUSE_PLIC -DUSE_M_TIME -g -march=rv32ima -mabi=ilp32 -mcmodel=medany -I/home/thomas/freedom-e-sdk/bsp/include -I/home/thomas/freedom-e-sdk/bsp/drivers/ -I/home/thomas/freedom-e-sdk/bsp/env -I/home/thomas/freedom-e-sdk/bsp/env/freedom-e300-arty -c -o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/getpid.o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/getpid.c
riscv-none-embed-gcc -O2 -fno-builtin-printf -DUSE_PLIC -DUSE_M_TIME -g -march=rv32ima -mabi=ilp32 -mcmodel=medany -I/home/thomas/freedom-e-sdk/bsp/include -I/home/thomas/freedom-e-sdk/bsp/drivers/ -I/home/thomas/freedom-e-sdk/bsp/env -I/home/thomas/freedom-e-sdk/bsp/env/freedom-e300-arty -c -o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/kill.o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/kill.c
riscv-none-embed-gcc -O2 -fno-builtin-printf -DUSE_PLIC -DUSE_M_TIME -g -march=rv32ima -mabi=ilp32 -mcmodel=medany -I/home/thomas/freedom-e-sdk/bsp/include -I/home/thomas/freedom-e-sdk/bsp/drivers/ -I/home/thomas/freedom-e-sdk/bsp/env -I/home/thomas/freedom-e-sdk/bsp/env/freedom-e300-arty -c -o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/wait.o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/wait.c
riscv-none-embed-gcc -O2 -fno-builtin-printf -DUSE_PLIC -DUSE_M_TIME -g -march=rv32ima -mabi=ilp32 -mcmodel=medany -I/home/thomas/freedom-e-sdk/bsp/include -I/home/thomas/freedom-e-sdk/bsp/drivers/ -I/home/thomas/freedom-e-sdk/bsp/env -I/home/thomas/freedom-e-sdk/bsp/env/freedom-e300-arty -c -o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/isatty.o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/isatty.c
riscv-none-embed-gcc -O2 -fno-builtin-printf -DUSE_PLIC -DUSE_M_TIME -g -march=rv32ima -mabi=ilp32 -mcmodel=medany -I/home/thomas/freedom-e-sdk/bsp/include -I/home/thomas/freedom-e-sdk/bsp/drivers/ -I/home/thomas/freedom-e-sdk/bsp/env -I/home/thomas/freedom-e-sdk/bsp/env/freedom-e300-arty -c -o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/times.o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/times.c
riscv-none-embed-gcc -O2 -fno-builtin-printf -DUSE_PLIC -DUSE_M_TIME -g -march=rv32ima -mabi=ilp32 -mcmodel=medany -I/home/thomas/freedom-e-sdk/bsp/include -I/home/thomas/freedom-e-sdk/bsp/drivers/ -I/home/thomas/freedom-e-sdk/bsp/env -I/home/thomas/freedom-e-sdk/bsp/env/freedom-e300-arty -c -o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/sbrk.o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/sbrk.c
riscv-none-embed-gcc -O2 -fno-builtin-printf -DUSE_PLIC -DUSE_M_TIME -g -march=rv32ima -mabi=ilp32 -mcmodel=medany -I/home/thomas/freedom-e-sdk/bsp/include -I/home/thomas/freedom-e-sdk/bsp/drivers/ -I/home/thomas/freedom-e-sdk/bsp/env -I/home/thomas/freedom-e-sdk/bsp/env/freedom-e300-arty -c -o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/_exit.o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/_exit.c
riscv-none-embed-gcc -O2 -fno-builtin-printf -DUSE_PLIC -DUSE_M_TIME -g -march=rv32ima -mabi=ilp32 -mcmodel=medany -I/home/thomas/freedom-e-sdk/bsp/include -I/home/thomas/freedom-e-sdk/bsp/drivers/ -I/home/thomas/freedom-e-sdk/bsp/env -I/home/thomas/freedom-e-sdk/bsp/env/freedom-e300-arty -c -o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/puts.o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/puts.c
riscv-none-embed-gcc -O2 -fno-builtin-printf -DUSE_PLIC -DUSE_M_TIME -g -march=rv32ima -mabi=ilp32 -mcmodel=medany -I/home/thomas/freedom-e-sdk/bsp/include -I/home/thomas/freedom-e-sdk/bsp/drivers/ -I/home/thomas/freedom-e-sdk/bsp/env -I/home/thomas/freedom-e-sdk/bsp/env/freedom-e300-arty -c -o /home/thomas/freedom-e-sdk/bsp/libwrap/misc/write_hex.o /home/thomas/freedom-e-sdk/bsp/libwrap/misc/write_hex.c
riscv-none-embed-ar rcs libwrap.a /home/thomas/freedom-e-sdk/bsp/libwrap/stdlib/malloc.o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/open.o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/lseek.o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/read.o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/write.o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/fstat.o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/stat.o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/close.o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/link.o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/unlink.o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/execve.o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/fork.o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/getpid.o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/kill.o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/wait.o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/isatty.o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/times.o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/sbrk.o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/_exit.o /home/thomas/freedom-e-sdk/bsp/libwrap/sys/puts.o /home/thomas/freedom-e-sdk/bsp/libwrap/misc/write_hex.o
riscv-none-embed-gcc -O2 -fno-builtin-printf -DUSE_PLIC -DUSE_M_TIME -g -march=rv32ima -mabi=ilp32 -mcmodel=medany -I/home/thomas/freedom-e-sdk/bsp/include -I/home/thomas/freedom-e-sdk/bsp/drivers/ -I/home/thomas/freedom-e-sdk/bsp/env -I/home/thomas/freedom-e-sdk/bsp/env/freedom-e300-arty /home/thomas/freedom-e-sdk/bsp/env/start.o /home/thomas/freedom-e-sdk/bsp/env/entry.o demo_gpio.o /home/thomas/freedom-e-sdk/bsp/drivers/plic/plic_driver.o /home/thomas/freedom-e-sdk/bsp/env/freedom-e300-arty/init.o -o demo_gpio -Wl,--wrap=malloc -Wl,--wrap=free -Wl,--wrap=open -Wl,--wrap=lseek -Wl,--wrap=read -Wl,--wrap=write -Wl,--wrap=fstat -Wl,--wrap=stat -Wl,--wrap=close -Wl,--wrap=link -Wl,--wrap=unlink -Wl,--wrap=execve -Wl,--wrap=fork -Wl,--wrap=getpid -Wl,--wrap=kill -Wl,--wrap=wait -Wl,--wrap=isatty -Wl,--wrap=times -Wl,--wrap=sbrk -Wl,--wrap=_exit -Wl,--wrap=puts -Wl,--wrap=_malloc -Wl,--wrap=_free -Wl,--wrap=_open -Wl,--wrap=_lseek -Wl,--wrap=_read -Wl,--wrap=_write -Wl,--wrap=_fstat -Wl,--wrap=_stat -Wl,--wrap=_close -Wl,--wrap=_link -Wl,--wrap=_unlink -Wl,--wrap=_execve -Wl,--wrap=_fork -Wl,--wrap=_getpid -Wl,--wrap=_kill -Wl,--wrap=_wait -Wl,--wrap=_isatty -Wl,--wrap=_times -Wl,--wrap=_sbrk -Wl,--wrap=__exit -Wl,--wrap=_puts -L. -Wl,--start-group -lwrap -lc -Wl,--end-group -T /home/thomas/freedom-e-sdk/bsp/env/freedom-e300-arty/flash.lds -nostartfiles -L/home/thomas/freedom-e-sdk/bsp/env --specs=nano.specs
make[1]: Leaving directory '/home/thomas/freedom-e-sdk/software/demo_gpio'

The freedom-e-sdk/bsp/libwrap directory hasn’t existed since c.2018. Please consider upgrading.

sure i will definitely try that.

thanks.

Hi Nick,
so I have the latest of everything set up already but the metal_uart_getc() is still not working as expected (user input is not picked up).

here is the test code: am i missing something?

thanks.

/* Copyright 2019 SiFive, Inc */
/* SPDX-License-Identifier: Apache-2.0 */

#include <stdio.h>
#include "../../freedom-metal/metal/uart.h"

int main() {
    printf("waiting...");
    int *c;
    struct metal_uart *uart0;
    uart0 = metal_uart_get_device(0);
    metal_uart_init(uart0, 57600);
    printf("waiting2...");
        while(1){
        metal_uart_getc(uart0,c);
        printf("sucess");
        printf("%d\n",*c);
        }
}

Sorry to hear it’s still not working. I’m not an expert in this area, and I don’t have the correct hardware to attempt to reproduce your issue. I’ve flagged your question internally for someone from CX to look at.

In the meanwhile, all I can do is suggest ensuring that you’re using the latest versions of Freedom-E-SDK and its dependences (including the GNU toolchain), as explained in the instructions here:

GitHub - sifive/freedom-e-sdk: Open Source Software for Developing on the Freedom E Platform

Also, I was under the impression that Freedom Metal sets up the UART(s) automatically, so you might consider using just C standard I/O, e.g., calling getc() directly.

thank you.
i tried with getc():

/* Copyright 2019 SiFive, Inc */
/* SPDX-License-Identifier: Apache-2.0 */

#include <stdio.h>
#include "../../freedom-metal/metal/uart.h"
#include "../../freedom-metal/metal/tty.h"

int main() {
    printf("waiting...");
    struct metal_uart *uart0;
    uart0 = metal_uart_get_device(0);
    metal_uart_init(uart0, 57600);
    char c;
    getc(stdin);
    printf("Character entered: ");
    putc(c, stdout);
    printf("end");
}

and got the result:

waiting...Character entered:  end

seems like the getc() just skipped the user input.