Over-The-Air FPGA Programming Using Arduino
Total Page:16
File Type:pdf, Size:1020Kb
Bachelor’s Thesis Bachelor’s Degree in Industrial Technology Engineering Over-the-air FPGA programming using Arduino Author: Alexandre Araiza i Tamarit Director: Juan Manuel Moreno Eguilaz Call: September 2020 Escola Tècnica Superior d’Enginyeria Industrial de Barcelona Acknowledgements First and foremost, I would like to thank my thesis director Juan Manuel Moreno Eguilaz for introducing me to the world of FPGAs and for helping me out along the way. I would also like to thank my parents for providing feedback about their areas of expertise and for their support during this project. Last but not least, I would like to thank the people at MoCo Makers for brin- ging FPGAs to a wider audience. If it weren’t for the Fipsy FPGA, this project wouldn’t have been possible. Abstract Field-programmable gate arrays are slowly becoming popular for many different applications, securing their place in the future of electronics. This project aims to expand on the current state of field-programmable gate array development by providing a tool that enables remote development of a commercially available field-programmable gate array using Wi-Fi, the most popular wireless networking technology. A web-based tool is developed as a result, enabling multiple users to manipulate the field-programmable gate array without the need for additional software. Table of contents Abstract ................................................................................................. 5 Glossary ................................................................................................. 9 1. Introduction ........................................................................................11 2. Theoretical foundations ..................................................................13 2.1. Data transmission .....................................................................................13 2.1.1. Serial Peripheral Interface ........................................................................13 2.1.2. Wi-Fi ........................................................................................................15 2.2. Hardware ..................................................................................................15 2.2.1. Field-programmable gate array .................................................................15 2.2.2. WeMos D1 R1 ...........................................................................................20 2.3. Software ....................................................................................................21 2.3.1. Arduino IDE .............................................................................................21 2.3.2. Lattice Diamond .......................................................................................23 3. FPGA programming ........................................................................25 3.1. FPGA Commands ....................................................................................26 3.2. User commands ......................................................................................28 3.3. JEDEC file ................................................................................................30 4. Wi-Fi implementation .....................................................................33 4.1. Hypertext Transfer Protocol .....................................................................35 4.1.1. HTTP request ...........................................................................................36 4.1.2. HTTP response .........................................................................................38 4.2. Basic request handlers ..............................................................................39 4.3. File system ................................................................................................40 4.4. File system request handlers .....................................................................41 4.5. Tool usability ............................................................................................42 5. User interface .....................................................................................43 5.1. User commands .........................................................................................44 5.2. Status messages ........................................................................................45 5.3. Managing the file list ................................................................................45 5.4. Checking JEDEC files ...............................................................................46 5.5. Web page responsiveness ..........................................................................46 6. Future updates ..................................................................................49 7. Resource use .......................................................................................51 7.1. Hardware ..................................................................................................51 7.2. Software ....................................................................................................51 7.3. Time and human resources .......................................................................52 7.4. Financial resources....................................................................................53 7.5. Environmental resources ...........................................................................54 Conclusions .........................................................................................55 Bibliography .......................................................................................57 Appendices ..........................................................................................59 Appendix 1 ...............................................................................................61 Appendix 2 ...............................................................................................87 Appendix 3 ...............................................................................................91 Appendix 4 ...............................................................................................97 Appendix 5 ............................................................................................. 105 9 Glossary AJAX Asynchronous JavaScript and XML. Set of technologies to update web pages asynchronously. IDE Integrated development environment. Software applica- tion providing tools for software development. IEEE Institute of Electrical and Electronics Engineers. Profes- sional association for electrical and electronic enginee- ring. IP address Internet Protocol address. Numerical address assigned to each device using the Internet Protocol in a computer network. IP core Intellectual property core. Reusable block of logic that is the intellectual property of an entity. LAN Local Area Network. Computer network spanning a limi- ted area, such as a residence, school or office building. LUT Lookup table. Array used to look up values usually diffi- cult to compute. Request handler Program used to process incoming requests. Robustness Ability of computer systems to deal with errors. Runtime Time span of program execution on a computer. Single-board microcontroller Microcontroller built onto a printed circuit board. 11 1. Introduction From the growing Internet of things to the rise of artificial intelligence, field-pro- grammable gate arrays are slowly making their way into the future of electronics. Their versatility allows them to be used in various industries for many different applications, and their ever-decreasing price attracts more and more people to enter the world of field-programmable gate array development. Devices are getting smaller and more connected, some of them being so small that they can be difficult to handle, making development impractical. As lots of devices use a field-programmable gate array during development, it could be helpful to use some form of connectivity to manipulate it remotely. This is the main objective of this project; developing a tool to allow a commercially available field-programmable gate array to be programmed remotely. To achieve this goal, a wireless networking technology is necessary. Wi-Fi will be used, as it is the most common technology for wireless local area networks. A single-board microcontroller will also be used to communicate with the field-pro- grammable gate array and provide Wi-Fi functionality. Software optimization will be taken into account to reduce runtime and improve robustness, but ease of use will be the top priority, as that in itself can reduce the amount of time it takes the user to learn how to use the tool as well as do different actions with it, making the user experience smoother. The final product will be the result of modifying existing source code to make use of Wi-Fi functionality on an Arduino compatible single-board microcontroller. 13 2. Theoretical foundations 2.1. Data transmission Data transmission is a fundamental part of electronics, enabling devices to com- municate with each other and thus allowing data to be manipulated from different places. For devices to understand each other, data has to be sent in the same way it is received; the device sending data and the device receiving it need to use the same communication protocol. Two different communication protocols will be used in this project. The sin- gle-board microcontroller will transfer data to the FPGA via SPI and the PC will