Skip to content

Commit 5f09609

Browse files
committed
Add Spresense board folder
1 parent 1fa8841 commit 5f09609

10 files changed

Lines changed: 198 additions & 90 deletions

File tree

ports/cxd56/Makefile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,23 @@
2222
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2323
# THE SOFTWARE.
2424

25+
# Select the board to build for.
26+
ifeq ($(BOARD),)
27+
$(error You must provide a BOARD parameter)
28+
else
29+
ifeq ($(wildcard boards/$(BOARD)/.),)
30+
$(error Invalid BOARD specified)
31+
endif
32+
endif
33+
34+
# If the build directory is not given, make it reflect the board name.
35+
BUILD ?= build-$(BOARD)
36+
2537
include ../../py/mkenv.mk
2638

39+
# Board-specific
40+
include boards/$(BOARD)/mpconfigboard.mk
41+
2742
# Port-specific
2843
include mpconfigport.mk
2944

@@ -54,6 +69,7 @@ INC += \
5469
-I../lib/timeutils \
5570
-I../../lib/tinyusb/src \
5671
-I../../supervisor/shared/usb \
72+
-Iboards/$(BOARD) \
5773
-I$(BUILD) \
5874
-I$(SPRESENSE_SDK)/nuttx/include \
5975
-I$(SPRESENSE_SDK)/nuttx/arch \
@@ -123,6 +139,8 @@ SRC_C = \
123139
background.c \
124140
fatfs_port.c \
125141
mphalport.c \
142+
boards/$(BOARD)/board.c \
143+
boards/$(BOARD)/pins.c \
126144
lib/utils/stdout_helpers.c \
127145
lib/utils/pyexec.c \
128146
lib/libc/string0.c \

ports/cxd56/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Change directory to cxd56:
3939

4040
To build circuitpython image run:
4141

42-
$ make
42+
$ make BOARD=spresense
4343

4444
USB connection
4545
--------------
@@ -67,14 +67,14 @@ Extract spresense binaries in your PC to ports/spresense/spresense-exported-sdk/
6767

6868
To flash the bootloader run the command:
6969

70-
$ make flash-bootloader
70+
$ make BOARD=spresense flash-bootloader
7171

7272
Flash the circuitpython.spk image
7373
---------------------------------
7474

7575
To flash the firmware run the command:
7676

77-
$ make flash
77+
$ make BOARD=spresense flash
7878

7979
Accessing the board
8080
-------------------

