Skip to content

Conversation

jia200x
Copy link
Member

@jia200x jia200x commented Jul 29, 2020

Contribution description

This PR is rebased on top of #14371 and add all radios implemented so far for testing the Radio HAL API.
This means:

  • A POC implementation for AT86RF2xx (doesn't include subghz stuff) 27ae6c3
  • An (almost) ready to merge implementation for nrf52840 f726f00
  • A ready to merge implementation for CC2538 ebeb695
  • A test application for testing these 3 radios. 5aebfa9

Testing procedure

  1. Check the implementations of the radio HAL for each radio. Please focus on the ieee802154_radio_ops_timplementation
  2. Run tests/ieee802154_hal test (for any of this radios).
  • Test setting channel and TX power with the config_phy command:
2020-08-12 18:24:49,390 #  config_phy
2020-08-12 18:24:49,393 # Usage: config_phy <channel> <tx_pow>

An out of range value for TX power should give an error

  • Send data between nodes using the txtsnd command.
Usage: txtsnd <long_addr> <len>

It's possible to get the long address with the print_addr command.

  • Perform CCa with the cca command:
2020-08-12 18:28:57,628 #  cca
2020-08-12 18:28:57,629 # CLEAR
> 2020-08-12 18:28:57,827 #  cca
2020-08-12 18:28:57,828 # CLEAR
> 2020-08-12 18:28:58,157 #  cca
2020-08-12 18:28:58,158 # CLEAR
> 2020-08-12 18:28:58,334 #  cca
2020-08-12 18:28:58,335 # BUSY
> 2020-08-12 18:28:58,473 #  cca
2020-08-12 18:28:58,474 # CLEAR
  • Change the CCA mode and the threshold with the config_cca command:
config_cca <ed|cs|or|and> [ED threshold]>

Note the ED is in dBm. The ED threshold doesn't affect the Carrier Sense mode (CCA mode 2).

  • Try different TX modes (CSMA-CA, CCA, direct transmission) using the tx_mode command:
Usage: tx_mode <csma_ca|cca|direct>
  • Try different RX states (ACK on, ACK disabled, ACK with Frame Pending or Promiscuous mode) with the rx_mode command:
Usage: rx_mode <on|off|pend|promisc>

Use a sniffer to check if the receiver sends ACK. As expected, a radio with Promiscuous Mode will receive all kind of packets with correct FCS.

  • Use the caps command to get the available caps for a given device:
2020-08-13 13:33:37,385 # caps
2020-08-13 13:33:37,388 #                CAPS              
2020-08-13 13:33:37,391 # =================================
2020-08-13 13:33:37,394 # - Frame Retransmissions:        y
2020-08-13 13:33:37,397 #     * Info retries:             y
2020-08-13 13:33:37,400 # - Auto CSMA-CA:                 y
2020-08-13 13:33:37,403 # - 2.4 GHz band:                 y
2020-08-13 13:33:37,406 # - SubGHz band:                  n
2020-08-13 13:33:37,412 # - TX DONE indication:           y
2020-08-13 13:33:37,415 #     * ACK Timeout indication:   n
2020-08-13 13:33:37,418 # - RX_START indication:          n
2020-08-13 13:33:37,420 # - CCA Done indication:          y

Example session between a cc2538dk and nrf52840:

NRF52840:
2020-07-29 18:19:56,350 # Initialization successful - starting the shell now
print_addrli
2020-07-29 18:20:05,050 #  print_addr
2020-07-29 18:20:05,051 # 3a72df8cb6556f1d
> 2020-07-29 18:20:07,537 #  Packet received:
2020-07-29 18:20:07,549 # 61 dc 00 23 00 1d 6f 55 b6 8c df 72 3a 25 2e 42 fe 23 31 68 22 4c 6f 72 65 6d 20 69 70 73 75 6d 20 64 6f 6c 6f 72 20 73 69 74 2
txtsnd 22683123fe422e25 100
2020-07-29 18:20:10,986 # txtsnd 22683123fe422e25 100
2020-07-29 18:20:10,993 # TX_DONE!
> txtsnd 22683123fe422e2e 100
2020-07-29 18:20:20,533 #  txtsnd 22683123fe422e2e 100
2020-07-29 18:20:20,538 # TX_DONE!
> config_phy 19 14
2020-07-29 18:20:29,788 #  config_phy 19 14
2020-07-29 18:20:29,790 # Success!
> 2020-07-29 18:20:45,803 #  Packet received:
2020-07-29 18:20:45,816 # 61 dc 03 23 00 1d 6f 55 b6 8c df 72 3a 25 2e 42 fe 23 31 68 22 4c 6f 72 65 6d 20 69 70 73 75 6d 20 64 6f 6c 6f 72 20 73 69 74 2
> 2020-07-29 18:20:53,906 #  Packet received:
2020-07-29 18:20:53,918 # 61 dc 04 23 00 1d 6f 55 b6 8c df 72 3a 25 2e 42 fe 23 31 68 22 4c 6f 72 65 6d 20 69 70 73 75 6d 20 64 6f 6c 6f 72 20 73 69 74 2
> 2020-07-29 18:21:00,818 #  Packet received:
2020-07-29 18:21:00,831 # 61 dc 05 23 00 1d 6f 55 b6 8c df 72 3a 25 2e 42 fe 23 31 68 22 4c 6f 72 65 6d 20 69 70 73 75 6d 20 64 6f 6c 6f 72 20 73 69 74 2
> 2020-07-29 18:21:09,375 #  Packet received:
2020-07-29 18:21:09,388 # 61 dc 06 23 00 1d 6f 55 b6 8c df 72 3a 25 2e 42 fe 23 31 68 22 4c 6f 72 65 6d 20 69 70 73 75 6d 20 64 6f 6c 6f 72 20 73 69 74 2
2020-07-29 18:21:10,038 # Packet received:
2020-07-29 18:21:10,051 # 61 dc 07 23 00 1d 6f 55 b6 8c df 72 3a 25 2e 42 fe 23 31 68 22 4c 6f 72 65 6d 20 69 70 73 75 6d 20 64 6f 6c 6f 72 20 73 69 74 2
txtsnd 22683123fe422e25 100
2020-07-29 18:21:17,263 # txtsnd 22683123fe422e25 100
2020-07-29 18:21:17,270 # TX_DONE!
> txtsnd 22683123fe422e25 100
2020-07-29 18:21:17,785 #  txtsnd 22683123fe422e25 100
2020-07-29 18:21:17,791 # TX_DONE!
> txtsnd 22683123fe422e25 100
2020-07-29 18:21:18,249 #  txtsnd 22683123fe422e25 100
2020-07-29 18:21:18,255 # TX_DONE!
CC2538DK
2020-07-29 18:17:33,401 # Initialization successful - starting the shell now
print_addr00
2020-07-29 18:17:35,792 #  print_addr
2020-07-29 18:17:35,792 # 22683123fe422e25
txtsnd 3a72df8cb6556f1d 100
2020-07-29 18:19:27,311 #  txtsnd 3a72df8cb6556f1d 100
2020-07-29 18:19:27,316 # TX_DONE!
2020-07-29 18:19:46,682 #  Packet received:
2020-07-29 18:19:46,683 # 61 dc 00 23 00 25 2e 42 fe 23 31 68 22 1d 6f 55 b6 8c df 72 3a LQI: 229, RSSI: 6
2020-07-29 18:19:46,683 # 
2020-07-29 18:19:51,729 # Packet received:
2020-07-29 18:19:51,767 # 61 dc 01 23 00 25 2e 42 fe 23 31 68 22 1d 6f 55 b6 8c df 72 3a 4c 6f 72 65 6d 20 69 70 73 75 6d 20 64 6f 6c 6f 72 20 73 69 74 20 61 6d 65 74 2c 20 63 6f 6e 73 65 63 74 65 74 75 72 20 61 64 69 70 69 73 63 69 6e 67 20 65 6c 69 74 2e 20 45 74 69 61 6d 20 6f 72 6e 61 72 65 20 6c 61 63 69 6e 69 61 20 6d 69 20 65 6c 65 6d 65 6e 74 75 6d 20 69 6e 74 65 72 64 75 6d 20 LQI: 238, RSSI: 6
2020-07-29 18:19:51,767 # 
2020-07-29 18:19:57,567 # main(): This is RIOT! (Version: 2020.07-devel-1612-gdd739-pr/radio_hal_tester)
2020-07-29 18:19:57,568 # Initialization successful - starting the shell now
print_addr00
2020-07-29 18:20:02,218 #  print_addr
2020-07-29 18:20:02,219 # 22683123fe422e25
txtsnd 3a72df8cb6556f1d 100
2020-07-29 18:20:07,531 #  txtsnd 3a72df8cb6556f1d 100
2020-07-29 18:20:07,536 # TX_DONE!
> 2020-07-29 18:20:10,993 #  Packet received:
2020-07-29 18:20:11,030 # 61 dc 00 23 00 25 2e 42 fe 23 31 68 22 1d 6f 55 b6 8c df 72 3a 4c 6f 72 65 6d 20 69 70 73 75 6d 20 64 6f 6c 6f 72 20 73 69 74 20 61 6d 65 74 2c 20 63 6f 6e 73 65 63 74 65 74 75 72 20 61 64 69 70 69 73 63 69 6e 67 20 65 6c 69 74 2e 20 45 74 69 61 6d 20 6f 72 6e 61 72 65 20 6c 61 63 69 6e 69 61 20 6d 69 20 65 6c 65 6d 65 6e 74 75 6d 20 69 6e 74 65 72 64 75 6d 20 LQI: 233, RSSI: 7
2020-07-29 18:20:11,030 # 
txtsnd 3a72df8cb6556f1e 100
2020-07-29 18:20:16,934 # txtsnd 3a72df8cb6556f1e 100
2020-07-29 18:20:16,940 # TX_DONE!
txtsnd 3a72df8cb6556f1d 100
2020-07-29 18:20:38,113 #  txtsnd 3a72df8cb6556f1d 100
2020-07-29 18:20:38,118 # TX_DONE!
> config_phy 19 14
2020-07-29 18:20:44,729 #  config_phy 19 14
2020-07-29 18:20:44,730 # Success!
txtsnd 3a72df8cb6556f1d 100
2020-07-29 18:20:45,798 #  txtsnd 3a72df8cb6556f1d 100
2020-07-29 18:20:45,802 # TX_DONE!
> txtsnd 3a72df8cb6556f1d 100
2020-07-29 18:20:53,900 #  txtsnd 3a72df8cb6556f1d 100
2020-07-29 18:20:53,905 # TX_DONE!
> txtsnd 3a72df8cb6556f1d 100
2020-07-29 18:21:00,812 #  txtsnd 3a72df8cb6556f1d 100
2020-07-29 18:21:00,817 # TX_DONE!
> txtsnd 3a72df8cb6556f1d 100
2020-07-29 18:21:09,369 #  txtsnd 3a72df8cb6556f1d 100
2020-07-29 18:21:09,374 # TX_DONE!
> txtsnd 3a72df8cb6556f1d 100
2020-07-29 18:21:10,033 #  txtsnd 3a72df8cb6556f1d 100
2020-07-29 18:21:10,037 # TX_DONE!
> 2020-07-29 18:21:17,270 #  Packet received:
2020-07-29 18:21:17,311 # 61 dc 0b 23 00 25 2e 42 fe 23 31 68 22 1d 6f 55 b6 8c df 72 3a 4c 6f 72 65 6d 20 69 70 73 75 6d 20 64 6f 6c 6f 72 20 73 69 74 20 61 6d 65 74 2c 20 63 6f 6e 73 65 63 74 65 74 75 72 20 61 64 69 70 69 73 63 69 6e 67 20 65 6c 69 74 2e 20 45 74 69 61 6d 20 6f 72 6e 61 72 65 20 6c 61 63 69 6e 69 61 20 6d 69 20 65 6c 65 6d 65 6e 74 75 6d 20 69 6e 74 65 72 64 75 6d 20 LQI: 238, RSSI: 7
2020-07-29 18:21:17,311 # 
2020-07-29 18:21:17,791 # Packet received:
2020-07-29 18:21:17,828 # 61 dc 0c 23 00 25 2e 42 fe 23 31 68 22 1d 6f 55 b6 8c df 72 3a 4c 6f 72 65 6d 20 69 70 73 75 6d 20 64 6f 6c 6f 72 20 73 69 74 20 61 6d 65 74 2c 20 63 6f 6e 73 65 63 74 65 74 75 72 20 61 64 69 70 69 73 63 69 6e 67 20 65 6c 69 74 2e 20 45 74 69 61 6d 20 6f 72 6e 61 72 65 20 6c 61 63 69 6e 69 61 20 6d 69 20 65 6c 65 6d 65 6e 74 75 6d 20 69 6e 74 65 72 64 75 6d 20 LQI: 238, RSSI: 8
2020-07-29 18:21:17,829 # 
2020-07-29 18:21:18,256 # Packet received:
2020-07-29 18:21:18,296 # 61 dc 0d 23 00 25 2e 42 fe 23 31 68 22 1d 6f 55 b6 8c df 72 3a 4c 6f 72 65 6d 20 69 70 73 75 6d 20 64 6f 6c 6f 72 20 73 69 74 20 61 6d 65 74 2c 20 63 6f 6e 73 65 63 74 65 74 75 72 20 61 64 69 70 69 73 63 69 6e 67 20 65 6c 69 74 2e 20 45 74 69 61 6d 20 6f 72 6e 61 72 65 20 6c 61 63 69 6e 69 61 20 6d 69 20 65 6c 65 6d 65 6e 74 75 6d 20 69 6e 74 65 72 64 75 6d 20 LQI: 238, RSSI: 7

Issues/PRs references

#14371
#13943

@jia200x jia200x force-pushed the pr/radio_hal_tester branch 2 times, most recently from 7a7eb95 to 13ed540 Compare July 29, 2020 16:38
@jia200x
Copy link
Member Author

jia200x commented Jul 29, 2020

@PeterKietzmann @maribu @benpicco if you all agree, I would like to move the CC2538 commits out of #14371 and move them here. That way #14371 only focus on the API. I can keep rebasing this one.

@jia200x
Copy link
Member Author

jia200x commented Jul 30, 2020

done!

Copy link
Member

@PeterKietzmann PeterKietzmann left a comment

Choose a reason for hiding this comment

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

First test observation:

nrf52840 -> remote-reva : txtsnd <remote-reva addy> 10

  • nrf52840 hangs, remote-reva crashes
  • reset both nodes and send a packet the other way around before
  • nrf52840 will receive the packet
  • now repeat nrf52840->remote-reva
  • nrf52840 will indicate that it receive a packet and hang. It is still receive-ready though.

case IEEE802154_RADIO_CONFIRM_CCA:
mutex_unlock(&lock);
break;
case IEEE802154_RADIO_INDICATION_RX_DONE:
Copy link
Member

Choose a reason for hiding this comment

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

Add IEEE802154_RADIO_INDICATION_RX_START and IEEE802154_RADIO_CONFIRM_ACK_TIMEOUT here

ieee802154_radio_write(_dev, pkt);

/* If the radio supports frame retransmissions (thus, CSMA-CA), send with
* CSMA-CA. Otherwise, send without any kind of collision avoidance */
Copy link
Member

Choose a reason for hiding this comment

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

Add a note that this would be the task of a MAC layer (SubMAC) to justify that it is out of scope for the radio HAL


/* Set PHY configuration */
ieee802154_phy_conf_t conf = {.channel=21, .page=0, .pow=1000};
ieee802154_radio_config_phy(_dev, &conf);
Copy link
Member

Choose a reason for hiding this comment

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

#define parameters in header of file

ieee802154_radio_set_hw_addr_filter(_dev, (uint8_t*) &short_addr, (uint8_t*) &ext_addr, 0x23);

/* Set PHY configuration */
ieee802154_phy_conf_t conf = {.channel=21, .page=0, .pow=1000};
Copy link
Member

Choose a reason for hiding this comment

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

1000dBm?

Copy link
Member Author

Choose a reason for hiding this comment

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

.iol_next = NULL,
};

