mirror of
https://github.com/polhenarejos/pico-keys-sdk
synced 2026-05-29 17:41:24 +02:00
Now it builds the image.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
@@ -86,6 +86,8 @@ endif(USB_ITF_CCID)
|
|||||||
add_definitions(-DDEBUG_APDU=${DEBUG_APDU})
|
add_definitions(-DDEBUG_APDU=${DEBUG_APDU})
|
||||||
if (NOT ESP_PLATFORM)
|
if (NOT ESP_PLATFORM)
|
||||||
add_definitions(-DMBEDTLS_CONFIG_FILE="${CMAKE_CURRENT_LIST_DIR}/config/mbedtls_config.h")
|
add_definitions(-DMBEDTLS_CONFIG_FILE="${CMAKE_CURRENT_LIST_DIR}/config/mbedtls_config.h")
|
||||||
|
else()
|
||||||
|
add_definitions(-DCFG_TUSB_CONFIG_FILE="../../src/usb/tusb_config.h")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
message(STATUS "USB VID/PID: ${USB_VID}:${USB_PID}")
|
message(STATUS "USB VID/PID: ${USB_VID}:${USB_PID}")
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
# This file was generated using idf.py save-defconfig. It can be edited manually.
|
# This file was generated using idf.py save-defconfig. It can be edited manually.
|
||||||
# Espressif IoT Development Framework (ESP-IDF) Project Minimal Configuration
|
# Espressif IoT Development Framework (ESP-IDF) Project Minimal Configuration
|
||||||
#
|
#
|
||||||
|
IGNORE_UNKNOWN_FILES_FOR_MANAGED_COMPONENTS=1
|
||||||
|
|
||||||
CONFIG_TINYUSB=y
|
CONFIG_TINYUSB=y
|
||||||
CONFIG_TINYUSB_MSC_ENABLED=y
|
|
||||||
|
|
||||||
CONFIG_PARTITION_TABLE_CUSTOM=y
|
CONFIG_PARTITION_TABLE_CUSTOM=y
|
||||||
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv"
|
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv"
|
||||||
@@ -11,6 +12,9 @@ CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
|
|||||||
CONFIG_WL_SECTOR_SIZE_512=y
|
CONFIG_WL_SECTOR_SIZE_512=y
|
||||||
CONFIG_WL_SECTOR_MODE_PERF=y
|
CONFIG_WL_SECTOR_MODE_PERF=y
|
||||||
|
|
||||||
CONFIG_TINYUSB_CDC_ENABLED=y
|
CONFIG_TINYUSB_VENDOR_ENABLED=y
|
||||||
|
CONFIG_TINYUSB_VENDOR_COUNT=2
|
||||||
|
CONFIG_TINYUSB_HID_ENABLED=y
|
||||||
|
CONFIG_TINYUSB_HID_COUNT=2
|
||||||
# CONFIG_TINYUSB_DESC_USE_DEFAULT_PID is not set
|
# CONFIG_TINYUSB_DESC_USE_DEFAULT_PID is not set
|
||||||
CONFIG_TINYUSB_DESC_CUSTOM_PID=0x4001
|
CONFIG_TINYUSB_DESC_CUSTOM_PID=0x4001
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
idf_component_register(
|
idf_component_register(
|
||||||
SRCS ${INTERNAL_SOURCES}
|
SRCS ${INTERNAL_SOURCES}
|
||||||
INCLUDE_DIRS . fs rng usb
|
INCLUDE_DIRS . fs rng usb ../mbedtls/include
|
||||||
PRIV_REQUIRES bootloader_support esp_partition
|
REQUIRES bootloader_support esp_partition tinyusb
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -15,7 +15,10 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef ENABLE_EMULATION
|
#if defined(ENABLE_EMULATION)
|
||||||
|
#elif defined(ESP_PLATFORM)
|
||||||
|
#include "esp_compat.h"
|
||||||
|
#else
|
||||||
#include <pico/unique_id.h>
|
#include <pico/unique_id.h>
|
||||||
#endif
|
#endif
|
||||||
#include "mbedtls/md.h"
|
#include "mbedtls/md.h"
|
||||||
|
|||||||
@@ -18,10 +18,6 @@
|
|||||||
#ifndef _CRYPTO_UTILS_H_
|
#ifndef _CRYPTO_UTILS_H_
|
||||||
#define _CRYPTO_UTILS_H_
|
#define _CRYPTO_UTILS_H_
|
||||||
|
|
||||||
#include "stdlib.h"
|
|
||||||
#ifndef ENABLE_EMULATION
|
|
||||||
#include "pico/stdlib.h"
|
|
||||||
#endif
|
|
||||||
#include "mbedtls/ecp.h"
|
#include "mbedtls/ecp.h"
|
||||||
#include "mbedtls/md.h"
|
#include "mbedtls/md.h"
|
||||||
|
|
||||||
|
|||||||
@@ -18,10 +18,6 @@
|
|||||||
#ifndef _EAC_H_
|
#ifndef _EAC_H_
|
||||||
#define _EAC_H_
|
#define _EAC_H_
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#ifndef ENABLE_EMULATION
|
|
||||||
#include "pico/stdlib.h"
|
|
||||||
#endif
|
|
||||||
#include "pico_keys.h"
|
#include "pico_keys.h"
|
||||||
|
|
||||||
typedef enum MSE_protocol {
|
typedef enum MSE_protocol {
|
||||||
|
|||||||
@@ -39,6 +39,8 @@
|
|||||||
#include "mman.h"
|
#include "mman.h"
|
||||||
#else
|
#else
|
||||||
#ifdef ESP_PLATFORM
|
#ifdef ESP_PLATFORM
|
||||||
|
#include "esp_compat.h"
|
||||||
|
esp_partition_t part0;
|
||||||
#else
|
#else
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
## IDF Component Manager Manifest File
|
## IDF Component Manager Manifest File
|
||||||
dependencies:
|
dependencies:
|
||||||
espressif/esp_tinyusb: "^1.2"
|
espressif/tinyusb: "^0.15.0"
|
||||||
idf: "^5.0"
|
|
||||||
|
|||||||
38
src/main.c
38
src/main.c
@@ -25,28 +25,11 @@
|
|||||||
#endif
|
#endif
|
||||||
#include "emulation.h"
|
#include "emulation.h"
|
||||||
#elif defined(ESP_PLATFORM)
|
#elif defined(ESP_PLATFORM)
|
||||||
|
#include "tusb.h"
|
||||||
#else
|
#else
|
||||||
#include "pico/stdlib.h"
|
#include "pico/stdlib.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// For memcpy
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#ifndef ENABLE_EMULATION
|
|
||||||
// Include descriptor struct definitions
|
|
||||||
//#include "usb_common.h"
|
|
||||||
// USB register definitions from pico-sdk
|
|
||||||
#include "hardware/regs/usb.h"
|
|
||||||
// USB hardware struct definitions from pico-sdk
|
|
||||||
#include "hardware/structs/usb.h"
|
|
||||||
// For interrupt enable and numbers
|
|
||||||
#include "hardware/irq.h"
|
|
||||||
// For resetting the USB controller
|
|
||||||
#include "hardware/resets.h"
|
|
||||||
|
|
||||||
#include "pico/multicore.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "random.h"
|
#include "random.h"
|
||||||
#include "pico_keys.h"
|
#include "pico_keys.h"
|
||||||
#include "apdu.h"
|
#include "apdu.h"
|
||||||
@@ -101,11 +84,14 @@ static inline void ws2812_program_init(PIO pio,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef ENABLE_EMULATION
|
#if defined(ENABLE_EMULATION)
|
||||||
|
#else
|
||||||
#include "usb.h"
|
#include "usb.h"
|
||||||
|
#ifndef ESP_PLATFORM
|
||||||
#include "hardware/rtc.h"
|
#include "hardware/rtc.h"
|
||||||
#include "bsp/board.h"
|
#include "bsp/board.h"
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
extern void do_flash();
|
extern void do_flash();
|
||||||
extern void low_flash_init();
|
extern void low_flash_init();
|
||||||
@@ -196,6 +182,11 @@ uint32_t board_millis() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
#ifdef ESP_PLATFORM
|
||||||
|
bool board_button_read() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
bool button_pressed_state = false;
|
bool button_pressed_state = false;
|
||||||
uint32_t button_pressed_time = 0;
|
uint32_t button_pressed_time = 0;
|
||||||
uint8_t button_press = 0;
|
uint8_t button_press = 0;
|
||||||
@@ -289,7 +280,9 @@ void led_off_all() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void init_rtc() {
|
void init_rtc() {
|
||||||
#ifndef ENABLE_EMULATION
|
#if defined(ENABLE_EMULATION)
|
||||||
|
#elif defined(ESP_PLATFORM)
|
||||||
|
#else
|
||||||
rtc_init();
|
rtc_init();
|
||||||
datetime_t dt = {
|
datetime_t dt = {
|
||||||
.year = 2020,
|
.year = 2020,
|
||||||
@@ -345,15 +338,16 @@ void core0_loop() {
|
|||||||
|
|
||||||
#ifdef ESP_PLATFORM
|
#ifdef ESP_PLATFORM
|
||||||
TaskHandle_t hcore0 = NULL, hcore1 = NULL;
|
TaskHandle_t hcore0 = NULL, hcore1 = NULL;
|
||||||
void app_main(void) {
|
int app_main() {
|
||||||
#else
|
#else
|
||||||
int main(void) {
|
int main(void) {
|
||||||
#endif
|
#endif
|
||||||
#ifndef ENABLE_EMULATION
|
#ifndef ENABLE_EMULATION
|
||||||
usb_init();
|
usb_init();
|
||||||
|
#ifndef ESP_PLATFORM
|
||||||
board_init();
|
board_init();
|
||||||
stdio_init_all();
|
stdio_init_all();
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef PIMORONI_TINY2040
|
#ifdef PIMORONI_TINY2040
|
||||||
gpio_init(TINY2040_LED_R_PIN);
|
gpio_init(TINY2040_LED_R_PIN);
|
||||||
|
|||||||
@@ -21,9 +21,6 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#ifndef ENABLE_EMULATION
|
|
||||||
#include "pico/stdlib.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void random_init(void);
|
void random_init(void);
|
||||||
void random_fini(void);
|
void random_fini(void);
|
||||||
|
|||||||
@@ -15,28 +15,11 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
// Pico
|
|
||||||
#include "pico/stdlib.h"
|
|
||||||
|
|
||||||
// For memcpy
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
// Include descriptor struct definitions
|
|
||||||
//#include "usb_common.h"
|
|
||||||
// USB register definitions from pico-sdk
|
|
||||||
#include "hardware/regs/usb.h"
|
|
||||||
// USB hardware struct definitions from pico-sdk
|
|
||||||
#include "hardware/structs/usb.h"
|
|
||||||
// For interrupt enable and numbers
|
|
||||||
#include "hardware/irq.h"
|
|
||||||
// For resetting the USB controller
|
|
||||||
#include "hardware/resets.h"
|
|
||||||
|
|
||||||
#include "random.h"
|
#include "random.h"
|
||||||
#include "pico_keys.h"
|
#include "pico_keys.h"
|
||||||
|
#if !defined(ENABLE_EMULATION) && !defined(ESP_PLATFORM)
|
||||||
#include "hardware/rtc.h"
|
#include "hardware/rtc.h"
|
||||||
|
#endif
|
||||||
#include "tusb.h"
|
#include "tusb.h"
|
||||||
#include "ccid.h"
|
#include "ccid.h"
|
||||||
#include "device/usbd_pvt.h"
|
#include "device/usbd_pvt.h"
|
||||||
|
|||||||
@@ -26,8 +26,6 @@
|
|||||||
#ifndef _TUSB_CONFIG_H_
|
#ifndef _TUSB_CONFIG_H_
|
||||||
#define _TUSB_CONFIG_H_
|
#define _TUSB_CONFIG_H_
|
||||||
|
|
||||||
#include "usb.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
@@ -64,7 +62,7 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CFG_TUSB_OS
|
#ifndef CFG_TUSB_OS
|
||||||
//#define CFG_TUSB_OS OPT_OS_PICO
|
#define CFG_TUSB_OS OPT_OS_FREERTOS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CFG_TUSB_DEBUG
|
#ifndef CFG_TUSB_DEBUG
|
||||||
@@ -115,7 +113,7 @@ extern "C" {
|
|||||||
#ifdef USB_ITF_CCID
|
#ifdef USB_ITF_CCID
|
||||||
#define CFG_TUD_VENDOR 2
|
#define CFG_TUD_VENDOR 2
|
||||||
#else
|
#else
|
||||||
#define CFG_TUD_VENDOR 0
|
#define CFG_TUD_VENDOR 2
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// HID buffer size Should be sufficient to hold ID (if any) + Data
|
// HID buffer size Should be sufficient to hold ID (if any) + Data
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ void usb_clear_rx(uint8_t itf) {
|
|||||||
|
|
||||||
#define USB_BCD 0x0200
|
#define USB_BCD 0x0200
|
||||||
|
|
||||||
#if !defined(ENABLE_EMULATION) && !defined(ESP_PLATFORM)
|
#if !defined(ENABLE_EMULATION)
|
||||||
queue_t usb_to_card_q;
|
queue_t usb_to_card_q;
|
||||||
queue_t card_to_usb_q;
|
queue_t card_to_usb_q;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user