@@ -120,7 +120,7 @@ SPIFBlockDevice::SPIFBlockDevice(
120
120
_region_erase_types_bitfield[0 ] = ERASE_BITMASK_NONE;
121
121
122
122
if (SPIF_BD_ERROR_OK != _spi_set_frequency (freq)) {
123
- tr_error (" ERROR: SPI Set Frequency Failed" );
123
+ tr_error (" SPI Set Frequency Failed" );
124
124
}
125
125
126
126
_cs = 1 ;
@@ -151,7 +151,7 @@ int SPIFBlockDevice::init()
151
151
152
152
// Soft Reset
153
153
if (-1 == _reset_flash_mem ()) {
154
- tr_error (" ERROR: init - Unable to initialize flash memory, tests failed\n " );
154
+ tr_error (" init - Unable to initialize flash memory, tests failed" );
155
155
status = SPIF_BD_ERROR_DEVICE_ERROR;
156
156
goto exit_point;
157
157
}
@@ -160,7 +160,7 @@ int SPIFBlockDevice::init()
160
160
spi_status = _spi_send_general_command (SPIF_RDID, SPI_NO_ADDRESS_COMMAND, NULL , 0 , (char *)vendor_device_ids,
161
161
data_length);
162
162
if (spi_status != SPIF_BD_ERROR_OK) {
163
- tr_error (" ERROR: init - Read Vendor ID Failed" );
163
+ tr_error (" init - Read Vendor ID Failed" );
164
164
status = SPIF_BD_ERROR_DEVICE_ERROR;
165
165
goto exit_point;
166
166
}
@@ -176,22 +176,22 @@ int SPIFBlockDevice::init()
176
176
177
177
// Synchronize Device
178
178
if (false == _is_mem_ready ()) {
179
- tr_error (" ERROR: init - _is_mem_ready Failed" );
179
+ tr_error (" init - _is_mem_ready Failed" );
180
180
status = SPIF_BD_ERROR_READY_FAILED;
181
181
goto exit_point;
182
182
}
183
183
184
184
/* *************************** Parse SFDP Header ***********************************/
185
185
if (0 != _sfdp_parse_sfdp_headers (basic_table_addr, basic_table_size, sector_map_table_addr, sector_map_table_size)) {
186
- tr_error (" ERROR: init - Parse SFDP Headers Failed" );
186
+ tr_error (" init - Parse SFDP Headers Failed" );
187
187
status = SPIF_BD_ERROR_PARSING_FAILED;
188
188
goto exit_point;
189
189
}
190
190
191
191
192
192
/* *************************** Parse Basic Parameters Table ***********************************/
193
193
if (0 != _sfdp_parse_basic_param_table (basic_table_addr, basic_table_size)) {
194
- tr_error (" ERROR: init - Parse Basic Param Table Failed" );
194
+ tr_error (" init - Parse Basic Param Table Failed" );
195
195
status = SPIF_BD_ERROR_PARSING_FAILED;
196
196
goto exit_point;
197
197
}
@@ -203,7 +203,7 @@ int SPIFBlockDevice::init()
203
203
204
204
if ((sector_map_table_addr != 0 ) && (0 != sector_map_table_size)) {
205
205
if (0 != _sfdp_parse_sector_map_table (sector_map_table_addr, sector_map_table_size)) {
206
- tr_error (" ERROR: init - Parse Sector Map Table Failed" );
206
+ tr_error (" init - Parse Sector Map Table Failed" );
207
207
status = SPIF_BD_ERROR_PARSING_FAILED;
208
208
goto exit_point;
209
209
}
@@ -213,6 +213,7 @@ int SPIFBlockDevice::init()
213
213
// Dummy And Mode Cycles Back default 0
214
214
_dummy_and_mode_cycles = _write_dummy_and_mode_cycles;
215
215
_is_initialized = true ;
216
+ tr_debug (" Device size: %llu Kbytes" , _device_size_bytes / 1024 );
216
217
217
218
if (_device_size_bytes > (1 << 24 )) {
218
219
tr_debug (" Size is bigger than 16MB and thus address does not fit in 3 byte, switch to 4 byte address mode" );
@@ -247,7 +248,7 @@ int SPIFBlockDevice::deinit()
247
248
// Disable Device for Writing
248
249
status = _spi_send_general_command (SPIF_WRDI, SPI_NO_ADDRESS_COMMAND, NULL , 0 , NULL , 0 );
249
250
if (status != SPIF_BD_ERROR_OK) {
250
- tr_error (" ERROR: Write Disable failed" );
251
+ tr_error (" Write Disable failed" );
251
252
}
252
253
_is_initialized = false ;
253
254
@@ -299,7 +300,7 @@ int SPIFBlockDevice::program(const void *buffer, bd_addr_t addr, bd_size_t size)
299
300
300
301
// Send WREN
301
302
if (_set_write_enable () != 0 ) {
302
- tr_error (" ERROR: Write Enabe failed\n " );
303
+ tr_error (" Write Enabe failed" );
303
304
program_failed = true ;
304
305
status = SPIF_BD_ERROR_WREN_FAILED;
305
306
goto exit_point;
@@ -312,7 +313,7 @@ int SPIFBlockDevice::program(const void *buffer, bd_addr_t addr, bd_size_t size)
312
313
size -= chunk;
313
314
314
315
if (false == _is_mem_ready ()) {
315
- tr_error (" ERROR: Device not ready after write, failed\n " );
316
+ tr_error (" Device not ready after write, failed" );
316
317
program_failed = true ;
317
318
status = SPIF_BD_ERROR_READY_FAILED;
318
319
goto exit_point;
@@ -347,12 +348,12 @@ int SPIFBlockDevice::erase(bd_addr_t addr, bd_size_t in_size)
347
348
uint8_t bitfield = _region_erase_types_bitfield[region];
348
349
349
350
if ((addr + in_size) > _device_size_bytes) {
350
- tr_error (" ERROR: erase exceeds flash device size" );
351
+ tr_error (" erase exceeds flash device size" );
351
352
return SPIF_BD_ERROR_INVALID_ERASE_PARAMS;
352
353
}
353
354
354
355
if (((addr % get_erase_size (addr)) != 0 ) || (((addr + in_size) % get_erase_size (addr + in_size - 1 )) != 0 )) {
355
- tr_error (" ERROR: invalid erase - unaligned address and size" );
356
+ tr_error (" invalid erase - unaligned address and size" );
356
357
return SPIF_BD_ERROR_INVALID_ERASE_PARAMS;
357
358
}
358
359
@@ -369,7 +370,7 @@ int SPIFBlockDevice::erase(bd_addr_t addr, bd_size_t in_size)
369
370
_mutex->lock ();
370
371
371
372
if (_set_write_enable () != 0 ) {
372
- tr_error (" ERROR: SPI Erase Device not ready - failed" );
373
+ tr_error (" SPI Erase Device not ready - failed" );
373
374
erase_failed = true ;
374
375
status = SPIF_BD_ERROR_READY_FAILED;
375
376
goto exit_point;
@@ -387,7 +388,7 @@ int SPIFBlockDevice::erase(bd_addr_t addr, bd_size_t in_size)
387
388
}
388
389
389
390
if (false == _is_mem_ready ()) {
390
- tr_error (" ERROR: SPI After Erase Device not ready - failed\n " );
391
+ tr_error (" SPI After Erase Device not ready - failed" );
391
392
erase_failed = true ;
392
393
status = SPIF_BD_ERROR_READY_FAILED;
393
394
goto exit_point;
@@ -446,7 +447,7 @@ bd_size_t SPIFBlockDevice::get_erase_size(bd_addr_t addr)
446
447
}
447
448
448
449
if (i_ind == 4 ) {
449
- tr_error (" ERROR: no erase type was found for region addr" );
450
+ tr_error (" no erase type was found for region addr" );
450
451
}
451
452
}
452
453
@@ -605,19 +606,19 @@ int SPIFBlockDevice::_sfdp_parse_sector_map_table(uint32_t sector_map_table_addr
605
606
spif_bd_error status = _spi_send_read_command (SPIF_SFDP, sector_map_table, sector_map_table_addr /* address*/ ,
606
607
sector_map_table_size);
607
608
if (status != SPIF_BD_ERROR_OK) {
608
- tr_error (" ERROR: init - Read SFDP First Table Failed" );
609
+ tr_error (" init - Read SFDP First Table Failed" );
609
610
return -1 ;
610
611
}
611
612
612
613
// Currently we support only Single Map Descriptor
613
614
if (!((sector_map_table[0 ] & 0x3 ) == 0x03 ) && (sector_map_table[1 ] == 0x0 )) {
614
- tr_error (" ERROR: Sector Map - Supporting Only Single! Map Descriptor (not map commands)" );
615
+ tr_error (" Sector Map - Supporting Only Single! Map Descriptor (not map commands)" );
615
616
return -1 ;
616
617
}
617
618
618
619
_regions_count = sector_map_table[2 ] + 1 ;
619
620
if (_regions_count > SPIF_MAX_REGIONS) {
620
- tr_error (" ERROR: Supporting up to %d regions, current setup to %d regions - fail" ,
621
+ tr_error (" Supporting up to %d regions, current setup to %d regions - fail" ,
621
622
SPIF_MAX_REGIONS, _regions_count);
622
623
return -1 ;
623
624
}
@@ -659,13 +660,13 @@ int SPIFBlockDevice::_sfdp_parse_basic_param_table(uint32_t basic_table_addr, si
659
660
spif_bd_error status = _spi_send_read_command (SPIF_SFDP, param_table, basic_table_addr /* address*/ ,
660
661
basic_table_size);
661
662
if (status != SPIF_BD_ERROR_OK) {
662
- tr_error (" ERROR: init - Read SFDP First Table Failed" );
663
+ tr_error (" init - Read SFDP First Table Failed" );
663
664
return -1 ;
664
665
}
665
666
666
667
// Check address size, currently only supports 3byte addresses
667
668
if ((param_table[2 ] & 0x4 ) != 0 || (param_table[7 ] & 0x80 ) != 0 ) {
668
- tr_error (" ERROR: init - verify 3byte addressing Failed" );
669
+ tr_error (" init - verify 3byte addressing Failed" );
669
670
return -1 ;
670
671
}
671
672
@@ -676,6 +677,7 @@ int SPIFBlockDevice::_sfdp_parse_basic_param_table(uint32_t basic_table_addr, si
676
677
(param_table[5 ] << 8 ) |
677
678
param_table[4 ]);
678
679
_device_size_bytes = (density_bits + 1 ) / 8 ;
680
+ tr_debug (" Density bits: %ld , device size: %llu bytes" , density_bits, _device_size_bytes);
679
681
680
682
// Set Default read/program/erase Instructions
681
683
_read_instruction = SPIF_READ;
@@ -711,14 +713,14 @@ int SPIFBlockDevice::_sfdp_parse_sfdp_headers(uint32_t &basic_table_addr, size_t
711
713
712
714
spif_bd_error status = _spi_send_read_command (SPIF_SFDP, sfdp_header, addr /* address*/ , data_length);
713
715
if (status != SPIF_BD_ERROR_OK) {
714
- tr_error (" ERROR: init - Read SFDP Failed" );
716
+ tr_error (" init - Read SFDP Failed" );
715
717
return -1 ;
716
718
}
717
719
718
720
// Verify SFDP signature for sanity
719
721
// Also check that major/minor version is acceptable
720
722
if (!(memcmp (&sfdp_header[0 ], " SFDP" , 4 ) == 0 && sfdp_header[5 ] == 1 )) {
721
- tr_error (" ERROR: init - _verify SFDP signature and version Failed" );
723
+ tr_error (" init - _verify SFDP signature and version Failed" );
722
724
return -1 ;
723
725
}
724
726
@@ -733,14 +735,14 @@ int SPIFBlockDevice::_sfdp_parse_sfdp_headers(uint32_t &basic_table_addr, size_t
733
735
734
736
status = _spi_send_read_command (SPIF_SFDP, param_header, addr, data_length);
735
737
if (status != SPIF_BD_ERROR_OK) {
736
- tr_error (" ERROR: init - Read Param Table %d Failed" , i_ind + 1 );
738
+ tr_error (" init - Read Param Table %d Failed" , i_ind + 1 );
737
739
return -1 ;
738
740
}
739
741
740
742
// The SFDP spec indicates the standard table is always at offset 0
741
743
// in the parameter headers, we check just to be safe
742
744
if (param_header[2 ] != 1 ) {
743
- tr_error (" ERROR: Param Table %d - Major Version should be 1!" , i_ind + 1 );
745
+ tr_error (" Param Table %d - Major Version should be 1!" , i_ind + 1 );
744
746
return -1 ;
745
747
}
746
748
@@ -806,7 +808,7 @@ int SPIFBlockDevice::_sfdp_detect_erase_types_inst_and_size(uint8_t *basic_param
806
808
if (erase4k_inst != erase_type_inst_arr[i_ind]) {
807
809
// Verify 4KErase Type is identical to Legacy 4K erase type specified in Byte 1 of Param Table
808
810
erase4k_inst = erase_type_inst_arr[i_ind];
809
- tr_warning (" WARNING: _detectEraseTypesInstAndSize - Default 4K erase Inst is different than erase type Inst for 4K" );
811
+ tr_warning (" _detectEraseTypesInstAndSize - Default 4K erase Inst is different than erase type Inst for 4K" );
810
812
811
813
}
812
814
}
@@ -818,7 +820,7 @@ int SPIFBlockDevice::_sfdp_detect_erase_types_inst_and_size(uint8_t *basic_param
818
820
}
819
821
820
822
if (false == found_4Kerase_type) {
821
- tr_warning (" WARNING: Couldn't find Erase Type for 4KB size" );
823
+ tr_warning (" Couldn't find Erase Type for 4KB size" );
822
824
}
823
825
return 0 ;
824
826
}
@@ -881,7 +883,7 @@ int SPIFBlockDevice::_reset_flash_mem()
881
883
if (SPIF_BD_ERROR_OK == _spi_send_general_command (SPIF_RSTEN, SPI_NO_ADDRESS_COMMAND, NULL , 0 , NULL , 0 )) {
882
884
// store received values in status_value
883
885
} else {
884
- tr_error (" ERROR: Sending RSTEN failed\n " );
886
+ tr_error (" Sending RSTEN failed" );
885
887
status = -1 ;
886
888
}
887
889
@@ -890,7 +892,7 @@ int SPIFBlockDevice::_reset_flash_mem()
890
892
if (SPIF_BD_ERROR_OK == _spi_send_general_command (SPIF_RST, SPI_NO_ADDRESS_COMMAND, NULL , 0 , NULL , 0 )) {
891
893
// store received values in status_value
892
894
} else {
893
- tr_error (" ERROR: Sending RST failed\n " );
895
+ tr_error (" Sending RST failed" );
894
896
status = -1 ;
895
897
}
896
898
_is_mem_ready ();
@@ -913,12 +915,12 @@ bool SPIFBlockDevice::_is_mem_ready()
913
915
// Read the Status Register from device
914
916
if (SPIF_BD_ERROR_OK != _spi_send_general_command (SPIF_RDSR, SPI_NO_ADDRESS_COMMAND, NULL , 0 , status_value,
915
917
1 )) { // store received values in status_value
916
- tr_error (" ERROR: Reading Status Register failed\n " );
918
+ tr_error (" Reading Status Register failed" );
917
919
}
918
920
} while ((status_value[0 ] & SPIF_STATUS_BIT_WIP) != 0 && retries < IS_MEM_READY_MAX_RETRIES);
919
921
920
922
if ((status_value[0 ] & SPIF_STATUS_BIT_WIP) != 0 ) {
921
- tr_error (" ERROR: _is_mem_ready FALSE\n " );
923
+ tr_error (" _is_mem_ready FALSE" );
922
924
mem_ready = false ;
923
925
}
924
926
return mem_ready;
@@ -932,24 +934,24 @@ int SPIFBlockDevice::_set_write_enable()
932
934
933
935
do {
934
936
if (SPIF_BD_ERROR_OK != _spi_send_general_command (SPIF_WREN, SPI_NO_ADDRESS_COMMAND, NULL , 0 , NULL , 0 )) {
935
- tr_error (" ERROR: Sending WREN command FAILED\n " );
937
+ tr_error (" Sending WREN command FAILED" );
936
938
break ;
937
939
}
938
940
939
941
if (false == _is_mem_ready ()) {
940
- tr_error (" ERROR: Device not ready, write failed" );
942
+ tr_error (" Device not ready, write failed" );
941
943
break ;
942
944
}
943
945
944
946
memset (status_value, 0 , 2 );
945
947
if (SPIF_BD_ERROR_OK != _spi_send_general_command (SPIF_RDSR, SPI_NO_ADDRESS_COMMAND, NULL , 0 , status_value,
946
948
1 )) { // store received values in status_value
947
- tr_error (" ERROR: Reading Status Register failed\n " );
949
+ tr_error (" Reading Status Register failed" );
948
950
break ;
949
951
}
950
952
951
953
if ((status_value[0 ] & SPIF_STATUS_BIT_WEL) == 0 ) {
952
- tr_error (" ERROR: _set_write_enable failed\n " );
954
+ tr_error (" _set_write_enable failed" );
953
955
break ;
954
956
}
955
957
status = 0 ;
@@ -1002,7 +1004,7 @@ int SPIFBlockDevice::_utils_iterate_next_largest_erase_type(uint8_t &bitfield, i
1002
1004
}
1003
1005
1004
1006
if (i_ind == 4 ) {
1005
- tr_error (" ERROR: no erase type was found for current region addr" );
1007
+ tr_error (" no erase type was found for current region addr" );
1006
1008
}
1007
1009
return largest_erase_type;
1008
1010
0 commit comments