Agree, it could be merged in some base file. But of course adding tons of #ifdefs inside a single file makes things hard to follow, see the arch/arm/src/stm32/ to see that!
Using #ifdefs at top of the file just to include the files with only the functions that are different is better. BR, Alan On Thu, Dec 28, 2023 at 4:26 PM Bernd Walter <ti...@cicely7.cicely.de> wrote: > On Thu, Dec 28, 2023 at 06:22:05PM +0000, Tim Hardisty wrote: > > Code size? > > Hardly an argument when the basic read and write is the same code and the > remaining could be under #ifdef. > On the other hand there is a lot of bloated code if a board could > be populated with two a more different chips. > > > > On 28 Dec 2023, at 17:11, Bernd Walter <ti...@cicely7.cicely.de> > wrote: > > > > > > On Thu, Dec 28, 2023 at 04:46:08PM +0000, Janardhan Silwal wrote: > > >> Oh!! > > >> So that is the one you used. > > >> I did see that on the menu config, but wasn't sure if it was the one. > and I was halfway through completing the driver when I noticed that option > in menu config anyway, so I went ahead and completed the driver. > > >> Anyway it is working, so no worries there. > > >> Thanks though. > > > > > > I really wonder why the are so many *25 NOR-flash drivers to begin > with. > > > Aren't they supposed to be similar and autoprobing? > > > > > >> ________________________________ > > >> From: Tim Hardisty <timhardist...@gmail.com> > > >> Sent: Thursday, December 28, 2023 20:18 > > >> To: dev@nuttx.apache.org <dev@nuttx.apache.org> > > >> Subject: Re: LittleFS Implementation using MTD for NOR flash > > >> > > >> Device Drivers -> Memory Technology Device (MTD) Support -> SPI-based > > >> M25P/MT25Q > > >> > > >>> On 28/12/2023 14:28, Janardhan Silwal wrote: > > >>> which driver did you use? > > >>> I didn't see MT25QL SPI flash in menu config so I went ahead and > wrote one! > > >>> > > >>> Best regards, > > >>> Janardhan > > >>> ________________________________ > > >>> From: Tim Hardisty<timhardist...@gmail.com> > > >>> Sent: Thursday, December 28, 2023 19:15 > > >>> To:dev@nuttx.apache.org <dev@nuttx.apache.org> > > >>> Subject: Re: LittleFS Implementation using MTD for NOR flash > > >>> > > >>> I have only ever used NuttX "directly" with my apps running over it > > >>> rather than any other middleware or anything, so I can't answer that. > > >>> > > >>> My board has been fitted with a MT25QL01GBBB8ESF, and has worked > fine, > > >>> so your flash is most likely supported already? > > >>> > > >>> On 28/12/2023 12:12, Janardhan Silwal wrote: > > >>>> Hi, > > >>>> > > >>>> I am using MT25QL, 1Gbit series flash memory. > > >>>> > > >>>> Thanks for the template. > > >>>> Would running in this format over the middleware running over nuttx > also follow the same approach? > > >>>> > > >>>> Best Regards, > > >>>> Janardhan > > >>>> ________________________________ > > >>>> From: Tim Hardisty<timhardist...@gmail.com> > > >>>> Sent: Thursday, December 28, 2023 17:31 > > >>>> To:dev@nuttx.apache.org <dev@nuttx.apache.org> > > >>>> Subject: Re: LittleFS Implementation using MTD for NOR flash > > >>>> > > >>>> Hi, > > >>>> > > >>>> What flash are you using out of interest? > > >>>> > > >>>> But, the basic approach (in or called from your board bringup for > > >>>> example) is: > > >>>> > > >>>> > > >>>> spi_flash= sam_spibus_initialize(PORT); /* this call is arch > dependent */ > > >>>> if(!spi_flash) > > >>>> { > > >>>> /* Do something */ > > >>>> } > > >>>> #ifdefined(CONFIG_MTD_M25P) > > >>>> mtd = m25p_initialize(spi_flash, MINOR); > > >>>> #elifdefined(CONFIG_MTD_GD25) > > >>>> mtd = gd25_initialize(spi_flash, MINOR); > > >>>> #elif defined(CONFIG_MTD_YOURFLASHTYPE) > > >>>> /* etc */ > > >>>> #endif > > >>>> if(!mtd) > > >>>> { > > >>>> /* Do something */ > > >>>> } > > >>>> #ifdefined(CONFIG_FS_LITTLEFS) > > >>>> /* Mount the LittleFS file system */ > > >>>> ret = register_mtddriver("/dev/flash", mtd, 0755, NULL); > > >>>> if(ret < 0) > > >>>> { > > >>>> /* Do something */ > > >>>> } > > >>>> ret = nx_mount("/dev/flash", "/mnt/flash", "littlefs", 0, > "autoformat"); > > >>>> if(ret < 0) > > >>>> { > > >>>> /* Do something */ > > >>>> } > > >>>> > > >>>> That was a copy/paste/edit or my own code so please forgive any > typo errors! > > >>>> > > >>>> On 28/12/2023 11:19, Janardhan Silwal wrote: > > >>>>> Hi community, > > >>>>> > > >>>>> I am trying to get littlefs running on a NOR flash memory using > the MTD driver, on a STM32F4 chip. > > >>>>> > > >>>>> I had some bottlenecks in the implementation as I am an > out-and-out novice when it comes to Nuttx. > > >>>>> I have written a custom driver for the flash, which is working > with MTD, as I couldn't find the exact driver for the flash installed on > my system. > > >>>>> > > >>>>> Now I need some guidance on where to start for linking LittleFS to > MTD and the rest.. > > >>>>> > > >>>>> Best Regards, > > >>>>> Janardhan Silwal > > >>>>> > > > > > > -- > > > B.Walter <be...@bwct.de> https://www.bwct.de > > > Modbus/TCP Ethernet I/O Baugruppen, ARM basierte FreeBSD Rechner uvm. > > -- > B.Walter <be...@bwct.de> https://www.bwct.de > Modbus/TCP Ethernet I/O Baugruppen, ARM basierte FreeBSD Rechner uvm. >