Skip to content

Commit

Permalink
- enabled config button in HM_LC_Sw1PBU_FM
Browse files Browse the repository at this point in the history
- small bugfix in bootloader.c (unused variable when no config button used)
- fixed address in Readme for sreg_cat for 8k version
- bugfix in bin2eq3.php (adding one too many pages if pageborder is hit by bin-file, causing potential bootloader self erasing)
  • Loading branch information
unimatrix27 committed Aug 19, 2014
1 parent 840dc57 commit 5af89d9
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ srec_cat <payload.hex> -intel -fill 0xFF 0x0000 0xEFFE -Cyclic_Redundancy_Check_

* For 64k devices with 8k bootloader space like (Atmega644):
```
srec_cat <payload.hex> -intel -fill 0xFF 0x0000 0xDEED -Cyclic_Redundancy_Check_16_Little_Endian 0xDEED -o payload.bin -binary
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
Expand Down
6 changes: 4 additions & 2 deletions bin2eq3.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@
$fhInfile = fopen($inFile, 'r');

$out = '';
$numPages=0;
while(!feof($fhInfile)) {
$payload = fread($fhInfile, $spmPagesize);
if(strlen($payload)==0) continue;
$numPages++;
$out .= sprintf('%04X', $spmPagesize);

for($i = 0; $i < $spmPagesize; $i++) {
if ($i >= strlen($payload)) {
$out.= '00';
Expand All @@ -40,5 +42,5 @@

file_put_contents($outFile, $out);

echo 'File "' . $outFile . '" was written with page size of ' . $spmPagesize . ' Bytes.' . LF;
echo 'File "' . $outFile . '" was written with page size of ' . $spmPagesize . ' Bytes and a total of ' . $numPages . ' Pages.' . LF;

8 changes: 5 additions & 3 deletions bootloader.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ const uint8_t hm_id[3] ADDRESS_SECTION = {HM_ID}; // 3 bytes devic
#endif

int main() {
uint8_t watchdogReset = 0;
watchdogReset = bitRead(MCUSR, WDRF); // is reset triggert from watchdog?

#if defined(PORT_CONFIG_BTN) && defined(DDR_CONFIG_BTN) && defined (INPUT_CONFIG_BTN) && defined(PIN_CONFIG_BTN)
uint8_t watchdogReset = 0;
watchdogReset = bitRead(MCUSR, WDRF); // is reset triggert from watchdog?
#endif

MCUSR=0; // disable watchdog (used for software reset the device)
wdt_reset();
wdt_disable();
Expand Down
10 changes: 5 additions & 5 deletions devices/HM-LC-Sw1PBU-FM.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
// Pin assignment for config button (without hold the config button the main programm starts immediately if CRC was correct)
// config defines and enable lins below to use config button
//
//#define PORT_CONFIG_BTN PORTD // The Port D Data Register
//#define DDR_CONFIG_BTN DDRD // The Port D Data Direction Register
//#define INPUT_CONFIG_BTN PIND // The Port D Input Pins Address
//#define PIN_CONFIG_BTN 7 // PD7 where the button sould connected (to ground)
//#define WAIT_FOR_CONFIG 10 // Wait 10 seconds after watchdog reset for press config button
#define PORT_CONFIG_BTN PORTD // The Port D Data Register
#define DDR_CONFIG_BTN DDRD // The Port D Data Direction Register
#define INPUT_CONFIG_BTN PIND // The Port D Input Pins Address
#define PIN_CONFIG_BTN 7 // PD7 where the button sould connected (to ground)
#define WAIT_FOR_CONFIG 10 // Wait 10 seconds after watchdog reset for press config button

/**
* set to 1 to activate debug info over UART
Expand Down

0 comments on commit 5af89d9

Please sign in to comment.