diff --git a/CMakeLists.txt b/CMakeLists.txt
index 85def50..0adf96b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -17,66 +17,86 @@
cmake_minimum_required(VERSION 3.16)
-if(ESP_PLATFORM)
-set(EXTRA_COMPONENT_DIRS src)
-include($ENV{IDF_PATH}/tools/cmake/project.cmake)
-set(USB_ITF_CCID 1)
-#set(USB_ITF_HID 1)
-include(pico_keys_sdk_import.cmake)
-project(pico_keys_sdk)
+ if(ESP_PLATFORM)
+ set(EXTRA_COMPONENT_DIRS src)
+ include($ENV{IDF_PATH}/tools/cmake/project.cmake)
else()
+ if(NOT ENABLE_EMULATION)
+ set(PICO_USE_FASTEST_SUPPORTED_CLOCK 1)
+ include(pico_sdk_import.cmake)
+ endif()
- if(ENABLE_EMULATION)
- else()
- include(pico_sdk_import.cmake)
- endif()
+ project(picokey C CXX ASM)
- project(pico_keys C CXX ASM)
+ set(CMAKE_C_STANDARD 11)
+ set(CMAKE_CXX_STANDARD 17)
- set(CMAKE_C_STANDARD 11)
- set(CMAKE_CXX_STANDARD 17)
+ if(NOT DEFINED __FOR_CI)
+ set(__FOR_CI 0)
+ endif()
+ if(__FOR_CI)
+ add_definitions(-D__FOR_CI)
+ endif()
- if(ENABLE_EMULATION)
- else()
- pico_sdk_init()
- endif()
-
- if (NOT DEFINED __FOR_CI)
- set(__FOR_CI 0)
- endif()
- if (__FOR_CI)
- add_definitions(-D__FOR_CI)
- endif()
+ add_executable(picokey)
+endif()
set(USB_ITF_CCID 1)
-set(USB_ITF_HID 1)
+set(USB_ITF_WCID 1)
+include(cmake/version.cmake)
include(pico_keys_sdk_import.cmake)
-
-add_executable(pico_keys_sdk_exe)
-
-target_compile_options(pico_keys_sdk_exe PUBLIC
- -Wall
- -Werror
+if(NOT ESP_PLATFORM)
+ set(SOURCES ${PICO_KEYS_SOURCES})
+endif()
+set(SOURCES ${SOURCES}
+ ${CMAKE_CURRENT_LIST_DIR}/src/fs/files.c
+ ${CMAKE_CURRENT_LIST_DIR}/src/version.c
)
-if(ENABLE_EMULATION)
-target_compile_options(pico_keys_sdk_exe PUBLIC
- -fdata-sections
- -ffunction-sections
- )
-if(APPLE)
-target_link_options(pico_keys_sdk_exe PUBLIC
- -Wl,-dead_strip
- )
-else()
-target_link_options(pico_keys_sdk_exe PUBLIC
- -Wl,--gc-sections
- )
-endif (APPLE)
-else()
-pico_add_extra_outputs(pico_keys_sdk_exe)
+SET_VERSION(ver_major ver_minor "${CMAKE_CURRENT_LIST_DIR}/src/pico_keys_version.h" 2)
-target_link_libraries(pico_keys_sdk_exe PRIVATE pico_keys_sdk pico_stdlib pico_multicore hardware_flash hardware_sync hardware_adc pico_unique_id hardware_rtc tinyusb_device tinyusb_board)
+if(ESP_PLATFORM)
+ project(picokey)
endif()
+if(NOT ESP_PLATFORM)
+ target_sources(picokey PUBLIC ${SOURCES})
+ target_include_directories(picokey PUBLIC ${INCLUDES})
+
+ target_compile_options(picokey PUBLIC
+ -Wall
+ )
+ if(NOT MSVC)
+ target_compile_options(picokey PUBLIC
+ -Werror
+ )
+ endif()
+
+ if(ENABLE_EMULATION)
+ if(NOT MSVC)
+ target_compile_options(picokey PUBLIC
+ -fdata-sections
+ -ffunction-sections
+ )
+ endif()
+ if(APPLE)
+ target_link_options(picokey PUBLIC
+ -Wl,-dead_strip
+ )
+ elseif(MSVC)
+ target_compile_options(picokey PUBLIC
+ -WX
+ )
+
+ target_link_libraries(picokey PUBLIC wsock32 ws2_32 Bcrypt)
+ else()
+ target_link_options(picokey PUBLIC
+ -Wl,--gc-sections
+ )
+ endif(APPLE)
+ target_link_libraries(picokey PRIVATE pthread m)
+ else()
+ pico_add_extra_outputs(${CMAKE_PROJECT_NAME})
+ endif()
endif()
+
diff --git a/pico_keys_sdk_import.cmake b/pico_keys_sdk_import.cmake
index fc6ea6b..346febf 100644
--- a/pico_keys_sdk_import.cmake
+++ b/pico_keys_sdk_import.cmake
@@ -15,7 +15,7 @@
# along with this program. If not, see .
#
-include(pico-keys-sdk/cmake/version.cmake)
+include(pico-keys-sdk/cmake/version.cmake OPTIONAL)
option(VIDPID "Set specific VID/PID from a known platform {NitroHSM, NitroFIDO2, NitroStart, NitroPro, Nitro3, Yubikey5, YubikeyNeo, YubiHSM, Gnuk, GnuPG}" "None")
diff --git a/src/fs/files.c b/src/fs/files.c
new file mode 100644
index 0000000..7608e02
--- /dev/null
+++ b/src/fs/files.c
@@ -0,0 +1,28 @@
+/*
+ * This file is part of the Pico Keys SDK distribution (https://github.com/polhenarejos/pico-keys-sdk).
+ * Copyright (c) 2022 Pol Henarejos.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+#include "file.h"
+
+file_t file_entries[] = {
+ /* 0 */ { .fid = 0x3f00, .parent = 0xff, .name = NULL, .type = FILE_TYPE_DF, .data = NULL,
+ .ef_structure = 0, .acl = { 0 } }, // MF
+ /* 1 */ { .fid = 0x0000, .parent = 0xff, .name = NULL, .type = FILE_TYPE_NOT_KNOWN, .data = NULL,
+ .ef_structure = 0, .acl = { 0 } } //end
+};
+
+const file_t *MF = &file_entries[0];
+const file_t *file_last = &file_entries[sizeof(file_entries) / sizeof(file_t) - 1];
diff --git a/src/version.c b/src/version.c
new file mode 100644
index 0000000..369ddb2
--- /dev/null
+++ b/src/version.c
@@ -0,0 +1,23 @@
+/*
+ * This file is part of the Pico Keys SDK distribution (https://github.com/polhenarejos/pico-keys-sdk).
+ * Copyright (c) 2022 Pol Henarejos.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+#include "pico_keys.h"
+#include "pico_keys_version.h"
+
+const uint8_t PICO_PRODUCT = 0;
+const uint8_t PICO_VERSION_MAJOR = PICO_KEYS_SDK_VERSION_MAJOR;
+const uint8_t PICO_VERSION_MINOR = PICO_KEYS_SDK_VERSION_MINOR;