Skip to content

Latest commit

 

History

History
59 lines (44 loc) · 3.45 KB

File metadata and controls

59 lines (44 loc) · 3.45 KB

UART flashing to esp32-cam

I wanted to flash the firmware for the esp32-cam using UART, and ran into some troubles early on.

  1. enable serial: sudo raspi-config -> interface options -> enable serial -> reboot
  2. after rebooting, run dmesg -t | grep serial initial output: $ dmesg -t | grep serial

uart-pl011 fe201000.serial: there is not valid maps for state default uart-pl011 fe201000.serial: cts_event_workaround enabled fe201000.serial: ttyAMA1 at MMIO 0xfe201000 (irq = 39, base_baud = 0) is a PL011 rev3 serial serial0: tty port ttyAMA1 registered bcm2835-aux-uart fe215040.serial: there is not valid maps for state default fe215040.serial: ttyS0 at MMIO 0xfe215040 (irq = 40, base_baud = 62500000) is a 16550 systemd[1]: Created slice system-serial\x2dgetty.slice - Slice /system/serial-getty. hci_uart_bcm serial0-0: supply vbat not found, using dummy regulator hci_uart_bcm serial0-0: supply vddio not found, using dummy regulator

Here we can see two issues:

  1. the systemd[1] line is the Pi tryingg to launch a getty service on this port, if we try to flash anything over serial port, the Pi will interpret the esp32's data as text commands and the getty service will spam the line with login prompts. to fix this we need to edit /boot/firmware/cmdline.txt and remove any code that looks like: console=serial0,115200 or console=ttyAMA1,115200, leave the rest of the code, such as console-tty1 root=PARTUUID...

  2. that hci_uart_bcm is trying to initialize on serial0, this was the bluetooth module trying initialize on the serial port and corrupting the data stream. edit /boot/firmware/config.txt. go to the bottom and below enable_uart=1 add dtoverlay=disable-bt

reboot and check again:

$ dmesg -t | grep serial uart-pl011 fe201000.serial: there is not valid maps for state default uart-pl011 fe201000.serial: cts_event_workaround enabled fe201000.serial: ttyAMA0 at MMIO 0xfe201000 (irq = 40, base_baud = 0) is a PL011 rev3 $ ls -l /dev/serial0 lrwxrwxrwx 1 root root 7 Dec 27 09:02 /dev/serial0 -> ttyAMA0

good! now lets try to flash again:

$ cd industrial-iot/ bill@raspberrypi:/industrial-iot $ . .venv/bin/activate (.venv) bill@raspberrypi:/industrial-iot $ esptool -p /dev/serial0 --baud 115200 write-flash -z 0x10000 firmware.bin esptool v5.1.0 Connected to ESP32 on /dev/serial0: Chip type: ESP32-D0WDQ6 (revision v1.1) Features: Wi-Fi, BT, Dual Core + LP Core, 240MHz, Vref calibration in eFuse, Coding Scheme None Warning: Detected crystal freq 41.01 MHz is quite different to normalized freq 40 MHz. Unsupported crystal in use? Crystal frequency: 40MHz MAC: 08:f9:e0:ed:01:f4

Stub flasher running.

Configuring flash size... Flash will be erased from 0x00010000 to 0x00105fff... Compressed 1006448 bytes to 639088... Writing at 0x000de2b4 [=======================> ] 82.0% 524288/639088 bytes...

Pi sdcard failure

At this point, I attempted to install minicom and I got a sudo error. I rebooted the device and couldn't get ssh'd back in. I connected the pi to my tv to see the boot and got error messages about fixing garbage files. I popped the sdcard out and mounted it on my laptop and checked the cmdline.txt file:

console=tty1 root=PARTUUID=bdeb291b-02 rootfstype=ext4 fsck.repair=yes rootwait cfg80211.ieee80211_regdom=US

i appended fsck.mode=force to the end, saved the file, unmounted the disk, loaded it back into my pi and powered it on.