Permalink
Browse files

Merge branch 'master' of github.com:milkymist/autotest-m1

  • Loading branch information...
2 parents d9bee5b + 8239be0 commit 36be79a8b61049e073cdd91e4e76567e463d6c4c @sbourdeauducq sbourdeauducq committed Dec 1, 2011
Showing with 332 additions and 43 deletions.
  1. +26 −6 src/Makefile
  2. +75 −0 src/append_crc_len.sh
  3. +1 −0 src/linker.ld
  4. +14 −8 src/main.c
  5. +1 −1 src/tests_dmx.c
  6. +2 −4 src/tests_ethernet.c
  7. +129 −0 src/tests_images.c
  8. +47 −9 src/tests_ir.c
  9. +33 −11 src/tests_midi.c
  10. +2 −2 src/tests_usb.c
  11. +2 −2 src/tests_videoin.c
View
@@ -1,27 +1,47 @@
include $(MMDIR)/software/include.mak
-OBJECTS=crt0.o main.o tests_sdram.o tests_gpio.o tests_vga.o tests_memorycard.o tests_audio.o tests_ethernet.o tests_videoin.o tests_midi.o tests_dmx.o tests_ir.o tests_usb.o
-SEGMENTS=-j .text -j .data -j .rodata
+SRCS = $(wildcard *.c)
+COBJS = $(SRCS:.c=.o)
+OBJECTS = crt0.o $(COBJS)
+
+SEGMENTS= -j .text -j .data -j .rodata
+
+LDFLAGS+= -T linker.ld -N
+LDFLAGS+= -L$(MMDIR)/software/libbase -L$(MMDIR)/software/libmath -L$(MMDIR)/software/libnet -L$(MMDIR)/software/libhal
+LIBS = -lbase -lmath -lnet -lhal
+
+CFLAGS+= -DVERSION='"$(GIT_VERSION)$(GIT_STATUS)"'
+
+GIT_VERSION:=$(shell git rev-parse HEAD | cut -c 1-7)
+GIT_STATUS:=$(shell [ -z "`git status -s -uno`" ] || echo +)
+
all: boot.bin
%.bin: %.elf
- $(MAKE) -C $(MMDIR)/tools
$(OBJCOPY) $(SEGMENTS) -O binary $< $@
chmod -x $@
+ $(MAKE) -C $(MMDIR)/tools
$(MMDIR)/tools/mkmmimg $@
boot.elf: linker.ld $(OBJECTS)
- $(LD) $(LDFLAGS) -T linker.ld -N -o $@ -L$(MMDIR)/software/libbase -L$(MMDIR)/software/libmath -L$(MMDIR)/software/libnet -L$(MMDIR)/software/libhal $(OBJECTS) -lbase -lmath -lnet -lhal -lbase
+ make -C ${MMDIR}/software/libbase
+ make -C ${MMDIR}/software/libmath
+ make -C ${MMDIR}/software/libnet
+ make -C ${MMDIR}/software/libhal
+ $(LD) $(LDFLAGS) $(OBJECTS) -o $@ $(LIBS)
chmod -x $@
load: boot.bin
$(MMDIR)/tools/flterm --port /dev/ttyUSB0 --kernel boot.bin
-.PHONY: clean depend load
+.PHONY: clean depend load boot.crc.bin
+
+boot.crc.bin: boot.bin
+ IMAGES_DIR=$(IMAGES_DIR) ./append_crc_len.sh
depend:
makedepend -Y -- $(CFLAGS) -- *.c
clean:
- rm -f $(OBJECTS) boot.elf boot.bin .*~ *~ Makefile.bak
+ rm -f $(OBJECTS) boot.elf boot.bin boot.crc.*.bin .*~ *~ Makefile.bak
View
@@ -0,0 +1,75 @@
+#!/bin/bash
+
+REV=$(git rev-parse HEAD | cut -b1-7)
+BOOT_CRC_BIN="boot.crc.${REV}.bin"
+
+CRC_LEN_TMP=`mktemp`
+BOOT_BIN_TMP=`mktemp`
+
+FILENAMES=\
+standby.fpg,\
+soc-rescue.fpg,\
+bios-rescue-without-CRC.bin,\
+splash-rescue.raw,\
+flickernoise.fbi,\
+soc.fpg,\
+bios.bin,\
+splash.raw,\
+flickernoise.fbi
+
+IFS=',' FILES=( ${FILENAMES} )
+
+create_crc_len_file() {
+ CRC=`mkmmimg $1 | awk '{print $3}'`
+ LEN=`ls -l $1 | awk '{printf "%08x\n",$5}'`
+
+ if [ `basename "$1"` == "bios-rescue-without-CRC.bin" ]; then
+ CRC="00000000"
+ fi
+ if [ `basename "$1"` == "bios.bin" ]; then
+ CRC="00000000"
+ LEN=`ls -l $1 | awk '{printf "%08x\n",$5-4}'`
+ fi
+ if [ `basename "$1"` == "flickernoise.fbi" ]; then
+ CRC="00000000"
+ LEN="00000000"
+ fi
+ # 0 mean length/crc included by themself
+
+ CRC1=`echo $CRC | cut -b1-2`
+ CRC2=`echo $CRC | cut -b3-4`
+ CRC3=`echo $CRC | cut -b5-6`
+ CRC4=`echo $CRC | cut -b7-8`
+
+ LEN1=`echo $LEN | cut -b1-2`
+ LEN2=`echo $LEN | cut -b3-4`
+ LEN3=`echo $LEN | cut -b5-6`
+ LEN4=`echo $LEN | cut -b7-8`
+
+ printf "\\x$(printf "%x" 0x${CRC1})" > ${CRC_LEN_TMP}
+ printf "\\x$(printf "%x" 0x${CRC2})" >> ${CRC_LEN_TMP}
+ printf "\\x$(printf "%x" 0x${CRC3})" >> ${CRC_LEN_TMP}
+ printf "\\x$(printf "%x" 0x${CRC4})" >> ${CRC_LEN_TMP}
+
+ printf "\\x$(printf "%x" 0x${LEN1})" >> ${CRC_LEN_TMP}
+ printf "\\x$(printf "%x" 0x${LEN2})" >> ${CRC_LEN_TMP}
+ printf "\\x$(printf "%x" 0x${LEN3})" >> ${CRC_LEN_TMP}
+ printf "\\x$(printf "%x" 0x${LEN4})" >> ${CRC_LEN_TMP}
+}
+
+cp boot.bin ${BOOT_CRC_BIN}
+
+for (( i=0; i<9; i++ ))
+do
+ if [ -e ${IMAGES_DIR}/${FILES[i]} ]; then
+ create_crc_len_file ${IMAGES_DIR}/${FILES[i]}
+ cp -f ${BOOT_CRC_BIN} ${BOOT_BIN_TMP}
+ cat ${BOOT_BIN_TMP} ${CRC_LEN_TMP} > ${BOOT_CRC_BIN}
+ else
+ echo "${IMAGES_DIR}/${FILES[i]} not exist, check IMAGES_DIR value"
+ exit 1
+ fi
+done
+
+echo "${BOOT_CRC_BIN} created"
+exit 0
View
@@ -38,6 +38,7 @@ SECTIONS
.bss :
{
+ . = _edata + 72;
. = ALIGN(4);
_fbss = .;
*(.dynsbss)
View
@@ -29,10 +29,8 @@ void isr()
irqs = irq_pending() & irq_getmask();
- if(irqs & IRQ_UARTRX)
- uart_isr_rx();
- if(irqs & IRQ_UARTTX)
- uart_isr_tx();
+ if(irqs & IRQ_UART)
+ uart_isr();
if(irqs & IRQ_USB)
usb_isr();
@@ -49,9 +47,14 @@ extern struct test_description tests_midi[];
extern struct test_description tests_dmx[];
extern struct test_description tests_ir[];
extern struct test_description tests_usb[];
+extern struct test_description tests_images[];
struct test_category categories[] = {
{
+ .name = "Images",
+ .tests = tests_images
+ },
+ {
.name = "SDRAM",
.tests = tests_sdram
},
@@ -196,21 +199,24 @@ int main()
irq_setmask(0);
irq_enable(1);
uart_init();
- printf("*** Milkymist One automated tests starting...\n\n");
+ printf("*** Milkymist One automated tests starting...\n");
+ printf("*** Built: %s at %s (rev %s)\n\n", __DATE__, __TIME__, VERSION);
while(1) {
- printf("Select a test category below, or hit ENTER to run all tests:\n");
+ printf("*** Select a test category below, or hit ENTER to run all tests:\n");
i = 0;
while(categories[i].name != NULL) {
- printf("%c: %s\n", 'a'+i, categories[i].name);
+ printf(" %c: %s\n", 'a'+i, categories[i].name);
i++;
}
c = readchar();
if(c == '\n') {
run_all_tests(categories);
printf("******** TEST SUMMARY ********\n");
print_summary(categories);
- } else if((c >= 'a') && ((c - 'a') < i))
+ } else if((c >= 'a') && ((c - 'a') < i)) {
+ printf("*** %c pressed\n", c);
run_in_category(categories, c - 'a');
+ }
}
return 0;
}
View
@@ -44,7 +44,7 @@ static int loopback()
struct test_description tests_dmx[] = {
{
- .name = "Loopback",
+ .name = "DMX512 Loopback",
.run = loopback
},
{
@@ -35,12 +35,10 @@ static int mdio()
static int arp_resolution()
{
- int ethbuf[MICROUDP_BUFSIZE/4];
-
- microudp_start((unsigned char *)FLASH_OFFSET_MAC_ADDRESS, IPTOINT(192, 168, 0, 42), ethbuf);
+ microudp_start((unsigned char *)FLASH_OFFSET_MAC_ADDRESS, IPTOINT(192, 168, 0, 42));
if(!microudp_arp_resolve(IPTOINT(192, 168, 0, 14)))
return TEST_STATUS_FAILED;
- microudp_shutdown();
+
return TEST_STATUS_PASSED;
}
View
@@ -0,0 +1,129 @@
+/*
+ * Milkymist One automated testing program
+ * Copyright (C) 2011 Xiangfu Liu
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <stdio.h>
+#include <irq.h>
+#include <console.h>
+#include <string.h>
+#include <crc.h>
+
+#include <hw/interrupts.h>
+#include <hw/hpdmc.h>
+#include <hw/flash.h>
+
+#include "testdefs.h"
+
+static int compare_crc(unsigned int *flashbase, unsigned int crc, unsigned int length)
+{
+ unsigned int got_crc;
+
+ /* Flickernoise have the length and crc at begin, See makefile of Flickernoise */
+ if((unsigned int)flashbase == FLASH_OFFSET_RESCUE_APP ||
+ (unsigned int)flashbase == FLASH_OFFSET_REGULAR_APP) {
+ length = *flashbase++;
+ crc = *flashbase++;
+ }
+
+ /* BIOS have the crc at end, See makefile of BIOS */
+ if((unsigned int)flashbase == FLASH_OFFSET_RESCUE_BIOS ||
+ (unsigned int)flashbase == FLASH_OFFSET_REGULAR_BIOS)
+ crc = *(flashbase + (length / 4));
+
+ if((length < 32) || (length > 4*1024*1024)) {
+ printf("Invalid flash image length: %d\n", length);
+ return TEST_STATUS_FAILED;
+ }
+
+ got_crc = crc32((unsigned char *)flashbase, length);
+ if(crc != got_crc) {
+ printf("CRC failed (expected %08x, got %08x)\n", crc, got_crc);
+ return TEST_STATUS_FAILED;
+ }
+
+ printf("CRC passed (got %08x)\n", crc);
+ return TEST_STATUS_PASSED;
+}
+
+extern unsigned int _edata;
+
+#define IMAGES_COUNT 9
+
+static int compare_loop()
+{
+ int i, ret, count;
+
+ unsigned int crc, len;
+ unsigned int images[IMAGES_COUNT];
+
+ unsigned int * file_end = (unsigned int *) ((unsigned int)&_edata);
+
+ char * images_name[IMAGES_COUNT] = {
+ "standby.fpg",
+ "soc-rescue.fpg",
+ "bios-rescue.bin",
+ "splash-rescue.raw",
+ "flickernoise.fbi",
+ "soc.fpg",
+ "bios.bin",
+ "splash.raw",
+ "flickernoise.fbi"
+ };
+
+ images[0] = FLASH_OFFSET_STANDBY_BITSTREAM;
+ images[1] = FLASH_OFFSET_RESCUE_BITSTREAM;
+ images[2] = FLASH_OFFSET_RESCUE_BIOS;
+ images[3] = FLASH_OFFSET_RESCUE_SPLASH;
+ images[4] = FLASH_OFFSET_RESCUE_APP;
+ images[5] = FLASH_OFFSET_REGULAR_BITSTREAM;
+ images[6] = FLASH_OFFSET_REGULAR_BIOS;
+ images[7] = FLASH_OFFSET_REGULAR_SPLASH;
+ images[8] = FLASH_OFFSET_REGULAR_APP;
+
+ /*
+ * images crc and len write at the end of boot.bin
+ * see "append_crc_len.sh" for more info
+ */
+
+ count = 0;
+ for(i = 0; i < IMAGES_COUNT; i++) {
+ crc = *file_end++;
+ len = *file_end++;
+
+ printf(" %s\t", images_name[i]);
+
+ ret = compare_crc((unsigned int *)images[i], crc, len);
+ if(ret == TEST_STATUS_FAILED)
+ count++;
+ }
+
+ if(count == 0)
+ return TEST_STATUS_PASSED;
+ else {
+ printf("%d images failed\n", count);
+ return TEST_STATUS_FAILED;
+ }
+}
+
+struct test_description tests_images[] = {
+ {
+ .name = "Images CRC",
+ .run = compare_loop
+ },
+ {
+ .name = NULL
+ }
+};
Oops, something went wrong.

0 comments on commit 36be79a

Please sign in to comment.