Skip to content

Commit

Permalink
Support for PC platform (#12)
Browse files Browse the repository at this point in the history
* improvements for cross-platform compiling

* moved tactility-core to libs/

* splitup improvements

* remove git/gitmodules from freertos

* better platformbetter platform checks

* added build scripts

* delete mbedtls

* re-add mbedtls

* fixes and improvements

* added pc build

* simplify build scripts

* revert build scrpit

* updated builds

* fix for pc

* fix for pc

* fix for build
  • Loading branch information
KenVanHoeylandt authored Jan 19, 2024
1 parent c830c66 commit a94baf0
Show file tree
Hide file tree
Showing 2,359 changed files with 674,656 additions and 137 deletions.
File renamed without changes.
16 changes: 16 additions & 0 deletions .github/workflows/pc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Build
on: [push]
jobs:
Build-PC:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2
with:
submodules: recursive
- name: Configure Project
uses: threeal/[email protected]
- name: Prepare Project
run: cmake -S ./ -B build
- name: Build Project
run: cmake --build build
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.DS_Store

build/
build-sim/
cmake-build-debug/
cmake-build-release/
CMakeCache.txt
Expand Down
37 changes: 26 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,35 @@ cmake_minimum_required(VERSION 3.16)

add_definitions(-DTT_DEBUG)

set(COMPONENTS main)
set(EXTRA_COMPONENT_DIRS "boards" "components")
if (DEFINED ENV{ESP_IDF_VERSION})
message("Building with ESP-IDF v$ENV{ESP_IDF_VERSION}")

# Yellow Board only runs on ESP32
if(NOT "${IDF_TARGET}" STREQUAL "esp32")
set(EXCLUDE_COMPONENTS "yellow_board_2432s024")
endif()
include($ENV{IDF_PATH}/tools/cmake/project.cmake)

add_definitions(-DESP_TARGET)
set(COMPONENTS app-esp tactility tactility-data)
set(EXTRA_COMPONENT_DIRS "boards" "components" "app-esp")

# Yellow Board only runs on ESP32
if(NOT "${IDF_TARGET}" STREQUAL "esp32")
set(EXCLUDE_COMPONENTS "yellow_board_2432s024")
endif()

# T-Deck is an S3 platform
if(NOT "${IDF_TARGET}" STREQUAL "esp32s3")
set(EXCLUDE_COMPONENTS "lilygo_tdeck")
# T-Deck is an S3 platform
if(NOT "${IDF_TARGET}" STREQUAL "esp32s3")
set(EXCLUDE_COMPONENTS "lilygo_tdeck")
endif()
else()
message("Building for sim target")
endif()

include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(Tactility)
project(tactility-root)

add_subdirectory(libs/mlib)
add_subdirectory(tactility-core)

if (NOT IDF_TARGET)
add_subdirectory(libs/freertos-kernel)
add_subdirectory(libs/mbedtls)
add_subdirectory(app-sim)
endif()
28 changes: 18 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,28 @@ Other configurations can be supported, but they require you to set up the driver

## Guide

Until there is proper documentation, here are some pointers:
- Sample application: [bootstrap](main/src/main.c) and [app](main/src/hello_world/hello_world.c)
- [Tactility](./components/tactility): The main platform with default services and apps.
- [Tactility Core](./components/tactility-core): The core platform code.
### Build environment setup

Ensure you have [esp-idf 5.1.2](https://docs.espressif.com/projects/esp-idf/en/v5.1.2/esp32/get-started/index.html) installed, then select the correct device:

Copy the `sdkconfig.board.YOUR_BOARD` into `sdkconfig`. Use `sdkconfig.defaults` if you are setting up a custom board.

## Building Firmware
### Building firmware

First we have to select the correct device:
You can run `idf.py flash monitor`, but there are some helpers available too:

1. If you use CLion, close it and delete the `cmake-build-debug` folder.
2. Run `idf.py fullclean` to remove any cache from previous builds (or delete `build` folder manually)
3. Copy the `sdkconfig.board.YOUR_BOARD` into `sdkconfig`. Use `sdkconfig.defaults` if you are setting up a custom board.
`./build.sh` - build the ESP-IDF or the PC version of Tactility (*)
`./build.sh -p /dev/ttyACM0` - optional: you can pass on extra parameters for esp-idf builds
`./run.sh` - Does `flash` and `monitor` for ESP-IDF and simply builds and starts it for PC

Now you can run `idf.py flash monitor`
The build scripts will detect if ESP-IDF is available. They will adapter if you ran `${IDF_PATH}/export.sh`.

### Development

Until there is proper documentation, here are some pointers:
- Sample application: [bootstrap](app-esp/src/main.c) and [app](app-esp/src/hello_world/hello_world.c)
- [Tactility](./components/tactility): The main platform with default services and apps.
- [Tactility Core](./tactility-core): The core platform code.

## License

Expand Down
19 changes: 19 additions & 0 deletions app-esp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
cmake_minimum_required(VERSION 3.16)

set(BOARD_COMPONENTS tactility)

if("${IDF_TARGET}" STREQUAL "esp32")
list(APPEND BOARD_COMPONENTS yellow_board)
endif()

# T-Deck is an S3 platform
if("${IDF_TARGET}" STREQUAL "esp32s3")
list(APPEND BOARD_COMPONENTS lilygo_tdeck)
endif()

idf_component_register(
SRC_DIRS "src"
"src/hello_world"
REQUIRES ${BOARD_COMPONENTS}
)

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions app-sim/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 3.16)

file(GLOB SOURCES "src/*.c")
add_executable(app-sim ${SOURCES})
target_link_libraries(app-sim PRIVATE tactility-core)
target_link_libraries(app-sim PRIVATE freertos-kernel)

42 changes: 42 additions & 0 deletions app-sim/src/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#include "log.h"

#include "FreeRTOS.h"
#include "task.h"
#include "portmacro.h"


void vAssertCalled( unsigned long ulLine, const char * const pcFileName )
{
static portBASE_TYPE xPrinted = pdFALSE;
volatile uint32_t ulSetToNonZeroInDebuggerToContinue = 0;

/* Parameters are not used. */
( void ) ulLine;
( void ) pcFileName;

taskENTER_CRITICAL();
{
/* You can step out of this function to debug the assertion by using
the debugger to set ulSetToNonZeroInDebuggerToContinue to a non-zero
value. */
while( ulSetToNonZeroInDebuggerToContinue == 0 )
{
}
}
taskEXIT_CRITICAL();
}

int main() {
// static const Config config = {
// .hardware = NULL,
// .apps = {
// &hello_world_app
// },
// .services = { },
// .auto_start_app_id = NULL
// };
//
// tactility_start(&config);
TT_LOG_I("app", "Hello, world!");
return 0;
}
8 changes: 8 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh
if [[ -v ESP_IDF_VERSION ]]; then
idf.py build
else
cmake -S ./ -B build-sim
cmake --build build-sim
fi

5 changes: 5 additions & 0 deletions clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh
rm -rf build
rm -rf build-sim
rm -rf cmake-*

8 changes: 0 additions & 8 deletions components/tactility-core/CMakeLists.txt

This file was deleted.

8 changes: 0 additions & 8 deletions components/tactility-core/README.md

This file was deleted.

9 changes: 9 additions & 0 deletions components/tactility-data/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
idf_component_register(
REQUIRES spiffs
)

set(ASSETS_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/assets")
spiffs_create_partition_image(assets ${ASSETS_SRC_DIR} FLASH_IN_PROJECT)

set(CONFIG_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/config")
spiffs_create_partition_image(config ${CONFIG_SRC_DIR} FLASH_IN_PROJECT)
File renamed without changes.
8 changes: 1 addition & 7 deletions components/tactility/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,8 @@ idf_component_register(
esp_wifi
driver
fatfs
tactility-core
nvs_flash
spiffs
)

set(ASSETS_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/assets")
spiffs_create_partition_image(assets ${ASSETS_SRC_DIR} FLASH_IN_PROJECT)

set(CONFIG_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/config")
spiffs_create_partition_image(config ${CONFIG_SRC_DIR} FLASH_IN_PROJECT)

target_link_libraries(${COMPONENT_LIB} ${IDF_TARGET_NAME} tactility-core)
2 changes: 1 addition & 1 deletion components/tactility/src/graphics.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Lvgl tt_graphics_init(Hardware _Nonnull* hardware) {
DisplayDevice _Nonnull* display = hardware->display;

// Add display
ESP_LOGD(TAG, "lvgl add display");
TT_LOG_I(TAG, "lvgl add display");
const lvgl_port_display_cfg_t disp_cfg = {
.io_handle = display->io_handle,
.panel_handle = display->display_handle,
Expand Down
5 changes: 4 additions & 1 deletion components/tactility/src/services/wifi/wifi.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
extern "C" {
#endif

#include "esp_wifi.h"
#include "pubsub.h"
#include <stdbool.h>
#include <stdio.h>

#ifdef ESP_PLATFORM
#include "esp_wifi.h"
#endif

typedef enum {
/** Radio was turned on */
WifiEventTypeRadioStateOn,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#ifdef ESP_PLATFORM

#include "wifi_credentials.h"

#include "nvs_flash.h"
Expand Down Expand Up @@ -235,3 +237,4 @@ bool tt_wifi_credentials_remove(const char* ssid) {

// end region Wi-Fi Credentials - public

#endif
37 changes: 37 additions & 0 deletions components/tactility/src/services/wifi/wifi_credentials_mock.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#ifndef ESP_PLATFORM

#include "wifi_credentials.h"

#include "log.h"

#define TAG "wifi_credentials"

// region Wi-Fi Credentials - public

bool tt_wifi_credentials_contains(const char* ssid) {
// TODO: Implement
return false;
}

void tt_wifi_credentials_init() {
TT_LOG_W(TAG, "init mock implementation");
}

bool tt_wifi_credentials_get(const char* ssid, char password[TT_WIFI_CREDENTIALS_PASSWORD_LIMIT]) {
// TODO: Implement
return false;
}

bool tt_wifi_credentials_set(const char* ssid, char password[TT_WIFI_CREDENTIALS_PASSWORD_LIMIT]) {
// TODO: Implement
return false;
}

bool tt_wifi_credentials_remove(const char* ssid) {
// TODO: Implement
return false;
}

// end region Wi-Fi Credentials - public

#endif
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#ifdef ESP_PLATFORM

#include "wifi.h"

#include "check.h"
Expand Down Expand Up @@ -227,16 +229,16 @@ static void wifi_publish_event_simple(Wifi* wifi, WifiEventType type) {
static void event_handler(void* arg, esp_event_base_t event_base, int32_t event_id, void* event_data) {
UNUSED(arg);
if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_START) {
ESP_LOGI(TAG, "event_handler: sta start");
TT_LOG_I(TAG, "event_handler: sta start");
if (wifi_singleton->radio_state == WIFI_RADIO_CONNECTION_PENDING) {
esp_wifi_connect();
}
} else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED) {
xEventGroupSetBits(wifi_singleton->event_group, WIFI_FAIL_BIT);
ESP_LOGI(TAG, "event_handler: disconnected");
TT_LOG_I(TAG, "event_handler: disconnected");
} else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP) {
ip_event_got_ip_t* event = (ip_event_got_ip_t*)event_data;
ESP_LOGI(TAG, "event_handler: got ip:" IPSTR, IP2STR(&event->ip_info.ip));
TT_LOG_I(TAG, "event_handler: got ip:" IPSTR, IP2STR(&event->ip_info.ip));
xEventGroupSetBits(wifi_singleton->event_group, WIFI_CONNECTED_BIT);
}
}
Expand Down Expand Up @@ -465,15 +467,15 @@ static void wifi_connect_internal(Wifi* wifi, WifiConnectMessage* connect_messag
if (bits & WIFI_CONNECTED_BIT) {
wifi->radio_state = WIFI_RADIO_CONNECTION_ACTIVE;
wifi_publish_event_simple(wifi, WifiEventTypeConnectionSuccess);
ESP_LOGI(TAG, "Connected to %s", connect_message->ssid);
TT_LOG_I(TAG, "Connected to %s", connect_message->ssid);
} else if (bits & WIFI_FAIL_BIT) {
wifi->radio_state = WIFI_RADIO_ON;
wifi_publish_event_simple(wifi, WifiEventTypeConnectionFailed);
ESP_LOGI(TAG, "Failed to connect to %s", connect_message->ssid);
TT_LOG_I(TAG, "Failed to connect to %s", connect_message->ssid);
} else {
wifi->radio_state = WIFI_RADIO_ON;
wifi_publish_event_simple(wifi, WifiEventTypeConnectionFailed);
ESP_LOGE(TAG, "UNEXPECTED EVENT");
TT_LOG_E(TAG, "UNEXPECTED EVENT");
}
}

Expand Down Expand Up @@ -590,3 +592,5 @@ const ServiceManifest wifi_service = {
.on_start = &wifi_service_start,
.on_stop = &wifi_service_stop
};

#endif
Loading

0 comments on commit a94baf0

Please sign in to comment.