OTA flash types for MySensors


  • Contest Winner

    @Gulpman @hek
    Hello everybody,
    I just added a pullrequest which will support SST25 Series flash for OTA Bootloader:
    https://github.com/mysensors/Arduino/pull/445

    SST25 Series flash mentioned by Gulpman as 1st and 2nd Alternative are currently not supported, because the dont support pagewriting with opcode 0x02. Instead they support Automatic Address Increment Word writing (opcode 0xAD). I updated teh SPIFlash.cpp and .h so they will take care of that if #define MY_SPIFLASH_SST25TYPE is set somewhere.
    I tested with this SPI Flash: http://www.reichelt.de/25PF020B80-4C-S/3/index.html?&ACTION=3&LA=446&ARTICLE=137365&artnr=25PF020B80-4C-S&SEARCH=25pf020b80 which is of Type SST25PF020B-80-4C-SAE (2MBit) and working now.

    I only hat a short look at the ISSI and Winbond flash Datasheets mentioned by Gulpman before. At first look I think they both could work with the current Mysensors / SPIFlash Version becuase they support Pagewriting with opcode 0x02 and seem to implement the other relevant opcodes. However I did not test..!

    Best Regards
    DirkH / D-H-R πŸ™‚

    -edited on 2016-06-01 to take care of changed Name for define (added "MY_")


  • Admin

    @Dirk_H

    Did you test the SST25 together with DualOptiboot? Or is it only the writing from library that is tested?


  • Contest Winner

    @tbowmo
    I tested the complete chain with SST25. I.e. I prepared two sketches and uploaded them via OTA with MYSController and checked that the sketch changed via presentation Message.

    Dual Optiboot does not need modification because AFAIK it only reads from Flash, which works the same way for SST and other Flash Types.


  • Contest Winner

    I am new in this thread. But I think it may be worth using spi jedec flash in my latest hardware projects (insertable socket and insertable switch). So it will key to the future πŸ™‚
    What about atmel AT26DF series(4/8mb)? It's compartible with AT25DF series pin to pin.


  • Admin

    @Dirk_H

    I think that DualOptiboot is writing to the external flash, after a successful upgrade of the internal flash, as it tries to delete the image stored there.

    But I haven't looked that much into the design of dualoptiboot.. Just forked it, and adjusted bits here and there, to be suitable for the sensebender πŸ™‚ So I don't know what commands it uses to erase the data.


  • Contest Winner

    @tbowmo
    I looked at the defines inside the DualOptibootloader, I truly hope that there is no "hardcoded" opcode hidden somewhere... Assuming this, dualoptiboot does not write to the SPIFlash. It does erase, however thats not writing in this scope πŸ˜‰

    #define SPIFLASH_STATUSWRITE      0x01        // write status register
    #define SPIFLASH_STATUSREAD       0x05        // read status register
    #define SPIFLASH_WRITEENABLE      0x06        // write enable
    #define SPIFLASH_ARRAYREADLOWFREQ 0x03        // read array (low frequency)
    #define SPIFLASH_BLOCKERASE_32K   0x52        // erase one 32K block of flash memory
    #define SPIFLASH_BLOCKERASE_64K   0xD8        // erase one 32K block of flash memory
    #define SPIFLASH_JEDECID          0x9F        // read JEDEC ID
    

    @Koresh please post a link to the datasheet. You can also check on your own: check if your spi-flash supports all commands listed in the SPIFlash.h defines. Of cause obvious things such as pinning and supply voltage range must also be checked.

    A caveeat I fell into, was that opcode 0x02 supports byte and pageprogramming for some SPI-Flash types but not for all (e.g. SST25 does not support pageprogramming but therefore has the AAI Wordprogramming feature).


  • Hardware Contributor

    interesting..on my side I like the AT25DF512 for its voltage range 1.65v min and its low power mode 0.2uA in deepest mode. better for low power batt nodes I think..too bad there is not something like this in i2c format but I guess these flash types prefer faster spi transfer..


  • Contest Winner

    Yes the AT25DF512 seems to outperform other memories and is truly a good chip. However unfortunately its hard to get in Germany (and maybe other parts of the world πŸ˜‰ ). The common distributors here do not have it in stock...


  • Hero Member

    @Dirk_H said:

    AT25DF512
    Hard for me to determine but is this different from AT25F512N?


  • Contest Winner

    @AWI
    The AT25F512 (from Atmel?) is quiet different from the Adesto AT25DF512. As far as I can see the Atmel one seems not to have a Block erase command (32k/64k), which is used in MySensor AND in Bootloader code.

    If I'm not wrong with that assumption (and I dont think I am), I would NOT recommend to use the Atmel AT25F512.

    To all: please provide links to the Datasheet if you expect help... Its tedious to search them every time. Gulpman did great preparation work in his post above.

    Edit: Never mind what I said in this Post. I got confused with sectors pages and blocks πŸ‘€ ... I'll write some more later.


  • Admin

    @Dirk_H

    It seems that atmel is calling it "Sector erase" instead of "Block erase".



  • Hi I just wonder if this Spansion, S25FL208K0RMFI040 could be used?

    http://www.mouser.com/ds/2/100/S25FL208K_00-933907.pdf


  • Contest Winner

    About the AT25F512N wich was proposed by @AWI: tbowmo was right, I got confused by Sector, Page and Block erase. Like tbowmo said atmel does call blocks sectors... The AT25F512 does not support Block Erase 64k, which is defined but AFAIK not used in SPIFlash.cpp BUT it is used in the Bootloader if the "Imagesize" is > 32k. But I dont know how Image size is retrieved. Also I think for an ATMega 328p the image size should never be >32k. So this Flashtype could probably work as long as the image size is below 32k. I'd expect the Bootloader to crash or fail when program size is >32k.

    About the S25FL... @bjacobse proposed I see the problem that it does not support the Bock Erase 32k opcode which is used in SPIFlash.cpp and Bootloader. Both must be changed when S25FL... should be used. (I would emulate the 32k Block erase by 8 times 4k Block erase.) However remember that Dualoptiboot must also be altered which requires "non-arduino" programming and some work / knowlegde about makefiles / compiler/linker settings in IDE.



  • @Dirk_H
    Thank you Dirk for checking the flash I asked about. I have noticed that the company I'm working is using this device. And then I hoped I could buy it from the company to a hopefully reduced price compared to retail price for private.


  • Hardware Contributor

    Hey, guys I am currently looking for a (cheap) solution for OTA available in germany. I wanted to use the AT25DF512C-SSHN-B but the only source I could find was aliexpress which only sells 150 pcs at a time (a little too much, although future proof for me I guess πŸ˜‰ ).
    I did not really understand this thread so far: is there another model that works with my sensors?

    Or do you by chance know a place where I can get some of the AT25DF512C-SSHN-B ones here in europe? Thanks!


  • Hardware Contributor

    @LastSamurai said:

    AT25DF512C

    Well not in EU, but you can order from DigiKey or Mouser if everything else fails - thats where I order my parts.

    EDIT: And I live in DK - maybe worth mentioning.

    BR Jonas


  • Hardware Contributor

    @LastSamurai said:

    AT25DF512C-SSHN-B

    Thanks, but both have shipping costs of abount 20€ (if you pay <50€ overall). Or is there a way around it?

    I also found SST25VF020B‑80‑4I‑SAE and 25VF512A33-4C-SA flash modules in german stores though. Would they work too?


  • Hardware Contributor

    @LastSamurai Yes, thats true. My order is always above the "free shipping" limit πŸ™‚
    I'll give the datasheets a look, of the devices you mentioned.

    BR Jonas


  • Contest Winner

    @LastSamurai The SST25VF020B... should work fine with the 2.0 developversion and #define MY_SPIFLASH_SST25TYPE set. It seems to be very close to the SST25PF020B I used. However keep an eye on the even more limited voltage range of the SST25VF Type which needs at least 2,7V which would be a problem if you want to power your circuit directly by 2xNiMH Batteries.

    The SST25VF512 needs also 2,7V but additionally does not support the 64k erase command (see my comments on that issue some posts above where I wrote something about the AT25F512).



  • Hi all,

    A question, why don't use an EPPROM SPI 25AA020A or 25AA512?

    They works between 1.8 and 5.5V.

    BR
    Xavier



  • I have AT25512N-SH-T SOIC-8 -> http://www.mouser.com/ds/2/36/Atmel-5165-SEEPROM-AT25512-Datasheet-476711.pdf

    Anyone knows if it is fully interchangeable with AT25DF512C? I cannot see any difference from the datasheet. The pinout is the same.



  • Hi all,

    Any news with the EEPROM compatibility and the new Mysensors version 2.0?

    BR,
    Xavier


  • Admin

    @XavTroniC

    It's the bootloader that sets the limit on which flash / eeprom you can use, not the library. So the support in 2.0.0 is the same as for 1.5.x


  • Hardware Contributor

    Hello,

    Would AT45DB041E be a good choice as a OTA flash? I see it's in the schematics for the new Sensebender Micro mk2.

    https://www.adestotech.com/wp-content/uploads/doc8783.pdf

    BR
    Martin


  • Admin

    @mardah

    I can't remember if I just dumped components in there at the moment, or if I actually looked at the datasheets πŸ™‚



  • @XavTroniC said in OTA flash types for MySensors:

    25AA512

    Seems these are only 2K in size.
    I would like something similar though!


  • Admin

    @shabba

    It's a 512kbit device, which is 64 kbytes


  • Hardware Contributor

    @mardah said in OTA flash types for MySensors:

    Would AT45DB041E be a good choice as a OTA flash? I see it's in the schematics for the new Sensebender Micro mk2.

    Did you ever figure out if this works with Optiboot for OTA flashing?

    I must admit that i'm very confused at this thread, it was setup to advise of other Flash IC's for us to use but there seems to be no 'solid' alternatives that you guys have suggested. For me, living in the UK, its near impossible to grab any of the AT25DF512C-SSHN-B without paying through the roof for shipping.

    I can see that AT45DB041E is JEDEC compliant but that is as far as i can go with knowing if it will work. Flash architecture is way out of my depth right now.


  • Contest Winner

    @Samuel235 said in OTA flash types for MySensors:

    AT45DB041E

    Hello. This chip (AT45DB041E) has no erase 32kb command (0x52), status read command has a strange opcode too (D7h). So it is no trivial task to use this chip.
    I can suggest Micron M25P40 as widespread IC. But it requires one trick and I will try to describe it. This chip has no erase 32kb command (0x52) too. It means OTA code will not erase memory and update will be failed. We (me and Yury) bumped into this problem when we started intensive tests of my nodes before production (we use micron M25P40). Moreover, when I try to investigate inexpensive avaliable chips I find an interesting thing. Chips with 64kb erase option (0xD8 opcode) are more common than chips with 32kb erase option (which support 64kb erase option too). So it can be worth adapting mysensors for use of any flash chip which supports 64kb erase option. To adapt your sketches you should do only two things

    1. Add this code into your sketch after including mysensors.h
    #define SPIFLASH_BLOCKERASE_32K   0xD8
    

    So OTA library will call erase 64kb command instead of erase 32kb command. It is very easy.

    1. You should use Bootloader which calls erase 64kb command instead of 32kb command.
      Bad news. It is not an easy task and you should recompile dual optiboot and burn it. 😧
      Good news. I've recompliled dual optiboot and all my nodes will burn with it by default. πŸ˜‹

    My changes in bootloader are very simple but it sutable for my boards. We update it many many times and the process is absolutely bulletproof (especially after Tekka's update πŸ‘ ).
    But how about a more universal solution? I think it is not too hard to modify dual optiboot to check flash first 10 bytes (OTA flag) after 32kb erase command call and try another command? I will try this idea later but may be someone will do it faster πŸ˜ƒ


  • Hardware Contributor

    @Koresh - Thank you for explaining this to me. I think i understand this a little more clearly now. Like i said, i've never dealt with flash so its all a grey area for myself.

    I'm currently looking at recompiling MYSBootloader for use with an 8Mhz crystal instead of this work around. The whole reasoning behind me asking this question is simply because i wanted OTA updates on a battery powered node. Now, this means i need OTA updates on 3.3v, but my MYSBootloader nodes require 16Mhz crystal to work. So its either use 16Mhz on 3.3v (while it works, its not the correct solution) OR to get a bootloader working with an 8Mhz crystal setup. I chose the later, and therefor its either recompile MYSBootloader to work with 8Mhz OR to get a flash IC on the board to allow for Dual Optiboot.

    At the moment i'm toying with the idea of going the software issue route and attempting to recompile MYSBootloader for 8Mhz (just need to workout what to change for the recompiled version). Seems a little easier and cheaper than going the route of flash considering my location and not being able to get my hands on the recommended/mostly used flash IC.



  • @Koresh what about Winbond W25X40CLSNIG - the same used by Moteino? It seems to me this could be a good match?

    https://www.winbond.com/resource-files/w25x40cl_e01.pdf

    @tbowmo Thomas, what do you think?


  • Contest Winner

    @alexsh1 It seems suitable at first sight πŸ˜‰



  • @Koresh I have just tried it and it works nicely.

    Start...Init OK!
    DeviceID: EF30
    Flash content:
    FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.
    
    WriteByte(1)
    WriteByte(2)
    WriteByte(3)
    WriteByte(4)
    WriteByte(5)Flash content:
    FF.BB.BB.BB.AA.BB.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.FF.
    Erasing Flash chip ... DONE
    

    The only disadvantage to me is voltage given that nrf24l01+ can run down to 1.9V

    Features

    • 2.3V to 3.6V supply
    • 1mA active current,
    • <1ΞΌA Power-down

    Aliexpress: $0.25 a piece + postage ($2.50 to Europe)



  • I found the following one which is now offered in a breakout board.

    http://www.ebay.es/itm/2Pcs-W25q32b-Module-De-Memoire-Haute-Capacite-Module-De-Memoire-Interface-Spi-W-/132248126492?hash=item1eca9a441c:g:EukAAOSw4GVYI2CY

    I read the datasheet and compared the characteristics and instruction set with the ones for W25X40CLSNIG. I also checked against the SPIFlash.h file in github.

    Datasheet: http://www.elinux.org/images/f/f5/Winbond-w25q32.pdf

    To me everything seems consistent and am planning to order one to check. Does anyone see something what might prevent it from working?

    I'll report on what I find - it will be in some weeks since the delivery time is long.


  • Mod

    What do you think would be the best solution to fit a flash chip on the easypcb board?


  • Hardware Contributor



  • @Nca78 Thanks for the hint. I actually purchased from this seller who is chaper:

    http://www.ebay.es/itm/Module-De-Memoire-Dinterface-1Pcs-Spi-W25q32b-Haute-Capacite-Ic-Nouveau-K-/162656857086?hash=item25df1aabfe:g:1Z8AAOSwSblZqs0q

    While the ebay seller shipped for free, Aliexpress would charge me 1.24€ for shipping to my country so the total price would be 2.63, significantly more expensive.

    Many thanks anyways!


  • Hardware Contributor

    @gohan said in OTA flash types for MySensors:

    What do you think would be the best solution to fit a flash chip on the easypcb board?

    The best solution IMHO is to use MYSBootloader so you don't need a flash chip πŸ˜‰


  • Mod

    @Nca78 I thought about that, but there are quite some limitations like no encryption and signing support


  • Contest Winner

    @gohan I do believe mysbooloader has signing support.


  • Mod

    @Anticimex does it? How about encryption?


  • Contest Winner

    @gohan not sure. Better ask the author of the bootloader for that. Ping @tekka


  • Hardware Contributor

    also note:
    so far MysBootloader is available for nrf24 only.
    And for rfm69 FOTA, it's dualoptiboot bootloader based (from Lowpowerlab) which needs a flash ic.
    It has been answered by tekka in another thread, but I don't think there is an eta for rfm69 MysBootloader yet..as the todolist isn't short !


  • Plugin Developer

    @manutremo said in OTA flash types for MySensors:

    @Nca78 Thanks for the hint. I actually purchased from this seller who is chaper:

    @manutremo I am getting trouble with W25Q32B. Can you help me to get success? I am struggling to get jedec id for this chip.

    UPDATE: I included the following lines on the sketch it works,

    //Enable OTA feature
    #define MY_OTA_FIRMWARE_FEATURE
    #define MY_OTA_FLASH_JDECID 0x00
    


  • @jkandasa happy to see that you solved it. In case it matters, I didn't need to add the second line.



  • Hi, old thread but I hope a question not too far off the mark. I'm using Easy PCB nodes and looking to use OTA on the reverse side. I'm having some issues finding a source in Australia for the SPI chip mentioned, I am seeing this one very easily available. From the data sheet on the page, it appears to be pretty much the same, just the lower end of the acceptable voltage is up to 2.6V. Any thoughts welcome if you can see if it would/wouldn't work, my tech knowledge is limited on this sort of thing.

    https://au.rs-online.com/web/p/flash-memory/8228477

    Cheers!


  • Hardware Contributor

    @p359 - not really good at these external flash either... but as you said its a 2.8-3.6v chip meaning you limit the EasyPCB to a regulated 3.3v 8mhz Pro mini. Battery operations will be hard to achieve (not impossible though). But since you are aiming for OTA i guess you wont be using sleep/battery.

    for how to write to the chip, im not the person to ask/answer since this is quite new to me but it seems like a fair price so maybe worth a shot.


  • Mod

    It is possible to use battery, just use smartsleep instead of sleep to allow a little extra time for the controller to send the OTA update command and you can also use LiFePO4 batteries that work exactly in that voltage range.



  • @sundberg84 you raise an obvious point about upper voltage that I'd overlooked to to be honest. I'll make a 3.3v node up to test when the chips arrive to test. If it works, perhaps try to use on 5v node with a shifter. Will report back if they work or not. I see also in the code now, reference to using i2c eeproms. Plenty of options to try. Thanks



  • Not making too much headway with this. Chips arrived, soldered on the the reverse side of the easypcb. Not able to get any sign of the flash being seen. One odd thing, the physical solder pad for the flash chip, pin 6 on my boards isn't connected to sck of the arduino pin 13 at all, just a bare solder pad. I've bridged this with wire, still no luck. Hmmmm...! More experiments ahead, good fun!


 

310
Online

8.2k
Users

9.0k
Topics

96.0k
Posts