Minor updates

Add openocd CPLD flashing script for the old version (10.0-5) of openocd, rework interrupt handling a bit so that more software works, update buptest to work with the proto3 bitstream.
This commit is contained in:
beeanyew
2021-03-22 14:58:44 +01:00
parent 59a59c3067
commit b094944dae
6 changed files with 115 additions and 57 deletions

38
68old.cfg Normal file
View File

@@ -0,0 +1,38 @@
# this supports ECP5 Evaluation Board
reset_config none
interface bcm2835gpio
#bcm2835gpio_peripheral_base 0x20000000
bcm2835gpio_peripheral_base 0x3F000000
# Transition delay calculation: SPEED_COEFF/khz - SPEED_OFFSET
# These depend on system clock, calibrated for stock 700MHz
# bcm2835gpio_speed SPEED_COEFF SPEED_OFFSET
#bcm2835gpio_speed_coeffs 146203 36
bcm2835gpio_speed_coeffs 194938 48
#bcm2835gpio_peripheral_base 0x3F000000
#bcm2835gpio_speed_coeffs 194938 48
reset_config none
adapter_khz 100
# JTAG tck tms tdi tdo
bcm2835gpio_jtag_nums 26 24 27 25
#meh dummy reset to make openocd happy, set to A0 on SMI
bcm2835gpio_srst_num 5
reset_config srst_only srst_open_drain
transport select jtag
jtag newtap max2 tap -irlen 11 -expected-id 0x020a20dd
init
svf ./rtl/bitstream.svf -quiet
sleep 200
shutdown

View File

@@ -1 +1 @@
gcc buptest.c gpio/gpio.c -o buptest -march=armv8-a -mfloat-abi=hard -mfpu=neon-fp-armv8 -O0
gcc buptest.c gpio/ps_protocol.c -I./ -o buptest -march=armv8-a -mfloat-abi=hard -mfpu=neon-fp-armv8 -O0

106
buptest.c
View File

@@ -16,65 +16,72 @@
#include <unistd.h>
#include <sys/ioctl.h>
#include "emulator.h"
#include "gpio/gpio.h"
#include "gpio/ps_protocol.h"
#include "platforms/amiga/gayle-ide/ide.h"
uint8_t garbege_datas[2 * 1024 * 1024];
#define SIZE_KILO 1024
#define SIZE_MEGA (1024 * 1024)
#define SIZE_GIGA (1024 * 1024 * 1024)
uint8_t garbege_datas[2 * SIZE_MEGA];
struct timespec f2;
uint8_t gayle_int;
uint32_t mem_fd;
uint32_t errors = 0;
uint8_t loop_tests = 0, total_errors = 0;
void sigint_handler(int sig_num) {
//if (sig_num) { }
//cpu_emulation_running = 0;
//return;
printf("Received sigint %d, exiting.\n", sig_num);
printf("Total number of transaction errors occured: %d\n", total_errors);
if (mem_fd)
close(mem_fd);
exit(0);
}
int main() {
int main(int argc, char *argv[]) {
uint32_t test_size = 512 * SIZE_KILO, cur_loop = 0;
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &f2);
srand((unsigned int)f2.tv_nsec);
signal(SIGINT, sigint_handler);
setup_io();
printf("Enable 200MHz GPCLK0 on GPIO4\n");
gpio_enable_200mhz();
ps_setup_protocol();
ps_reset_state_machine();
ps_pulse_reset();
write_reg(0x01);
usleep(100);
usleep(1500);
write_reg(0x00);
usleep(100);
usleep(1500);
write_reg(0x00);
// printf("Status Reg%x\n",read_reg());
usleep(100000);
write_reg(0x02);
usleep(1500);
write8(0xbfe201, 0x0101); //CIA OVL
write8(0xbfe001, 0x0000); //CIA OVL LOW
if (argc > 1) {
test_size = atoi(argv[1]) * SIZE_KILO;
if (test_size == 0 || test_size > 2 * SIZE_MEGA) {
test_size = 512 * SIZE_KILO;
}
printf("Testing %d KB of memory.\n", test_size / SIZE_KILO);
if (argc > 2) {
if (strcmp(argv[2], "l") == 0) {
printf("Looping tests.\n");
loop_tests = 1;
}
}
}
test_loop:;
printf("Writing garbege datas.\n");
for (uint32_t i = 0; i < 512 * 1024; i++) {
for (uint32_t i = 0; i < test_size; i++) {
while(garbege_datas[i] == 0x00)
garbege_datas[i] = (uint8_t)(rand() % 0xFF);
write8(i, (uint32_t)garbege_datas[i]);
}
printf("Reading back garbege datas, read8()...\n");
for (uint32_t i = 0; i < 512 * 1024; i++) {
for (uint32_t i = 0; i < test_size; i++) {
uint32_t c = read8(i);
if (c != garbege_datas[i]) {
if (errors < 512)
@@ -83,11 +90,12 @@ int main() {
}
}
printf("read8 errors total: %d.\n", errors);
total_errors += errors;
errors = 0;
sleep (1);
printf("Reading back garbege datas, read16(), even addresses...\n");
for (uint32_t i = 0; i < (512 * 1024) - 2; i += 2) {
for (uint32_t i = 0; i < (test_size) - 2; i += 2) {
uint32_t c = be16toh(read16(i));
if (c != *((uint16_t *)&garbege_datas[i])) {
if (errors < 512)
@@ -96,11 +104,12 @@ int main() {
}
}
printf("read16 even errors total: %d.\n", errors);
total_errors += errors;
errors = 0;
sleep (1);
printf("Reading back garbege datas, read16(), odd addresses...\n");
for (uint32_t i = 1; i < (512 * 1024) - 2; i += 2) {
for (uint32_t i = 1; i < (test_size) - 2; i += 2) {
uint32_t c = be16toh((read8(i) << 8) | read8(i + 1));
if (c != *((uint16_t *)&garbege_datas[i])) {
if (errors < 512)
@@ -113,7 +122,7 @@ int main() {
sleep (1);
printf("Reading back garbege datas, read32(), even addresses...\n");
for (uint32_t i = 0; i < (512 * 1024) - 4; i += 2) {
for (uint32_t i = 0; i < (test_size) - 4; i += 2) {
uint32_t c = be32toh(read32(i));
if (c != *((uint32_t *)&garbege_datas[i])) {
if (errors < 512)
@@ -122,15 +131,15 @@ int main() {
}
}
printf("read32 even errors total: %d.\n", errors);
total_errors += errors;
errors = 0;
sleep (1);
printf("Reading back garbege datas, read32(), odd addresses...\n");
for (uint32_t i = 1; i < (512 * 1024) - 4; i += 2) {
for (uint32_t i = 1; i < (test_size) - 4; i += 2) {
uint32_t c = read8(i);
c |= (be16toh(read16(i + 1)) << 8);
c |= (read8(i + 3) << 24);
//c = be32toh(c);
if (c != *((uint32_t *)&garbege_datas[i])) {
if (errors < 512)
printf("READ32_ODD: Garbege data mismatch at $%.6X: %.8X should be %.8X.\n", i, c, *((uint32_t *)&garbege_datas[i]));
@@ -138,66 +147,71 @@ int main() {
}
}
printf("read32 odd errors total: %d.\n", errors);
total_errors += errors;
errors = 0;
sleep (1);
printf("Clearing 512KB of Chip again\n");
for (uint32_t i = 0; i < 512 * 1024; i++) {
printf("Clearing %d KB of Chip again\n", test_size / SIZE_KILO);
for (uint32_t i = 0; i < test_size; i++) {
write8(i, (uint32_t)0x0);
}
printf("[WORD] Writing garbege datas to Chip, unaligned...\n");
for (uint32_t i = 1; i < (512 * 1024) - 2; i += 2) {
for (uint32_t i = 1; i < (test_size) - 2; i += 2) {
uint16_t v = *((uint16_t *)&garbege_datas[i]);
write8(i, (v & 0x00FF));
write8(i + 1, (v >> 8));
//write16(i, *((uint16_t *)&garbege_datas[i]));
}
sleep (1);
printf("Reading back garbege datas, read16(), odd addresses...\n");
for (uint32_t i = 1; i < (512 * 1024) - 2; i += 2) {
//uint32_t c = be16toh(read16(i));
for (uint32_t i = 1; i < (test_size) - 2; i += 2) {
uint32_t c = be16toh((read8(i) << 8) | read8(i + 1));
if (c != *((uint16_t *)&garbege_datas[i])) {
if (errors < 512)
printf("READ16_EVEN: Garbege data mismatch at $%.6X: %.4X should be %.4X.\n", i, c, *((uint16_t *)&garbege_datas[i]));
printf("READ16_ODD: Garbege data mismatch at $%.6X: %.4X should be %.4X.\n", i, c, *((uint16_t *)&garbege_datas[i]));
errors++;
}
}
printf("read16 even errors total: %d.\n", errors);
printf("read16 odd errors total: %d.\n", errors);
total_errors += errors;
errors = 0;
printf("Clearing 512KB of Chip again\n");
for (uint32_t i = 0; i < 512 * 1024; i++) {
printf("Clearing %d KB of Chip again\n", test_size / SIZE_KILO);
for (uint32_t i = 0; i < test_size; i++) {
write8(i, (uint32_t)0x0);
}
printf("[LONG] Writing garbege datas to Chip, unaligned...\n");
for (uint32_t i = 1; i < (512 * 1024) - 4; i += 4) {
for (uint32_t i = 1; i < (test_size) - 4; i += 4) {
uint32_t v = *((uint32_t *)&garbege_datas[i]);
write8(i , v & 0x0000FF);
write16(i + 1, htobe16(((v & 0x00FFFF00) >> 8)));
write8(i + 3 , (v & 0xFF000000) >> 24);
//write32(i, v);
}
sleep (1);
printf("Reading back garbege datas, read32(), even addresses...\n");
for (uint32_t i = 1; i < (512 * 1024) - 4; i += 4) {
printf("Reading back garbege datas, read32(), odd addresses...\n");
for (uint32_t i = 1; i < (test_size) - 4; i += 4) {
uint32_t c = read8(i);
c |= (be16toh(read16(i + 1)) << 8);
c |= (read8(i + 3) << 24);
//uint32_t c = be32toh(read32(i));
if (c != *((uint32_t *)&garbege_datas[i])) {
if (errors < 512)
printf("READ32_EVEN: Garbege data mismatch at $%.6X: %.8X should be %.8X.\n", i, c, *((uint32_t *)&garbege_datas[i]));
printf("READ32_ODD: Garbege data mismatch at $%.6X: %.8X should be %.8X.\n", i, c, *((uint32_t *)&garbege_datas[i]));
errors++;
}
}
printf("read32 even errors total: %d.\n", errors);
printf("read32 odd errors total: %d.\n", errors);
total_errors += errors;
errors = 0;
if (loop_tests) {
printf ("Loop %d done. Begin loop %d.\n", cur_loop + 1, cur_loop + 2);
printf ("Current total errors: %d.\n", total_errors);
goto test_loop;
}
return 0;
}

View File

@@ -61,7 +61,7 @@ extern uint8_t realtime_graphics_debug;
uint8_t realtime_disassembly, int2_enabled = 0;
uint32_t do_disasm = 0, old_level;
char c = 0, c_code = 0, c_type = 0; // @todo temporary main/cpu_task scope workaround until input moved to a thread
uint32_t last_irq = 0, last_last_irq = 0;
uint32_t last_irq = 8, last_last_irq = 8;
char disasm_buf[4096];
@@ -73,7 +73,7 @@ int mem_fd_gpclk;
int irq;
int gayleirq;
//#define MUSASHI_HAX
#define MUSASHI_HAX
#ifdef MUSASHI_HAX
#include "m68kcpu.h"
@@ -121,8 +121,10 @@ void *ipl_task(void *args) {
if (!(value & (1 << PIN_IPL_ZERO))) {
irq = 1;
old_irq = irq_delay;
NOP
//NOP
M68K_END_TIMESLICE;
NOP
//usleep(0);
}
else {
if (irq) {
@@ -132,12 +134,13 @@ void *ipl_task(void *args) {
else {
irq = 0;
}
NOP
M68K_END_TIMESLICE;
NOP
//usleep(0);
}
}
if (gayle_ide_enabled) {
/*if (gayle_ide_enabled) {
if (((gayle_int & 0x80) || gayle_a4k_int) && (get_ide(0)->drive[0].intrq || get_ide(0)->drive[1].intrq)) {
//get_ide(0)->drive[0].intrq = 0;
gayleirq = 1;
@@ -145,11 +148,12 @@ void *ipl_task(void *args) {
}
else
gayleirq = 0;
}
}*/
//usleep(0);
//NOP NOP
NOP NOP NOP NOP NOP NOP NOP NOP
NOP NOP NOP NOP NOP NOP NOP NOP
NOP NOP NOP NOP NOP NOP NOP NOP
//NOP NOP NOP NOP NOP NOP NOP NOP
//NOP NOP NOP NOP NOP NOP NOP NOP
/*NOP NOP NOP NOP NOP NOP NOP NOP
NOP NOP NOP NOP NOP NOP NOP NOP
NOP NOP NOP NOP NOP NOP NOP NOP*/
@@ -198,6 +202,7 @@ cpu_loop:
}
M68K_SET_IRQ(0);
last_last_irq = 0;
m68k_execute(5);
}
/*else {
if (last_irq != 0) {

View File

@@ -89,8 +89,8 @@
* If off, all interrupts will be autovectored and all interrupt requests will
* auto-clear when the interrupt is serviced.
*/
#define M68K_EMULATE_INT_ACK OPT_OFF
#define M68K_INT_ACK_CALLBACK(A) cpu_irq_ack(A)
#define M68K_EMULATE_INT_ACK OPT_SPECIFY_HANDLER
#define M68K_INT_ACK_CALLBACK(...) 0xFFFFFFFF
/* If ON, CPU will call the breakpoint acknowledge callback when it encounters

1
nprog_old.sh Normal file
View File

@@ -0,0 +1 @@
sudo openocd -f 68old.cfg