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..
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:
Help needed. Thanks in advance!