Browse Source

larger flash support

teensy4-core
PaulStoffregen 4 years ago
parent
commit
10084eca06
3 changed files with 18 additions and 2 deletions
  1. +4
    -0
      teensy4/avr/eeprom.h
  2. +6
    -0
      teensy4/bootdata.c
  3. +8
    -2
      teensy4/eeprom.c

+ 4
- 0
teensy4/avr/eeprom.h View File



#include "avr_functions.h" #include "avr_functions.h"


#if defined(ARDUINO_TEENSY40)
#define E2END 0x437 #define E2END 0x437
#elif defined(ARDUINO_TEENSY41)
#define E2END 0x10BB
#endif


#endif #endif

+ 6
- 0
teensy4/bootdata.c View File

0, // reserved 0, // reserved
0, // reserved 0, // reserved


#if defined(ARDUINO_TEENSY40)
0x00200000, // sflashA1Size 0x50 0x00200000, // sflashA1Size 0x50
#elif defined(ARDUINO_TEENSY41)
0x00800000, // sflashA1Size 0x50
#else
#error "Unknow flash chip size";
#endif
0, // sflashA2Size 0, // sflashA2Size
0, // sflashB1Size 0, // sflashB1Size
0, // sflashB2Size 0, // sflashB2Size

+ 8
- 2
teensy4/eeprom.c View File

#include <string.h> #include <string.h>
#include "debug/printf.h" #include "debug/printf.h"


#if defined(ARDUINO_TEENSY40)
#define FLASH_BASEADDR 0x601F0000 #define FLASH_BASEADDR 0x601F0000
#define FLASH_SECTORS 15 #define FLASH_SECTORS 15
#elif defined(ARDUINO_TEENSY41)
#define FLASH_BASEADDR 0x607C0000
#define FLASH_SECTORS 63
#endif



#if E2END > (255*FLASH_SECTORS-1) #if E2END > (255*FLASH_SECTORS-1)
#error "E2END is set larger than the maximum possible EEPROM size" #error "E2END is set larger than the maximum possible EEPROM size"
FLEXSPI_LUT60 = LUT0(CMD_SDR, PINS1, 0x32) | LUT1(ADDR_SDR, PINS1, 24); // 32 = quad write FLEXSPI_LUT60 = LUT0(CMD_SDR, PINS1, 0x32) | LUT1(ADDR_SDR, PINS1, 24); // 32 = quad write
FLEXSPI_LUT61 = LUT0(WRITE_SDR, PINS4, 1); FLEXSPI_LUT61 = LUT0(WRITE_SDR, PINS4, 1);
FLEXSPI_IPTXFCR = FLEXSPI_IPTXFCR_CLRIPTXF; // clear tx fifo FLEXSPI_IPTXFCR = FLEXSPI_IPTXFCR_CLRIPTXF; // clear tx fifo
FLEXSPI_IPCR0 = (uint32_t)addr & 0x001FFFFF;
FLEXSPI_IPCR0 = (uint32_t)addr & 0x007FFFFF;
FLEXSPI_IPCR1 = FLEXSPI_IPCR1_ISEQID(15) | FLEXSPI_IPCR1_IDATSZ(len); FLEXSPI_IPCR1 = FLEXSPI_IPCR1_ISEQID(15) | FLEXSPI_IPCR1_IDATSZ(len);
FLEXSPI_IPCMD = FLEXSPI_IPCMD_TRG; FLEXSPI_IPCMD = FLEXSPI_IPCMD_TRG;
const uint8_t *src = (const uint8_t *)data; const uint8_t *src = (const uint8_t *)data;
while (!(FLEXSPI_INTR & FLEXSPI_INTR_IPCMDDONE)) ; // wait while (!(FLEXSPI_INTR & FLEXSPI_INTR_IPCMDDONE)) ; // wait
FLEXSPI_INTR = FLEXSPI_INTR_IPCMDDONE; FLEXSPI_INTR = FLEXSPI_INTR_IPCMDDONE;
FLEXSPI_LUT60 = LUT0(CMD_SDR, PINS1, 0x20) | LUT1(ADDR_SDR, PINS1, 24); // 20 = sector erase FLEXSPI_LUT60 = LUT0(CMD_SDR, PINS1, 0x20) | LUT1(ADDR_SDR, PINS1, 24); // 20 = sector erase
FLEXSPI_IPCR0 = (uint32_t)addr & 0x001FF000;
FLEXSPI_IPCR0 = (uint32_t)addr & 0x007FF000;
FLEXSPI_IPCR1 = FLEXSPI_IPCR1_ISEQID(15); FLEXSPI_IPCR1 = FLEXSPI_IPCR1_ISEQID(15);
FLEXSPI_IPCMD = FLEXSPI_IPCMD_TRG; FLEXSPI_IPCMD = FLEXSPI_IPCMD_TRG;
while (!(FLEXSPI_INTR & FLEXSPI_INTR_IPCMDDONE)) ; // wait while (!(FLEXSPI_INTR & FLEXSPI_INTR_IPCMDDONE)) ; // wait

Loading…
Cancel
Save