edison-fw / meta-intel-edison

Here is the meta-intel-edison that builds, tries to stay up to date. Master is based on Yocto Poky Gatesgarth LTS 5.10.yy vanilla kernels. It builds a 32bit kernel (Gatesgarth branch 64bit) with ACPI enabled and corresponding rootfs. Telegram group: https://t.me/IntelEdison Web-site:
https://edison-fw.github.io/meta-intel-edison/
MIT License
60 stars 38 forks source link

UART on arduino board does not work in acpi version. #107

Closed xlla closed 4 years ago

xlla commented 4 years ago

I compiled a mraa uart test progrom, by comment all uart mux/bias statements, prepare uart2w in acpi tables.

I connect D0/D1 to another Arduino mega 2560 board's D16/D17, and run a SerialPassthrough sketch, it monitor data from D16/D17(uart2) then write to usb(uart) and vice versa.

But I can't read any char in Arduino's monitor. can't read any char in Edison board too.

here is gpio info.

    line 130:      unnamed       unused   input  active-high 
    line 131:      unnamed       unused   input  active-high 
    line  14: "TRI_STATE_ALL" "mraa" output active-high [used]
    line   0: "DIG0_PU_PD" "uart1-rx-pu" input active-high [used]
    line   1: "DIG1_PU_PD" "uart1-tx-pu" input active-high [used]
    line   0:  "MUX33_DIR" "uart1-rx-oe" output active-high [used]
    line   1:  "MUX31_DIR" "uart1-tx-oe" output active-high [used]

it seems no one used GP130/GP131, mraa lib just open /dev/ttyS1 and write/read data.

xlla commented 4 years ago

I found the reason. in function mraa_gpio_read_dir, it will check line->flags with those macro

#define GPIOLINE_FLAG_KERNEL        (1UL << 0) /* Line used by the kernel */
#define GPIOLINE_FLAG_IS_OUT        (1UL << 1)
#define GPIOLINE_FLAG_ACTIVE_LOW    (1UL << 2)
#define GPIOLINE_FLAG_OPEN_DRAIN    (1UL << 3)
#define GPIOLINE_FLAG_OPEN_SOURCE   (1UL << 4)

but in mraa_gpio_chardev_dir function, it had prepare line tristate, set line->flag with those macro

/* Linerequest flags */
#define GPIOHANDLE_REQUEST_INPUT    (1UL << 0)
#define GPIOHANDLE_REQUEST_OUTPUT   (1UL << 1)
#define GPIOHANDLE_REQUEST_ACTIVE_LOW   (1UL << 2)
#define GPIOHANDLE_REQUEST_OPEN_DRAIN   (1UL << 3)
#define GPIOHANDLE_REQUEST_OPEN_SOURCE  (1UL << 4)

then mraa will think this line was used by kernel, skip some code to set tristate high. after comment check logic , it works! I can comfirm uart with mraa lib was fine.