- last_init_img_num++;
- if (last_init_img_num >= DELUGE_NUM_VOLUMES) {
- signal Notify.notify(SUCCESS);
- state = S_READY;
- } else {
- call SubBlockRead.read[last_init_img_num](0, &(imgDesc[last_init_img_num]), sizeof(DelugeImgDesc));
- }
+ if (imgDesc[current_image].uid != DELUGE_INVALID_UID) {
+ current_page = 0;
+ state = S_READ_CRC;
+ call SubBlockRead.read[current_image](calcCrcAddr(), ¤t_crc, sizeof(current_crc));
+ } else {
+ current_image++;
+ nextImage();
+ }
+ }
+ break;
+ case S_READ_CRC:
+ state = S_CRC;
+ if (current_page == 0) {
+ call SubBlockRead.computeCrc[current_image](calcPageAddr() + DELUGE_CRC_BLOCK_SIZE,
+ DELUGE_BYTES_PER_PAGE - DELUGE_CRC_BLOCK_SIZE, 0);
+ } else {
+ call SubBlockRead.computeCrc[current_image](calcPageAddr(), DELUGE_BYTES_PER_PAGE, 0);