0

From last week i am working OTA system for arduino mega. I got one bootloader which flashes firmware from SD card. Here is the link of the github repository https://github.com/FleetProbe/MicroBridge-Arduino-ATMega2560/tree/master/hardware/microbridge.

As per readme file of the bootloader SD card chip select pin should be connected to digital pin 53 of arduino mega. When i define pin D53 for chip select of sd card then it working fine. Problem is that i want to change the default chip select pin of the SD card from D53 to D44.

And readme file (click here to read readme file) is saying that if you want to change CS pin from default (i.e. 53), you need to change the pinout in asmfunc.S and recompile the bootloader.

To compile bootloader, i using microchip studio command prompt and make commands. The make command are as follows:

  • make clean
  • make all.

But it gives error which i dont understand. Here is the screenshot of the command prompt.enter image description here.

Here are the things I using to complete OTA system:

  • Development board: Arduino Mega (ATMEGA 2560)
  • Programmer: AVR-ISP-MK2
  • Development IDE: Arduino IDE (version: 1.8.13)

Here is the code snippet I am using after burn bootloader:

#include <SPI.h>
#include <SD.h>
#include <avr/wdt.h>
#include "EEPROM.h"

#define sdcs 44

void setup()
{
   Serial.begin(9600);

   /*----(Initialise sd Module)-----*/
   if (!SD.begin(sdcs)) 
   {                       
      Serial.println(F("Card failed, or not present"));
   }
   else
   {
      Serial.println(F("card initialized."));
   }

   Serial.println("Press 'F' and 'enter' to set flagbit in eeprom 0x1FF to 0xF0 ");
   Serial.println("also to induce watchdog timeout which triggers the bootloader ");
   Serial.println("and flashes the new firmware on the sd card");
}
void loop()
{
   char inChar = '\0';

   while (Serial.available() > 0) 
   {
     inChar = Serial.read();
   }
   wdt_enable(WDTO_500MS); // have the wdt reset the chip

   // if 500ms passes without a reset
   if (inChar == 'F') {
   Serial.println("");
   Serial.println("rebooting and flashing with firmware.bin on sdcard");
   EEPROM.write(0x1FF, 0xF0);
   wdt_reset();
   delay(600); // wait 600ms to timeout wdt
   }
}

Below are the files present on the bootloader directory: enter image description here

Help needed. Thanks in advance!

  • How about to remove rm *.cof from the Makefile? Or create one file with cof extension there, but make shouldn't be wrote to fail on freaking cleanup – KIIV Feb 21 '21 at 16:36
  • @KIIV how to generate cof extension file. Google saying it is a common object file. The cof file format used in MPLAB. – Tushar Yadav Feb 21 '21 at 16:50
  • doesn't matter, it tries to delete that file and it doesn't exist, so whole make fails before it even started to do something useful – KIIV Feb 21 '21 at 16:58
  • You know you can copy and paste plain text from the cmd window? Pictures of text are not efficient or particularly useful, much less an image of your entire screen (Alt-PrtSc for just the window). Similarly you could copy and paste the text from a dir command rather than a screen-shot. Also the code is irrelevant; it is not the compilation the is failing, it is the `make clean`. It would be more useful to post the makefile since that is what is failing. – Clifford Feb 21 '21 at 17:02

1 Answers1

1

.cof is a type of object file, but looking at your build folder it looks like the build is creating a .elf object file rather then .cof. Modify the make file to correct the target, or perhaops run the make all to create the .cof file if that is what your tool chain is intended to produce.

That said, make clean should not fail on missing files in any case - the project might already be "clean". It is simply a means of deleting build artefacts to force a complete re-build - if those artefacts don't exist, that is not really a problem since the aim is only to delete them in any case.

Clifford
  • 88,407
  • 13
  • 85
  • 165
  • Hi Clifford, i created a .cof file and run the command **make clean**, it works. But when entered new make command **make all** it gives me the below error: ```-f was unexpected at this time. Makefile:429: recipe for target 'sizebefore' failed make: *** [sizebefore] Error 255 ``` . – Tushar Yadav Feb 22 '21 at 12:15
  • 1
    @TusharYadav How did you create the coff file if you cannot run the make? You cannot " cargo cult" this, you have to understand it. Anyway your new issue is a different issue, so you should post a new question. Without knowing what line 429 of your makefile is, it is not possible to help. It remains a toolchain/build issue - none of your tags or code are relevant at this time. – Clifford Feb 22 '21 at 12:42