Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expanding "shield" functionality (example uses WNC-M14A2A and SARA modem) #14057

Merged
merged 18 commits into from
May 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
4cb1a63
drivers: modem: wncm14a2a: dont free packet on error
mike-scott May 17, 2019
28d7f4e
drivers: modem: wncm14a2a: correct pinconfig assert check
mike-scott May 17, 2019
e53f58b
dts-binding: modem: wnc-14a2a: add label binding
mike-scott May 17, 2019
9f2c8db
dts/bindings: introduce Arduino-header-R3 GPIO binding
mike-scott May 17, 2019
d685032
boards: arm: frdm_k64f: add Arduino header definition to DTS
mike-scott May 17, 2019
f1576d5
boards: nrf52840_pca10056: add Arduino header definition to DTS
mike-scott May 17, 2019
93ed6b0
board: disco_l475_iot1: add Arduino header definition to DTS
mike-scott May 17, 2019
0560624
samples: lwm2m_client: cleanup shield overlay files
mike-scott May 17, 2019
7b1638a
cmake: add handling for shield config and shield/board overlays
mike-scott May 17, 2019
d12922b
shields: introduce shield-based WNC-M14A2A modem setup
mike-scott May 17, 2019
dfaa250
drivers: modem: wncm14a2a: remove HW specific Kconfig settings
mike-scott May 17, 2019
c5cbebf
boards: arm: frdm_k64f: don't use ETH if MODEM is enabled
mike-scott May 17, 2019
74ddf2f
samples: lwm2m_client: re-add sanity check for WNC-M14A2A build
mike-scott May 17, 2019
4c3ae4b
dts: bindings: add modem binding for u-blox SARA-R4
mike-scott May 17, 2019
1f199b3
drivers: modem: introduce u-blox SARA-R4 modem driver
mike-scott May 17, 2019
ffbeaee
boards: arm: frdm_k64f: add pinmux for SARA-R4 modem
mike-scott May 17, 2019
b606d35
boards: shields: introduce SparkFun u-blox SARA-R4 shield
mike-scott May 17, 2019
a56e073
boards: arm: particle_boron: enable SARA-R4 modem
mike-scott May 17, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions boards/arm/disco_l475_iot1/disco_l475_iot1.dts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,33 @@
sw0 = &user_button;
eswifi0 = &wifi0;
};

arduino_header: connector {
compatible = "arduino-header-r3";
#gpio-cells = <2>;
gpio-map = <0 0 &gpioc 5 0>, /* A0 */
<1 0 &gpioc 4 0>, /* A1 */
<2 0 &gpioc 3 0>, /* A2 */
<3 0 &gpioc 2 0>, /* A3 */
<4 0 &gpioc 1 0>, /* A4 */
<5 0 &gpioc 0 0>, /* A5 */
<6 0 &gpioa 1 0>, /* D0 */
<7 0 &gpioa 0 0>, /* D1 */
<8 0 &gpiod 14 0>, /* D2 */
<9 0 &gpiob 0 0>, /* D3 */
<10 0 &gpioa 3 0>, /* D4 */
<11 0 &gpiob 4 0>, /* D5 */
<12 0 &gpiob 1 0>, /* D6 */
<13 0 &gpioa 4 0>, /* D7 */
<14 0 &gpiob 2 0>, /* D8 */
<15 0 &gpioa 15 0>, /* D9 */
<16 0 &gpioa 2 0>, /* D10 */
<17 0 &gpioa 7 0>, /* D11 */
<18 0 &gpioa 6 0>, /* D12 */
<19 0 &gpioa 5 0>, /* D13 */
<20 0 &gpiob 9 0>, /* D14 */
<21 0 &gpiob 8 0>; /* D15 */
};
};

arduino_i2c: &i2c1 {};
Expand Down
2 changes: 1 addition & 1 deletion boards/arm/frdm_k64f/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ endif # SPI
if NETWORKING

config NET_L2_ETHERNET
default y if !MODEM_WNCM14A2A
default y if !MODEM

