@@ -116,12 +116,12 @@ bool eraseBootCommandBlock(void) {
116116  return  1 ;
117117}
118118
119- uint32_t  eboot_command_read_from_flash (void )
119+ uint32_t  eboot_command_read_from_flash (eboot_flash_command_t  *cmd )
120120{
121121    eboot_index_t  eboot_index;
122122    eboot_flash_command_t  *flash_command;
123123    uint32_t  i;
124- //      const uint32_t dw_count = sizeof(struct eboot_command) / sizeof(uint32_t);
124+    const  uint32_t  dw_count = sizeof (struct  eboot_command ) / sizeof (uint32_t );
125125
126126    if  (!eboot_read_flash_index (&eboot_index)) {
127127        return  0 ;
@@ -131,11 +131,11 @@ uint32_t eboot_command_read_from_flash(void)
131131            if  (((flash_command->flags  & EBOOT_CMD_FLAG_SLOT_FREE) == 0 ) &&
132132                ((flash_command->flags  & EBOOT_CMD_FLAG_PENDING) == EBOOT_CMD_FLAG_PENDING)) {
133133                //  This is a valid command waiting to be actioned, or should be. The CRC check will determine if it's actually valid
134-                 //   uint32_t* dst = (uint32_t *) cmd;
135-                 //   uint32_t* src = (uint32_t *) flash_command->cmd;
136-                 //   for (uint32_t i = 0; i < dw_count; ++i) {
137-                 //       dst[i] = src[i];
138-                 //   }
134+                 uint32_t * dst = (uint32_t  *) cmd;
135+                 uint32_t * src = (uint32_t  *) &( flash_command->cmd ) ;
136+                 for  (uint32_t  i = 0 ; i < dw_count; ++i) {
137+                     dst[i] = src[i];
138+                 }
139139                return  1 ;
140140            }
141141        }
@@ -158,7 +158,9 @@ uint32_t eboot_command_write_to_flash(struct eboot_command *cmd)
158158        } else  {
159159            ets_printf (" Read bootCommand %d, flags: %x\n " flags );
160160            if  (((flash_command.flags  & EBOOT_CMD_FLAG_SLOT_FREE) == EBOOT_CMD_FLAG_SLOT_FREE) &&
161-                 ((flash_command.flags  & EBOOT_CMD_FLAG_PENDING) == EBOOT_CMD_FLAG_PENDING)) {
161+                 ((flash_command.flags  & EBOOT_CMD_FLAG_PENDING) == EBOOT_CMD_FLAG_PENDING) && 
162+                 (flash_command.cmd .magic  == 0 )
163+                 ) {
162164                target_command_slot = i;
163165                break ;
164166            }
0 commit comments