IOT base station

Idee

A universal Atmega1284P board with Ethernet and an Internet bootloader, more compact than an Arduino Ethernet and using the more recent W5500 from WizNet (obtainable in Europe for instance from TME) which allows faster transmissions than the previous W5100.

Hardware-Design Version V02

SchematicsLayout
FrontsideBackside
AssemblyAssembled PCBs

Corrections and lessons learned

This was my first attempt to design a PCB, and obviously I made quite a few mistakes. Lessons learned include:

Internet bootloader

Different from other open source approaches (Sowerbutts, Ariadne, Ethernut, Ethersex, and miscellaneous others at http://www.mikrocontroller.net), my bootloader obtains the application software not via TFTP from a local server, but rather via HTTP from any given server on the Internet. This allows remote deployment and software upgrade. Please note that the current bootloader is not resilient against MitM-Attacks etc.

How does it work? The Eeprom contains, in addition to a MAC address, also the URL of the boot server. Upon every reset the bootloader starts, retrieves new software from the boot server as necessary and programs it into flash memory, activates the watchdog, and starts the application software. Flash pages that did not change are not overwritten (in order to protect the flash lifetime in case of reboot loops). The application software must regularily feed the watchdog, otherwise a reset is triggered which reactivates the bootloader.

The bootloader can retrieve the startup IP addresses (own, gateway, DNS server) and the netmask either from the Eeprom as well, or via DHCP; the IP address of the boot server is retrieved via DNS.

The URL should contain a unique system id (hwid) as parameter, in order to allow the boot server to maintain a mapping between systems and their current application software, for instance via MqSQL/phpmyadmin (see screen dump). Within the URL the bootloader also transmits its own identifier (loaderid, composed from __FILE__ " " __DATE__ " " __TIME__) and the cause of the reset. The bootloader expects to receive an Intel_HEX file in the body of the reply to the HTTP GET request. It supports type 00, 01 and 02 records, which are exactly those produced by avr-gcc (Atmel Studio, Arduino).

The booloader also implements a simple serial protocol at 57600 baud:

ResetBootloader identification and cause of reset\nSWID,MCUSR=MCUSR\n
PromptRequest for input>
[R|W][E|F|S]Read (R) oder write (W) of Eeprom, Flash orSramData in Intel_HEX format
MCause of resetMCUSR: MCUSR\n
BInternet Bootload
GStart application software (Go)
TTrigger watchdog reset

Upon every startup the bootloader also commands the SD card (if any is plugged in) to change into SPI bus mode, in order to circumvent the SD-SPI problem described above.

The complete source code of the bootloader can be found at http://github.com/wangnick/httpboot.

Internet boot server

The Internet boot server is a simple Python script in my case, connected to a MySQL database, and a file system containing application software in Intel HEX format. The boot server also registers and stores every boot request (in order to detect and debug reboot loops) in a dedicated database table.

Respective discussions in www.mikrocontroller.net