Skip to content

Commit 0ff0b8f

Browse files
Merge remote-tracking branch 'upstream/master'
2 parents c2b99b1 + bbc0fe0 commit 0ff0b8f

File tree

10 files changed

+737
-154
lines changed

10 files changed

+737
-154
lines changed

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
OUTNAME = mdloader
22
OBJDIR = build
33
CC = gcc
4-
CFLAGS = -Wall -Os -std=gnu99
4+
CFLAGS = -Wall -std=gnu99
55

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

1616
all: $(OBJDIR)/$(OUTNAME)
17+
$(info Copying applets to ${OBJDIR}...)
18+
@cp applet-*.bin $(OBJDIR)
19+
$(info Done!)
1720

1821
$(OBJDIR)/$(OUTNAME): $(OBJS)
1922
$(info Creating $@...)
@@ -32,3 +35,4 @@ $(OBJS): $(OBJDIR)/%.o : %.c
3235
clean:
3336
$(info Removing $(OBJDIR)...)
3437
@rm -r -f $(OBJDIR)
38+
$(info Done!)

README.md

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,13 @@
66

77
3. Press the reset button on your keyboard.
88

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

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

15-
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.
16-
**Linux** - Run `./mdloader_linux --port PORT_NAME --download FILE_NAME --restart`. Replace "PORT_NAME" and "FILE_NAME" in the command as instructed above.
17-
**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.
18-
19-
7. Enjoy (important)
15+
6. Enjoy (important)
2016

2117
-----
2218

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

2925
Windows XP or greater (32-bit and 64-bit versions, USB Serial driver in drv_win folder)
30-
Linux x86 (32-bit and 64-bit versions)
31-
Mac OS X
26+
Linux x86 (32-bit and 64-bit versions)
27+
Mac OS X
3228

3329
## Supported devices
3430

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

4137
`make`
4238

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

4643
## Usage
4744
```
4845
Usage: mdloader [options] ...
4946
-h --help Print this help message
5047
-v --verbose Print verbose messages
5148
-V --version Print version information
49+
-f --first Use first found device port as programming port
5250
-l --list Print valid attached devices for programming
5351
-p --port port Specify programming port
5452
-U --upload file Read firmware from device into <file>
@@ -61,27 +59,24 @@ Usage: mdloader [options] ...
6159
--restart Restart device after successful programming
6260
```
6361

64-
To detect connected keyboards ready for programming:
65-
66-
`mdloader --list`
67-
68-
If you do not see your keyboard listed, try pressing the reset button on your keyboard and try again.
69-
70-
Assume for example the listing included a device at port name `THE_PORT`
71-
7262
To write firmware to the device and restart it:
7363

74-
`mdloader --port THE_PORT --download new_firmware.bin --restart`
64+
`mdloader --first --download new_firmware.hex --restart`
65+
66+
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.
67+
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.
68+
Note that safeguards are in place to prevent overwriting the bootloader section of the device.
7569

7670
To read firmware from the device:
7771

78-
`mdloader --port THE_PORT --upload read_firmware.bin --addr 0x4000 --size 0x10000`
72+
`mdloader --first --upload read_firmware.bin --addr 0x4000 --size 0x10000`
7973

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

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

8580
## Troubleshooting
8681

87-
Linux: User may need to be added to group dialout to access programming port
82+
Linux: User may need to be added to group dialout to access programming port

applet-flash-samd51j18a.bin

44 Bytes
Binary file not shown.

atmel/applet.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@
7777
#define APPLET_CMD_READ_FUSES 0x43
7878
/** Applet erase application section command */
7979
#define APPLET_CMD_ERASE_APP 0x44
80-
80+
/** Applet information command */ //Massdrop Specific
81+
#define APPLET_CMD_INFO 0xF0
8182

8283
/** Operation was successful.*/
8384
#define APPLET_SUCCESS 0x00
@@ -280,6 +281,15 @@ typedef struct mailbox_s {
280281

281282
/** Output arguments for the erase app command */
282283
/** NONE */
284+
285+
/** Input arguments for information command */ //Massdrop Specific
286+
/** NONE */
287+
288+
/** Output arguments for information command */ //Massdrop Specific
289+
struct {
290+
/** Applet version number */
291+
uint16_t version_number;
292+
} outputInfo;
283293
} argument;
284294
} mailbox_t;
285295

0 commit comments

Comments
 (0)