step to no softdevice
This commit is contained in:
parent
27cd385c58
commit
be87aac09d
8 changed files with 23 additions and 11 deletions
|
|
@ -39,10 +39,8 @@
|
|||
*/
|
||||
#include "app_util_platform.h"
|
||||
|
||||
#ifdef SOFTDEVICE_PRESENT
|
||||
/* Global nvic state instance, required by nrf_nvic.h */
|
||||
nrf_nvic_state_t nrf_nvic_state;
|
||||
#endif
|
||||
|
||||
static uint32_t m_in_critical_region = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -52,10 +52,8 @@
|
|||
#include <stdint.h>
|
||||
#include "compiler_abstraction.h"
|
||||
#include "nrf.h"
|
||||
#ifdef SOFTDEVICE_PRESENT
|
||||
#include "nrf_soc.h"
|
||||
#include "nrf_nvic.h"
|
||||
#endif
|
||||
#include "nrf_assert.h"
|
||||
#include "app_error.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -169,7 +169,7 @@ bool bootloader_app_is_valid(uint32_t app_addr)
|
|||
// A stored crc value of 0 indicates that CRC checking is not used.
|
||||
if (p_bootloader_settings->bank_0_crc != 0)
|
||||
{
|
||||
image_crc = crc16_compute((uint8_t *)DFU_BANK_0_REGION_START,
|
||||
image_crc = crc16_compute((uint8_t *)app_addr,
|
||||
p_bootloader_settings->bank_0_size,
|
||||
NULL);
|
||||
}
|
||||
|
|
@ -375,9 +375,11 @@ static void interrupts_disable(void)
|
|||
|
||||
void bootloader_app_start(uint32_t app_addr)
|
||||
{
|
||||
#ifdef SOFTDEVICE_PRESENT
|
||||
// If the applications CRC has been checked and passed, the magic number will be written and we
|
||||
// can start the application safely.
|
||||
APP_ERROR_CHECK ( sd_softdevice_disable() );
|
||||
#endif
|
||||
|
||||
interrupts_disable();
|
||||
|
||||
|
|
@ -391,9 +393,13 @@ void bootloader_app_start(uint32_t app_addr)
|
|||
sd_mbr_command(&command);
|
||||
#endif
|
||||
|
||||
APP_ERROR_CHECK( sd_softdevice_vector_table_base_set(CODE_REGION_1_START) );
|
||||
#ifdef SOFTDEVICE_PRESENT
|
||||
APP_ERROR_CHECK( sd_softdevice_vector_table_base_set(app_addr) );
|
||||
#else
|
||||
SCB->VTOR = app_addr;
|
||||
#endif
|
||||
|
||||
bootloader_util_app_start(CODE_REGION_1_START);
|
||||
bootloader_util_app_start(app_addr);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -29,10 +29,13 @@
|
|||
#include "nrf.h"
|
||||
#include "app_util.h"
|
||||
|
||||
#define SD_MAGIC_NUMBER 0x51b1e5db
|
||||
#define SD_MAGIC_OK() (*((uint32_t*)(SOFTDEVICE_INFO_STRUCT_ADDRESS+4)) == 0x51b1e5db)
|
||||
|
||||
#define NRF_UICR_BOOT_START_ADDRESS (NRF_UICR_BASE + 0x14) /**< Register where the bootloader start address is stored in the UICR register. */
|
||||
#define NRF_UICR_MBR_PARAMS_PAGE_ADDRESS (NRF_UICR_BASE + 0x18) /**< Register where the mbr params page is stored in the UICR register. (Only in use in nRF52 MBR).*/
|
||||
|
||||
#define CODE_REGION_1_START SD_SIZE_GET(MBR_SIZE) /**< This field should correspond to the size of Code Region 0, (which is identical to Start of Code Region 1), found in UICR.CLEN0 register. This value is used for compile safety, as the linker will fail if application expands into bootloader. Runtime, the bootloader will use the value found in UICR.CLEN0. */
|
||||
#define CODE_REGION_1_START (SD_MAGIC_OK() ? SD_SIZE_GET(MBR_SIZE) : MBR_SIZE) /**< This field should correspond to the size of Code Region 0, (which is identical to Start of Code Region 1), found in UICR.CLEN0 register. This value is used for compile safety, as the linker will fail if application expands into bootloader. Runtime, the bootloader will use the value found in UICR.CLEN0. */
|
||||
#define SOFTDEVICE_REGION_START MBR_SIZE /**< This field should correspond to start address of the bootloader, found in UICR.RESERVED, 0x10001014, register. This value is used for sanity check, so the bootloader will fail immediately if this value differs from runtime value. The value is used to determine max application size for updating. */
|
||||
#define CODE_PAGE_SIZE 0x1000 /**< Size of a flash codepage. Used for size of the reserved flash space in the bootloader region. Will be runtime checked against NRF_UICR->CODEPAGESIZE to ensure the region is correct. */
|
||||
|
||||
|
|
|
|||
|
|
@ -258,9 +258,10 @@ int main(void)
|
|||
// Jump to application if valid
|
||||
if (bootloader_app_is_valid(DFU_BANK_0_REGION_START) && !bootloader_dfu_sd_in_progress())
|
||||
{
|
||||
#ifdef SOFTDEVICE_PRESENT
|
||||
// MBR must be init before start application
|
||||
if ( !sd_inited ) softdev_mbr_init();
|
||||
|
||||
#endif
|
||||
// Select a bank region to use as application region.
|
||||
// @note: Only applications running from DFU_BANK_0_REGION_START is supported.
|
||||
bootloader_app_start(DFU_BANK_0_REGION_START);
|
||||
|
|
|
|||
|
|
@ -39,8 +39,6 @@ SOFTWARE.
|
|||
|
||||
#include "dfu_types.h"
|
||||
|
||||
#define SD_MAGIC_NUMBER 0x51b1e5db
|
||||
#define SD_MAGIC_OK() (*((uint32_t*)(SOFTDEVICE_INFO_STRUCT_ADDRESS+4)) == 0x51b1e5db)
|
||||
extern bool sdRunning;
|
||||
|
||||
// All entries are little endian.
|
||||
|
|
|
|||
|
|
@ -9,7 +9,12 @@
|
|||
#define FLASH_SIZE (USER_FLASH_END-USER_FLASH_START) // Max flash size
|
||||
|
||||
// Only allow to write application TODO dynamic depending on SD size
|
||||
#ifdef SOFTDEVICE_PRESENT
|
||||
#define USER_FLASH_START 0x26000
|
||||
#else
|
||||
#define USER_FLASH_START 0x1000
|
||||
#endif
|
||||
|
||||
#define USER_FLASH_END 0xAD000 // Fat Fs start here
|
||||
|
||||
#define FLASH_PAGE_SIZE 4096
|
||||
|
|
|
|||
|
|
@ -109,11 +109,14 @@ void usb_teardown(void)
|
|||
NRF_USBD->INTENCLR = NRF_USBD->INTEN;
|
||||
|
||||
nrf_usbd_disable(NRF_USBD);
|
||||
|
||||
#if defined(SOFTDEVICE_PRESENT)
|
||||
sd_clock_hfclk_release();
|
||||
|
||||
sd_power_usbdetected_enable(false);
|
||||
sd_power_usbpwrrdy_enable(false);
|
||||
sd_power_usbremoved_enable(false);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue