Adding UART & TCP in the AN00202 AVB app

Technical questions regarding the XTC tools and programming with XMOS.
Post Reply
mx12
Member++
Posts: 20
Joined: Thu Aug 18, 2016 3:22 pm

Adding UART & TCP in the AN00202 AVB app

Post by mx12 »

Hi,
My project is an AVB extension board that will act as a 8 channels talker unit. It will fit into an existing 8 channels mic preamp that have a web based wifi configuration page.

I used the xCORE-200 Multichannel Audio Platform as reference design and AN00202 (Gigabit Ethernet AVB endpoint example using I2S master) as base code. I modified the code to disable the listener and to add a SPI slave interface to communicate with the mic preamp processor. This seems to work fine now.

When this extension board is fitted, we want to disable the wifi module and use the AVB extension card ethernet interface instead. Wifi module uses UART lines, so I need to make an UART to TCP socket bridge into the XMOS.

When I compile my app, I get the following constraint check report:
Constraint check for tile[0]:
Cores available: 8, used: 7 . OKAY
Timers available: 10, used: 7 . OKAY
Chanends available: 32, used: 28 . OKAY
Memory available: 262144, used: 95632 . OKAY
(Stack: 23924, Code: 60808, Data: 10900)
Constraints checks PASSED.
Constraint check for tile[1]:
Cores available: 8, used: 8 . OKAY
Timers available: 10, used: 8 . OKAY
Chanends available: 32, used: 27 . OKAY
Memory available: 262144, used: 110516 . OKAY
(Stack: 79116, Code: 22060, Data: 9340)
Constraints checks PASSED.
The UART library example gives the following code:

Code: Select all

int main() {
interface uart_rx_if i_rx;
interface uart_tx_if i_tx;
input_gpio_if i_gpio_rx[1];
output_gpio_if i_gpio_tx[1];
par {
on tile[0]: output_gpio(i_gpio_tx, 1, p_uart_tx, null);
on tile[0]: uart_tx(i_tx, null,
115200, UART_PARITY_NONE, 8, 1,
i_gpio_tx[0]);
on tile[0].core[0] : input_gpio_with_events(i_gpio_rx, 1, p_uart_rx, null);
on tile[0].core[0] : uart_rx(i_rx, null, RX_BUFFER_SIZE,
115200, UART_PARITY_NONE, 8, 1,
i_gpio_rx[0]);
on tile[0]: app(i_tx, i_rx);
}
return 0;
}
I tried to include that code into my project. As UART lines are connected to 1-pin GPIOs on tile 1, the build failed, as it uses too many cores. I tried to combine/distribute tasks:

Code: Select all

on tile[1]: [[distribute]] output_gpio(i_gpio_tx, 1, p_uart_tx, null);
    on tile[1]: [[distribute]] uart_tx(i_tx, null, 115200, UART_PARITY_NONE, 8, 1, i_gpio_tx[0]);
    on tile[1]: par {
        uart_rx(i_rx, null, RX_BUFFER_SIZE, 115200, UART_PARITY_NONE, 8, 1, i_gpio_rx[0]);
        input_gpio_with_events(i_gpio_rx, 1, p_uart_rx, null);
    };
    on tile[1]: uart_tcp_bridge(i_tx, i_rx);
..and got an error:
xcc1: terminated due to internal unrecoverable error
uart_tcp_bridge is for now only an UART loopback:

Code: Select all

void uart_tcp_bridge(client uart_tx_if uart_tx, client uart_rx_if uart_rx) {
    while(1) {
        select {
            case uart_rx.data_ready():
            uint8_t data = uart_rx.read();
            uart_tx.write(data);
            break;
        }
    }
}
Any help welcome!


mx12
Member++
Posts: 20
Joined: Thu Aug 18, 2016 3:22 pm

Post by mx12 »

nobody got that xcc1 internal unrecoverable error? Really need help here...
User avatar
infiniteimprobability
XCore Legend
Posts: 1126
Joined: Thu May 27, 2010 10:08 am
Contact:

Post by infiniteimprobability »

hi,
without full source it's difficult to reproduce, but some thoughts/questions..

What version of the compiler are you using?

Code: Select all

on tile[1]: [[distribute]] output_gpio(i_gpio_tx, 1, p_uart_tx, null);
    on tile[1]: [[distribute]] uart_tx(i_tx, null, 115200, UART_PARITY_NONE, 8, 1, i_gpio_tx[0]);
    on tile[1]: par {
        uart_rx(i_rx, null, RX_BUFFER_SIZE, 115200, UART_PARITY_NONE, 8, 1, i_gpio_rx[0]);
        input_gpio_with_events(i_gpio_rx, 1, p_uart_rx, null);
    };
    on tile[1]: uart_tcp_bridge(i_tx, i_rx);
You shouldn't need [[distribute]] as distributable tasks are automatically distributed if they can be (same tile normally). Also, you don't need to have a second par just for uart_rx and input_gpio_with_events. Although, again, this should be fine. Do try removing this to flatten out the par. I have seen issues in the past with how things are ordered.
You only need to be explicit about combinable tasks. Either using [[combine]] attribute or .core[n]...
User avatar
infiniteimprobability
XCore Legend
Posts: 1126
Joined: Thu May 27, 2010 10:08 am
Contact:

Post by infiniteimprobability »

By the way - you have definitely found a bug in the compiler, so do feel free to upload (preferably a minimum case) here https://www.xmos.com/rt4/SelfService/Cr ... t-bug.html
Post Reply