Skip to content

Commit 40632dd

Browse files
committed
rp2/boards: BOARD_VARIANT can now select flash size.
1 parent b37d06a commit 40632dd

File tree

5 files changed

+29
-17
lines changed

5 files changed

+29
-17
lines changed

ports/rp2/boards/WEACTSTUDIO/board.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"weact_rp2040.jpg"
1313
],
1414
"mcu": "rp2040",
15-
"product": "WeAct Studio RP2040 (16MiB)",
15+
"product": "WeAct Studio RP2040",
1616
"url": "https://github.com/WeActTC/WeActStudio.RP2040CoreBoard/tree/master",
1717
"vendor": "WeAct"
1818
}

ports/rp2/boards/WEACTSTUDIO/modules/board.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from micropython import const
21
from machine import Pin
32

43
led = Pin(25, Pin.OUT, value=0)
Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,39 @@
1-
# cmake file for WeAct Studio RP2040 boards
1+
# CMake file for WeAct Studio RP2040 boards
22

33
# The WeAct Studio boards don't have official pico-sdk support so we define it
44
# here in weactstudio.h.
55
# See also: https://github.com/raspberrypi/pico-sdk/tree/master/src/boards/include/boards
6-
#set(PICO_BOARD_HEADER_DIRS ${MICROPY_PORT_DIR}/boards/${MICROPY_BOARD})
76
list(APPEND PICO_BOARD_HEADER_DIRS ${MICROPY_BOARD_DIR})
87

98
# Freeze board.py
109
set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest.py)
1110

1211
# Provide different variants for the downloads page.
13-
#string(CONCAT BOARD_VARIANTS "${BOARD_VARIANTS} " "flash_2mb flash_4mb flash_8mb flash_16mb")
1412
set(BOARD_VARIANTS "flash_2mb flash_4mb flash_8mb flash_16mb")
1513

1614
if("${BOARD_VARIANT}" STREQUAL "flash_2mb")
1715
set(FLASH_SIZE_MB 2)
18-
math(EXPR PICO_FLASH_SIZE_BYTES "${FLASH_SIZE_MB} * 1024 * 1024")
19-
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DPICO_FLASH_SIZE_BYTES=${PICO_FLASH_SIZE_BYTES}")
20-
message("BOARD_VARIANT=" ${BOARD_VARIANT} " FLASH_SIZE_MB=" ${FLASH_SIZE_MB} " PICO_FLASH_SIZE_BYTES=" ${PICO_FLASH_SIZE_BYTES})
2116
endif()
2217

23-
if (DEFINED PICO_FLASH_SIZE_BYTES)
18+
if("${BOARD_VARIANT}" STREQUAL "flash_4mb")
19+
set(FLASH_SIZE_MB 4)
20+
endif()
21+
22+
if("${BOARD_VARIANT}" STREQUAL "flash_8mb")
23+
set(FLASH_SIZE_MB 8)
24+
endif()
25+
26+
if("${BOARD_VARIANT}" STREQUAL "flash_16mb")
27+
set(FLASH_SIZE_MB 16)
28+
endif()
29+
30+
if (DEFINED FLASH_SIZE_MB)
31+
math(EXPR PICO_FLASH_SIZE_BYTES "${FLASH_SIZE_MB} * 1024 * 1024")
2432
add_compile_definitions(
25-
PICO_FLASH_SIZE_BYTES="${PICO_FLASH_SIZE_BYTES}"
33+
PICO_FLASH_SIZE_BYTES=${PICO_FLASH_SIZE_BYTES}
34+
FLASH_SIZE_MB=${FLASH_SIZE_MB}
35+
)
36+
list(
37+
APPEND MICROPY_CPP_DEF_EXTRA PICO_FLASH_SIZE_BYTES=${PICO_FLASH_SIZE_BYTES}
2638
)
2739
endif()
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
#define MICROPY_HW_BOARD_NAME "WeAct Studio RP2040"
2-
// TODO(mst) Need to update this from "FLASH_SIZE_MB - 1", see mpconfigboard.cmake
3-
#define MICROPY_HW_FLASH_STORAGE_BYTES (15 * 1024 * 1024)
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 ((FLASH_SIZE_MB - 1) * 1024 * 1024)

ports/rp2/boards/WEACTSTUDIO/weactstudio.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
// Officially supported boards:
55
// https://github.com/raspberrypi/pico-sdk/tree/master/src/boards/include/boards
66

7-
#ifndef _BOARDS_WAVGAT_16MB_H
8-
#define _BOARDS_WAVGAT_16MB_H
7+
#ifndef _BOARDS_WEACTSTUDIO_H
8+
#define _BOARDS_WEACTSTUDIO_H
99

1010
// For board detection
11-
#define WAVGAT_16MB
11+
#define WEACTSTUDIO
1212

1313
// --- UART ---
1414
#ifndef PICO_DEFAULT_UART
@@ -63,7 +63,7 @@
6363

6464
#ifndef PICO_FLASH_SIZE_BYTES
6565
#define PICO_FLASH_SIZE_BYTES (FLASH_SIZE_MB * 1024 * 1024)
66-
#error Fail!
66+
#error PICO_FLASH_SIZE_BYTES should always be set by selecting an appropriate BOARD_VARIANT
6767
#endif
6868

6969
// All boards have B1 RP2040

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy