-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
2,206 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Wokwi-CI Build | ||
|
||
on: [push, pull_request] | ||
|
||
# jobs: | ||
# build: | ||
# strategy: | ||
# fail-fast: false | ||
# matrix: | ||
# target: [esp32, esp32s2, esp32s3, esp32c3, esp32h2, esp32c6, esp32p4] | ||
# runs-on: ubuntu-latest | ||
# steps: | ||
# - uses: actions/checkout@v4 | ||
# - uses: espressif/esp-idf-ci-action@v1 | ||
# with: | ||
# esp_idf_version: v5.3 | ||
# target: ${{ matrix.target }} | ||
# - name: Copy diagram ${{ matrix.target }} | ||
# run: | | ||
# cp .github/workflows/wokwi/diagram-${{ matrix.target }}.json diagram.json | ||
# - uses: wokwi/wokwi-ci-action@v1 | ||
# with: | ||
# token: ${{ secrets.WOKWI_CI_TOKEN }} | ||
# timeout: 5000 | ||
# expect_text: 'Hello, world from C3!' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"version": 1, | ||
"author": "Juraj Michálek", | ||
"editor": "wokwi", | ||
"parts": [ { "type": "board-esp32-devkit-c-v4", "id": "esp", "top": 0, "left": 0, "attrs": {} } ], | ||
"connections": [ [ "esp:TX", "$serialMonitor:RX", "", [] ], [ "esp:RX", "$serialMonitor:TX", "", [] ] ], | ||
"dependencies": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"version": 1, | ||
"author": "Juraj Michálek", | ||
"editor": "wokwi", | ||
"parts": [ | ||
{ | ||
"type": "board-esp32-c3-devkitm-1", | ||
"id": "esp", | ||
"top": 0, | ||
"left": 0, | ||
"attrs": { "builder": "esp-idf" } | ||
} | ||
], | ||
"connections": [ [ "esp:TX", "$serialMonitor:RX", "", [] ], [ "esp:RX", "$serialMonitor:TX", "", [] ] ], | ||
"dependencies": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"version": 1, | ||
"author": "Juraj Michálek", | ||
"editor": "wokwi", | ||
"parts": [ | ||
{ | ||
"type": "board-esp32-c6-devkitc-1", | ||
"id": "esp", | ||
"top": 0, | ||
"left": 0, | ||
"attrs": { } | ||
} | ||
], | ||
"connections": [ [ "esp:TX", "$serialMonitor:RX", "", [] ], [ "esp:RX", "$serialMonitor:TX", "", [] ] ], | ||
"dependencies": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"version": 1, | ||
"author": "Juraj Michálek", | ||
"editor": "wokwi", | ||
"parts": [ | ||
{ | ||
"type": "board-esp32-h2-devkitm-1", | ||
"id": "esp", | ||
"top": 0, | ||
"left": 0, | ||
"attrs": { "builder": "esp-idf" } | ||
} | ||
], | ||
"connections": [ [ "esp:TX", "$serialMonitor:RX", "", [] ], [ "esp:RX", "$serialMonitor:TX", "", [] ] ], | ||
"dependencies": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"version": 1, | ||
"author": "Uri Shaked", | ||
"editor": "wokwi", | ||
"parts": [ | ||
{ "type": "board-esp32-p4-preview", "id": "esp", "top": -17.23, "left": -16.04, "attrs": {} } | ||
], | ||
"connections": [ | ||
["esp:TX", "$serialMonitor:RX", "", []], | ||
["esp:RX", "$serialMonitor:TX", "", []] | ||
], | ||
"serialMonitor": { "display": "terminal" }, | ||
"dependencies": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"version": 1, | ||
"author": "Juraj Michálek", | ||
"editor": "wokwi", | ||
"parts": [ { "type": "board-esp32-s2-devkitm-1", "id": "esp", "top": 0, "left": 0, "attrs": {} } ], | ||
"connections": [ [ "esp:TX", "$serialMonitor:RX", "", [] ], [ "esp:RX", "$serialMonitor:TX", "", [] ] ], | ||
"dependencies": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"version": 1, | ||
"author": "Juraj Michálek", | ||
"editor": "wokwi", | ||
"parts": [ { "type": "board-esp32-s3-devkitc-1", "id": "esp", "top": 0, "left": 0, "attrs": { "flashSize":"8"} } ], | ||
"connections": [ [ "esp:TX", "$serialMonitor:RX", "", [] ], [ "esp:RX", "$serialMonitor:TX", "", [] ] ], | ||
"dependencies": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,6 @@ compile_commands.json | |
CTestTestfile.cmake | ||
_deps | ||
CMakeUserPresets.json | ||
build/ | ||
build.sh | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# The following lines of boilerplate have to be in your project's | ||
# CMakeLists in this exact order for cmake to work correctly | ||
cmake_minimum_required(VERSION 3.5) | ||
|
||
include($ENV{IDF_PATH}/tools/cmake/project.cmake) | ||
set(BUILD_PATH ${CMAKE_CURRENT_SOURCE_DIR}) | ||
project(c3-sample-idf) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,19 @@ | ||
# esp32-xtensa-c3 | ||
Testing C3 lang for esp32 target | ||
# esp32-c3lang | ||
|
||
Testing [C3 language](http://www.c3-lang.org/) in esp32 target. | ||
|
||
## Requirments | ||
- [esp-idf](https://github.com/espressif/esp-idf) | ||
- [c3c](https://github.com/c3lang/c3c) forked to [espressif/llvm](https://github.com/espressif/llvm-project) backend | ||
|
||
## Preview | ||
|
||
```bash | ||
# C3 with espressif/llvm 18.1.2 | ||
c3c --version | ||
C3 Compiler Version: 0.6.2 (prerelease) | ||
Installed directory: /home/kassane/.local/bin/ | ||
LLVM version: 18.1.2 | ||
LLVM default target: x86_64-linux-musl | ||
``` | ||
![image](https://github.com/user-attachments/assets/b7160ec9-fdb0-4e1a-aa9b-8c365f56d053) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
set(DEPS pthread driver) | ||
|
||
idf_component_register(SRCS "placeholder.c" | ||
INCLUDE_DIRS "." | ||
PRIV_REQUIRES "${DEPS}" | ||
) | ||
|
||
# Based on zig-esp-idf-sample project | ||
|
||
if(CONFIG_IDF_TARGET_ARCH_RISCV) | ||
set(C3_TARGET "elf-riscv32") # generic | ||
# if(CONFIG_IDF_TARGET_ESP32C6 OR CONFIG_IDF_TARGET_ESP32C5 OR CONFIG_IDF_TARGET_ESP32H2) | ||
# set(TARGET_CPU_MODEL "generic_rv32+m+a+c") | ||
# elseif(CONFIG_IDF_TARGET_ESP32P4) | ||
# string(REGEX REPLACE "-none" "-eabihf" C3_TARGET ${C3_TARGET}) | ||
# set(TARGET_CPU_MODEL "generic_rv32+m+a+c+f") | ||
# else() | ||
# set(TARGET_CPU_MODEL "generic_rv32+m+c") | ||
# endif() | ||
elseif(CONFIG_IDF_TARGET_ARCH_XTENSA) | ||
set(C3_TARGET "elf-xtensa") # generic | ||
# if(CONFIG_IDF_TARGET_ESP32) | ||
# set(TARGET_CPU_MODEL "esp32") | ||
# elseif(CONFIG_IDF_TARGET_ESP32S2) | ||
# set(TARGET_CPU_MODEL "esp32s2") | ||
# else(CONFIG_IDF_TARGET_ESP32S3) | ||
# set(TARGET_CPU_MODEL "esp32s3") | ||
# endif() | ||
else() | ||
message(FATAL_ERROR "Unsupported target ${CONFIG_IDF_TARGET}") | ||
endif() | ||
|
||
if(CMAKE_BUILD_TYPE STREQUAL "Debug") | ||
set(C3_BUILD_TYPE "-g0") | ||
else() | ||
set(C3_BUILD_TYPE "-Oz") | ||
endif() | ||
|
||
add_custom_target(c3_build | ||
COMMAND ${CMAKE_COMMAND} -E env | ||
"INCLUDE_DIRS=${include_dirs}" | ||
c3c | ||
--no-entry | ||
--use-stdlib=no | ||
--link-libc=no | ||
static-lib | ||
-o libc3 | ||
app.c3 | ||
--output-dir ${CMAKE_BINARY_DIR}/lib | ||
${C3_BUILD_TYPE} | ||
--target ${C3_TARGET} | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | ||
BYPRODUCTS ${CMAKE_BINARY_DIR}/lib/libc3.a | ||
VERBATIM) | ||
|
||
add_prebuilt_library(c3 ${CMAKE_BINARY_DIR}/lib/libc3.a) | ||
add_dependencies(c3 c3_build) | ||
target_link_libraries(${COMPONENT_LIB} PRIVATE ${CMAKE_BINARY_DIR}/lib/libc3.a) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
extern fn int printf(char* format, ...); | ||
|
||
fn void app_main() @export("app_main") | ||
{ | ||
printf("Hello World C3 language!\n"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// empty file |
Oops, something went wrong.