Friday, March 25, 2022

Testing code to load the flash chip without having an Arduino handy

WOKWI.COM ARDUINO SIMULATOR TO THE RESCUE

I don't have any Arduinos at home and, due to family visiting, am not going over to the workshop. I initially thought the best I could do was to desk check my programs, leaving actual execution until the guests have departed.

Fortunately, I discovered the Wokwi effort, an Arduino simulator, which lets me load my sketch (program) and execute it, sending text over the Serial Monitor provided by the simulator. I was able to add in plenty of diagnostic outputs, validate the results, and improve the code quality.

I was even able to wire up some virtual LEDs and slide switches so that I could see signals being asserted and change inputs. The actual chip control signals CE# and WE# are off only on the order of 30 microseconds per access of the chip, essentially they stay lit to the human eye. On the other hand, I could validate the OE# signal when the program switches to read mode for verification of the data we just wrote.

USED MY SPARE TIME AT HOME TO TEST EXHAUSTIVELY

I took advantage of the simulator to verify the operation of the program in depth, assuring me that the edge cases work properly and all the validation ensures that only properly formatted data is accepted over the USB serial link. 

The file provided with the IOB6120 to load the flash ROM does not have a specific delimiter at the end of the file, it just runs out of data, the read times out and the load command is considered complete. I decided I wanted to tailor my program with a more definitive termination, so I went to the last block of data, converted the octal block number to a 19 bit chip address and coded the outer loop to end when we finish that block.

I sent data lines with the next to last block number, which did not terminate the load portion of the program. When I sent data lines with the last block number, the code worked properly, exiting the loop after writing that block to flash.

The checksum verification for each block is just the summation of all the data bytes in the block, trimmed to the low 12 bits. I sent data lines with various values for the bytes and assured that the checksum had to match to successfully accept the block for writing. 

All the numbers must be valid octal digits, only characters '0' through '7' are acceptable. The line has mandatory spaces between the address and between each three character byte value, which I check. Too, the address has a decimal point between the block number of four octal digits and the relative byte start value of three octal digits. The end of the address is terminated by a '/' character. 

No comments:

Post a Comment