Open pavanshah2001 opened 3 years ago
show your modified SDU source SDUBoot.ino
`#include <SerialFlash.h>
#include <FlashStorage.h>
#define SDU_START 0x2000
#define SDU_SIZE 0x6000
#define SKETCH_START (uint32_t*)(SDU_START + SDU_SIZE)
//#ifndef SDCARD_SS_PIN
//#define SDCARD_SS_PIN 4
//#endif
#define UPDATE_FILE "UPDATE.BIN"
FlashClass flash;
// Initialize C library
extern "C" void __libc_init_array(void);
int main() {
init();
__libc_init_array();
delay(1);
if (SerialFlash.begin(SS1) && SerialFlash.exists(UPDATE_FILE)) {
SerialFlashFile updateFile = SerialFlash.open(UPDATE_FILE);
uint32_t updateSize = updateFile.size();
bool updateFlashed = false;
pinMode(13,OUTPUT);
if (updateSize > SDU_SIZE) {
// skip the SDU section
updateFile.seek(SDU_SIZE);
updateSize -= SDU_SIZE;
digitalWrite(13,0);
uint32_t flashAddress = (uint32_t)SKETCH_START;
// erase the pages
flash.erase((void*)flashAddress, updateSize);
uint8_t buffer[512];
// write the pages
for (uint32_t i = 0; i < updateSize; i += sizeof(buffer)) {
updateFile.read(buffer, sizeof(buffer));
flash.write((void*)flashAddress, buffer, sizeof(buffer));
flashAddress += sizeof(buffer);
digitalWrite(13,1);
}
updateFlashed = true;
}
updateFile.close();
if (updateFlashed) {
SerialFlash.remove(UPDATE_FILE);
}
}
// jump to the sketch
__set_MSP(*SKETCH_START);
//Reset vector table address
SCB->VTOR = ((uint32_t)(SKETCH_START) & SCB_VTOR_TBLOFF_Msk);
// address of Reset_Handler is written by the linker at the beginning of the .text section (see linker script)
uint32_t resetHandlerAddress = (uint32_t) * (SKETCH_START + 1);
// jump to reset handler
asm("bx %0"::"r"(resetHandlerAddress));
}
Hi @jandrassy Above is modified file. The compile size is more than 16kb, and i have alotted sdu size as 0x6000 instead of 0x4000 Is that an issue, respective changes were done in SDU.cpp file
doesn't the Adafruit M0 have the M0 bootloader, which is 0x4000 bytes large? do you upload with bossac or with avrdude? the M0 bootloader uses avrdude as fake Mega.
Hi,
adafruit feather m0 express has 8 kB bootlooader space, hence the offset 0x2000. using bossac.
Does the SDU size affect the process? is it limited to 16k?
has flash_with_bootloader.ld
in variants
KEEP(*(.sketch_boot))
. = ALIGN(0x2000);
?
Yes I added that.
did you see the SFU library?
Hi, i'm using adafruit feather m0 express and have done following things till now 1) I modified the SDUBoot file for the above board. 2) Then compiled binary for that, and created hex dump of it. 3) Saved this hexdump in .h file and file and stored at location /boot/myboard.h 4) Then modified the SDU.cpp file to accept this .h file. 5) Everything compiles well no errors. 6) On my board the SDU .h works, as i have included an LED to see the flash loop is working or not, So it modifies my flash and deletes the UPDATE.bin( this is confirmed).
Although after everything is done, i dont see the output of my updated bin file, rather the board stops working and not detected as port and i have to reset the feather bootloader by double clicking the reset button.
Can anybody help me with where im going wrong, I can provide any further details as required.