OLED show text in bootloader

Hello,

SDK17.2, nRF52840, Keil5, SIP cannect to a OLED, 

now, i want to OLED show text "DFUing" in the bootloader, 

when no app,   bootloader can show text in OLED, but Reset button will can't restart,no logs output,

breakdown or Flash memory is damaged?

if remove the line of nrf_drv_spi_init, Reset button will no show text and can got logs output.

int main(void)
{
    uint32_t ret_val;

    // Must happen before flash protection is applied, since it edits a protected page.
    nrf_bootloader_mbr_addrs_populate();

    // Protect MBR and bootloader code from being overwritten.
    ret_val = nrf_bootloader_flash_protect(0, MBR_SIZE);
    APP_ERROR_CHECK(ret_val);
    ret_val = nrf_bootloader_flash_protect(BOOTLOADER_START_ADDR, BOOTLOADER_SIZE);
    APP_ERROR_CHECK(ret_val);

    (void) NRF_LOG_INIT(nrf_bootloader_dfu_timer_counter_get);
    NRF_LOG_DEFAULT_BACKENDS_INIT();

    NRF_LOG_INFO("Inside main");
	
		nrf_gpio_cfg_output(0x24);	//
		nrf_gpio_pin_set(0x24);		//pull high
		//nrf_gpio_pin_clear(0x24);	//pull low

		nrf_gpio_cfg_output(0x20);	//
		nrf_gpio_pin_set(0x20);		//pull high
		//nrf_gpio_pin_clear(0x20);	//pull low
		
		OLED_Init();

    ret_val = nrf_bootloader_init(dfu_observer);
    APP_ERROR_CHECK(ret_val);

    NRF_LOG_FLUSH();

    NRF_LOG_ERROR("After main, should never be reached.");
    NRF_LOG_FLUSH();

    APP_ERROR_CHECK_BOOL(false);
}

static const nrf_drv_spi_t spi = NRF_DRV_SPI_INSTANCE(2);  /**< SPI instance. */
void OLED_Init(void)
{
	nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG;
	spi_config.frequency    = NRF_DRV_SPI_FREQ_500K,
	spi_config.ss_pin   = 0xFF;
	spi_config.miso_pin = spi_miso_pin;
	spi_config.mosi_pin = spi_mosi_pin;
	spi_config.sck_pin  = spi_sck_pin;
	
	APP_ERROR_CHECK(nrf_drv_spi_init(&spi, &spi_config, spi_event_handler, NULL));
}

IROM1 size change 0xD000 to 0xE000,

button restart logs

00> <info> app: Inside main
00> 
00> <debug> app: In nrf_bootloader_init
00> 
00> <debug> nrf_dfu_settings: Calling nrf_dfu_settings_init()...
00> 
00> <debug> nrf_dfu_flash: Initializing nrf_fstorage_nvmc backend.
00> 
00> <debug> nrf_dfu_settings: Using settings page.
00> 
00> <debug> nrf_dfu_settings: Destination settings are identical to source, write not needed. Skipping.
00> 
00> <info> nrf_dfu_settings: Backing up settings page to address 0xFE000.
00> 
00> <debug> nrf_dfu_settings: Writing settings...
00> 
00> <debug> nrf_dfu_settings: Erasing old settings at: 0x000FE000
00> 
00> <debug> nrf_dfu_flash: nrf_fstorage_erase(addr=0x0x000FE000, len=1 pages), queue usage: 0
00> 
00> <debug> nrf_dfu_flash: Flash erase success: addr=0x000FE000, pending 0
00> 
00> <debug> nrf_dfu_flash: nrf_fstorage_write(addr=0x000FE000, src=0x2000982C, len=896 bytes), queue usage: 1
00> 
00> <debug> nrf_dfu_flash: Flash write success: addr=0x000FE000, pending 0
00> 
00> <debug> app: Enter nrf_bootloader_fw_activate
00> 
00> <info> app: No firmware to activate.
00> 
00> <debug> app: nrf_bootloader_fw_activate   0
00> 
00> <info> app: *Boot validation failed. No valid app to boot.
00> 
00> <debug> app: DFU mode because app is not valid.
00> 
00> <info> nrf_bootloader_wdt: WDT is not enabled
00> 
00> <debug> app: in weak nrf_dfu_init_user
00> 
00> <debug> app: timer_stop (0x20006DEC)
00> 
00> <debug> app: timer_activate (0x20006DEC)
00> 
00> <info> app: Entering DFU mode.
00> 
00> <debug> app: Initializing transports (found: 1)
00> 
00> <debug> nrf_dfu_ble: Initializing BLE DFU transport
00> 
00> <debug> nrf_dfu_ble: Setting up vector table: 0x000F1000
00> 
00> <debug> nrf_dfu_ble: Enabling SoftDevice.
00> 
00> <debug> nrf_dfu_ble: Configuring BLE stack.
00> 
00> <debug> nrf_dfu_ble: Enabling the BLE stack.
00> 
00> <debug> nrf_dfu_ble: No advertising name found
00> 
00> <debug> nrf_dfu_ble: Using default advertising name
00> 
00> <debug> nrf_dfu_ble: Advertising...
00> 
00> <debug> nrf_dfu_ble: BLE DFU transport initialized.
00> 
00> <debug> nrf_dfu_flash: Initializing nrf_fstorage_sd backend.
00> 
00> <debug> app: Enter main loop

    

Best regards

Parents
  • Hi,

    Which pins do you use for SPI? Do any of these overlap with the RESET pin for the nRF52840?

    when no app,   bootloader can show text in OLED, but Reset button will can't restart,no logs output,

    breakdown or Flash memory is damaged?

    if remove the line of nrf_drv_spi_init, Reset button will no show text and can got logs output.

    The reset button should normally not be affected by what is running on the chip, as this is enabled in UICR, either during programming or by the application). Once it is enabled, it will be enabled until UICR is erased.

    How do you know that the reset button is not working? Could it be an error in your bootloader code causing it to be stuck in a reset loop?

    Best regards,
    Jørgen

  • Hi,

    thanks for reply,

    the spi pins is follow,it work well in app.

    no pin  of these overlap with the RESET pin for the nRF52840;

    #define spi_miso_pin 23
    #define spi_mosi_pin 20
    #define spi_sck_pin 19

       

    How do you know that the reset button is not working?

    because RTT no logs output when button reset;

          

    After a night's effort, i find the problem is Font array is too large. 

    i set array minimization, it can button reset, and all work well.

        

    large array in app work well,  but in bootloader will  destroy flash memory?

    or need set larger IRAM1 size. the max IRAM1 size is?

      

    Best regards

Reply
  • Hi,

    thanks for reply,

    the spi pins is follow,it work well in app.

    no pin  of these overlap with the RESET pin for the nRF52840;

    #define spi_miso_pin 23
    #define spi_mosi_pin 20
    #define spi_sck_pin 19

       

    How do you know that the reset button is not working?

    because RTT no logs output when button reset;

          

    After a night's effort, i find the problem is Font array is too large. 

    i set array minimization, it can button reset, and all work well.

        

    large array in app work well,  but in bootloader will  destroy flash memory?

    or need set larger IRAM1 size. the max IRAM1 size is?

      

    Best regards

Children
No Data
Related