-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Add support for Silabs EFR32MG12P device and Thunderboard Sense 2 #9042
Add support for Silabs EFR32MG12P device and Thunderboard Sense 2 #9042
Conversation
Ping @chrta . |
Are the emlib and the other gecko sdk files are still on 5.1.2, but the efm32mg files are from gecko sdk 5.5.0? Does this work? Or should we first update the gecko sdk to 5.5.0 for all already merged silabs boards? |
Codecov Report
@@ Coverage Diff @@
## master #9042 +/- ##
======================================
Coverage 53.3% 53.3%
======================================
Files 215 215
Lines 25908 25908
Branches 5711 5711
======================================
Hits 13810 13810
Misses 9777 9777
Partials 2321 2321 Continue to review full report at Codecov.
|
@chrta , It is working without any issues. If you compare the CMSIS headers between these versions you will see that it is more about adding defines and declarations. The idea is to update the Gecko SDK in the near future. |
453d1ee
to
8cea032
Compare
.. _efr32mg_sltb004a: | ||
|
||
EFR32MG-SLTB004A | ||
############### |
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.
The title underline must be at least as long as the title above it, so add one more #
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.
Addressed.
- One bi-color LED and two push buttons | ||
- Power enable signals for fine grained power-control | ||
- On-board SEGGER J-Link debugger for easy programming and debugging, which | ||
includes a USB virtual COM port |
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 line should be indented to the O
on the previous line
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.
Addressed.
- On-board SEGGER J-Link debugger for easy programming and debugging, which | ||
includes a USB virtual COM port | ||
- Mini Simplicity connector for access to energy profiling and advanced wireless | ||
network debugging |
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.
same here, indent the line to the M
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.
Addressed.
|
||
The default configuration can be found in the defconfig file: | ||
|
||
``boards/arm/efr32mg_sltb004a/efr32mg_sltb004a_defconfig`` |
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.
delete the blank line and indent:
The default configuration can be found in the defconfig file:
``boards/arm/efr32mg_sltb004a/efr32mg_sltb004a_defconfig``.
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.
Addressed.
e92f489
to
187026b
Compare
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.
+1 for docs, thanks.
@galak and @MaureenHelm , Any feedbacks? |
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.
Number of dts related comments.
config SOC_SERIES_EFR32MG12P | ||
bool "EFR32MG12P Series MCU" | ||
select CPU_CORTEX_M4 | ||
select CPU_HAS_FPU |
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.
duplicated in config SOC_EFR32MG12P
drivers/serial/Kconfig.gecko
Outdated
@@ -6,7 +6,7 @@ | |||
# | |||
|
|||
menuconfig UART_GECKO | |||
bool "Gecko uart driver" | |||
bool "Gecko UART/USART driver" |
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.
Can you merge this with the rework of the driver patch.
|
||
#define CONFIG_UART_GECKO_0_BAUD_RATE SILABS_EFM32_USART_4000C000_CURRENT_SPEED | ||
#define CONFIG_UART_GECKO_0_IRQ_PRI SILABS_EFM32_USART_4000C000_IRQ_0_PRIORITY | ||
#define USART_0_RX_IRQ SILABS_GECKO_USART_4000C000_IRQ_0 |
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.
We've used CONFIG_ to prefix such defines. Want to keep this consistent with other DTS support for now.
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'm trying to keep the consistency with the define names automatically generated by the alias. I can check if I can do something in the devicetree yaml to have these defines automatically generated without needing a fixup.
Doesn't look nice to me to have in the driver a mixture between defines with and without CONFIG_ prefix.
I even sent an email to the mailing list about cleaning up these fixups and make usage of the aliases. Have you seen it?
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 got rid of these fixups by adding the "interrupt-names" for the uarts nodes.
@@ -18,13 +18,13 @@ | |||
|
|||
#ifdef CONFIG_SOC_PART_NUMBER_EFR32FG1P133F256GM48 | |||
#ifdef CONFIG_USART_GECKO_0 | |||
#if (CONFIG_USART_GECKO_0_GPIO_LOC == 0) | |||
#if (USART_0_LOC == 0) | |||
#define PIN_USART0_TXD {gpioPortA, 0, gpioModePushPull, 1} |
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.
Why can't these just be:
`
#define PIN_USART0_TXD {gpioPortA, 0 + CONFIG_USART_0_LOC, gpioModePushPull, 1}
#define PIN_USART0_RXD {gpioPortA, 1 + CONFIG_USART_0_LOC, gpioModeInput, 1}
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.
The "loc" property is not directly related to the pin number.
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.
Yeah, ignore my comments on loc. However we should rename to location.
#error ("Serial Driver for Gecko MCUs not implemented for this location index") | ||
#elif (CONFIG_USART_GECKO_1_GPIO_LOC == 1) | ||
#elif (USART_1_LOC == 1) | ||
#define PIN_USART1_TXD {gpioPortF, 10, gpioModePushPull, 1} |
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.
Similar comment as above.
@@ -20,5 +24,6 @@ | |||
|
|||
&uart0 { | |||
current-speed = <115200>; | |||
loc = <1>; |
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.
We should have this be tx-pin and rx-pin.
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.
Do you mean we need to have a loc (location) property for the tx-pin and rx-pin separately?
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'm thinking we should, it would be consistent with what the NRF SoC is doing in dts for the pins for rx & tx.
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.
Looking at the manual, and maybe loc makes sense. I was tracing the code and came to soc_gpio_configure/GPIO_PinModeSet. So I'm confused about what location means for which pins are used.
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.
The loc is used to instruct which pin (ball) is going to be used. As a consequence, we need to pass which port will be used and the alternate configuration (location). Take a look at the section "6.7 Alternate Functionality Overview" in this document:
https://www.silabs.com/documents/public/data-sheets/efr32fg1-datasheet.pdf
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.
What do you say?
Take a look at the function uart_gecko_init_pins
in drivers/serial/uart_gecko.c file to understand how the "loc" property is used. If you want we can slipt the loc for rx and tx because they can be eventually different.
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.
For the EFM32WG (and all the older EFM32 i think), there is only one loc per U(S)ART, see e.g. https://www.silabs.com/documents/public/reference-manuals/EFM32WG-RM.pdf chapter 17.5.22 USARTn_ROUTE - I/O Routing Register.
This should be considered (one loc per peripheral vs. one loc per pin in a peripheral), if the driver implementation is changed.
@@ -27,4 +27,10 @@ properties: | |||
category: required | |||
description: required interrupts | |||
generation: define | |||
|
|||
loc: |
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.
should be rx-pin & tx-pin.
187026b
to
266b741
Compare
I'm not sure how to solve the merging conflicts in the Shippable testing environment. |
You have to rebase your branch on the current master. Because the soc files moved to another directory, you have to change a few things (board dts file, create soc dtsi file, change path to drivers is board cmake file etc). |
I already rebased and I'm using the new SoC path. |
@diegosueiro Your SoC commit 10045194958167858bf93db5c74b8405501d32fe is still based on an older master branch, e.g. there is no file dts/arm/silabs/mem.h any more. |
f3d4657
to
39e8e31
Compare
@pfalcon can you review the uart driver. |
I opened up PR #10728 to merge the base SoC support. The board code needs a little updating (for moving gpio info into device tree). Also would like to get a little more review on the uart/i2c drivers. |
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.
Seems like the I2C driver doesn't use interrupts, so we should remove the code associated w/setting up interrupts and the isr handler.
drivers/serial/Kconfig.gecko
Outdated
@@ -52,4 +52,4 @@ config USART_GECKO_3 | |||
Enable support for Gecko USART3 port in the driver. Say y here if you | |||
want to use USART3 device. | |||
|
|||
endif # UART_GECKO | |||
endif # UART_GECKO |
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.
Is this commit doing anything now? (drivers: Add more uart instances for Silabs Devices)
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 showing as outdated. I think this is gone after I rebased it the master instead of the PR that was changing this file.
drivers/i2c/i2c_gecko.c
Outdated
} | ||
|
||
|
||
static void i2c_gecko_isr(void *arg) |
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.
Why have isr code at all if it doesn't do anything?
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'll remove that after getting the others reviews.
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.
Ok. I found the problem. I forgot to drop 2 commits when rebasing this PR against the master.
I'll rebase it dropping these two commits and remove the i2c interrupt function.
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.
Ok, I've merged the base SoC support, and add a few minor comments on the board code.
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.
Done
39e8e31
to
a632c53
Compare
a632c53
to
f8b2625
Compare
boards/arm/efr32mg_sltb004a/board.h
Outdated
|
||
|
||
/* Push button PB0 (SW0) */ | ||
#define PB0_GPIO_NAME CONFIG_GPIO_GECKO_PORTD_NAME |
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.
Move the button and LED into device tree out of board.h
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.
Done
|
||
if LEUART_GECKO | ||
|
||
config LEUART_GECKO_0 |
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.
Sorry, but is that we still don't have means to deal with that in device tree?
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'm following the same pattern for drivers/serial/Kconfig.gecko
{ | ||
LEUART_TypeDef *base = DEV_BASE(dev); | ||
|
||
LEUART_Tx(base, c); |
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 would suggest to add comment here that the blocking until a char can be sent happens in LEUART_Tx(). (Because majority of our drivers have explicit busy-wait loop in poll_out; so, the above looks confusing.)
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.
Added a comment.
drivers/serial/leuart_gecko.c
Outdated
LEUART_TypeDef *base = DEV_BASE(dev); | ||
u32_t flags = LEUART_IntGet(base); | ||
|
||
LEUART_IntClear(base, LEUART_IF_TXC); |
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.
Why do you clear interrupt here? This function is supposed to be side effect free.
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.
Removed
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.
(Github glitches today, let's see if my comments were recorded.)
Some questions/suggestions.
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.
Just a note.
static void leuart_gecko_irq_tx_enable(struct device *dev) | ||
{ | ||
LEUART_TypeDef *base = DEV_BASE(dev); | ||
u32_t mask = LEUART_IEN_TXBL | LEUART_IEN_TXC; |
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.
My understanding that this enables both "fifo has empty space" and "transmission complete" interrupts. Just a note that many other drivers don't enable "transmission complete" IRQ, because it's not really much useful.
Again, this is just a note of difference to other drivers. (If someone later would need to investigate any issues and path which led to them.
)
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've just followed the same pattern for drivers/serial/uart_gecko.c
driver.
Well, I tried. If there's something to guaranteedly change, is to add more comments ;-). Otherwise, it's prompted me to prepare #10761 , because docs there still leave much to be desired (i.e. were partially updated previously). @diegosueiro : Did you try to run samples/subsys/console/echo with this driver? That would a litmus test whether this driver does everything "good enough" or "not good enough". Please be sure to also test clipboard-pasting of reasonable amount of data into the sample (at least CONFIG_CONSOLE_GETCHAR_BUFSIZE should go without any char loss, but on many boards I tried many more than that can go w/o loss, let's say at least 2x). |
Adds the Low Energy UART shim serial driver for Silabs Gecko Devices. Signed-off-by: Diego Sueiro <diego.sueiro@gmail.com>
Adds the I2C shim driver for Silabs Gecko Devices. Signed-off-by: Diego Sueiro <diego.sueiro@gmail.com>
f8b2625
to
5b200fe
Compare
I tested as you suggested and it is working fine. |
Great! Let me approve from my side. |
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.
+1 for UART driver.
boards/arm/efr32mg_sltb004a/board.c
Outdated
|
||
#include <init.h> | ||
|
||
static int efr32mg_sltb004a_init(struct device *dev) |
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.
If this doesn't do anything, why do we need it?
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.
Done.
boards/arm/efr32mg_sltb004a/board.h
Outdated
#endif | ||
|
||
/* Environment Sensors Enable Pin */ | ||
#define ENV_SENSE_ENABLE_NAME CONFIG_GPIO_GECKO_PORTF_NAME |
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.
where is this used?
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 one I used for testing an i2c sensor in the board to validate the i2c driver.
I'll remove it.
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.
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.
do we need board.c and some defines in board.h don't seem to be used.
The EFR32™ Mighty Gecko Starter Kit EFR32MG-SLTB004A (a.k.a Thunderboard Sense 2) contains a MCU from the EFR32MG12P family built on ARM® Cortex®-M4F processor with low power capabilities. There is an On-Board J-Link Debugger that presents a virtual COM port for general purpose application serial data transfer with this interface and a Mass Storage for firmware flashing. Signed-off-by: Diego Sueiro <diego.sueiro@gmail.com>
5b200fe
to
bddc8d7
Compare
This PR adds the support for Silabs EFR32MG-SLTB004A (Thunderboard Sense 2) board in Zephyr.
It adds the Gecko SDK for EFR32MG12P devices into the ext/hal for Silabs, introduces leuart and i2c drivers for Gecko Devices and a sample application to read Relative Humidity and Temperature from Silabs
SI7021 chip via I2C interface.
This PR depends on #8930 (first 3 commits) and as soon as it gets merged I will update this one to remove the redundant commits.