Boot from wired Ethernet to RAM?

marekm
Posts: 3
Joined: Wed Apr 30, 2025 11:53 am

Boot from wired Ethernet to RAM?

Postby marekm » Wed Apr 30, 2025 1:18 pm

Hello, first post here, I'm fairly new to ESP32 though already experienced with other MCUs, Linux and C programming (did some hacking on avr-gcc about 25 years ago).

I'm working on an application, a PoE powered remote sensor that will be difficult to access physically in the final location. The device sends data over wired Ethernet LAN to a server that processes it, it's all on a local carefully controlled network (not on the Internet) so it doesn't have to be secure. My prototype is based on the Olimex ESP32-POE board, which I reprogram over USB using the Arduino IDE. The device has no buttons or any other user interface, when installed in the final location it will only have wired Ethernet with PoE that can be remotely power-cycled. Since it depends on a server to process the data from the sensor anyway, I'd like to be able to do kind of "diskless boot" - like back in the old days a boot ROM in a network card could boot DOS on a diskless PC, for those old enough to remember.

Bootloader in flash (rarely if ever updated) does DHCP to configure the network (and any other settings with DHCP options), then loads the real application from TFTP server to RAM and runs it from there. No OTA, no flash writes, no way to brick the device, if the application is buggy then simply update it on the server and power-cycle the device to load it again. Has something like this been done before?

I'm currently using the WROOM version of the board, but can change to WROVER if the added PSRAM would help. Physical replacement of the device (high on a mast, to monitor vibration and wind speed) would be more expensive than the device itself, that's why I'd like to make it as difficult to brick as possible. For those curious - the device contains a small EVAL-ADXL355Z board with SPI accelerometer and the Olimex ESP32-POE board, all nicely fit into the case of the "Seav" anemometer (3 cups, rotating magnet, reed contact, about 1 Hz per 4 km/h of wind) and will be powered from a MikroTik CRS318-16P-2S+OUT switch.

Sprite
Espressif staff
Espressif staff
Posts: 10599
Joined: Thu Nov 26, 2015 4:08 am

Re: Boot from wired Ethernet to RAM?

Postby Sprite » Thu May 01, 2025 5:33 am

That's not trivially possible; if any, on the original ESP32 (the one you're using) the internal RAM is not large enough to contain a full WiFi+TCP-IP application, and the PSRAM is not capable of executing code on that chip; that makes OTA the only way to run native code.

The only way around that that I can imagine is having your 'bootloader' contain an interpreter for e.g. webassembly; it'd download a webassembly binary from the server to PSRAM and then execute it. Means that if you need to change behaviour, you'd only need to recompile your webassembly binary and reset the system. Not sure how trivial that would be to implement, though.

boarchuz
Posts: 656
Joined: Tue Aug 21, 2018 5:28 am

Re: Boot from wired Ethernet to RAM?

Postby boarchuz » Thu May 01, 2025 6:51 am

The RAM requirement makes this a lot more complex than it would otherwise be. If we remove that...

Have a partition table with 2 app partitions: the factory app (an "ethernet bootloader" which is never altered) and the "real" app. On power up, the factory app always boots. It establishes an ethernet connection, checks your network location for the latest "real" app binary, updates the partition if necessary, then sets some flag in RTC memory and soft reboots. A little logic added to the actual bootloader (valid "real" app image && valid flag && expected reset reason) then selects and loads the "real" app partition.

marekm
Posts: 3
Joined: Wed Apr 30, 2025 11:53 am

Re: Boot from wired Ethernet to RAM?

Postby marekm » Fri May 02, 2025 11:11 pm

My application doesn't need WiFi or TCP (just wired Ethernet, and UDP - currently sending all sensor data as UDP multicast, packet structure loosely based on RTP, considering also adding basic SNMP support, no need for nice web UI etc.) so it may be possible to reduce size by not linking a lot of unused code. Also, I'll see if I can fit the ESP32-P4-DevKit board instead (+ PoE board) in the available space, maybe it would be easier to do network boot on that platform (much more RAM, usable for both code and data).

Who is online

Users browsing this forum: Baidu [Spider], ChatGPT-User and 1 guest