aboutsummaryrefslogtreecommitdiffstats
path: root/docs/ja/getting_started_make_guide.md
blob: d33485ce111465096a4884ee13b0b099551fa088 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# より詳細な `make` 手順

<!---
  original document: 5f35203d1:docs/getting_started_make_guide.md
  git diff 5f35203d1 HEAD -- docs/getting_started_make_guide.md | cat
-->

`make` コマンドの完全な構文は `<keyboard_folder>:<keymap>:<target>` です:

* `<keyboard_folder>` はキーボードのパスです。例えば、`planck`
   * 全てのキーボードをコンパイルするには `all` を使います。
   * リビジョンを選択してコンパイルするためのパスを指定します。例えば `planck/rev4` あるいは `planck/rev3`
   * キーボードにフォルダが無い場合は、省略することができます
   * デフォルトのフォルダをコンパイルする場合は、省略することができます
* `<keymap>` はキーマップの名前です。例えば、`algernon`
   * 全てのキーマップをコンパイルするには `all` を使います。
* `<target>` の詳細は以下で説明します。

`<target>` は以下を意味します
* target が指定されない場合は、以下の `all` と同じです
* `all` は指定されたキーボード/リビジョン/キーマップの可能な全ての組み合わせのコンパイルを行います。例えば、`make planck/rev4:default` は1つの .hex を生成しますが、`make planck/rev4:all` は planck で利用可能な全てのキーマップについて hex を生成します。
* `flash`、`dfu`、`teensy`、`avrdude`、`dfu-util` または `bootloadHID` はファームウェアをコンパイルし、キーボードにアップロードします。コンパイルが失敗すると、何もアップロードされません。使用するプログラマはキーボードに依存します。ほとんどのキーボードでは `dfu` ですが、ChibiOS キーボードについては `dfu-util` 、標準的な Teensy については `teensy` を使います。キーボードに使うコマンドを見つけるには、キーボード固有の readme をチェックしてください。
* **注意**: 一部のオペレーティングシステムではこれらのコマンドが機能するためには root アクセスが必要です。その場合、例えば `sudo make planck/rev4:default:flash` を実行する必要があります。
* `clean` は、全てをゼロからビルドするためにビルド出力フォルダを掃除します。説明できない問題がある場合は、通常のコンパイルの前にこれを実行してください。

make コマンドの最後、つまり target の後に追加のオプションを追加することもできます

