The next step is to try with sram soldered in, still waiting on the chip..
// The FSMC TEST example
// from libmaple-master.lib
// modded/fixed for stm32duino
// uses SRAM in Bank 1, Region 3, /CS at PG10
// for stm32f103zet6 board
// Pito 12/2016
#include <stddef.h> // for ptrdiff_t
#include <libmaple/rcc.h>
#include <libmaple/fsmc.h>
// -- SRAM config -------------------------------------------------------------
// Timing configuration - for a 55ns SRAM (to be tested)
#define DATAST 0x4
#define ADDSET 0x1
// Number of SRAM chips wired (max 4 in BANK1)
#define NSRAMCHIPS 1
// Their start addresses in FSMC BANK 1 (we do not use here)
__io uint16 *const starts[NSRAMCHIPS] = {
// (__io uint16 *const)FSMC_NOR_PSRAM_REGION1,
// (__io uint16 *const)FSMC_NOR_PSRAM_REGION2,
(__io uint16 *const)FSMC_NOR_PSRAM_REGION3,
// (__io uint16 *const)FSMC_NOR_PSRAM_REGION4,
};
// Corresponding FSMC configuration registers
__io uint32 *const bcrs[NSRAMCHIPS] = {
// &FSMC_NOR_PSRAM1_BASE->BCR,
// &FSMC_NOR_PSRAM2_BASE->BCR,
&FSMC_NOR_PSRAM3_BASE->BCR,
// &FSMC_NOR_PSRAM4_BASE->BCR,
};
// Corresponding FSMC timing registers
__io uint32 *const btrs[NSRAMCHIPS] = {
// &FSMC_NOR_PSRAM1_BASE->BTR,
// &FSMC_NOR_PSRAM2_BASE->BTR,
&FSMC_NOR_PSRAM3_BASE->BTR,
// &FSMC_NOR_PSRAM4_BASE->BTR,
};
// Start of FSMC SRAM BANK 1, REGION 3
static uint16 *const sram_start = (uint16*)0x68000000;
// End of Maple Native SRAM chip address space (512K 16-bit words)
static uint16 *const sram_end = (uint16*)0x68100000;
void test_single_write(void);
void test_all_addresses(void);
void setup() {
fsmc_sram_init_gpios();
rcc_clk_enable(RCC_FSMC);
// All wired SRAM chips are of the same type
for (int i = 0; i < NSRAMCHIPS; i++) {
*bcrs[i] = (FSMC_BCR_WREN |
FSMC_BCR_MTYP_SRAM |
FSMC_BCR_MWID_16BITS |
FSMC_BCR_MBKEN);
*btrs[i] = (DATAST << 8) | ADDSET;
}
delay(10000); // wait on USB
pinMode(PC13, OUTPUT);
digitalWrite(PC13, LOW);
Serial.begin(115200);
// Serial.read();
Serial.println("*** Beginning RAM chip test");
test_single_write();
test_all_addresses();
Serial.println("Tests pass, finished.");
Serial.println("***\n");
}
void loop() {
}
void test_single_write() {
uint16 *ptr = sram_start;
uint16 tmp;
Serial.print("Writing 0x1234... ");
*ptr = 0x1234;
Serial.println("Done.");
Serial.print("Reading... ");
tmp = *ptr;
Serial.print("Done: 0x");
Serial.println(tmp, HEX);
if (tmp != 0x1234) {
Serial.println("Mismatch; abort.");
// ASSERT(0);
}
}
void test_all_addresses() {
uint32 start, end;
uint16 count = 0;
uint16 *ptr;
Serial.println("Now writing all memory addresses (unrolled loop)");
start = micros();
for (ptr = sram_start; ptr < sram_end;) {
*ptr++ = count++;
*ptr++ = count++;
*ptr++ = count++;
*ptr++ = count++;
*ptr++ = count++;
*ptr++ = count++;
*ptr++ = count++;
*ptr++ = count++;
*ptr++ = count++;
*ptr++ = count++;
*ptr++ = count++;
*ptr++ = count++;
*ptr++ = count++;
*ptr++ = count++;
*ptr++ = count++;
*ptr++ = count++;
}
end = micros();
Serial.println(count);
Serial.print("Done. Elapsed time (us): ");
Serial.println(end - start);
// delay(10000);
Serial.println("Validating writes.");
for (ptr = sram_start, count = 0; ptr < sram_end; ptr++, count++) {
uint16 value = *ptr;
if (value != count) {
Serial.print("mismatch: 0x");
Serial.print((uint32)ptr, HEX);
Serial.print(" = 0x");
Serial.print(value, HEX);
Serial.print(", should be 0x");
Serial.print(count, HEX);
Serial.println(".");
//ASSERT(0);
}
}
Serial.println("Done; all writes seem valid.");
ptrdiff_t nwrites = sram_end - sram_start;
double us_per_write = double(end-start) / double(nwrites);
Serial.print("Number of writes = ");
Serial.print(nwrites);
Serial.print("; avg. time per write = ");
Serial.print(us_per_write);
Serial.print(" us (");
Serial.print(1 / us_per_write);
Serial.println(" MHz)");
}
*** Beginning RAM chip test
Writing 0x1234... Done.
Reading... Done: 0x0
Mismatch; abort.
Now writing all memory addresses (unrolled loop)
Done. Elapsed time (us): 27369
Validating writes.
mismatch: 0x1610612738 = 0x0, should be 0x1.
mismatch: 0x1610612740 = 0x0, should be 0x2.
mismatch: 0x1610612742 = 0x0, should be 0x3.
mismatch: 0x1610612744 = 0x0, should be 0x4.
mismatch: 0x1610612746 = 0x0, should be 0x5.
mismatch: 0x1610612748 = 0x0, should be 0x6.
mismatch: 0x1610612750 = 0x0, should be 0x7.
mismatch: 0x1610612752 = 0x0, should be 0x8.
mismatch: 0x1610612754 = 0x0, should be 0x9.
..srp
Now the numbers are much more realistic, indeed:
*** Beginning RAM chip test
Writing 0x1234... Done.
Reading... Done: 0xFFFF
Mismatch; abort.
Now writing all memory addresses (unrolled loop)
524288
Done. Elapsed time (us): 2140840
Validating writes.
mismatch: 0x1610612736 = 0xFFFF, should be 0x0.
mismatch: 0x1610612738 = 0xFFFF, should be 0x1.
mismatch: 0x1610612740 = 0xFFFF, should be 0x2.
mismatch: 0x1610612742 = 0xFFFF, should be 0x3.
mismatch: 0x1610612744 = 0xFFFF, should be 0x4.
mismatch: 0x1610612746 = 0xFFFF, should be 0x5.mismatch: 0x60000000 = 0xFEDF, should be 0x0.
mismatch: 0x60000002 = 0xFE5F, should be 0x1.
mismatch: 0x60000004 = 0xFE5F, should be 0x2.
mismatch: 0x60000006 = 0xFE5F, should be 0x3.#define DATAST 0x4
#define ADDSET 0x1might even have 407/429i expansion boards as well.
buy the highest/best you can afford at the kink in the plot of cost / go faster stripes, even if you can’t immediately use it.
rule exported from purchasing hardware for use under linux, it’ll get there eventually … …
i suppose i should mention ppi refunds i got, why not ask, you never know.
not quite lotto, but still rather nice. all gone now, but bits and pieces for a good few years of playtime.
so just where would i start with nand or nor memory plug-ins ?
i had a quick look only, but all i found was a gpio pins setup file.
stephen
*** Beginning RAM chip test
Writing 0x1234... Done.
Reading... Done: 0x1234
Now writing all memory addresses (unrolled loop)
524288
Done. Elapsed time (us): 67501
Validating writes.
Done; all writes seem valid.
Number of writes = 524288; avg. time per write = 0.13 us (7.77 MHz)
Tests pass, finished.
***

