GithubHelp home page GithubHelp logo

jp112sdl / asksin_ota_bootloader Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jabdoa2/asksin_ota_bootloader

1.0 2.0 0.0 2.6 MB

Bootloader with Homematic Bidcos Over the Air Update OTA support

Shell 29.27% PHP 3.74% Makefile 9.47% Batchfile 3.17% C 39.18% C++ 0.07% Objective-C 1.47% CSS 0.93% HTML 12.70%

asksin_ota_bootloader's Introduction

Bidcos Bootloader for Atmega

Currently tested at Atmega328p and Atmega644.

Tested on

Prepare device:

  • Clone repository
  • Build source for HB-UW-Sen-THPL
make clean HB_UW_Sen_THPL
  • Build source for HM-LC-Sw1PBU-FM
make clean HM_LC_Sw1PBU_FM
  • Build source for HM-LC-Sw1PBU-FM (8k Bootloader space)
make clean HM_LC_Sw1PBU_FM_8k
avrdude -p m328p -P usb -c usbasp -U lfuse:w:0xE2:m -U hfuse:w:0xD0:m -U efuse:w:0x06:m -U lock:w:0x2F:m
  • Flash to device (Atmega328p):
avrdude -p m328p -P usb -c usbasp -V -U flash:w:Bootloader-AskSin-OTA-HB_UW_Sen_THPL.hex
avrdude -p m644 -P usb -c usbasp -U lfuse:w:0xFD:m -U hfuse:w:0xDA:m -U lock:w:0x2F:m
  • Flash to device (Atmega644):
avrdude -p m644 -P usb -c usbasp -V -U flash:w:Bootloader-AskSin-OTA-HM_LC_Sw1PBU_FM.hex

Convert payload and flash:

  • You need to convert your elf file to binary first (For arduino GUI you can find this in /tmp/buildXXXXX/)
  • If CRC Check is disabled, simply use the avr-objcopy tool
avr-objcopy -j .text -j .data -O binary payload.elf payload.bin
  • If CRC Check is enabled, you need to generate a CRC checksum to your binary to make it acceptable for the bootloader

  • The intention of the CRC check is to prevent unfinished transfers to start and force you to do a hard reset to re-enter the bootloader

  • This CRC Checksum has to be added with the tool srec_cat (from srecord: http://srecord.sourceforge.net/download.html)

  • In this case, do not use avr-objcopy, simply run srec_cat as follows (use the .hex file as input, not the .elf file)

  • For 32k devices with 4k bootloader space like (Atmega328p):

srec_cat <payload.hex> -intel -fill 0xFF 0x0000 0x6FFE -Cyclic_Redundancy_Check_16_Little_Endian 0x6FFE -o  payload.bin -binary
  • For 64k devices with 4k bootloader space like (Atmega644):
srec_cat <payload.hex> -intel -fill 0xFF 0x0000 0xEFFE -Cyclic_Redundancy_Check_16_Little_Endian 0xEFFE -o  payload.bin -binary
  • For 64k devices with 8k bootloader space like (Atmega644):
srec_cat <payload.hex> -intel -fill 0xFF 0x0000 0xDFFE -Cyclic_Redundancy_Check_16_Little_Endian 0xDFFE -o  payload.bin -binary
  • in both cases you end up with the binary, which has to go through the converter to get the EQ3 format
  • Use the converter (need php-cli):
./bin2eq3.php payload.bin payload.eq3 # convert to eq3 hex format

Dependent on the flash page size of the desired AVR, a different page size can pass as third parameter in bytes. The default pages size is 256 bytes.
E.g. the Atmega328 needs a page size of 128 bytes.

tar -czf payload.tar.gz payload.eq3 # create .tar.gz for homematic windows tool
  • Open serial with 57600 baud to see debug output
  • Flash payload with flash-ota (from hmland https://git.zerfleddert.de/cgi-bin/gitweb.cgi/hmcfgusb):
  • As SERIAL_NUMBER, set your desired number in the header of bootloader.c. Defaults to KEQ0000001
  • You should set a different number for each device to prevent bootloader conflicts when more than 1 device is switched on at the same time
sudo ./flash-ota -f payload.eq3 -s <SERIAL_NUMBER>
  • Reboot device to enter bootloader
  • Wait for flash-ota to do its job

If you have feedback or problems you can ask questions or leave comments in this thread in FHEM Forum (forum is mostly german but you may also write in english): http://forum.fhem.de/index.php/topic,18071.0.html / http://forum.fhem.de/index.php/board,22.0.html

asksin_ota_bootloader's People

Contributors

jabdoa2 avatar kc-github avatar unimatrix27 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.