ports/cxd56/boards/board.h

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright 2019 Sony Semiconductor Solutions Corporation
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
// This file defines board specific functions.
28+
29+
#ifndef MICROPY_INCLUDED_CXD56_BOARDS_BOARD_H
30+
#define MICROPY_INCLUDED_CXD56_BOARDS_BOARD_H
31+
32+
#include <stdbool.h>
33+
34+
// Initializes board related state once on start up.
35+
void board_init(void);
36+
37+
// Returns true if the user initiates safe mode in a board specific way.
38+
// Also add BOARD_USER_SAFE_MODE in mpconfigboard.h to explain the board specific
39+
// way.
40+
bool board_requests_safe_mode(void);
41+
42+
// Reset the state of off MCU components such as neopixels.
43+
void reset_board(void);
44+
45+
#endif // MICROPY_INCLUDED_CXD56_BOARDS_BOARD_H
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright 2019 Sony Semiconductor Solutions Corporation
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
#include "boards/board.h"
28+
29+
void board_init(void)
30+
{
31+
}
32+
33+
bool board_requests_safe_mode(void) {
34+
return false;
35+
}
36+
37+
void reset_board(void) {
38+
}
File renamed without changes.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
USB_VID = 0x054c
2+
USB_PID = 0x0bc2
3+
USB_PRODUCT = "Spresense"
4+
USB_MANUFACTURER = "Sony"
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright 2019 Sony Semiconductor Solutions Corporation
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
#include "shared-bindings/board/__init__.h"
28+
29+
STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
30+
{ MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_D0) },
31+
{ MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_D1) },
32+
{ MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_D2) },
33+
{ MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_D3) },
34+
{ MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_D4) },
35+
{ MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_D5) },
36+
{ MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_D6) },
37+
{ MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_D7) },
38+
{ MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_D8) },
39+
{ MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_D9) },
40+
{ MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_D10) },
41+
{ MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_D11) },
42+
{ MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_D12) },
43+
{ MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_D13) },
44+
{ MP_ROM_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_D14) },
45+
{ MP_ROM_QSTR(MP_QSTR_D15), MP_ROM_PTR(&pin_D15) },
46+
{ MP_ROM_QSTR(MP_QSTR_D16), MP_ROM_PTR(&pin_D16) },
47+
{ MP_ROM_QSTR(MP_QSTR_D17), MP_ROM_PTR(&pin_D17) },
48+
{ MP_ROM_QSTR(MP_QSTR_D18), MP_ROM_PTR(&pin_D18) },
49+
{ MP_ROM_QSTR(MP_QSTR_D19), MP_ROM_PTR(&pin_D19) },
50+
{ MP_ROM_QSTR(MP_QSTR_D20), MP_ROM_PTR(&pin_D20) },
51+
{ MP_ROM_QSTR(MP_QSTR_D21), MP_ROM_PTR(&pin_D21) },
52+
{ MP_ROM_QSTR(MP_QSTR_D22), MP_ROM_PTR(&pin_D22) },
53+
{ MP_ROM_QSTR(MP_QSTR_D23), MP_ROM_PTR(&pin_D23) },
54+
{ MP_ROM_QSTR(MP_QSTR_D24), MP_ROM_PTR(&pin_D24) },
55+
{ MP_ROM_QSTR(MP_QSTR_D25), MP_ROM_PTR(&pin_D25) },
56+
{ MP_ROM_QSTR(MP_QSTR_D26), MP_ROM_PTR(&pin_D26) },
57+
{ MP_ROM_QSTR(MP_QSTR_D27), MP_ROM_PTR(&pin_D27) },
58+
{ MP_ROM_QSTR(MP_QSTR_D28), MP_ROM_PTR(&pin_D28) },
59+
{ MP_ROM_QSTR(MP_QSTR_LED0), MP_ROM_PTR(&pin_LED0) },
60+
{ MP_ROM_QSTR(MP_QSTR_LED1), MP_ROM_PTR(&pin_LED1) },
61+
{ MP_ROM_QSTR(MP_QSTR_LED2), MP_ROM_PTR(&pin_LED2) },
62+
{ MP_ROM_QSTR(MP_QSTR_LED3), MP_ROM_PTR(&pin_LED3) },
63+
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_A0) },
64+
{ MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_A1) },
65+
{ MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_A2) },
66+
{ MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_A3) },
67+
{ MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_A4) },
68+
{ MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_A5) },
69+
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_D14) },
70+
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_D15) },
71+
{ MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_D13) },
72+
{ MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_D12) },
73+
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_D11) },
74+
{ MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_D0) },
75+
{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_D1) },
76+
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
77+
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) },
78+
{ MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) },
79+
};
80+
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);
Lines changed: 1 addition & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1 @@
1-
/*
2-
* This file is part of the MicroPython project, http://micropython.org/
3-
*
4-
* The MIT License (MIT)
5-
*
6-
* Copyright 2019 Sony Semiconductor Solutions Corporation
7-
*
8-
* Permission is hereby granted, free of charge, to any person obtaining a copy
9-
* of this software and associated documentation files (the "Software"), to deal
10-
* in the Software without restriction, including without limitation the rights
11-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12-
* copies of the Software, and to permit persons to whom the Software is
13-
* furnished to do so, subject to the following conditions:
14-
*
15-
* The above copyright notice and this permission notice shall be included in
16-
* all copies or substantial portions of the Software.
17-
*
18-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24-
* THE SOFTWARE.
25-
*/
26-
27-
#include "shared-bindings/board/__init__.h"
28-
29-
STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
30-
{ MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_D0) },
31-
{ MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_D1) },
32-
{ MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_D2) },
33-
{ MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_D3) },
34-
{ MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_D4) },
35-
{ MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_D5) },
36-
{ MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_D6) },
37-
{ MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_D7) },
38-
{ MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_D8) },
39-
{ MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_D9) },
40-
{ MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_D10) },
41-
{ MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_D11) },
42-
{ MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_D12) },
43-
{ MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_D13) },
44-
{ MP_ROM_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_D14) },
45-
{ MP_ROM_QSTR(MP_QSTR_D15), MP_ROM_PTR(&pin_D15) },
46-
{ MP_ROM_QSTR(MP_QSTR_D16), MP_ROM_PTR(&pin_D16) },
47-
{ MP_ROM_QSTR(MP_QSTR_D17), MP_ROM_PTR(&pin_D17) },
48-
{ MP_ROM_QSTR(MP_QSTR_D18), MP_ROM_PTR(&pin_D18) },
49-
{ MP_ROM_QSTR(MP_QSTR_D19), MP_ROM_PTR(&pin_D19) },
50-
{ MP_ROM_QSTR(MP_QSTR_D20), MP_ROM_PTR(&pin_D20) },
51-
{ MP_ROM_QSTR(MP_QSTR_D21), MP_ROM_PTR(&pin_D21) },
52-
{ MP_ROM_QSTR(MP_QSTR_D22), MP_ROM_PTR(&pin_D22) },
53-
{ MP_ROM_QSTR(MP_QSTR_D23), MP_ROM_PTR(&pin_D23) },
54-
{ MP_ROM_QSTR(MP_QSTR_D24), MP_ROM_PTR(&pin_D24) },
55-
{ MP_ROM_QSTR(MP_QSTR_D25), MP_ROM_PTR(&pin_D25) },
56-
{ MP_ROM_QSTR(MP_QSTR_D26), MP_ROM_PTR(&pin_D26) },
57-
{ MP_ROM_QSTR(MP_QSTR_D27), MP_ROM_PTR(&pin_D27) },
58-
{ MP_ROM_QSTR(MP_QSTR_D28), MP_ROM_PTR(&pin_D28) },
59-
{ MP_ROM_QSTR(MP_QSTR_LED0), MP_ROM_PTR(&pin_LED0) },
60-
{ MP_ROM_QSTR(MP_QSTR_LED1), MP_ROM_PTR(&pin_LED1) },
61-
{ MP_ROM_QSTR(MP_QSTR_LED2), MP_ROM_PTR(&pin_LED2) },
62-
{ MP_ROM_QSTR(MP_QSTR_LED3), MP_ROM_PTR(&pin_LED3) },
63-
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_A0) },
64-
{ MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_A1) },
65-
{ MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_A2) },
66-
{ MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_A3) },
67-
{ MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_A4) },
68-
{ MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_A5) },
69-
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_D14) },
70-
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_D15) },
71-
{ MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_D13) },
72-
{ MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_D12) },
73-
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_D11) },
74-
{ MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_D0) },
75-
{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_D1) },
76-
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
77-
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) },
78-
{ MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) },
79-
};
80-
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);
1+
// No board module functions.

