This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Advertisement fails after writing an image(40kB) into the internal flash

Hi,

I need to store an image of size 40kB to internal flash memory. Actually i tried to store it from the address like 0x28400 and 0x2E984 (memory addresses after softdevice and bank 0 ). I am getting hard-fault error, in timer initialization itself ( fails in, is buffer word aligned). and sometimes i can write and display the images but advertisement is not happening (hard-fault in ble_stack_init) .

So how can i use the memory to store the images, without fail in advertisement.

Regards, Balaji.M

Parents
  • Thanks for the reply Morten, I cannot say that there is no accidental written of data in somewhere(how can i check?). But, as a result through readout i can only say that, the image data's are written in exact location as i programmed. If possible try to give solution using the snippets below.

    i just modified the ble_ app_alert_notification application,

    int main(void)
    {    
        leds_init();
        timers_init();
       app_timer_start(m_timer_update_id, TIMER_UPDATE_INTERVAL, NULL);
        gpiote_init();
        buttons_init();
        app_button_enable();
    
    // store and display an image before advertisement start
    
              store_image(Image_Sample_128x160, 40960);   // function to store image data in internal flash
    	  nrf_gpio_cfg_output(RST);
    	  nrf_gpio_cfg_output(RS);
    	
    	  spi_master_init(SPI0, SPI_MODE0,false);   
    	  TFT_init();
    	  TFT_Clear_Screen(WHITE);
              TFT_Putphoto();                                            // read and display the image stored in internal flash
    
        bond_manager_init();
        ble_stack_init();
        ble_error_log_init();
        gap_params_init();
        advertising_init();
        alert_notification_init();
        conn_params_init();
        sec_params_init();
        radio_notification_init();
        
        // Start execution.
        advertising_start();
    		
        // Enter main loop.
        for (;;)
        {
            power_manage();
        }
    
    }
    
    
    int store_image(const unsigned char image[], uint32_t size)     
    {  
        uint32_t *addr;  
        uint32_t i;
        uint32_t pg_size;
        uint32_t pg_num;
    	 uint32_t  image_data; 
    	    
        pg_size   = NRF_FICR->CODEPAGESIZE;
        pg_num  = NRF_FICR->CODESIZE - 65;    
       addr = (uint32_t *)(pg_size * pg_num);
    	
    	for (i=0; i<39; i++)
    	{	
    	flash_page_erase(addr+(i*pg_size));    
    	}
    	
    	for (i = 0; i<size; i+=4)  
    	{
    	image_data = (image[i+3]<<24)|(image[i+2]<<16)|(image[i+1]<<8)|(image[i]);
    		
               ////		image_data = (image[i]<<24)|(image[i+1]<<16)|(image[i+2]<<8)|(image[i+3]);
    	  flash_word_write(addr++, image_data);  
      }
        
    }
    

    If the above information is not enough i can post a regular support case as you suggest.

    Regards, Balaji

  • I've expanded my answer above with what turned out to be the problem here, so I'd be happy if you could accept it as an answer, to clear up this question.

Reply Children
No Data
Related