Skip to content

Conversation

@mike-scott
Copy link
Contributor

I took some time today to see if I could setup a "shield" to represent the AT&T LTE-M WNC-M14A2A-based Arduino-R3 compatible shield.

This is very rough work and generates a few warnings when compiling, but this RFC patch series handles the following "special cases" which I encountered:

  • I felt like a shield-based .conf file simplified everything. So I added handling for that (as opposed to adding overlay-conf files into each sample or creating special samples for the shield).
  • AT&T LTE-M shield uses non-standard UART pins on the headers and Nordic UART needs tx, rx, cts and rts pins configured for nRF52840_pca10056, so I added handling for [shield]X[board].overlay files which could be board specific.
  • No current shields use GPIOs, and in order to configure the A0-A5 & D0-D13 Arduino pins, I created a new dts binding for arduino-header-r3.
  • Then I configured those pins in the frdm_k64f and nrf52840_pca10056 DTS files and assign them arduino_d1/d2 handle names.
  • I adjusted the WNC-M14A2A modem driver and DTS bindings slightly to allow for the use of aliases for the pins instead of the dts-binding gpios. This way driver can be used for the shield-based WNC-M14A2A or if a piece of HW had the modem directly connected, it could still be configured completely in the board's DTS.
  • Finally I add the actual wnc_m14a2a shield complete with it's own overlay file, conf file, and board-based overlays. (Missing docs for the moment).

The following now works to build the LwM2M client for each of the 2 configured boards:

$ cd samples/net/lwm2m_client/
$ mkdir build && cd build
$ cmake -DBOARD=frdm_k64f -DSHIELD=wnc_m14a2a ..
or
$ cmake -DBOARD=nrf52840_pca10056 -DSHIELD=wnc_m14a2a ..

These warnings are generated since I named the alias "gpios":

nrf52840_pca10056.dts_compiled: Warning (gpios_property): /aliases:dt-wnc-m14a2a-0-mdm-boot-mode-sel-gpios: cell 0 is not a phandle reference
nrf52840_pca10056.dts_compiled: Warning (gpios_property): /aliases:dt-wnc-m14a2a-0-mdm-boot-mode-sel-gpios: Could not get phandle node for (cell 0)
nrf52840_pca10056.dts_compiled: Warning (gpios_property): /aliases:dt-wnc-m14a2a-0-mdm-power-gpios: cell 0 is not a phandle reference
nrf52840_pca10056.dts_compiled: Warning (gpios_property): /aliases:dt-wnc-m14a2a-0-mdm-power-gpios: Could not get phandle node for (cell 0)
nrf52840_pca10056.dts_compiled: Warning (gpios_property): /aliases:dt-wnc-m14a2a-0-mdm-keep-awake-gpios: cell 0 is not a phandle reference
nrf52840_pca10056.dts_compiled: Warning (gpios_property): /aliases:dt-wnc-m14a2a-0-mdm-keep-awake-gpios: Could not get phandle node for (cell 0)
nrf52840_pca10056.dts_compiled: Warning (gpios_property): /aliases:dt-wnc-m14a2a-0-mdm-reset-gpios: cell 0 is not a phandle reference
nrf52840_pca10056.dts_compiled: Warning (gpios_property): /aliases:dt-wnc-m14a2a-0-mdm-reset-gpios: Could not get phandle node for (cell 0)
nrf52840_pca10056.dts_compiled: Warning (gpios_property): /aliases:dt-wnc-m14a2a-0-mdm-shld-trans-ena-gpios: cell 0 is not a phandle reference
nrf52840_pca10056.dts_compiled: Warning (gpios_property): /aliases:dt-wnc-m14a2a-0-mdm-shld-trans-ena-gpios: Could not get phandle node for (cell 0)

However, it looks like the generated include file has the right defines/values in it.

I am also working on the U-blox SARA R41xx modem driver, which is present in the Particle.io Boron board as well as a SparkFun LTE-M Arduino shield. It uses the standard UART exposed by Arduino so it won't need per board .overlay files, but this series solves a lot of the issues I am hitting with that driver as well (reset and power GPIOs, etc).

Please discuss.

