BIOS starting on M1, SDRAM not working
authorlekernel <sebastien.bourdeauducq@lekernel.net>
Mon, 21 Jun 2010 20:55:02 +0000 (22:55 +0200)
committerlekernel <sebastien.bourdeauducq@lekernel.net>
Mon, 21 Jun 2010 20:55:02 +0000 (22:55 +0200)
14 files changed:
README
boards/milkymist-one/flash/Makefile [new file with mode: 0644]
boards/milkymist-one/flash/flash.cmd [new file with mode: 0644]
boards/milkymist-one/synthesis/common.mak
boards/milkymist-one/synthesis/flash.cmd [deleted file]
boards/milkymist-one/synthesis/load.cmd
clean_all.sh
cores/norflash16/rtl/norflash16.v
flash_bios.sh [deleted file]
flash_bitstream.sh [deleted file]
setup.inc
software/bios/Makefile
software/demo/Makefile
software/libhpdmc/libhpdmc.S

diff --git a/README b/README
index b9d79fa..a33506a 100644 (file)
--- a/README
+++ b/README
@@ -25,6 +25,7 @@ You will need:
  - Bourne Again Shell (bash),
  - Xilinx ISE for synthesizing the FPGA bitstream (WebPack is enough),
  - LatticeMico32 toolchain for building the SoC software,
+ - SRecord,
 For the host-side tools:
  - native Clang/LLVM toolchain,
  - libGD,
diff --git a/boards/milkymist-one/flash/Makefile b/boards/milkymist-one/flash/Makefile
new file mode 100644 (file)
index 0000000..9cf91a0
--- /dev/null
@@ -0,0 +1,16 @@
+all: flash.mcs
+
+flash.mcs:
+       make -C ../../../software/bios
+       srec_cat -Output flash.mcs -Intel ../../../software/bios/bios.bin -Binary
+
+# Run the Xilinx crapware in a separate directory that we can simply rm -rf
+# to get rid of the garbage it puts all over the filesystem.
+flash: flash.mcs
+       mkdir -p impact_sucks
+       cd impact_sucks && impact -batch ../flash.cmd
+
+clean:
+       rm -rf impact_sucks flash.mcs
+
+.PHONY: flash clean
diff --git a/boards/milkymist-one/flash/flash.cmd b/boards/milkymist-one/flash/flash.cmd
new file mode 100644 (file)
index 0000000..8da2634
--- /dev/null
@@ -0,0 +1,8 @@
+setMode -bscan
+setCable -p auto
+identify -inferir
+identifyMPM
+attachflash -position 1 -bpi "28F256J3F"
+assignfiletoattachedflash -position 1 -file "../flash.mcs"
+program -p 1 -dataWidth 16 -rs1 NONE -rs0 NONE -bpionly -e
+quit
index 2da9cc3..f28d200 100644 (file)
@@ -1,5 +1,3 @@
-prom: build/system.mcs
-
 timing: build/system-routed.twr
 
 usage: build/system-routed.xdl
@@ -8,9 +6,6 @@ usage: build/system-routed.xdl
 load: build/system.bit
        cd build && impact -batch ../load.cmd
 
-flash: build/system.mcs
-       cd build && impact -batch ../flash.cmd
-
 build/system.ncd: build/system.ngd
        cd build && map -w system.ngd
 
@@ -20,9 +15,6 @@ build/system-routed.ncd: build/system.ncd
 build/system.bit: build/system-routed.ncd
        cd build && bitgen -w system-routed.ncd system.bit
 
-build/system.mcs: build/system.bit
-       cd build && promgen -w -u 0 system
-
 build/system-routed.xdl: build/system-routed.ncd
        cd build && xdl -ncd2xdl system-routed.ncd system-routed.xdl
 
