diff --git a/platforms/nuttx/src/px4/common/px4_mtd.cpp b/platforms/nuttx/src/px4/common/px4_mtd.cpp index 6723c35eca..5e66af2450 100644 --- a/platforms/nuttx/src/px4/common/px4_mtd.cpp +++ b/platforms/nuttx/src/px4/common/px4_mtd.cpp @@ -300,6 +300,7 @@ int px4_mtd_config(const px4_mtd_manifest_t *mft_mtd) for (uint8_t i = num_instances, num_entry = 0u; i < total_new_instances; ++i, ++num_entry) { + rv = -ENOMEM; instances[i] = new mtd_instance_s; if (instances[i] == nullptr) { @@ -315,7 +316,6 @@ memoryout: instances[i]->mtd_dev = nullptr; instances[i]->n_partitions_current = 0; - rv = -ENOMEM; instances[i]->part_dev = new FAR struct mtd_dev_s *[nparts]; if (instances[i]->part_dev == nullptr) { @@ -358,8 +358,12 @@ memoryout: #endif } else if (mtd_list->entries[num_entry]->device->bus_type == px4_mft_device_t::ONCHIP) { - instances[i]->n_partitions_current++; - return 0; + /* ONCHIP type is registered externally. + * Populate the query table for all partitions and skip the MTD attach / geometry + * steps. */ + instances[i]->n_partitions_current = nparts; + rv = 0; + continue; } if (rv != 0) {