I recently damaged the firmware and the USB bootloader on my Espruino, remembering that the STM32 which is at the core of the Espruino has a hardcoded bootloader that can be used to restore the firmware by uploading it through 3v TTL serial transfer.
Heading over to the Espruino website, I found this guide http://www.espruino.com/Serial+Bootloader
which has instructions for programming the Espruino using a USB-TTL converter. Not having one of those and exhausting a few other methods I gave up for the time being until I had a new idea.
The BBB has 6 serial UART's on board that run at 3v TTL, however only one of them is enabled as default and that is already in use being linked to the serial console.
The other UART's must be enabled by modifying the uEnv.txt file. An easy way to modify this is to connect the BBB to your computer using a USB cable so it appears as a flash drive. The uEnv.txt file should be located in that drive and can be modified with any standard text editor. (the precise location differs with each variant of Linux, with the standard Debian version, it should appear in the files when you first open the drive).
If you are modifying it from within the BBB's file system then it will be in the /boot/ folder or a child folder within that.
Once it's open, just add the following line:-
I'm not sure that it matters where it goes but I added it straight below the line that says:
##BeagleBone Cape Overrides
Again, there's a likelihood that other variants of Linux may have a different format to the uEnv.txt file, so you will need to use your judgement as to where best modify it.
Once you reset your BBB, UART 4 should be enabled and we can check by connecting to the BBB in a terminal and typing
there should be 2 items returned in the list:
/dev/ttyO4 is the serial UART we just enabled
It's a good idea from this point to head over to http://www.espruino.com/Serial+Bootloader and follow the guide in order to understand how to put the STM32 into serial bootloader mode.
Download the stm32loader.py script and the latest Espruino binary from the link above and transfer these over to your BBB. I used the scp command from a terminal, but you could even just put them on a micro-sd card and put them onto your BBB like that.
The next step is to connect the Espruino to the BBB, and make sure the Espruino is wired up to enable the serial bootloader as follows:-
Espruino BOOT0 > Espruino 3.3v
Espruino BOOT1(PB2) > Espruino GND
Espruino PA9(tx) > BBB P9 – 11 (rx)
Espruino PA10(rx) > BBB P9 – 13 (tx)
Espruino GND > BBB GND
Espruino 3.3v > BBB 3.3v
*the BOOT0 pin is labelled BOOT0 and is near the STM32 device.
It's probably best to leave connecting the 3.3v supplies until just before you start programming in case the bootloader times out.
Log onto the BBB using a terminal as normal, navigate to the folder where you have your stm32loader.py and espruino binary and enter the following line:
(it's the same as the guide in the link above only we're using a specific serial port)
python stm32loader.py -p /dev/ttyO4 -evw espruino_for_your_device.bin
remember to change the 'espruino_for_your_device.bin' to the specific file that you downloaded, in my case it was:
python stm32loader.py -p /dev/ttyO4 -evw espruino_1v75_espruino_1r3.bin
I waited until just before I pressed enter to make the 3.3v connection between the BBB and the Espruino and as it says on the serial bootloader page on the Espruino website:
Note: The flasher may give you an error message such as Chip replied with a NACK. If so, just try running it again without resetting your board.
This happened with me and the trick really is to not reset your board, just run the command again and it will start programming the Espruino software.
Once finished, disconnect the power to the Espruino, disconnect the BOOT0 and BOOT1 pins and re-apply power, the Espruino should boot up as normal with the new firmware.
Wow, thanks! That's really thorough!
The Espruino 1v3's bootloader had a bug in it which made USB comms unreliable (luckily there was a workaround that the Web IDE (and -k in the modified python bootloader) can apply) - but if you wanted to replace your existing bootloader with the new one without the problem then you could do what is detailed above as well.
edit: just linked this post from the Serial Bootloader page
Don't worry about formatting, just type in the text and we'll take care of making sense of it. We will auto-convert links, and if you put asterisks around words we will make them bold.
For a full reference visit the Markdown syntax.
© Espruino, powered by microcosm.
Report a problem