Skip to content

Commit f0dc0e7

Browse files
bors[bot]maribuhugueslarriveszsam
authored
19606: doc: add board selection guide r=benpicco a=maribu ### Contribution description This adds a board selection guide to the documentation to aid new users picking good hardware for their use case. 19753: cpu/atmega8: new cpu r=benpicco a=hugueslarrive ### Contribution description Splitted from: - #19740 ### Testing procedure Tested on atmega8 with: - #19755 ### Issues/PRs references Dependencies: - #19752 - #19751 19757: core: fix null pointer dereference r=benpicco a=szsam Check return values of following functions for null: - thread_get - thread_get_unchecked Co-authored-by: Marian Buschsieweke <[email protected]> Co-authored-by: Hugues Larrive <[email protected]> Co-authored-by: Mingjie Shen <[email protected]>
4 parents 3ec62a2 + e13b3c4 + 0401d55 + 3fad959 commit f0dc0e7

11 files changed

+365
-0
lines changed

boards/doc.txt

+62
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,68 @@
1717
* device drivers should go into this module.
1818
*
1919

20+
Board Selection Guide {#board-selection-guide}
21+
=====================
22+
23+
There is no single best board to buy for use with RIOT, as hardware design
24+
involves many trade-offs. The challenge is to clearly assess the use case and
25+
collect the requirements and to find the best match for those.
26+
27+
With this in mind, it is still possible to give some hints and recommendations:
28+
29+
1. During Development:
30+
- An integrated programmer/debugger is immensely useful. At the very least
31+
a standard JTAG/SWD connector for quick and fool-proof connection is
32+
required
33+
- If possible, pick an MCU with *more* RAM and flash than your target board.
34+
This allows to spend the excess in memory for debug features such as
35+
utility modules, verbose assert messages, etc. during development
36+
- Standard connectors such as Arduino Headers, or Grove, STEMMA, STEMMA QT,
37+
QUIIC connectors etc. make hardware prototyping easier
38+
2. Final Product:
39+
- An integrated programmer/debugger is a waste of resources (money, power,
40+
space, ...)
41+
- ...
42+
43+
Popular Boards
44+
--------------
45+
46+
| Board | Use Case | Performance | Integrated Debugger | Integrated Networking | Native USB | Arduino Headers | Other Connectors | Integrated Sensors/... | Breadboard Friendly | Costs | Remarks |
47+
|:------------------------------------- |:--------------------- |:------------- |:--------------------- |:--------------------------------- |:------------- |:--------------------- |:------------------------- |:----------------------------------------------------- |:--------------------- |:--------- |:----------------------------- |
48+
| @ref boards_arduino-due | Education | `++` | ✔ | ✗ | ✔ | `+++` (Uno, Mega, ISP)| ✗ | `-` (1 LED) | `+` | `o` | Better buy the nrf52840dk |
49+
| @ref boards_arduino-mega2560 | You have them anyway | `--` | ✗ | ✗ | ✗ | `+++` (Uno, Mega, ISP)| ✗ | `-` (1 LED) | `+` | `--` | Better buy the nrf52840dk |
50+
| @ref boards_arduino-uno | You have them anyway | `---` | ✗ | ✗ | ✗ | `++` (Uno, ISP) | ✗ | `-` (1 LED) | `+` | `--` | You like pain, don't you? |
51+
| @ref boards_common_nucleo32 | Development | `-/o/+/++` | ✔ | ✗ | ✗ | `o` (Nano) | Custom | `o` (1 button, 1 LED) | `+` | `++` | Good bang for the buck |
52+
| @ref boards_common_nucleo64 | Development | `o/+/++` | ✔ | ✗ | ✗ | `+` (Uno) | ST Morpho Headers | `o` (1 button, 1 LED) | `+` | `++` | Good bang for the buck |
53+
| @ref boards_common_nucleo144 | Development | `+/++/+++` | ✔ | (✔) (some have Ethernet) | ✔ | `++` (Uno, Mega) | ST Morpho Headers | `+` (1 button, 3 LEDs) | `+` | `++` | Good bang for the buck |
54+
| @ref boards_esp32_esp-ethernet-kit | Development | `+++` | ✔ | ✔ (WiFi, BLE, Ethernet, custom) | ✗ | ✗ | Custom | `-` (1 button) | `+` | `o` | Requires proprietary software |
55+
| @ref boards_esp32_wroom-32 | Prototyping | `+++` | ✗ | ✔ (WiFi, BLE, custom) | ✗ | ✗ | Custom | `-` (1 button) | `+++` | `+++` | Requires proprietary software |
56+
| @ref boards_microbit_v2 | Education | `++` | ✔ | ✔ (802.15.4, BLE, custom) | ✗ | ✗ | micro:bit edge connector | `+++` (6 buttons, LED matrix, mic, speaker, IMO) | `--` | `++` | Good education board |
57+
| @ref boards_nrf52840dk | Development | `++` | ✔ | ✔ (802.15.4, BLE, custom) | ✔ | `+++`(Uno, Mega) | Custom | `+` (4 buttons, 4 LEDs) | `+` | `+` | Excellent border router |
58+
| @ref boards_nrf52840dongle | Prototyping | `++` | ✗ | ✔ (802.15.4, BLE, custom) | ✔ | ✗ | Custom | o (1 button, 4 LEDs) | `++` | `++` | Good wireless dev board |
59+
| @ref boards_nucleo-wl55jc | Development | `++` | ✔ | ✔ (LoRa) | ✗ | `+` (Uno) | ST Morpho Headers | `+` (3 buttons, 3 LEDs) | `+` | `++` | Good bang for the buck |
60+
| @ref boards_pinetime | Gadget | `++` | ✗ | ✔ (BLE) | ✗ | ✗ | ✗ | `+++` (LCD, button, touch screen, IMU, flash, ...) | `---` | `+++` | Buy two: One with SWD access |
61+
| @ref boards_samr21-xpro | Development | `+` | ✔ | ✔ (802.15.4) | ✔ | ✗ | XPRO Expansion Header | `o` (1 button, 1 LED) | `+` | `--` | Quite expensive |
62+
| @ref boards_samr34-xpro | Development | `++` | ✔ | ✔ (LoRa) | ✔ | ✗ | XPRO Expansion Header | `o` (1 button, 2 LEDs) | `+` | `---` | Got a spare kidney to sell? |
63+
| @ref boards_weact-f411ce | Prototyping | `++` | ✗ | ✗ | ✔ | ✗ | Custom | `+` (1 button, 1 LED, SPI flash) | `+++` | `+++` | Excellent bang for the buck |
64+
65+
@note Only boards with mature RIOT support and decent documentation qualify for above list
66+
@details This list was last updated in May 2023
67+
68+
69+
<!-- Add when doc is fixed
70+
| @ref boards_b-l072z-lrwan1 | Development | `+` | ✔ | ✔ (LoRa) | ✗ | `++` (Uno, Mega) | ST Morpho Headers | `+` (1 button, 4 LEDs) | `+` | `++` | Good bang for the buck |
71+
-->
72+
73+
### Notes on Arduino Compatibility
74+
75+
- Perfect (`+++`) only if it is fully compatible with both Arduino Uno and Arduino Mega Shields (including SPI via ISP connector)
76+
- Good (`++`) if it is fully compatible with Arduino Uno shields (including SPI via ISP connector)
77+
- Good (`++`) if it is partially compatible with both Arduino Uno and Arduino Mega Shields (no SPI via ISP connector)
78+
- Decent (`+`) if it is partially compatible with Arduino Uno Shields (no SPI via ISP connector)
79+
- Decent (`+`) if it is fully compatible with Arduino Nano Shields (including SPI via ISP connector)
80+
- OK (`o`) if it is partially compatible with Arduino Nano Shields
81+
2082
Guide to board pinouts {#pinout_guide}
2183
=====================================
2284

core/msg.c

+6
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,9 @@ int msg_reply_int(msg_t *m, msg_t *reply)
322322
{
323323
thread_t *target = thread_get_unchecked(m->sender_pid);
324324

325+
/* msg_reply_int() can only be used to reply to existing threads */
326+
assert(target != NULL);
327+
325328
if (target->status != STATUS_REPLY_BLOCKED) {
326329
DEBUG("msg_reply_int(): %" PRIkernel_pid ": Target \"%" PRIkernel_pid
327330
"\" not waiting for reply.", thread_getpid(),
@@ -466,6 +469,9 @@ unsigned msg_queue_capacity(kernel_pid_t pid)
466469
pid);
467470

468471
thread_t *thread = thread_get(pid);
472+
473+
assert(thread != NULL);
474+
469475
int queue_cap = 0;
470476

471477
if (thread_has_msg_queue(thread)) {

cpu/atmega8/Kconfig

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Copyright (c) 2020 HAW Hamburg
2+
#
3+
# This file is subject to the terms and conditions of the GNU Lesser
4+
# General Public License v2.1. See the file LICENSE in the top level
5+
# directory for more details.
6+
#
7+
8+
config CPU_FAM_ATMEGA8
9+
bool
10+
select CPU_COMMON_ATMEGA
11+
12+
## CPU Models
13+
config CPU_MODEL_ATMEGA8
14+
bool
15+
select CPU_FAM_ATMEGA8
16+
select HAS_CPU_ATMEGA8
17+
18+
## Definition of specific features
19+
config HAS_CPU_ATMEGA8
20+
bool
21+
help
22+
Indicates that a 'atmega8' cpu is being used.
23+
24+
## Common CPU symbols
25+
config CPU_FAM
26+
default "atmega8" if CPU_FAM_ATMEGA8
27+
28+
config CPU_MODEL
29+
default "atmega8" if CPU_MODEL_ATMEGA8
30+
31+
config CPU
32+
default "atmega8" if CPU_FAM_ATMEGA8
33+
34+
source "$(RIOTCPU)/atmega_common/Kconfig"

cpu/atmega8/Makefile

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# define the module that is build
2+
MODULE = cpu
3+
4+
# add a list of subdirectories, that should also be build
5+
DIRS = $(RIOTCPU)/atmega_common/
6+
7+
include $(RIOTBASE)/Makefile.base

cpu/atmega8/Makefile.dep

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include $(RIOTCPU)/atmega_common/Makefile.dep

cpu/atmega8/Makefile.features

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include $(RIOTCPU)/atmega_common/Makefile.features

cpu/atmega8/Makefile.include

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
RAM_LEN = 1K
2+
ROM_LEN = 8K
3+
4+
LINKER_SCRIPT ?= avr4.ld
5+
6+
# CPU depends on the atmega common module, so include it
7+
include $(RIOTCPU)/atmega_common/Makefile.include

cpu/atmega8/doc.txt

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
* @defgroup cpu_atmega8 Atmel ATmega8
3+
* @ingroup cpu
4+
* @brief Implementation of Atmel's ATmega8 MCU
5+
*/
6+
7+
/**
8+
* @defgroup cpu_atmega8_definitions Atmel ATmega8 Definitions
9+
* @ingroup cpu_atmega8
10+
*/

cpu/atmega8/include/cpu_conf.h

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/*
2+
* Copyright (C) 2014 Freie Universität Berlin, Hinnerk van Bruinehsen
3+
* 2017 RWTH Aachen, Josua Arndt
4+
* 2018 Matthew Blue
5+
* 2023 Hugues Larrive
6+
*
7+
* This file is subject to the terms and conditions of the GNU Lesser
8+
* General Public License v2.1. See the file LICENSE in the top level
9+
* directory for more details.
10+
*/
11+
12+
/**
13+
* @ingroup cpu_atmega_common
14+
* @{
15+
*
16+
* @file
17+
* @brief Implementation specific CPU configuration options
18+
*
19+
* @author Hauke Petersen <[email protected]>
20+
* @author Hinnerk van Bruinehsen <[email protected]>
21+
* @author Josua Arndt <[email protected]>
22+
* @author Steffen Robertz <[email protected]>
23+
* @author Matthew Blue <[email protected]>
24+
* @author Hugues Larrive <[email protected]>
25+
*/
26+
27+
#ifndef CPU_CONF_H
28+
#define CPU_CONF_H
29+
30+
#include "atmega_regs_common.h"
31+
32+
#ifdef __cplusplus
33+
extern "C" {
34+
#endif
35+
36+
#ifndef THREAD_EXTRA_STACKSIZE_PRINTF
37+
#define THREAD_EXTRA_STACKSIZE_PRINTF (64)
38+
#endif
39+
40+
/**
41+
* @name Kernel configuration
42+
*
43+
* Since printf seems to get memory allocated by the
44+
* linker/avr-libc the stack size tested successfully
45+
* even with pretty small stacks.
46+
* @{
47+
*/
48+
#ifndef THREAD_STACKSIZE_DEFAULT
49+
#define THREAD_STACKSIZE_DEFAULT (128)
50+
#endif
51+
52+
/* keep THREAD_STACKSIZE_IDLE > THREAD_EXTRA_STACKSIZE_PRINTF
53+
* to avoid not printing of debug in interrupts
54+
*/
55+
#ifndef THREAD_STACKSIZE_IDLE
56+
#if MODULE_XTIMER || MODULE_ZTIMER || MODULE_ZTIMER64
57+
/* For AVR no ISR stack is used, hence an IRQ will victimize the stack of
58+
* whatever thread happens to be running with the IRQ kicks in. If more than
59+
* trivial stuff is needed to be done in ISRs (e.g. when soft timers are used),
60+
* the idle stack will overflow.
61+
*/
62+
#define THREAD_STACKSIZE_IDLE (192)
63+
#else
64+
#define THREAD_STACKSIZE_IDLE (96)
65+
#endif
66+
#endif
67+
/** @} */
68+
69+
/**
70+
* @brief Attribute for memory sections required by SRAM PUF
71+
*/
72+
#define PUF_SRAM_ATTRIBUTES __attribute__((used, section(".noinit")))
73+
74+
/**
75+
* @brief Declare the heap_stats function as available
76+
*/
77+
#define HAVE_HEAP_STATS
78+
79+
/**
80+
* @brief This arch uses the inlined IRQ API.
81+
*/
82+
#define IRQ_API_INLINED (1)
83+
84+
#ifndef DOXYGEN
85+
#define HAS_FLASH_UTILS_ARCH 1
86+
#endif
87+
88+
#ifdef __cplusplus
89+
}
90+
#endif
91+
92+
#endif /* CPU_CONF_H */
93+
/** @} */
+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Copyright (C) 2015 HAW Hamburg
3+
* 2016 Freie Universität Berlin
4+
* 2023 Hugues Larrive
5+
*
6+
* This file is subject to the terms and conditions of the GNU Lesser
7+
* General Public License v2.1. See the file LICENSE in the top level
8+
* directory for more details.
9+
*/
10+
11+
/**
12+
* @ingroup cpu_atmega8
13+
* @{
14+
*
15+
* @file
16+
* @brief Default timer configuration
17+
*
18+
* @author René Herthel <[email protected]>
19+
* @author Hauke Petersen <[email protected]>
20+
* @author Hugues Larrive <[email protected]>
21+
*/
22+
23+
#ifndef DEFAULT_TIMER_CONFIG_H
24+
#define DEFAULT_TIMER_CONFIG_H
25+
26+
#ifdef __cplusplus
27+
extern "C" {
28+
#endif
29+
30+
#ifndef TIMER_NUMOF
31+
#define TIMER_NUMOF (1U)
32+
#define TIMER_CHANNEL_NUMOF (2)
33+
34+
#define TIMER_0 MEGA_TIMER1
35+
#define TIMER_0_MASK &TIMSK
36+
#define TIMER_0_FLAG &TIFR
37+
#define TIMER_0_ISRA TIMER1_COMPA_vect
38+
#define TIMER_0_ISRB TIMER1_COMPB_vect
39+
#endif /* TIMER_NUMOF */
40+
41+
#ifdef __cplusplus
42+
}
43+
#endif
44+
45+
#endif /* DEFAULT_TIMER_CONFIG_H */
46+
/** @} */

cpu/atmega8/include/periph_cpu.h

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/*
2+
* Copyright (C) 2015 HAW Hamburg
3+
* 2016 Freie Universität Berlin
4+
* 2023 Hugues Larrive
5+
*
6+
* This file is subject to the terms and conditions of the GNU Lesser
7+
* General Public License v2.1. See the file LICENSE in the top level
8+
* directory for more details.
9+
*/
10+
11+
/**
12+
* @ingroup cpu_atmega8
13+
* @{
14+
*
15+
* @file
16+
* @brief CPU specific definitions for internal peripheral handling
17+
*
18+
* @author René Herthel <[email protected]>
19+
* @author Hauke Petersen <[email protected]>
20+
* @author Hugues Larrive <[email protected]>
21+
*/
22+
23+
#ifndef PERIPH_CPU_H
24+
#define PERIPH_CPU_H
25+
26+
#include "periph_cpu_common.h"
27+
28+
#ifdef __cplusplus
29+
extern "C" {
30+
#endif
31+
32+
/**
33+
* @brief Define a CPU specific GPIO pin generator macro
34+
*/
35+
#define GPIO_PIN(x, y) ((x << 4) | y)
36+
37+
/**
38+
* @brief Available ports on the ATmega8 family
39+
*/
40+
enum {
41+
PORT_B = 1, /**< port B */
42+
PORT_C = 2, /**< port C */
43+
PORT_D = 3 /**< port D */
44+
};
45+
46+
/**
47+
* @brief Available external interrupt pins on the ATmega8 family
48+
*
49+
* In order of their interrupt number.
50+
*/
51+
#define CPU_ATMEGA_EXT_INTS { GPIO_PIN(PORT_D, 2), \
52+
GPIO_PIN(PORT_D, 3) }
53+
54+
/**
55+
* @brief Get the interrupt vector number of the given GPIO pin
56+
*/
57+
static inline uint8_t atmega_pin2exti(uint8_t port_num, uint8_t pin_num)
58+
{
59+
(void)port_num;
60+
return pin_num - 2;
61+
}
62+
63+
/**
64+
* @brief Check if the given pin can be used as external interrupt
65+
*/
66+
static inline bool atmega_has_pin_exti(uint8_t port_num, uint8_t pin_num)
67+
{
68+
if (port_num == PORT_D) {
69+
return ((pin_num == 2) || (pin_num == 3));
70+
}
71+
72+
return false;
73+
}
74+
75+
/**
76+
* @name Defines for the I2C interface
77+
* @{
78+
*/
79+
#define I2C_PORT_REG PORTC
80+
#define I2C_PIN_MASK (1 << PORTC4) | (1 << PORTC5)
81+
/** @} */
82+
83+
/**
84+
* @name EEPROM configuration
85+
* @{
86+
*/
87+
#define EEPROM_SIZE (512U) /* 512B */
88+
/** @} */
89+
90+
#ifdef __cplusplus
91+
}
92+
#endif
93+
94+
#include "periph_conf.h"
95+
#include "default_timer_config.h"
96+
97+
#endif /* PERIPH_CPU_H */
98+
/** @} */

0 commit comments

Comments
 (0)