Skip to content

Commit afd73b9

Browse files
committed
Prepare release for EuRuKo 2025
- Upgrade picoruby - Require "numeric-ext" in main_task.rb - Refactor HEAP_SIZE to make maintainance easy - Debug printf in usb_tud.c
1 parent 9a8bb20 commit afd73b9

File tree

4 files changed

+34
-20
lines changed

4 files changed

+34
-20
lines changed

lib/picoruby

Submodule picoruby updated 313 files

mrblib/main_task.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
require "machine"
2+
require "numeric-ext"
23
require "watchdog"
34
Watchdog.disable
45
require "shell"

src/main.c

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,36 +13,40 @@
1313

1414
#if !defined(HEAP_SIZE)
1515
#if defined(PICO_RP2040)
16-
#if defined(USE_WIFI)
17-
#define HEAP_SIZE (1024 * 140)
18-
#else
19-
#define HEAP_SIZE (1024 * 174)
20-
#endif
16+
#define RAM_SIZE_KB 264
2117
#elif defined(PICO_RP2350)
22-
#if defined(USE_WIFI)
23-
#define HEAP_SIZE (1024 * (150 + 200))
24-
#else
25-
#define HEAP_SIZE (1024 * (194 + 200))
26-
#endif
18+
#define RAM_SIZE_KB 524
2719
#else
28-
#error "Unknown board"
20+
#error "PICO_RP2040 or PICO_RP2350 must be defined"
2921
#endif
22+
// Compiling a big Ruby code may need more stack size
23+
#define BASIC_STACK_SIZE_KB 80
24+
#define WIFI_STACK_SIZE_KB 60
25+
#if defined(USE_WIFI)
26+
#define STACK_SIZE_KB (BASIC_STACK_SIZE_KB + WIFI_STACK_SIZE_KB)
27+
#else
28+
#define STACK_SIZE_KB BASIC_STACK_SIZE_KB
29+
#endif
30+
#define HEAP_SIZE_KB (RAM_SIZE_KB - STACK_SIZE_KB)
31+
#define HEAP_SIZE (HEAP_SIZE_KB * 1024)
3032
#endif
3133

3234
#if defined(R2P2_ALLOC_LIBC)
33-
#define heap_pool NULL
35+
#define heap_pool NULL
3436
#else
35-
static uint8_t heap_pool[HEAP_SIZE] __attribute__((aligned(8)));
37+
static uint8_t heap_pool[HEAP_SIZE] __attribute__((aligned(8)));
3638
#endif
3739

38-
mrb_state *global_mrb = NULL;
40+
#if defined(PICORB_VM_MRUBY)
41+
mrb_state *global_mrb = NULL;
42+
#endif
3943

4044
int
4145
main(void)
4246
{
4347
stdio_init_all();
4448
printf("R2P2 PicoRuby starting...\n");
45-
printf("HEAP_SIZE: %d bytes\n", HEAP_SIZE);
49+
printf("Heap size: %d KB\n", HEAP_SIZE_KB);
4650
board_init();
4751

4852
int ret = 0;

src/usb_tud.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,38 @@
11
#include <pico/stdlib.h>
2+
#include <stdio.h>
23

34
//--------------------------------------------------------------------+
45
// Device callbacks
56
//--------------------------------------------------------------------+
67

78
// Invoked when device is mounted
8-
void tud_mount_cb(void)
9+
void
10+
tud_mount_cb(void)
911
{
12+
printf("USB mounted!\n");
1013
}
1114

1215
// Invoked when device is unmounted
13-
void tud_umount_cb(void)
16+
void
17+
tud_umount_cb(void)
1418
{
19+
printf("USB unmounted!\n");
1520
}
1621

1722
// Invoked when usb bus is suspended
1823
// remote_wakeup_en : if host allow us to perform remote wakeup
1924
// Within 7ms, device must draw an average of current less than 2.5 mA from bus
20-
void tud_suspend_cb(bool remote_wakeup_en)
25+
void
26+
tud_suspend_cb(bool remote_wakeup_en)
2127
{
2228
(void) remote_wakeup_en;
29+
printf("USB suspended!\n");
2330
}
2431

2532
// Invoked when usb bus is resumed
26-
void tud_resume_cb(void)
33+
void
34+
tud_resume_cb(void)
2735
{
36+
printf("USB resumed!\n");
2837
}
2938

0 commit comments

Comments
 (0)