Skip to content

Commit 92c0774

Browse files
sandeepmistryfacchinm
authored andcommitted
Check bitstream version before reloading, also check + reload before jumping to app
1 parent e500e2b commit 92c0774

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

bootloaders/zero/board_driver_jtag.c

+11
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,17 @@ int mbRead(uint32_t address, void* data, int len)
687687

688688
#define MB_DEV_FLASH 0x01000000
689689

690+
uint32_t jtagBitstreamVersion()
691+
{
692+
uint32_t ptr[1];
693+
uint32_t ver;
694+
695+
ptr[0] = 0 | 1;
696+
ver = mbCmdSend(ptr, 1);
697+
698+
return ver;
699+
}
700+
690701
void jtagFlashEraseBlock(uint32_t offset)
691702
{
692703
uint32_t rpc[256];

bootloaders/zero/board_driver_jtag.h

+1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ int jtagWriteBuffer(unsigned int address, const uint8_t* data, size_t len);
8080
int jtagReadBuffer(unsigned int address, uint8_t* data, size_t len);
8181
void jtagDeinit(void);
8282

83+
uint32_t jtagBitstreamVersion();
8384
void jtagFlashEraseBlock(uint32_t offset);
8485
void jtagFlashWriteBlock(uint32_t offset, size_t len, uint32_t* data);
8586
void jtagFlashReadBlock(uint32_t offset, size_t len, uint8_t* buf);

bootloaders/zero/main.c

+10-4
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,6 @@ int main(void)
180180

181181
#ifdef CONFIGURE_PMIC
182182
configure_pmic();
183-
if (jump_to_app == true) {
184-
jump_to_application();
185-
}
186183
#endif
187184

188185
#ifdef ENABLE_JTAG_LOAD
@@ -196,7 +193,16 @@ int main(void)
196193
clockout(0, 1);
197194

198195
jtagInit();
199-
jtagReload();
196+
if ((jtagBitstreamVersion() & 0xFF000000) != 0xB0000000) {
197+
// FPGA is not in the bootloader, restart it
198+
jtagReload();
199+
}
200+
#endif
201+
202+
#ifdef CONFIGURE_PMIC
203+
if (jump_to_app == true) {
204+
jump_to_application();
205+
}
200206
#endif
201207

202208
#if defined(SAM_BA_UART_ONLY) || defined(SAM_BA_BOTH_INTERFACES)

0 commit comments

Comments
 (0)