flags = IEEE802154_FCF_TYPE_DATA | 0x20;
Copy link
Member

Choose a reason for hiding this comment

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

Use IEEE802154_FCF_ACK_REQ?

return send(addr, res, len);
}

int config_phy(int argc, char **argv)
Copy link
Member

Choose a reason for hiding this comment

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

A bit confusing the shell function is names similar to the HAL function

ifneq (,$(filter nrf52840dk,$(BOARD)))
DRIVER := nrf802154
endif
ifneq (,$(filter cc2538dk,$(BOARD)))
Copy link
Member

Choose a reason for hiding this comment

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

Would be fine to check for the CC2538 MCU here. However, you were talking about the remote-rev% board somewhere, not cc2538dk.

@PeterKietzmann
Copy link
Member

I think we should specify a test procedure according to which we test all combinations of devices

@miri64 miri64 added Area: drivers Area: Device drivers Area: network Area: Networking State: demonstrator State: This PR (loosely) demonstrates a concept and is not necessarily meant to be merged. Type: new feature The issue requests / The PR implemements a new feature for RIOT Type: tracking The issue tracks and organizes the sub-tasks of a larger effort labels Jul 31, 2020
@PeterKietzmann
Copy link
Member

The issues reported here are fixed with #14672 and #14673.

ieee802154_dev_t *dev = &nrf802154_hal_dev;

