Skip to content

Commit 389e12f

Browse files
dgarskedanielinux
authored andcommitted
Fixes to get TPM working with T1024 and MMU enabled.
1 parent 3e8d6fb commit 389e12f

File tree

8 files changed

+25
-33
lines changed

8 files changed

+25
-33
lines changed

hal/nxp_p1021.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ static int test_tpm(void);
6161
#endif
6262

6363
#ifdef ENABLE_ESPI
64-
#include "spi_drv.h" /* for transfer flags */
64+
#include "spi_drv.h" /* for transfer flags and chip select */
6565
#endif
6666

6767
/* P1021 Platform */
@@ -1936,9 +1936,6 @@ static int test_flash(void)
19361936
#endif /* ENABLE_ELBC && TEST_FLASH */
19371937

19381938
#if defined(ENABLE_ESPI) && defined(TEST_TPM)
1939-
#ifndef SPI_CS_TPM
1940-
#define SPI_CS_TPM 2
1941-
#endif
19421939
int test_tpm(void)
19431940
{
19441941
/* Read 4 bytes at TIS address D40F00. Assumes 0 wait state on TPM */

hal/nxp_t1024.c

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,20 @@
3737
#define ENABLE_BUS_CLK_CALC
3838
#define ENABLE_IFC
3939
#ifndef BUILD_LOADER_STAGE1
40+
/* Tests */
41+
#if 0
42+
#define TEST_DDR
43+
#define TEST_FLASH
44+
#define TEST_TPM
45+
#endif
46+
4047
//#define ENABLE_CPLD
4148
#define ENABLE_QE /* QUICC Engine */
4249
//#define ENABLE_FMAN
4350
//#define ENABLE_MP /* multi-core support */
4451
#if defined(WOLFBOOT_TPM) || defined(TEST_TPM)
4552
#define ENABLE_ESPI /* SPI for TPM */
4653
#endif
47-
48-
/* Tests */
49-
#if 1
50-
//#define TEST_DDR
51-
//#define TEST_FLASH
52-
//#define TEST_TPM
53-
#endif
5454
#endif
5555

5656
#define USE_ERRATA_DDRA008378
@@ -72,7 +72,7 @@ static int test_tpm(void);
7272
static void hal_flash_unlock_sector(uint32_t sector);
7373

7474
#ifdef ENABLE_ESPI
75-
#include "spi_drv.h" /* for transfer flags */
75+
#include "spi_drv.h" /* for transfer flags and chip select */
7676
#endif
7777

7878
/* T1024 */
@@ -1697,9 +1697,6 @@ static int test_flash(void)
16971697
#endif /* ENABLE_IFC && TEST_FLASH */
16981698

16991699
#if defined(ENABLE_ESPI) && defined(TEST_TPM)
1700-
#ifndef SPI_CS_TPM
1701-
#define SPI_CS_TPM 2
1702-
#endif
17031700
int test_tpm(void)
17041701
{
17051702
/* Read 4 bytes at TIS address D40F00. Assumes 0 wait state on TPM */

hal/spi/spi_drv_nxp.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,10 @@
2929

3030
#ifdef WOLFBOOT_TPM
3131

32-
#if defined(PLATFORM_nxp_p1021)
33-
/* functions from nxp_p1021.c hal */
32+
/* functions from nxp_p1021.c and nxp_t1024.c hal */
3433
extern void hal_espi_init(uint32_t cs, uint32_t clock_hz, uint32_t mode);
35-
extern int hal_espi_xfer(int cs, const uint8_t* tx, uint8_t* rx, uint32_t sz, int flags);
34+
extern int hal_espi_xfer(int cs, const uint8_t* tx, uint8_t* rx, uint32_t sz, int flags);
3635
extern void hal_espi_deinit(void);
37-
#endif
3836

3937
#include <wolftpm/tpm2_types.h>
4038

hal/spi/spi_drv_nxp.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020

2121
#include <stdint.h>
2222

23-
#if defined(PLATFORM_nxp_p1021)
24-
25-
/* Chip select for TPM */
23+
/* Chip select for TPM - defaults */
2624
#ifndef SPI_CS_TPM
27-
#define SPI_CS_TPM 2
28-
#endif
29-
25+
#if defined(PLATFORM_nxp_p1021)
26+
#define SPI_CS_TPM 2
27+
#elif defined(PLATFORM_nxp_t1024)
28+
#define SPI_CS_TPM 1
29+
#endif
3030
#endif
3131

3232
#endif /* !SPI_DRV_NXP_H_INCLUDED */

include/spi_drv.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
#include "hal/spi/spi_drv_nrf52.h"
5555
#endif
5656

57-
#if defined(PLATFORM_nxp_p1021)
57+
#if defined(PLATFORM_nxp_p1021) || defined(PLATFORM_nxp_t1024)
5858
#include "hal/spi/spi_drv_nxp.h"
5959
#endif
6060

src/image.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -819,9 +819,10 @@ int wolfBoot_open_image_address(struct wolfBoot_image *img, uint8_t *image)
819819
}
820820

821821
#ifdef MMU
822-
/* Inline use of ByteReverseWord32 */
823-
#define WOLFSSL_MISC_INCLUDED
824-
#include <wolfcrypt/src/misc.c>
822+
#ifndef WOLFBOOT_TPM /* tpm2_types.h has ByteReverseWord32 */
823+
#define WOLFSSL_MISC_INCLUDED /* allow misc.c code to be inlined */
824+
#include <wolfcrypt/src/misc.c> /* for ByteReverseWord32 */
825+
#endif /* !WOLFBOOT_TPM */
825826
static uint32_t wb_reverse_word32(uint32_t x)
826827
{
827828
return ByteReverseWord32(x);

src/libwolfboot.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,8 @@ static uint32_t ext_cache;
119119

120120

121121
#if defined(__WOLFBOOT) || defined (UNIT_TEST)
122-
/* Inline use of ByteReverseWord32 */
123-
#define WOLFSSL_MISC_INCLUDED
124-
#include <wolfcrypt/src/misc.c>
122+
#define WOLFSSL_MISC_INCLUDED /* allow misc.c code to be inlined */
123+
#include <wolfcrypt/src/misc.c> /* for ByteReverseWord32 */
125124
static uint32_t wb_reverse_word32(uint32_t x)
126125
{
127126
return ByteReverseWord32(x);

stage1/loader_stage1.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ int main(void)
125125
#ifdef PRINTF_ENABLED
126126
wolfBoot_printf("Jumping to full wolfBoot at %p\n", wolfboot_start);
127127
#elif defined(DEBUG_UART)
128-
uart_write("Jumping to full wolfBoot\n", 27);
128+
uart_write("Jumping to full wolfBoot\n", 25);
129129
#endif
130130

131131
hal_prepare_boot();

0 commit comments

Comments
 (0)