LedgerHQ / nanos-secure-sdk

Secure (ST31) SDK for Ledger Nano S
Apache License 2.0
96 stars 54 forks source link

nvm_write throws error #23

Closed i-xiaov closed 4 years ago

i-xiaov commented 4 years ago

It throws error (0x6802) when I calling nvm_write. It seems like an INVALID_PARAMETER error, and occurs at code SVC_Call(SYSCALL_nvm_write_ID_IN, parameters).

Below is my code:

typedef struct {
    uint8_t buffer[2048];
} flash_storage_t;

flash_storage_t N_appdata_impl __attribute__((aligned(64)));
#define N_appdata (*(flash_storage_t *)PIC(&N_appdata_impl))

...

nvm_write(N_appdata.buffer, data, data_size);

I used sdk tag nanos-1553 and my device is ledger-nano-s which firmware is Secure Element 1.5.5 MCU 1.7-printf, is it correct? Or just something wrong with my code?

i-xiaov commented 4 years ago

Well, I solved it. Actually it's not a problem as I passed a wrong --dataSize parameter. What a stupid bug I made.