*************************** Updating Firmware/Software *************************** At the time of writing, the versions of these firmware are not fixed. **You must also make sure that the ICM Golden Image is located on flashIDs 0 & 1. If you are confused ask an expert.** Please consult an expert to confirm the correct version numbers. | *Currently (2022-10-26):* | | **FPGA: 0x110** | **iceboot: (MCU software) 0x3E** | **In-ice ICM (Position 0): 21.2.15 GI2** | **In-ice ICM (Position 1): 21.2.15 GI1** | **In-ice ICM (Position 2): 21.4.9** | **In-ice ICM (Position 7): 21.3.6 EEPROM** ============= ICM Upgrade ============= Should start with the ICM firmware update. First, turn on the MFH and supply power to the D-Egg following the instructions below. Run the ``domnet``: .. code-block:: domnet /dev/ttyUSB0 Keep the window and move to the different terminal window. Go to the ``fh_server/scripts/`` and run: .. code-block:: ./wp_on.py Make sure the ``domnet`` recognizes the port number of the device (usually 2) on the domnet terminal window. The example is shown below: .. code-block:: --- domnet V1.4.10 --- Opening serial device /dev/ttyUSB0, port range 5000-5007, command server on port 6000 ICMs detected at address(es): 8 ICMs detected at address(es): 2 8 Note that if the pre-installed ICM firmware is too old, we cannot see the device port number. If you observed such a case, please contact an expert. You can check the current running ICM firmware version using the ``icm_probe.py`` script. On the ``fh_server/scripts`` terminal window, run: .. code-block:: python3 icm_probe.py Next, to upgrade the ICM firmware, *disable domnet* (ctrl-c on the domnet terminal window) and navigate to ``fh_server/scripts/``. The basic command is: .. code-block:: python3 golden_image_control.py /dev/ttyUSB0 21 Make sure that you are looking at the correct ttyUSB (for the test stand should be 0). For the test stand the firmware is located in ``~/Downloads`` or ``Firmware/ICM``. * ```` Refers to the device wirepair address (the port --- if the port number is 5002, set it to "2") * ```` for programme * ```` for the location in flash memory. First, upload the version **21.4.9** (0x1549) to the slot 2 with the command: .. code-block:: python3 golden_image_control.py /dev/ttyUSB0 p 21 2 [path]/ICM_in_ice_rev1549.mcs Make sure that the upgrading was performed without any problems: .. code-block:: Status: 0xa0 Error: 0x00 Done. If you notice that the command failed (dumped some errors, the status value is not ``0xa0``, or the error value is not ``0x00``) and/or the driving ICM firmware version is **21.1.3**, try another (old) script named ``golden_image_control_rev20_rev21.py``: .. code-block:: python3 golden_image_control_rev20_rev21.py /dev/ttyUSB0 p 21 2 [path]/icm_in_ice_rev1549.mcs Still you observed some errors, please ask an expert. Try to reboot the firmware from the slot 2: .. code-block:: python3 golden_image_control.py /dev/ttyUSB0 r 21 2 In this case, "r" stands for reboot, and again "2" the image location. And, check the current firmware version: .. code-block:: python3 golden_image_control.py /dev/ttyUSB0 rf 21 See the correct version **21.4.9**. Second, upgrade the Golden Images in the slots 0 & 1. For changing the Golden Image, replace "p" with either "og0" for changing Golden Image 0, or "og1" for changing Golden Image 1. Carefully read the print from the script, and confirm your choice with "YES". If you observe an error message here, try it again. The slots 0 & 1 were upgraded without any errors, check the firmware versions for both using the "r" and "rf" commands shown above. More detail, follow the procedure: .. code-block:: python3 golden_image_control.py /dev/ttyUSB0 og0 21 0 [path]/icm_in_ice_rev21_2_15_GI2.mcs > YES python3 golden_image_control.py /dev/ttyUSB0 og1 21 1 [path]/icm_in_ice_rev21_2_15_GI1.mcs > YES If there is no errors in the terminal, make sure the firmware images are installed correctly: .. code-block:: python3 golden_image_control.py /dev/ttyUSB0 r 21 0 python3 golden_image_control.py /dev/ttyUSB0 rf 21 > (Check if the running ICM version is 21.2.15 [0x152f]) python3 golden_image_control.py /dev/ttyUSB0 r 21 2 python3 golden_image_control.py /dev/ttyUSB0 rf 21 > (Check if the running ICM version is 21.4.9 [0x1549] -- latest) python3 golden_image_control.py /dev/ttyUSB0 r 21 1 python3 golden_image_control.py /dev/ttyUSB0 rf 21 > (Check if the running ICM version is 21.2.15 [0x152f]) In this series of command running, the driving ICM firmware is changed to 21.4.9 -> 21.2.15 -> 21.4.9 -> 21.2.15. Next, install the EEPROM image into the slot 7 using the "p" command and checking the version with the same procesure. .. code-block:: python3 golden_image_control.py /dev/ttyUSB0 p 21 7 [path]/icm_in_ice_21_3_6_EEPROM_write.mcs Check the firmware version: .. code-block:: python3 golden_image_control.py /dev/ttyUSB0 r 21 7 python3 golden_image_control.py /dev/ttyUSB0 rf 21 You will see the version of 21.3.6. **After programming the ICM, always check that the version matches what you would expect!** More information about the Golden Image is available on: `github link `_. Finally, restore the ICM firmware version of 21.4.9 (latest) by: .. code-block:: python3 golden_image_control.py /dev/ttyUSB0 r 21 2 And apply the write protection for the Golden Images (see: `IR backdoor test in Chiba `_): .. code-block:: python3 golden_image_control.py /dev/ttyUSB0 s 21 **Side Note** You can also use ``icm_reprogram.py`` in the ``fh_server`` repository *while domnet is running*. The syntax is a bit different: .. code-block:: python3 icm_reprogram.py --host localhost -p 6000 -w X -f [path]/icm_in_ice_firmware.mcs -i 2 *p* is the ICM port, normally 6000. *w* again refers to the device on the wirepair (0, 1, 2, or 3). *i* is the flash location. This method however seems a bit unstable, so if you encounter problems use the one above. ============= MCU Software ============= To upgrade the MCU software use the bootloader. Navigate to the ``fh_server`` directory. First run (with ``domnet``): .. code-block:: python3 fh_server/scripts/mcu_flash_enable.py Then in the directory ``Software/DAQ/MCU/src/tools/python`` (fat-daq: ``mcu_dev/src/tools/python``) run the following line. If you are working on the test stand, you can determine the port from the jumper box (see last section): .. code-block:: python bootloaderProgram.py --host=localhost --port=XXXX --file= The installed MCU software version will be verified after the FPGA firmware installation. ============== FPGA Firmware ============== Make sure ``domnet`` running. In the ``Software/DAQ/MCU/src/tools/python/iceboot`` (for faq-daq: ``mcu_dev/src/tools/python/iceboot``) run the following command: .. code-block:: python uploadFlashFile.py --host=localhost --port=XXXX --file= The FPGA file is usually stored in the ``Firmware/FPGA`` directory in the computer. .. .. If there is no error in the terminal display, open a telnet session and check with ``flashLS``: .. .. code-block:: .. .. telnet localhost .. .. > flashLS .. Check the name of the uploaded FPGA image. .. ==================== .. FPGA Firmware (old) .. ==================== .. (This is outdated document, please ignore it. If you have any problems in the previous section, it might be helpful.) .. .. To upgrade the FPGA firmware have 2 terminal tabs open, the timing is important. .. .. With an open domnet instance, open a telnet session: .. .. .. code-block:: .. .. telnet localhost .. .. You will likely need to hit enter once or twice until ">" appears (the prompt). .. Check the firmware on the board using: .. .. .. code-block:: .. .. flashLS .. .. Delete all unnecessary firmware versions (see above) before transferring the new file. .. You can run either: .. .. .. code-block:: .. .. s" " flashRemove .. .. to remove them individually or: .. .. .. code-block:: .. .. flashClear .. .. to remove them all. .. Then before running the following command (timing to follow-up is important here) first open a terminal to ``MCU/src/tools/python`` (``/home/icehap-daq/mcu_dev/src/tools/python`` on the FAT PC) and type out *but do not yet run*: .. .. .. code-block:: .. .. python3 ymodem.py --host=localhost --port= .. .. The firmware files are located in ``Software/STF/data/``. .. Now with that line prepared you can run: .. .. .. code-block:: .. .. s" " ymodemFlashUpload .. .. Close the session by pressing *Ctrl + ]*, *q*, and *Enter*. .. Then run the command you prepared to execute ymodem.py. To confirm that the firmware is valid, flash the FPGA firmware. In ``Software/DAQ/degg_measurements/degg_measurements/utils/`` run: .. code-block:: python3 flash_fpga.py and type "yes" when prompted. If the flash is successful you should see that the correct MCU & FPGA versions have been initialised and a green print saying "FPGA flash successful". ==================== Read Pressure Sensor ==================== Once the ICM, MCU, and FPGA have been updated, we should check that the pressure sensor is working. The pressure sensor does not work (reliably) for the ICM Golden Image (default after power-on), so we need to reboot the device into the newer version. To reboot the device use the code in ``/home/icehap-daq/mcu_dev/fh_server/scripts/`` (do it only if the ICM doesn't run with the slot 2 firmware) .. code-block:: python3 icm_fpga_reboot.py --host localhost -p icm_port -w device_num -i 2 where the host will always be "localhost", the icm_port is typically 6000 (check domnet), and the device_num is the position of the D-Egg on the wire pair (between 0 and 7). The value of "i" should always be 2, assuming that the newest ICM firmware has been written to slot 2. Once finished rebooting, we can read the pressure. The sensor returns values in hPa, where ~1000 corresponds to atmospheric pressure. If the D-Egg seal is still good, we should expect a value between 400 - 600 hPa. **If you observe values much greater than 600, much smaller than 400, or any errors, please record this and contact an expert.** .. To read the pressure sensor, enter a telnet session (instructions are repeated here): .. .. .. code-block:: .. .. telnet localhost port .. .. .. where "port" is the value assigned via domnet (between 5000 and 5007 by default). .. If you see "#" as the prompt, press enter once. .. Then type "boot", and press enter again. .. Wait 5 seconds, then enter once more. .. The prompt should now have changed to ">". .. .. Once you have ">" as your prompt type, .. .. .. code-block:: .. .. getPressure printPressure To read the pressure, run the dedicated script `pressure.py` in `tools/python`: .. code-block:: python3 pressure.py --host localhost --port XXXX Record this value on the pre-FAT worksheet and in the D-Egg FAT Information Database. =================== Check Logbook Data =================== The D-Egg logbook contains the primary set of information for each module. For the FAT it is important to make sure that each D-Egg has matching information in the logbook and nothing was entered incorrectly. You should use the script "confirm_id.py" in "degg_measurements/degg_measurements/utils/" to check this validity. .. code-block:: python3 confirm_id.py If no error is thrown, check that this makes sense - i.e. the name of the D-Egg matches that on the sticker and no items are empty. If any of the fields are empty this is likely because the ICM field is not filled for this D-Egg. This should only happen with Batch #1 D-Eggs, but it could be other causes. *To solve this issue navigate to the D-Egg logbook in the web browser and find this D-Egg.* Once you have located this D-Egg, check if the ICM field is filled. If not, fill it with the number corresponding to this ICM ID as returned by the ``confirm_id.py`` script. **If the results from the script make sense, record your information in the pre-FAT checklist.** **Then update the logbook for this specific D-Egg, filling in the MCU, FPGA, & ICM versions.** If there is an error, report this to experts and make a note on the D-Egg FAT Test Stand Checklist. =============== IR-Flashlight =============== To release the write protection of the ICM flash memory, flashing the infrared light is needed. If you notice that the write protection is *wrongly* enabled, follow the description to disable it. Find the J6 on the ICM on the mainboard. .. image:: ../../images/ICM_3.png :width: 400 :alt: ICM_3 Keeping to flash the IR light towards the J6 on the ICM with running the following command to release the write protection: .. code-block:: python3 golden_image_control.py /dev/ttyUSB0 u 21