1#[cfg(any(feature = "atsam4e", feature = "atsam4n"))]
7use crate::pac::efc;
8
9#[cfg(any(feature = "atsam4e", feature = "atsam4n"))]
10use crate::pac::EFC;
11
12#[cfg(feature = "atsam4s")]
13use crate::pac::efc0 as efc;
14
15#[cfg(feature = "atsam4s")]
16use crate::pac::EFC0 as EFC;
17
18#[cfg(feature = "atsam4sd")]
19use crate::pac::EFC1;
20
21use cortex_m::interrupt;
22use embedded_storage::nor_flash::{
23 ErrorType, NorFlash, NorFlashError, NorFlashErrorKind, ReadNorFlash,
24};
25
26const FLASH_PAGE_SIZE: u32 = 512;
28const USER_SIG_FLASH_SIZE: u32 = 512;
29const FLASH_LOCK_REGION_SIZE: u32 = 8192;
30const FLASH_READ_SIZE: u32 = 4;
31const FLASH_WRITE_SIZE: u32 = 4;
32
33struct FlashParameters {
34 gpnvm_num_max: u8,
35 flash0_addr: u32,
36 flash0_size: u32,
37 #[cfg(feature = "atsam4sd")]
38 flash1_addr: u32,
39 #[cfg(feature = "atsam4sd")]
40 flash1_size: u32,
41}
42
43#[cfg(any(feature = "atsam4e8c", feature = "atsam4e8e"))]
44const FLASH_PARAMS: FlashParameters = FlashParameters {
45 gpnvm_num_max: 2,
46 flash0_addr: 0x00400000,
47 flash0_size: 0x00080000,
48};
49
50#[cfg(any(feature = "atsam4e16c", feature = "atsam4e16e"))]
51const FLASH_PARAMS: FlashParameters = FlashParameters {
52 gpnvm_num_max: 2,
53 flash0_addr: 0x00400000,
54 flash0_size: 0x00100000,
55};
56
57#[cfg(any(feature = "atsam4n8a", feature = "atsam4n8b", feature = "atsam4n8c"))]
58const FLASH_PARAMS: FlashParameters = FlashParameters {
59 gpnvm_num_max: 2,
60 flash0_addr: 0x00400000,
61 flash0_size: 0x00080000,
62};
63
64#[cfg(any(feature = "atsam4n16b", feature = "atsam4n16c"))]
65const FLASH_PARAMS: FlashParameters = FlashParameters {
66 gpnvm_num_max: 2,
67 flash0_addr: 0x00400000,
68 flash0_size: 0x00100000,
69};
70
71#[cfg(any(feature = "atsam4s2a", feature = "atsam4s2b", feature = "atsam4s2c"))]
72const FLASH_PARAMS: FlashParameters = FlashParameters {
73 gpnvm_num_max: 2,
74 flash0_addr: 0x00400000,
75 flash0_size: 0x00020000,
76};
77
78#[cfg(any(feature = "atsam4s4a", feature = "atsam4s4b", feature = "atsam4s4c"))]
79const FLASH_PARAMS: FlashParameters = FlashParameters {
80 gpnvm_num_max: 2,
81 flash0_addr: 0x00400000,
82 flash0_size: 0x00040000,
83};
84
85#[cfg(any(feature = "atsam4s8b", feature = "atsam4s8c"))]
86const FLASH_PARAMS: FlashParameters = FlashParameters {
87 gpnvm_num_max: 2,
88 flash0_addr: 0x00400000,
89 flash0_size: 0x0080000,
90};
91
92#[cfg(any(feature = "atsam4sa16b", feature = "atsam4sa16c"))]
93const FLASH_PARAMS: FlashParameters = FlashParameters {
94 gpnvm_num_max: 2,
95 flash0_addr: 0x00400000,
96 flash0_size: 0x00100000,
97};
98
99#[cfg(any(feature = "atsam4sd16b", feature = "atsam4sd16c"))]
100const FLASH_PARAMS: FlashParameters = FlashParameters {
101 gpnvm_num_max: 3,
102 flash0_addr: 0x00400000,
103 flash0_size: 0x00080000,
104 flash1_addr: 0x00480000,
105 flash1_size: 0x00080000,
106};
107
108#[cfg(any(feature = "atsam4sd32b", feature = "atsam4sd32c"))]
109const FLASH_PARAMS: FlashParameters = FlashParameters {
110 gpnvm_num_max: 3,
111 flash0_addr: 0x00400000,
112 flash0_size: 0x00100000,
113 flash1_addr: 0x00500000,
114 flash1_size: 0x00100000,
115};
116
117extern "C" {
118 fn efc_perform_read_sequence(
125 efc: *const u32,
126 cmd_st: u32,
127 cmd_sp: u32,
128 buf: *mut u32,
129 size: u32,
130 flash_addr: *mut u32,
131 ) -> u32;
132
133 fn efc_perform_fcr(efc: *const u32, fcr: u32) -> u32;
139}
140
141pub struct Efc {
203 #[cfg(any(feature = "atsam4e", feature = "atsam4n", feature = "atsam4s"))]
204 efc: EFC,
205 #[cfg(feature = "atsam4sd")]
206 efc1: EFC1,
207 storage: &'static mut [u32],
208}
209
210impl Efc {
211 #[cfg(any(
213 feature = "atsam4e",
214 feature = "atsam4n",
215 feature = "atsam4s_",
216 feature = "atsam4sa"
217 ))]
218 pub fn new(efc: EFC, storage: &'static mut [u32]) -> Efc {
219 Self { efc, storage }
220 }
221
222 #[cfg(feature = "atsam4sd")]
224 pub fn new(efc0: EFC, efc1: EFC1, storage: &'static mut [u32]) -> Efc {
225 Self {
226 efc: efc0,
227 efc1,
228 storage,
229 }
230 }
231
232 #[cfg(any(feature = "atsam4e", feature = "atsam4n", feature = "atsam4s_"))]
234 pub fn free(self) -> (EFC, &'static mut [u32]) {
235 (self.efc, self.storage)
236 }
237
238 #[cfg(feature = "atsam4sd")]
240 pub fn free(self) -> (EFC, EFC1, &'static mut [u32]) {
241 (self.efc, self.efc1, self.storage)
242 }
243
244 #[inline]
245 fn wait_ready(&self) {
246 while !self.efc.fsr.read().frdy().bit() {}
247 }
248
249 #[cfg(feature = "atsam4sd")]
252 fn translate_address(&self, address: u32) -> Result<(u16, u16, u8), EfcError> {
253 if address < FLASH_PARAMS.flash0_addr
254 || address > FLASH_PARAMS.flash1_addr + FLASH_PARAMS.flash1_size
255 {
256 return Err(EfcError::AddressBoundsError);
257 }
258
259 let gpnvm2 = self.is_gpnvm_set(2)?;
261 if address >= FLASH_PARAMS.flash1_addr {
262 let bank = if gpnvm2 { 0 } else { 1 }; let page = (address - FLASH_PARAMS.flash1_addr) / FLASH_PAGE_SIZE;
264 let offset = (address - FLASH_PARAMS.flash1_addr) % FLASH_PAGE_SIZE;
265 Ok((page as u16, offset as u16, bank))
266 } else {
267 let bank = u8::from(gpnvm2);
268 let page = (address - FLASH_PARAMS.flash0_addr) / FLASH_PAGE_SIZE;
269 let offset = (address - FLASH_PARAMS.flash0_addr) % FLASH_PAGE_SIZE;
270 Ok((page as u16, offset as u16, bank))
271 }
272 }
273
274 #[cfg(not(feature = "atsam4sd"))]
277 fn translate_address(&self, address: u32) -> Result<(u16, u16, u8), EfcError> {
278 if address < FLASH_PARAMS.flash0_addr
279 || address > FLASH_PARAMS.flash0_addr + FLASH_PARAMS.flash0_size
280 {
281 return Err(EfcError::AddressBoundsError);
282 }
283
284 let page = (address - FLASH_PARAMS.flash0_addr) / FLASH_PAGE_SIZE;
285 let offset = (address - FLASH_PARAMS.flash0_addr) % FLASH_PAGE_SIZE;
286 Ok((page as u16, offset as u16, 0))
287 }
288
289 fn compute_lock_range(&self, start: u32, end: u32) -> (u32, u32) {
322 let actual_start = start - (start % FLASH_LOCK_REGION_SIZE);
323 let actual_end = end - (end % FLASH_LOCK_REGION_SIZE) + FLASH_LOCK_REGION_SIZE - 1;
324 (actual_start, actual_end)
325 }
326
327 pub fn lock(&self, start: u32, end: u32) -> Result<(u32, u32), EfcError> {
331 let num_pages_in_region = (FLASH_LOCK_REGION_SIZE / FLASH_PAGE_SIZE) as u16;
332
333 let (actual_start, actual_end) = self.compute_lock_range(start, end);
335
336 let (mut start_page, _, bank) = self.translate_address(actual_start)?;
338 let (_, end_page, _) = self.translate_address(actual_end)?;
339
340 while start_page < end_page {
342 self.efc_perform_command(bank, efc::fcr::FCMD_AW::SLB, start_page)?;
343 start_page += num_pages_in_region;
344 }
345
346 Ok((actual_start, actual_end))
347 }
348
349 pub fn unlock(&self, start: u32, end: u32) -> Result<(u32, u32), EfcError> {
352 let num_pages_in_region = (FLASH_LOCK_REGION_SIZE / FLASH_PAGE_SIZE) as u16;
353
354 let (actual_start, actual_end) = self.compute_lock_range(start, end);
356
357 let (mut start_page, _, bank) = self.translate_address(actual_start)?;
359 let (_, end_page, _) = self.translate_address(actual_end)?;
360
361 while start_page < end_page {
363 self.efc_perform_command(bank, efc::fcr::FCMD_AW::CLB, start_page)?;
364 start_page += num_pages_in_region;
365 }
366
367 Ok((actual_start, actual_end))
368 }
369
370 pub fn is_locked(&self, start: u32, end: u32) -> Result<u32, EfcError> {
372 if end < start
373 || start < FLASH_PARAMS.flash0_addr
374 || end > FLASH_PARAMS.flash0_addr + FLASH_PARAMS.flash0_size
375 {
376 return Err(EfcError::AddressBoundsError);
377 }
378
379 let (start_page, _, bank) = self.translate_address(start)?;
381 let (_, end_page, _) = self.translate_address(end)?;
382
383 let num_pages_in_region = FLASH_LOCK_REGION_SIZE / FLASH_PAGE_SIZE;
385 let start_region = start_page as u32 / num_pages_in_region;
386 let end_region = end_page as u32 / num_pages_in_region;
387
388 self.efc_perform_command(bank, efc::fcr::FCMD_AW::GLB, 0)?;
390
391 let mut count = 0;
393 let mut status = self.efc_get_result(bank);
394 while count <= start_region && start_region < count + 32 {
395 status = self.efc_get_result(bank);
396 count += 32;
397 }
398
399 let mut bit = start_region - count;
400 count = end_region - start_region + 1;
401 let mut num_locked_regions = 0;
402
403 while count > 0 {
404 if status & (1 << bit) != 0 {
405 num_locked_regions += 1;
406 }
407
408 count -= 1;
409 bit += 1;
410 if bit == 32 {
411 status = self.efc_get_result(bank);
412 bit = 0;
413 }
414 }
415
416 Ok(num_locked_regions)
417 }
418
419 pub fn set_gpnvm(&self, gpnvm: u8) -> Result<(), EfcError> {
421 if gpnvm >= FLASH_PARAMS.gpnvm_num_max {
423 return Err(EfcError::InvalidGpnvmBitError);
424 }
425
426 if self.is_gpnvm_set(gpnvm)? {
428 return Ok(());
429 }
430
431 self.efc_perform_command(0, efc::fcr::FCMD_AW::SGPB, gpnvm as u16)
433 }
434
435 pub fn clear_gpnvm(&self, gpnvm: u8) -> Result<(), EfcError> {
437 if gpnvm >= FLASH_PARAMS.gpnvm_num_max {
439 return Err(EfcError::InvalidGpnvmBitError);
440 }
441
442 if !self.is_gpnvm_set(gpnvm)? {
444 return Ok(());
445 }
446
447 self.efc_perform_command(0, efc::fcr::FCMD_AW::CGPB, gpnvm as u16)
449 }
450
451 pub fn is_gpnvm_set(&self, gpnvm: u8) -> Result<bool, EfcError> {
453 if gpnvm >= FLASH_PARAMS.gpnvm_num_max {
455 return Err(EfcError::InvalidGpnvmBitError);
456 }
457
458 self.efc_perform_command(0, efc::fcr::FCMD_AW::GGPB, gpnvm as u16)?;
460 let gpnvm_bits = self.efc_get_result(0);
461
462 Ok(gpnvm_bits & (1 << gpnvm) != 0)
464 }
465
466 pub fn enable_security_bit(&self) -> Result<(), EfcError> {
468 self.set_gpnvm(0)
469 }
470
471 pub fn is_security_bit_enabled(&self) -> Result<bool, EfcError> {
473 self.is_gpnvm_set(0)
474 }
475
476 pub fn read_unique_id(&self) -> Result<[u32; 4], EfcError> {
478 let mut uid: [u32; 4] = [0; 4];
480 self.efc_perform_read_sequence(
481 0,
482 efc::fcr::FCMD_AW::STUI,
483 efc::fcr::FCMD_AW::SPUI,
484 &mut uid,
485 4,
486 )?;
487
488 Ok(uid)
490 }
491
492 pub fn read_user_signature(&self, data: &mut [u32], len: usize) -> Result<(), EfcError> {
494 if len > USER_SIG_FLASH_SIZE as usize / core::mem::size_of::<u32>() {
496 return Err(EfcError::InvalidUserSignatureSizeError);
497 }
498
499 self.efc_perform_read_sequence(
501 0,
502 efc::fcr::FCMD_AW::STUS,
503 efc::fcr::FCMD_AW::SPUS,
504 data,
505 len,
506 )
507 }
508
509 pub fn write_user_signature(&mut self, data: &[u32]) -> Result<(), EfcError> {
511 if data.len() > USER_SIG_FLASH_SIZE as usize / core::mem::size_of::<u32>() {
513 return Err(EfcError::InvalidUserSignatureSizeError);
514 }
515
516 self.storage[..data.len()].clone_from_slice(data);
518
519 self.efc_perform_command(0, efc::fcr::FCMD_AW::WUS, 0)
521 }
522
523 pub fn erase_user_signature(&self) -> Result<(), EfcError> {
525 self.efc_perform_command(0, efc::fcr::FCMD_AW::EUS, 0)
526 }
527
528 #[cfg(not(feature = "atsam4sd"))]
530 fn efc_get_result(&self, _bank: u8) -> u32 {
531 self.efc.frr.read().fvalue().bits()
532 }
533
534 #[cfg(feature = "atsam4sd")]
536 fn efc_get_result(&self, bank: u8) -> u32 {
537 if bank == 0 {
538 self.efc.frr.read().fvalue().bits()
539 } else {
540 self.efc1.frr.read().fvalue().bits()
541 }
542 }
543
544 fn efc_perform_command(
549 &self,
550 bank: u8,
551 command: efc::fcr::FCMD_AW,
552 argument: u16,
553 ) -> Result<(), EfcError> {
554 match command {
556 efc::fcr::FCMD_AW::STUI | efc::fcr::FCMD_AW::SPUI => {
557 return Err(EfcError::UnsupportedCommandError);
558 }
559 _ => {}
560 }
561
562 self.efc_fcr_command(bank, command, argument)
563 }
564
565 fn efc_fcr_command(
569 &self,
570 bank: u8,
571 command: efc::fcr::FCMD_AW,
572 argument: u16,
573 ) -> Result<(), EfcError> {
574 let fcr_cmd: u32 = ((efc::fcr::FKEY_AW::PASSWD as u32) << 24)
576 | ((argument as u32) << 8)
577 | (command as u32);
578
579 #[cfg(not(feature = "atsam4sd"))]
581 let efc_ptr = {
582 let _ = bank;
583 EFC::PTR as *const _
584 };
585 #[cfg(feature = "atsam4sd")]
586 let efc_ptr = if bank == 0 {
587 EFC::PTR as *const _
588 } else if bank == 1 {
589 EFC1::PTR as *const _
590 } else {
591 return Err(EfcError::InvalidFlashBank);
592 };
593
594 cortex_m::asm::dsb();
596 cortex_m::asm::isb();
597
598 let status = interrupt::free(|_| unsafe { efc_perform_fcr(efc_ptr, fcr_cmd) });
600
601 if status & (1 << 1) != 0 {
603 Err(EfcError::CommandError)
604 } else if status & (1 << 2) != 0 {
605 Err(EfcError::LockError)
606 } else if status & (1 << 3) != 0 {
607 Err(EfcError::FlashError)
608 } else {
609 Ok(())
611 }
612 }
613
614 fn efc_perform_read_sequence(
619 &self,
620 bank: u8,
621 start_cmd: efc::fcr::FCMD_AW,
622 stop_cmd: efc::fcr::FCMD_AW,
623 bytes: &mut [u32],
624 len: usize,
625 ) -> Result<(), EfcError> {
626 if bytes.len() < len {
628 return Err(EfcError::InvalidBufferSizeError);
629 }
630
631 #[cfg(not(feature = "atsam4sd"))]
634 let status = {
635 let _ = bank;
636 unsafe {
637 efc_perform_read_sequence(
638 EFC::PTR as *const _,
639 start_cmd as u32,
640 stop_cmd as u32,
641 bytes.as_mut_ptr(),
642 len as u32,
643 FLASH_PARAMS.flash0_addr as *mut _,
644 )
645 }
646 };
647 #[cfg(feature = "atsam4sd")]
648 let status = {
649 unsafe {
650 if bank == 0 {
651 efc_perform_read_sequence(
652 EFC::PTR as *const _,
653 start_cmd as u32,
654 stop_cmd as u32,
655 bytes.as_mut_ptr(),
656 len as u32,
657 FLASH_PARAMS.flash0_addr as *mut _,
658 )
659 } else if bank == 1 {
660 efc_perform_read_sequence(
661 EFC1::PTR as *const _,
662 start_cmd as u32,
663 stop_cmd as u32,
664 bytes.as_mut_ptr(),
665 len as u32,
666 FLASH_PARAMS.flash1_addr as *mut _,
667 )
668 } else {
669 return Err(EfcError::InvalidFlashBank);
670 }
671 }
672 };
673
674 if status != 0 {
675 Err(EfcError::InvalidBufferSizeError)
677 } else {
678 Ok(())
679 }
680 }
681}
682
683impl ErrorType for Efc {
684 type Error = EfcError;
685}
686
687impl ReadNorFlash for Efc {
688 const READ_SIZE: usize = FLASH_READ_SIZE as usize;
689
690 fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Self::Error> {
698 let offset = offset as usize;
699 let bytes_len = bytes.len();
700 let read_len = bytes_len + (Self::READ_SIZE - (bytes_len % Self::READ_SIZE));
701 let target_offset = offset + read_len;
702 if offset % Self::READ_SIZE == 0 && target_offset <= self.capacity() {
703 self.wait_ready();
704 let last_offset = target_offset - Self::READ_SIZE;
705 for offset in (offset..last_offset).step_by(Self::READ_SIZE) {
706 let word = self.storage[offset >> 2];
707 bytes[offset] = (word >> 24) as u8;
708 bytes[offset + 1] = (word >> 16) as u8;
709 bytes[offset + 2] = (word >> 8) as u8;
710 bytes[offset + 3] = (word) as u8;
711 }
712 let offset = last_offset;
713 let word = self.storage[offset >> 2];
714 let mut bytes_offset = offset;
715 if bytes_offset < bytes_len {
716 bytes[bytes_offset] = (word >> 24) as u8;
717 bytes_offset += 1;
718 if bytes_offset < bytes_len {
719 bytes[bytes_offset] = (word >> 16) as u8;
720 bytes_offset += 1;
721 if bytes_offset < bytes_len {
722 bytes[bytes_offset] = (word >> 8) as u8;
723 bytes_offset += 1;
724 if bytes_offset < bytes_len {
725 bytes[bytes_offset] = (word) as u8;
726 }
727 }
728 }
729 }
730 Ok(())
731 } else {
732 Err(EfcError::Unaligned)
733 }
734 }
735
736 #[cfg(not(feature = "atsam4sd"))]
737 fn capacity(&self) -> usize {
738 FLASH_PARAMS.flash0_size as usize
739 }
740
741 #[cfg(feature = "atsam4sd")]
742 fn capacity(&self) -> usize {
743 (FLASH_PARAMS.flash0_size + FLASH_PARAMS.flash1_size) as usize
744 }
745}
746
747impl NorFlash for Efc {
748 const WRITE_SIZE: usize = FLASH_WRITE_SIZE as usize;
752
753 const ERASE_SIZE: usize = 8 * FLASH_PAGE_SIZE as usize;
774
775 fn erase(&mut self, from: u32, to: u32) -> Result<(), Self::Error> {
781 if from == to {
783 return Ok(());
784 }
785
786 if from > to {
788 return Err(EfcError::AddressBoundsError);
789 }
790
791 if to >= FLASH_PARAMS.flash0_size {
793 return Err(EfcError::AddressBoundsError);
794 }
795
796 if from == 0 && to == FLASH_PARAMS.flash0_size {
798 return self.efc_perform_command(0, efc::fcr::FCMD_AW::EA, 0);
799 }
800 #[cfg(feature = "atsam4sd")]
801 if from == FLASH_PARAMS.flash1_addr && to == FLASH_PARAMS.flash1_size {
802 return self.efc_perform_command(1, efc::fcr::FCMD_AW::EA, 0);
803 }
804 #[cfg(feature = "atsam4sd")]
805 if from == 0 && to == FLASH_PARAMS.flash0_size + FLASH_PARAMS.flash1_size {
806 self.efc_perform_command(0, efc::fcr::FCMD_AW::EA, 0)?;
807 return self.efc_perform_command(1, efc::fcr::FCMD_AW::EA, 0);
808 }
809
810 if from % Self::ERASE_SIZE as u32 != 0 || to % Self::ERASE_SIZE as u32 != 0 {
813 return Err(EfcError::NotWithinFlashPageBoundsError);
814 }
815
816 for address in (from..to).step_by(Self::ERASE_SIZE) {
820 let (page, _, bank) = self.translate_address(address)?;
823
824 let farg = 1;
830
831 self.efc_perform_command(bank, efc::fcr::FCMD_AW::EPA, farg | page)?;
832 }
833
834 Ok(())
835 }
836
837 fn write(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Self::Error> {
842 let offset = offset as usize;
844 if offset % Self::WRITE_SIZE == 0 && bytes.len() % Self::WRITE_SIZE == 0 {
845 if bytes.len() + offset > FLASH_PARAMS.flash0_size as usize {
847 return Err(EfcError::AddressBoundsError);
848 }
849
850 for offset in (offset..(offset + bytes.len())).step_by(Self::WRITE_SIZE) {
852 let word = ((bytes[offset] as u32) << 24)
853 | ((bytes[offset + 1] as u32) << 16)
854 | ((bytes[offset + 2] as u32) << 8)
855 | (bytes[offset + 3] as u32);
856
857 self.storage[offset >> 2] = word;
859
860 if (offset + Self::WRITE_SIZE) % FLASH_PAGE_SIZE as usize == 0
862 || offset + Self::WRITE_SIZE == offset + bytes.len()
863 {
864 let (page, _, bank) =
866 self.translate_address(FLASH_PARAMS.flash0_addr + offset as u32)?;
867
868 self.efc_perform_command(bank, efc::fcr::FCMD_AW::WP, page)?;
869 }
870 }
871
872 Ok(())
873 } else {
874 Err(EfcError::Unaligned)
875 }
876 }
877}
878
879#[derive(Debug, defmt::Format)]
880pub enum EfcError {
881 Unaligned,
883 CommandError,
885 LockError,
887 FlashError,
889 AddressBoundsError,
891 UnsupportedCommandError,
893 InvalidGpnvmBitError,
895 InvalidBufferSizeError,
897 InvalidUserSignatureSizeError,
899 NotWithinFlashPageBoundsError,
901 InvalidFlashBank,
903}
904
905impl NorFlashError for EfcError {
906 fn kind(&self) -> NorFlashErrorKind {
907 match self {
908 EfcError::AddressBoundsError => NorFlashErrorKind::OutOfBounds,
909 EfcError::CommandError => NorFlashErrorKind::Other,
910 EfcError::FlashError => NorFlashErrorKind::Other,
911 EfcError::InvalidBufferSizeError => NorFlashErrorKind::Other,
912 EfcError::InvalidFlashBank => NorFlashErrorKind::Other,
913 EfcError::InvalidGpnvmBitError => NorFlashErrorKind::Other,
914 EfcError::InvalidUserSignatureSizeError => NorFlashErrorKind::Other,
915 EfcError::LockError => NorFlashErrorKind::Other,
916 EfcError::NotWithinFlashPageBoundsError => NorFlashErrorKind::Other,
917 EfcError::Unaligned => NorFlashErrorKind::NotAligned,
918 EfcError::UnsupportedCommandError => NorFlashErrorKind::Other,
919 }
920 }
921}