Skip to content

Commit

Permalink
Merge commit 'refs/pull/1174/head' of https://github.com/digitalbitbo…
Browse files Browse the repository at this point in the history
  • Loading branch information
benma committed Feb 14, 2024
2 parents de92acb + 6a7ba4d commit 010eef0
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions scripts/set-new-screen.jlink
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
mem 0xe002 1
w1 0xe002 1
mem 0xe002 1
q
4 changes: 4 additions & 0 deletions scripts/set-original-screen.jlink
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
mem 0xe002 1
w1 0xe002 0xff
mem 0xe002 1
q
4 changes: 4 additions & 0 deletions scripts/set-securechip-optiga.jlink
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
mem 0xe003 1
w1 0xe003 1
mem 0xe003 1
q
10 changes: 10 additions & 0 deletions src/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ void util_uint8_to_hex(const uint8_t* in_bin, const size_t in_len, char* out)
rust_util_bytes(in_bin, in_len), rust_util_bytes_mut((uint8_t*)out, in_len * 2 + 1));
}

#if defined(SEMIHOSTING)
char* util_uint8_to_hex_alloc(const uint8_t* in_bin, const size_t in_len)
{
void* out = malloc(in_len * 2 + 1);
rust_util_uint8_to_hex(
rust_util_bytes(in_bin, in_len), rust_util_bytes_mut((uint8_t*)out, in_len * 2 + 1));
return (char*)out;
}
#endif

void util_cleanup_str(char** str)
{
util_zero(*str, strlens(*str));
Expand Down
4 changes: 4 additions & 0 deletions src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ void util_zero(volatile void* dst, size_t len);
// `out` must be of size in_len*2+1. Use BB_HEX_SIZE() to compute the size.
void util_uint8_to_hex(const uint8_t* in_bin, size_t in_len, char* out);

// This function is only compiled when we compile with SEMIHOSTING, it is convenient when debugging
// to print byte arrays as hex.
char* util_uint8_to_hex_alloc(const uint8_t* in_bin, size_t in_len);

#define BB_HEX_SIZE(in_bin) (sizeof((in_bin)) * 2 + 1)

void util_cleanup_str(char** str);
Expand Down

0 comments on commit 010eef0

Please sign in to comment.