* Migrate RP2040-specific bits to separate dirs * Add chip to boards.txt, isolate RP2040-specifics * Add RP2350 boot2, bearssl, and libraries * Platform.IO adjust to new paths * Add RPIPICO2 JSON for P.IO * Add RP2350 to Platform.io * Update Picotool and OpenOCD for all hosts * Use picotool to generate UF2s * Build separate libpico blobs serially Thanks for the review, @aarturo182 ! * Add RP2350 to CI * Allow Ethernet/WiFi building for RP2350 * Update Adafruit TinyUSB to latest * Test skip fix * Make RP2350 Picotool work. update USB ID * Fix EEPROM/FS flash locations RP2350 adds a 4K header sector to the UF2, meaning we have 4K less total flash to work with. Adjust all constants appropriately on the RP2350. * Adds ilabs board and PSRAM support. (#2342) * Adds iLabs boards and basic PSRAM support. * Make PSRAM come up as part of chip init Uses SparkFun psram.cpp to set timings on clocks which are defined in the variant file. Prefix things with RP2350_PSRAM_xxx for sanity. Users don't need to call anything, PSRAM "just appears". Still need to add in malloc-type allocation. * Add board SparkFun ProMicro RP2350 Same pinout as the SparkFun ProMicro RP2040 with 8MB PSRAM and RP2350 * Add TLSF library for use w/PSRAM Fork of upstream to include add'l C++ warning fixes. * Add pmalloc/pcalloc to use PSRAM memory free() and realloc() all look at the pointer passed in and jump to the appropriate handler. Also takes care of stopping IRQs and taking the malloc mutex to support multicore and FreeRTOS (when that workd) * Fix BOOTSEL for RP2350 * Add simple rp2040.idleOtherCore test * Add Generic RP2350 and clean up PSRAM menus Commercial boards now only have 1 size PSRAM, no need to have menu for them. * Add Solder Party RP2350 Stamp boards (#2352) * Add PSRAM heap info helpers, mutex lock mallinfo * Add RP2350 docs * FreeRTOS and OTA unsupported warnings for RP2350
98 lines
2.7 KiB
C++
98 lines
2.7 KiB
C++
/*
|
|
PSRAM Test
|
|
|
|
This section of code tests the onboard ram of RP2350 based boards with external
|
|
PSRAM.
|
|
|
|
This example code is in the public domain.
|
|
|
|
*/
|
|
|
|
#if !defined(RP2350_PSRAM_CS)
|
|
|
|
void setup() {
|
|
Serial.println("This example needs an RP2350 with PSRAM attached");
|
|
}
|
|
|
|
void loop() {
|
|
}
|
|
|
|
#else
|
|
|
|
#define CHUNK_SIZE 131072
|
|
#define PMALLOCSIZE (CHUNK_SIZE * 13)
|
|
uint8_t tmp[CHUNK_SIZE];
|
|
uint8_t mems[1024 * 1024 * 1] PSRAM;
|
|
|
|
// the setup function runs once when you press reset or power the board
|
|
void setup() {
|
|
// initialize digital pin LED_BUILTIN as an output.
|
|
pinMode(LED_BUILTIN, OUTPUT);
|
|
while (!Serial) {
|
|
delay(10);
|
|
}
|
|
Serial.begin(115200);
|
|
Serial.printf("PSRAM Size: %d\r\n", rp2040.getPSRAMSize());
|
|
}
|
|
|
|
// the loop function runs over and over again forever
|
|
void loop() {
|
|
int i;
|
|
static int cntr = 1;
|
|
|
|
uint8_t *mem = mems;
|
|
Serial.printf("%05d: Filling %d memory locations @%p with random values and verifying in %d byte chunks.\r\n", cntr++, sizeof(mems), mem, CHUNK_SIZE);
|
|
|
|
for (size_t m = 0; m < (sizeof(mems) / CHUNK_SIZE); m++) {
|
|
for (i = 0; i < CHUNK_SIZE; i++) {
|
|
tmp[i] = (char)random(0, 255);
|
|
mem[i] = tmp[i];
|
|
}
|
|
|
|
for (i = 0; i < CHUNK_SIZE; i++) {
|
|
if (mem[i] != tmp[i]) {
|
|
Serial.printf("Memory error @%p(%d), was 0x%02x, should be 0x%02x\r\n", mem, i, *mem, tmp[i]);
|
|
delay(10);
|
|
}
|
|
}
|
|
Serial.write('.');
|
|
Serial.flush();
|
|
mem += CHUNK_SIZE;
|
|
}
|
|
Serial.printf("\r\nDone, testing %d bytes\r\n", sizeof(mems));
|
|
|
|
Serial.printf("\r\nBefore pmalloc, total PSRAM heap: %d, available PSRAM heap: %d\r\n", rp2040.getTotalPSRAMHeap(), rp2040.getFreePSRAMHeap());
|
|
uint8_t *pmem = (uint8_t *)pmalloc(PMALLOCSIZE);
|
|
if (!pmem) {
|
|
Serial.printf("Error: Unable to allocate PSRAM chunk!\r\n");
|
|
return;
|
|
}
|
|
Serial.printf("After pmalloc, total PSRAM heap: %d, available PSRAM heap: %d\r\n", rp2040.getTotalPSRAMHeap(), rp2040.getFreePSRAMHeap());
|
|
|
|
Serial.printf("Allocated block @%p, size %d\r\n", pmem, PMALLOCSIZE);
|
|
delay(3000);
|
|
mem = pmem;
|
|
for (size_t m = 0; m < (PMALLOCSIZE / CHUNK_SIZE); m++) {
|
|
for (i = 0; i < CHUNK_SIZE; i++) {
|
|
tmp[i] = (char)random(0, 255);
|
|
mem[i] = tmp[i];
|
|
}
|
|
|
|
for (i = 0; i < CHUNK_SIZE; i++) {
|
|
if (mem[i] != tmp[i]) {
|
|
Serial.printf("Memory error @%p(%d), was 0x%02x, should be 0x%02x\r\n", mem, i, *mem, tmp[i]);
|
|
delay(10);
|
|
}
|
|
}
|
|
Serial.write('.');
|
|
Serial.flush();
|
|
mem += CHUNK_SIZE;
|
|
}
|
|
Serial.printf("\nDone, testing %d allocated bytes\r\n", sizeof(mems));
|
|
free(pmem); // Release allocation for next pass
|
|
Serial.printf("After free, total PSRAM heap: %d, available PSRAM heap: %d\r\n", rp2040.getTotalPSRAMHeap(), rp2040.getFreePSRAMHeap());
|
|
|
|
delay(1000);
|
|
}
|
|
|
|
#endif // RAM_CHIP_SELECT
|