1.x firmware and compiling

Setting up environment:

I use Arduino IDE. But I use external editor, no matter for Arduino IDE. 
Currently I have switched to 1.8.5.  It is good practice to create separate environment just for Gateway to separate it from your other projects. Gateway uses sometime slightly modified versions of standard libraries, like Ethernet.

To sum up:
  1. Download Arduino IDE. Latest as of now is 1.8.5. 
  2. In Arduino IDE open File->Preferences, and change "Sketchbook location"  to some unique folder just for OHS.
  3. Download from my GitHub gateway and libraries. Extract them to your newly created folder from step 2.
  4. Gateway uses ATmega1284p, that is not included in standard Arduino Boards Manager. The instruction how to add the board into your Arduino IDE can be found here. Basically just download the zip, and extract its content in /arduino-1.8.5//hardware folder. Use following board to compile sketch "Mighty 1284p 16MHz using Optiboot". 
  5. Gateway uses different Ethernet library, delete the original Ethernet folder from /arduino-1.8.5/libraries and from /arduino-1.8.5/hardware/mighty-1284p/avr/libraries. We will be using only the one found in my libraries you've downloaded.
  6. Open /arduino-1.8.5/hardware/arduino/avr/cores/arduino/HardwareSerial0.cpp and change following line:
    #if defined(HAVE_HWSERIAL0)
    to:
    #if defined(_HAVE_HWSERIAL0)
    This is needed because Serial0 is somehow hard-coded into core and we need private library for GSM on port Serial0.

Now all is needed to open main_board.ino and try to compile it. All assembled boards come with Arduino bootloader and with latest firmware. They are also fully tested. When you plug a FTDI USB to serial programmer into gateway you can upload your changes directly to board.

Getting sources:

  • Gateway, all libraries required are included. Be aware that I have sometimes included small change in common libraries like Ethernet or Webserver, and all those are required to compile the sketch.
  • Libraries 
  • Code for nodes is also stored on GitHub as single sketches depending on hardware version and accompanied fetaures.

 

Firmware update:

If you want to upgrade firmware on gateway, but you are not interested in modification of code, I have prepared compiled firmware for gateway. They are located at GDrive.

Firmware naming convection is as follows:
main_board_abcd.hex

  • "ab" stands for hardware revision, like current 1.7. and its modifications.
  • "c" stands for major version, and it also indicates that there is a change of EEPROM configuration, and gateway internal settings have to be redone. Sometime there can be only new block appended on the end of EEPROM. In such case only new functions need to be configured. But other time, the entire block of memory is shifted in EEPROM, and the whole configuration may become corrupted. In such case it is recommended to press Reset to Default button in Home tab on Web UI, and start configuration from beginning. 
  • "d" is the minor version of firmware, and it is safe to flash new firmware over same configuration of EEPROM.

To flash the firmware into gateway you will need the 3V3 FTDI USB to Serial adapter, and program called avrdude. Avrdude is also included in some subfolder of Arduino IDE. First test the connection:
avrdude -p m1284p -c arduino -P (your USB port) 

Replace (your USB port) by the name found on your system. On Linux it would be /dev/ttyUSB0. Like this:
$avrdude -p m1284p -c arduino -P /dev/ttyUSB0

And you will see:
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.00s
avrdude: Device signature = 0x1e9705 (probably m1284p)
avrdude: safemode: Fuses OK (E:00, H:00, L:00)
avrdude done.  Thank you.

If you see above output you can then add "-Uflash:w.file_name.hex":
$avrdude -p m1284p -c arduino -P /dev/ttyUSB0 -Uflash:w:main_board_####.hex 

After some writing and reading steps you will see something similar to this:
...
avrdude: verifying ...
avrdude: ###### bytes of flash verified
avrdude: safemode: Fuses OK (E:00, H:00, L:00)

avrdude done.  Thank you.

That means you are done.

No comments:

Post a Comment