Skip to content

Commit 6393c48

Browse files
kojo1danielinux
authored andcommitted
print partition info
1 parent def2a53 commit 6393c48

3 files changed

Lines changed: 60 additions & 12 deletions

File tree

include/printf.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@
5555
/* use minimal printf support in string.h */
5656
void uart_printf(const char* fmt, ...);
5757
# define wolfBoot_printf(_f_, ...) uart_printf(_f_, ##__VA_ARGS__)
58+
# elif defined(__CCRX__)
59+
# define wolfBoot_printf printf
5860
# else
5961
# define wolfBoot_printf(_f_, ...) printf(_f_, ##__VA_ARGS__)
6062
# endif

include/user_settings.h

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,6 @@
2828

2929
#include <target.h>
3030

31-
#define WOLFBOOT_SIGN_ED25519
32-
#define WOLFBOOT_HASH_SHA256
33-
34-
#define WOLFBOOT_DUALBOOT
35-
#define WOLFBOOT_FIXED_PARTITIONS
36-
37-
#include "rx72n/r_flash_rx72n.h"
38-
#define FLASHBUFFER_SIZE WOLFBOOT_SECTOR_SIZE
39-
#define WOLFSSL_HAVE_MIN
40-
#define WOLFSSL_HAVE_MAX
41-
#define WC_NO_RNG_SIMPLE
42-
4331
/* System */
4432
#define WOLFSSL_GENERAL_ALIGNMENT 4
4533
#define SINGLE_THREADED
@@ -290,4 +278,5 @@ extern int tolower(int c);
290278
# define WOLFSSL_SMALL_STACK
291279
#endif
292280

281+
293282
#endif /* !H_USER_SETTINGS_ */

src/loader.c

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,60 @@ static volatile const uint32_t __attribute__((used)) wolfboot_version = WOLFBOOT
3232
extern void (** const IV_RAM)(void);
3333
#endif
3434

35+
#if defined(WOLFBOOT_PARTION_INFO) && defined(PRINTF_ENABLED)
36+
37+
#include <printf.h>
38+
39+
static void printPart(uint8_t *part)
40+
{
41+
#ifdef WOLFBOOT_PARTION_VERBOS
42+
uint32_t *v;
43+
int i;
44+
#endif
45+
uint8_t *magic;
46+
uint8_t state;
47+
uint32_t ver;
48+
49+
magic = part;
50+
wolfBoot_printf("Magic: %c%c%c%c\n", magic[0], magic[1], magic[2], magic[3]);
51+
ver = wolfBoot_get_blob_version(part);
52+
wolfBoot_printf("Version: %02x\n", ver);
53+
state = *(part + WOLFBOOT_PARTITION_SIZE - sizeof(uint32_t) - 1);
54+
wolfBoot_printf("Status: %02x\n", state);
55+
magic = part + WOLFBOOT_PARTITION_SIZE - sizeof(uint32_t);
56+
wolfBoot_printf("Tail Mgc: %c%c%c%c\n", magic[0], magic[1], magic[2], magic[3]);
57+
58+
#ifdef WOLFBOOT_PARTIION_VERBOS
59+
v = (uint32_t *)part;
60+
for(i = 0; i < 0x100/4; i++) {
61+
if(i % 4 == 0)
62+
wolfBoot_printf("\n%08x: ", (uint32_t)v+i*4);
63+
wolfBoot_printf("%08x ", v[i]);
64+
}
65+
66+
wolfBoot_printf("\n\nImage:");
67+
68+
for( ; i < 0x100/4 + 16; i++) {
69+
if(i % 4 == 0)
70+
wolfBoot_printf("\n%08x: ", (uint32_t)v+i*4);
71+
wolfBoot_printf("%08x ", v[i]);
72+
}
73+
74+
wolfBoot_printf("\n\n");
75+
#endif
76+
77+
}
78+
79+
80+
static void printPartitions(void)
81+
{
82+
wolfBoot_printf("\n=== Boot Partition[%08x] ===\n", WOLFBOOT_PARTITION_BOOT_ADDRESS);
83+
printPart((uint8_t*)WOLFBOOT_PARTITION_BOOT_ADDRESS);
84+
wolfBoot_printf("\n=== Update Partition[%08x] ===\n", WOLFBOOT_PARTITION_UPDATE_ADDRESS);
85+
printPart((uint8_t*)WOLFBOOT_PARTITION_UPDATE_ADDRESS);
86+
}
87+
#endif
88+
3589
#ifdef PLATFORM_sim
3690
extern char **main_argv;
3791
extern int main_argc;
@@ -60,6 +114,9 @@ int main(void)
60114
wolfBoot_tpm2_init();
61115
#endif
62116

117+
#if defined(WOLFBOOT_PARTION_INFO) && defined(PRINTF_ENABLED)
118+
printPartitions();
119+
#endif
63120
wolfBoot_start();
64121

65122
/* wolfBoot_start should never return. */

0 commit comments

Comments
 (0)