ports/cxd56/mpconfigport.mk

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
USB_VID = 0x054c
2-
USB_PID = 0x0bc2
3-
USB_PRODUCT = "Spresense"
4-
USB_MANUFACTURER = "Sony"
51
USB_SERIAL_NUMBER_LENGTH = 10
62
USB_DEVICES = "CDC,MSC"
73
USB_MSC_MAX_PACKET_SIZE = 512

ports/cxd56/supervisor/port.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
#include <stdint.h>
2828
#include <sys/boardctl.h>
2929

30+
#include "boards/board.h"
31+
3032
#include "supervisor/port.h"
3133

3234
#include "common-hal/microcontroller/Pin.h"
@@ -36,6 +38,13 @@
3638

3739
safe_mode_t port_init(void) {
3840
boardctl(BOARDIOC_INIT, 0);
41+
42+
board_init();
43+
44+
if (board_requests_safe_mode()) {
45+
return USER_SAFE_MODE;
46+
}
47+
3948
return NO_SAFE_MODE;
4049
}
4150

@@ -55,9 +64,6 @@ void reset_port(void) {
5564
reset_all_pins();
5665
}
5766

58-
void reset_board(void) {
59-
}
60-
6167
void reset_to_bootloader(void) {
6268
}
6369

0 commit comments

Comments
 (0)