config ETH_MCUX_0
default y if NET_L2_ETHERNET
Expand Down
30 changes: 30 additions & 0 deletions boards/arm/frdm_k64f/frdm_k64f.dts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,36 @@
gpios = <&gpioa 4 GPIO_INT_ACTIVE_LOW>;
};
};

arduino_header: connector {
compatible = "arduino-header-r3";
#gpio-cells = <2>;
gpio-map = <0 0 &gpiob 2 0>, /* A0 */
<1 0 &gpiob 3 0>, /* A1 */
<2 0 &gpiob 10 0>, /* A2 */
<3 0 &gpiob 11 0>, /* A3 */
<4 0 &gpioc 11 0>, /* A4 */
<5 0 &gpioc 10 0>, /* A5 */
<6 0 &gpioc 16 0>, /* D0 */
<7 0 &gpioc 17 0>, /* D1 */
<8 0 &gpiob 9 0>, /* D2 */
<9 0 &gpioa 1 0>, /* D3 */
<10 0 &gpiob 23 0>, /* D4 */
<11 0 &gpioa 2 0>, /* D5 */
<12 0 &gpioc 2 0>, /* D6 */
<13 0 &gpioc 3 0>, /* D7 */
/* NOTE: HW Rev D and below use: */
/* <14 0 &gpioa 0 0>, */
/* NOTE: HW Rev E and on use: */
<14 0 &gpioc 12 0>, /* D8 */
<15 0 &gpioc 4 0>, /* D9 */
<16 0 &gpiod 0 0>, /* D10 */
<17 0 &gpiod 2 0>, /* D11 */
<18 0 &gpiod 3 0>, /* D12 */
<19 0 &gpiod 1 0>, /* D13 */
<20 0 &gpioe 25 0>, /* D14 */
<21 0 &gpioe 24 0>; /* D15 */
};
};

arduino_serial: &uart3 {};
Expand Down
7 changes: 7 additions & 0 deletions boards/arm/frdm_k64f/pinmux.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ static int frdm_k64f_pinmux_init(struct device *dev)
pinmux_pin_set(portc, 17, PORT_PCR_MUX(kPORT_MuxAsGpio));
#endif

#ifdef CONFIG_MODEM_UBLOX_SARA_R4
/* Modem RESET */
pinmux_pin_set(portc, 2, PORT_PCR_MUX(kPORT_MuxAsGpio));
/* Modem POWER_ON */
pinmux_pin_set(porta, 2, PORT_PCR_MUX(kPORT_MuxAsGpio));
#endif

#ifdef CONFIG_IEEE802154_MCR20A
/* FRDM-MCR20A Reset (D5) */
pinmux_pin_set(porta, 2, PORT_PCR_MUX(kPORT_MuxAsGpio));
Expand Down
27 changes: 27 additions & 0 deletions boards/arm/nrf52840_pca10056/nrf52840_pca10056.dts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,33 @@
};
};

arduino_header: connector {
compatible = "arduino-header-r3";
#gpio-cells = <2>;
gpio-map = <0 0 &gpio0 3 0>, /* A0 */
<1 0 &gpio0 4 0>, /* A1 */
<2 0 &gpio0 28 0>, /* A2 */
<3 0 &gpio0 29 0>, /* A3 */
<4 0 &gpio0 30 0>, /* A4 */
<5 0 &gpio0 31 0>, /* A5 */
<6 0 &gpio1 1 0>, /* D0 */
<7 0 &gpio1 2 0>, /* D1 */
<8 0 &gpio1 3 0>, /* D2 */
<9 0 &gpio1 4 0>, /* D3 */
<10 0 &gpio1 5 0>, /* D4 */
<11 0 &gpio1 6 0>, /* D5 */
<12 0 &gpio1 7 0>, /* D6 */
<13 0 &gpio1 8 0>, /* D7 */
<14 0 &gpio1 10 0>, /* D8 */
<15 0 &gpio1 11 0>, /* D9 */
<16 0 &gpio1 12 0>, /* D10 */
<17 0 &gpio1 13 0>, /* D11 */
<18 0 &gpio1 14 0>, /* D12 */
<19 0 &gpio1 15 0>, /* D13 */
<20 0 &gpio0 26 0>, /* D14 */
<21 0 &gpio0 27 0>; /* D15 */
};

