Intel® FPGA University Program
University Program Material, Education Boards, and Laboratory Exercises

SD Card HAL API bug

Honored Contributor II

Not sure if someone has posted this before. 


There is a bug in the function "alt_up_sd_card_read()


When reading the byte from SD card (line 1733), the data is cast to (char) and then returned as (short int). However, if the byte read is 0xFF, it will be sign extended and 0xFFFF will be returned. Unfortunately this is the same as -1, indicating end of file. Thus, there is no way to distinguish between an EOF and reading a 0xFF.  


the correction is to cast to (unsigned char) before returning. 


For my installation, the file is located here: 

0 Kudos
0 Replies