Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
just-another-jxliu committed Oct 16, 2018
2 parents c2b99b1 + bbc0fe0 commit 0ff0b8f
Show file tree
Hide file tree
Showing 10 changed files with 737 additions and 154 deletions.
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
OUTNAME = mdloader
OBJDIR = build
CC = gcc
CFLAGS = -Wall -Os -std=gnu99
CFLAGS = -Wall -std=gnu99

SRCFILES = mdloader_common.c
SRCFILES = mdloader_common.c mdloader_parser.c
ifeq ($(OS),Windows_NT)
SRCFILES += mdloader_win32.c
else
Expand All @@ -14,6 +14,9 @@ OBJFILES = $(patsubst %.c,%.o,$(SRCFILES))
OBJS = $(addprefix $(OBJDIR)/,$(OBJFILES))

all: $(OBJDIR)/$(OUTNAME)
$(info Copying applets to ${OBJDIR}...)
@cp applet-*.bin $(OBJDIR)
$(info Done!)

$(OBJDIR)/$(OUTNAME): $(OBJS)
$(info Creating $@...)
Expand All @@ -32,3 +35,4 @@ $(OBJS): $(OBJDIR)/%.o : %.c
clean:
$(info Removing $(OBJDIR)...)
@rm -r -f $(OBJDIR)
$(info Done!)
47 changes: 21 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,13 @@

3. Press the reset button on your keyboard.

4. In your terminal, change to the directory where you downloaded the executable.
4. In your terminal, change to the directory where you downloaded the executable and applet-*.bin file(s).

5. **Windows** - Run `mdloader_windows.exe --list`. Copy the port name, e.g. `/dev/ttyACM0`, `/dev/ttyS23`, `/dev/cu.usbmodem234411`.
**Linux** - Run `./mdloader_linux --list`. Copy the port name as described above.
**Mac** - Run `./mdloader_mac --list`. If you downloaded with Mac Safari, run `./mdloader_mac.dms --list`. Copy the port name as described above.
5. **Windows** - Run `mdloader_windows.exe --first --download FILE_NAME --restart`. Replace "FILE_NAME" with the filename of your compiled firmware.
**Linux** - Run `mdloader_linux --first --download FILE_NAME --restart`. Replace "FILE_NAME" with the filename of your compiled firmware.
**Mac** - Run `mdloader_mac --first --download FILE_NAME --restart`. If you downloaded with Mac Safari, run `mdloader_mac.dms --first --download FILE_NAME --restart`. Replace "FILE_NAME" with the filename of your compiled firmware.

6. **Windows** - Run `mdloader_windows.exe --port PORT_NAME --download FILE_NAME --restart`. Replace "PORT_NAME" with the port name you copied in the previous step. Replace "FILE_NAME" with the filename of your compiled firmware.
**Linux** - Run `./mdloader_linux --port PORT_NAME --download FILE_NAME --restart`. Replace "PORT_NAME" and "FILE_NAME" in the command as instructed above.
**Mac** - Run `./mdloader_mac --port PORT_NAME --download FILE_NAME --restart`. If you downloaded with Mac Safari, run `./mdloader_mac.dms --port PORT_NAME --download FILE_NAME --restart`. Replace "PORT_NAME" and "FILE_NAME" in the command as instructed above.

7. Enjoy (important)
6. Enjoy (important)

-----

Expand All @@ -27,8 +23,8 @@ Massdrop Loader is used to read firmware from and write firmware to Massdrop key
## Supported operating systems

Windows XP or greater (32-bit and 64-bit versions, USB Serial driver in drv_win folder)
Linux x86 (32-bit and 64-bit versions)
Mac OS X
Linux x86 (32-bit and 64-bit versions)
Mac OS X

## Supported devices

Expand All @@ -40,15 +36,17 @@ Enter mdloader directory where Makefile is located and excute:

`make`

This will create a build/ directory with the compiled executable.
This will create a `build` directory with the compiled executable and required applet-*.bin files.
Run `./build/mdloader` to test.
Note that the target MCU applet file must exist in the directory the executable is called from.

## Usage
```
Usage: mdloader [options] ...
-h --help Print this help message
-v --verbose Print verbose messages
-V --version Print version information
-f --first Use first found device port as programming port
-l --list Print valid attached devices for programming
-p --port port Specify programming port
-U --upload file Read firmware from device into <file>
Expand All @@ -61,27 +59,24 @@ Usage: mdloader [options] ...
--restart Restart device after successful programming
```

To detect connected keyboards ready for programming:

`mdloader --list`

If you do not see your keyboard listed, try pressing the reset button on your keyboard and try again.

Assume for example the listing included a device at port name `THE_PORT`

To write firmware to the device and restart it:

`mdloader --port THE_PORT --download new_firmware.bin --restart`
`mdloader --first --download new_firmware.hex --restart`

The program will now be searching for your device. Press the reset switch found through the small hole on the back case or by appropriate key sequence to enter programming mode and allow programming to commence.
Firmware may be provided as a binary ending in .bin or an Intel HEX format ending in .hex, but .hex is preferred for data integrity.
Note that safeguards are in place to prevent overwriting the bootloader section of the device.

To read firmware from the device:

`mdloader --port THE_PORT --upload read_firmware.bin --addr 0x4000 --size 0x10000`
`mdloader --first --upload read_firmware.bin --addr 0x4000 --size 0x10000`

Test mode may be used to test operations, just use the -t or --test switch.
Test mode also allows viewing of binary data from a read instead of writing to a file.
Where --addr and --size are set as desired.
Note the output of reading firmware will be in binary format.

You may also use the --restart switch to boot the keyboard into operating mode.
Test mode may be invoked with the --test switch to test operations while preventing firmware modification.
Test mode also allows viewing of binary data from a read instead of writing to a file.

## Troubleshooting

Linux: User may need to be added to group dialout to access programming port
Linux: User may need to be added to group dialout to access programming port
Binary file modified applet-flash-samd51j18a.bin
Binary file not shown.
12 changes: 11 additions & 1 deletion atmel/applet.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@
#define APPLET_CMD_READ_FUSES 0x43
/** Applet erase application section command */
#define APPLET_CMD_ERASE_APP 0x44

/** Applet information command */ //Massdrop Specific
#define APPLET_CMD_INFO 0xF0

/** Operation was successful.*/
#define APPLET_SUCCESS 0x00
Expand Down Expand Up @@ -280,6 +281,15 @@ typedef struct mailbox_s {

/** Output arguments for the erase app command */
/** NONE */

/** Input arguments for information command */ //Massdrop Specific
/** NONE */

/** Output arguments for information command */ //Massdrop Specific
struct {
/** Applet version number */
uint16_t version_number;
} outputInfo;
} argument;
} mailbox_t;

Expand Down
Loading

0 comments on commit 0ff0b8f

Please sign in to comment.