8000 rp2/boards/WEACTSTUDIO: Add WEACTSTUDIO with multiple variants. · micropython/micropython@bdbc444 · GitHub
[go: up one dir, main page]

Skip to content

Commit bdbc444

Browse files
mattytrentinidpgeorge
authored andcommitted
rp2/boards/WEACTSTUDIO: Add WEACTSTUDIO with multiple variants.
This supports 2, 4, 8 and 16MB flash variants.
1 parent 0bc1d10 commit bdbc444

12 files changed

+235
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# WeAct Studio RP2040
2+
3+
The WeAct Studio RP2040 Board is based on the Raspberry Pi RP2040 and can be
4+
purchased with 2/4/8/16 MiB of flash.
5+
6+
These boards are available from a number of resellers and often have the name
7+
"Pico Board RP2040". WeAct maintain the [WeActStudio.RP2040CoreBoard](https://github.com/WeActTC/WeActStudio.RP2040CoreBoard/tree/master)
8+
repository containing information on the board.
9+
10+
## Build notes
11+
12+
Builds can be configured with the `BOARD_VARIANT` parameter. Valid variants
13+
can be displayed with the `query-variant` target. An example:
14+
15+
```bash
16+
> cd ports/rp2
17+
> make BOARD=WEACTSTUDIO query-variants
18+
VARIANTS: flash_2mb flash_4mb flash_8mb flash_16mb
19+
> make BOARD=WEACTSTUDIO BOARD_VARIANT=flash_8mb submodules all # Build the 8 MiB variant
20+
```
21+
22+
`flash_16mb` is the default if `BOARD_VARIANT` is not supplied.
23+
24+
## Board-specific modules
25+
26+
The `board` module contains definitions for the onboard LED and user button.
27+
28+
Example:
29+
30+
```python
31+
> import board
32+
> board.led.toggle() # Toggles the state of the on-board LED
33+
> board.key.value() # Returns 0 or 1 corresponding to the state of the user key
34+
```
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"deploy": [
3+
"deploy.md"
4+
],
5+
"docs": "",
6+
"features": [
7+
"Breadboard Friendly",
8+
"SPI Flash",
9+
"USB-C"
10+
],
11+
"images": [
12+
"weact_rp2040.jpg"
13+
],
14+
"mcu": "rp2040",
15+
"product": "WeAct Studio RP2040",
16+
"url": "https://github.com/WeActTC/WeActStudio.RP2040CoreBoard",
17+
"variants": {
18+
"flash_2mb": "2 MiB Flash",
19+
"flash_4mb": "4 MiB Flash",
20+
"flash_8mb": "8 MiB Flash"
21+
},
22+
"vendor": "WeAct"
23+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
### Flashing via UF2 bootloader
2+
3+
To get the board in bootloader mode ready for the firmware update, execute
4+
`machine.bootloader()` at the MicroPython REPL. Alternatively, hold
5+
down the BOOTSEL button while pressing reset (NRST). The uf2 file below
6+
should then be copied to the USB mass storage device that appears. Once
7+
programming of the new firmware is complete the device will automatically reset
8+
and be ready for use.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
include("$(PORT_DIR)/boards/manifest.py")
2+
freeze("./modules")
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from machine import Pin
2+
3+
led = Pin(25, Pin.OUT, value=0)
4+
key = Pin(23, Pin.IN, Pin.PULL_UP)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# CMake file for WeAct Studio RP2040 boards
2+
3+
# The WeAct Studio boards don't have official pico-sdk support so we define it
4+
# See also: https://github.com/raspberrypi/pico-sdk/tree/master/src/boards/include/boards
5+
list(APPEND PICO_BOARD_HEADER_DIRS ${MICROPY_BOARD_DIR})
6+
7+
# Freeze board.py
8+
set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest.py)
9+
10+
# Provide different variants for the downloads page
11+
set(BOARD_VARIANTS "flash_2mb flash_4mb flash_8mb flash_16mb")
12+
13+
# Select the 16MB variant as the default
14+
set(PICO_BOARD "weactstudio_16mb")
15+
16+
if("${BOARD_VARIANT}" STREQUAL "flash_2mb")
17+
set(PICO_BOARD "weactstudio_2mb")
18+
endif()
19+
20+
if("${BOARD_VARIANT}" STREQUAL "flash_4mb")
21+
set(PICO_BOARD "weactstudio_4mb")
22+
endif()
23+
24+
if("${BOARD_VARIANT}" STREQUAL "flash_8mb")
25+
set(PICO_BOARD "weactstudio_8mb")
26+
endif()
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#define MICROPY_HW_BOARD_NAME "WeAct Studio RP2040"
2+
3+
// Allow 1MB for the firmware image itself, allocate the remainder to the filesystem
4+
#define MICROPY_HW_FLASH_STORAGE_BYTES (PICO_FLASH_SIZE_BYTES - (1 * 1024 * 1024))
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// A pico-sdk board definition is required since the WeAct Studio boards are
2+
// not officially supported.
3+
//
4+
// Officially supported boards:
5+
// https://github.com/raspberrypi/pico-sdk/tree/master/src/boards/include/boards
6+
7+
#ifndef _BOARDS_WEACTSTUDIO_16MB_H
8+
#define _BOARDS_WEACTSTUDIO_16MB_H
9+
10+
#include "weactstudio_common.h"
11+
12+
#define WEACTSTUDIO_16MB
13+
14+
#ifndef PICO_FLASH_SIZE_BYTES
15+
#define PICO_FLASH_SIZE_BYTES (16 * 1024 * 1024)
16+
#endif
17+
18+
#endif
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// A pico-sdk board definition is required since the WeAct Studio boards are
2+
// not officially supported.
3+
//
4+
// Officially supported boards:
5+
// https://github.com/raspberrypi/pico-sdk/tree/master/src/boards/include/boards
6+
7+
#ifndef _BOARDS_WEACTSTUDIO_2MB_H
8+
#define _BOARDS_WEACTSTUDIO_2MB_H
9+
10+
#include "weactstudio_common.h"
11+
12+
#define WEACTSTUDIO_2MB
13+
14+
#ifndef PICO_FLASH_SIZE_BYTES
15+
#define PICO_FLASH_SIZE_BYTES (2 * 1024 * 1024)
16+
#endif
17+
18+
#endif
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// A pico-sdk board definition is required since the WeAct Studio boards are
2+
// not officially supported.
3+
//
4+
// Officially supported boards:
5+
// https://github.com/raspberrypi/pico-sdk/tree/master/src/boards/include/boards
6+
7+
#ifndef _BOARDS_WEACTSTUDIO_4MB_H
8+
#define _BOARDS_WEACTSTUDIO_4MB_H
9+
10+
#include "weactstudio_common.h"
11+
12+
#define WEACTSTUDIO_4MB
13+
14+
#ifndef PICO_FLASH_SIZE_BYTES
15+
#define PICO_FLASH_SIZE_BYTES (4 * 1024 * 1024)
16+
#endif
17+
18+
#endif
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// A pico-sdk board definition is required since the WeAct Studio boards are
2+
// not officially supported.
3+
//
4+
// Officially supported boards:
5+
// https://github.com/raspberrypi/pico-sdk/tree/master/src/boards/include/boards
6+
7+
#ifndef _BOARDS_WEACTSTUDIO_8MB_H
8+
#define _BOARDS_WEACTSTUDIO_8MB_H
9+
10+
#include "weactstudio_common.h"
11+
12+
#define WEACTSTUDIO_8MB
13+
14+
#ifndef PICO_FLASH_SIZE_BYTES
15+
#define PICO_FLASH_SIZE_BYTES (8 * 1024 * 1024)
16+
#endif
17+
18+
#endif
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// Common configuration to all WeAct Studio boards (only flash size differs)
2+
3+
#ifndef _BOARDS_WEACTSTUDIO_COMMON_H
4+
#define _BOARDS_WEACTSTUDIO_COMMON_H
5+
6+
// --- UART ---
7+
#ifndef PICO_DEFAULT_UART
8+
#define PICO_DEFAULT_UART 0
9+
#endif
10+
#ifndef PICO_DEFAULT_UART_TX_PIN
11+
#define PICO_DEFAULT_UART_TX_PIN 0
12+
#endif
13+
#ifndef PICO_DEFAULT_UART_RX_PIN
14+
#define PICO_DEFAULT_UART_RX_PIN 1
15+
#endif
16+
17+
// --- LED ---
18+
#ifndef PICO_DEFAULT_LED_PIN
19+
#define PICO_DEFAULT_LED_PIN 25
20+
#endif
21+
22+
// --- I2C ---
23+
#ifndef PICO_DEFAULT_I2C
24+
#define PICO_DEFAULT_I2C 0
25+
#endif
26+
#ifndef PICO_DEFAULT_I2C_SDA_PIN
27+
#define PICO_DEFAULT_I2C_SDA_PIN 4
28+
#endif
29+
#ifndef PICO_DEFAULT_I2C_SCL_PIN
30+
#define PICO_DEFAULT_I2C_SCL_PIN 5
31+
#endif
32+
33+
// --- SPI ---
34+
#ifndef PICO_DEFAULT_SPI
35+
#define PICO_DEFAULT_SPI 0
36+
#endif
37+
#ifndef PICO_DEFAULT_SPI_SCK_PIN
38+
#define PICO_DEFAULT_SPI_SCK_PIN 18
39+
#endif
40+
#ifndef PICO_DEFAULT_SPI_TX_PIN
41+
#define PICO_DEFAULT_SPI_TX_PIN 19
42+
#endif
43+
#ifndef PICO_DEFAULT_SPI_RX_PIN
44+
#define PICO_DEFAULT_SPI_RX_PIN 16
45+
#endif
46+
#ifndef PICO_DEFAULT_SPI_CSN_PIN
47+
#define PICO_DEFAULT_SPI_CSN_PIN 17
48+
#endif
49+
50+
// --- FLASH ---
51+
#define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1
52+
53+
#ifndef PICO_FLASH_SPI_CLKDIV
54+
#define PICO_FLASH_SPI_CLKDIV 2
55+
#endif
56+
57+
// All boards have B1 RP2040
58+
#ifndef PICO_RP2040_B0_SUPPORTED
59+
#define PICO_RP2040_B0_SUPPORTED 0
60+
#endif
61+
62+
#endif

0 commit comments

Comments
 (0)
0