Describe the bug
This issue will only occur if lx_nor_flash_extended_cache_entries attribute is none zero. That is the EXTENDED_CACHE is enabled.
The function _lx_nor_flash_driver_read() can enter an infinite loop if the flash_address parameter is between 0 and (LX_NOR_SECTOR_SIZE - 1).
The infinite loop occurs because 'lx_nor_flash_extended_cache_entry_sector_address' is assigned a value of 0 at line 172 of file lx_nor_flash_driver_read.c. Once this value becomes zero line 108 can NEVER become true as the cache_entry_start value will be zero while we search for a flash_address between 0 and (LX_NOR_SECTOR_SIZE - 1) in each of the cache entries.
The only way to exit this function when cache is enabled is via line 126 or 168 so if line 108 can NEVER become true then the while() loop will run forever.
For me this issue occurs when _lx_nor_flash_next_block_to_erase_find() is called. This causes the issue because at line 110 the parameter block_word_ptr is assigned the flash_base_address which is zero. So when it starts to iterate through each of the blocks the first call _lx_nor_flash_driver_read() on line 147 is passed the block_word_ptr value which the first time through is going to be zero, and therefore never returns from _lx_nor_flash_driver_read() function.
The only way to overcome this issue is by NOT using the first block of memory in the NOR flash, so that the flash_base_address starts at LX_NOR_SECTOR_SIZE instead of zero. Or turn of EXTENDED_CACHE and take a hit in speed. Or patch the file _lx_nor_flash_driver_read() so that lx_nor_flash_extended_cache_entry_sector_address can never be assign a value of zero in the _lx_nor_flash_driver_read() function.
To Reproduce
Steps to reproduce the behavior:
- Build my project in IAR Workbench.
- See error
Expected behavior
A clear and concise description of what you expected to happen.
Impact
Showstopper
Logs and console output
If applicable, add console logs or other types of debug information like Wireshark capture as .zip file.
Additional context
Add any other context about the problem here.
Describe the bug
This issue will only occur if lx_nor_flash_extended_cache_entries attribute is none zero. That is the EXTENDED_CACHE is enabled.
The function _lx_nor_flash_driver_read() can enter an infinite loop if the flash_address parameter is between 0 and (LX_NOR_SECTOR_SIZE - 1).
The infinite loop occurs because 'lx_nor_flash_extended_cache_entry_sector_address' is assigned a value of 0 at line 172 of file lx_nor_flash_driver_read.c. Once this value becomes zero line 108 can NEVER become true as the cache_entry_start value will be zero while we search for a flash_address between 0 and (LX_NOR_SECTOR_SIZE - 1) in each of the cache entries.
The only way to exit this function when cache is enabled is via line 126 or 168 so if line 108 can NEVER become true then the while() loop will run forever.
For me this issue occurs when _lx_nor_flash_next_block_to_erase_find() is called. This causes the issue because at line 110 the parameter block_word_ptr is assigned the flash_base_address which is zero. So when it starts to iterate through each of the blocks the first call _lx_nor_flash_driver_read() on line 147 is passed the block_word_ptr value which the first time through is going to be zero, and therefore never returns from _lx_nor_flash_driver_read() function.
The only way to overcome this issue is by NOT using the first block of memory in the NOR flash, so that the flash_base_address starts at LX_NOR_SECTOR_SIZE instead of zero. Or turn of EXTENDED_CACHE and take a hit in speed. Or patch the file _lx_nor_flash_driver_read() so that lx_nor_flash_extended_cache_entry_sector_address can never be assign a value of zero in the _lx_nor_flash_driver_read() function.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
Impact
Showstopper
Logs and console output
If applicable, add console logs or other types of debug information like Wireshark capture as
.zipfile.Additional context
Add any other context about the problem here.