minimum build code for new APPROTECT is chip type-specific

This commit is contained in:
Peter Hansen 2023-12-03 13:47:26 -05:00
parent a31ae52d1a
commit dd62bb16e5
8 changed files with 10 additions and 2 deletions

View File

@ -7,6 +7,7 @@ pub const FORCE_COPY_BUFFER_SIZE: usize = 256;
pub const FLASH_SIZE: usize = 192 * 1024; pub const FLASH_SIZE: usize = 192 * 1024;
pub const RESET_PIN: u32 = 21; pub const RESET_PIN: u32 = 21;
pub const APPROTECT_MIN_BUILD_CODE: u8 = b'B';
embassy_hal_internal::peripherals! { embassy_hal_internal::peripherals! {
// RTC // RTC

View File

@ -7,6 +7,7 @@ pub const FORCE_COPY_BUFFER_SIZE: usize = 256;
pub const FLASH_SIZE: usize = 192 * 1024; pub const FLASH_SIZE: usize = 192 * 1024;
pub const RESET_PIN: u32 = 21; pub const RESET_PIN: u32 = 21;
pub const APPROTECT_MIN_BUILD_CODE: u8 = b'E';
embassy_hal_internal::peripherals! { embassy_hal_internal::peripherals! {
// RTC // RTC

View File

@ -7,6 +7,7 @@ pub const FORCE_COPY_BUFFER_SIZE: usize = 256;
pub const FLASH_SIZE: usize = 192 * 1024; pub const FLASH_SIZE: usize = 192 * 1024;
pub const RESET_PIN: u32 = 21; pub const RESET_PIN: u32 = 21;
pub const APPROTECT_MIN_BUILD_CODE: u8 = b'B';
embassy_hal_internal::peripherals! { embassy_hal_internal::peripherals! {
// RTC // RTC

View File

@ -7,6 +7,7 @@ pub const FORCE_COPY_BUFFER_SIZE: usize = 512;
pub const FLASH_SIZE: usize = 256 * 1024; pub const FLASH_SIZE: usize = 256 * 1024;
pub const RESET_PIN: u32 = 18; pub const RESET_PIN: u32 = 18;
pub const APPROTECT_MIN_BUILD_CODE: u8 = b'D';
embassy_hal_internal::peripherals! { embassy_hal_internal::peripherals! {
// USB // USB

View File

@ -11,6 +11,7 @@ pub const FORCE_COPY_BUFFER_SIZE: usize = 255;
pub const FLASH_SIZE: usize = 512 * 1024; pub const FLASH_SIZE: usize = 512 * 1024;
pub const RESET_PIN: u32 = 21; pub const RESET_PIN: u32 = 21;
pub const APPROTECT_MIN_BUILD_CODE: u8 = b'G';
embassy_hal_internal::peripherals! { embassy_hal_internal::peripherals! {
// RTC // RTC

View File

@ -7,6 +7,7 @@ pub const FORCE_COPY_BUFFER_SIZE: usize = 512;
pub const FLASH_SIZE: usize = 512 * 1024; pub const FLASH_SIZE: usize = 512 * 1024;
pub const RESET_PIN: u32 = 18; pub const RESET_PIN: u32 = 18;
pub const APPROTECT_MIN_BUILD_CODE: u8 = b'B';
embassy_hal_internal::peripherals! { embassy_hal_internal::peripherals! {
// USB // USB

View File

@ -7,6 +7,7 @@ pub const FORCE_COPY_BUFFER_SIZE: usize = 512;
pub const FLASH_SIZE: usize = 1024 * 1024; pub const FLASH_SIZE: usize = 1024 * 1024;
pub const RESET_PIN: u32 = 18; pub const RESET_PIN: u32 = 18;
pub const APPROTECT_MIN_BUILD_CODE: u8 = b'F';
embassy_hal_internal::peripherals! { embassy_hal_internal::peripherals! {
// USB // USB

View File

@ -349,10 +349,11 @@ pub fn init(config: config::Config) -> Peripherals {
// Get the letter for the build code (b'A' .. b'F') // Get the letter for the build code (b'A' .. b'F')
let build_code = (variant >> 8) as u8; let build_code = (variant >> 8) as u8;
if build_code >= b'F' { if build_code >= chip::APPROTECT_MIN_BUILD_CODE {
// Chips with build code F and higher (revision 3 and higher) have an // Chips with a certain chip type-specific build code or higher have an
// improved APPROTECT ("hardware and software controlled access port protection") // improved APPROTECT ("hardware and software controlled access port protection")
// which needs explicit action by the firmware to keep it unlocked // which needs explicit action by the firmware to keep it unlocked
// See https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/working-with-the-nrf52-series-improved-approtect
// UICR.APPROTECT = SwDisabled // UICR.APPROTECT = SwDisabled
let res = uicr_write(consts::UICR_APPROTECT, consts::APPROTECT_DISABLED); let res = uicr_write(consts::UICR_APPROTECT, consts::APPROTECT_DISABLED);