henrykotze commented on issue #17809:
URL: https://github.com/apache/nuttx/issues/17809#issuecomment-3763053966

   Yes happy to share to get this over the line:
   
   I decided to move to simple boot, as the OTA benefits we are not using. 
Simple boot was not working with the following boot message:
   ```
    rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
   configsip: 0, SPIWP:0xee
   clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
   mode:DIO, clock div:2
   load:0x3ffb5f00,len:6912
   load:0x40080000,len:32432
   entry 0x40103220
   Fatal exception (0): IllegalInstruction
   epc1=0x40103222, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00000000, 
depc=0x00000000
   ets Jul 29 2019 12:21:46 
   ```
   
   I then added the IRAM_ATTR to the __esp32_start() and __start() function, 
and then it booted succesfully.
   
   Im sharing the above as im wondering if the esp_flash operation might sit in 
the wrong memory locations? 
   
   Here is my boot sequence now:
   ```
   ets Jul 29 2019 12:21:46
   
   rst:0x3 (SW_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
   configsip: 0, SPIWP:0xee
   clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
   mode:DIO, clock div:2
   load:0x3ffb5f00,len:6912
   load:0x40080000,len:33404
   entry 0x40080fbc
   *** Booting NuttX ***
   I (143) boot: chip revision: v3.1
   I (143) boot.esp32: SPI Speed      : 40MHz
   I (143) boot.esp32: SPI Mode       : DIO
   I (146) boot.esp32: SPI Flash Size : 8MB
   I (150) boot: Enabling RNG early entropy source...
   dram: lma 0x00001020 vma 0x3ffb5f00 len 0x1b00   (6912)
   iram: lma 0x00002b28 vma 0x40080000 len 0x827c   (33404)
   padd: lma 0x0000adb8 vma 0x00000000 len 0x5240   (21056)
   imap: lma 0x00010000 vma 0x40100000 len 0x771b0  (487856)
   padd: lma 0x000871b8 vma 0x00000000 len 0x8e40   (36416)
   dmap: lma 0x00090000 vma 0x3f410000 len 0x26fd4  (159700)
   total segments stored 6
   ABDESP32 chip revision is v3.1
   Starting
   found procfs
   found binfs
   Entry
   ESP SPI Flash information:
           ID = 0x204017
           Status mask = 0xffff
           Chip size = 8192 KB
           Page size = 256 B
           Sector size = 4 KB
           Block size = 64 KB
           MTD offset = 0x180000
           MTD size = 0x10000
   esp_ioctl: 1537
   blocksize: 64 erasesize: 4096 neraseblocks: 2048
   return 0
   ```
   
   and here is my code to set up the parition:
   ```
   int esp32_spiflash_init(void)
   {
        int ret = OK;
   
   
        ret = esp_spiflash_init();
        if (ret < 0) {
                return ret;
        }
   
        ret = init_param_partition();
   
        if (ret < 0) {
                return ret;
        }
   ```
   ```
   #define CONFIG_ESP32_PARAM_MTD_OFFSET   0x180000
   #define CONFIG_ESP32_PARAM_MTD_SIZE     0x10000
   static int init_param_partition(void)
   {
        int ret = OK;
        struct mtd_dev_s *mtd;
   
        mtd = esp_spiflash_alloc_mtdpart(CONFIG_ESP32_PARAM_MTD_OFFSET,
                                           CONFIG_ESP32_PARAM_MTD_SIZE);
   
        if (!mtd) {
                ferr("ERROR: Failed to alloc PARAM MTD partition of SPI 
Flash\n");
                return -ENOMEM;
        }
   
        ret = register_mtddriver("/fs/mtd_params", mtd, 0755, NULL);
   
        if (ret < 0) {
                ferr("ERROR: Failed to register PARAM MTD: %d\n", ret);
                return ret;
        }
   
        return ret;
   }
   ```
   
   So im using a RAW mtd pointer with not filesystem. And this is also how i 
used it in PX4 on nuttx 10.3.
   
   The example spiflash also worked. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to