@@ -32,4 +24,4 @@ build/system-routed.twr: build/system-routed.ncd
 clean:
        rm -rf build/*
 
-.PHONY: prom timing usage load clean
+.PHONY: timing usage load clean
diff --git a/boards/milkymist-one/synthesis/flash.cmd b/boards/milkymist-one/synthesis/flash.cmd
deleted file mode 100644 (file)
index ad0e8b8..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-setMode -bscan
-setCable -p auto
-identify
-assignfile -p 2 -file system.mcs
-erase -p 2
-program -p 2
-quit
index 7c42f2b..52de4fc 100644 (file)
@@ -1,6 +1,6 @@
 setMode -bscan
 setCable -p auto
 identify
-assignfile -p 3 -file system.bit
-program -p 3
+assignfile -p 1 -file system.bit
+program -p 1
 quit
index 26048f1..08dda99 100755 (executable)
@@ -20,6 +20,7 @@ cd $BASEDIR/software/demo && make clean
 
 cd $BASEDIR/boards/xilinx-ml401/synthesis && make -f common.mak clean
 cd $BASEDIR/boards/milkymist-one/synthesis && make -f common.mak clean
+cd $BASEDIR/boards/milkymist-one/flash && make clean
 
 cd $BASEDIR/doc && make clean
 for i in $COREDOC; do
index 1a30d8a..e65bbfd 100644 (file)
@@ -44,8 +44,8 @@ always @(posedge sys_clk) begin
                flash_adr_msb <= wb_adr_i[adr_width-1:2];
        if(load) begin
                case(flash_adr_lsb)
-                       1'b0: wb_dat_o[31:16] <= flash_d;
-                       1'b1: wb_dat_o[15:0] <= flash_d;
+                       1'b0: wb_dat_o[31:16] <= {flash_d[7:0], flash_d[15:8]};
+                       1'b1: wb_dat_o[15:0] <= {flash_d[7:0], flash_d[15:8]};
                endcase
                flash_adr_lsb <= ~flash_adr_lsb;
        end
diff --git a/flash_bios.sh b/flash_bios.sh
deleted file mode 100755 (executable)
index 82473a6..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-#!/bin/bash
-
-source setup.inc
-
-BASEDIR=`pwd`
-LOGFILE=$BASEDIR/biosflash.log
-BIOSDIR=$BASEDIR/software/bios
-
-echo "================================================================================"
-echo "Flashing Milkymist BIOS"
-if [ -z $NOSPLASH ] ; then
-       BIOSFILE=$BIOSDIR/bios_splash.bin
-else
-       BIOSFILE=$BIOSDIR/bios.bin
-       echo "Splash screen flashing disabled"
-fi
-echo ""
-echo "Board:    $BOARD"
-echo "Log file: $LOGFILE"
-echo "================================================================================"
-echo ""
-
-echo "Flashing BIOS into NOR flash..."
-
-echo >> $LOGFILE
-date >> $LOGFILE
-
-if [ $BOARD == "xilinx-ml401" ] ; then
-       echo -n "  Loading flasher bitstream..."
-       load-ml401-flasher > $LOGFILE 2>&1
-       if [ "$?" != 0 ] ; then
-               echo "FAILED"
-               exit 1
-       else
-               echo "OK"
-       fi
-
-       echo -n "  Writing flash..."
-       ml401-flasher $BIOSFILE >> $LOGFILE 2>&1
-       if [ "$?" != 0 ] ; then
-               echo "FAILED"
-               exit 1
-       else
-               echo "OK"
-       fi
-else
-       echo "Unsupported board, aborting."
-       exit
-fi
-
-echo "Flashing complete!"
diff --git a/flash_bitstream.sh b/flash_bitstream.sh
deleted file mode 100755 (executable)
index 8026a15..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/bin/bash
-
-source setup.inc
-
-BASEDIR=`pwd`
-LOGFILE=$BASEDIR/bitflash.log
-
-echo "================================================================================"
-echo "Flashing Milkymist bitstream file"
-echo ""
-echo "Board:    $BOARD"
-echo "Log file: $LOGFILE"
-echo "================================================================================"
-echo ""
-
-echo -n "Flashing FPGA bitstream..."
-echo >> $LOGFILE
-date >> $LOGFILE
-cd $BASEDIR/boards/$BOARD/synthesis && make -f Makefile.$SYNTOOL flash > $LOGFILE 2>&1
-if [ "$?" != 0 ] ; then
-        echo "FAILED"
-       exit 1
-else
-        echo "OK"
-fi
-
-cd $BASEDIR
-
-echo "Flashing complete!"
index d1af0a5..aefc2da 100644 (file)
--- a/setup.inc
+++ b/setup.inc
@@ -7,6 +7,5 @@ fi
 # Board name (name of the subfolder of the "boards" folder)
 if [ -z "$BOARD" ]
 then
-       BOARD=xilinx-ml401
+       BOARD=milkymist-one
 fi
-
index 238016e..d090a89 100644 (file)
@@ -11,7 +11,10 @@ all: bios_splash.bin
        chmod -x $@
        $(MMDIR)/tools/crc32 $@ write
 
-bios.elf: linker.ld $(OBJECTS) $(MMDIR)/software/libhpdmc/libhpdmc.a $(MMDIR)/software/libbase/libbase-light.a $(MMDIR)/software/libnet/libnet.a
+bios.elf: linker.ld $(OBJECTS)
+       $(MAKE) -C $(MMDIR)/software/libhpdmc
+       $(MAKE) -C $(MMDIR)/software/libbase
+       $(MAKE) -C $(MMDIR)/software/libnet
        $(LD) $(LDFLAGS) -T linker.ld -N -o $@ $(OBJECTS) -L$(MMDIR)/software/libhpdmc -L$(MMDIR)/software/libbase -L$(MMDIR)/software/libnet -lhpdmc -lbase-light -lnet
        chmod -x $@
 
@@ -24,7 +27,7 @@ bios_padded.bin: bios.bin
 bios_splash.bin: bios_padded.bin splash.raw
        cat bios_padded.bin splash.raw > bios_splash.bin
 
-.PHONY: clean depend
+.PHONY: clean depend bios.elf
 
 depend:
        makedepend -Y -- $(CFLAGS) -- *.c
index d705331..4258c16 100644 (file)
@@ -20,11 +20,15 @@ spam.h: spam.raw
        chmod -x $@
        $(MMDIR)/tools/crc32 $@
 
-boot.elf: linker.ld $(OBJECTS) $(MMDIR)/software/libbase/libbase.a $(MMDIR)/software/libmath/libmath.a $(MMDIR)/software/libhal/libhal.a $(MMDIR)/software/libfpvm/libfpvm.a
+boot.elf: linker.ld $(OBJECTS)
+       $(MAKE) -C $(MMDIR)/software/libbase
+       $(MAKE) -C $(MMDIR)/software/libmath
+       $(MAKE) -C $(MMDIR)/software/libhal
+       $(MAKE) -C $(MMDIR)/software/libfpvm
        $(LD) $(LDFLAGS) -T linker.ld -N -o $@ -L$(MMDIR)/software/libbase -L$(MMDIR)/software/libmath -L$(MMDIR)/software/libhal -L$(MMDIR)/software/libfpvm --start-group $(OBJECTS) -lbase -lmath -lhal -lfpvm --end-group
        chmod -x $@
 
-.PHONY: clean depend
+.PHONY: clean depend boot.elf
 
 depend: bandfilters.h spam.h
        makedepend -Y -- $(CFLAGS) -- *.c
index 096c6c8..beb9024 100644 (file)
@@ -67,6 +67,8 @@ _sdram_init:
        PRINT(nl)
        PRINT(nl)
 
+// HACK for Milkymist One
+#if 0
        /* wait for the PLLs to lock */
        mvhi    r1, hi(CSR_HPDMC_IODELAY)
        ori     r1, r1, lo(CSR_HPDMC_IODELAY)
@@ -85,6 +87,7 @@ wait_dqs_start:
        be      r2, r0, wait_dqs_start
        xor     r25, r25, r25
        xor     r24, r24, r24
+#endif
 
        /* send init sequence */
        bi send_init
@@ -100,7 +103,8 @@ send_init_return:
        bne     r2, r0, mancal
 #endif
 
-       bi      autocalibrate
+// HACK for Milkymist One
+       //bi    autocalibrate
 autocalibrate_fail_return:
        PRINT(autocalfail)
 #ifdef FEAT_MANUAL_CALIBRATION