Skip to content

Commit

Permalink
Add linux flash script
Browse files Browse the repository at this point in the history
Signed-off-by: Ola Jeppsson <ola.jeppsson@gmail.com>
  • Loading branch information
olajep committed May 8, 2015
1 parent a1d2baa commit 3bcda8b
Show file tree
Hide file tree
Showing 14 changed files with 459 additions and 0 deletions.
Binary file added env.bin
Binary file not shown.
59 changes: 59 additions & 0 deletions env.txt
@@ -0,0 +1,59 @@
bootdelay=1
ipaddr=10.11.12.13
serverip=10.11.12.1
bootenv=uEnv.txt
fdt_high=0x20000000
kernel_image=uImage
old_bitstream_image=parallella.bit.bin
old_devicetree_image=devicetree.dtb
loadbootenv_addr=0x2000000

slowblink=led 0 toggle && sleep 1 && led 0 toggle && sleep 1 || true

loadbootenv=load mmc 0 ${loadbootenv_addr} ${bootenv}

importbootenv=echo Importing environment from SD ...; \
env import -t ${loadbootenv_addr} $filesize

importbootenvtftp=echo Importing environment from TFTP ...; \
env import -t ${loadbootenv_addr} $filesize

preboot=\
if mmcinfo; then \
led 0 on; \
run slowblink; \
env set modeboot sdboot_old; \
run loadbootenv && \
run importbootenv && \
env set modeboot sdboot; \
else \
led 0 off; \
env set modeboot tftpboot; \
fi;

sdboot_old=\
echo Legacy boot from SD card...; \
load mmc 0 0x4000000 ${old_bitstream_image} && \
fpga load 0 0x4000000 $filesize && \
run slowblink; \
load mmc 0 0x3000000 ${kernel_image} && \
load mmc 0 0x2A00000 ${old_devicetree_image} && \
run slowblink && \
bootm 0x3000000 - 0x2A00000; \
led 0 off

tftpboot=\
while true; do \
echo TFTPing second stage boot script... && \
tftpboot ${loadbootenv_addr} ${bootenv} && \
run importbootenvtftp && \
run tftpboot_stage2; \
done

bootcmd=run $modeboot

# STDIO
baudrate=115200
stderr=serial
stdin=serial
stdout=serial
1 change: 1 addition & 0 deletions linux/.gitignore
@@ -0,0 +1 @@
backup
Binary file added linux/BOOT.7z020.bin
Binary file not shown.
28 changes: 28 additions & 0 deletions linux/README.md
@@ -0,0 +1,28 @@
linux-flash
===========

This script can be used to flash a live Parallella system from the command
line in linux.

File | Description
---------------|---------------------------------------------------------------
linux-flash.sh | Flash script
|
backup | The flash script will place backups here
|
BOOT.7z020.bin | Boot flash image. Created by ../mkbootflash.sh
|
env.bin | Created with:
| uboot/tools/mkenvimage -s 0x20000 -o env.bin ../env.txt
|
getfpga | Print on-board FPGA-type (e.g. "7z010" "7z020" ...)
getfpga.c | gcc getfpga.c -o getfpga
|
|
fw_printenv | Tools to read and write uboot environment partition
fw_setenv |
uboot--.patch | Patch that embeds Parallella flash configuration in above
| two binaries.
|
md5sum.txt | Checksum file linux-flash.sh uses to verify that the files to
| be flashed are not corrupt.
Empty file added linux/backup/.gitkeep
Empty file.
Binary file added linux/env.bin
Binary file not shown.
Binary file added linux/fw_printenv
Binary file not shown.
Binary file added linux/fw_setenv
Binary file not shown.
Binary file added linux/getfpga
Binary file not shown.
84 changes: 84 additions & 0 deletions linux/getfpga.c
@@ -0,0 +1,84 @@
#include <stdio.h>
#include <stdint.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <unistd.h>

#define SLCR_IDCODE_MASK 0x1F000
#define SLCR_IDCODE_SHIFT 12

#define SLCR_BASE 0xF8000000
#define PSS_IDCODE_OFFS 0x530

#define XILINX_ZYNQ_7010 0x2
#define XILINX_ZYNQ_7015 0x1b
#define XILINX_ZYNQ_7020 0x7
#define XILINX_ZYNQ_7030 0xc
#define XILINX_ZYNQ_7035 0x12
#define XILINX_ZYNQ_7045 0x11
#define XILINX_ZYNQ_7100 0x16

int decode(uint32_t idcode)
{
int ret;

idcode = (idcode & SLCR_IDCODE_MASK) >> SLCR_IDCODE_SHIFT;

switch (idcode) {
case XILINX_ZYNQ_7010:
printf("7z010\n");
return 0;
case XILINX_ZYNQ_7015:
printf("7z015\n");
return 0;
case XILINX_ZYNQ_7020:
printf("7z020\n");
return 0;
case XILINX_ZYNQ_7030:
printf("7z030\n");
return 0;
case XILINX_ZYNQ_7035:
printf("7z035\n");
return 0;
case XILINX_ZYNQ_7045:
printf("7z045\n");
return 0;
case XILINX_ZYNQ_7100:
printf("7z100\n");
return 0;

default:
printf("unknown\n");
return 1;
}
}

int main()
{
uint32_t *slcr, *pss_idcode;
int ret, fd;

fd = open("/dev/mem", O_RDONLY | O_SYNC);
if (fd < 0) {
fprintf(stderr, "Could not open /dev/mem\n");
return 1;
}

slcr = mmap(NULL, 4096, PROT_READ, MAP_SHARED, fd, SLCR_BASE);
if (slcr == MAP_FAILED) {
fprintf(stderr, "mmap failed\n");
return 1;
}

pss_idcode = (uint32_t *)
((uintptr_t) slcr + (uintptr_t) PSS_IDCODE_OFFS);

ret = decode(*pss_idcode);

munmap(slcr, 4096);
close(fd);

return ret;
}

0 comments on commit 3bcda8b

Please sign in to comment.