Dual Optiboot Questions ...

Started by Humancell, May 20, 2019, 07:23:45 PM

Humancell

Hello,

I'm looking at the Dual Optiboot code, and have a few questions:


  • Looking in Github, there are a number of compiled .hex files.  For both the Moteino and Moteino MEGA there are versions with "disable SPI" but I'm unable to figure out how you built these versions.  Is there an additional parameter for the MAKE command to build these?  And why would I want these vs. the version without "disable SPI"?
  • There are also some DEBUG ON and OFF versions that were built.  Same question: how did you build these?  Are there additional MAKE command parameters to turn on and off DEBUG?
  • In the Optiboot.c file, there are lines 474-484 that seem to define the pins used for the flash memory, and the HopeRF radio.  I'm guessing that the SS definition is used to ensure that the HopeRF radio is disabled during the flash copy section of code?
  • If I am also wanting to use this on a different board that I have configured using different GPIO pins for the CS on the flash memory and HopeRF radio, I'll need to add a new section to the lines listed above?  Is there anywhere else that I'll need to touch the code?
  • Being a little rusty on MAKE file editing and operation, what would you suggest as a way to pass my board name (e.g. MYBOARD) into the MAKE file to have these new lines that I add used, instead of the current lines 474-484?

I appreciate any input and suggestions, or even links where I can read more on the best way to make these changes.  I'm about to fork the project on Github, and begin to make my edits.  I'm just trying to see if there is anything else that I need to account for that I might be missing.

Thanks in advance!

Felix

I think you're mostly wondering how to use make. There are extensive tutorials online.
To your Qs:

1) - I can't remember how everything was done. I just removed the old HEXes (non SPI_disable), so now they are not suffixed with SPI Disable anymore. SPI should be disabled after bootloader is done. Take a look at this changeset for the SPI disable.

2) The debug enable disable was done by passing on "DEBUG_ON" to make. This was only used during development and disabled for production binaries. It is done with putch('') as you can see in code.

3) Correct.
4) Pin definitions are in pin_defs.h.
5) "make yourboard" but you have to add it to the makefile

Humancell

Hello,

Thank you for the reply.  I'm fairly familiar with make, and have been looking up the pieces that are unfamiliar.  Your responses are helpful in bridging some gaps.


  • I had seen that exact changeset, and was wondering how you were able to build both versions with that line being explicitly added.  Your answer cleared up my confusion.  :-)
  • I searched for how the DEBUG_ON would work via the makefile, and then found Line 496 in Optiboot.c that appears to be the toggle for the debug versions of the code?
  • In looking at this code, starting on Line 474 of Optiboot.c, you are using the processor type to set the pins for the flash memory and HopeRF radio.  Lines 475-478 are really specific to a Moteino, and lines 480-483 are really specific to a Moteino MEGA, correct?  Was there a reason you didn't use these board names as the tests on lines 474 and 479?  Again, I just want to make sure that I understand the best way/place to insert my board name into this logic.
  • I did look through pin_defs.h, but could not find any references to the flash memory pins, or the HopeRF radio pins.  The bulk was related to the LED pins of various boards.  Did I miss something here?
  • I've been reviewing the makefile, but it seems I'll have to make changes to Optiboot.c also per the lines 474-484 ... I can't figure out a way to make the changes in only the makefile.

This really is awesome code, and I'll make sure to incorporate any of your suggestions/answers and post here as I get something working.

Felix

DEBUG_ON ... yes that's the debug output toggle.
Yes, the pin defs for the SPI and atmega1284p are defined here.
You can define your own board pins if that's what you need.
The code is compilable, everything you need is already there, if you're familiar with make, spend a little time understanding the code and you should be all set.