Skip to content
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

Support for NXP P1021 eSPI and TPM (and fixes for eLBC NAND) #302

Merged
merged 12 commits into from
May 11, 2023

Conversation

dgarske
Copy link
Contributor

@dgarske dgarske commented May 4, 2023

  • Fix for P1021 to disable XIP support. This enables PART_BOOT_EXT to correctly load the boot partition from external flash.
  • Fix the eLBC NAND flash driver issues with page/col selection.
  • Allow override of the WOLFBOOT_SHA_BLOCK_SIZE.
  • Refactor the TPM SPI interface to enable full transfers.
  • Update the new spi_xfer to include a "continue" flag to allow leaving the CS asserted.
  • Enable support for calling into target HAL for SPI.
  • Added P1021 TPM test.
  • Reduce first stage init code (don't relocate CCSRBAR or invalidate all TLB's).
  • Improve udelay to use timebase.
  • Fix L1 cache line sizes.
  • Fix L2ADDR to enable all 256KB.
  • Use do_boot not the jump to function pointer.
  • Switch PPC test app linker script to use WOLFBOOT_LOAD_ADDRESS.
  • Improvements to the clock calculation code (dynamic based on ratio).
  • Make stage1 PIC.
  • Disable L1/L2 for first stage.
  • Add GOT2 to flash region.
  • Fix to use correct boot ROM entry (0xFFFFF000) in stage1 linker script.
wolfBoot HAL Init
Flash Init: Ret 0, ID 0x76207620
Part: Active 0, Address 0
Boot partition: 200000
Image size 3964
Firmware Valid
Loading 3964 bytes to RAM at 1E000000
Booting at 1E000000

Test App

0x00000001
0x00000002
0x00000003
0x00000004
0x00000005
0x00000006

@dgarske dgarske self-assigned this May 4, 2023
@dgarske dgarske force-pushed the nxp_tpm branch 2 times, most recently from f7df3b6 to 48b7e17 Compare May 4, 2023 22:11
hal/nxp_p1021.c Outdated Show resolved Hide resolved
jpbland1
jpbland1 previously approved these changes May 5, 2023
…override of the `WOLFBOOT_SHA_BLOCK_SIZE`.

```
wolfBoot HAL Init
Flash Init: Ret 0, ID 0x76207620
Part: Active 0, Address 0
Boot partition: 200000
Image size 3964
Firmware Valid
Loading 3964 bytes to RAM at 1E000000
Booting at 1E000000
```
@dgarske dgarske changed the title Support for NXP P1021 eSPI and TPM Support for NXP P1021 eSPI and TPM (and fixes for eLBC NAND) May 5, 2023
while (blks--) {
/* wait till TX fifo has room */
while ((get32(ESPI_SPIE) & ESPI_SPIE_TNF) == 0);
reg = *((uint32_t*)tx);
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think you can ensure all transactions are going to be multiples of 4, especially with the TPM's with unknown wait states. This logic will over-read tx* and over-write rx* when sz is not a multiple of 4. Recommend to add logic to handle the last transaction into a stack uint32_t variable and simply memcpy the data back into rx. Make sure the extra tx data are known values (like 0's).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree, this needs fixed up, since I WILL add wait state support, since customer is using a Microchip ATTPM20.

tx += 4;
set32(ESPI_SPIE, ESPI_SPIE_TNF); /* clear event */

udelay(5);
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you try busy checking the DON bit (17) in the event register? This should be set when the last bit is transmitted, which means the RNE should be set soon after.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I tried using DON also. No luck

#endif

#ifdef WOLFBOOT_TPM
int spi_xfer(int cs, const uint8_t* tx, uint8_t* rx, uint32_t sz);
Copy link
Contributor

Choose a reason for hiding this comment

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

Hrmmm. I think we may need an interface that allows continued transactions where the CS does not get deserted, specifically when the total size of the transaction is unknown at the beginning, like with wait states.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree and the eSPI has the ability to assert / dessert the CS separately.

…l TLB's). Improve udelay to use timebase. Fix L1 cache line sizes. Fix L2ADDR to enable all 256KB. Use `do_boot` not the jump to function pointer. Switch PPC test app linker script to use `WOLFBOOT_LOAD_ADDRESS`.
…Remove execute bits on files. Make stage1 PIC. Disable L1/L2 for first stage. Add PLT/GOT to .data region.
@dgarske dgarske requested a review from billphipps May 10, 2023 23:52
@dgarske dgarske assigned billphipps and unassigned dgarske May 11, 2023
@billphipps billphipps merged commit 106b780 into wolfSSL:master May 11, 2023
41 checks passed
@@ -123,12 +123,10 @@ Also see MPC8544ERM

_reset:

#ifdef DEBUG
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @jpbland1 for spotting this. It was on purpose for release testing. I will investigate impact of this.

@dgarske dgarske deleted the nxp_tpm branch July 26, 2023 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants