Fix integer type warnings in SFDP and *SPIFBlockDevice

pull/13947/head
Lingkai Dong 2020-11-26 10:06:53 +00:00
parent fb0f9687e4
commit c41f7cb864
5 changed files with 31 additions and 32 deletions

View File

@ -144,8 +144,8 @@ int sfdp_find_addr_region(bd_addr_t offset, const sfdp_hdr_info &sfdp_info);
* @return Largest erase type, or -1 if none matches the given address and size
*/
int sfdp_iterate_next_largest_erase_type(uint8_t bitfield,
int size,
int offset,
bd_size_t size,
bd_addr_t offset,
int region,
const sfdp_smptbl_info &smptbl);

View File

@ -394,8 +394,8 @@ int sfdp_find_addr_region(bd_addr_t offset, const sfdp_hdr_info &sfdp_info)
}
int sfdp_iterate_next_largest_erase_type(uint8_t bitfield,
int size,
int offset,
bd_size_t size,
bd_addr_t offset,
int region,
const sfdp_smptbl_info &smptbl)
{

View File

@ -31,6 +31,7 @@
#include "mbed_trace.h"
#define TRACE_GROUP "OSPIF"
using namespace std::chrono;
using namespace mbed;
/* Default OSPIF Parameters */
@ -409,7 +410,7 @@ int OSPIFBlockDevice::program(const void *buffer, bd_addr_t addr, bd_size_t size
uint32_t chunk = 0;
bd_size_t written_bytes = 0;
tr_debug("Program - Buff: 0x%lxh, addr: %llu, size: %llu", (uint32_t)buffer, addr, size);
tr_debug("Program - Buff: %p, addr: %llu, size: %llu", buffer, addr, size);
while (size > 0) {
// Write on _page_size_bytes boundaries (Default 256 bytes a page)
@ -457,11 +458,10 @@ exit_point:
return status;
}
int OSPIFBlockDevice::erase(bd_addr_t addr, bd_size_t in_size)
int OSPIFBlockDevice::erase(bd_addr_t addr, bd_size_t size)
{
int type = 0;
ospi_inst_t cur_erase_inst = OSPI_NO_INST;
int size = (int)in_size;
bool erase_failed = false;
int status = OSPIF_BD_ERROR_OK;
// Find region of erased address
@ -469,14 +469,14 @@ int OSPIFBlockDevice::erase(bd_addr_t addr, bd_size_t in_size)
// Erase Types of selected region
uint8_t bitfield = _sfdp_info.smptbl.region_erase_types_bitfld[region];
tr_debug("Erase - addr: %llu, in_size: %llu", addr, in_size);
tr_debug("Erase - addr: %llu, size: %llu", addr, size);
if ((addr + in_size) > _sfdp_info.bptbl.device_size_bytes) {
if ((addr + size) > _sfdp_info.bptbl.device_size_bytes) {
tr_error("Erase exceeds flash device size");
return OSPIF_BD_ERROR_INVALID_ERASE_PARAMS;
}
if (((addr % get_erase_size(addr)) != 0) || (((addr + in_size) % get_erase_size(addr + in_size - 1)) != 0)) {
if (((addr % get_erase_size(addr)) != 0) || (((addr + size) % get_erase_size(addr + size - 1)) != 0)) {
tr_error("Invalid erase - unaligned address and size");
return OSPIF_BD_ERROR_INVALID_ERASE_PARAMS;
}
@ -502,11 +502,11 @@ int OSPIFBlockDevice::erase(bd_addr_t addr, bd_size_t in_size)
if (addr % eu_size != 0 || addr + size < eu_size) {
// Should not happen if the erase table parsing
// and alignment checks were performed correctly
tr_error("internal error: address %llu not aligned to erase size %llu (type %d)",
tr_error("internal error: address %llu not aligned to erase size %u (type %d)",
addr, eu_size, type);
}
tr_debug("Erase - addr: %llu, size:%d, Inst: 0x%xh, erase size: %lu ",
tr_debug("Erase - addr: %llu, size:%llu, Inst: 0x%xh, erase size: %u ",
addr, size, cur_erase_inst, eu_size);
tr_debug("Erase - Region: %d, Type:%d ",
region, type);
@ -1520,7 +1520,7 @@ bool OSPIFBlockDevice::_is_mem_ready()
bool mem_ready = true;
do {
rtos::ThisThread::sleep_for(1);
rtos::ThisThread::sleep_for(1ms);
retries++;
//Read Status Register 1 from device, the number of read byte need to be even in octa flash DOPI mode
if (OSPI_STATUS_OK != _ospi_send_general_command(OSPIF_INST_RSR1, OSPI_NO_ADDRESS_COMMAND,
@ -1668,7 +1668,7 @@ ospi_status_t OSPIFBlockDevice::_ospi_send_general_command(ospi_inst_t instructi
_ospi.configure_format(_inst_width, _inst_size, _address_width, _address_size, OSPI_CFG_BUS_SINGLE,
0, _data_width, 4);
addr = 0;
} else if ((instruction == OSPIF_INST_WSR1)) {
} else if (instruction == OSPIF_INST_WSR1) {
addr = 0;
}
}

View File

@ -338,7 +338,7 @@ int QSPIFBlockDevice::program(const void *buffer, bd_addr_t addr, bd_size_t size
uint32_t chunk = 0;
bd_size_t written_bytes = 0;
tr_debug("Program - Buff: 0x%lxh, addr: %llu, size: %llu", (uint32_t)buffer, addr, size);
tr_debug("Program - Buff: %p, addr: %llu, size: %llu", buffer, addr, size);
while (size > 0) {
// Write on _page_size_bytes boundaries (Default 256 bytes a page)
@ -385,11 +385,10 @@ exit_point:
return status;
}
int QSPIFBlockDevice::erase(bd_addr_t addr, bd_size_t in_size)
int QSPIFBlockDevice::erase(bd_addr_t addr, bd_size_t size)
{
int type = 0;
qspi_inst_t cur_erase_inst = QSPI_NO_INST;
int size = (int)in_size;
bool erase_failed = false;
int status = QSPIF_BD_ERROR_OK;
// Find region of erased address
@ -397,14 +396,14 @@ int QSPIFBlockDevice::erase(bd_addr_t addr, bd_size_t in_size)
// Erase Types of selected region
uint8_t bitfield = _sfdp_info.smptbl.region_erase_types_bitfld[region];
tr_debug("Erase - addr: %llu, in_size: %llu", addr, in_size);
tr_debug("Erase - addr: %llu, size: %llu", addr, size);
if ((addr + in_size) > _sfdp_info.bptbl.device_size_bytes) {
if ((addr + size) > _sfdp_info.bptbl.device_size_bytes) {
tr_error("Erase exceeds flash device size");
return QSPIF_BD_ERROR_INVALID_ERASE_PARAMS;
}
if (((addr % get_erase_size(addr)) != 0) || (((addr + in_size) % get_erase_size(addr + in_size - 1)) != 0)) {
if (((addr % get_erase_size(addr)) != 0) || (((addr + size) % get_erase_size(addr + size - 1)) != 0)) {
tr_error("Invalid erase - unaligned address and size");
return QSPIF_BD_ERROR_INVALID_ERASE_PARAMS;
}
@ -415,7 +414,7 @@ int QSPIFBlockDevice::erase(bd_addr_t addr, bd_size_t in_size)
if (_sfdp_info.bptbl.legacy_erase_instruction == QSPI_NO_INST) {
// Iterate to find next largest erase type that is a) supported by region, and b) smaller than size.
// Find the matching instruction and erase size chunk for that type.
type = sfdp_iterate_next_largest_erase_type(bitfield, size, (int)addr,
type = sfdp_iterate_next_largest_erase_type(bitfield, size, addr,
region,
_sfdp_info.smptbl);
cur_erase_inst = _sfdp_info.smptbl.erase_type_inst_arr[type];
@ -429,11 +428,11 @@ int QSPIFBlockDevice::erase(bd_addr_t addr, bd_size_t in_size)
if (addr % eu_size != 0 || addr + size < eu_size) {
// Should not happen if the erase table parsing
// and alignment checks were performed correctly
tr_error("internal error: address %llu not aligned to erase size %llu (type %d)",
tr_error("internal error: address %llu not aligned to erase size %u (type %d)",
addr, eu_size, type);
}
tr_debug("Erase - addr: %llu, size:%d, Inst: 0x%xh, erase size: %lu ",
tr_debug("Erase - addr: %llu, size:%llu, Inst: 0x%xh, erase size: %u",
addr, size, cur_erase_inst, eu_size);
tr_debug("Erase - Region: %d, Type:%d ",
region, type);

View File

@ -25,6 +25,7 @@
#include "mbed_trace.h"
#define TRACE_GROUP "SPIF"
using namespace std::chrono;
using namespace mbed;
/* Default SPIF Parameters */
@ -298,7 +299,7 @@ exit_point:
return status;
}
int SPIFBlockDevice::erase(bd_addr_t addr, bd_size_t in_size)
int SPIFBlockDevice::erase(bd_addr_t addr, bd_size_t size)
{
if (!_is_initialized) {
return BD_ERROR_DEVICE_ERROR;
@ -307,7 +308,6 @@ int SPIFBlockDevice::erase(bd_addr_t addr, bd_size_t in_size)
int type = 0;
int cur_erase_inst = _erase_instruction;
unsigned int curr_erase_size = 0;
int size = (int)in_size;
bool erase_failed = false;
int status = SPIF_BD_ERROR_OK;
// Find region of erased address
@ -319,14 +319,14 @@ int SPIFBlockDevice::erase(bd_addr_t addr, bd_size_t in_size)
// Erase Types of selected region
uint8_t bitfield = _sfdp_info.smptbl.region_erase_types_bitfld[region];
tr_debug("erase - addr: %llu, in_size: %llu", addr, in_size);
tr_debug("erase - addr: %llu, size: %llu", addr, size);
if ((addr + in_size) > _sfdp_info.bptbl.device_size_bytes) {
if ((addr + size) > _sfdp_info.bptbl.device_size_bytes) {
tr_error("erase exceeds flash device size");
return SPIF_BD_ERROR_INVALID_ERASE_PARAMS;
}
if (((addr % get_erase_size(addr)) != 0) || (((addr + in_size) % get_erase_size(addr + in_size - 1)) != 0)) {
if (((addr % get_erase_size(addr)) != 0) || (((addr + size) % get_erase_size(addr + size - 1)) != 0)) {
tr_error("invalid erase - unaligned address and size");
return SPIF_BD_ERROR_INVALID_ERASE_PARAMS;
}
@ -336,17 +336,17 @@ int SPIFBlockDevice::erase(bd_addr_t addr, bd_size_t in_size)
// iterate to find next Largest erase type ( a. supported by region, b. smaller than size)
// find the matching instruction and erase size chunk for that type.
type = sfdp_iterate_next_largest_erase_type(bitfield, size, (unsigned int)addr, region, _sfdp_info.smptbl);
type = sfdp_iterate_next_largest_erase_type(bitfield, size, addr, region, _sfdp_info.smptbl);
cur_erase_inst = _sfdp_info.smptbl.erase_type_inst_arr[type];
curr_erase_size = _sfdp_info.smptbl.erase_type_size_arr[type];
if (addr % curr_erase_size != 0 || addr + size < curr_erase_size) {
// Should not happen if the erase table parsing
// and alignment checks were performed correctly
tr_error("internal error: address %llu not aligned to erase size %llu (type %d)",
tr_error("internal error: address %llu not aligned to erase size %u (type %d)",
addr, curr_erase_size, type);
}
tr_debug("erase - addr: %llu, size:%d, Inst: 0x%xh, erase size: %" PRIu32 " , ",
tr_debug("erase - addr: %llu, size:%llu, Inst: 0x%xh, erase size: %u",
addr, size, cur_erase_inst, curr_erase_size);
tr_debug("erase - Region: %d, Type:%d",
region, type);
@ -696,7 +696,7 @@ bool SPIFBlockDevice::_is_mem_ready()
bool mem_ready = true;
do {
rtos::ThisThread::sleep_for(1);
rtos::ThisThread::sleep_for(1ms);
retries++;
//Read the Status Register from device
if (SPIF_BD_ERROR_OK != _spi_send_general_command(SPIF_RDSR, SPI_NO_ADDRESS_COMMAND, NULL, 0, status_value,