* `make COLOR=false` - カラー出力をオフ
* `make SILENT=true` - エラー/警告以外の出力をオフ
* `make VERBOSE=true` - 全ての gcc のものを出力 (デバッグする必要が無い限り面白くありません)
* `make EXTRAFLAGS=-E` - コンパイルせずにコードを前処理 (#define コマンドをデバッグしようとする場合に便利)

make コマンド自体にもいくつかの追加オプションがあります。詳細は `make --help` を入力してください。最も有用なのはおそらく `-jx` です。これは複数の CPU を使ってコンパイルしたいことを指定し、`x` は使用したい CPU の数を表します。設定すると、特に多くのキーボード/キーマップをコンパイルしている場合は、コンパイル時間を大幅に短縮することができます。通常は、コンパイル中に他の作業を行うための余裕をもたせるために、持っている CPU の数より1つ少ない値に設定します。全てのオペレーティングシステムと make バージョンがオプションをサポートしているわけではないことに注意してください。

コマンドの例を幾つか示します

* `make all:all` は、全てをビルドします (全てのキーボードフォルダ、全てのキーマップ)。`root` から単に `make` を実行すると、これを実行します。
* `make ergodox_infinity:algernon:clean` は、Ergodox Infinity キーボードのビルド出力を掃除します。
* `make planck/rev4:default:flash COLOR=false` カラー出力なしでキーマップをビルドしアップロードします。

## `rules.mk` オプション

無効にするにはこれらの変数を `no` に設定します。有効にするには `yes` に設定します。

`BOOTMAGIC_ENABLE`

これにより、1つのキーとソルトキー(デフォルトではスペース)を押し続けることで、電力が失われても持続する様々な EEPROM 設定へアクセスできます。誤って設定が変更されることが多く、デバッグするのが難しい混乱した結果を生成するため、これを無効にしておくことをお勧めします。ヘルプセッションで発生する、より一般的な問題の1つです。

`MOUSEKEY_ENABLE`

これにより、キーコード/カスタム関数を介して、カーソルの動きとクリックを制御することができます。

`EXTRAKEY_ENABLE`

これにより、システムとオーディオ制御キーコードを使うことができます。

`CONSOLE_ENABLE`

これにより、[`hid_listen`](https://www.pjrc.com/teensy/hid_listen.html) を使って読むことができるメッセージを出力することができます。

デフォルトで、全てのデバッグ( *dprint* ) 出力 ( *print*、*xprintf* )、およびユーザ出力 ( *uprint* ) メッセージが有効になります。これにより、フラッシュメモリの大部分が消費され、キーボードの .hex ファイルが大きすぎてプログラムできなくなるかもしれません。

デバッグメッセージ( *dprint* ) を無効にし、.hex ファイルのサイズを小さくするには、`config.h` に `#define NO_DEBUG` を含めます。

出力メッセージ( *print*、*xprintf* )とユーザ出力( *uprint* ) を無効にし、.hex のファイルサイズを小さくするには、`config.h` に `#define NO_PRINT` を含めます。

出力メッセージ ( *print*、*xprintf* ) を無効にし、ユーザメッセージ ( *uprint* )を**そのままにする**には、`config.h` に `#define USER_PRINT` を含めます(この場合は、`#define NO_PRINT` も含めないでください)。

テキストを見るには、`hid_listen` を開き、出力メッセージを見るのを楽しんでください。

**注意:** キーマップコード以外の *uprint* メッセージを含めないでください。QMK システムフレームワーク内で使うべきではありません。さもないと、他の人の .hex ファイルが肥大化します。

`COMMAND_ENABLE`

これはマジックコマンドを有効にし、通常はデフォルトのマジックキーの組み合わせ `LSHIFT+RSHIFT+KEY` で起動されます。マジックコマンドは、デバッグメッセージ (`MAGIC+D`) の有効化や NKRO の一時的な切り替え (`MAGIC+N`) を含みます。

`SLEEP_LED_ENABLE`

コンピュータがスリープの間に LED がブレスできるようにします。ここでは Timer1 が使われます。この機能は大部分が未使用でテストされておらず、更新もしくは抽象化が必要です。

`NKRO_ENABLE`

これにより、キーボードはホスト OS に最大 248 個のキーが同時に押されていることを伝えることができます (NKRO 無しのデフォルトは 6 です)。NKRO は、`NKRO_ENABLE` が設定されていたとしても、デフォルトではオフです。config.h に `#define FORCE_NKRO` を追加するか、`MAGIC_TOGGLE_NKRO` をキーにバインドしてキーを押すことで、NKRO を強制することができます。

`BACKLIGHT_ENABLE`

これはスイッチ内の LED のバックライトを有効にします。`config.h` 内に以下を入れることでバックライトピンを指定することができます:

    #define BACKLIGHT_PIN B7

`MIDI_ENABLE`

キーボードで MIDI の送受信を有効にします。MIDI 送信モードに入るためにキーコード `MI_ON` を使うことができ、オフにするために `MI_OFF` を使うことができます。これはほとんどテストされていない機能ですが、詳細については `quantum/quantum.c` ファイルで見つけることができます。

`UNICODE_ENABLE`

これによりキーマップで `UC(<code point>)` を使って Unicode 文字を送信することができます。`0x7FFF` までのコードポイントがサポートされます。これはほとんどの現代言語の文字と記号を対象にしますが、絵文字は対象外です。

`UNICODEMAP_ENABLE`

これによりキーマップで `X(<map index>)` を使って Unicode 文字を送信することができます。キーマップファイル内にマッピングテーブルを保持する必要があります。可能な全てのコードポイント( `0x10FFFF` まで)がサポートされます。

`UCIS_ENABLE`

これにより、送信したい文字に対応するニーモニックを入力することで Unicode 文字を送信することができます。キーマップファイル内にマッピングテーブルを保持する必要があります。可能な全てのコードポイント( `0x10FFFF` まで)がサポートされます。

詳細と制限については、[Unicode ページ](ja/feature_unicode.md) を見てください。

`BLUETOOTH_ENABLE`

これによりキーコードをワイヤレスで送信するために Bluefruit EZ-key と連動することができます。D2 と D3 ピンを使います。

`AUDIO_ENABLE`

C6 ピン(抽象化が必要)でオーディオ出力できます。詳細は[オーディオページ](ja/feature_audio.md)を見てください。

`FAUXCLICKY_ENABLE`

クリック音のあるスイッチをエミュレートするためにブザーを使います。Cherry社製の青軸スイッチの安っぽい模倣です。デフォルトでは、`AUDIO_ENABLE` と同じように C6 ピンを使います。

`VARIABLE_TRACE`

これを使って変数の値の変更をデバッグします。詳細についてはユニットテストのページの[変数のトレース](ja/unit_testing.md#tracing-variables)のセクションを見てください。

`API_SYSEX_ENABLE`

これにより Quantum SYSEX API を使って文字列を送信することができます (どこに?)

`KEY_LOCK_ENABLE`

これは [キーロック](ja/feature_key_lock.md) を有効にします。

`SPLIT_KEYBOARD`

分割キーボード (let's split や bakingpy's boards のようなデュアル MCU) のサポートを有効にし、quantum/split_common にある全ての必要なファイルをインクルードします

`SPLIT_TRANSPORT`

ARM ベースの分割キーボード用の標準分割通信ドライバはまだ無いため、これらのために `SPLIT_TRANSPORT = custom` を使わなければなりません。カスタムの実装が使われるようにすることで、標準の分割キーボード通信コード(AVR 固有)が含まれないようにします。

`CUSTOM_MATRIX`

デフォルトのマトリックス走査ルーチンを独自のコードで置き換えます。詳細については、[カスタムマトリックスページ](ja/custom_matrix.md) を見てください。

`DEBOUNCE_TYPE`

デフォルトのキーデバウンスルーチンを別のものに置き換えます。`custom` の場合、独自の実装を提供する必要があります。

## キーマップごとに Makefile オプションをカスタマイズ

あなたのキーマップディレクトリに `rules.mk` というファイルがある場合、そのファイルで設定した全てのオプションは、あなたのキーボードの他の `rules.mk` オプションよりも優先されます。

あなたのキーボードの `rules.mk``BACKLIGHT_ENABLE = yes` があるとします。あなたの特定のキーボードでバックライトが無いようにするには、`rules.mk` というファイルを作成し、`BACKLIGHT_ENABLE = no` を指定します。
by two since USB * communicates power requirements in units of 2 mA.] */ #define USB_CFG_IMPLEMENT_FN_WRITE 1 /* Set this to 1 if you want usbFunctionWrite() to be called for control-out * transfers. Set it to 0 if you don't need it and want to save a couple of * bytes. */ #define USB_CFG_IMPLEMENT_FN_READ 0 /* Set this to 1 if you need to send control replies which are generated * "on the fly" when usbFunctionRead() is called. If you only want to send * data from a static buffer, set it to 0 and return the data from * usbFunctionSetup(). This saves a couple of bytes. */ #define USB_CFG_IMPLEMENT_FN_WRITEOUT 0 /* Define this to 1 if you want to use interrupt-out (or bulk out) endpoints. * You must implement the function usbFunctionWriteOut() which receives all * interrupt/bulk data sent to any endpoint other than 0. The endpoint number * can be found in 'usbRxToken'. */ #define USB_CFG_HAVE_FLOWCONTROL 0 /* Define this to 1 if you want flowcontrol over USB data. See the definition * of the macros usbDisableAllRequests() and usbEnableAllRequests() in * usbdrv.h. */ #define USB_CFG_LONG_TRANSFERS 0 /* Define this to 1 if you want to send/receive blocks of more than 254 bytes * in a single control-in or control-out transfer. Note that the capability * for long transfers increases the driver size. */ /* #define USB_RX_USER_HOOK(data, len) if(usbRxToken == (uchar)USBPID_SETUP) blinkLED(); */ /* This macro is a hook if you want to do unconventional things. If it is * defined, it's inserted at the beginning of received message processing. * If you eat the received message and don't want default processing to * proceed, do a return after doing your things. One possible application * (besides debugging) is to flash a status LED on each packet. */ #if CALIBRATE_OSCCAL #ifndef __ASSEMBLER__ #include <avr/interrupt.h> /* for sei() */ extern void calibrateOscillator(void); #endif #define USB_RESET_HOOK(resetStarts) if(!resetStarts){cli(); calibrateOscillator(); sei();} #endif /* This macro is a hook if you need to know when an USB RESET occurs. It has * one parameter which distinguishes between the start of RESET state and its * end. */ /* #define USB_SET_ADDRESS_HOOK() hadAddressAssigned(); */ /* This macro (if defined) is executed when a USB SET_ADDRESS request was * received. */ #define USB_COUNT_SOF 0 /* define this macro to 1 if you need the global variable "usbSofCount" which * counts SOF packets. This feature requires that the hardware interrupt is * connected to D- instead of D+. */ #if TUNE_OSCCAL #define TIMER0_PRESCALING 64 /* must match the configuration for TIMER0 in main */ #define TOLERATED_DEVIATION_PPT 5 /* max clock deviation before we tune in 1/10 % */ /* derived constants: */ #define EXPECTED_TIMER0_INCREMENT ((F_CPU / (1000 * TIMER0_PRESCALING)) & 0xff) #define TOLERATED_DEVIATION (TOLERATED_DEVIATION_PPT * F_CPU / (1000000 * TIMER0_PRESCALING)) #ifdef __ASSEMBLER__ macro tuneOsccal push YH in YL, TCNT0 lds YH, lastTimer0Value sts lastTimer0Value, YL sub YL, YH ; time passed since last frame subi YL, EXPECTED_TIMER0_INCREMENT in YH, OSCCAL cpi YL, TOLERATED_DEVIATION + 1 brmi notTooHigh subi YH, 1 ; clock rate was too high ; brcs tuningOverflow ; optionally check for overflow rjmp osctuneDone notTooHigh: cpi YL, -TOLERATED_DEVIATION brpl osctuneDone ; not too low inc YH ; clock rate was too low ; breq tuningOverflow ; optionally check for overflow osctuneDone: out OSCCAL, YH ; store tuned value tuningOverflow: pop YH endm #endif #define USB_SOF_HOOK tuneOsccal #endif /* TUNE_OSCCAL */ /* #ifdef __ASSEMBLER__ * macro myAssemblerMacro * in YL, TCNT0 * sts timer0Snapshot, YL * endm * #endif * #define USB_SOF_HOOK myAssemblerMacro * This macro (if defined) is executed in the assembler module when a * Start Of Frame condition is detected. It is recommended to define it to * the name of an assembler macro which is defined here as well so that more * than one assembler instruction can be used. The macro may use registers * YL and YH and SREG. * What can you do with this hook? Since the SOF signal occurs exactly every * 1 ms (unless the host is in sleep mode), you can use it to tune OSCCAL in * designs running on the internal RC oscillator. * Please note that Start Of Frame detection works only if D- is wired to the * interrupt, not D+. THIS IS DIFFERENT THAN MOST EXAMPLES! */ #define USB_CFG_CHECK_DATA_TOGGLING 0 /* define this macro to 1 if you want to filter out duplicate data packets * sent by the host. Duplicates occur only as a consequence of communication * errors, when the host does not receive an ACK. Please note that you need to * implement the filtering yourself in usbFunctionWriteOut() and * usbFunctionWrite(). Use the global usbCurrentDataToken and a static variable * for each control- and out-endpoint to check for duplicate packets. */ #define USB_CFG_HAVE_MEASURE_FRAME_LENGTH 1 /* define this macro to 1 if you want the function usbMeasureFrameLength() * compiled in. This function can be used to calibrate the AVR's RC oscillator. */ /* -------------------------- Device Description --------------------------- */ #define USB_CFG_VENDOR_ID 0xc0, 0x16 /* USB vendor ID for the device, low byte first. If you have registered your * own Vendor ID, define it here. Otherwise you use one of obdev's free shared * VID/PID pairs. Be sure to read USB-IDs-for-free.txt for rules! */ #define USB_CFG_DEVICE_ID 0xdc, 0x05 /* This is the ID of the product, low byte first. It is interpreted in the * scope of the vendor ID. If you have registered your own VID with usb.org * or if you have licensed a PID from somebody else, define it here. Otherwise * you use obdev's free shared VID/PID pair. Be sure to read the rules in * USB-IDs-for-free.txt! */ #define USB_CFG_DEVICE_VERSION 0x00, 0x01 /* Version number of the device: Minor number first, then major number. */ #define USB_CFG_VENDOR_NAME 'o', 'b', 'd', 'e', 'v', '.', 'a', 't' #define USB_CFG_VENDOR_NAME_LEN 8 /* These two values define the vendor name returned by the USB device. The name * must be given as a list of characters under single quotes. The characters * are interpreted as Unicode (UTF-16) entities. * If you don't want a vendor name string, undefine these macros. * ALWAYS define a vendor name containing your Internet domain name if you use * obdev's free shared VID/PID pair. See the file USB-IDs-for-free.txt for * details. */ #define USB_CFG_DEVICE_NAME 'T', 'e', 's', 't' #define USB_CFG_DEVICE_NAME_LEN 4 /* Same as above for the device name. If you don't want a device name, undefine * the macros. See the file USB-IDs-for-free.txt before you assign a name if * you use a shared VID/PID. */ /*#define USB_CFG_SERIAL_NUMBER 'N', 'o', 'n', 'e' */ /*#define USB_CFG_SERIAL_NUMBER_LEN 0 */ /* Same as above for the serial number. If you don't want a serial number, * undefine the macros. * It may be useful to provide the serial number through other means than at * compile time. See the section about descriptor properties below for how * to fine tune control over USB descriptors such as the string descriptor * for the serial number. */ #define USB_CFG_DEVICE_CLASS 0xff /* set to 0 if deferred to interface */ #define USB_CFG_DEVICE_SUBCLASS 0 /* See USB specification if you want to conform to an existing device class. * Class 0xff is "vendor specific". */ #define USB_CFG_INTERFACE_CLASS 0 /* define class here if not at device level */ #define USB_CFG_INTERFACE_SUBCLASS 0 #define USB_CFG_INTERFACE_PROTOCOL 0 /* See USB specification if you want to conform to an existing device class or * protocol. The following classes must be set at interface level: * HID class is 3, no subclass and protocol required (but may be useful!) * CDC class is 2, use subclass 2 and protocol 1 for ACM */ /* #define USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH 42 */ /* Define this to the length of the HID report descriptor, if you implement * an HID device. Otherwise don't define it or define it to 0. * If you use this define, you must add a PROGMEM character array named * "usbHidReportDescriptor" to your code which contains the report descriptor. * Don't forget to keep the array and this define in sync! */ /* #define USB_PUBLIC static */ /* Use the define above if you #include usbdrv.c instead of linking against it. * This technique saves a couple of bytes in flash memory. */ /* ------------------- Fine Control over USB Descriptors ------------------- */ /* If you don't want to use the driver's default USB descriptors, you can * provide our own. These can be provided as (1) fixed length static data in * flash memory, (2) fixed length static data in RAM or (3) dynamically at * runtime in the function usbFunctionDescriptor(). See usbdrv.h for more * information about this function. * Descriptor handling is configured through the descriptor's properties. If * no properties are defined or if they are 0, the default descriptor is used. * Possible properties are: * + USB_PROP_IS_DYNAMIC: The data for the descriptor should be fetched * at runtime via usbFunctionDescriptor(). If the usbMsgPtr mechanism is * used, the data is in FLASH by default. Add property USB_PROP_IS_RAM if * you want RAM pointers. * + USB_PROP_IS_RAM: The data returned by usbFunctionDescriptor() or found * in static memory is in RAM, not in flash memory. * + USB_PROP_LENGTH(len): If the data is in static memory (RAM or flash), * the driver must know the descriptor's length. The descriptor itself is * found at the address of a well known identifier (see below). * List of static descriptor names (must be declared PROGMEM if in flash): * char usbDescriptorDevice[]; * char usbDescriptorConfiguration[]; * char usbDescriptorHidReport[]; * char usbDescriptorString0[]; * int usbDescriptorStringVendor[]; * int usbDescriptorStringDevice[]; * int usbDescriptorStringSerialNumber[]; * Other descriptors can't be provided statically, they must be provided * dynamically at runtime. * * Descriptor properties are or-ed or added together, e.g.: * #define USB_CFG_DESCR_PROPS_DEVICE (USB_PROP_IS_RAM | USB_PROP_LENGTH(18)) * * The following descriptors are defined: * USB_CFG_DESCR_PROPS_DEVICE * USB_CFG_DESCR_PROPS_CONFIGURATION * USB_CFG_DESCR_PROPS_STRINGS * USB_CFG_DESCR_PROPS_STRING_0 * USB_CFG_DESCR_PROPS_STRING_VENDOR * USB_CFG_DESCR_PROPS_STRING_PRODUCT * USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER * USB_CFG_DESCR_PROPS_HID * USB_CFG_DESCR_PROPS_HID_REPORT * USB_CFG_DESCR_PROPS_UNKNOWN (for all descriptors not handled by the driver) * * Note about string descriptors: String descriptors are not just strings, they * are Unicode strings prefixed with a 2 byte header. Example: * int serialNumberDescriptor[] = { * USB_STRING_DESCRIPTOR_HEADER(6), * 'S', 'e', 'r', 'i', 'a', 'l' * }; */ #define USB_CFG_DESCR_PROPS_DEVICE 0 #define USB_CFG_DESCR_PROPS_CONFIGURATION 0 #define USB_CFG_DESCR_PROPS_STRINGS 0 #define USB_CFG_DESCR_PROPS_STRING_0 0 #define USB_CFG_DESCR_PROPS_STRING_VENDOR 0 #define USB_CFG_DESCR_PROPS_STRING_PRODUCT 0 #define USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER 0 #define USB_CFG_DESCR_PROPS_HID 0 #define USB_CFG_DESCR_PROPS_HID_REPORT 0 #define USB_CFG_DESCR_PROPS_UNKNOWN 0 /* ----------------------- Optional MCU Description ------------------------ */ /* The following configurations have working defaults in usbdrv.h. You * usually don't need to set them explicitly. Only if you want to run * the driver on a device which is not yet supported or with a compiler * which is not fully supported (such as IAR C) or if you use a differnt * interrupt than INT0, you may have to define some of these. */ //#define USB_INTR_CFG_SET ((1 << ISC01)) /* cfg for falling edge */ /* #define USB_INTR_CFG MCUCR */ /* #define USB_INTR_CFG_SET ((1 << ISC00) | (1 << ISC01)) */ /* #define USB_INTR_CFG_CLR 0 */ /* #define USB_INTR_ENABLE GIMSK */ /* #define USB_INTR_ENABLE_BIT INT0 */ /* #define USB_INTR_PENDING GIFR */ /* #define USB_INTR_PENDING_BIT INTF0 */ /* #define USB_INTR_VECTOR SIG_INTERRUPT0 */ #endif /* __usbconfig_h_included__ */