Skip to content

Commit ad111f3

Browse files
committed
bricks/ev3rt: Use pbsys.
This gets it inline with the other hubs, making development easier. It does not have any pbsys implementation for stdio, but it launches into the REPL and uses stdio as defined in mphalport. This allows it to be used with mpremote for the time being.
1 parent e24e126 commit ad111f3

File tree

6 files changed

+52
-43
lines changed

6 files changed

+52
-43
lines changed

.vscode/c_cpp_properties.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@
9696
"${workspaceFolder}/bricks/ev3rt/build",
9797
"${workspaceFolder}/micropython",
9898
"${workspaceFolder}/lib/ev3rt-lib/sdk/common",
99+
"${workspaceFolder}/lib/ev3rt-lib/sdk/common/ev3api/include",
100+
"${workspaceFolder}/lib/ev3rt-lib/sdk/common/ev3api/src",
101+
"${workspaceFolder}/lib/ev3rt-lib/target/ev3_gcc/pil/include",
99102
"${workspaceFolder}/lib/ev3rt-lib",
100103
"${workspaceFolder}/lib/ev3rt-lib/include",
101104
"${workspaceFolder}/lib/ev3rt-lib/target/ev3_gcc",

bricks/ev3rt/app.c

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,2 @@
1-
// SPDX-License-Identifier: MIT
2-
// Copyright (c) 2022 The Pybricks Authors
3-
4-
#include "ev3api.h"
5-
#include "app.h"
6-
7-
#include <pbsys/main.h>
8-
9-
// For now, this file is the main entry point from EV3RT. Eventually, this
10-
// file can be dropped and main_task() can be mapped to main() in pbsys/main.
11-
// For now it enters the MicroPython REPL directly for convenient debugging.
12-
13-
static char heap[1024 * 256];
14-
15-
void main_task(intptr_t unused) {
16-
17-
// Show the Pybricks logo on the screen so we know that something is
18-
// running. This should be replaced by an appropriate driver in pbio and
19-
// called from the system hmi interface in pbsys.
20-
memfile_t memfile;
21-
image_t image;
22-
if (ev3_memfile_load("/pybricks.bmp", &memfile) == E_OK &&
23-
ev3_image_load(&memfile, &image) == E_OK) {
24-
ev3_lcd_draw_image(&image, 0, 0);
25-
}
26-
27-
while (true) {
28-
pbsys_main_program_t program = {
29-
.id = PBIO_PYBRICKS_USER_PROGRAM_ID_REPL,
30-
.code_start = heap,
31-
.code_end = heap,
32-
.user_ram_start = heap,
33-
.user_ram_end = heap + sizeof(heap),
34-
};
35-
pbsys_main_run_program(&program);
36-
}
37-
}
1+
// Unused, but required for EV3RT build system.
2+
// The main Pybricks entry point is in pbio/platform/ev3rt/platform.c

lib/pbio/platform/ev3rt/pbdrvconfig.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
#define PBDRV_CONFIG_CLOCK (1)
77
#define PBDRV_CONFIG_CLOCK_EV3RT (1)
88

9+
#define PBDRV_CONFIG_BLOCK_DEVICE (1)
10+
#define PBDRV_CONFIG_BLOCK_DEVICE_TEST (1)
11+
#define PBDRV_CONFIG_BLOCK_DEVICE_TEST_SIZE (8 * 1024)
12+
#define PBDRV_CONFIG_BLOCK_DEVICE_TEST_SIZE_USER (512)
13+
914
#define PBDRV_CONFIG_HAS_PORT_A (1)
1015
#define PBDRV_CONFIG_HAS_PORT_B (1)
1116
#define PBDRV_CONFIG_HAS_PORT_C (1)

