Repository navigation
Home
For the firmware development Visual Studio Code is used. Compilation and flashing is done via terminal though.
- esp-adf 2.4
- esp-idf 4.4.1
- Micropython 1.20.0
- Clone the esp-adf repository (that includes esp-idf):
git clone --recursive -b release/v2.4 https://github.com/Mobsya/esp-adf.git esp-adf-2.4 - Install espressif toolchain:
sudo apt-get install git wget flex bison gperf python3 python3-pip python3-setuptools cmake ninja-build ccache libffi-dev libssl-dev dfu-util libusb-1.0-0cd esp-adf-2.4/esp-idf/./install.sh
- Clone the Thymio ESP32 firmware:
git clone -b micropython https://github.com/Mobsya/thymio3-firmware-esp32.git thymio3-firmware-esp32_micropython source /PATH-TO/esp-adf-2.4/esp-idf/export.shcd thymio3-firmware-esp32_micropython/git submodule initgit submodule updatecd components/mp_component/micropython/make -C mpy-crosscd ports/esp32make submodules- change
adf_pathinCmakeLists.txtin the project root directory -
idf.py build(from project root directory) - Flash the firmware:
idf.py -p /dev/ttyACM0 flash -b 115200
Since it will be rarely upgraded, the default USB DFU mode will be used. The STM32 Cube Programmer application is used to flash the chip. To program the STM32 follows these steps:
- download the last firmware STM32 firmware (13.09.23)
- enter DFU mode: while robot is on, press on/off button and then quickly the reset button once. The robot seems to be turned off but instead it entered DFU mode.
- open STM32 programmer, on the left side select "Erasing and Programming" and browse the "elf" file
- on the right side select USB interface, click on refresh icon and a device should be recognized
- click on "start programming"
- reset the robot
The first time the robot must be programmed via USB cable by following these steps:
- download the last firmware: bootloader (22.09.23), partition table (22.09.23), ESP32 firmware (22.09.23)
- erase the flash:
esptool.py -p /dev/ttyACM0 erase_flash source /PATH-TO/esp-adf-2.4/esp-idf/export.sh- flash the firmware:
esptool.py -p /dev/ttyACM0 -b 115200 --before=default_reset --after=hard_reset write_flash --flash_mode dio --flash_freq 80m --flash_size 8MB 0x1000 bootloader.bin 0x10000 thymio3-esp32-firmware.bin 0x8000 partition-table.bin
Also the built-in sound must be programmed once:
- download the audio binary data: audio_tone.bin
- flash the audio data:
esptool.py -p /dev/ttyACM0 -b 115200 --before=default_reset --after=hard_reset write_flash --flash_mode dio --flash_freq 80m --flash_size 8MB 0x780000 audio_tone.bin
The following updates (after the first programming via USB cable) can be done using OTA by following these steps:
- download the following files and transfer them to the robot (if not already present): open_url.py, ota32.py, test_ota_dfu.py
- configure WiFi with internet access on the robot
- run the script
test_ota_dfu.py - restart robot
Micropython is integrated in the Thymio firmware as esp-idf component.
At the moment the library gives complete access to all sensors and actuators, but there is no event implementation yet.
The documentation of the library is available in the following link https://mobsya.github.io/thymio-platform/?path=/docs/thymio-iii-python-library--page.
The library is implemented by extending the ESP32 port (micropython\ports\esp32): two files are added for each sensor/actuator (e.g. thymio_buttons.c and thymio_buttons.h, thymio_imu.c and thymio_imu.h, ...). All these modules are then exported from the main file modthymio.c.
The events will be probably implemented using asnycio.
REPL is not enabled by default, it must be enabled from the menu:
- Turn on the robot and navigate to the REPL menu identified by: RGB LEDs off + front lego LEDs off + first LED on the left turned on for the back lego LEDs. Refer to the modes T3 (state machines) for more information on the menu modes.
- Press enter to enter REPL
- Open a terminal (e.g. TeraTerm for Windows or Minicom for Linux) and connect to the USB serial port of the robot. You can now interact with REPL, for instance you can run a script by issuing the command
from REPL: exec(open("test.py").read())
The following examples make use of the Python script pyboard.py, refer to https://docs.micropython.org/en/latest/reference/pyboard.py.html#pyboard-py.
Transfer files between pc and robot:
- transfer from pc to robot:
pyboard.py --device /dev/ttyACM0 -f cp /PC-path-to-file/test.py :test.py - transfer from robot to pc:
pyboard.py --device /dev/ttyACM0 -f cp :test.py /PC-path-to-file/test2.py
Others useful commands:
- list files on robot:
pyboard.py --device /dev/ttyACM0 -f ls - print content of file on robot:
pyboard.py --device /dev/ttyACM0 -f cat boot.py - run script on robot from the pc:
pyboard.py --device /dev/ttyACM0 /PC-path-to-file/test.py
The boot.py script can be used to configure the WiFi connection at boot. Simply put this script on the robot.
You can call directly connect() at the end of the script to automatically connect on boot. Otherwise you can connect manually by issuing:
import boot
boot.connect()
No more supported
Not all behaviors are implemented: attentive, obedient and NN are missing.
Some behaviors need fine tuning.
Refer to the following document for detailed informations https://docs.google.com/presentation/d/11YURm4wyTFIW-WM7v4zo3Jsm14PWats5pz4ayr20tw8/edit?usp=sharing