====== Firmware Installation ====== original source(([[http://en.blitzortung.org/Compendium/Documentations/Documentation_2014-05-11_Red_PCB_10.4_PCB_12.3_PCB_13.1_PCB_14.1.pdf|Documentation System RED]], chapter 5.1)) The firmware on the STM32F4 controller is the heart of the System RED. It initializes and controls all peripherals and performs the communication with the servers. Compared to the System GREEN, the firmware is very complex but also very powerful. Especially during the first months after start of System RED, there have been several updates to improve stability and add new features. After assembly of the system, you have to install the firmware over the dedicated USB port. There is already a small pre-flashed firmware on your new STM32F4DISCOVERY, which lets the LEDs blink according to accelerometer value. This is only a demonstration and it will be overwritten by our firmware. Never flash any other 3rd party firmware on the STM32F4DISCOVERY, while it is connected to our PCB! Otherwise parts on both of the PCBs or the CPU might be damaged! ===== Flash by using on-board programmer ===== The STM32F4DISCOVERY has an ST-Link V2 programmer integrated. The flash procedure is easy and takes only some seconds. It is almost impossble to brick the STM32F4DISCOVERY, even if you pull the cable while flashing, because the on-board programmer has direct access to the flash memory. Please never set any user option bits, otherwise the flash might be write protected forever! There are several tools for flashing the STM32 family on different operating systems. These tools can be used for different hardware types and are not specific for our hardware. You have to download them from their official websites: * [[https://www.st.com/en/development-tools/stsw-link004.html|STM32 ST-Link utility]] * [[http://www.coocox.org/CoFlash_Programmer.htm|CooCox CoFlash]] * [[https://github.com/texane/stlink|stlink]] (Linux/Mac) * Several others... For the following description, we use the official STM32 ST-Link utility (version 3). First of all, download the tool [[https://www.st.com/en/development-tools/stsw-link004.html|here]]. If you don’t find the download, then try Google. After download, run the setup. The driver is also included in the package. The current version finally supports Windows 8 and 8.1. Follow these steps, to program the flash: - USB connection: Connect the mini-USB jack on the STM32F4DISCOVERY with a cable to your computer (see Fig. 49). If you do this the first time, the driver will be installed, which can take a while. While connected to the USB port, the CPU gets the necessary power from your computer. It doesn’t matter whether the system is powered by external 5V or not while flashing. There is no need to remove the Discovery from the red PCB, as there is a good chance to damage it mechanically or electrically during this procedure. When the connection is established successfully, the big ST-Link LED should stay red. If it is blinking red, then there is a connection or driver problem. - Open the programmer window (see Fig. 50): Start the STM32 ST-LINK Utility. In this tool, select Target->Program... from menu, click Browse and select the Firmware (.bin) file. - Start flashing (see Fig. 51): Check if the Start address is 0x08000000 and click on Start. The data is now programmed into the flash. It takes several seconds. - Reset: If the CPU didn’t perform a reset after flashing is done, simply press the black button. {{:en:hardware:red:operation:mini_usb_connection.jpg?|}}\\ Figure 49: Mini-USB connection {{:en:hardware:red:operation:st_link_2program_menu.png?|}}\\ Figure 50: Open the programmer window {{:en:hardware:red:operation:st_link_3program.png?|}}\\ Figure 51: Start flashing the new firmware ===== DFU Method ===== The STM32F4 CPU has an integrated boot loader, which is write proteced. This boot loader allows programming the flash through the serial or USB interface. There is currently only need for using this feature when you have problems with the method above. But we may need this method on future controller boards, where the CPU is integrated on our PCB. ST provides a tool for USB-DFU mode which you can download here. After installation, connect your Discovery with the micro-USB to your computer, jumper the pins BOOT0-VDD on the STM32F4DISCOVERY and attach the power supply to the controller. Use DFU File Manager to create a DFU-file from the Firmware binary and DfuSe Demonstration to flash you controller. After flashing, remove BOOT0-VDD and push reset. A more detailed description will be published later. This method is as robust as the way through the ST-Link programmer. That means, even after a failed flash procedure, the CPU still be programmed with the DFU method. ===== Flash through the web-interface ===== Since Firmware version 4.0, there is an integrated firmware update tool available in the web-interface. We cannot guarantee for 100% functionality, but it is the easiest and fastest way to update the firmware. It even works through slow or unstable connections. If it fails, you can still use the methods described above. For more information, refer to the guide integrated into the controllers web-interface in the About section.