/* These aliases are provided for compatibility with samples */
aliases {
led0 = &led0;
Expand Down
4 changes: 4 additions & 0 deletions boards/arm/particle_boron/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# SPDX-License-Identifier: Apache-2.0

zephyr_library()
zephyr_library_sources(board.c)
16 changes: 16 additions & 0 deletions boards/arm/particle_boron/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,20 @@ endif # IEEE802154
config BT_CTLR
default BT

if MODEM

config UART_1_NRF_UARTE
default y

config UART_1_NRF_FLOW_CONTROL
default y

config MODEM_UBLOX_SARA_R4
default y

config UART_INTERRUPT_DRIVEN
default y

endif # MODEM

endif # BOARD_PARTICLE_BORON
35 changes: 35 additions & 0 deletions boards/arm/particle_boron/board.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright (c) 2019 Foundries.io
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <init.h>
#include "board.h"
#include <gpio.h>

static int particle_boron_init(struct device *dev)
{

ARG_UNUSED(dev);

#if defined(CONFIG_MODEM_UBLOX_SARA_R4)
struct device *gpio_dev;

/* Enable the serial buffer for SARA-R4 modem */
gpio_dev = device_get_binding(SERIAL_BUFFER_ENABLE_GPIO_NAME);
if (!gpio_dev) {
return -ENODEV;
}

gpio_pin_configure(gpio_dev, V_INT_DETECT_GPIO_PIN, GPIO_DIR_IN);

gpio_pin_configure(gpio_dev, SERIAL_BUFFER_ENABLE_GPIO_PIN,
GPIO_DIR_OUT);
#endif

return 0;
}

/* needs to be done after GPIO driver init */
SYS_INIT(particle_boron_init, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
17 changes: 17 additions & 0 deletions boards/arm/particle_boron/board.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright (c) 2019 Foundries.io
*
* SPDX-License-Identifier: Apache-2.0
*/

#ifndef __INC_BOARD_H
#define __INC_BOARD_H

/* pin used to enable the buffer power */
#define SERIAL_BUFFER_ENABLE_GPIO_NAME DT_NORDIC_NRF_GPIO_0_LABEL
#define SERIAL_BUFFER_ENABLE_GPIO_PIN 25

/* pin used to detect V_INT (buffer power) */
#define V_INT_DETECT_GPIO_PIN 2

#endif /* __INC_BOARD_H */
13 changes: 12 additions & 1 deletion boards/arm/particle_boron/particle_boron.dts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

/dts-v1/;
#include <nordic/nrf52840_qiaa.dtsi>
#include <dt-bindings/gpio/gpio.h>
#include "mesh_feather.dtsi"

/ {
Expand All @@ -23,10 +24,20 @@

&uart1 { /* u-blox SARA-U2 or SARA-R4 */
compatible = "nordic,nrf-uarte";
current-speed = <921600>;
current-speed = <115200>;
status = "ok";

tx-pin = <37>;
rx-pin = <36>;
rts-pin = <39>;
cts-pin = <38>;

sara_r4 {
compatible = "ublox,sara-r4";
label = "ublox-sara-r4";
status = "ok";

mdm-power-gpios-gpio = <&gpio0 16 0>;
mdm-reset-gpios-gpio = <&gpio0 12 0>;
};
};
1 change: 0 additions & 1 deletion boards/arm/particle_boron/particle_boron_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ CONFIG_GPIO=y
# enable uart driver
CONFIG_SERIAL=y
CONFIG_UART_0_NRF_UARTE=y
CONFIG_UART_1_NRF_UARTE=y

# enable power I2C interface
CONFIG_I2C=y
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CONFIG_UART_4=y
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mike-scott , why not applying @MaureenHelm's proposal (in d5eda49#r263920854) here?

This is close to what we should get in future, if get read of Kconfig symbols per device instance. Then, the following would do the same:

&arduino_spi {
               status = "ok";
}

Copy link
Contributor Author

@mike-scott mike-scott May 20, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@erwango This PR is now suffering from "scope creep". There are several more additions I want to do, but felt like it would be best to land it as is and then make those changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, this approach doesn't work for WNC-M14A2A (the original modem driver in this PR) -- it uses non-standard pins for UART on the Arduino headers.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@erwango This PR is now suffering from "scope creep".

I'd rather say this is an ambitious PR that could have been split in small pieces.
Please not that I retained myself to request again for splitting board connector dts definitions into dedicated .dtsi files :-).

Anyway, agreed to let this as a further enhancement.

1 change: 1 addition & 0 deletions boards/shields/sparkfun_sara_r4/boards/frdm_k64f.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CONFIG_UART_MCUX_3=y
2 changes: 2 additions & 0 deletions boards/shields/sparkfun_sara_r4/boards/nrf52840_pca10056.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CONFIG_GPIO_NRF_P1=y
CONFIG_UART_1_NRF_UARTE=y
10 changes: 10 additions & 0 deletions boards/shields/sparkfun_sara_r4/boards/nrf52840_pca10056.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* Copyright (c) 2019 Foundries.io
*
* SPDX-License-Identifier: Apache-2.0
*/

&arduino_serial {
tx-pin = <34>;
rx-pin = <33>;
};
12 changes: 12 additions & 0 deletions boards/shields/sparkfun_sara_r4/sparkfun_sara_r4.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Enable u-blox SARA-R4 modem
CONFIG_MODEM=y
CONFIG_MODEM_SHELL=y
CONFIG_MODEM_UBLOX_SARA_R4=y
CONFIG_UART_INTERRUPT_DRIVEN=y

# extend retry timing to 20 seconds for LTE/LTE-M
CONFIG_COAP_INIT_ACK_TIMEOUT_MS=20000

# Hack: disable IPv6 for now
# CONFIG_NET_IPV6 is not set
# CONFIG_NET_CONFIG_NEED_IPV6 is not set
18 changes: 18 additions & 0 deletions boards/shields/sparkfun_sara_r4/sparkfun_sara_r4.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright (c) 2019 Foundries.io
*
* SPDX-License-Identifier: Apache-2.0
*/

&arduino_serial {
current-speed = <115200>;
status = "ok";

sara_r4 {
compatible = "ublox,sara-r4";
label = "ublox-sara-r4";
mdm-power-gpios = <&arduino_header 11 0>; /* D5 */
mdm-reset-gpios = <&arduino_header 12 0>; /* D6 */
status = "ok";
};
};
1 change: 1 addition & 0 deletions boards/shields/wnc_m14a2a/boards/frdm_k64f.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CONFIG_UART_MCUX_2=y
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if instead we add a CONFIG_ARDUINO_SERIAL to drivers/serial/Kconfig, and then the boards can intelligently enable the right instance like they do with the console uart? Something like this in boards/arm/frdm_k64f/Kconfig.defconfig

if UART_MCUX

config UART_MCUX_0
        default y if UART_CONSOLE
config UART_MCUX_2
        default y if ARDUINO_SERIAL
config UART_MCUX_3
        default y if BT_UART

endif # UART_MCUX

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MaureenHelm I like this idea. I was struggling with the abstraction between a shield's UART (arduino_serial) and a HW specific UART (Like if the driver needed to be used directly).

A great example of this is the Particle.io Boron board which has a U-blox SARA-R41xx modem connected to the nRF52840 directly via UART1 vs. a SparkFun LTE Cat M1 shield which has the U-blox SARA-R41xx connected to Arduino R3-compatible headers.

The shield configuration should only reference the arduino_serial and stay away from anything too specific to the device.

However, this approach won't work for the WNC-M14A2A modem. The UART pins are on non-standard Arduino pins. The traditional Arduino UART is actually C16/C17 pins (UART_3) for K64F.

Technically, ARDUINO_SERIAL should enable UART_3 (where BT_UART is identified). And, the BT_UART setting could go away if we migrate that to a shield setup.

26 changes: 26 additions & 0 deletions boards/shields/wnc_m14a2a/boards/frdm_k64f.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright (c) 2019 Foundries.io
*
* SPDX-License-Identifier: Apache-2.0
*/

/*
* WNC-M14A2A shield uses an odd UART available on *some* Arduino-R3-compatible
* headers. It needs to be defined individually.
*/
&uart2 {
current-speed = <115200>;
hw-flow-control;
status = "ok";

wnc_m14a2a: wncm14a2a {
status = "ok";
compatible = "wnc,m14a2a";
label = "wnc-m14a2a";
mdm-boot-mode-sel-gpios = <&arduino_header 7 0>; /* D1 */
mdm-power-gpios = <&arduino_header 8 0>; /* D2 */
mdm-keep-awake-gpios = <&arduino_header 12 0>; /* D6 */
mdm-reset-gpios = <&arduino_header 14 0>; /* D8 */
mdm-shld-trans-ena-gpios = <&arduino_header 15 0>; /* D9 */
};
};
3 changes: 3 additions & 0 deletions boards/shields/wnc_m14a2a/boards/nrf52840_pca10056.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CONFIG_GPIO_NRF_P1=y
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather do it as Kconfig.defconfig than .conf direct setting style

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like I said above, this particular setting can be abstracted under CONFIG_ARDUINO_SERIAL and handled in the board's Kconfig.defconfig. The nRF52840's don't have the same problem as K64F because they can set any pin to serial. The tricky part here is that these settings in the .overlay are unique to this shield:

	tx-pin = <46>;
	rx-pin = <45>;
	rts-pin = <44>;
	cts-pin = <47>;

The standard Arduino serial pins are different.

CONFIG_UART_1_NRF_UARTE=y
CONFIG_UART_1_NRF_FLOW_CONTROL=y
31 changes: 31 additions & 0 deletions boards/shields/wnc_m14a2a/boards/nrf52840_pca10056.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright (c) 2019 Foundries.io
*
* SPDX-License-Identifier: Apache-2.0
*/

/*
* WNC-M14A2A shield uses an odd UART available on *some* Arduino-R3-compatible
* headers. It needs to be defined individually.
*/
&uart1 {
current-speed = <115200>;
hw-flow-control;
status = "ok";

tx-pin = <46>;
rx-pin = <45>;
rts-pin = <44>;
cts-pin = <47>;

wnc_m14a2a: wncm14a2a {
status = "ok";
compatible = "wnc,m14a2a";
label = "wnc-m14a2a";
mdm-boot-mode-sel-gpios = <&arduino_header 7 0>; /* D1 */
mdm-power-gpios = <&arduino_header 8 0>; /* D2 */
mdm-keep-awake-gpios = <&arduino_header 12 0>; /* D6 */
mdm-reset-gpios = <&arduino_header 14 0>; /* D8 */
mdm-shld-trans-ena-gpios = <&arduino_header 15 0>; /* D9 */
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@
CONFIG_MODEM=y
mike-scott marked this conversation as resolved.
Show resolved Hide resolved
CONFIG_MODEM_SHELL=y
CONFIG_MODEM_WNCM14A2A=y

# Connect to public LwM2M server (leshan.ecplise.org)
CONFIG_NET_CONFIG_PEER_IPV4_ADDR="5.39.83.206"
CONFIG_UART_INTERRUPT_DRIVEN=y

# extend retry timing to 20 seconds for LTE/LTE-M
CONFIG_COAP_INIT_ACK_TIMEOUT_MS=20000

# Hack: disable IPv6 for now
CONFIG_NET_IPV6=n
CONFIG_NET_CONFIG_NEED_IPV6=n
CONFIG_UART_INTERRUPT_DRIVEN=y
7 changes: 7 additions & 0 deletions boards/shields/wnc_m14a2a/wnc_m14a2a.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
* Copyright (c) 2019 Foundries.io
*
* SPDX-License-Identifier: Apache-2.0
*/

/* File meant to be empty */
Loading