Skip to content

Commit

Permalink
Added PC software
Browse files Browse the repository at this point in the history
  • Loading branch information
kuro68k committed Apr 2, 2015
1 parent 50a4e39 commit 20c10f6
Show file tree
Hide file tree
Showing 84 changed files with 2,511 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ build/
bld/
[Bb]in/
[Oo]bj/
.research

# Roslyn cache directories
*.ide/
Expand Down Expand Up @@ -230,3 +231,4 @@ $RECYCLE.BIN/
# Windows shortcuts
*.lnk
*.atsuo
pc/hid_bootloader/test.hex
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# hid_bootloader

USB HID bootloader for Atmel XMEGA devices. Needs an 8k bootloader section because the Atmel ASF USB stack is about 6k on its own.
(C) 2015 Paul Qureshi
Licence: GPL 3.0

USB HID bootloader for Atmel XMEGA devices. Needs an 8k bootloader section because the Atmel ASF USB stack is about 6k on its own. The use of HID avoids the need for drivers on most operating systems.

PC software uses HIDAPI (http://github.com/signal11/hidapi/commits/master).

Currently supports 128k devices. Modify as required for other memory sizes.
1 change: 1 addition & 0 deletions firmware/build.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Built with Atmel Studio 6.2 and ASF 6.2.1314.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
674 changes: 674 additions & 0 deletions licence.txt

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions pc/build.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Built with Visual Studio 2013 Express.
22 changes: 22 additions & 0 deletions pc/hid_bootloader.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Express 2013 for Windows Desktop
VisualStudioVersion = 12.0.31101.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hid_bootloader", "hid_bootloader\hid_bootloader.vcxproj", "{BB669013-CF0A-4984-9E10-4C35D7EFD35B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{BB669013-CF0A-4984-9E10-4C35D7EFD35B}.Debug|Win32.ActiveCfg = Debug|Win32
{BB669013-CF0A-4984-9E10-4C35D7EFD35B}.Debug|Win32.Build.0 = Debug|Win32
{BB669013-CF0A-4984-9E10-4C35D7EFD35B}.Release|Win32.ActiveCfg = Release|Win32
{BB669013-CF0A-4984-9E10-4C35D7EFD35B}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
23 changes: 23 additions & 0 deletions pc/hid_bootloader/bootloader.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// bootloader.h

#define CMD_NOP 0x00
#define CMD_WRITE_BUFFER 0x01
#define CMD_READ_BUFFER 0x02
#define CMD_ERASE_APP_SECTION 0x03
#define CMD_READ_FLASH_CRCS 0x04
#define CMD_READ_MCU_IDS 0x05
#define CMD_READ_FUSES 0x06
#define CMD_WRITE_PAGE 0x07
#define CMD_READ_PAGE 0x08
#define CMD_ERASE_USER_SIG_ROW 0x09
#define CMD_WRITE_USER_SIG_ROW 0x0A
#define CMD_READ_USER_SIG_ROW 0x0B


#define APP_SECTION_ERASE_TIMEOUT_MS 2000
#define APP_SECTION_NUM_PAGES 256
#define APP_SECTION_PAGE_SIZE 512
#define READ_FLASH_CRCS_TIMEOUT_MS 5000


#define HID_DATA_BYTES 32
49 changes: 49 additions & 0 deletions pc/hid_bootloader/crc.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// crc.cpp

#include <stdint.h>
#include <stdlib.h>
#include "crc.h"


/**************************************************************************************************
* Reverse bits in a uint32
*/
uint32_t reverse(uint32_t x)
{
x = ((x & 0x55555555) << 1) | ((x >> 1) & 0x55555555);
x = ((x & 0x33333333) << 2) | ((x >> 2) & 0x33333333);
x = ((x & 0x0F0F0F0F) << 4) | ((x >> 4) & 0x0F0F0F0F);
x = (x << 24) | ((x & 0xFF00) << 8) |
((x >> 8) & 0xFF00) | (x >> 24);
return x;
}

/**************************************************************************************************
* Slow but correct CRC32
*/
uint32_t crc32(uint8_t *buffer, uint32_t buffer_length)
{
int32_t i, j;
uint32_t byte, crc;

i = 0;
crc = 0xFFFFFFFF;

while (buffer_length--)
{
byte = *buffer++;
byte = reverse(byte);

for (j = 0; j < 8; j++)
{
if ((int32_t)(crc ^ byte) < 0)
crc = (crc << 1) ^ 0x04C11DB7;
else
crc <<= 1;
byte <<= 1;
}
i++;
}

return reverse(~crc);
}
3 changes: 3 additions & 0 deletions pc/hid_bootloader/crc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// crc.h

extern uint32_t crc32(uint8_t *buffer, uint32_t buffer_length);
Loading

0 comments on commit 20c10f6

Please sign in to comment.