-
Notifications
You must be signed in to change notification settings - Fork 2.1k
boards: add Wemos D1 R32 (aka ESPDuino-32) board definition #21479
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
boards: add Wemos D1 R32 (aka ESPDuino-32) board definition #21479
Conversation
121091e
to
5cffb8a
Compare
boards/esp32-wroom-32/doc.txt
Outdated
@@ -96,8 +96,8 @@ Function | GPIOs | Remarks |Configuration | |||
:---------------|:-------|:--------|:---------------------------------- | |||
BUTTON0 | GPIO0 | | | | |||
ADC | GPIO0, GPIO2, GPIO4, GPIO12, GPIO13,\n GPIO14, GPIO15, GPIO25, GPIO26, GPIO27,\n GPIO32, GPIO33, GPIO34, GPIO35, GPIO36,\n GPIO39 | | see \ref esp32_adc_channels "ADC Channels" | |||
DAC | GPIO25, GPIO26 | | \ref esp32_dac_channels "refer" | |||
PWM_DEV(0) | GPIO0, GPIO2, GPIO4, GPIO16, GPIO17 | - | \ref esp32_pwm_channels "DAC Channels" | |||
DAC | GPIO25, GPIO26 | | \ref esp32_dac_channels \ref esp32_pwm_channels "DAC Channels" |
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.
DAC | GPIO25, GPIO26 | | \ref esp32_dac_channels \ref esp32_pwm_channels "DAC Channels" | |
DAC | GPIO25, GPIO26 | | \ref esp32_dac_channels "DAC Channels" |
boards/esp32-wemos-d1-r32/Kconfig
Outdated
@@ -0,0 +1,16 @@ | |||
# Copyright (c) 2020 HAW Hamburg |
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.
maybe consider changing the copyright here
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.
Thanks, at typical copy&paste problem. The Kconfig still had to be completely updated 😎
boards/esp32-wemos-d1-r32/doc.md
Outdated
/* | ||
* Copyright (C) 2025 Gunar Schorcht | ||
* | ||
* This file is subject to the terms and conditions of the GNU Lesser | ||
* General Public License v2.1. See the file LICENSE in the top level | ||
* directory for more details. | ||
*/ | ||
|
||
/** |
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.
/* | |
* Copyright (C) 2025 Gunar Schorcht | |
* | |
* This file is subject to the terms and conditions of the GNU Lesser | |
* General Public License v2.1. See the file LICENSE in the top level | |
* directory for more details. | |
*/ | |
/** |
No copyright notices and block comments are required for Markdown files.
(Remember to remove the closing piece of the block comment below as well).
boards/esp32-wemos-d1-r32/doc.md
Outdated
* @defgroup boards_esp32_wemos_d1_r32 Wemos D1 R32 (ESPDuino-32) | ||
* @ingroup boards_esp32 | ||
* @brief Support for the Wemos D1 R32 (ESPDuino-32) board | ||
* @author Gunar Schorcht <gunar@schorcht.net> |
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.
* @defgroup boards_esp32_wemos_d1_r32 Wemos D1 R32 (ESPDuino-32) | |
* @ingroup boards_esp32 | |
* @brief Support for the Wemos D1 R32 (ESPDuino-32) board | |
* @author Gunar Schorcht <gunar@schorcht.net> | |
@defgroup boards_esp32_wemos_d1_r32 Wemos D1 R32 (ESPDuino-32) | |
@ingroup boards_esp32 | |
@brief Support for the Wemos D1 R32 (ESPDuino-32) board | |
@author Gunar Schorcht <gunar@schorcht.net> |
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.
Ah ok, now where it is a Markdown file, C comments are wrong 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 was already wondering why Doxygen is complaining about a wrong list item.
boards/esp32-wemos-d1-r32/doc.md
Outdated
1. [Overview](#esp32_wemos_d1_r32_overview) | ||
2. [Hardware](#esp32_wemos_d1_r32_hardware) | ||
1. [MCU](#esp32_wemos_d1_r32_mcu) | ||
2. [Board Configuration](#esp32_wemos_d1_r32_board_configuration) | ||
3. [Board Pinout](#esp32_wemos_d1_r32_pinout) | ||
3. [Flashing the Device](#esp32_wemos_d1_r32_flashing) |
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. [Overview](#esp32_wemos_d1_r32_overview) | |
2. [Hardware](#esp32_wemos_d1_r32_hardware) | |
1. [MCU](#esp32_wemos_d1_r32_mcu) | |
2. [Board Configuration](#esp32_wemos_d1_r32_board_configuration) | |
3. [Board Pinout](#esp32_wemos_d1_r32_pinout) | |
3. [Flashing the Device](#esp32_wemos_d1_r32_flashing) | |
-# [Overview](#esp32_wemos_d1_r32_overview) | |
-# [Hardware](#esp32_wemos_d1_r32_hardware) | |
-# [MCU](#esp32_wemos_d1_r32_mcu) | |
-# [Board Configuration](#esp32_wemos_d1_r32_board_configuration) | |
-# [Board Pinout](#esp32_wemos_d1_r32_pinout) | |
-# [Flashing the Device](#esp32_wemos_d1_r32_flashing) |
You can let Doxygen do the enumeration for you instead of doing it manually.
boards/esp32-wemos-d1-r32/doc.md
Outdated
|
||
### Board Configuration {#esp32_wemos_d1_r32_board_configuration} | ||
|
||
The boad configuration guaranties that the board is compatible with Arduino |
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 boad configuration guaranties that the board is compatible with Arduino | |
The board configuration guarantees that the board is compatible with Arduino |
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.
Good catch, I'm wondering why it wasn't catched by the spell checker in CI?
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.
guaranties
is the valid plural form of guaranty
and boad
is simply not in the library: https://github.com/codespell-project/codespell/blob/d59cf4fe68f1d606c23f21a19ecd3828dbe8725e/codespell_lib/data/dictionary.txt#L9789
* mode for the GPIO pin has to be GPIO_IN. | ||
*/ | ||
#ifndef BTN0_INT_FLANK | ||
#define BTN0_INT_FLANK GPIO_FALLING |
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.
#define BTN0_INT_FLANK GPIO_FALLING | |
# define BTN0_INT_FLANK GPIO_FALLING |
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, I forgot to elaborate. Our official stylekeeper @maribu establishes the indentations after the # for #defines
in #if
statements to make them more readable, especially for multiple #if
-layers.
Therefore the suggestion.
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.
@maribu I really like indentation for nested #ifdef ... #endif
directives or a sequence of defines within a conditional compilation. But especially for a bunch simple #ifndef
s directives used as macro guards with just a single define depending on whether it is already defined or not, indentation leads to more "choppy" code that makes reading harder rather than better.
#ifndef ABDCX
#define ABDCX x
#endif
#ifndef ABDCY
#define ABDCX y
#endif
#ifndef ABDCZ
#define ABDCZ z
#endif
vs.
#ifndef ABDCX
# define ABDCX x
#endif
#ifndef ABDCX
# define ABDCY y
#endif
#ifndef ABDCZ
# define ABDCZ z
#endif
IMHO, copy & paste errors are also easier to catch with the first variant than with the second variant because of the alignment of the identifiers. Personally, I would prefer if the indentation for such conditionals were not mandatory for such a single definition.
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 doesn't matter for BTN0_INT_FLANK
since the board doesn't have a button 😉 This was just a leftover. I didn't take care about it because usually each ESP32x board has a BOOT
-Button that can be used as button once the application is loaded from flash.
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 just joking with the "official stylekeeper", but the indentation is indeed part of the Coding Convention https://github.com/RIOT-OS/RIOT/blob/master/CODING_CONVENTIONS.md#indentation-of-preprocessor-directives
But indeed maribu is a lot more experienced with code styling than I am, so maybe he can voice his opinion.
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 just joking with the "official stylekeeper", but the indentation is indeed part of the Coding Convention https://github.com/RIOT-OS/RIOT/blob/master/CODING_CONVENTIONS.md#indentation-of-preprocessor-directives
I know, I have read it 😉 but sometimes it is worth to discuss some style rules 😎
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 favor to just unconditionally stick with two spaces of indent. Style is pretty subjective, e.g. to me the second example with the indent is actually easier to read than the one without.
I would argue that adding exceptions to the coding conventions for short code makes the coding convention more complex and makes it more difficult to the use of tools such as clang-format
and uncrustify
, as special exceptions are not easily configured with such tools. Exceptions also tends to cause a lot of discussion (Would two #define
s within the #ifndef
... #endif
still be considered as short? How about three?).
In core
@kaspar030 has enforced an "run uncrustify
, don't discuss style" policy, even for the few cases the output of uncrustify
not super ideal. I think we ended up spending more time to discuss the content of the code and almost no time on discussing style, which I believe is a good thing.
But anyway, so far we have not strictly enforced the coding convention outside of core
yet, so I would not start insisting here.
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.
Style is pretty subjective, e.g. to me the second example with the indent is actually easier to read than the one without.
Totally agree. Maybe I should look for an editor with better syntax highlighting, where macro names in defines and guards are somehow colored 😉 gnome-textedit
only uses one color for complete preprocessor directives, so that in header files that only contain preprocessor directives, there is in fact no highlighting 😟
#ifndef PERIPH_CONF_H | ||
#define PERIPH_CONF_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.
#ifndef PERIPH_CONF_H | |
#define PERIPH_CONF_H |
Looks like you found a cornercase in the headerguards check 😅
I'll add a PR to cover that.
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 commit is for another ESP32 board 4e3bb01 ?
The boards/esp32-wemos-d1-r32/include/periph_conf.h
is still unchanged.
Did you cd
into the wrong directory? 😅
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 just mixed some work when I was switching between differen branches 🙈
5dcda95
to
59525bd
Compare
static const saul_gpio_params_t saul_gpio_params[] = | ||
{ | ||
{ | ||
.name = "BOOT", | ||
.pin = BTN0_PIN, | ||
.mode = BTN0_MODE, | ||
.flags = SAUL_GPIO_INVERTED | ||
}, | ||
}; | ||
|
||
/** | ||
* @brief LED configuration | ||
*/ | ||
static const saul_gpio_params_t saul_gpio_params[] = | ||
{ | ||
{ | ||
.name = "LED", | ||
.pin = LED0_PIN, | ||
.mode = GPIO_OUT, | ||
.flags = (SAUL_GPIO_INVERTED | SAUL_GPIO_INIT_CLEAR) | ||
} | ||
}; |
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 should probably be one struct?
The compiler throws the following errors when building examples/basic/default
:
In file included from /home/cbuec/RIOTstuff/riot-gettingstarted/RIOT/drivers/saul/init_devs/auto_init_saul_gpio.c:25:
/home/cbuec/RIOTstuff/riot-gettingstarted/RIOT/boards/esp32-wemos-d1-r32/include/gpio_params.h:33:16: error: 'BTN0_PIN' undeclared here (not in a function)
33 | .pin = BTN0_PIN,
| ^~~~~~~~
/home/cbuec/RIOTstuff/riot-gettingstarted/RIOT/boards/esp32-wemos-d1-r32/include/gpio_params.h:34:17: error: 'BTN0_MODE' undeclared here (not in a function)
34 | .mode = BTN0_MODE,
| ^~~~~~~~~
/home/cbuec/RIOTstuff/riot-gettingstarted/RIOT/boards/esp32-wemos-d1-r32/include/gpio_params.h:42:33: error: redefinition of 'saul_gpio_params'
42 | static const saul_gpio_params_t saul_gpio_params[] =
| ^~~~~~~~~~~~~~~~
/home/cbuec/RIOTstuff/riot-gettingstarted/RIOT/boards/esp32-wemos-d1-r32/include/gpio_params.h:29:33: note: previous definition of saul_gpio_params' with type 'const saul_gpio_params_t[1]'
29 | static const saul_gpio_params_t saul_gpio_params[] =
| ^~~~~~~~~~~~~~~~
make[3]: *** [/home/cbuec/RIOTstuff/riot-gettingstarted/RIOT/Makefile.base:157: /home/cbuec/RIOTstuff/riot-gettingstarted/RIOT/examples/basic/default/bin/esp32-wemos-d1-r32/saul_init_devs/auto_init_saul_gpio.o] Error 1
make[2]: *** [/home/cbuec/RIOTstuff/riot-gettingstarted/RIOT/Makefile.base:31: ALL--/home/cbuec/RIOTstuff/riot-gettingstarted/RIOT/drivers/saul/init_devs] Error 2
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 should probably be one struct?
Yeah, of course. But how could the compilation in Murdock succeed with this error, I'm a bit confused.
Anyway, since the board has no button, I will just drop the first structure. The problem was probably caused by copying and pasting these structures from different boards, sorry.
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 CI only compiles for certain boards and this board is not one of them. Therefore the error would've shown only in the full build when the tests and examples are compiled for all boards, including this one.
.name = "LED", | ||
.pin = LED0_PIN, | ||
.mode = GPIO_OUT, | ||
.flags = (SAUL_GPIO_INVERTED | SAUL_GPIO_INIT_CLEAR) |
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.
.flags = (SAUL_GPIO_INVERTED | SAUL_GPIO_INIT_CLEAR) | |
.flags = (SAUL_GPIO_INIT_CLEAR) |
With the inverted flag, the LED is off when writing 1 and on when writing 0.
Furthermore, the LED is on on startup.
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.
You can squash the fixups. Please also address the suggestion from @mguetschow.
I tested the board locally with examples/basic/default
, tests/periph/adc
and tests/periph/pwm
and everything seems to work as it should.
One thing that is still on my mind is the removal of the arduino_board_common.h
in this PR. Maybe #21484 would be a better home for that, since it's already an "ESP32 Arduino Cleanup" PR?
These suggestions were already addressed.
I moved the commit to #21484 and squashed. Thanks for reviewing and testing. |
b8da11d
to
6f1ee54
Compare
Hm, compilation failed in Murdock because
It is not yet clear for what purpose the macro was defined. It seems that it is not used in the driver code. Maybe it's just a leftover from the time when In the description of PR #13256, it is pointed out that the SPS30 only works at normal speed. Maybe the definition of I now conditionally define |
I had to modify the comments and mapping for Arduino DAC pins with commit 1e274e1. |
@crasbe With commit 1e274e1 I tried to changed the order of the Arduino DAC pins so that Arduino pins
RIOT/boards/esp32-wemos-d1-r32/include/arduino_iomap.h Lines 102 to 103 in 694e4a4
However, this results in the Arduino pin D2 being the DAC1 and D3 the DAC0 . That is, while the digital Arduino pins D2 and D3 are labelled in ascending order, the DAC pins are labelled in descending order. With other words you have D2=DAC1 and D3=DAC0 which might be a little bit confusing.RIOT/boards/esp32-wemos-d1-r32/include/arduino_iomap.h Lines 40 to 41 in 694e4a4
Now I'm wondering whether it wouldn't be better to change the order in
so that we could map D2= On the other hand, DAC pins are something that is not known in the Arduino world and it probably doesn't matter how you map them to the DAC lines. What do you think? |
You are probably overthinking it :D |
Ok, since we live in the RIOT bubble where Arduino sketches are just a nice but very special gadget, I would say that it is more important to map the ESP32 GPIOs to the So I would have to squash the fixups. |
694e4a4
to
bd55bd0
Compare
May I enable |
Any time :) |
@crasbe Many thanks for reviewing 😉 |
Contribution description
This PR adds the board definition for the Wemos D1 R32 also known as ESPDuino-32, the only only Arduino-sized ESP32 board with Arduino Uno compatible headers.
Testing procedure
Compilation in CI should succeed.
Issues/PRs references