Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add Espressif SPI support #368

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

Conversation

gojimmypi
Copy link
Contributor

This PR is credit [David Safford] that kindly sent me a patch along with a brief description:

I noticed you submitted the wolftpm code for i2c on espressif, and
thought you might be interested in this. Attached is a quick patch
that adds SPI support on espessif, in the same HAL file you added. I
tested it on a custom card with esp32-S3-wroom and SLB9672 on
HOST_SPI2.
It's pretty simple, the only trick being that the esp SPI support has
a hard limit of 64 bytes for the total transfer including the four
header bytes, so the burstCount has to be limited to 60. Took me a
while to figure that one out :-)

I've not had time to test this. I wanted to at least express my thanks to David and open this draft PR to let people know that it is in the works.

@gojimmypi gojimmypi marked this pull request as draft August 11, 2024 17:20
@gojimmypi gojimmypi self-assigned this Aug 11, 2024
static int _is_initialized_spi = FALSE;

int esp_spi_master_init() {
// SPI bus & device configuration
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C style comments /* */. Please refactor all


int esp_spi_master_init() {
// SPI bus & device configuration
spi_bus_config_t bus_cfg = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add const if possible


// FSPI (HOST_SPI2) on esp32-s3-wroom
#define PIN_NUM_MISO 13
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider #ifndef PIN_NUM_MISO to allow build-time override. Same for below.

}

/* Aquire SPI bus and keep pulling CS */
int tpm_spi_acquire()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

static int tpm_spi_acquire(void)


static int _is_initialized_spi = FALSE;

int esp_spi_master_init() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

static int esp_spi_master_init()
{

int64_t timeout_expiry;
} *tpm_data;

static int _is_initialized_spi = FALSE;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not use FALSE. Use 0

gojimmypi added a commit to gojimmypi/wolfTPM that referenced this pull request Jan 22, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants