docs: Move Mega 2560 information to separate file

Make a more comprehensive document describing the Mega 2560 and FPC
breakout board.
This commit is contained in:
Tim Crawford 2020-08-07 15:51:47 -06:00 committed by Jeremy Soller
parent babcc970c4
commit 2414476a66
2 changed files with 79 additions and 22 deletions

View File

@ -13,27 +13,12 @@ external USB keyboard or SSH session.
Requirements:
- Arduino Mega 2560 compatible board
- 24 pin flexible printed circuit
- 24 pin FPC breakout board and cables
- 0.5mm or 1.0mm pitch, depending on target connector
- 24 pin FPC breakout board with connectors
- USB-C cable
### Configuring the Mega 2560
If the breakout board did not come preassembled, assemble it before
starting. This will require soldering.
1. Connect the breakout board to the Mega 2560
- Orientation will affect the mapping of GPIO pins
2. Connect the Mega 2560 to the host
3. Configure GPIO pin mapping in `parallel.c` based on how it will
connect to the target parallel port
- Trace pin 1 on motherboard connector to Mega's GPIO pins
4. Build and flash the firmware for the Mega 2560
```
make BOARD=arduino/mega2560
make BOARD=arduino/mega2560 flash
```
For details on configuring the Mega 2560 and breakout board, see
[mega2560](./mega2560.md).
### Setup
@ -44,10 +29,10 @@ make BOARD=arduino/mega2560 flash
3. Remove bottom panel
4. Unplug keyboard cable
- May require removing keyboard depending on port location
5. Connect Mega 2560 to host
- This will create an ACM device at `/dev/ttyACM*`
6. Ground target to host
5. Ground target to host
- Connect USB cable from USB-C port on target to host
6. Connect Mega 2560 to host
- This will create an ACM device at `/dev/ttyACM*`
7. Connect Mega 2560 to target
8. Start the console
```
@ -57,7 +42,7 @@ make BOARD=system76/<model> console_external
EC logs should now print to the console on the host. This can be tested
by removing or inserting the AC adapter to trigger a power event.
To return the Mega to host mode, reset the device.
To return the Mega 2560 to host mode, reset the device.
If logs are corrupted, try power cycling the Mega or reseating the cable.

72
doc/mega2560.md Normal file
View File

@ -0,0 +1,72 @@
# Mega 2560
The Mega 2560 is the recommended tool for EC flashing and debugging.
The Mega 2560 is an open-source hardware design by [Arduino] based on the 8-bit
Atmel ATmega2560. Arduino's official model sells for around 40 USD. Multiple
clones exist, and can be bought for around 15 USD.
## Clone compatibility
Multiple clones of the Arduino Mega 2560 exist. Clones can be used, but must be
compatible with the Arduino model. Some have replaced the ATmega16U2 chip used
for USB communication with a CH340G chip. If it does not explicitly state that
it uses the ATmega16U2, find a different model.
## FPC breakout board
A flexible printed circuit (FPC) breakout board is required. It should have:
- 24 pins with 0.1" (2.54mm) pitch
- One side with 0.5mm pitch FPC connector (for lemp9)
- One side with 1.0mm pitch FPC connector (for all other models)
Depending on the vendor, the connectors may not come soldered to the board (or
at all). A header block will likely not be be provided, so male breakaway
headers will need to be purchased separately.
### Connecting to the Mega 2560
The FPC board should be assembled so the 1.0mm pitch connector faces up. When
connected to the Mega 2560, the FPC connector should face away from the Mega
2560. In this orientation, pin 1 of the FPC connector connects to pin 22 (PA0)
of the Mega 2560.
### Connecting to the laptop
A 24 pin flexible flat cable (FFC) is used to connect the Mega 2560 to the
laptop. It may be worth buying both a set of standard cables (traces exposed on
same side at each end) and reversed cables (traces exposed on opposite sides at
each end). With both, it will always be possible to have pin 1 of the breakout
board go to pin 1 of the keyboard port.
The orientation of the FFC traces can be determined by looking at how the
keyboard connects to its port.
The laptop keyboard may use a 26-pin connection. Ensure that the FFC is aligned
so the traces line up with pins 1-24 on the keyboard port.
A second cable (typically, USB-C) must be used for grounding the target laptop
to the host system (what the Mega 2560 is connected to).
## Firmware
`mega2560/parallel.c` must be modified for the mapping of the keyboard pins to
the GPIO pins.
- [Arduino Mega 2560 pin mapping][PinMapping2560]
Using the orientation described above, pin 1 of the keyboard maps to
- pin 22 (PA0) of the Mega 2560 when using the 1.0mm pitch connector
- pin 45 (PL4) of the Mega 2560 when using the 0.5mm pitch connector
Once the GPIO mapping is updated, the firmware can be compiled and flashed.
```
make BOARD=arduino/mega2560
make BOARD=arduino/mega2560 flash
```
[Arduino]: https://www.arduino.cc/
[PinMapping2560]: https://www.arduino.cc/en/Hacking/PinMapping2560