0
\$\begingroup\$

What method should we follow when an updating code cannot be made with a cable to a PCB in a closed box? Is it possible to send another code(update) to PCB in closed box using IrDA? I couldn't find an example for this.

\$\endgroup\$
2
  • \$\begingroup\$ What's wrong with Wi-Fi? I think you need to tell us much more about your constraints and requirements. \$\endgroup\$ Commented Dec 1, 2022 at 11:51
  • \$\begingroup\$ It will be a battery powered PCB and shouldn't drain the battery too much. Think about place where there is no Wi-Fi(could be a vacant lot or farm) and in a closed box. I don't know how to explain it fully. An attendant will go near the PCB and upload an update with the PCB with another IrDA circuit \$\endgroup\$
    – harmonica
    Commented Dec 1, 2022 at 11:59

1 Answer 1

3
\$\begingroup\$

If cable is not an option, it depends what is your update method is in principle. Typically a firmware is uploaded via a dedicated bootloader - a piece of code that does only one job - the firmware update. Some microcontrollers have a built-in UART bootloader, open protocols and reference PC software for FW file upload (for example, MSP430 series has a bootloader are that can be reprogrammed). As mentioned in comments, the preferred STM32L073 microcontroller has a built-in bootloader code which resides in ROM area and cannot be re-programmed to a custom code.

Assuming that your STM32 controller has a bootloader implementation that works via UART, you can use any wireless UART "bridges":

  • IRDA - is what you mentioned. Cheap, but slow.
  • Bluetooth: there are modules that have UART on the other end. More expensive, but range is a bit longer, i.e. 10-20 meters.
  • any other wireless protocol that would require another microcontroller to perform the update

What else is needed? To decide how to enter bootloader mode.

  1. if power is external and box is remote, it can be done via "polarity reverse" trick;

  2. if there is no power control (powered by a sealed battery) but there is physical access to the box, it can be done via a button that would reset microcontroller, after reset it goes into the bootloader.

  3. If there is no electrical access, but there is optical window - IR or visible light can be used to activate the bootloader.

\$\endgroup\$
5
  • \$\begingroup\$ I'm considering using the STM32L073 chip and MCP2120 EN/DEC and, didn't know I had to research the bootloader issue. Thank you! \$\endgroup\$
    – harmonica
    Commented Dec 1, 2022 at 12:50
  • \$\begingroup\$ When I looked at the AN2606 document, I saw that there were USART1 bootloader and USART2 bootloader. Is the bootloader only available on these USART1 and 2? Can another USART be used by creating a custom bootloader? Do I need to pay attention to this during PCB design? \$\endgroup\$
    – harmonica
    Commented Dec 1, 2022 at 13:22
  • 2
    \$\begingroup\$ >> Is the bootloader only available on these USART1 and 2? << I looked into AN2606 to check. Yes, only two serial ports are used in the bootloader code that is "stored in the internal boot ROM (system memory) of STM32 devices, and is programmed by ST during production". \$\endgroup\$
    – Alex Stark
    Commented Dec 1, 2022 at 20:13
  • 2
    \$\begingroup\$ >> Can another USART be used by creating a custom bootloader? << Since ROM (not Flash) is mentioned in the AN2606, I presume you cannot rewrite it, so you would have to do 3 steps (they would take quite a time for develop from scratch): 1. to write your own bootloader code; 2. to sacrifice part of Flash for it; 3. to amend Linker setting in order to avoid placing main application into your custom bootloader area. I would rather allocate UART1 or UART2 for the default proven bootloader. \$\endgroup\$
    – Alex Stark
    Commented Dec 1, 2022 at 20:18
  • 2
    \$\begingroup\$ >> Do I need to pay attention to this during PCB design? << Yes, the idea is to connect your UART (IRDA?) to one of those bootloader UART ports (USART1 or USART2). I would prototype this on development board before rushing to schematics/PCB design to fully understand the update process from electrical and PC/updater point of view. Dry run of "Hello World rev.1" updated by bootloader-programmed "Hello World rev.2" is highly recommended. \$\endgroup\$
    – Alex Stark
    Commented Dec 1, 2022 at 20:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.