mirror of
https://github.com/polhenarejos/pico-keys-sdk
synced 2026-05-28 17:11:23 +02:00
Fixed potential crash.
board_button_read() disables interrupts and cannot be parallelized when flash is being used. It is imperative that core1 must not use flash during the board_button_read(). Since it is not feasible to put mutexes in *every* flash memory read/write in core1, it is preferable to wait until core1 finishes command execution. Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
@@ -204,7 +204,7 @@ done: ;
|
|||||||
void apdu_finish() {
|
void apdu_finish() {
|
||||||
apdu.rdata[apdu.rlen] = apdu.sw >> 8;
|
apdu.rdata[apdu.rlen] = apdu.sw >> 8;
|
||||||
apdu.rdata[apdu.rlen + 1] = apdu.sw & 0xff;
|
apdu.rdata[apdu.rlen + 1] = apdu.sw & 0xff;
|
||||||
timeout_stop();
|
//timeout_stop();
|
||||||
#ifndef ENABLE_EMULATION
|
#ifndef ENABLE_EMULATION
|
||||||
if ((apdu.rlen + 2 + 10) % 64 == 0) { // FIX for strange behaviour with PSCS and multiple of 64
|
if ((apdu.rlen + 2 + 10) % 64 == 0) { // FIX for strange behaviour with PSCS and multiple of 64
|
||||||
apdu.ne = apdu.rlen - 2;
|
apdu.ne = apdu.rlen - 2;
|
||||||
|
|||||||
@@ -323,7 +323,7 @@ int main(void) {
|
|||||||
neug_task();
|
neug_task();
|
||||||
do_flash();
|
do_flash();
|
||||||
#ifndef ENABLE_EMULATION
|
#ifndef ENABLE_EMULATION
|
||||||
if (board_millis() > 1000 && !is_busy()) { // wait 1 second to boot up
|
if (board_millis() > 5000 && !is_busy()) { // wait 5 second to boot up
|
||||||
bool current_button_state = board_button_read();
|
bool current_button_state = board_button_read();
|
||||||
if (current_button_state != button_pressed_state) {
|
if (current_button_state != button_pressed_state) {
|
||||||
if (current_button_state == false) { // unpressed
|
if (current_button_state == false) { // unpressed
|
||||||
|
|||||||
@@ -280,7 +280,6 @@ void usb_task() {
|
|||||||
// printf("\r\n ------ M = %lu\r\n",m);
|
// printf("\r\n ------ M = %lu\r\n",m);
|
||||||
if (has_m) {
|
if (has_m) {
|
||||||
if (m == EV_EXEC_FINISHED) {
|
if (m == EV_EXEC_FINISHED) {
|
||||||
timeout_stop();
|
|
||||||
#ifdef USB_ITF_HID
|
#ifdef USB_ITF_HID
|
||||||
if (itf == ITF_HID) {
|
if (itf == ITF_HID) {
|
||||||
driver_exec_finished_hid(finished_data_size);
|
driver_exec_finished_hid(finished_data_size);
|
||||||
@@ -293,6 +292,7 @@ void usb_task() {
|
|||||||
#endif
|
#endif
|
||||||
led_set_blink(BLINK_MOUNTED);
|
led_set_blink(BLINK_MOUNTED);
|
||||||
card_locked_itf = ITF_TOTAL;
|
card_locked_itf = ITF_TOTAL;
|
||||||
|
timeout_stop();
|
||||||
}
|
}
|
||||||
else if (m == EV_PRESS_BUTTON) {
|
else if (m == EV_PRESS_BUTTON) {
|
||||||
uint32_t flag = wait_button() ? EV_BUTTON_TIMEOUT : EV_BUTTON_PRESSED;
|
uint32_t flag = wait_button() ? EV_BUTTON_TIMEOUT : EV_BUTTON_PRESSED;
|
||||||
|
|||||||
Reference in New Issue
Block a user