Skip to content

Commit

Permalink
Port to RP2350
Browse files Browse the repository at this point in the history
  • Loading branch information
Natchanon Nuntanirund committed Sep 2, 2024
1 parent f4a3243 commit 0c1c41b
Show file tree
Hide file tree
Showing 63 changed files with 2,072 additions and 304 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
.DS_Store
*.so
build/
examples/*.c
examples/*.c.bak
js/*.c
js/*.c.bak
tests/js/*.c
tests/js/*.c.bak
isere
Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[submodule "3rdparty/FreeRTOS"]
path = 3rdparty/FreeRTOS
url = https://github.com/FreeRTOS/FreeRTOS-Kernel.git
url = https://github.com/raspberrypi/FreeRTOS-Kernel.git
[submodule "3rdparty/quickjs"]
path = 3rdparty/quickjs
url = https://github.com/jeeyo/quickjs.git
Expand Down
38 changes: 30 additions & 8 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"configurations": [
{
"name": "POSIX",
"intelliSenseMode": "gcc-arm64",
"intelliSenseMode": "gcc-x64",
"includePath": [
"${workspaceFolder}/include",
"${workspaceFolder}/portable/include",
Expand Down Expand Up @@ -30,23 +30,45 @@
},
{
"name": "RP2040",
"intelliSenseMode": "gcc-arm64",
"intelliSenseMode": "gcc-x64",
"includePath": [
"/Applications/ArmGNUToolchain/13.2.Rel1/arm-none-eabi/include",
"${workspaceFolder}/include",
"${workspaceFolder}/portable/include",
"${workspaceFolder}/portable/rp2040/include",
"${workspaceFolder}/portable/pico/include",
"${workspaceFolder}/schemas",
"${workspaceFolder}/3rdparty/FreeRTOS/include",
"${workspaceFolder}/3rdparty/FreeRTOS/portable/ThirdParty/GCC/Posix",
"${workspaceFolder}/3rdparty/FreeRTOS/portable/ThirdParty/GCC/Posix/utils",
"${workspaceFolder}/3rdparty/FreeRTOS/portable/ThirdParty/GCC/RP2040/include",
"${workspaceFolder}/3rdparty/quickjs",
"${workspaceFolder}/3rdparty/llhttp/include",
"${workspaceFolder}/3rdparty/libyuarel",
"${workspaceFolder}/3rdparty/c-capnproto/lib"
],
"cStandard": "c99",
"cppStandard": "c++17",
"browse": {
"path": [
"${workspaceFolder}"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
},
"configurationProvider": "ms-vscode.cpptools"
},
{
"name": "RP2350",
"intelliSenseMode": "gcc-x64",
"includePath": [
"${workspaceFolder}/include",
"${workspaceFolder}/portable/include",
"${workspaceFolder}/portable/pico2/include",
"${workspaceFolder}/schemas",
"${workspaceFolder}/3rdparty/FreeRTOS/include",
"${workspaceFolder}/3rdparty/FreeRTOS/portable/ThirdParty/GCC/RP2350_ARM_NTZ/non_secure",
"${workspaceFolder}/3rdparty/quickjs",
"${workspaceFolder}/3rdparty/llhttp/include",
"${workspaceFolder}/3rdparty/libyuarel",
"${workspaceFolder}/3rdparty/cpputest/include",
"${workspaceFolder}/3rdparty/c-capnproto/lib"
],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c99",
"cppStandard": "c++17",
"browse": {
Expand Down
52 changes: 45 additions & 7 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,15 @@
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/build",
"environment": [],
"environment": [
{
"name": "LD_LIBRARY_PATH",
"value": "${workspaceFolder}/build"
}
],
"externalConsole": false,
"MIMode": "lldb"
"miDebuggerPath": "/usr/bin/gdb",
"MIMode": "gdb",
},
{
"name": "Pico Debug",
Expand All @@ -23,12 +29,9 @@
"request": "launch",
"type": "cortex-debug",
"servertype": "openocd",
// This may need to be "arm-none-eabi-gdb" for some previous builds
// "gdbPath" : "gdb-multiarch",
"gdbPath": "arm-none-eabi-gdb",
"device": "RP2040",
"configFiles": [
// This may need to be "interface/picoprobe.cfg" for some previous builds
"interface/cmsis-dap.cfg",
"target/rp2040.cfg"
],
Expand All @@ -39,7 +42,42 @@
"break main",
"continue"
],
"openOCDLaunchCommands": ["adapter speed 5000"]
"openOCDLaunchCommands": [
"adapter speed 5000"
],
"postLaunchCommands": [
"monitor arm semihosting enable",
"monitor arm semihosting ioclient 2", // 1: telnet (port 2333); 2: gdb; 3: both telnet and gdbclient output
]
},
{
"name": "Pico 2 Debug",
"cwd": "${workspaceRoot}",
"executable": "${workspaceFolder}/build/isere.elf",
"request": "launch",
"type": "cortex-debug",
"servertype": "openocd",
"gdbPath": "arm-none-eabi-gdb",
"device": "RP2350",
"configFiles": [
"interface/cmsis-dap.cfg",
"target/rp2350.cfg"
],
"svdFile": "${workspaceFolder}/3rdparty/pico-sdk/src/rp2350/hardware_regs/RP2350.svd",
"runToEntryPoint": "main",
// Work around for stopping at main on restart
"postRestartCommands": [
"break main",
"continue"
],
"openOCDLaunchCommands": [
"bindto 0.0.0.0",
"adapter speed 5000"
],
"postLaunchCommands": [
"monitor arm semihosting enable",
"monitor arm semihosting ioclient 2", // 1: telnet (port 2333); 2: gdb; 3: both telnet and gdbclient output
]
}
]
}
}
2 changes: 1 addition & 1 deletion 3rdparty/FreeRTOS
Submodule FreeRTOS updated 58 files
+0 −6 README.md
+1 −1 portable/ARMv8M/secure/heap/secure_heap.c
+1 −1 portable/GCC/ARM_CM23/secure/secure_heap.c
+1 −1 portable/GCC/ARM_CM33/secure/secure_heap.c
+1 −1 portable/GCC/ARM_CM35P/secure/secure_heap.c
+1 −1 portable/GCC/ARM_CM55/secure/secure_heap.c
+1 −1 portable/GCC/ARM_CM85/secure/secure_heap.c
+17 −50 portable/GCC/ARM_CRx_No_GIC/port.c
+84 −213 portable/GCC/ARM_CRx_No_GIC/portASM.S
+44 −42 portable/GCC/ARM_CRx_No_GIC/portmacro.h
+1 −1 portable/IAR/ARM_CM23/secure/secure_heap.c
+1 −1 portable/IAR/ARM_CM33/secure/secure_heap.c
+1 −1 portable/IAR/ARM_CM35P/secure/secure_heap.c
+1 −1 portable/IAR/ARM_CM55/secure/secure_heap.c
+1 −1 portable/IAR/ARM_CM85/secure/secure_heap.c
+1 −1 portable/MemMang/heap_1.c
+1 −1 portable/MemMang/heap_2.c
+2 −2 portable/MemMang/heap_4.c
+24 −7 portable/ThirdParty/GCC/Posix/port.c
+57 −27 portable/ThirdParty/GCC/RP2040/FreeRTOS_Kernel_import.cmake
+2 −2 portable/ThirdParty/GCC/RP2040/README.md
+19 −23 portable/ThirdParty/GCC/RP2040/include/portmacro.h
+81 −88 portable/ThirdParty/GCC/RP2040/port.c
+2 −0 portable/ThirdParty/GCC/RP2350_ARM_NTZ/.gitignore
+50 −0 portable/ThirdParty/GCC/RP2350_ARM_NTZ/CMakeLists.txt
+70 −0 portable/ThirdParty/GCC/RP2350_ARM_NTZ/FreeRTOS_Kernel_import.cmake
+23 −0 portable/ThirdParty/GCC/RP2350_ARM_NTZ/LICENSE.md
+67 −0 portable/ThirdParty/GCC/RP2350_ARM_NTZ/README.md
+73 −0 portable/ThirdParty/GCC/RP2350_ARM_NTZ/library.cmake
+77 −0 portable/ThirdParty/GCC/RP2350_ARM_NTZ/non_secure/freertos_sdk_config.h
+2,055 −0 portable/ThirdParty/GCC/RP2350_ARM_NTZ/non_secure/mpu_wrappers_v2_asm.c
+2,743 −0 portable/ThirdParty/GCC/RP2350_ARM_NTZ/non_secure/port.c
+526 −0 portable/ThirdParty/GCC/RP2350_ARM_NTZ/non_secure/portasm.c
+114 −0 portable/ThirdParty/GCC/RP2350_ARM_NTZ/non_secure/portasm.h
+230 −0 portable/ThirdParty/GCC/RP2350_ARM_NTZ/non_secure/portmacro.h
+516 −0 portable/ThirdParty/GCC/RP2350_ARM_NTZ/non_secure/portmacrocommon.h
+96 −0 portable/ThirdParty/GCC/RP2350_ARM_NTZ/non_secure/rp2040_config.h
+66 −0 portable/ThirdParty/GCC/RP2350_ARM_NTZ/pico_sdk_import.cmake
+2 −0 portable/ThirdParty/GCC/RP2350_RISC-V/.gitignore
+50 −0 portable/ThirdParty/GCC/RP2350_RISC-V/CMakeLists.txt
+5 −0 portable/ThirdParty/GCC/RP2350_RISC-V/Documentation.url
+70 −0 portable/ThirdParty/GCC/RP2350_RISC-V/FreeRTOS_Kernel_import.cmake
+23 −0 portable/ThirdParty/GCC/RP2350_RISC-V/LICENSE.md
+65 −0 portable/ThirdParty/GCC/RP2350_RISC-V/README.md
+68 −0 portable/ThirdParty/GCC/RP2350_RISC-V/include/freertos_risc_v_chip_specific_extensions.h
+77 −0 portable/ThirdParty/GCC/RP2350_RISC-V/include/freertos_sdk_config.h
+264 −0 portable/ThirdParty/GCC/RP2350_RISC-V/include/portContext.h
+314 −0 portable/ThirdParty/GCC/RP2350_RISC-V/include/portmacro.h
+96 −0 portable/ThirdParty/GCC/RP2350_RISC-V/include/rp2040_config.h
+74 −0 portable/ThirdParty/GCC/RP2350_RISC-V/library.cmake
+4 −0 portable/ThirdParty/GCC/RP2350_RISC-V/notes.txt
+66 −0 portable/ThirdParty/GCC/RP2350_RISC-V/pico_sdk_import.cmake
+713 −0 portable/ThirdParty/GCC/RP2350_RISC-V/port.c
+461 −0 portable/ThirdParty/GCC/RP2350_RISC-V/portASM.S
+23 −0 portable/ThirdParty/GCC/RP2350_RISC-V/readme.txt
+2 −33 portable/ThirdParty/xClang/XCOREAI/port.c
+6 −3 portable/ThirdParty/xClang/XCOREAI/portasm.S
+2 −2 tasks.c
2 changes: 1 addition & 1 deletion 3rdparty/pico-sdk
Submodule pico-sdk updated 977 files
32 changes: 16 additions & 16 deletions BENCHMARK.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,7 @@ Requests/sec: 85861.04
Transfer/sec: 14.08MB
```

### isère

##### without QuickJS

```
$ wrk -t12 -c400 -d10s http://127.0.0.1:8080
Running 10s test @ http://127.0.0.1:8080
12 threads and 400 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 2.73ms 20.49ms 439.61ms 99.78%
Req/Sec 428.20 429.25 1.60k 80.27%
6367 requests in 10.09s, 118.14KB read
Socket errors: connect 155, read 12230, write 21, timeout 0
Requests/sec: 631.03
Transfer/sec: 11.71KB
```
### isère on Apple M1

##### with QuickJS

Expand All @@ -46,3 +31,18 @@ Running 10s test @ http://127.0.0.1:8080
Requests/sec: 77.85
Transfer/sec: 5.32KB
```

### isère on Raspberry Pi Pico 2

```
$ wrk -t12 -c400 -d10s http://192.168.7.1:8080
Running 10s test @ http://192.168.7.1:8080
12 threads and 400 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 1.19s 239.32ms 1.88s 72.73%
Req/Sec 0.73 0.83 3.00 86.36%
22 requests in 10.08s, 770.00B read
Socket errors: connect 0, read 1321, write 0, timeout 0
Requests/sec: 2.18
Transfer/sec: 76.40B
```
30 changes: 19 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ cmake_minimum_required(VERSION 3.5)

set(TARGET_PLATFORM linux CACHE STRING "Platform to compile isere for")

# build configuration
option(DEBUG "Debug mode" OFF)
option(NEED_LWIP "Include LwIP" OFF)
option(WITH_QUICKJS "Include QuickJS" ON)

# platform-specific configuration
option(WITH_LWIP "Include LwIP" OFF)
option(SUPPORT_DYNLINK "Platform supports Dynamic Linking" OFF)

include(portable/${TARGET_PLATFORM}/platform_features.cmake)
Expand All @@ -17,7 +21,7 @@ set(LWIP_DIR ./3rdparty/lwip)
set(LLHTTP_DIR ./3rdparty/llhttp)
set(LIBYUAREL_DIR ./3rdparty/libyuarel)
set(CAPNPROTO_DIR ./3rdparty/c-capnproto)
set(EXAMPLES_DIR ./examples)
set(JS_DIR ./js)

set(SOURCES )

Expand All @@ -28,7 +32,6 @@ list(APPEND SOURCES
./src/ini.c
./src/js.c
./src/quickjs-libc.c
# ./src/rb.c
./src/polyfills/fetch.c
./src/polyfills/timer.c
./src/polyfills/pvPortRealloc.c
Expand Down Expand Up @@ -63,7 +66,7 @@ list(APPEND SOURCES

include(portable/${TARGET_PLATFORM}/platform_sources.cmake OPTIONAL)

if(NEED_LWIP)
if(WITH_LWIP)
set(LWIP_INCLUDE_DIRS
${LWIP_DIR}/src/include
./portable/${TARGET_PLATFORM}/include
Expand All @@ -84,11 +87,11 @@ endif()

add_custom_command(
OUTPUT handler.c
COMMAND xxd -i ../${EXAMPLES_DIR}/handler.js handler.c
COMMAND xxd -i ../${JS_DIR}/handler.js handler.c
COMMAND sed -i.bak -E "s/[a-z_]+\\[\\]/handler\\[\\]/" handler.c # change code array variable name to "handler"
COMMAND sed -i.bak -E "s/[a-z_]+_len/handler_len/" handler.c # change code length variable name to "handler_len"
COMMENT "Compiling JavaScript files"
MAIN_DEPENDENCY ../${EXAMPLES_DIR}/handler.js
MAIN_DEPENDENCY ../${JS_DIR}/handler.js
VERBATIM
)

Expand All @@ -103,9 +106,14 @@ execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD OUTPUT_VARIABLE
target_compile_definitions(isere PRIVATE _GNU_SOURCE CONFIG_BIGNUM EMSCRIPTEN CONFIG_VERSION="${COMMIT_ID}")

if(DEBUG)
target_compile_options(isere PRIVATE -O0 -g -pg)
target_compile_definitions(isere PRIVATE DUMP_LEAKS)
# target_compile_definitions(isere PRIVATE DUMP_LEAKS DUMP_MEM)
target_compile_options(isere PRIVATE -O0 -g)

# enable profiling on Linux
if(TARGET_PLATFORM STREQUAL "linux")
# target_compile_definitions(isere PRIVATE DUMP_LEAKS DUMP_MEM)
target_compile_options(isere PRIVATE -pg)
target_link_options(isere PRIVATE -pg)
endif()
endif()

include(portable/${TARGET_PLATFORM}/platform_extras.cmake OPTIONAL)
Expand All @@ -122,7 +130,7 @@ target_include_directories(isere PRIVATE
${CAPNPROTO_DIR}/lib
)

if(NEED_LWIP)
if(WITH_LWIP)
target_include_directories(isere PRIVATE
${LWIP_DIR}/src/include
)
Expand All @@ -140,5 +148,5 @@ add_custom_command(
)

if(TARGET_PLATFORM STREQUAL "linux")
include(unittests.cmake)
include(./tests/CMakeLists.txt)
endif()
Loading

0 comments on commit 0c1c41b

Please sign in to comment.