Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

tests_images, first version hardcode the CRC and length

  • Loading branch information...
commit 540f5fee3cbdb133f83ff755ed64aba3c7020f7c 1 parent b48ae83
authored July 28, 2011

Showing 1 changed file with 117 additions and 2 deletions. Show diff stats Hide diff stats

  1. 119  src/tests_images.c
119  src/tests_images.c
@@ -18,18 +18,133 @@
18 18
 #include <stdio.h>
19 19
 #include <irq.h>
20 20
 #include <console.h>
  21
+#include <string.h>
  22
+#include <crc.h>
  23
+
21 24
 #include <hw/interrupts.h>
  25
+#include <hw/hpdmc.h>
  26
+#include <hw/flash.h>
  27
+
22 28
 #include "testdefs.h"
23 29
 
24  
-static int compare_crc()
  30
+struct m1_image {
  31
+	char *name;
  32
+	unsigned int *addr;
  33
+	unsigned int crc;
  34
+	unsigned int len;
  35
+};
  36
+
  37
+static struct m1_image images[] = {
  38
+	{
  39
+		.name = "standby.fpg",
  40
+		.addr = (unsigned int *)FLASH_OFFSET_STANDBY_BITSTREAM,
  41
+		.crc = 0xc58e8905,
  42
+		.len = 495060
  43
+	},
  44
+	{
  45
+		.name = "soc-rescue.fpg",
  46
+		.addr = (unsigned int *)FLASH_OFFSET_RESCUE_BITSTREAM,
  47
+		.crc = 0x30dcc535,
  48
+		.len = 1484404
  49
+	},
  50
+	{
  51
+		.name = "bios-rescue.bin(CRC)",
  52
+		.addr = (unsigned int *)FLASH_OFFSET_RESCUE_BIOS,
  53
+		.crc = 0,
  54
+		.len = 73812
  55
+	},
  56
+	{
  57
+		.name = "splash-rescue.raw",
  58
+		.addr = (unsigned int *)FLASH_OFFSET_RESCUE_SPLASH,
  59
+		.crc = 0xe8ff824f,
  60
+		.len = 614400
  61
+	},
  62
+	{
  63
+		.name = "flickernoise.fbi(rescue)(CRC)",
  64
+		.addr = (unsigned int *)FLASH_OFFSET_RESCUE_APP,
  65
+		.crc = 0,
  66
+		.len = 0
  67
+	},
  68
+	{
  69
+		.name = "soc.fpg",
  70
+		.addr = (unsigned int *)FLASH_OFFSET_REGULAR_BITSTREAM,
  71
+		.crc = 0x3a31e737,
  72
+		.len = 1484404
  73
+	},
  74
+	{
  75
+		.name = "bios.bin(CRC)",
  76
+		.addr = (unsigned int *)FLASH_OFFSET_REGULAR_BIOS,
  77
+		.crc = 0,
  78
+		.len = (73724 - 4)
  79
+	},
  80
+	{
  81
+		.name = "splash.raw",
  82
+		.addr = (unsigned int *)FLASH_OFFSET_REGULAR_SPLASH,
  83
+		.crc = 0x978f860c,
  84
+		.len = 614400
  85
+	},
  86
+	{
  87
+		.name = "flickernoise.fbi(CRC)",
  88
+		.addr = (unsigned int *)FLASH_OFFSET_REGULAR_APP,
  89
+		.crc = 0,
  90
+		.len = 0
  91
+	},
  92
+	{
  93
+		.name = NULL
  94
+	}
  95
+};
  96
+
  97
+static int compare_crc(unsigned int *flashbase, unsigned int crc, unsigned int length)
25 98
 {
  99
+	unsigned int got_crc;
  100
+
  101
+	if(length == 0 && crc == 0) {
  102
+		length = *flashbase++;
  103
+		crc = *flashbase++;
  104
+	}
  105
+
  106
+	if(length != 0 && crc == 0)
  107
+		crc = *(flashbase + (length / 4));
  108
+
  109
+	if((length < 32) || (length > 4*1024*1024)) {
  110
+		printf("Invalid flash image length\n");
  111
+		return TEST_STATUS_FAILED;
  112
+	}
  113
+
  114
+	unsigned int membase = SDRAM_BASE + 2000000;
  115
+	memcpy((void *)membase, flashbase, length);
  116
+	got_crc = crc32((unsigned char *)membase, length);
  117
+	if(crc != got_crc) {
  118
+		printf("CRC failed (expected %08x, got %08x)\n", crc, got_crc);
  119
+		return TEST_STATUS_FAILED;
  120
+	}
  121
+
  122
+	printf("CRC passed (got %08x)\n", crc);
26 123
 	return TEST_STATUS_PASSED;
27 124
 }
28 125
 
  126
+static int compare_loop()
  127
+{
  128
+	int i, ret, result;
  129
+
  130
+	result = TEST_STATUS_PASSED;
  131
+	i = 0;
  132
+	while(images[i].name != NULL) {
  133
+		printf("  Checking : %s\t", images[i].name);
  134
+		ret = compare_crc(images[i].addr, images[i].crc, images[i].len);
  135
+		if(ret == TEST_STATUS_FAILED)
  136
+			result = TEST_STATUS_FAILED;
  137
+		i++;
  138
+	}
  139
+
  140
+	printf("\n");
  141
+	return result;
  142
+}
  143
+
29 144
 struct test_description tests_images[] = {
30 145
 	{
31 146
 		.name = "Images CRC",
32  
-		.run = compare_crc
  147
+		.run = compare_loop
33 148
 	},
34 149
 	{
35 150
 		.name = NULL

0 notes on commit 540f5fe

Please sign in to comment.
Something went wrong with that request. Please try again.