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

Minor tweaks #1174

Merged
merged 2 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you also add scripts to set it back to the old one? on raw pcb's it's easy to switch screens.

probably not necessary for the chip as you can't switch that :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done!

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
Loading