lib/pbio/platform/ev3rt/pbsysconfig.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,15 @@
1111
#define PBSYS_CONFIG_HMI_NUM_SLOTS (0)
1212
#define PBSYS_CONFIG_HUB_LIGHT_MATRIX (0)
1313
#define PBSYS_CONFIG_MAIN (1)
14-
#define PBSYS_CONFIG_STORAGE (0)
14+
#define PBSYS_CONFIG_STORAGE (1)
15+
#define PBSYS_CONFIG_STORAGE_NUM_SLOTS (1)
16+
#define PBSYS_CONFIG_STORAGE_RAM_SIZE (258 * 1024)
17+
#define PBSYS_CONFIG_STORAGE_ROM_SIZE (PBDRV_CONFIG_BLOCK_DEVICE_TEST_SIZE)
18+
#define PBSYS_CONFIG_STORAGE_USER_DATA_SIZE (PBDRV_CONFIG_BLOCK_DEVICE_TEST_SIZE_USER)
1519
#define PBSYS_CONFIG_STATUS_LIGHT (0)
1620
#define PBSYS_CONFIG_STATUS_LIGHT_BATTERY (0)
1721
#define PBSYS_CONFIG_STATUS_LIGHT_BLUETOOTH (0)
18-
#define PBSYS_CONFIG_STATUS_LIGHT_STATE_ANIMATIONS (1)
19-
#define PBSYS_CONFIG_USER_PROGRAM (0)
22+
#define PBSYS_CONFIG_STATUS_LIGHT_STATE_ANIMATIONS (0)
23+
#define PBSYS_CONFIG_USER_PROGRAM (1)
24+
#define PBSYS_CONFIG_USER_PROGRAM_AUTO_START (1)
2025
#define PBSYS_CONFIG_PROGRAM_STOP (1)

lib/pbio/platform/ev3rt/platform.c

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,35 @@
11
// SPDX-License-Identifier: MIT
2-
// Copyright (c) 2022 The Pybricks Authors
2+
// Copyright (c) 2024 The Pybricks Authors
33

4-
// This file is unused, but required for the common make file.
4+
#include "ev3api.h"
5+
#include "app.h"
6+
7+
#include <pbsys/main.h>
8+
9+
/**
10+
* Any device specific initialization that isn't already done by EV3RT can
11+
* be done here. This follows the pattern of the embedded hubs where there is
12+
* a bit more to do.
13+
*/
14+
static void SystemInit(void) {
15+
// Show the Pybricks logo on the screen so we know that something is
16+
// running. This should be replaced by an appropriate driver in pbio and
17+
// called from the system hmi interface in pbsys.
18+
memfile_t memfile;
19+
image_t image;
20+
if (ev3_memfile_load("/pybricks.bmp", &memfile) == E_OK &&
21+
ev3_image_load(&memfile, &image) == E_OK) {
22+
ev3_lcd_draw_image(&image, 0, 0);
23+
}
24+
}
25+
26+
/**
27+
* This is the main user task launched by EV3RT. It initializes the system
28+
* and then runs to the main pbsys function. This is similar to how these two
29+
* subsequent calls are normally made from startup.s on the embedded hubs.
30+
*/
31+
void main_task(intptr_t unused) {
32+
SystemInit();
33+
extern int main(int argc, char **argv);
34+
main(0, NULL);
35+
}

lib/pbio/platform/nxt/pbsysconfig.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#define PBSYS_CONFIG_STORAGE_NUM_SLOTS (1)
1212
#define PBSYS_CONFIG_STORAGE_RAM_SIZE (10 * 1024)
1313
#define PBSYS_CONFIG_STORAGE_ROM_SIZE (PBDRV_CONFIG_BLOCK_DEVICE_TEST_SIZE)
14-
#define PBSYS_CONFIG_STORAGE_USER_DATA_SIZE (512)
14+
#define PBSYS_CONFIG_STORAGE_USER_DATA_SIZE (PBDRV_CONFIG_BLOCK_DEVICE_TEST_SIZE_USER)
1515
#define PBSYS_CONFIG_STATUS_LIGHT (0)
1616
#define PBSYS_CONFIG_STATUS_LIGHT_BATTERY (0)
1717
#define PBSYS_CONFIG_STATUS_LIGHT_BLUETOOTH (0)

0 commit comments

Comments
 (0)