ack[0] = 5;
ack[1] = 0x02;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
ack[1] = 0x02;
ack[1] = IEEE802154_FCF_TYPE_ACK;

(void)chan;
ieee802154_dev_t *dev = &nrf802154_hal_dev;

ack[0] = 5;
Copy link
Contributor

@benpicco benpicco Aug 3, 2020

Choose a reason for hiding this comment

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

Do we have defines for that?

Suggested change
ack[0] = 5;
ack[0] = 5; /* frame length */

Comment on lines 358 to 360
ack[0] = 5;
ack[1] = 0x02;
ack[2] = 0;
Copy link
Contributor

@benpicco benpicco Aug 3, 2020

Choose a reason for hiding this comment

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

We might just initialize that part once and never touch it, should always stay constant.

ack[0] = 5;
ack[1] = 0x02;
ack[2] = 0;
ack[3] = rxbuf[3];
Copy link
Contributor

@benpicco benpicco Aug 3, 2020

Choose a reason for hiding this comment

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

~~sequence number should be ack[2] ~~

802.15.4 frame structure

nvm this includes the frame length

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, this includes frame length. I will add a macro for the magic number

Copy link
Contributor

Choose a reason for hiding this comment

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

sizeof(ack) would be enough. There are already maces for the rest.

@jia200x jia200x force-pushed the pr/radio_hal_tester branch from daf4111 to 7eeeed9 Compare August 4, 2020 15:17
@jia200x
Copy link
Member Author

jia200x commented Aug 4, 2020

updated to latest changes of #14371

@jia200x
Copy link
Member Author

jia200x commented Aug 5, 2020

I had to re-implement the set_trx_state function of nrf52840. The radio behaves weird when switching from TX to RX mode without going to DISABLED state (as seen in the ERRATA, Nº 204: "Switching between TX and RX causes unwanted emissions").

I also needed to enable Fast RX-TX transition (this means I had to manually calculate IFS times and reject a transmit request if it doesn't meet the IFS criteria)

@jia200x jia200x force-pushed the pr/radio_hal_tester branch 2 times, most recently from 57be8fb to 3569a98 Compare August 7, 2020 11:12
@benpicco
Copy link
Contributor

So how do we proceed?
Want to make separate PRs for the individual drivers?

@jia200x
Copy link
Member Author

jia200x commented Aug 19, 2020

I would say so. The CC2420 is in an ok-ish state (I just need to fix some labels and minor stuff). The nrf52840 is also not so far from being in a mergeable state.

The at86rf2xx might need some love.

@jia200x jia200x force-pushed the pr/radio_hal_tester branch from 70c1fc5 to cabdb5e Compare August 19, 2020 11:19
@jia200x
Copy link
Member Author

jia200x commented Aug 19, 2020

Rebased. I will leave this PR open as a reference and open implementations for the radios.

@jia200x jia200x force-pushed the pr/radio_hal_tester branch from c213fd5 to 433a05a Compare September 4, 2020 09:36
@jia200x
Copy link
Member Author

jia200x commented Oct 1, 2020

since we already have a couple of radios merged with the new Radio HAL API, I think we can close this one.

@jia200x jia200x closed this Oct 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: drivers Area: Device drivers Area: network Area: Networking State: demonstrator State: This PR (loosely) demonstrates a concept and is not necessarily meant to be merged. Type: new feature The issue requests / The PR implemements a new feature for RIOT Type: tracking The issue tracks and organizes the sub-tasks of a larger effort
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants