Skip to content

Commit c10abe5

Browse files
committed
Upgrade picoruby
1 parent cc29aed commit c10abe5

14 files changed

+133
-122
lines changed

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
11
# Change log
22

3+
## 0.10.0 on 2024/11/17
4+
5+
Almost one year has passed since the last release. We have been working on improving the PRK Firmware!
6+
7+
### Breaking Change 💣
8+
- No breaking change in this release
9+
10+
### New Feature 🎉
11+
- On startup, if you connect a terminal emulator to com port, you can skip starting the keyboard task by pressing `s` according to the message on the terminal
12+
- This feature is useful when your `keymap.rb` breaks and hangs up the keyboard
13+
- Note that `s` key should be sent from the other keyboard that is working fine. This means you have to have multiple keyboards⌨⌨⌨⌨
14+
15+
### Improvement 🔈
16+
- Replace PicoRuby with a totally new one:
17+
- The Ruby parser is now Prism!
18+
- Many bugs are fixed in the virtual machine and libraries
19+
- Stability should be improved a lot🤞
20+
21+
Please report if you find any bugs!
22+
323
## 0.9.23 on 2023/11/19
424

525
### require

CMakeLists.txt

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.24)
33
# initialize the SDK based on PICO_SDK_PATH
44
# note: this must happen before project()
55
include(pico_sdk_import.cmake)
6+
include(pico_extras_import.cmake)
67

78
#####################################################
89
# project specific configuration from here
@@ -48,6 +49,14 @@ project("prk_firmware-${MSC_NAME}-${PRK_VERSION}-${PRK_BUILDDATE}-${PRK_REVISION
4849
# Initializing the Raspberry Pi Pico SDK should happen after project created
4950
pico_sdk_init()
5051

52+
add_compile_options(-Wall
53+
# int != int32_t as far as the compiler is concerned because gcc has int32_t as long int
54+
-Wno-format
55+
-Wno-unused-function
56+
-Wno-maybe-uninitialized
57+
-fshort-enums
58+
)
59+
5160
file(GLOB SRCS src/*.c)
5261
add_executable(${PROJECT_NAME}
5362
${SRCS}
@@ -58,7 +67,13 @@ add_executable(${PROJECT_NAME}
5867
${CMAKE_SOURCE_DIR}/lib/picoruby/mrbgems/picoruby-i2c/ports/rp2040/i2c.c
5968
${CMAKE_SOURCE_DIR}/lib/picoruby/mrbgems/picoruby-spi/ports/rp2040/spi.c
6069
${CMAKE_SOURCE_DIR}/lib/picoruby/mrbgems/picoruby-adc/ports/rp2040/adc.c
70+
${CMAKE_SOURCE_DIR}/lib/picoruby/mrbgems/picoruby-uart/ports/rp2040/uart.c
71+
${CMAKE_SOURCE_DIR}/lib/picoruby/mrbgems/picoruby-pwm/ports/rp2040/pwm.c
72+
${CMAKE_SOURCE_DIR}/lib/picoruby/mrbgems/picoruby-machine/ports/rp2040/machine.c
6173
${CMAKE_SOURCE_DIR}/lib/picoruby/mrbgems/picoruby-io-console/ports/rp2040/io-console.c
74+
${CMAKE_SOURCE_DIR}/lib/picoruby/mrbgems/picoruby-watchdog/ports/rp2040/watchdog.c
75+
${CMAKE_SOURCE_DIR}/lib/picoruby/mrbgems/picoruby-rng/ports/rp2040/rng.c
76+
${CMAKE_SOURCE_DIR}/lib/picoruby/mrbgems/picoruby-env/ports/rp2040/env.c
6277
)
6378

6479
set(PICORBC ${CMAKE_SOURCE_DIR}/lib/picoruby/bin/picorbc)
@@ -114,11 +129,11 @@ add_dependencies(${PROJECT_NAME}
114129
target_include_directories(${PROJECT_NAME} PRIVATE
115130
${CMAKE_SOURCE_DIR}/tinyusb
116131
${CMAKE_SOURCE_DIR}/lib/picoruby/include/hal_no_impl
117-
${CMAKE_SOURCE_DIR}/lib/picoruby/mrbgems/picoruby-mrubyc/repos/mrubyc/src
132+
${CMAKE_SOURCE_DIR}/lib/picoruby/mrbgems/picoruby-mrubyc/lib/mrubyc/src
118133
${CMAKE_SOURCE_DIR}/lib/picoruby/mrbgems/picoruby-filesystem-fat/lib/ff14b/source
119134
${CMAKE_SOURCE_DIR}/lib/picoruby/build/$ENV{MRUBY_CONFIG}/mrbgems
120-
${CMAKE_SOURCE_DIR}/lib/picoruby/build/repos/$ENV{MRUBY_CONFIG}/mruby-pico-compiler/include
121135
${CMAKE_SOURCE_DIR}/lib/picoruby/mrbgems
136+
${CMAKE_SOURCE_DIR}/lib/picoruby/build/repos/${BUILD_CONFIG}/mruby-compiler2/include
122137
)
123138

124139
target_link_directories(${PROJECT_NAME} PRIVATE
@@ -131,15 +146,16 @@ target_link_libraries(${PROJECT_NAME}
131146
tinyusb_device
132147
tinyusb_board
133148
hardware_pio
134-
hardware_pwm
135-
pico_multicore
149+
hardware_sleep
136150
hardware_flash
137151
hardware_adc
152+
hardware_uart
138153
hardware_dma
139154
hardware_sync
140155
hardware_irq
141156
hardware_i2c
142157
hardware_spi
158+
hardware_pwm
143159
mruby
144160
)
145161

Gemfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
source 'https://rubygems.org'
22

33
gem 'rake'
4-
gem "mrubyc-test", ">= 0.9.1"

Gemfile.lock

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,12 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4-
activesupport (7.0.4.2)
5-
concurrent-ruby (~> 1.0, >= 1.0.2)
6-
i18n (>= 1.6, < 2)
7-
minitest (>= 5.1)
8-
tzinfo (~> 2.0)
9-
concurrent-ruby (1.2.2)
10-
i18n (1.12.0)
11-
concurrent-ruby (~> 1.0)
12-
minitest (5.18.0)
13-
mrubyc-test (0.9.2)
14-
activesupport (~> 7.0)
15-
rufo (~> 0.12)
16-
thor (~> 1.2)
174
rake (13.0.6)
18-
rufo (0.15.1)
19-
thor (1.2.1)
20-
tzinfo (2.0.6)
21-
concurrent-ruby (~> 1.0)
225

236
PLATFORMS
247
x86_64-linux
258

269
DEPENDENCIES
27-
mrubyc-test (>= 0.9.1)
2810
rake
2911

3012
BUNDLED WITH

Guardfile

Lines changed: 0 additions & 4 deletions
This file was deleted.

Rakefile

Lines changed: 8 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
require "fileutils"
22

33
ENV['MRUBY_CONFIG'] = "prk_firmware-cortex-m0plus"
4-
PICO_SDK_TAG = "1.5.1"
4+
PICO_SDK_TAG = "2.0.0"
55

66
task :default => :production
77

88
task :setup do
99
sh "bundle install"
10-
sh "git submodule update --init"
10+
sh "git submodule update --init --recursive"
1111
FileUtils.cd "lib/picoruby" do
1212
sh "bundle install"
1313
end
1414
end
1515

16-
task :all => [:libmruby, :test, :cmake, :build]
17-
16+
task :all => [:libmruby, :cmake, :build]
1817

1918
desc "build debug (you may need to rake clean before this)"
2019
task :debug do
2120
ENV['PICORUBY_DEBUG'] = '1'
22-
ENV['-DCMAKE_BUILD_TYPE'] = 'Debug'
21+
ENV['CMAKE_BUILD_TYPE'] = 'Debug'
2322
Rake::Task[:all].invoke
2423
end
2524

2625
desc "build production"
2726
task :production do
27+
ENV['CMAKE_BUILD_TYPE'] = 'Release'
2828
Rake::Task[:all].invoke
2929
end
3030

@@ -55,12 +55,12 @@ end
5555
task :libmruby => "lib/picoruby" do
5656
FileUtils.cd "lib/picoruby" do
5757
sh "MRUBY_CONFIG=default rake test"
58-
sh "MRUBY_CONFIG=#{ENV['MRUBY_CONFIG']} rake"
58+
sh "rake"
5959
end
6060
end
6161

6262
task :cmake do
63-
sh "cmake -B #{ENV['PRK_BUILD_DIR']}build"
63+
sh "cmake -DCMAKE_BUILD_TYPE=#{ENV['CMAKE_BUILD_TYPE']} -B #{ENV['PRK_BUILD_DIR']}build"
6464
end
6565

6666
task :check_pico_sdk => :check_pico_sdk_path do
@@ -96,28 +96,6 @@ task :clean_with_keymap , ['keyboard_name'] do |_t, args|
9696
FileUtils.rm_r Dir.glob("keyboards/#{args.keyboard_name}/build/*")
9797
end
9898

99-
100-
desc "run :mrubyc_test"
101-
task :test => %i(mrubyc_test)
102-
103-
desc "run unit test for ruby program"
104-
task :mrubyc_test => :setup_test do
105-
sh %q(MRUBYCFILE=test/Mrubycfile bundle exec mrubyc-test)
106-
end
107-
108-
task :setup_test do
109-
FileUtils.cd "test/models" do
110-
Dir.glob("../../lib/picoruby/mrbgems/picoruby-prk-*").each do |dir|
111-
Dir.glob("#{dir}/mrblib/*.rb").each do |model|
112-
FileUtils.ln_sf model, File.basename(model)
113-
end
114-
end
115-
FileUtils.ln_sf "../../lib/picoruby/mrbgems/picoruby-gpio/mrblib/gpio.rb", "gpio.rb"
116-
FileUtils.ln_sf "../../lib/picoruby/mrbgems/picoruby-float-ext/mrblib/float.rb", "float.rb"
117-
FileUtils.ln_sf "../../lib/picoruby/mrbgems/picoruby-music-macro-language/mrblib/mml.rb", "mml.rb"
118-
end
119-
end
120-
12199
desc "clean built"
122100
task :clean do
123101
FileUtils.cd "lib/picoruby" do
@@ -150,13 +128,8 @@ task :symlinks do
150128
end
151129
end
152130

153-
desc "run guard-process"
154-
task :guard do
155-
sh "bundle exec guard start -i"
156-
end
157-
158131
# Add a new tag then push it
159-
task :release => :test do
132+
task :release do
160133
git_status = `git status`
161134
branch = git_status.split("\n")[0].match(/\AOn branch (.+)\z/)[1]
162135
if branch != "master"

lib/picoruby

Submodule picoruby updated 387 files

mrblib/object-ext.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
class LoadError < StandardError
2-
# ScriptError is the super class in CRuby
3-
end
4-
51
class Object
62

73
alias _puts puts

mrblib/usb_task.rb

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
1+
require "machine"
2+
require "watchdog"
3+
Watchdog.disable
4+
require 'env'
5+
6+
ENV["HOME"] = "/"
7+
ENV["PWD"] = "/"
8+
9+
STDOUT = IO
10+
STDIN = IO
11+
STDIN.echo = false
12+
113
if PICORUBY_MSC == "MSC_SD"
214
require "spi"
315
end
416
require "keyboard"
517

6-
ENV = {}
7-
818
200.times do
919
USB.tud_task
1020
sleep_ms 2
@@ -17,6 +27,11 @@
1727
while true
1828
USB.tud_task
1929
if Keyboard.autoreload_ready? && File.exist?("/keymap.rb")
20-
Keyboard.restart
30+
break unless Keyboard.restart
2131
end
2232
end
33+
34+
puts "Restart microcontroller when you want to reload keymap.rb"
35+
while true
36+
USB.tud_task
37+
end

pico_extras_import.cmake

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# This is a copy of <PICO_EXTRAS_PATH>/external/pico_extras_import.cmake
2+
3+
# This can be dropped into an external project to help locate pico-extras
4+
# It should be include()ed prior to project()
5+
6+
if (DEFINED ENV{PICO_EXTRAS_PATH} AND (NOT PICO_EXTRAS_PATH))
7+
set(PICO_EXTRAS_PATH $ENV{PICO_EXTRAS_PATH})
8+
message("Using PICO_EXTRAS_PATH from environment ('${PICO_EXTRAS_PATH}')")
9+
endif ()
10+
11+
if (DEFINED ENV{PICO_EXTRAS_FETCH_FROM_GIT} AND (NOT PICO_EXTRAS_FETCH_FROM_GIT))
12+
set(PICO_EXTRAS_FETCH_FROM_GIT $ENV{PICO_EXTRAS_FETCH_FROM_GIT})
13+
message("Using PICO_EXTRAS_FETCH_FROM_GIT from environment ('${PICO_EXTRAS_FETCH_FROM_GIT}')")
14+
endif ()
15+
16+
if (DEFINED ENV{PICO_EXTRAS_FETCH_FROM_GIT_PATH} AND (NOT PICO_EXTRAS_FETCH_FROM_GIT_PATH))
17+
set(PICO_EXTRAS_FETCH_FROM_GIT_PATH $ENV{PICO_EXTRAS_FETCH_FROM_GIT_PATH})
18+
message("Using PICO_EXTRAS_FETCH_FROM_GIT_PATH from environment ('${PICO_EXTRAS_FETCH_FROM_GIT_PATH}')")
19+
endif ()
20+
21+
if (NOT PICO_EXTRAS_PATH)
22+
if (PICO_EXTRAS_FETCH_FROM_GIT)
23+
include(FetchContent)
24+
set(FETCHCONTENT_BASE_DIR_SAVE ${FETCHCONTENT_BASE_DIR})
25+
if (PICO_EXTRAS_FETCH_FROM_GIT_PATH)
26+
get_filename_component(FETCHCONTENT_BASE_DIR "${PICO_EXTRAS_FETCH_FROM_GIT_PATH}" REALPATH BASE_DIR "${CMAKE_SOURCE_DIR}")
27+
endif ()
28+
FetchContent_Declare(
29+
PICO_EXTRAS
30+
GIT_REPOSITORY https://github.com/raspberrypi/pico-extras
31+
GIT_TAG master
32+
)
33+
if (NOT PICO_EXTRAS)
34+
message("Downloading PICO EXTRAS")
35+
FetchContent_Populate(PICO_EXTRAS)
36+
set(PICO_EXTRAS_PATH ${PICO_EXTRAS_SOURCE_DIR})
37+
endif ()
38+
set(FETCHCONTENT_BASE_DIR ${FETCHCONTENT_BASE_DIR_SAVE})
39+
else ()
40+
if (PICO_SDK_PATH AND EXISTS "${PICO_SDK_PATH}/../pico-extras")
41+
set(PICO_EXTRAS_PATH ${PICO_SDK_PATH}/../pico-extras)
42+
message("Defaulting PICO_EXTRAS_PATH as sibling of PICO_SDK_PATH: ${PICO_EXTRAS_PATH}")
43+
else()
44+
message(FATAL_ERROR
45+
"PICO EXTRAS location was not specified. Please set PICO_EXTRAS_PATH or set PICO_EXTRAS_FETCH_FROM_GIT to on to fetch from git."
46+
)
47+
endif()
48+
endif ()
49+
endif ()
50+
51+
set(PICO_EXTRAS_PATH "${PICO_EXTRAS_PATH}" CACHE PATH "Path to the PICO EXTRAS")
52+
set(PICO_EXTRAS_FETCH_FROM_GIT "${PICO_EXTRAS_FETCH_FROM_GIT}" CACHE BOOL "Set to ON to fetch copy of PICO EXTRAS from git if not otherwise locatable")
53+
set(PICO_EXTRAS_FETCH_FROM_GIT_PATH "${PICO_EXTRAS_FETCH_FROM_GIT_PATH}" CACHE FILEPATH "location to download EXTRAS")
54+
55+
get_filename_component(PICO_EXTRAS_PATH "${PICO_EXTRAS_PATH}" REALPATH BASE_DIR "${CMAKE_BINARY_DIR}")
56+
if (NOT EXISTS ${PICO_EXTRAS_PATH})
57+
message(FATAL_ERROR "Directory '${PICO_EXTRAS_PATH}' not found")
58+
endif ()
59+
60+
set(PICO_EXTRAS_PATH ${PICO_EXTRAS_PATH} CACHE PATH "Path to the PICO EXTRAS" FORCE)
61+
62+
add_subdirectory(${PICO_EXTRAS_PATH} pico_extras)

0 commit comments

Comments
 (0)