Author Topic: Generic M0 SPI Flash Reprogramming  (Read 374 times)

mantonakakis

  • NewMember
  • *
  • Posts: 20
Generic M0 SPI Flash Reprogramming
« on: February 26, 2021, 06:05:33 PM »
I'm having a little trouble getting a full grasp of the Moteino M0's ability to load a new program from the flash module. We're looking to do a generic implementation (not using a RFM69), and using a similar-but-different-spec (bigger) Winbond Flash module.
Is it safe to assume that if we do the following, the Moteino M0 bootloader will handle it properly and run the new program image? (this assumes, correctly or not, that there's not some compatibility issue with the flash module itself; it's a W25Q128JVSIQ TR)
  • Write "FLXIMG:NNN:" to address 0 of the flash module where NNN is the image size
  • Write the image starting at address 11 (or address 12?)
  • *((volatile uint32_t *)(HMCRAMC0_ADDR + HMCRAMC0_SIZE - 4)) = 0xF1A507AF;
  • NVIC_SystemReset();
« Last Edit: February 26, 2021, 06:08:35 PM by mantonakakis »

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6531
  • Country: us
    • LowPowerLab
Re: Generic M0 SPI Flash Reprogramming
« Reply #1 on: February 27, 2021, 06:37:57 PM »
Yes. Byte 12 will be the start of the HEX binary.
The logic of how it all needs to be done is illustrated in uint8_t HandleWirelessHEXData().
Once you reset the bootloader takes over.
As long as the flash instruction set is the same it will work, most likely will since its the same mfg. To know you're at least doing the writing part correct start with the stock 4MBIT, then move on to your new part.

mantonakakis

  • NewMember
  • *
  • Posts: 20
Re: Generic M0 SPI Flash Reprogramming
« Reply #2 on: March 01, 2021, 12:29:33 PM »
Thanks Felix, we'll give it a try!

mantonakakis

  • NewMember
  • *
  • Posts: 20
Re: Generic M0 SPI Flash Reprogramming
« Reply #3 on: April 22, 2021, 01:20:31 PM »
It took us a little while to get it working (mostly our firmware server setup), but it does seem to work perfectly now. For a little background, we are using a cell modem for communication and were able to download the new firmware image from our remote server, save it to the flash module, and reboot with the new firmware. Thanks Felix!

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6531
  • Country: us
    • LowPowerLab
Re: Generic M0 SPI Flash Reprogramming
« Reply #4 on: April 22, 2021, 08:42:54 PM »
Awesome, good to know!