From patchwork Mon Jun 13 09:57:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Zulberti X-Patchwork-Id: 9172511 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 161C46075D for ; Mon, 13 Jun 2016 09:57:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 05B2121C9A for ; Mon, 13 Jun 2016 09:57:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EE92F265B9; Mon, 13 Jun 2016 09:57:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6A48321C9A for ; Mon, 13 Jun 2016 09:57:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964875AbcFMJ54 (ORCPT ); Mon, 13 Jun 2016 05:57:56 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:34042 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964861AbcFMJ5z (ORCPT ); Mon, 13 Jun 2016 05:57:55 -0400 Received: by mail-wm0-f66.google.com with SMTP id n184so13496380wmn.1 for ; Mon, 13 Jun 2016 02:57:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:reply-to:from:date:message-id:subject:to:cc; bh=RCrtn02X1dvPsSDL3HGr8xK26rkSOSkwagNbjbYT9rA=; b=E1D/xWEDYBzgCv4dqu7XQM4NA3dK2b8KTYwNir5wcGoYPheguhMH5uU2bArD3kxNFF 4ZC8hgaM10ljBz+f4Co8J7K/dJFD8XKyXcUwDBm5it+TYpQBlhJghZYo3c+EaVQyKp0U aZf+Qf9z66y9rV8dlcffmr9kN2EeNMubr3/MU6s6ktmjFBgdo3TpaiyKw9KJMoQqT3xI akyfJlyL1ledCC/NMg9987jQAP51boRopa48Om5NsfO/xT+qiw9/xUGYa6DFCiZ6pn4C RWFZwyfxW3VKxlRNdzx468cDbqZ/mtZYyZQUXCpd+9PQAfCXG+75iKLYMJdCMgQ8AVjd Ge2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:reply-to:from:date:message-id :subject:to:cc; bh=RCrtn02X1dvPsSDL3HGr8xK26rkSOSkwagNbjbYT9rA=; b=H6vBG+j/EFusDC+BG4qWHPiQCMH9EEpqP+PbXAPeo8hNJCM2F+zvSxwzCsbjmJ8qaP Lc2sT+4WoH6LyqzVrByrVtsfYW3b7n9T1sBGu+1bFS5gm8ZY91ooIsS7b3bY3oAW6I9e rAm+Qr/7qI/PyUvr1yNMJJS9XYGBYB86EM8wxR2GvWyDWrsCmmATep7m6mEYyg6jTXLB r6HipU7+GR/iwZ96FaXedgIazHmVngr5gBEaIKgij+dNLQ4csDr0e1WCgoaujd0D4VVh suQb2/7sVlzaEwogD21My6YIuhLCqsj5r23nfTh3ZW642r2OE5TtFq6fPRFiHVjfmshk Ap6Q== X-Gm-Message-State: ALyK8tLDiIluYYq+DszZwQ9M/7s6vAt7Ys3+BFUWbM3wGIqK8Ix6Rg+XdzGOIyg/iZnEAwvbq3u66eAFYYPtIw== X-Received: by 10.28.5.147 with SMTP id 141mr270278wmf.48.1465811874176; Mon, 13 Jun 2016 02:57:54 -0700 (PDT) MIME-Version: 1.0 Received: by 10.28.230.202 with HTTP; Mon, 13 Jun 2016 02:57:53 -0700 (PDT) Reply-To: zulberti.luca@gmail.com From: Luca Zulberti Date: Mon, 13 Jun 2016 11:57:53 +0200 Message-ID: Subject: RX problems with at86rf230 driver To: aar@pengutronix.de Cc: linux-wpan@vger.kernel.org, Rodolfo Giometti Sender: linux-wpan-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wpan@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hello Alexander, I'm trying to use the AT86RF233 radio transceiver for 6lowpan purposes. Now I'm using an ieee802154 compatible transmitter to test the monitor functionality of the 6lowpan node. I've put the following code into the at86rf230_rx_read_frame_complete() of the driver at86rf230.c into kernel 4.7-rc2: I've noticed some incompatible data read from the spi. printk output: INIZIO RX - spi_len: 13 0x00 0x0b 0x61 0x08 0x0f 0x04 0x16 0x04 0x16 0x01 0x00 0xe3 0xcf FINE RX INIZIO RX - spi_len: 248 0x20 0xf6 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0xfd 0xff 0x24 0xf0 0x62 0xff 0x24 0xf0 0x77 0xff 0x24 0xf0 0x41 0xff 0x24 0xf0 0x93 0xff 0x24 0xf0 0x72 0xff 0x24 0xf0 0xd4 0xff 0x24 0xf0 0x11 0xff 0x24 0xf0 0x8e 0xff 0x24 0xf0 0x8a 0xff 0x24 0xf0 0x0f 0xff 0x24 0xf0 0x49 0xff 0x24 0xf0 0xcb 0xff 0x24 0xf0 0x57 0xff 0x24 0xf0 0x30 0xff 0x24 0xf0 0xfb 0xff 0x24 0xf0 0x92 0xff 0x24 0xf0 0xce 0xff 0x24 0xf0 0x8d 0xff 0x24 0xf0 0x15 0xff 0x24 0xf0 0xa5 0xff 0x24 0xf0 0x4e 0xff 0x24 0xf0 0x57 0xff 0x24 0xf0 0x4d 0xff 0x24 0xf0 0x38 0xff 0x24 0xf0 0xf5 0xff 0x24 0xf0 0x41 0xff 0x24 0xf0 0xf9 0xff 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 FINE RX INIZIO RX - spi_len: 248 0x00 0x0b 0x61 0x08 0x10 0x04 0x16 0x04 0x16 0x01 0x00 0xde 0x63 0xff 0x20 0xf0 0x43 0xff 0x20 0xf0 0xfd 0xff 0x20 0xf0 0x62 0xff 0x20 0xf0 0x77 0xff 0x20 0xf0 0x41 0xff 0x20 0xf0 0x93 0xff 0x20 0xf0 0x72 0xff 0x20 0xf0 0xd4 0xff 0x20 0xf0 0x11 0xff 0x20 0xf0 0x8e 0xff 0x20 0xf0 0x8a 0xff 0x20 0xf0 0x0f 0xff 0x20 0xf0 0x49 0xff 0x20 0xf0 0xcb 0xff 0x20 0xf0 0x57 0xff 0x20 0xf0 0x30 0xff 0x20 0xf0 0xfb 0xff 0x20 0xf0 0x92 0xff 0x20 0xf0 0xce 0xff 0x20 0xf0 0x8d 0xff 0x20 0xf0 0x15 0xff 0x20 0xf0 0xa5 0xff 0x20 0xf0 0x4e 0xff 0x20 0xf0 0x57 0xff 0x20 0xf0 0x4d 0xff 0x20 0xf0 0x38 0xff 0x20 0xf0 0xf5 0xff 0x20 0xf0 0x41 0xff 0x20 0xf0 0xf9 0xff 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 FINE RX The transmitter sends 12 bytes (10 byte of payload and 2 of FCS) as shown in the first output but the driver often reads 248 bytes from the spi buffer which is wrong. In the third output 'spi_len' is 248 even if the second byte of the stream (the PHR) is 11!!! With a logic analyzer I've checked the data from the at86rf233 and they are correct, however when the driver reads them something goes wrong and invalid data are returned! It seems to me that the driver returns the previously written data instead of the current read ones maybe due a race condition... Below is the DTS settings for my board: spi1: spi@f0004000 { status = "okay"; cs-gpios = <&pioA 29 GPIO_ACTIVE_LOW>, <0>, <0>, <0>; at86rf233@0 { compatible = "atmel,at86rf233"; reg = <0>; interrupt-parent = <&pioA>; interrupts = <27 IRQ_TYPE_EDGE_RISING 7>; pinctrl-names = "default"; pinctrl-0 = <&pinctrl_at86rf233_irq>; reset-gpio = <&pioA 24 GPIO_ACTIVE_LOW>; sleep-gpio = <&pioA 25 GPIO_ACTIVE_HIGH>; spi-max-frequency = <3000000>; xtal-trim = /bits/ 8 <0x0F>; }; pinctrl@fffff400 { board { pinctrl_at86rf233_irq: at86rf233_irq { atmel,pins = ; }; }; }; Thanks in advance for your help! Regards, Luca. --- To unsubscribe from this list: send the line "unsubscribe linux-wpan" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/net/ieee802154/at86rf230.c b/drivers/net/ieee802154/at86rf230.c index 9f10da6..4d616c8 100644 --- a/drivers/net/ieee802154/at86rf230.c +++ b/drivers/net/ieee802154/at86rf230.c @@ -711,6 +711,18 @@ at86rf230_rx_read_frame_complete(void *context) u8 len, lqi; len = buf[1]; + + { + int i; + printk("\nSTART RX - spi_len: %d\n", len + 2); + for (i = 0; i < len + 2; i++) { + printk("0x%02x ", buf[i]); + if (i % 16 == 15) + printk("\n"); + } + printk("\nEND RX\n"); + } + if (!ieee802154_is_valid_psdu_len(len)) { dev_vdbg(&lp->spi->dev, "corrupted frame received\n"); len = IEEE802154_MTU; @@ -878,6 +890,18 @@ at86rf230_write_frame(void *context) memcpy(buf + 2, skb->data, skb->len); ctx->trx.len = skb->len + 2; ctx->msg.complete = at86rf230_write_frame_complete; + + { + int i, len = buf[1] + 2; + printk("\nSTART TX - spi_len: %d\n", len); + for (i = 0; i < len; i++) { + printk("0x%02x ", buf[i]); + if (i % 16 == 15) + printk("\n"); + } + printk("\nEND TX\n"); + } + rc = spi_async(lp->spi, &ctx->msg); if (rc) { ctx->trx.len = 2;