-
Notifications
You must be signed in to change notification settings - Fork 622
Summary: Add Initial support to pico2 (Arm Cortex M) #12518
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
psiddh
wants to merge
2
commits into
main
Choose a base branch
from
pico2_poc
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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 @@ | ||
cmake_minimum_required(VERSION 3.10) | ||
project(pico) | ||
|
||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) | ||
set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../) | ||
|
||
|
||
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_SOURCE_DIR}/arm-cortex-m0plus-toolchain.cmake) | ||
|
||
# Only include here, NOT in arm-cortex-m0plus-toolchain.cmake | ||
include(${CMAKE_SOURCE_DIR}/tools/cmake/Codegen.cmake) | ||
|
||
target_sources(executorch_core PRIVATE ${CMAKE_CURRENT_LIST_DIR}/syscall_stubs.c) | ||
gen_selected_ops(LIB_NAME "portable_ops_lib" ROOT_OPS "aten::add.out") |
This file contains hidden or 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,29 @@ | ||
# cortex-m0plus cmake | ||
|
||
if(NOT DEFINED EXECUTORCH_BUILD_ARM_BAREMETAL) | ||
# If not defined, assume we're building standalone | ||
set(EXECUTORCH_BUILD_ARM_BAREMETAL ON) | ||
endif() | ||
set(CMAKE_SYSTEM_NAME Generic) | ||
set(CMAKE_SYSTEM_PROCESSOR cortex-m0plus) | ||
|
||
if(NOT DEFINED CMAKE_C_COMPILER) | ||
set(CMAKE_C_COMPILER arm-none-eabi-gcc CACHE STRING "C compiler") | ||
endif() | ||
|
||
if(NOT DEFINED CMAKE_CXX_COMPILER) | ||
set(CMAKE_CXX_COMPILER arm-none-eabi-g++ CACHE STRING "C++ compiler") | ||
endif() | ||
|
||
set(CPU_FLAGS "-mcpu=cortex-m0plus -mthumb -mfloat-abi=soft") | ||
# C flags (no RTTI or exceptions here, since RTTI is C++-only) | ||
set(CMAKE_C_FLAGS "${CPU_FLAGS} -O2 -ffunction-sections -fdata-sections -fno-exceptions -fno-unwind-tables") | ||
|
||
# C++ flags (RTTI-related flags go here) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -fno-rtti -fno-use-cxa-atexit -ffunction-sections -fdata-sections") | ||
|
||
# Linker flags | ||
# set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections -nostartfiles -flto") | ||
|
||
# Linker flags | ||
set(CMAKE_EXE_LINKER_FLAGS "-nostartfiles") |
This file contains hidden or 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,40 @@ | ||
cmake_minimum_required(VERSION 3.13) | ||
include($ENV{PICO_SDK_PATH}/external/pico_sdk_import.cmake) | ||
project(executorch_pico C CXX ASM) | ||
pico_sdk_init() | ||
|
||
set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../../../) | ||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) | ||
|
||
add_executable(executorch_pico main.cpp simple_addmodule_pte.c) | ||
pico_enable_stdio_usb(executorch_pico 1) | ||
pico_enable_stdio_uart(executorch_pico 0) | ||
|
||
# Set correct flags for Pico (Cortex-M0+) | ||
target_compile_options(executorch_pico PRIVATE | ||
-mcpu=cortex-m0plus | ||
-mfloat-abi=soft | ||
-mthumb | ||
) | ||
|
||
# Link Executorch and Pico libraries | ||
target_link_libraries(executorch_pico | ||
PRIVATE | ||
${EXECUTORCH_ROOT}/executorch/build/libexecutorch.a | ||
${EXECUTORCH_ROOT}/executorch/build/libexecutorch_core.a | ||
-Wl,--whole-archive | ||
${EXECUTORCH_ROOT}/executorch/build/kernels/portable/libportable_ops_lib.a | ||
-Wl,--no-whole-archive | ||
${EXECUTORCH_ROOT}/executorch/build/kernels/portable/libportable_kernels.a | ||
pico_stdlib | ||
pico_stdio_usb | ||
) | ||
|
||
# Include Executorch and third-party headers | ||
target_include_directories(executorch_pico PRIVATE | ||
${EXECUTORCH_ROOT} | ||
${EXECUTORCH_ROOT}/executorch/third-party/ | ||
# Add other include paths as needed | ||
) | ||
|
||
pico_add_extra_outputs(executorch_pico) |
This file contains hidden or 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,129 @@ | ||
#include "pico/stdio_usb.h" | ||
#include "pico/stdlib.h" | ||
|
||
#include <executorch/extension/data_loader/buffer_data_loader.h> | ||
#include <executorch/runtime/core/portable_type/scalar_type.h> | ||
#include <executorch/runtime/executor/method.h> | ||
#include <executorch/runtime/executor/program.h> | ||
#include <executorch/runtime/platform/runtime.h> | ||
|
||
// Declare your model data (from simple_addmodule_pte.c) | ||
extern const uint8_t model_pte[] __attribute__((aligned(8))); | ||
extern const unsigned int model_pte_len; | ||
|
||
// Define GPIO pins for indicators | ||
const uint INDICATOR_PIN_1 = 25; // Onboard LED | ||
const uint INDICATOR_PIN_2 = 22; // External LED | ||
const uint INDICATOR_PIN_3 = 23; // Onboard LED | ||
|
||
static uint8_t method_allocator_pool[1024]; | ||
static uint8_t activation_pool[512]; | ||
|
||
void blink_indicator(uint pin, int times, int delay_ms = 100) { | ||
gpio_init(pin); | ||
gpio_set_dir(pin, GPIO_OUT); | ||
for (int i = 0; i < times; ++i) { | ||
gpio_put(pin, 1); | ||
sleep_ms(delay_ms); | ||
gpio_put(pin, 0); | ||
sleep_ms(delay_ms); | ||
} | ||
} | ||
|
||
int main() { | ||
using namespace executorch::extension; | ||
using namespace executorch::runtime; | ||
using executorch::aten::Tensor; | ||
using executorch::aten::TensorImpl; | ||
using ScalarType = executorch::runtime::etensor::ScalarType; | ||
using executorch::runtime::runtime_init; | ||
|
||
stdio_init_all(); | ||
|
||
// Give host time to enumerate USB serial | ||
sleep_ms(1000); | ||
|
||
int retry_usb_count= 0; | ||
while (!stdio_usb_connected() && retry_usb_count++ < 10) { | ||
printf("Retry again! USB not connected \n"); | ||
sleep_ms(100); // Check every 100 ms | ||
} | ||
runtime_init(); | ||
|
||
executorch::extension::BufferDataLoader loader(model_pte, model_pte_len); | ||
MemoryAllocator method_allocator(sizeof(method_allocator_pool), method_allocator_pool); | ||
method_allocator.enable_profiling("method allocator"); | ||
|
||
Span<uint8_t> memory_planned_buffers[1]{{activation_pool, sizeof(activation_pool)}}; | ||
HierarchicalAllocator planned_memory({memory_planned_buffers, 1}); | ||
|
||
MemoryManager memory_manager(&method_allocator, &planned_memory); | ||
auto program_result = Program::load(&loader); | ||
if (!program_result.ok()) { | ||
printf("Failed to load model: %d\n", (int)program_result.error()); | ||
blink_indicator(INDICATOR_PIN_1, 10); | ||
return 1; | ||
} | ||
Program program = std::move(*program_result); | ||
|
||
const char* method_name = nullptr; | ||
// Get method name (usually "forward") | ||
auto method_name_result = program.get_method_name(0); | ||
if (!method_name_result.ok()) { | ||
printf("Failed to get method name: %d\n", (int)method_name_result.error()); | ||
blink_indicator(INDICATOR_PIN_1, 10); | ||
return 1; | ||
} | ||
|
||
method_name = *method_name_result; | ||
// Load method | ||
auto method_result = program.load_method(method_name, &memory_manager); | ||
if (!method_result.ok()) { | ||
printf("Failed to load method: %d\n", (int)method_result.error()); | ||
blink_indicator(INDICATOR_PIN_1, 10); | ||
return 1; | ||
} | ||
printf("Method loaded [%s]\n", method_name); | ||
|
||
auto method = std::move(*method_result); | ||
// Prepare input tensor | ||
float input_data_0[4] = {4.0, 109.0, 13.0, 123.0}; | ||
float input_data_1[4] = {9.0, 27.0, 11.0, 8.0}; | ||
TensorImpl::SizesType sizes[1] = {4}; | ||
TensorImpl::DimOrderType dim_order[] = {0}; | ||
TensorImpl impl0(ScalarType::Float, 1, sizes, input_data_0, dim_order); | ||
TensorImpl impl1(ScalarType::Float, 1, sizes, input_data_1, dim_order); | ||
Tensor input0(&impl0); | ||
Tensor input1(&impl1); | ||
|
||
// Set input | ||
auto set_input_error0 = method.set_input(input0, 0); | ||
auto set_input_error1 = method.set_input(input1, 1); | ||
if (set_input_error0 != Error::Ok || set_input_error1 != Error::Ok) { | ||
printf("Failed to set input(s)\n"); | ||
blink_indicator(INDICATOR_PIN_1, 10); | ||
return 1; | ||
} | ||
|
||
// Run inference | ||
auto exec_error = method.execute(); | ||
if (exec_error != Error::Ok) { | ||
printf("Failed to execute: %d\n", (int)exec_error); | ||
blink_indicator(INDICATOR_PIN_1, 10); | ||
return 1; | ||
} | ||
|
||
// Get output | ||
const EValue& output = method.get_output(0); | ||
if (output.isTensor()) { | ||
const auto& out_tensor = output.toTensor(); | ||
const float* out_data = out_tensor.const_data_ptr<float>(); | ||
printf("Output: %f, %f, %f, %f\n", out_data[0], out_data[1], out_data[2], out_data[3]); | ||
} else { | ||
printf("Output is not a tensor!\n"); | ||
blink_indicator(INDICATOR_PIN_1, 10); | ||
} | ||
|
||
blink_indicator(INDICATOR_PIN_1, 100, 500); // Blink onboard LED 10 times (~10 secs) to indicate success | ||
return 0; | ||
} |
This file contains hidden or 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,38 @@ | ||
__attribute__((aligned(8))) const unsigned char model_pte[] = { | ||
0x1c, 0x00, 0x00, 0x00, 0x45, 0x54, 0x31, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x18, 0x00, 0x00, 0x00, 0x04, 0x00, 0x08, 0x00, 0x0c, 0x00, 0x10, 0x00, 0x14, 0x00, 0x10, 0x00, 0x00, 0x00, | ||
0x44, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0c, 0xff, 0xff, 0xff, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, | ||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x28, 0x00, 0x04, 0x00, 0x08, 0x00, 0x0c, 0x00, 0x10, 0x00, 0x14, 0x00, 0x18, 0x00, 0x1c, 0x00, | ||
0x20, 0x00, 0x24, 0x00, 0x16, 0x00, 0x00, 0x00, 0x9c, 0x03, 0x00, 0x00, 0x10, 0x02, 0x00, 0x00, 0xdc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, | ||
0x24, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x38, 0xfe, 0xff, 0xff, 0x10, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x6f, 0x75, 0x74, 0x00, | ||
0x09, 0x00, 0x00, 0x00, 0x61, 0x74, 0x65, 0x6e, 0x3a, 0x3a, 0x61, 0x64, 0x64, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, 0x04, 0x00, | ||
0x08, 0x00, 0x0c, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x24, 0xff, 0xff, 0xff, | ||
0x00, 0x00, 0x00, 0x01, 0x0c, 0x00, 0x00, 0x00, 0x08, 0x00, 0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, | ||
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xd4, 0x00, 0x00, 0x00, 0x8c, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, | ||
0x44, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x02, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
0x00, 0x00, 0x00, 0x00, 0x68, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x05, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x16, 0x00, 0x07, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0c, 0x00, 0x00, 0x00, | ||
0x00, 0x00, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x24, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x08, 0x00, 0x04, 0x00, | ||
0x06, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0c, 0x00, 0x07, 0x00, 0x08, 0x00, | ||
0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x04, 0x00, 0x00, 0x00, 0xba, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x06, 0x20, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, | ||
0x8c, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0e, 0x00, | ||
0x07, 0x00, 0x08, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x14, 0x00, 0x07, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0c, 0x00, 0x00, 0x00, | ||
0x00, 0x00, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x20, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xe4, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, | ||
0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0c, 0x00, 0x04, 0x00, 0x08, 0x00, 0x08, 0x00, 0x00, 0x00, | ||
0x48, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x39, 0x00, 0x00, 0x00, 0x5b, 0x31, 0x2c, 0x20, 0x7b, 0x22, 0x74, 0x79, 0x70, 0x65, 0x22, 0x3a, 0x20, 0x6e, 0x75, 0x6c, 0x6c, 0x2c, 0x20, 0x22, | ||
0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x22, 0x3a, 0x20, 0x6e, 0x75, 0x6c, 0x6c, 0x2c, 0x20, 0x22, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x72, 0x65, 0x6e, 0x5f, 0x73, 0x70, 0x65, 0x63, 0x22, 0x3a, | ||
0x20, 0x5b, 0x5d, 0x7d, 0x5d, 0x00, 0x00, 0x00, 0x34, 0x01, 0x00, 0x00, 0x5b, 0x31, 0x2c, 0x20, 0x7b, 0x22, 0x74, 0x79, 0x70, 0x65, 0x22, 0x3a, 0x20, 0x22, 0x62, 0x75, 0x69, 0x6c, 0x74, 0x69, | ||
0x6e, 0x73, 0x2e, 0x74, 0x75, 0x70, 0x6c, 0x65, 0x22, 0x2c, 0x20, 0x22, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x22, 0x3a, 0x20, 0x22, 0x6e, 0x75, 0x6c, 0x6c, 0x22, 0x2c, 0x20, 0x22, 0x63, | ||
0x68, 0x69, 0x6c, 0x64, 0x72, 0x65, 0x6e, 0x5f, 0x73, 0x70, 0x65, 0x63, 0x22, 0x3a, 0x20, 0x5b, 0x7b, 0x22, 0x74, 0x79, 0x70, 0x65, 0x22, 0x3a, 0x20, 0x22, 0x62, 0x75, 0x69, 0x6c, 0x74, 0x69, | ||
0x6e, 0x73, 0x2e, 0x74, 0x75, 0x70, 0x6c, 0x65, 0x22, 0x2c, 0x20, 0x22, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x22, 0x3a, 0x20, 0x22, 0x6e, 0x75, 0x6c, 0x6c, 0x22, 0x2c, 0x20, 0x22, 0x63, | ||
0x68, 0x69, 0x6c, 0x64, 0x72, 0x65, 0x6e, 0x5f, 0x73, 0x70, 0x65, 0x63, 0x22, 0x3a, 0x20, 0x5b, 0x7b, 0x22, 0x74, 0x79, 0x70, 0x65, 0x22, 0x3a, 0x20, 0x6e, 0x75, 0x6c, 0x6c, 0x2c, 0x20, 0x22, | ||
0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x22, 0x3a, 0x20, 0x6e, 0x75, 0x6c, 0x6c, 0x2c, 0x20, 0x22, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x72, 0x65, 0x6e, 0x5f, 0x73, 0x70, 0x65, 0x63, 0x22, 0x3a, | ||
0x20, 0x5b, 0x5d, 0x7d, 0x2c, 0x20, 0x7b, 0x22, 0x74, 0x79, 0x70, 0x65, 0x22, 0x3a, 0x20, 0x6e, 0x75, 0x6c, 0x6c, 0x2c, 0x20, 0x22, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x22, 0x3a, 0x20, | ||
0x6e, 0x75, 0x6c, 0x6c, 0x2c, 0x20, 0x22, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x72, 0x65, 0x6e, 0x5f, 0x73, 0x70, 0x65, 0x63, 0x22, 0x3a, 0x20, 0x5b, 0x5d, 0x7d, 0x5d, 0x7d, 0x2c, 0x20, 0x7b, 0x22, | ||
0x74, 0x79, 0x70, 0x65, 0x22, 0x3a, 0x20, 0x22, 0x62, 0x75, 0x69, 0x6c, 0x74, 0x69, 0x6e, 0x73, 0x2e, 0x64, 0x69, 0x63, 0x74, 0x22, 0x2c, 0x20, 0x22, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, | ||
0x22, 0x3a, 0x20, 0x22, 0x5b, 0x5d, 0x22, 0x2c, 0x20, 0x22, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x72, 0x65, 0x6e, 0x5f, 0x73, 0x70, 0x65, 0x63, 0x22, 0x3a, 0x20, 0x5b, 0x5d, 0x7d, 0x5d, 0x7d, 0x5d, | ||
0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x66, 0x6f, 0x72, 0x77, 0x61, 0x72, 0x64, 0x00, }; | ||
|
||
|
||
const unsigned int model_pte_len = sizeof(model_pte); |
This file contains hidden or 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,33 @@ | ||
#include <sys/types.h> | ||
#include <sys/stat.h> | ||
#include <unistd.h> | ||
|
||
/* | ||
* We are adding a custom syscall_stubs.c file to provide dummy implementations for syscalls that are not | ||
* available on the Pico platform. This is necessary because the Pico does not have an operating system, | ||
* and therefore does not support standard C library functions like _exit, _sbrk, _read, etc. | ||
* By adding these stubs, we can resolve linker errors that occur when building our project for the Pico. | ||
* The stubs will be compiled and linked into our final executable, allowing it to run on the target hardware. | ||
*/ | ||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
void *__dso_handle = 0; | ||
int fnmatch(const char *pattern, const char *string, int flags) { return 1; } | ||
ssize_t pread(int fd, void *buf, size_t count, off_t offset) { return -1; } | ||
void _fini(void) {} | ||
void _exit(int status) { while (1) {} } | ||
void* _sbrk(ptrdiff_t incr) { return (void*)-1; } | ||
int _read(int file, char *ptr, int len) { return -1; } | ||
int _write(int file, char *ptr, int len) { return -1; } | ||
int _close(int file) { return -1; } | ||
int _fstat(int file, void *st) { return 0; } | ||
int _lseek(int file, int ptr, int dir) { return 0; } | ||
int _isatty(int file) { return 1; } | ||
int _kill(int pid, int sig) { return -1; } | ||
int _getpid(void) { return 1; } | ||
int _open(const char *name, int flags, int mode) { return -1; } | ||
int _gettimeofday(void *tv, void *tz) { return -1; } | ||
#ifdef __cplusplus | ||
} | ||
#endif |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All files in this repo seem to more fit in https://github.com/pytorch/executorch/tree/main/examples/arm