aboutsummaryrefslogtreecommitdiff
path: root/projects
diff options
context:
space:
mode:
Diffstat (limited to 'projects')
-rw-r--r--projects/hsm/Makefile23
-rw-r--r--projects/hsm/mgmt-misc.c28
-rw-r--r--projects/hsm/mgmt-task.c4
3 files changed, 47 insertions, 8 deletions
diff --git a/projects/hsm/Makefile b/projects/hsm/Makefile
index ecd1a5d..9a75b92 100644
--- a/projects/hsm/Makefile
+++ b/projects/hsm/Makefile
@@ -9,11 +9,8 @@ OBJS = mgmt-cli.o \
mgmt-masterkey.o \
mgmt-misc.o \
mgmt-task.o \
- log.o
-
-BOARD_OBJS += $(TOPLEVEL)/task.o
-
-CFLAGS += -DTASK_METRICS
+ log.o \
+ $(TOPLEVEL)/task.o
CFLAGS += -DNUM_RPC_TASK=4
@@ -23,10 +20,24 @@ CFLAGS += -I$(LIBCLI_SRC)
LIBS += $(LIBHAL_BLD)/libhal.a $(LIBTFM_BLD)/libtfm.a
LIBS += $(LIBCLI_BLD)/libcli.a
+LDFLAGS += -mcpu=cortex-m4 -mthumb -mlittle-endian -mthumb-interwork
+LDFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
+LDFLAGS += -Wl,--gc-sections
+
+ifdef DO_PROFILING
+OBJS += $(TOPLEVEL)/memfunc.o
+LIBS += $(LIBPROF_BLD)/libprof.a
+LDFLAGS += --specs=rdimon.specs -lc -lrdimon
+endif
+
+ifdef DO_TASK_METRICS
+CFLAGS += -DDO_TASK_METRICS
+endif
+
all: $(PROJ:=.elf)
%.elf: %.o $(BOARD_OBJS) $(OBJS) $(LIBS)
- $(CC) $(CFLAGS) $^ -o $@ -T$(LDSCRIPT) -g -Wl,-Map=$*.map
+ $(CC) $^ -o $@ -T$(LDSCRIPT) -g -Wl,-Map=$*.map $(LDFLAGS)
$(OBJCOPY) -O binary $*.elf $*.bin
$(SIZE) $*.elf
diff --git a/projects/hsm/mgmt-misc.c b/projects/hsm/mgmt-misc.c
index ccd032b..016d7cb 100644
--- a/projects/hsm/mgmt-misc.c
+++ b/projects/hsm/mgmt-misc.c
@@ -113,6 +113,25 @@ int cli_receive_data(struct cli_def *cli, uint8_t *buf, size_t len, cli_data_cal
return CLI_ERROR;
}
+#ifdef DO_PROFILING
+static int cmd_profile_start(struct cli_def *cli, const char *command, char *argv[], int argc)
+{
+ extern uint32_t CRYPTECH_FIRMWARE_START;
+ extern char __etext; /* end of text/code symbol, defined by linker */
+ extern void monstartup (size_t lowpc, size_t highpc);
+ monstartup((size_t)&CRYPTECH_FIRMWARE_START, (size_t)&__etext);
+ return CLI_OK;
+}
+
+static int cmd_profile_stop(struct cli_def *cli, const char *command, char *argv[], int argc)
+{
+ extern void _mcleanup(void);
+ _mcleanup();
+ return CLI_OK;
+}
+
+#endif
+
static int cmd_reboot(struct cli_def *cli, const char *command, char *argv[], int argc)
{
cli_print(cli, "\n\n\nRebooting\n\n\n");
@@ -124,6 +143,15 @@ static int cmd_reboot(struct cli_def *cli, const char *command, char *argv[], in
void configure_cli_misc(struct cli_def *cli)
{
+#ifdef DO_PROFILING
+ struct cli_command *c_profile = cli_register_command(cli, NULL, "profile", NULL, 0, 0, NULL);
+
+ /* profile start */
+ cli_register_command(cli, c_profile, "start", cmd_profile_start, 0, 0, "Start collecting profiling data");
+
+ /* profile stop */
+ cli_register_command(cli, c_profile, "stop", cmd_profile_stop, 0, 0, "Stop collecting profiling data");
+#endif
/* reboot */
cli_register_command(cli, NULL, "reboot", cmd_reboot, 0, 0, "Reboot the STM32");
}
diff --git a/projects/hsm/mgmt-task.c b/projects/hsm/mgmt-task.c
index 12ce2b8..1658a80 100644
--- a/projects/hsm/mgmt-task.c
+++ b/projects/hsm/mgmt-task.c
@@ -69,7 +69,7 @@ static int cmd_task_show(struct cli_def *cli, const char *command, char *argv[],
return CLI_OK;
}
-#ifdef TASK_METRICS
+#ifdef DO_TASK_METRICS
static int cmd_task_show_metrics(struct cli_def *cli, const char *command, char *argv[], int argc)
{
struct task_metrics tm;
@@ -97,7 +97,7 @@ void configure_cli_task(struct cli_def *cli)
/* task show */
struct cli_command *c_show = cli_register_command(cli, c, "show", cmd_task_show, 0, 0, "Show the active tasks");
-#ifdef TASK_METRICS
+#ifdef DO_TASK_METRICS
/* task show metrics */
cli_register_command(cli, c_show, "metrics", cmd_task_show_metrics, 0, 0, "Show task metrics");