-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[WIP] cpu/cc26x2_cc13x2: add sub-ghz driver #18737
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Jean Pierre Dudey <jeandudey@hotmail.com>
This adds the necessary structures to communicate with the RF Core. Signed-off-by: Jean Pierre Dudey <jeandudey@hotmail.com>
This is a patch distributed on the TI SDK for the Command and Packet Engine when the mode is the propietary PHY layer. Signed-off-by: Jean Pierre Dudey <jeandudey@hotmail.com>
Signed-off-by: Jean Pierre Dudey <me@jeandudey.tech>
This driver implements the ieee802154_hal interface. Signed-off-by: Jean Pierre Dudey <jeandudey@hotmail.com>
Signed-off-by: Jean Pierre Dudey <jeandudey@hotmail.com>
Signed-off-by: Jean Pierre Dudey <jeandudey@hotmail.com>
Signed-off-by: Jean Pierre Dudey <jeandudey@hotmail.com>
Signed-off-by: Jean Pierre Dudey <me@jeandudey.tech>
Also whitelisted the boards that support the `cc26x2_cc13x2_rf` IEEE 802.15.4g Sub-GHz radio. Signed-off-by: Jean Pierre Dudey <me@jeandudey.tech>
Signed-off-by: Jean Pierre Dudey <me@jeandudey.tech>
#define IEEE802154_SUN_PHY_FREQ_169_MHZ 0 /**< 169.400-169.475 (Europe) */ | ||
#define IEEE802154_SUN_PHY_FREQ_450_MHZ 1 /**< 450-470 (US FCC Part 22/90) */ | ||
#define IEEE802154_SUN_PHY_FREQ_470_MHZ 2 /**< 470-510 (China) */ | ||
#define IEEE802154_SUN_PHY_FREQ_780_MHZ 3 /**< 779-787 (China) */ | ||
#define IEEE802154_SUN_PHY_FREQ_863_MHZ 4 /**< 863-870 (Europe) */ | ||
#define IEEE802154_SUN_PHY_FREQ_896_MHZ 5 /**< 896-901 (US FCC Part 90) */ | ||
#define IEEE802154_SUN_PHY_FREQ_901_MHZ 6 /**< 901-902 (US FCC Part 24) */ | ||
#define IEEE802154_SUN_PHY_FREQ_915_MHZ 7 /**< 902-928 (US) */ | ||
#define IEEE802154_SUN_PHY_FREQ_917_MHZ 8 /**< 917-923.5 (Korea) */ | ||
#define IEEE802154_SUN_PHY_FREQ_920_MHZ 9 /**< 920-928 (Japan) */ | ||
#define IEEE802154_SUN_PHY_FREQ_928_MHZ 10 /**< 928-960 (US, non-contiguous) */ | ||
#define IEEE802154_SUN_PHY_FREQ_950_MHZ 11 /**< 950-958 (Japan) */ | ||
#define IEEE802154_SUN_PHY_FREQ_1427_MHZ 12 /**< 1427-1518 (US and Canada, non-contiguous) */ | ||
#define IEEE802154_SUN_PHY_FREQ_2450_MHZ 13 /**< 2400-2483.5 */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be moved to ieee802154 headers. Might be useful some day there outside of this driver if we manage to develop the descriptors present in the standard.
Don't know if @jia200x would agree on this
Hi, |
Do you have CCS or Uniflash? I'm using uniflash since I know openocd has a problem with these boards. Normally you may be able to use openocd if you have the TI version of it https://git.ti.com/cgit/sdo-emu/openocd |
I have ccs and uniflash installed but I failed to get uniflash invoked by the RIOT toolchain. Are you using an IDE for debugging RIOT on the launchpad or do you use only the terminal? |
No I'm using only the terminal. You may need to export the path to the uniflash binary. On my computer (a Macbook) I have this:
Then RIOT detects it and use it to flash the board. |
@SpooniSpoon have you tried updating the XDS110 firmware? Using CCS or Uniflash UI can do that |
Thanks for the hints. Unfortunately I am sill not able to use uniflash as a programmer. I set the PROGRAMMER and UNIFLASH_PATH environment variables. The GUI version of the uniflash tools works. I am able to compile and program the hello world example by using the GUI version of uniflash. Therefore I think the XDS110 firmware on my launchpad is valid. I am also able to compile the network example with some warnings as expected, but there is no terminal output at all after programming the generated *.bin file with the GUI version of uniflash. |
@SpooniSpoon what's the error you have when you try to flash with uniflash? (actually is rather dslite but both are part of the uniflash software) When I try with the default configuration I have the following error (on a cc1352-launchpad)
However, when I change the serial number of the adaptor in the file cc1352r1_XDS110.ccxml (at Could you maybe try the same? |
Hello, I tried to maintain continuous communication on two cc1312-launchpad boards and got the following error...
The problem is that once this "buffer is too small" message comes out, the network device (Netdev) stops working. |
@kYc0o |
if ((res = cc26x2_cc13x2_rf_request_transmit()) != 0) { | ||
DEBUG("[cc26x2_cc13x2_rf]: failed to transmit\n"); | ||
RFC_DBELL_NONBUF->RFCPEIFG = ~CPE_IRQ_LAST_COMMAND_DONE; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was trying keep in a loop the transmit process until the Radio cpu returns a CPE_IRQ_LAST_COMMAND_DONE
interruption. This would keep alive the network interface during TX/RX operations.
if ((res = cc26x2_cc13x2_rf_request_transmit()) != 0) { | |
DEBUG("[cc26x2_cc13x2_rf]: failed to transmit\n"); | |
RFC_DBELL_NONBUF->RFCPEIFG = ~CPE_IRQ_LAST_COMMAND_DONE; | |
} | |
while ((res = cc26x2_cc13x2_rf_request_transmit()) != 0) { | |
DEBUG("[cc26x2_cc13x2_rf]: failed to transmit\n"); | |
RFC_DBELL_NONBUF->RFCPEIFG = ~CPE_IRQ_LAST_COMMAND_DONE; | |
RFC_DBELL_NONBUF->RFCPEIEN |= CPE_IRQ_LAST_COMMAND_DONE; | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's probably a bug on my side as an error should be returned there, the ieee80215 upper layers should handle failed transmissions if any, maybe a goto end;
would be more appropriate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unrelated to the buffer to small issue though, would be great to check on cc26x2_cc13x2_rf_request_transmit
what is failing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, you are right, this refers to the "failed to transmit" issue, here it's repeating the process to trasmit until obtain a response from the radio CPU. Respecting to the upper layer i saw an issue generated after this error is printed.
Error Generated after "failed to transmit"
2022-10-26 15:02:03,412 # gnrc_netif: can't queue packet for sending
2022-10-26 15:02:03,415 # gnrc_netif: can't queue packet for sending
2022-10-26 15:02:04,412 # gnrc_netif: can't queue packet for sending
So, maybe could be presented in sys/net/gnrc/netif/gnrc_netif.c
between the lines 1844 and 1862
if (max_size < pktlen) { | ||
DEBUG("[cc26x2_cc13x2_rf]: buffer is too small\n"); | ||
entry->status = RFC_DATA_ENTRY_PENDING; | ||
return -ENOBUFS; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eduazocar if you could try again here and print before the if
the max_size
, pktlen
and buf
it would help a lot. It's strange that the caller is passing a buffer too small than the received packet.
(unless a larger than expected frame was received)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in the receive process this is returned:
2022-10-27 00:19:14,691 # [cc26x2_cc13x2_rf]: reading packet of length 43
2022-10-27 00:19:14,692 # Packet length: 43
2022-10-27 00:19:14,694 # Max size: 43
2022-10-27 00:19:14,710 # Buffer: 0x0 0x0 0x0 0x0 0xE8 0x17 0x0 0x0 0x2D 0x3 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0xD8 0x17 0x0 0x0 0x8 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x3 0xFE 0x58 0xB8 0x13 0x0 0x0 0x0 0x0 0x0 0x0
/** | ||
* @brief Data entry general | ||
*/ | ||
typedef struct { | ||
uint8_t* next_entry; /**< Pointer to next entry in the queue */ | ||
uint8_t status; /**< Indicates status of entry, including whether it is free | ||
for the system CPU to write to */ | ||
rfc_data_entry_config_t config; /**< Data entry configuration */ | ||
uint16_t length; /**< For pointer entries: Number of bytes in the data buffer | ||
pointed to. For other entries: Number of bytes | ||
following this length field */ | ||
uint8_t data; /**< First byte of the data array to be received or | ||
transmitted */ | ||
} rfc_data_entry_general_t; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @kYc0o, I have a question about radio_general_data_entry_t structures.
I have been comparing with the datasheet, and the last data element referred to in the code is taking a uint8_t
value, my question is the following, according to what is specified in table 25-11 of the datasheet, the data member should not be a type pointer void
? (I mean void because it is a content of any type and its size is unknown)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's an uint8_t*
pointer because the data it points to is a buffer which happens to contain that structure/header at the start, a void*
works too but it's semantics IMO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well maybe the void*
would solve the casting problem? This warnings were activated on the latest release so I really don't know what was the brackground. E.g.:
/Users/facosta/git/RIOT-OS/RIOT/cpu/cc26x2_cc13x2/radio/cc26x2_cc13x2_rf_radio_ops.c: In function 'cc26x2_cc13x2_rfc_isr':
/Users/facosta/git/RIOT-OS/RIOT/cpu/cc26x2_cc13x2/radio/cc26x2_cc13x2_rf_radio_ops.c:124:28: warning: cast increases required alignment of target type [-Wcast-align]
124 | uint16_t pktlen = *(uint16_t *)&entry->data;
| ^
/Users/facosta/git/RIOT-OS/RIOT/cpu/cc26x2_cc13x2/radio/cc26x2_cc13x2_rf_radio_ops.c: In function '_read':
/Users/facosta/git/RIOT-OS/RIOT/cpu/cc26x2_cc13x2/radio/cc26x2_cc13x2_rf_radio_ops.c:239:15: warning: cast increases required alignment of target type [-Wcast-align]
239 | pktlen = *(uint16_t *)&entry->data;
| ^
/Users/facosta/git/RIOT-OS/RIOT/cpu/cc26x2_cc13x2/radio/cc26x2_cc13x2_rf_radio_ops.c: In function '_len':
/Users/facosta/git/RIOT-OS/RIOT/cpu/cc26x2_cc13x2/radio/cc26x2_cc13x2_rf_radio_ops.c:277:24: warning: cast increases required alignment of target type [-Wcast-align]
277 | uint16_t pktlen = *(uint16_t *)&entry->data;
| ^
Hi @kYc0o! I flash this PR to the cc1352R1 and after reset there are no output and I cannot access shell. If you have debug version of this code I could try run it and send you output. Update. I set After this change and board reset I receive only two logs (few attempts made, always this same result):
|
Could you share the application you try to run on the board? % BOARD=cc1352-launchpad WERROR=0 make -C examples/gnrc_networking flash term
make: Entering directory '/Users/facosta/git/RIOT-OS/RIOT/examples/gnrc_networking'
Building application "gnrc_networking" for "cc1352-launchpad" with MCU "cc26x2_cc13x2".
"make" -C /Users/facosta/git/RIOT-OS/RIOT/boards/cc1352-launchpad
"make" -C /Users/facosta/git/RIOT-OS/RIOT/boards/common/init
"make" -C /Users/facosta/git/RIOT-OS/RIOT/core
"make" -C /Users/facosta/git/RIOT-OS/RIOT/core/lib
"make" -C /Users/facosta/git/RIOT-OS/RIOT/cpu/cc26x2_cc13x2
"make" -C /Users/facosta/git/RIOT-OS/RIOT/cpu/cc26x2_cc13x2/periph
"make" -C /Users/facosta/git/RIOT-OS/RIOT/cpu/cc26x2_cc13x2/radio
"make" -C /Users/facosta/git/RIOT-OS/RIOT/cpu/cc26x2_cc13x2/rfc
"make" -C /Users/facosta/git/RIOT-OS/RIOT/cpu/cc26xx_cc13xx
"make" -C /Users/facosta/git/RIOT-OS/RIOT/cpu/cc26xx_cc13xx/periph
"make" -C /Users/facosta/git/RIOT-OS/RIOT/cpu/cortexm_common
"make" -C /Users/facosta/git/RIOT-OS/RIOT/cpu/cortexm_common/periph
"make" -C /Users/facosta/git/RIOT-OS/RIOT/drivers
"make" -C /Users/facosta/git/RIOT-OS/RIOT/drivers/netdev
"make" -C /Users/facosta/git/RIOT-OS/RIOT/drivers/netdev_ieee802154_submac
"make" -C /Users/facosta/git/RIOT-OS/RIOT/drivers/periph_common
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/auto_init
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/div
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/event
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/evtimer
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/fmt
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/frac
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/isrpipe
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/libc
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/luid
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/malloc_thread_safe
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/net/crosslayer/inet_csum
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/net/gnrc
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/net/gnrc/netapi
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/net/gnrc/netif
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/net/gnrc/netif/hdr
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/net/gnrc/netif/ieee802154
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/net/gnrc/netif/init_devs
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/net/gnrc/netif/pktq
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/net/gnrc/netreg
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/net/gnrc/network_layer/icmpv6
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/net/gnrc/network_layer/icmpv6/echo
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/net/gnrc/network_layer/icmpv6/error
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/net/gnrc/network_layer/ipv6
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/net/gnrc/network_layer/ipv6/hdr
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/net/gnrc/network_layer/ipv6/nib
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/net/gnrc/network_layer/ndp
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/net/gnrc/network_layer/sixlowpan
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/net/gnrc/network_layer/sixlowpan/ctx
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/net/gnrc/network_layer/sixlowpan/frag
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/net/gnrc/network_layer/sixlowpan/frag/fb
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/net/gnrc/network_layer/sixlowpan/frag/rb
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/net/gnrc/network_layer/sixlowpan/iphc
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/net/gnrc/network_layer/sixlowpan/nd
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/net/gnrc/pkt
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/net/gnrc/pktbuf
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/net/gnrc/pktbuf_static
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/net/gnrc/pktdump
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/net/gnrc/routing/rpl
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/net/gnrc/transport_layer/udp
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/net/link_layer/eui_provider
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/net/link_layer/ieee802154
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/net/link_layer/l2util
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/net/netif
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/net/netutils
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/net/network_layer/icmpv6
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/net/network_layer/ipv6/addr
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/net/network_layer/ipv6/hdr
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/net/network_layer/sixlowpan
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/net/transport_layer/udp
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/newlib_syscalls_default
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/od
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/ps
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/random
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/shell
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/shell/cmds
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/stdio_uart
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/trickle
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/tsrb
"make" -C /Users/facosta/git/RIOT-OS/RIOT/sys/ztimer
text data bss dec hex filename
90528 540 29632 120700 1d77c /Users/facosta/git/RIOT-OS/RIOT/examples/gnrc_networking/bin/cc1352-launchpad/gnrc_networking.elf
/Applications/ti/uniflash_8.0.0//dslite.sh --config /Users/facosta/git/RIOT-OS/RIOT/boards/common/cc26xx_cc13xx/dist/cc1352r1_XDS110.ccxml /Users/facosta/git/RIOT-OS/RIOT/examples/gnrc_networking/bin/cc1352-launchpad/gnrc_networking.elf
Executing the following command:
> /Applications/ti/uniflash_8.0.0/deskdb/content/TICloudAgent/osx/ccs_base/DebugServer/bin/DSLite flash --config /Users/facosta/git/RIOT-OS/RIOT/boards/common/cc26xx_cc13xx/dist/cc1352r1_XDS110.ccxml /Users/facosta/git/RIOT-OS/RIOT/examples/gnrc_networking/bin/cc1352-launchpad/gnrc_networking.elf
For more details and examples, please refer to the UniFlash Quick Start guide.
Cortex_M4_0: GEL Output: Memory Map Initialization Complete.
Cortex_M4_0: GEL Output: Memory Map Initialization Complete.
Cortex_M4_0: GEL Output: Board Reset Complete.
/Users/facosta/git/RIOT-OS/RIOT/dist/tools/pyterm/pyterm -p "/dev/tty.usbmodemL41008PN1" -b "115200"
Twisted not available, please install it if you want to use pyterm's JSON capabilities
2022-11-03 09:56:53,559 # Connect to serial port /dev/tty.usbmodemL41008PN1
/Users/facosta/git/RIOT-OS/RIOT/dist/tools/pyterm/pyterm:289: DeprecationWarning: setDaemon() is deprecated, set the daemon attribute instead
receiver_thread.setDaemon(1)
Welcome to pyterm!
Type '/exit' to exit.
2022-11-03 09:56:57,776 # NETOPT_TX_END_IRQ not implemented by driver
2022-11-03 09:56:57,785 # main(): This is RIOT! (Version: 2022.10-devel-1151-g8a0be-pr/add_cc26x2_cc13x2_radio)
2022-11-03 09:56:57,789 # RIOT network stack example application
2022-11-03 09:56:57,791 # All up, running the shell now
> To see the shell output I just reset the device by hand, using the reset button on the board. |
I use this same program
|
@krzysztof-cabaj if you have docker you may try to build it using it, just set |
Thanks for good idea. I have to install docker in machine used for RIOT development and test this issue once again. |
Try updating the CCFG as follows:
Using CFLAGS CFLAGS="-DCONFIG_CC26XX_CC13XX_UPDATE_CCFG=1" BOARD=cc1312-launchpad WERROR=0 make -C examples/gnrc_networking flash term (Or) Using menuconfig BOARD=cc1312-launchpad WERROR=0 make -C examples/gnrc_networking menuconfig flash term and save changes of course, not perfect yet but should enable terminal |
Would you have any comments on this? Do you know if it is still in the progress of development? |
Contribution description
This PR is a continued work on #13295 from @jeandudey. Basically it retakes the same features and code, I just updated it and adapted it for the current API and HAL.
Testing procedure
For now some warnings are being triggered, I'm working on them but I think it will take me a while to remove them, although the code compiles and works with the following command:
$ BOARD=cc1312-launchpad WERROR=0 make -C examples/gnrc_networking flash term
I only tested on 2 cc1312-launchpad boards, I'd need to get some other supported sub-ghz board to check broad compatibility.
Issues/PRs references
#13295
#13205
#13215