@mike-scott mike-scott added area: Drivers RFC Request For Comments: want input from the community area: Shields Shields (add-on boards) labels Mar 5, 2019
@zephyrbot
Copy link

zephyrbot commented Mar 5, 2019

All checks are passing now.

Review history of this comment for details about previous failed status.
Note that some checks might have not completed yet.

Copy link
Contributor

@SebastianBoe SebastianBoe left a comment

Choose a reason for hiding this comment

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

The approach looks sane.

I'd prefer it if we could express this pattern in DT source code, instead of in the toolchain, but AFAICT this is impossible.

This pattern needs documentation.

@mike-scott
Copy link
Contributor Author

@SebastianBoe Thank you for the great feedback! I'll put up a v2 with your comments accounted for.

@mike-scott mike-scott force-pushed the master-wncm14a2a-shield branch 2 times, most recently from 005c048 to 8581444 Compare March 7, 2019 19:05
@mike-scott
Copy link
Contributor Author

Fixed gitlint issue

@mike-scott
Copy link
Contributor Author

@erwango Are you planning to be main CODEOWNER for boards/shields/?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This needs to be discussed as I think a change in our DTS processing is needed for:

  1. To remove the warning generated by these aliases using labels with a "gpios" portion in their name
    OR
  2. Perhaps we can make a change which would allow the actual GPIO setting in the modem DTS to be assigned a label:
    mdm-boot-mode-sel-gpios = &arduino_d1;
    This would make these hacky aliases go away.

Copy link
Member

Choose a reason for hiding this comment

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

I'll try to discuss this at connect with dts guys.

@erwango
Copy link
Member

erwango commented Mar 8, 2019

@mike-scott

Are you planning to be main CODEOWNER for boards/shields/?

I thought I was already, but indeed, it appears this is not the case. So, if you volunteer, please go ahead. Otherwise, answer is yes.

Copy link
Member

@MaureenHelm MaureenHelm left a comment

Choose a reason for hiding this comment

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

Thanks @mike-scott for tackling this problem! It's been blocking me from converting the MCR20A to a shield for quite some time.

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.

@mike-scott
Copy link
Contributor Author

@mike-scott

Are you planning to be main CODEOWNER for boards/shields/?

I thought I was already, but indeed, it appears this is not the case. So, if you volunteer, please go ahead. Otherwise, answer is yes.

@erwango Feel free to take ownership of the boards/shields dir. My Zephyr plate is fairly full considering I'm working at a starving startup. :)

@mike-scott mike-scott force-pushed the master-wncm14a2a-shield branch from 8581444 to fda5413 Compare March 10, 2019 05:27
erwango added a commit to erwango/zephyr that referenced this pull request Mar 11, 2019
Following new shield introduction in zephyrproject-rtos#14057, it has been highlighted
there was no codeowner for boards/shields/.
Assign erwango as codeowner.

Signed-off-by: Erwan Gouriou <[email protected]>
nashif pushed a commit that referenced this pull request Mar 11, 2019
Following new shield introduction in #14057, it has been highlighted
there was no codeowner for boards/shields/.
Assign erwango as codeowner.

Signed-off-by: Erwan Gouriou <[email protected]>
@mike-scott
Copy link
Contributor Author

recheck

@mike-scott
Copy link
Contributor Author

@WilliamGFish There are a couple more changes coming, but which modem were you testing?

I have been working with a modified sara-r4 driver on u201 on a particle boron.
Up until I pulled the last ~13 commits it had been working just fine, odd errors but there network related.

The error occurs when attempting :
/* Set iface up */
net_if_up(ictx.iface);

Can you try testing w/ these 2 changes to the prj.conf:
CONFIG_NET_IPV6=n
CONFIG_NET_CONFIG_NEED_IPV6=n

mike-scott added 18 commits May 20, 2019 09:23
Caller will handle freeing packet if error is encountered.

Fixes issue reported by Github User @weinholtendian:
<err> net_pkt: *** ERROR *** pkt 0x20027e78 is freed already
by offload_sendto():1717 (context_sendto():1473).

Signed-off-by: Michael Scott <[email protected]>
Assert is checking the array size of pinconfig.  Not the actual
size of the structure.

Fixes issue reported by Github User @weinholtendian

Signed-off-by: Michael Scott <[email protected]>
The label binding was missed during initial development of the
WNC-M14A2A modem.  Let's add the binding so that during the
migration to a shield, we can update the DTS correctly.

Signed-off-by: Michael Scott <[email protected]>
This allows HW with compatible headers to define the related GPIOs

Signed-off-by: Michael Scott <[email protected]>
Let's expose the Arduino R3-compatible pin definition as DTS
for the frdm_k64f board.

Signed-off-by: Michael Scott <[email protected]>
Let's expose the Arduino R3-compatible pin definition as DTS
for the nrf542840_pca10056 board.

Signed-off-by: Michael Scott <[email protected]>
Let's expose the Arduino R3-compatible pin definition as DTS
for the disco_l475_iot1 board.

Signed-off-by: Michael Scott <[email protected]>
Let's remove the sample-specific overlay files dealing with the
WNC-M14A2A modem.

Signed-off-by: Michael Scott <[email protected]>
Shields can often be very complex to setup in a generic way for several
boards to support.  Let's allow shields to have their own .conf files
as well as specialized overlays per board (when needed).

Signed-off-by: Michael Scott <[email protected]>
This shield uses a non-standard UART exposed via Arduino-R3
compatible header pins.

It has configurations for FRDM_K64F and nRF52840_PCA10056.

Signed-off-by: Michael Scott <[email protected]>
The WNC-M14A2A shield configuration has HW specific settings in place.
We can remove those settings here.

Signed-off-by: Michael Scott <[email protected]>
Let's change the specific WNC-M14A2A check into a more generic
MODEM check for enabling ethernet.  Many of these pins are used
on the Arduino headers.

Signed-off-by: Michael Scott <[email protected]>
Instead of using the now removed overlay files, use the SHIELD=
command-line option for testing the WNC-M14A2A modem.

Signed-off-by: Michael Scott <[email protected]>
The SARA-R4 series modules from U-Blox are size-optimized LTE-M /
NB-IoT and EGPRS modules designed for low power consumption and
longer battery life.

The binding identifies the UART device, power GPIO and reset GPIO
lines.

Signed-off-by: Michael Scott <[email protected]>
The u-blox SARA-R4 modem modules are Ultra-compact LTE Cat
M1 / NB1 ready:

- Configurable with a single hardware version
- Flexible mode selection as LTE Cat M1, LTE Cat NB1, EGPRS -
  only/preferred
- Low power consumption and longer battery life
- Extended range in buildings, basements, and with NB1,
  underground

This driver introduces support for basic AT commands to
query modem information as well as socket connection
for TCP/UDP communication.

Signed-off-by: Michael Scott <[email protected]>
Setup the SARA-R4 POWER and RESET pins as gpios.

Signed-off-by: Michael Scott <[email protected]>
SparkFun offers an Arduino-R3 compatible shield using the SARA-R410M-02B
LTE Cat M1/NB-IoT modem.

Now, that the basic SARA-R4 modem driver is implemented, let's enable
the shield for several MCUs supporting Arduino-R3 compatible headers.

Product Link:
https://www.sparkfun.com/products/14997

Signed-off-by: Michael Scott <[email protected]>
The Particle.io Boron is an nRF52840-based board with a connected
u-blox SARA-R4 modem.  The main board was previously upstreamed
without modem support.

Now that we have a driver to support the SARA-R4 modem, let's enable
it for the Boron board.

Signed-off-by: Michael Scott <[email protected]>
@mike-scott mike-scott force-pushed the master-wncm14a2a-shield branch from 8870e9c to a56e073 Compare May 20, 2019 16:26
@mike-scott
Copy link
Contributor Author

Rebased and addressed gitlint and license issues.

@zephyrproject-rtos zephyrproject-rtos deleted a comment from codecov-io May 21, 2019
@nashif nashif merged commit e2b45e6 into zephyrproject-rtos:master May 21, 2019
@MaureenHelm MaureenHelm mentioned this pull request Jul 5, 2019
@mike-scott mike-scott deleted the master-wncm14a2a-shield branch August 12, 2019 05:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: Drivers area: Shields Shields (add-on boards)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants