RAK3172-F external flash: extflash.info() fails

Hi everyone,

I wanted to play with the external flash on the RAK3172-F, but I can’t even get the info to print. I’m using the example straight from the RUI3 API docs.

SUPPORT_EXTFLASH is defined, so the init code does get compiled in.

I dug into the code a bit: in udrv_extflash_init(), st ends up at 2, meaning uhal_extflash_init() returns EXTFLASH_ERR_TIMEOUT. Because of that the driver never gets flagged as initialized, and every extflash call afterwards fails.

I haven’t gone further than that yet. Can you reproduce it on your side, or is it more likely something wrong in my board setup or code?

Thanks for the help!

What RUI3 version?
Are you sure you have the RAK3172- F ?
Please share a picture of the label on the stamp module.

Hello beegee,

Thanks for your help !

I am using the 4.2.4 RUI3 version.

I am using a -F variant (as you can see below)
Capture d’écran du 2026-09-15 09-30-35

The used code is the following. I tried it with 2 different boards and both couldnt get memory info.

uint32_t extflash_test_addr = 0x0u;
void setup() {
  RAK_EXTFLASH_INFO info;
  int32_t st = api.system.extflash.info(&info);
  if (st != 0) {
    Serial.printf("[FLASH] extflash.info failed, status=%d\r\n", st);
    return;
  }

  Serial.printf("[FLASH] JEDEC: %02X %02X %02X\r\n", info.jedec_id[0], info.jedec_id[1], info.jedec_id[2]);
  Serial.printf("[FLASH] total_size=%lu, sector_size=%lu, page_size=%lu\r\n", (unsigned long)info.total_size, (unsigned long)info.sector_size, (unsigned long)info.page_size);

  static uint8_t rxbuf[16];
  memset(rxbuf, 0, sizeof(rxbuf));

  st = api.system.extflash.get(extflash_test_addr, rxbuf, sizeof(rxbuf));
  if (st != 0) {
    Serial.printf("[FLASH] read failed %d\r\n", st);
    return;
  }

  Serial.printf("[FLASH] READBACK:");
  for (uint8_t i = 0; i < sizeof(rxbuf); ++i)
    Serial.printf(" %02X", rxbuf[i]);
  Serial.printf("\r\n");
}

void loop() {
  api.system.sleep.all(30000);
}

The problem seems to come from HAL_SPI_Receive that reach time out when called in uhal_extflash_init (in udrv_extflash_init).

Not sure what is wrong, but if I use your code on a RAK3172-F, it works as expected.
Log output from your code on my RAK3172-F:

[FLASH] JEDEC: C2 23 13
[FLASH] total_size=524288, sector_size=4096, page_size=256
[FLASH] READBACK: FF FF FF FF FF FF FF FF FF FF FF FF AA 01 05 00
Current Work Mode: LoRaWAN.

Do you have anything else conected to the RAK3172-F? Anything on the GPIO’s or external SPI pins?

Indeed, i have an IMU connected to the SPI bus, its CS pin is the pin 18 (SPI1_NSS).
Does the SPI bus need to be free to allow the Memory use ?

No, it should be no problem, the internal flash is connected like this:

Flash Pin STM32WLE5 GPIO
SPI NSS PB9
SPI MISO PC2
SPI MOSI PC1
SPI SCK PB10
WP PC0
RESET PC3

I will check with R&D if there is any known problem.

Does the IMU use any GPIO’s for interrupts or other functions? If yes, which GPIO’s does it use?

If I’m right, all the pins you listed are internal to the module: none of them are exposed on the RAK3172-F pads ?

Here is how the module is wired on my board:


In the previous version of my PCB, the module was a RAK3172-T. That’s why the pins specific to the -F are not here, they are left unconnected.

The IMU has an interrupt on IO5 (PA15), but the test sketch doesn’t configure any of my pins: it only contains the code I posted above.

Do you have an option to test the module without peripherals, or at least without the external SPI device?

I connected an external SPI FLASH module and run your code without problems.

I will try removing my peripherals one by one.

Could you share your compiled .hex please ?
I want to make sure that my compilation toolchain isn’t the problem.

Here is the compiled hex file RAK3172-F-Flash-Wear.ino.hex (497.7 KB)

This is my Flash wear test application, but the Flash chip check is exactly the same code as in your application.

Good news !

The problem seems to be with my compilation. Here is the result with your .hex :

Flash wear test started.
Flash JEDEC: C2 23 13
Flash total_size=524288, sector_size=4096, page_size=256
valid1 0 valid2 0 block# 9
valid1 FF valid2 ff block# 8
valid1 FF valid2 ff block# 7
valid1 FF valid2 ff block# 6
valid1 FF valid2 ff block# 5
valid1 FF valid2 ff block# 4
valid1 FF valid2 ff block# 3
valid1 FF valid2 ff block# 2
valid1 FF valid2 ff block# 1
valid1 AA valid2 0 block# 0
Valid block found 0
Flash init success
Read block 0
Valid data read: 
mySettings.counter: 1
mySettings.value: 0.00
mySettings.is_active: 1
Last block used 0
Available blocks = 10
Current Work Mode: LoRaWAN.
Data written to block 1
>> Counter: 1
>> Value: 0.010000
Data read back from block: 1
>> Counter: 1
>> Value: 0.010000
Data written to block 2
>> Counter: 2
>> Value: 0.020000
Data read back from block: 2
>> Counter: 2
>> Value: 0.020000
Data written to block 3

I will check my configuration again.

Update :

After redownloading the RUI3 v4.2.4 firmware, the example code is now working perfectly. I’m not sure how I managed to corrupt my previous firmware, but that seems to have been the issue!

Thanks for your help!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.